¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <el-dialog :title="title" :visible.sync="dialogVisible" append-to-body="true"> |
| | | <div> |
| | | <el-tag v-for="tag in tags" :key="tag" closable disable-transitions effect="dark" @click="handleClickTag(tag)" |
| | | @close="handleCloseTag(tag)"> |
| | | <span> {{ tag.name }}</span> |
| | | </el-tag> |
| | | </div> |
| | | |
| | | <el-divider v-if="tags.length !== 0"></el-divider> |
| | | <div class="btns-icon"> |
| | | <el-button type="primary" icon="el-icon-star-off" @click="handleCollect"></el-button> |
| | | <!-- <el-button type="primary" icon="el-icon-refresh" ></el-button> --> |
| | | </div> |
| | | <el-form :model="saveParam" class="demo-form-inline" label-position="left"> |
| | | <el-form-item :label="item.taskName" v-for="(item, index) in initFrom" :key="index"> |
| | | <el-select style="width: 50%;" v-model="saveParam.flowTaskUsers[index]['userId']" |
| | | :placeholder="item.taskName" @change="handleSelect($event, index)"> |
| | | <el-option :label="key.userNames" :value="key.userId" v-for="(key, keyi) in typeName" |
| | | :key="keyi"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button @click="handleCancel">å æ¶</el-button> |
| | | <el-button type="primary" @click="handleConfirm">ç¡® å®</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | </template> |
| | | <script> |
| | | import { personnelInit, personnelCollect, cancelCollect, personnelSave, personnelDict } from '@/api/template/setPersonnel.js' |
| | | export default { |
| | | name: 'SetPersonnel', |
| | | props: { |
| | | // æ¯å¦æå¼ |
| | | visible: { |
| | | typeof: Boolean, |
| | | default: false |
| | | }, |
| | | // æ é¢ |
| | | title: { |
| | | typeof: String, |
| | | default: '人å设置' |
| | | }, |
| | | // 模æ¿id |
| | | code: { |
| | | typeof: String, |
| | | default: '' |
| | | }, |
| | | // 模æ¿ç¨é |
| | | type: { |
| | | typeof: String, |
| | | default: '' |
| | | } |
| | | }, |
| | | watch: { |
| | | visible(n) { |
| | | this.dialogVisible = n; |
| | | }, |
| | | dialogVisible(n) { |
| | | this.$emit('update:visible', n) |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | | dialogVisible: this.visible, |
| | | initFrom: [], |
| | | tags: [], |
| | | typeName: [], |
| | | saveParam: {}, |
| | | users: [], |
| | | |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.apiInit() |
| | | this.apiDict() |
| | | }, |
| | | methods: { |
| | | async apiInit() { |
| | | const response = await personnelInit({ type: this.type, templateId: this.code }) |
| | | if (response.status === 200) { |
| | | console.log(response) |
| | | this.initFrom = response.data.data.user |
| | | this.tags = response.data.data.collect |
| | | const { modelKey, templateId } = response.data.data.flow |
| | | let flowTaskUsers = response.data.data.user |
| | | this.saveParam = { modelKey, templateId, flowTaskUsers: flowTaskUsers } |
| | | this.handleClickTag(this.tags[0]) |
| | | } |
| | | }, |
| | | async apiDict() { |
| | | const response = await personnelDict() |
| | | if (response.status === 200) { |
| | | console.log(response) |
| | | const data = response.data.data |
| | | this.typeName = data.map(item => { |
| | | const { account, deptName, id, realName } = item |
| | | let userNames = `${deptName} - ${realName} - ${account}` |
| | | return { userId: id, userName: realName, userNames: userNames } |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | handleCollect() { |
| | | this.$prompt('请è¾å
¥ä¸ä¸ªåå', 'æä½', { |
| | | confirmButtonText: 'ç¡®å®', |
| | | cancelButtonText: 'åæ¶', |
| | | }).then(async ({ value }) => { |
| | | console.log(this.users) |
| | | this.saveParam.flowTaskUsers = this.users |
| | | this.saveParam = { ...this.saveParam, name: value } |
| | | console.log(this.saveParam) |
| | | const response = await personnelCollect(this.saveParam) |
| | | if (response.status === 200) { |
| | | this.$nextTick(() => { |
| | | this.apiInit() |
| | | }) |
| | | console.log(response) |
| | | } |
| | | }).catch(() => { |
| | | |
| | | }); |
| | | }, |
| | | async canCollect(name) { |
| | | const response = await cancelCollect({ name: name }) |
| | | if (response.status === 200) { |
| | | console.log(response) |
| | | this.apiInit() |
| | | this.$message({ |
| | | type: 'success', |
| | | message: response.data.msg |
| | | }); |
| | | } |
| | | }, |
| | | async apiSave() { |
| | | try { |
| | | const { modelKey, templateId } = this.saveParam |
| | | const response = await personnelSave({ modelKey, templateId }) |
| | | if (response.status === 200) { |
| | | console.log(response) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: response.data.msg |
| | | }); |
| | | this.done() |
| | | } |
| | | } catch { |
| | | console.error('æ¥å£è°ç¨å¤±è´¥') |
| | | } |
| | | }, |
| | | handleClickTag(event) { |
| | | console.log(event) |
| | | const flowTaskUsers = event.flowTaskUsers |
| | | this.saveParam.flowTaskUsers = flowTaskUsers.map(item => { |
| | | const { taskId, taskName, userId, userName } = item |
| | | return { taskId, taskName, userId, userName } |
| | | }) |
| | | }, |
| | | handleCloseTag(event) { |
| | | console.log(event) |
| | | this.canCollect(event.name) |
| | | }, |
| | | handleSelect(event, index) { |
| | | const res = this.typeName.find(item => item.userId === event) |
| | | const { userName } = res |
| | | let users = { ... this.saveParam.flowTaskUsers[index], userName } |
| | | console.log(users) |
| | | this.users[index] = users |
| | | }, |
| | | done() { |
| | | this.dialogVisible = false |
| | | }, |
| | | handleCancel() { |
| | | this.done() |
| | | }, |
| | | handleConfirm() { |
| | | console.log(this.users) |
| | | console.log(this.saveParam) |
| | | this.apiSave() |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | <style lang="scss"> |
| | | .el-tag+.el-tag { |
| | | margin-left: 10px; |
| | | margin-top: 10px; |
| | | } |
| | | |
| | | .button-new-tag { |
| | | margin-left: 10px; |
| | | height: 32px; |
| | | line-height: 30px; |
| | | padding-top: 0; |
| | | padding-bottom: 0; |
| | | } |
| | | |
| | | .input-new-tag { |
| | | width: 90px; |
| | | margin-left: 10px; |
| | | vertical-align: bottom; |
| | | } |
| | | |
| | | .btns-icon { |
| | | display: flex; |
| | | justify-content: end; |
| | | padding-bottom: 10px; |
| | | } |
| | | </style> |