| | |
| | | <template> |
| | | <el-dialog :title="title" :visible.sync="dialogVisible" append-to-body="true" width="30%"> |
| | | <el-dialog :title="title" :visible.sync="dialogVisible" append-to-body="true" class="avue-dialog avue-dialog--top" top="-3%" width="30%"> |
| | | <el-tag v-for="tag in tags" :key="tag" closable disable-transitions effect="Plain" size="medium" |
| | | @click="handleClickTag(tag)" @close="handleCloseTag(tag)"> |
| | | <span> {{ tag.name }}</span> |
| | |
| | | </div> |
| | | <el-form :model="collectParam" class="demo-form-inline" label-position="left" label-width="auto"> |
| | | <el-form-item :label="item.taskName" v-for="(item, index) in initFrom" :key="index"> |
| | | <el-select style="width: 80%;" filterable v-model="collectParam.flowTaskUsers[index]['userId']" |
| | | <el-select style="width: 100%;" filterable v-model="collectParam.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> |
| | |
| | | </template> |
| | | <script> |
| | | import { personnelInit, personnelCollect, cancelCollect, personnelSave, personnelDict } from '@/api/template/setPersonnel.js' |
| | | import { dateFormat } from "@/util/date"; |
| | | export default { |
| | | name: 'SetPersonnel', |
| | | props: { |
| | | // 是否打开 |
| | | visible: { |
| | | typeof: Boolean, |
| | | default: false |
| | | }, |
| | | // 标题 |
| | | title: { |
| | | typeof: String, |
| | | default: '流程审批' |
| | | }, |
| | | // 参数:选择的id,多个以数组方式传递:['id','id'],模板id,模板用途,流程名字,流程模板 |
| | | parameter: { |
| | | typeof: Object, |
| | | default: () => { } |
| | | }, |
| | | parameterKeys: { |
| | | typeof: Object, |
| | | default: () => { |
| | | return { |
| | | ids: 'ids', |
| | | flowTemplate: 'flowTemplate', |
| | | code: 'code', |
| | | type: 'type' |
| | | } |
| | | } |
| | | // 是否打开 |
| | | visible: { |
| | | typeof: Boolean, |
| | | default: false |
| | | }, |
| | | // 标题 |
| | | title: { |
| | | typeof: String, |
| | | default: '流程审批' |
| | | }, |
| | | // 参数:选择的id,多个以数组方式传递:['id','id'],模板id,模板用途,流程名字,流程模板, |
| | | // flowTemplate: |
| | | // vars:object格式,名字为vars,里面key键值,自己随意 |
| | | parameter: { |
| | | typeof: Object, |
| | | default: () => { |
| | | } |
| | | |
| | | }, |
| | | parameterKeys: { |
| | | typeof: Object, |
| | | default: () => { |
| | | return { |
| | | ids: 'ids', |
| | | processName: 'processName', |
| | | code: 'code', |
| | | type: 'type', |
| | | btmtype: 'btmtype' |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | watch: { |
| | | visible(n) { |
| | | this.dialogVisible = n; |
| | | if(n){ |
| | | this.apiInit() |
| | | this.apiDict() |
| | | } |
| | | visible(n) { |
| | | this.dialogVisible = n; |
| | | if (n) { |
| | | this.apiInit() |
| | | this.apiDict() |
| | | } |
| | | }, |
| | | dialogVisible(n) { |
| | | this.$emit('update:visible', n) |
| | | }, |
| | | users: { |
| | | handler(val) { |
| | | this.collectParam.flowTaskUsers = val |
| | | }, |
| | | dialogVisible(n) { |
| | | this.$emit('update:visible', n) |
| | | deep: true, |
| | | immediate: true |
| | | }, |
| | | parameter: { |
| | | handler(newval, oldval) { |
| | | this.saveParam = Object.assign({processName:'',processDesc: ''},newval) ; |
| | | }, |
| | | deep: true, |
| | | immediate: true |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | |
| | | tags: [], |
| | | typeName: [], |
| | | collectParam: {}, |
| | | saveParam: this.saveParam(), |
| | | saveParam: {}, |
| | | users: [], |
| | | rules: { |
| | | processName: [ |
| | | { required: true, message: '模板名称不能为空', trigger: 'blur' }, |
| | | { min: 1, max: 20, message: '长度在 3 到 20 个字符', trigger: 'blur' } |
| | | { required: true, message: '流程名称不能为空', trigger: 'blur' }, |
| | | { min: 3, max: 50, message: '长度在 3 到 50 个字符', trigger: 'blur' } |
| | | ] |
| | | } |
| | | } |
| | | }, |
| | | |
| | | mounted() { |
| | | // this.apiInit() |
| | | // this.apiDict() |
| | | }, |
| | | methods: { |
| | | saveParam() { |
| | | return { |
| | | processName: this.parameter[this.parameterKeys.flowTemplate], |
| | | topName: this.title, |
| | | ids: this.parameter[this.parameterKeys.ids], |
| | | } |
| | | }, |
| | | created() { |
| | | }, |
| | | methods: { |
| | | userIndex(arr1) { |
| | | return this.initFrom.findIndex(i => i.taskId === arr1) |
| | | }, |
| | | async apiInit() { |
| | | const response = await personnelInit({ type: this.parameter[this.parameterKeys.type], templateId: this.parameter[this.parameterKeys.code] }) |
| | | const response = await personnelInit({ type: this.parameter[this.parameterKeys.type], templateId: this.parameter[this.parameterKeys.code]}) |
| | | if (response.status === 200) { |
| | | console.log(response) |
| | | this.initFrom = response.data.data.user |
| | | this.tags = response.data.data.collect |
| | | const { modelKey, templateId, modelName } = response.data.data.flow |
| | | let flowTaskUsers = response.data.data.user |
| | | this.collectParam = { modelKey, templateId, flowTaskUsers: flowTaskUsers } |
| | | console.log(this.collectParam) |
| | | this.users = response.data.data.user |
| | | this.saveParam = { ...this.saveParam, modelKey, templateId, modelName } |
| | | this.handleClickTag(this.tags[0]) |
| | | if (this.tags.length !== 0) this.handleClickTag(this.tags[0]) |
| | | } |
| | | }, |
| | | async apiDict() { |
| | | const response = await personnelDict() |
| | | console.log(response) |
| | | if (response.status === 200) { |
| | | console.log(response) |
| | | const data = response.data.data |
| | | this.typeName = data.map(item => { |
| | | const { account, deptName, id, realName } = item |
| | |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | }).then(async ({ value }) => { |
| | | console.log(this.users) |
| | | this.collectParam.flowTaskUsers = this.users |
| | | this.collectParam = { ...this.collectParam, name: value } |
| | | console.log(this.collectParam) |
| | | const response = await personnelCollect(this.collectParam) |
| | | Console.log(response) |
| | | 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.isCollent = true |
| | | this.$message({ |
| | |
| | | }, |
| | | async apiSave() { |
| | | try { |
| | | const response = await personnelSave(this.saveParam) |
| | | if (response.status === 200) { |
| | | console.log(response) |
| | | const len = this.collectParam.flowTaskUsers.length |
| | | if (len == 0 && len != this.initFrom.length) { |
| | | this.$message({ |
| | | type: 'success', |
| | | message: response.data.msg |
| | | type: "error", |
| | | message: "请选择节点!" |
| | | }); |
| | | this.done() |
| | | } else { |
| | | const {modelKey,modelName,processDesc,processName,templateId,topName,vars,ids,btmtype} = this.saveParam |
| | | let vals= {modelKey,modelName,processDesc,processName,templateId,topName,ids,btmtype,...vars} |
| | | vals.oids=ids; |
| | | vals.createTime=dateFormat(new Date(), "yyyy-MM-dd hh:mm:ss") |
| | | const response = await personnelSave({ variables:vals, flowTaskUsers: this.collectParam.flowTaskUsers, }) |
| | | if (response.status === 200) { |
| | | this.$message({ |
| | | type: 'success', |
| | | message: response.data.msg |
| | | }); |
| | | this.$emit('onLoad') |
| | | this.done() |
| | | } |
| | | } |
| | | |
| | | } catch { |
| | | console.error('接口调用失败') |
| | | this.$message.error('接口调用失败') |
| | | } |
| | | }, |
| | | handleClickTag(event) { |
| | | console.log(event) |
| | | const flowTaskUsers = event.flowTaskUsers//collet.flowTaskUsers |
| | | let tasks = this.collectParam.flowTaskUsers;//user |
| | | for(let i=0;i<tasks.length;i++){ |
| | | let thisFlowTaskUsers = tasks[i]; |
| | | console.log('thisFlowTaskUsers',thisFlowTaskUsers) |
| | | for(let j=0;j<flowTaskUsers.length;j++){ |
| | | let thisFflowTaskUsers = flowTaskUsers[j]; |
| | | if(thisFlowTaskUsers.taskId==thisFflowTaskUsers.taskId){ |
| | | thisFlowTaskUsers['userName']=thisFflowTaskUsers.userName; |
| | | thisFlowTaskUsers['userId']=thisFflowTaskUsers.userId; |
| | | let flowTaskUsers = this.collectParam.flowTaskUsers |
| | | this.collectParam.flowTaskUsers = flowTaskUsers.map((item, index) => { |
| | | for (let i = 0; i < event.flowTaskUsers.length; i++) { |
| | | if (item.taskId == event.flowTaskUsers[i].taskId) { |
| | | item['userName'] = event.flowTaskUsers[i]['userName'] |
| | | item['userId'] = event.flowTaskUsers[i]['userId'] |
| | | } |
| | | } |
| | | } |
| | | console.log(this.collectParam) |
| | | return item |
| | | }) |
| | | this.users = this.collectParam.flowTaskUsers |
| | | // const flowTaskUsers = event.flowTaskUsers//collet.flowTaskUsers |
| | | // let tasks = this.collectParam.flowTaskUsers;//user |
| | | // for (let i = 0; i < tasks.length; i++) { |
| | | // let thisFlowTaskUsers = tasks[i]; |
| | | // for (let j = 0; j < flowTaskUsers.length; j++) { |
| | | // let thisFflowTaskUsers = flowTaskUsers[j]; |
| | | // if (thisFlowTaskUsers.taskId == thisFflowTaskUsers.taskId) { |
| | | // thisFlowTaskUsers['userName'] = thisFflowTaskUsers.userName; |
| | | // thisFlowTaskUsers['userId'] = thisFflowTaskUsers.userId; |
| | | // } |
| | | // } |
| | | // } |
| | | // this.collectParam.flowTaskUsers = {...this.collectParam.flowTaskUsers,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.collectParam.flowTaskUsers[index], userName } |
| | | console.log(users) |
| | | this.users[index] = users |
| | | this.$set(this.users, index, { ... this.collectParam.flowTaskUsers[index], userName }) |
| | | // this.users[index] = { ... this.collectParam.flowTaskUsers[index], userName } |
| | | }, |
| | | done() { |
| | | this.dialogVisible = false |
| | |
| | | this.done() |
| | | }, |
| | | handleConfirm() { |
| | | console.log(this.saveParam) |
| | | this.apiSave() |
| | | } |
| | | } |
| | |
| | | justify-content: end; |
| | | padding-bottom: 10px; |
| | | } |
| | | |
| | | </style> |