|
@@ -1,20 +1,19 @@
|
|
|
<template>
|
|
|
<view>
|
|
|
- <view class="cmain">
|
|
|
+ <view class="cmain animated fadeInDown">
|
|
|
<view class="form_group">
|
|
|
<view class="lable re">贸易区域</view>
|
|
|
- <picker :range="tradeAreaList" @change="pickerTradeArea($event)" range-key="name">
|
|
|
+ <picker @click="selectArea()" :disabled="true">
|
|
|
<input placeholder="请选择" v-model="item.tradeAreaName" :disabled="true" />
|
|
|
<view class="icon more"></view>
|
|
|
</picker>
|
|
|
</view>
|
|
|
<view class="form_group">
|
|
|
<view class="lable re">商品名称</view>
|
|
|
- <picker v-if="flag === '新增商品'" :range="goodsList" @change="pickerGoods($event)" range-key="name">
|
|
|
+ <picker @click="selectGoods()" :disabled="true">
|
|
|
<input placeholder="请选择" v-model="item.goodsName" :disabled="true" />
|
|
|
<view class="icon more"></view>
|
|
|
</picker>
|
|
|
- <input v-else placeholder="请选择" v-model="item.goodsName" :disabled="true" disabled="true"/>
|
|
|
</view>
|
|
|
<view class="form_group">
|
|
|
<view class="lable re">商品价格</view>
|
|
@@ -25,7 +24,6 @@
|
|
|
<view class="form_group">
|
|
|
<view class="lable re">商品数量</view>
|
|
|
<input type="number" placeholder="请输入" v-model="item.stock" />
|
|
|
-
|
|
|
</view>
|
|
|
<view class="form_group">
|
|
|
<view class="lable re">净重</view>
|
|
@@ -39,12 +37,15 @@
|
|
|
<view class="ops" v-if="flag === '编辑商品'">{{ item.goodsUnits }}</view>
|
|
|
<view class="ops" v-else>{{ item.unit }}</view>
|
|
|
</view>
|
|
|
- <view class="form_group">
|
|
|
- <view class="lable re">商品状态</view>
|
|
|
- <picker :range="dict.goodsStatus" @change="picker($event, 'goodsStatus')">
|
|
|
- <input placeholder="请选择" :value="item.goodsStatus" :disabled="true" />
|
|
|
- <view class="icon more"></view>
|
|
|
- </picker>
|
|
|
+ </view>
|
|
|
+ <view class="mfooter">
|
|
|
+ <view class="flex">
|
|
|
+ <view class="f">
|
|
|
+ <button class="save btn" @click="save(0)">下架</button>
|
|
|
+ </view>
|
|
|
+ <view class="f">
|
|
|
+ <button class="btn" @click="save(1)">一键发售</button>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -55,106 +56,88 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
flag: '新增商品',
|
|
|
- item: {tradeAreaName:''},
|
|
|
- dict: {
|
|
|
- goodsType: ['水果', '药品', '茶叶'],
|
|
|
- goodsUnits: ['吨', '个', '柜'],
|
|
|
- goodsStatus: ['在售', '下架']
|
|
|
- },
|
|
|
- goodsList: [],
|
|
|
- tradeAreaList: []
|
|
|
+ item: {}
|
|
|
};
|
|
|
},
|
|
|
onLoad(e) {
|
|
|
if (e.id) {
|
|
|
- this.flag = '编辑商品'
|
|
|
+ this.flag = '编辑商品';
|
|
|
this.http.request({
|
|
|
url: '/level-one-server/app/TbGoodsTransit/getById?id=' + e.id,
|
|
|
success: res => {
|
|
|
this.item = res.data.data;
|
|
|
- this.item.goodsStatus = this.item.goodsStatus == 1 ? '在售' : '下架';
|
|
|
- uni.setNavigationBarTitle({ title: '编辑商品' });
|
|
|
+ uni.setNavigationBarTitle({ title: this.item.goodsStatus == 1 ? '编辑商品(在售)' : '编辑商品(下架)' });
|
|
|
}
|
|
|
});
|
|
|
- };
|
|
|
- this.getGoodsList();
|
|
|
- this.getTradeAreaList();
|
|
|
- },
|
|
|
- methods: {
|
|
|
- picker(e, tag) {
|
|
|
- this.item[tag] = this.dict[tag][e.detail.value];
|
|
|
- this.$forceUpdate();
|
|
|
- },
|
|
|
- pickerGoods(e) {
|
|
|
- this.item['goodsName'] = this.goodsList[e.detail.value].name;
|
|
|
- this.item['unit'] = this.goodsList[e.detail.value].unit;
|
|
|
+ }
|
|
|
+ //选择互市回显
|
|
|
+ uni.$on('area', res => {
|
|
|
+ this.item.tradeAreaName = res.name;
|
|
|
+ this.item.tradeAreaId = res.id;
|
|
|
this.$forceUpdate();
|
|
|
- if(this.flag == '新增商品') {
|
|
|
- this.item.id = this.goodsList[e.detail.value].id;
|
|
|
-
|
|
|
+ });
|
|
|
+ //选择商品回显
|
|
|
+ uni.$on('selects', res => {
|
|
|
+ this.item.goodsName = res.name;
|
|
|
+ this.item.unit = res.unit;
|
|
|
+ if (this.flag == '新增商品') {
|
|
|
+ this.item.id = res.id;
|
|
|
}
|
|
|
- },
|
|
|
- pickerTradeArea(e) {
|
|
|
- this.item['tradeAreaName'] = this.tradeAreaList[e.detail.value].name;
|
|
|
this.$forceUpdate();
|
|
|
- this.item.tradeAreaId = this.tradeAreaList[e.detail.value].id;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ //选择互市区
|
|
|
+ selectArea() {
|
|
|
+ uni.navigateTo({ url: '/pages/market/one/merchant/goods/area' });
|
|
|
},
|
|
|
- // 获取监管商品列表
|
|
|
- getGoodsList() {
|
|
|
- this.http.request({
|
|
|
- url: '/level-one-server/app/TbGoods/getList',
|
|
|
- method: 'POST',
|
|
|
- success: res => {
|
|
|
- this.goodsList = res.data.data;
|
|
|
- console.log("监管商品列表",this.goodsList);
|
|
|
- }
|
|
|
- });
|
|
|
+ //选择商品
|
|
|
+ selectGoods() {
|
|
|
+ if (this.item.tradeAreaId) {
|
|
|
+ uni.navigateTo({ url: '/pages/market/one/merchant/goods/selects?tradeAreaId=' + this.item.tradeAreaId + '&tradeAreaName=' + this.item.tradeAreaName });
|
|
|
+ } else {
|
|
|
+ uni.showModal({ content: '请先选择互市区', showCancel: false });
|
|
|
+ return;
|
|
|
+ }
|
|
|
},
|
|
|
- // 获取贸易区域列表
|
|
|
- getTradeAreaList() {
|
|
|
+ save(goodsStatus) {
|
|
|
+ let rule = [
|
|
|
+ { name: 'tradeAreaName', checkType: 'notnull', errorMsg: '请选择互市区' },
|
|
|
+ { name: 'goodsName', checkType: 'notnull', errorMsg: '请选择商品' },
|
|
|
+ { name: 'price', checkType: 'notnull', errorMsg: '请输入商品价格' },
|
|
|
+ { name: 'stock', checkType: 'notnull', errorMsg: '请输入商品数量' },
|
|
|
+ { name: 'netWeight', checkType: 'notnull', errorMsg: '请输入净重' },
|
|
|
+ { name: 'grossWeight', checkType: 'notnull', errorMsg: '请输入毛重' }
|
|
|
+ ];
|
|
|
+ if (!this.verify.check(this.item, rule)) {
|
|
|
+ uni.showModal({ content: this.verify.error, showCancel: false });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let action = this.flag == '新增商品' ? 'add' : 'update';
|
|
|
+ this.item.goodsStatus = goodsStatus;
|
|
|
+ delete this.item.createTime;
|
|
|
+ delete this.item.createBy;
|
|
|
+ delete this.item.createName;
|
|
|
this.http.request({
|
|
|
- url: '/level-one-server/app/TbTradeArea/getList',
|
|
|
+ url: '/level-one-server/app/TbGoodsTransit/' + action,
|
|
|
method: 'POST',
|
|
|
+ data: this.item,
|
|
|
success: res => {
|
|
|
- this.tradeAreaList = res.data.data;
|
|
|
- console.log("贸易区域列表",this.tradeAreaList);
|
|
|
+ uni.showToast({ title: '操作成功' });
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.$emit('goodsHandle');
|
|
|
+ uni.navigateBack();
|
|
|
+ }, 1000);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- },
|
|
|
- onNavigationBarButtonTap() {
|
|
|
- let rule = [
|
|
|
- { name: 'goodsName', checkType: 'notnull', errorMsg: '请输入商品名称' },
|
|
|
- { name: 'goodsStatus', checkType: 'notnull', errorMsg: '请选择状态' }
|
|
|
- ];
|
|
|
- if (!this.verify.check(this.item, rule)) {
|
|
|
- uni.showModal({ content: this.verify.error, showCancel: false });
|
|
|
- return false;
|
|
|
- }
|
|
|
- this.item.goodsStatus = this.item.goodsStatus == '在售' ? 1 : 0;
|
|
|
- let url = '';
|
|
|
- if(this.flag == '新增商品') {
|
|
|
- url = '/level-one-server/app/TbGoodsTransit/transactionGoods';
|
|
|
- } else {
|
|
|
- url = '/level-one-server/app/TbGoodsTransit/update';
|
|
|
- }
|
|
|
- delete this.item.createTime;
|
|
|
- delete this.item.createBy;
|
|
|
- delete this.item.createName;
|
|
|
- this.http.request({
|
|
|
- url: url,
|
|
|
- method: 'POST',
|
|
|
- data: this.item,
|
|
|
- success: res => {
|
|
|
- uni.showToast({ title: '操作成功' });
|
|
|
- setTimeout(() => {
|
|
|
- uni.$emit('goodsHandle');
|
|
|
- uni.navigateBack();
|
|
|
- }, 1000);
|
|
|
- }
|
|
|
- });
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-<style lang="scss"></style>
|
|
|
+<style lang="scss">
|
|
|
+.btn {
|
|
|
+ width: 100%;
|
|
|
+ border-radius: 5px;
|
|
|
+}
|
|
|
+</style>
|