Commit bce7f7bb by 前端

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

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