Commit 5b87d7ed by 胡悦

修复bug

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