Commit d669f6aa by chenwq

员工场景产品添加

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