Commit d669f6aa by chenwq

员工场景产品添加

1 parent 9b66c2c5
......@@ -33,7 +33,7 @@ Page({
},
getProList(sceneCode) {
let { scenceList } = this.data
let { scenceList, addOrEdit, proActList } = this.data
var params = {
sceneCode: sceneCode || ''
}
......@@ -42,6 +42,13 @@ Page({
sceneCodeList.forEach(item => {
let proList = res.find(k => k.sceneCode == item)?.productList
let target = scenceList.find(k => k.sceneCode == item)
if (addOrEdit == 'edit') {
proList.forEach(k => {
if(proActList.includes(k.productCode)) {
k.isCheck = true
}
})
}
target.proList = proList
list.push(target)
})
......@@ -51,6 +58,28 @@ Page({
})
},
getSceneProStatus() {
let { formData } = this.data
var params = {
merchant4sId: formData.merchantId
}
let proActList = []
outputApi.getSceneProStatus(params).then(res => {
console.log(res)
res.forEach(item => {
item.productList.forEach(k => {
if (k.productStatus == 2) {
proActList.push(k.productCode)
}
})
})
this.setData({
proActList: proActList
})
this.getProList()
})
},
getAllServiceList() {
mineServiceApi.getAllServiceList({}).then(res => {
this.setData({
......@@ -101,17 +130,21 @@ Page({
})
},
dealPro() {
dealScenePro() {
let sceneArr = []
let arr = []
let { scenceList } = this.data
scenceList.forEach(item => {
item.proList.forEach(k => {
if(k.isCheck) {
if (k.isCheck) {
arr.push(k.productCode)
if (sceneArr.findIndex(n => n == item.sceneCode) == -1) {
sceneArr.push(item.sceneCode)
}
}
})
})
return arr
return { sceneList: sceneArr, productCodeList: arr }
},
handleConfirm() {
......@@ -121,7 +154,9 @@ Page({
if (isConfirm) {
return true
}
formData.productCodeList = this.dealPro()
let scene = this.dealScenePro()
formData.sceneList = scene.sceneList
formData.productCodeList = scene.productCodeList
let validObj = wx.$util.checkRule(formData, constantData.formRule)
if (validObj) {
wx.$api.showToast(validObj.message)
......@@ -145,11 +180,23 @@ Page({
isConfirm: true
})
wx.$api.showLoading('加载中...')
// 创建/编辑接口
mineCustomerApi[apiNameObj[addOrEdit]]({
...formData,
let params = {
// ...formData,
serviceCenterMerchantId: formData.serviceCenterMerchantId,
merchantName: formData.merchantName,
contactName: formData.contactName,
phone: formData.phone,
sceneList: formData.sceneList,
productCodeList: formData.productCodeList,
oldPhone: formData?.oldPhone,
oldMerchantName: formData.oldMerchantName,
serviceMerchantName: userInfo.merchantName
}).then(res => {
}
if (addOrEdit == 'edit') {
params.merchantId = formData.merchantId
}
// 创建/编辑接口
mineCustomerApi[apiNameObj[addOrEdit]](params).then(res => {
let { code, data, message } = res
if (code == '0') {
wx.hideLoading()
......@@ -184,7 +231,6 @@ Page({
*/
onLoad(options) {
let { scenceList } = this.data
this.getProList()
wx.$router.getData(res => {
let { addOrEdit, target } = res
this.setData({
......@@ -207,6 +253,9 @@ Page({
yqMerchantName: target.serviceCenterMerchantName
}
})
this.getSceneProStatus()
} else {
this.getProList()
}
})
this.getAllServiceList()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!