From a0a0da23d98c3e38e1b917a1930006d75579b2d6 Mon Sep 17 00:00:00 2001 From: wuyize Date: Thu, 7 Jul 2022 23:39:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=B7=A5=E4=BD=9C=E9=A1=B9?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/icons/delete.svg | 2 + src/assets/icons/edit.svg | 2 +- src/views/ProjectWorkitem.vue | 78 ++++++++++++++++++++++++++++------- 3 files changed, 65 insertions(+), 17 deletions(-) create mode 100644 src/assets/icons/delete.svg diff --git a/src/assets/icons/delete.svg b/src/assets/icons/delete.svg new file mode 100644 index 0000000..50d26f2 --- /dev/null +++ b/src/assets/icons/delete.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/src/assets/icons/edit.svg b/src/assets/icons/edit.svg index 00da47b..0b08836 100644 --- a/src/assets/icons/edit.svg +++ b/src/assets/icons/edit.svg @@ -1,2 +1,2 @@ \ No newline at end of file + \ No newline at end of file diff --git a/src/views/ProjectWorkitem.vue b/src/views/ProjectWorkitem.vue index 367ab51..1d827b2 100644 --- a/src/views/ProjectWorkitem.vue +++ b/src/views/ProjectWorkitem.vue @@ -39,7 +39,8 @@ @@ -147,11 +148,15 @@ (this.$store.state.staff&&scope.row.taskHolderId===this.$store.state.staff.staffId)))? 'unset':'hidden'}" text> - + - + + + @@ -169,10 +174,10 @@ width="40%" top="60px" > - + - + @@ -248,7 +253,7 @@ - + @@ -271,7 +276,7 @@ - + @@ -339,15 +344,15 @@ export default { }, methods: { statusDisabled(row) { - return !(row.editable|| - (this.$store.state.staff&&row.taskHolderId===this.$store.state.staff.staffId)) + return !(row.editable || + (this.$store.state.staff && row.taskHolderId === this.$store.state.staff.staffId)) }, onRowClick(row, column, event) { - if(column.property==="operations") + if (column.property === "operations") return this.form = { disabled: !row.editable, - statusDisabled: this.statusDisabled(row), + statusDisabled: this.statusDisabled(row), title: '修改' + row.taskType, taskId: row.taskId, taskType: row.taskType, @@ -392,9 +397,9 @@ export default { taskEndTime: row.taskEndTime, taskDescription: row.taskDescription, taskId: row.taskId, - taskStatus:row.taskStatus, - taskCreatedTime:row.taskCreatedTime, - taskClosedTime:row.taskClosedTime + taskStatus: row.taskStatus, + taskCreatedTime: row.taskCreatedTime, + taskClosedTime: row.taskClosedTime } console.log(submitForm) const that = this @@ -456,19 +461,22 @@ export default { } console.log(submitForm) const that = this - if (this.form.operation==='add') { + if (this.form.operation === 'add') { request({ url: 'project/' + this.$route.params.projectId + '/task', method: 'post', data: submitForm }).then(response => { - console.log(response) + //console.log(response) if (response.data.code === 200) { if (submitForm.taskFatherId === 0) { that.getWorkitems() } else { + this.form.row.hasChildren = true let rtr = that.maps.get(submitForm.taskFatherId); + console.log(rtr) if (rtr) { + rtr.row.hasChildren = true rtr.treeNode.loading = true that.loadChildren(rtr.row, rtr.treeNode, rtr.resolve) } @@ -557,6 +565,7 @@ export default { }, onAddClick(row, taskType) { this.form = { + row: row, operation: 'add', title: '新增' + taskType, taskType: taskType, @@ -564,6 +573,41 @@ export default { } this.dialogVisible = true }, + onDeleteClick(row) { + const that = this + request({ + url: 'project/' + this.$route.params.projectId + '/task/' + row.taskId, + method: 'delete', + }).then(response => { + console.log(response) + if (response.data.code === 200) { + if (row.taskFatherId === 0) { + that.getWorkitems() + } else { + //console.log(that.$refs.tableRef.store.states.lazyTreeNodeMap) + if(that.$refs.tableRef.store.states.lazyTreeNodeMap.value[row.taskFatherId].length===1) + { + that.$refs.tableRef.store.states.lazyTreeNodeMap.value[row.taskFatherId] = [] + } + let rtr = that.maps.get(row.taskFatherId); + //console.log(rtr) + if (rtr) { + rtr.treeNode.loading = true + that.loadChildren(rtr.row, rtr.treeNode, rtr.resolve) + } + } + + ElMessage({ + message: '删除成功', + type: 'success', + }) + that.dialogVisible = false + } + }).catch(function (error) { + console.log(error) + }) + + }, getWorkitems() { const that = this; request({ @@ -594,6 +638,8 @@ export default { }).then(response => { if (response.data.code === 200) { let records = response.data.data.records + + const editable = row.editable || row.taskHolderId === this.$store.state.staff.staffId for (let workitem of records) { workitem['editable'] = editable