修复了工作项的亿点bug

main
wuyize 2022-07-08 12:05:00 +08:00
parent 968fc8d3c2
commit a5a2ffbb31
1 changed files with 205 additions and 106 deletions

View File

@ -3,8 +3,21 @@
<div style="margin: 0 40px 0 40px;
display: flex;flex-direction: row;justify-content: space-between">
<p style="font-family: 'Segoe UI',sans-serif;font-size: 20px;font-weight: bold;color: #606266">工作项</p>
<!-- <p style="font-family: 'Segoe UI',sans-serif;font-size: 20px;font-weight: bold;color: #606266">工作项</p>-->
<el-dropdown>
<span style="font-family: 'Segoe UI',sans-serif;font-size: 20px;font-weight: bold;color: #606266">
工作项
<el-icon class="el-icon--right">
<arrow-down/>
</el-icon>
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item>所有工作项</el-dropdown-item>
<el-dropdown-item>我的工作项</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<el-popover
placement="bottom-end"
:width="100"
@ -98,7 +111,7 @@
<el-table-column prop="operations" min-width="10%">
<template #default="scope">
<div style="width: 100%;display: flex;justify-content: flex-end">
<el-button v-show="scope.row.editable" style="padding: 4px" text @click.native="onEditClick(scope.row)">
<el-button v-show="scope.row.taskStatus!=='已完成'&&scope.row.taskStatus!=='关闭'&&scope.row.editable" style="padding: 4px" text @click.native="onEditClick(scope.row)">
<svg-icon style="width: 20px;height: 20px;" icon-class="edit"></svg-icon>
</el-button>
@ -144,8 +157,7 @@
<el-button
:style="{'padding':'4px','margin-left': '5px','visibility':
(scope.row.taskType!=='缺陷'&&
(scope.row.editable||
(this.$store.state.staff&&scope.row.taskHolderId===this.$store.state.staff.staffId)))?
!statusDisabled(scope.row))?
'unset':'hidden'}"
text>
<svg-icon style="width: 20px;height: 20px;" icon-class="add"></svg-icon>
@ -174,10 +186,10 @@
width="40%"
top="60px"
>
<el-form :model="form" label-position="top" label-width="120px">
<el-form ref="formRef" :model="form" label-position="top" label-width="120px" :rules="rules">
<el-row :gutter="20">
<el-col :span="form.operation==='add'?24:12">
<el-form-item label="标题">
<el-form-item label="标题" prop="taskName">
<el-input v-model="form.taskName" :disabled="form.disabled"/>
</el-form-item>
</el-col>
@ -194,7 +206,7 @@
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="负责人">
<el-form-item label="负责人" prop="taskHolderId">
<el-select style="width: 100%" v-model="form.taskHolderId" filterable :disabled="form.disabled">
<el-option
@ -226,7 +238,7 @@
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="开始时间">
<el-form-item label="开始时间" prop="taskStartTime">
<el-date-picker
v-model="form.taskStartTime"
@ -239,7 +251,7 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="截止时间">
<el-form-item label="截止时间" prop="taskEndTime">
<el-date-picker
type="datetime"
placeholder="选择时间"
@ -302,7 +314,7 @@
<el-button @click="dialogVisible = false">取消</el-button>
<el-button
:disabled="form.statusDisabled"
type="primary" @click="onSubmit"
type="primary" @click="onSubmit('formRef')"
>确定</el-button
>
</span>
@ -311,14 +323,14 @@
</template>
<script setup>
import {ArrowDown} from '@element-plus/icons'
// table
import {onMounted, ref} from "vue";
const tableRef = ref(null);
// table
const tableHeight = ref();
const formRef = ref(null);
onMounted(() => {
// innerHeight-offsetTop-
tableHeight.value = window.innerHeight - tableRef.value.$el.offsetTop - 70;
@ -343,9 +355,34 @@ export default {
return {
dialogVisible: false,
form: {},
rules: {
taskName: [
{required: true, message: '请输入标题', trigger: 'blur'}
],
taskHolderId: [
{required: true, message: '请指定负责人', trigger: 'blur'}
],
taskStartTime: [
{required: true, message: '请设置开始时间', trigger: 'blur'},
],
taskEndTime: [
{required: true, message: '请设置截止时间', trigger: 'blur'},
{
validator: (rule, value, callback) => {
if (!this.form.taskStartTime){
return callback();
}
if (this.form.taskEndTime.getTime() > this.form.taskStartTime.getTime())
return callback();
else
return callback(new Error("截止时间须在开始时间之后"));
}, trigger: 'change'
},
]
},
workitems: [],
defaultTime: new Date(1970, 1, 1, 12, 0, 0),
maps: new Map()
maps: new Map(),
}
},
watch: {
@ -362,14 +399,14 @@ export default {
},
methods: {
statusDisabled(row) {
return !(row.editable ||
return row.taskStatus==='已完成'||row.taskStatus==='关闭'||!(row.editable ||
(this.$store.state.staff && row.taskHolderId === this.$store.state.staff.staffId))
},
onRowClick(row, column, event) {
if (column.property === "operations")
return
this.form = {
disabled: !row.editable,
disabled: row.taskStatus==='已完成'||row.taskStatus==='关闭'||!row.editable,
statusDisabled: this.statusDisabled(row),
title: '修改' + row.taskType,
taskId: row.taskId,
@ -437,113 +474,144 @@ export default {
that.loadChildren(rtr.row, rtr.treeNode, rtr.resolve)
}
}
let rtr = that.maps.get(submitForm.taskId);
if (rtr) {
rtr.treeNode.loading = true
that.refreshChildren(rtr.row, rtr.treeNode, rtr.resolve)
}
ElMessage({
message: '修改成功',
type: 'success',
})
that.dialogVisible = false
}
else
Promise.reject(response)
}).catch(function (error) {
console.log(error)
ElMessage({
message: '修改失败',
type: 'error',
})
if (submitForm.taskFatherId === 0) {
that.getWorkitems()
} else {
let rtr = that.maps.get(submitForm.taskFatherId);
if (rtr) {
rtr.treeNode.loading = true
that.loadChildren(rtr.row, rtr.treeNode, rtr.resolve)
}
}
})
},
onSubmit() {
let submitForm = {
taskType: this.form.taskType,
taskFatherId: this.form.taskFatherId,
taskName: this.form.taskName,
taskHolderId: parseInt(this.form.taskHolderId),
taskPriority: this.form.taskPriority,
taskStartTime: this.form.taskStartTime.getTime() / 1000,
taskEndTime: this.form.taskEndTime.getTime() / 1000,
taskDescription: this.form.taskDescription
if( !this.$refs['formRef'])
{
console.log('formRef error')
return
}
switch (this.form.taskType) {
case '需求':
submitForm['attachedInfo'] = {
demandSource: this.form.demandSource
this.$refs['formRef'].validate((valid) => {
console.log(valid)
if(valid)
{
let submitForm = {
taskType: this.form.taskType,
taskFatherId: this.form.taskFatherId,
taskName: this.form.taskName,
taskHolderId: parseInt(this.form.taskHolderId),
taskPriority: this.form.taskPriority,
taskStartTime: this.form.taskStartTime.getTime() / 1000,
taskEndTime: this.form.taskEndTime.getTime() / 1000,
taskDescription: this.form.taskDescription
}
break;
case '任务':
submitForm['attachedInfo'] = {
estimatedManHours: this.form.estimatedManHours
}
break;
case '缺陷':
submitForm['attachedInfo'] = {
severity: this.form.severity,
recurrenceProbability: this.form.recurrenceProbability
}
break;
}
console.log(submitForm)
const that = this
if (this.form.operation === 'add') {
request({
url: 'project/' + this.$route.params.projectId + '/task',
method: 'post',
data: submitForm
}).then(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)
switch (this.form.taskType) {
case '需求':
submitForm['attachedInfo'] = {
demandSource: this.form.demandSource
}
}
ElMessage({
message: '新增成功',
type: 'success',
})
that.dialogVisible = false
}
}).catch(function (error) {
console.log(error)
})
} else {
submitForm['taskId'] = this.form.taskId
submitForm['taskStatus'] = this.form.taskStatus
submitForm['taskCreatedTime'] = this.form.taskCreatedTime
submitForm['taskClosedTime'] = this.form.taskClosedTime
request({
url: 'project/' + this.$route.params.projectId + '/task/' + this.form.taskId,
method: 'put',
data: submitForm
}).then(response => {
console.log(response)
if (response.data.code === 200) {
if (submitForm.taskFatherId === 0) {
that.getWorkitems()
} else {
let rtr = that.maps.get(submitForm.taskFatherId);
if (rtr) {
rtr.treeNode.loading = true
that.loadChildren(rtr.row, rtr.treeNode, rtr.resolve)
break;
case '任务':
submitForm['attachedInfo'] = {
estimatedManHours: this.form.estimatedManHours
}
}
ElMessage({
message: '修改成功',
type: 'success',
})
that.dialogVisible = false
break;
case '缺陷':
submitForm['attachedInfo'] = {
severity: this.form.severity,
recurrenceProbability: this.form.recurrenceProbability
}
break;
}
}).catch(function (error) {
console.log(error)
})
console.log(submitForm)
const that = this
if (this.form.operation === 'add') {
request({
url: 'project/' + this.$route.params.projectId + '/task',
method: 'post',
data: submitForm
}).then(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)
}
}
ElMessage({
message: '新增成功',
type: 'success',
})
that.dialogVisible = false
}
}).catch(function (error) {
console.log(error)
})
} else {
submitForm['taskId'] = this.form.taskId
submitForm['taskStatus'] = this.form.taskStatus
submitForm['taskCreatedTime'] = this.form.taskCreatedTime
submitForm['taskClosedTime'] = this.form.taskClosedTime
request({
url: 'project/' + this.$route.params.projectId + '/task/' + this.form.taskId,
method: 'put',
data: submitForm
}).then(response => {
console.log(response)
if (response.data.code === 200) {
if (submitForm.taskFatherId === 0) {
that.getWorkitems()
} else {
let rtr = that.maps.get(submitForm.taskFatherId);
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)
})
}
}
})
}
},
onEditClick(row) {
@ -668,6 +736,37 @@ export default {
console.log(error)
})
},
refreshChildren(row, treeNode, resolve) {
const that = this;
this.maps.set(row.taskId, {row, treeNode, resolve})
request({
url: 'project/' + this.$route.params.projectId + '/task/' + row.taskId + '/subtask',
method: 'get',
}).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
//console.log(workitem)
}
resolve(records)
for(let workitem of records)
{
let rtr = that.maps.get(workitem.taskId);
if (rtr) {
rtr.treeNode.loading = true
that.refreshChildren(rtr.row, rtr.treeNode, rtr.resolve)
}
}
}
}).catch(function (error) {
console.log(error)
})
},
dateFormatter(row, column) {
const moment = require('moment');