Commit 5b87d7ed by 胡悦

修复bug

1 parent df024a26
......@@ -27,7 +27,7 @@
</span>
<div class="sale-select" v-show="basicForm.userList">
<div :key="key" class="el-input-tag input-tag-wrapper">
<el-tag v-for="(tag, idx) in basicForm.userList" :key="idx" closable :disable-transitions="false" @close="remove(tag)">
<el-tag v-for="(tag, idx) in basicForm.userList" :key="idx" closable :disable-transitions="false" @close="remove(tag, idx)">
{{ tag.staffName }}
</el-tag>
<el-input size="small" style="outline: none; border: none"></el-input>
......@@ -39,9 +39,8 @@
<!-- 编辑入群欢迎语 -->
<div class="title">编辑入群欢迎语</div>
<div>
<el-form :model="basicForm" :rules="basicRules" ref="groupForm" label-width="120px">
<el-form-item label="入群欢迎语" prop="attachmentList">
<label slot="label" class="required">入群欢迎语</label>
<el-form :model="basicForm" label-width="120px">
<el-form-item label="入群欢迎语">
<WelcomeWords ref="welcome" :eventBus="eventBus"></WelcomeWords>
</el-form-item>
</el-form>
......@@ -64,7 +63,7 @@
<el-button type="primary" @click="handleCancel">取消</el-button>
</div>
<basic-dialog :title="'选择成员'" :width="'712px'" :isVisible="membersVisible" @confirmDialog="handleConfirm" @closeDialog="handleClose">
<SelectMembers :selectData.sync="selectData" ref="membersForm"></SelectMembers>
<SelectMembers :key="key" :selectData.sync="selectData" ref="membersForm"></SelectMembers>
</basic-dialog>
</div>
</template>
......@@ -82,9 +81,9 @@ export default {
},
data() {
const validatorUser = (rule, value, callback) => {
console.log(value)
if (this.$route.params.id == -1) {
if (this.$refs.membersForm.innerTags) this.basicForm.userList = this.$refs.membersForm.innerTags
console.log(value, !this.$route.params.id)
if (!this.$route.params.id) {
if (this.$refs.membersForm) this.basicForm.userList = this.$refs.membersForm.innerTags
if (this.basicForm.userList) {
if (this.basicForm.userList.length < 2) {
callback(new Error('至少配置2个及以上成员'))
......@@ -106,32 +105,12 @@ export default {
}
}
}
const validatorAttachment = (rule, value, callback) => {
const previewList = this.$refs.welcome.previewList
if (previewList.length != 0) {
this.basicForm.attachmentList = previewList
}
console.log(this.basicForm.attachmentList, '---')
if (this.basicForm.attachmentList) {
if (this.basicForm.attachmentList.length > 9) {
callback(new Error('附件不可超过9个'))
} else {
callback()
}
} else {
callback(new Error('请输入入群欢迎语'))
}
}
return {
eventBus: new Vue(),
basicForm: {},
basicRules: {
orgName: [{ required: true, message: '请输入组名', trigger: 'blur' }],
groupName: [{ required: true, message: '请输入群聊名称', trigger: 'blur' }],
attachmentList: [
// { required: true, message: '请输入入群欢迎语' },
{ validator: validatorAttachment, trigger: 'change' }
],
userList: [
// { required: true, message: '请选择默认成员', trigger: 'change' },
{ validator: validatorUser, trigger: 'change' }
......@@ -171,15 +150,17 @@ export default {
methods: {
openMembers() {
this.membersVisible = !this.membersVisible
if (this.membersVisible && this.$route.params.id != -1) {
if (this.membersVisible && this.$route.params.id) {
this.$nextTick(() => {
this.key = new Date()
console.log(this.$refs.membersForm)
this.$refs.membersForm.selectTable(this.basicForm.userList)
if (this.basicForm.userList && this.basicForm.userList.length != 0) {
this.basicForm.userList.map(item => {
if (item.masterStatus) {
if (item.masterStatus == 1) {
this.basicForm.group = item
this.$refs.membersForm.group = item
this.$refs.membersForm.handlGroup(item, true)
// this.$refs.membersForm.group = item
this.selectData = this.basicForm.userList
}
})
......@@ -188,18 +169,17 @@ export default {
}
},
handleSubmit() {
// const previewList = this.$refs.welcome.previewList
this.$refs.basicForm.validate(valid => {
if (valid) {
console.log(this.basicForm, '111')
this.$refs.groupForm.validate(v => {
console.log(v)
if (v) {
console.log(this.basicForm, '122211')
const params = {
attachmentList: this.basicForm.attachmentList,
// attachmentList: this.$refs.welcome.previewList,
orgName: this.basicForm.orgName,
groupName: this.basicForm.groupName
}
if (this.$refs.welcome.previewList) params.attachmentList = this.$refs.welcome.previewList
params.userList = this.basicForm.userList.map(item => {
if (this.basicForm.group.staffId == item.staffId) {
return {
......@@ -208,7 +188,7 @@ export default {
}
} else {
return {
staffId: item.id
staffId: item.staffId
}
}
})
......@@ -237,8 +217,6 @@ export default {
})
}
})
}
})
},
getDetail(id) {
this.$apis.groupGuest.detail({ id }).then(res => {
......@@ -253,51 +231,74 @@ export default {
}
this.$refs.welcome.updateList(res.attachmentList)
this.selectData = res.userList
if (this.selectData.find(i => i.masterStatus == 1)) this.basicForm.group = this.selectData.find(i => i.masterStatus == 1)
console.log(res.userList.find(i => i.masterStatus == 1))
if (res.userList.find(i => i.masterStatus == 1)) this.basicForm.group = this.$common.utils.deepClone(res.userList.find(i => i.masterStatus == 1))
}
})
},
handleCancel() {
this.$router.go(-1)
// this.$router.push({ path: '/guestGroup/index' })
// this.$router.go(-1)
this.$router.push({ path: '/guestGroup/index' })
this.basicForm = {}
this.$refs.welcome.updateList([])
this.selectData = []
},
remove(val) {
remove(val, idx) {
if (this.$refs.membersForm) {
this.$refs.membersForm.remove(val)
console.log(this.$refs.membersForm.innerTags)
this.$set(this.basicForm, 'userList', this.$refs.membersForm.innerTags)
this.key = new Date()
} else {
this.basicForm.userList.splice(idx, 1)
}
},
// 成员弹窗
handleConfirm() {
console.log(this.$refs.membersForm.innerTags)
if (this.$refs.membersForm.innerTags.length == 0) {
this.$message({
type: 'error',
message: '请选择成员'
})
} else if (this.$refs.membersForm.innerTags.length == 1) {
this.$message({
type: 'error',
message: '必须配置两个及以上成员'
})
} else {
this.$refs.membersForm.resetSearch()
console.log(this.$refs.membersForm.group)
this.basicForm.userList = this.$refs.membersForm.innerTags
if (!this.$refs.membersForm.group.id) {
this.basicForm.group = this.basicForm.userList[0]
this.$refs.membersForm.handlGroup(this.basicForm.userList[0], true)
} else {
this.basicForm.group = this.$refs.membersForm.group
// if (this.$refs.membersForm.group.id) {
}
this.openMembers()
// }
}
},
handleClose() {
// this.openMembers()
this.$refs.membersForm.resetSearch()
this.membersVisible = false
if (this.$route.params.id) {
this.$nextTick(() => {
this.$refs.membersForm.selectTable(this.basicForm.userList)
if (this.basicForm.userList && this.basicForm.userList.length != 0) {
this.basicForm.userList.map(item => {
if (item.masterStatus) {
this.basicForm.group = item
this.$refs.membersForm.group = item
this.selectData = this.basicForm.userList
}
})
}
})
} else {
this.selectData = []
}
// if (this.$route.params.id) {
// this.$nextTick(() => {
// this.$refs.membersForm.selectTable(this.basicForm.userList)
// if (this.basicForm.userList && this.basicForm.userList.length != 0) {
// this.basicForm.userList.map(item => {
// if (item.masterStatus) {
// this.basicForm.group = item
// this.$refs.membersForm.group = item
// this.selectData = this.basicForm.userList
// }
// })
// }
// })
// } else {
// this.selectData = []
// }
}
}
}
......
......@@ -18,7 +18,7 @@
height: treeHeight + 20 + 'px'
}"
>
<GLTable ref="saleTable" v-loading="loading" :tableData="tableEmpData" :tableParams="tableParams" :hasNum="false" :hasPage="false" @selectionTable="selectionTable">
<GLTable :key="key" ref="saleTable" v-loading="loading" :tableData="tableEmpData" :tableParams="tableParams" :hasNum="false" :hasPage="false" @selectionTable="selectionTable">
<div class="table-btns" slot="optionBtns" slot-scope="scope">
<el-button type="text" v-show="!group.staffName" @click="selectGroup(scope.scope)">设为群主</el-button>
<el-button type="text" v-show="group.staffName && scope.scope.staffName == group.staffName" @click="cancelGroup">取消群主</el-button>
......@@ -30,12 +30,13 @@
<script>
export default {
name: 'selectEmp',
props: ['selectData'],
props: ['selectData', 'key'],
data() {
return {
treeHeight: 0,
staffName: '',
listTree: [],
isFirst: true,
defaultProps: {
children: 'children',
label: 'departmentName'
......@@ -75,45 +76,58 @@ export default {
}
},
watch: {
selectData(val) {
selectData: {
handler(val) {
console.log(this.group)
console.log(val)
if (val.length == 0) {
this.clearSelection()
} else {
this.$nextTick(() => {
val.forEach(i => {
const row = this.getEmployee(this.listTree).find(j => j.staffId == i.staffId)
console.log(row)
this.clearSelect(row)
// if (i.masterStatus == 1) this.group = i
})
})
this.group = val.find(i => i.masterStatus == 1)
}
},
immediate: true
}
},
methods: {
selectionTable(val) {
console.log(val, this.group)
console.log(val, this.group, this.isFirst)
this.$emit('selectTable', val)
this.allGroup = val
const hasGroup = val.find(item => item.staffId == this.group.staffId)
if (!hasGroup) {
this.cancelGroup()
}
// if (val && !this.isFirst) {
// val.forEach(i => {
// const row = this.getEmployee(this.listTree).find(j => j.staffId == i.staffId)
// console.log(row)
// this.clearSelect(row)
// })
// }
},
listDepartmentTree() {
this.$apis.groupGuest.listDepartmentTree({ merchantId: 10001001, addChildrensFlag: true }).then(res => {
this.listTree = res
this.loading = false
this.isFirst = false
this.listTree[0].entmicroStaffResponses = this.getEmployee(this.listTree)
console.log(this.listTree, this.selectData)
this.currentArr = this.$common.utils.deepClone(this.listTree[0].entmicroStaffResponses)
this.gruop = this.selectData.find(i => i.masterStatus == 1)
this.$nextTick(() => {
this.selectData.forEach(i => {
const row = this.getEmployee(this.listTree).find(j => j.staffId == i.staffId)
console.log(row)
this.clearSelect(row)
// if (i.masterStatus == 1) this.group = i
})
this.$nextTick(() => {
document.getElementsByClassName('el-tree-node__expand-icon')[0].click()
document.getElementsByClassName('el-tree-node__content')[0].click()
if (this.selectData.find(i => i.masterStatus == 1)) {
......@@ -135,12 +149,15 @@ export default {
this.currentArr = this.$common.utils.deepClone(data.entmicroStaffResponses)
// this.listEntmicroStaff()
},
selectGroup(data) {
selectGroup(data, flag = false) {
console.log(data)
this.group = data
// 标识是否从父组件修改
if (!flag) {
const obj = this.allGroup.find(item => item.staffId == data.staffId)
if (!obj) this.$refs.saleTable.$refs.salelistMutiTable.toggleRowSelection(data)
this.$emit('group', this.group)
}
},
cancelGroup() {
this.group = {}
......@@ -160,7 +177,8 @@ export default {
return arr
},
searchTable(search) {
const arr = []
let arr = []
if (search) {
this.currentArr.forEach(item => {
console.log(item.staffName.indexOf(search) != -1)
if (item.staffName.indexOf(search) != -1) {
......@@ -168,24 +186,18 @@ export default {
arr.push(item)
}
})
} else {
arr = this.$common.utils.deepClone(this.listTree[0].entmicroStaffResponses)
}
this.tableEmpData = arr
}
// listEntmicroStaff(staffName) {
// let params = {
// departmentId: this.departmentId,
// staffName: staffName ? staffName : this.staffName,
// merchantid: this.$globalState.session.merchantId
// }
// this.$apis.emp.listEntmicroStaff(params).then(res => {
// this.tableEmpData = res
// })
// }
},
created() {
this.listDepartmentTree()
},
mounted() {
let clientHeight = document.documentElement.clientHeight
this.treeHeight = clientHeight - 800
this.listDepartmentTree()
console.log(this.selectData, '.....')
}
}
......
......@@ -13,7 +13,7 @@
</div>
<div>
<div class="select-sale-panel">
<select-emp :selectData.sync="selectData" @group="handlGroup" @selectTable="selectTable" ref="selectEmpTabel"></select-emp>
<select-emp :key="key" :selectData.sync="selectData" @group="handlGroup" @selectTable="selectTable" ref="selectEmpTabel"></select-emp>
<div class="popper__arrow"></div>
</div>
</div>
......@@ -28,7 +28,7 @@
import selectEmp from './selectEmp.vue'
export default {
name: 'SelectMembers',
props: ['selectData'],
props: ['selectData', 'key'],
components: {
selectEmp
},
......@@ -79,25 +79,20 @@ export default {
console.log(this.newTag)
this.$refs.selectEmpTabel.searchTable(this.newTag)
},
handlGroup(val) {
console.log(val)
resetSearch() {
this.newTag = ''
this.$refs.selectEmpTabel.searchTable()
},
handlGroup(val, flag = false) {
console.log(val, '=-=-=-=-=')
this.group = val
// 标识从父组件修改
if (flag) {
this.$refs.selectEmpTabel.selectGroup(val, true)
}
},
cancelGroup() {
this.$refs.selectEmpTabel.cancelGroup()
},
onSubmit() {
if (this.innerTags.length == 0) {
this.$message({
message: '请选择成员',
type: 'error'
})
return
}
let userIds = []
this.innerTags.forEach(item => {
userIds.push(item.userId)
})
}
}
}
......
......@@ -323,6 +323,7 @@ export default {
updateList(val) {
this.previewList = val
this.eventBus.$emit('update', this.previewList)
if (val) {
const obj = val.find(item => item.attType == 1)
if (obj) {
this.text = obj.attContent
......@@ -331,6 +332,7 @@ export default {
}
}
}
}
}
</script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!