上架多城市修改
This commit is contained in:
parent
2714001875
commit
238d9edb4a
|
|
@ -536,6 +536,14 @@ export default {
|
||||||
})
|
})
|
||||||
return res[1].data;
|
return res[1].data;
|
||||||
},
|
},
|
||||||
|
async editGoods(params = {}) {
|
||||||
|
let res = await uni.request({
|
||||||
|
url: '/goods/goods/app/edit',
|
||||||
|
method: 'POST',
|
||||||
|
data: params
|
||||||
|
})
|
||||||
|
return res[1].data;
|
||||||
|
},
|
||||||
async qryProductDetail(params = {}) {
|
async qryProductDetail(params = {}) {
|
||||||
let res = await uni.request({
|
let res = await uni.request({
|
||||||
url: '/goods/goods/app/detail',
|
url: '/goods/goods/app/detail',
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@
|
||||||
<input name="servName" v-model="formData.servName" placeholder="请编辑上架标题(供客户搜索)"></input>
|
<input name="servName" v-model="formData.servName" placeholder="请编辑上架标题(供客户搜索)"></input>
|
||||||
</view>
|
</view>
|
||||||
<view class="cu-form-group">
|
<view class="cu-form-group">
|
||||||
<view class="title">服务描述<text class="text-red">*</text></view>
|
<view class="title">关键词<text class="text-red">*</text></view>
|
||||||
<input name="servDesc" v-model="formData.servDesc" placeholder="让客户更清晰的上架内容描述"></input>
|
<input name="servDesc" v-model="formData.servDesc" placeholder="多个关键词用#分隔"></input>
|
||||||
</view>
|
</view>
|
||||||
<view class="solid-top">
|
<view class="solid-top">
|
||||||
<view class="cu-form-group">
|
<view class="cu-form-group">
|
||||||
|
|
@ -107,13 +107,13 @@
|
||||||
<!-- </view> -->
|
<!-- </view> -->
|
||||||
<!-- </view> -->
|
<!-- </view> -->
|
||||||
</view>
|
</view>
|
||||||
<view class="cu-form-group solid-top">
|
<view class="cu-form-group solid-top justify-start">
|
||||||
<view class="title">商品单位<text class="text-red">*</text></view>
|
<view class="title">商品单位<text class="text-red">*</text></view>
|
||||||
<my-uni-combox class="form-val-area" :candidates="goodsUnitList" placeholder="上方已填单位则以上方所填为准"
|
<my-uni-combox class="form-val-area" :candidates="goodsUnitList" placeholder="上方已填单位则以上方所填为准"
|
||||||
v-model="formData.goodsUnit">
|
v-model="formData.goodsUnit">
|
||||||
</my-uni-combox>
|
</my-uni-combox>
|
||||||
</view>
|
</view>
|
||||||
<view class="cu-form-group solid-top">
|
<view class="cu-form-group justify-start">
|
||||||
<view class="title">质保期</view>
|
<view class="title">质保期</view>
|
||||||
<my-uni-combox class="form-val-area" :candidates="warrantyPeriodList" placeholder="请选择"
|
<my-uni-combox class="form-val-area" :candidates="warrantyPeriodList" placeholder="请选择"
|
||||||
v-model="formData.warrantyPeriod">
|
v-model="formData.warrantyPeriod">
|
||||||
|
|
@ -165,6 +165,48 @@
|
||||||
<textarea name="areaDesc" style="width: 100%; height: 150rpx;" class="solid radius text-left padding-sm"
|
<textarea name="areaDesc" style="width: 100%; height: 150rpx;" class="solid radius text-left padding-sm"
|
||||||
v-model="formData.areaDesc" maxlength="-1" placeholder="如:XX区XX街道未覆盖或XX区仅服务XX街道"></textarea>
|
v-model="formData.areaDesc" maxlength="-1" placeholder="如:XX区XX街道未覆盖或XX区仅服务XX街道"></textarea>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- 多城市 -->
|
||||||
|
<view v-for="(item,index) in servArea" class="bg-white">
|
||||||
|
<view class="solid-top">
|
||||||
|
<view @click="delServArea(index)">
|
||||||
|
<button class="cu-btn bg-red light">
|
||||||
|
<text class="margin-right-xs"><text class="cuIcon-close"></text></text>
|
||||||
|
<text>删除</text>
|
||||||
|
</button>
|
||||||
|
</view>
|
||||||
|
<view class="cu-form-group">
|
||||||
|
<view class="title">上架区域<text class="text-red">*</text></view>
|
||||||
|
<picker :mode="'multiSelector'" @change="multiRegionChange($event, index)" @columnchange="multiRegionColChange($event, index)"
|
||||||
|
:value="servArea[index].regionMultiIndex" :range-key="'areaName'" :range="servArea[index].regionList">
|
||||||
|
<input disabled class="line-input radius-input" v-if="servArea[index].region"
|
||||||
|
:value="servArea[index].region && servArea[index].region.length ? servArea[index].region[0].areaName + '-' + servArea[index].region[1].areaName : ''"
|
||||||
|
placeholder="请选择区域"></input>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
<view class="padding-lr bg-white">
|
||||||
|
<checkbox-group @change="multiAreaCheckDistirct($event, index)" class="grid col-3">
|
||||||
|
<view v-for="(item, index1) in servArea[index].districtList" class="margin-tb-xs">
|
||||||
|
<checkbox style="transform:scale(1)" class="main-color margin-right-xs" :value="index1"
|
||||||
|
:checked="item.checked"></checkbox>
|
||||||
|
<text>{{item.areaName}}</text>
|
||||||
|
</view>
|
||||||
|
</checkbox-group>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="cu-bar">
|
||||||
|
<view class="action text-black">区域描述<text class="text-red">*</text></view>
|
||||||
|
</view>
|
||||||
|
<view class="padding-lr-sm padding-bottom-sm">
|
||||||
|
<textarea name="areaDesc" style="width: 100%; height: 150rpx;" class="solid radius text-left padding-sm"
|
||||||
|
v-model="servArea[index].areaDesc" maxlength="-1" placeholder="如:XX区XX街道未覆盖或XX区仅服务XX街道"></textarea>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="text-center padding-bottom bg-white">
|
||||||
|
<button class="cu-btn bg-main-color light" @click="addServArea">
|
||||||
|
<text class="margin-right-xs"><text class="cuIcon-add"></text></text>
|
||||||
|
<text>继续添加上架城市</text>
|
||||||
|
</button>
|
||||||
|
</view>
|
||||||
<!-- <view class="cu-form-group">
|
<!-- <view class="cu-form-group">
|
||||||
<view class="title">上门费</view>
|
<view class="title">上门费</view>
|
||||||
<input type="digit" name="doorPrice" :value="formData.doorPrice" :v-model="formData.doorPrice"
|
<input type="digit" name="doorPrice" :value="formData.doorPrice" :v-model="formData.doorPrice"
|
||||||
|
|
@ -300,6 +342,7 @@
|
||||||
coverImgList: [],
|
coverImgList: [],
|
||||||
videoList: []
|
videoList: []
|
||||||
},
|
},
|
||||||
|
servArea: [],
|
||||||
sysInfo: null,
|
sysInfo: null,
|
||||||
url2Crop: '',
|
url2Crop: '',
|
||||||
cropWidth: 0,
|
cropWidth: 0,
|
||||||
|
|
@ -607,6 +650,20 @@
|
||||||
});
|
});
|
||||||
this.formData.districtList = areaList.data;
|
this.formData.districtList = areaList.data;
|
||||||
},
|
},
|
||||||
|
async multiRegionChange(e, regionIndex) {
|
||||||
|
this.servArea[regionIndex].regionMultiIndex = e.detail.value;
|
||||||
|
let chosenRegion = [];
|
||||||
|
for (let i = 0; i < this.servArea[regionIndex].regionList.length; i++) {
|
||||||
|
chosenRegion.push(this.servArea[regionIndex].regionList[i][this.servArea[regionIndex].regionMultiIndex[i]]);
|
||||||
|
}
|
||||||
|
this.servArea[regionIndex].region = chosenRegion;
|
||||||
|
|
||||||
|
// 查询最后一级区域
|
||||||
|
let areaList = await this.$request.areaListByStep({
|
||||||
|
parentCode: chosenRegion[1].areaCode
|
||||||
|
});
|
||||||
|
this.servArea[regionIndex].districtList = areaList.data;
|
||||||
|
},
|
||||||
async regionColChange(e) {
|
async regionColChange(e) {
|
||||||
let colObj = e.detail;
|
let colObj = e.detail;
|
||||||
if (colObj.column == 0) {
|
if (colObj.column == 0) {
|
||||||
|
|
@ -620,6 +677,19 @@
|
||||||
this.regionMultiIndex = [colObj.value, 0];
|
this.regionMultiIndex = [colObj.value, 0];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async multiRegionColChange(e, regionIndex) {
|
||||||
|
let colObj = e.detail;
|
||||||
|
if (colObj.column == 0) {
|
||||||
|
// 通过一级查二级
|
||||||
|
let subAreaList = await this.$request.areaListByStep({
|
||||||
|
parentCode: this.regionList[0][colObj.value].areaCode
|
||||||
|
});
|
||||||
|
subAreaList = subAreaList.data;
|
||||||
|
this.servArea[regionIndex].regionList.pop();
|
||||||
|
this.servArea[regionIndex].regionList.push(subAreaList);
|
||||||
|
this.servArea[regionIndex].regionMultiIndex = [colObj.value, 0];
|
||||||
|
}
|
||||||
|
},
|
||||||
checkSpecs(e) {
|
checkSpecs(e) {
|
||||||
let checkedIndexArr = e.detail.value;
|
let checkedIndexArr = e.detail.value;
|
||||||
for (let i = 0; i < this.formData.specsList.length; i++) {
|
for (let i = 0; i < this.formData.specsList.length; i++) {
|
||||||
|
|
@ -653,6 +723,16 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
multiAreaCheckDistirct(e, index) {
|
||||||
|
let checkedIndexArr = e.detail.value;
|
||||||
|
for (let i = 0; i < this.servArea[index].districtList.length; i++) {
|
||||||
|
if (checkedIndexArr.indexOf(String(i)) !== -1) {
|
||||||
|
this.servArea[index].districtList[i].checked = true;
|
||||||
|
} else {
|
||||||
|
this.servArea[index].districtList[i].checked = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
chooseImgList(e, imgListField, cropWidth, cropHeight) {
|
chooseImgList(e, imgListField, cropWidth, cropHeight) {
|
||||||
this.cropWidth = cropWidth && cropWidth > 0 ? cropWidth : this.sysInfo.windowWidth * 2;
|
this.cropWidth = cropWidth && cropWidth > 0 ? cropWidth : this.sysInfo.windowWidth * 2;
|
||||||
this.cropHeight = cropHeight && cropHeight > 0 ? cropHeight : this.sysInfo.windowWidth * 2 * 1.15;
|
this.cropHeight = cropHeight && cropHeight > 0 ? cropHeight : this.sysInfo.windowWidth * 2 * 1.15;
|
||||||
|
|
@ -806,7 +886,48 @@
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
validMultiAreaList(list) {
|
||||||
|
let errMsg = null;
|
||||||
|
if (!list || !list.length) {
|
||||||
|
errMsg = '上架区域填写不完整';
|
||||||
|
}
|
||||||
|
if (errMsg) {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: errMsg,
|
||||||
|
duration: 2500
|
||||||
|
})
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
async submit() {
|
async submit() {
|
||||||
|
// 多城市上架区域校验
|
||||||
|
let multiServAreaChecked = true;
|
||||||
|
let multiServAreaList = [];
|
||||||
|
for(let x of this.servArea) {
|
||||||
|
let oneCheckedAreaList = null;
|
||||||
|
if (x && x.districtList && x.districtList.length) {
|
||||||
|
oneCheckedAreaList = x.districtList.filter((item) => {
|
||||||
|
if (item.checked) {
|
||||||
|
item.countryAreaId = item.areaId;
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!this.validMultiAreaList(oneCheckedAreaList)) {
|
||||||
|
multiServAreaChecked = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
multiServAreaList.push({
|
||||||
|
goodsAreaList: oneCheckedAreaList,
|
||||||
|
areaDesc: x.areaDesc
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!multiServAreaChecked) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let goodsStandardList = this.formData.specsList.filter((item) => {
|
let goodsStandardList = this.formData.specsList.filter((item) => {
|
||||||
if (item.checked) {
|
if (item.checked) {
|
||||||
if (!item.goodsStandardName) {
|
if (!item.goodsStandardName) {
|
||||||
|
|
@ -870,15 +991,26 @@
|
||||||
remark: this.formData.detailDesc,
|
remark: this.formData.detailDesc,
|
||||||
areaDesc: this.formData.areaDesc
|
areaDesc: this.formData.areaDesc
|
||||||
}
|
}
|
||||||
console.log(params)
|
|
||||||
|
let res = null;
|
||||||
if (this.goodsId) {
|
if (this.goodsId) {
|
||||||
uni.showToast({
|
res = await this.$request.editGoods({
|
||||||
icon: 'error',
|
...params,
|
||||||
title: '参数缺失'
|
goodsId: this.goodsId
|
||||||
})
|
});
|
||||||
return;
|
} else {
|
||||||
|
res = await this.$request.addGoods(params);
|
||||||
|
}
|
||||||
|
// 如果选了多城市,添加多个服务
|
||||||
|
let index = 0;
|
||||||
|
while(index < multiServAreaList.length && res && res.code === 0) {
|
||||||
|
res = await this.$request.addGoods({
|
||||||
|
...params,
|
||||||
|
goodsAreaList: multiServAreaList[index].goodsAreaList,
|
||||||
|
areaDesc: multiServAreaList[index].areaDesc
|
||||||
|
});
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
let res = await this.$request.addGoods(params);
|
|
||||||
if (res && res.code === 0) {
|
if (res && res.code === 0) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
|
|
@ -887,6 +1019,23 @@
|
||||||
url: '/pages/index/index?menuCode=supplyChainPage'
|
url: '/pages/index/index?menuCode=supplyChainPage'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
async addServArea() {
|
||||||
|
let subRegionList = await this.$request.areaListByStep({
|
||||||
|
parentCode: this.regionList[0][0].areaCode
|
||||||
|
});
|
||||||
|
subRegionList = subRegionList.data;
|
||||||
|
|
||||||
|
this.servArea.push({
|
||||||
|
region: [],
|
||||||
|
districtList: [],
|
||||||
|
areaDesc: null,
|
||||||
|
regionList: [this.regionList[0], subRegionList],
|
||||||
|
regionMultiIndex: [0, 0]
|
||||||
|
});
|
||||||
|
},
|
||||||
|
delServArea(index) {
|
||||||
|
this.servArea.splice(index, 1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue