Commit bce7f7bb by 前端

更换选择商户、选择机器人逻辑

1 parent 78d4f680
......@@ -100,6 +100,7 @@
</template>
<script>
import { taskApi } from '../../../../api/task'
export default {
name: 'selectBrand',
data() {
......@@ -117,21 +118,27 @@ export default {
},
brandTree: false,
ids: [],
robotListTree: this.brandListTree,
robotListTree: [],
currentCheckData: {},
selectItem: this.selectRobot,
// selectItem: this.selectRobot,
}
},
props: {
brandListTree: {
type: Array,
default: () => [],
},
// brandListTree: {
// type: Array,
// default: () => [],
// },
memberRef: {
type: String,
},
selectRobot: {
type: Array,
type: Array || String,
},
type: {
type: Boolean,
},
robotNo: {
type: Number || String,
},
},
watch: {
......@@ -156,36 +163,80 @@ export default {
},
deep: true,
},
robotListTree: {
handler(val) {
console.log(val)
console.log(this.selectItem)
if (this.selectItem) {
this.$nextTick(() => {
this.$refs[this.memberRef].setCheckedKeys(this.selectItem)
this.treeArr = this.$refs[this.memberRef]
.getCheckedNodes()
.filter((item) => item.children && item.children.length == 0)
})
}
},
deep: true,
},
selectItem(val) {
console.log(val)
this.$refs[this.memberRef].setCheckedKeys(val)
this.getCheckedArr = this.robotListTree.find((item) => item.id == val[0])
},
// brandListTree: {
// handler(val) {
// console.log(val)
// // this.robotListTree = val
// this.initData(val)
// console.log(this.selectItem)
// if (this.selectItem) {
// this.$nextTick(() => {
// this.$refs[this.memberRef].setCheckedKeys(this.selectItem)
// this.treeArr = this.$refs[this.memberRef]
// .getCheckedNodes()
// .filter((item) => item.children && item.children.length == 0)
// })
// }
// },
// deep: true,
// },
// brandListTree(val) {
// console.log(val)
// this.dealVal(val)
// },
// selectRobot(val) {
// console.log(val)
// this.$refs[this.memberRef].setCheckedKeys(val)
// this.getCheckedArr = this.robotListTree.find((item) => item.id == val[0])
// },
},
mounted() {
console.log(this.robotListTree)
if (this.robotListTree.length) {
console.log(111)
this.initData(this.robotListTree)
}
console.log(this.type, this.robotNo, this.selectRobot)
if (this.type && this.robotNo) this.getlistDepartmentTree(this.robotNo)
},
methods: {
async dealVal(val) {
await this.initData(val)
this.robotListTree = val
console.log(this.robotListTree)
},
getlistDepartmentTree(merchantId) {
let params = { addChildrensFlag: true, queryMerchantId: merchantId }
taskApi.getlistDepartmentTree(params).then(async (res) => {
console.log(res)
if (res) {
this.robotListTree = res.data.data
await this.initData(this.robotListTree)
console.log(this.robotListTree, '=======22')
if (this.selectRobot && this.selectRobot.length) {
this.$refs[this.memberRef].setCheckedKeys(this.selectRobot)
let treeArrInfo = this.getTreeName(
this.robotListTree,
this.selectRobot[0]
)
this.treeArr.push(treeArrInfo)
console.log(this.treeArr)
}
}
})
},
getTreeName(treeList, id) {
for (let i = 0; i < treeList.length; i++) {
let treeItem = treeList[i]
if (treeItem.id == id) {
return treeItem
} else {
if (treeItem.children && treeItem.children.length > 0) {
let res = this.getTreeName(treeItem.children, id)
if (res) {
return res
}
}
}
}
},
initData(data) {
console.log(11)
data.forEach((item, index) => {
this.$set(
item,
......@@ -338,7 +389,7 @@ export default {
selectClear() {
this.treeArr = []
this.$refs[this.memberRef].setCheckedKeys([])
this.handleCheck()
// this.handleCheck()
},
//删除
removeItem(checkItem, index) {
......
......@@ -310,7 +310,10 @@
:rules="taskFormRules.robotMerchantNo"
v-if="itm.autoReminderFlag == 2"
>
<el-radio-group v-model="itm.robotMerchantNo">
<el-radio-group
v-model="itm.robotMerchantNo"
@change="robotMerchantChange(itm)"
>
<template v-for="(item, index) in entmicroList">
<el-radio :key="index" :label="item.merchantNo">{{
item.entmicroName
......@@ -322,24 +325,22 @@
label="企微机器人:"
:prop="'missionList.' + index1 + '.enterMicroRobot'"
:rules="taskFormRules.enterMicroRobot"
v-if="itm.autoReminderFlag && itm.autoReminderFlag == 2"
v-if="itm.robotMerchantNo"
>
<SelectMembers
:id="
'missionList' + (itm.taskid || itm.id) + 'welcome'
"
:id="'missionList' + (itm.taskid || itm.id) + 'robot'"
:key="
'missionList' + (itm.taskid || itm.id) + 'welcome'
'missionList' + (itm.taskid || itm.id) + 'robot'
"
:ref="
'missionList' + (itm.taskid || itm.id) + 'welcome'
'missionList' + (itm.taskid || itm.id) + 'robot'
"
:brandListTree="brandListTree"
:type="isEditor"
:robotNo="itm.robotMerchantNo"
:selectRobot="isEditor ? itm.enterMicroRobot : []"
:memberRef="
'missionList' + (itm.taskid || itm.id) + 'welcome'
'missionList' + (itm.taskid || itm.id) + 'robot'
"
@click="getTree"
@getMenbers="getMenbers(item, index, itm, index1)"
@getSelectRobot="getSelectRobot"
></SelectMembers>
......@@ -348,7 +349,7 @@
label="目标群聊:"
:prop="'missionList.' + index1 + '.groupChat'"
:rules="taskFormRules.groupChat"
v-if="itm.autoReminderFlag && itm.autoReminderFlag == 2"
v-if="itm.robotMerchantNo && itm.enterMicroRobot"
>
<el-select
@focus="getGroupList(item, index, itm, index1)"
......@@ -1143,27 +1144,27 @@ export default {
// 清空活动
this.basicForm.activityId = ''
this.basicForm.activityName = ''
this.getlistDepartmentTree(val)
// this.getlistDepartmentTree(val)
// this.taskList = []
},
getTree() {
console.log(111)
},
// 根据商户获取机器人列表
getlistDepartmentTree(merchantId) {
return new Promise((resolve) => {
let params = { addChildrensFlag: true, queryMerchantId: merchantId }
taskApi.getlistDepartmentTree(params).then((res) => {
console.log(res)
if (res) {
this.brandListTree = res.data.data
resolve()
// this.initData(this.brandListTree)
// console.log(this.brandListTree, '=======22')
}
})
})
},
// getlistDepartmentTree(merchantId) {
// return new Promise((resolve) => {
// let params = { addChildrensFlag: true, queryMerchantId: merchantId }
// taskApi.getlistDepartmentTree(params).then((res) => {
// console.log(res)
// if (res) {
// this.brandListTree = res.data.data
// resolve()
// // this.initData(this.brandListTree)
// // console.log(this.brandListTree, '=======22')
// }
// })
// })
// },
// initData(data) {
// data.forEach((item, index) => {
// this.$set(
......@@ -1865,7 +1866,7 @@ export default {
})
})
// 获取其为机器人列表
await this.getlistDepartmentTree(merchantId)
// await this.getlistDepartmentTree(merchantId)
// 判断场景(代运营只有完整周期)
if (businessScene == 4) {
this.taskList = this.taskEditList.missionDateList
......@@ -1932,6 +1933,12 @@ export default {
this.$set(itm, 'enterMicroRobot', '')
this.$set(itm, 'groupChat', '')
},
// 企业机器人切换
robotMerchantChange(itm) {
let refLable = 'missionList' + (itm.taskid || itm.id) + 'robot'
console.log(this.$refs[refLable])
this.$refs[refLable][0].getlistDepartmentTree(itm.robotMerchantNo)
},
// 基础信息表单验证
basicFormValidate() {
this.$refs['basicForm'].validate((valid) => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!