修复了工作项的亿点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; <div style="margin: 0 40px 0 40px;
display: flex;flex-direction: row;justify-content: space-between"> 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 <el-popover
placement="bottom-end" placement="bottom-end"
:width="100" :width="100"
@ -98,7 +111,7 @@
<el-table-column prop="operations" min-width="10%"> <el-table-column prop="operations" min-width="10%">
<template #default="scope"> <template #default="scope">
<div style="width: 100%;display: flex;justify-content: flex-end"> <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> <svg-icon style="width: 20px;height: 20px;" icon-class="edit"></svg-icon>
</el-button> </el-button>
@ -144,8 +157,7 @@
<el-button <el-button
:style="{'padding':'4px','margin-left': '5px','visibility': :style="{'padding':'4px','margin-left': '5px','visibility':
(scope.row.taskType!=='缺陷'&& (scope.row.taskType!=='缺陷'&&
(scope.row.editable|| !statusDisabled(scope.row))?
(this.$store.state.staff&&scope.row.taskHolderId===this.$store.state.staff.staffId)))?
'unset':'hidden'}" 'unset':'hidden'}"
text> text>
<svg-icon style="width: 20px;height: 20px;" icon-class="add"></svg-icon> <svg-icon style="width: 20px;height: 20px;" icon-class="add"></svg-icon>
@ -174,10 +186,10 @@
width="40%" width="40%"
top="60px" 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-row :gutter="20">
<el-col :span="form.operation==='add'?24:12"> <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-input v-model="form.taskName" :disabled="form.disabled"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -194,7 +206,7 @@
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <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-select style="width: 100%" v-model="form.taskHolderId" filterable :disabled="form.disabled">
<el-option <el-option
@ -226,7 +238,7 @@
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="开始时间"> <el-form-item label="开始时间" prop="taskStartTime">
<el-date-picker <el-date-picker
v-model="form.taskStartTime" v-model="form.taskStartTime"
@ -239,7 +251,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="截止时间"> <el-form-item label="截止时间" prop="taskEndTime">
<el-date-picker <el-date-picker
type="datetime" type="datetime"
placeholder="选择时间" placeholder="选择时间"
@ -302,7 +314,7 @@
<el-button @click="dialogVisible = false">取消</el-button> <el-button @click="dialogVisible = false">取消</el-button>
<el-button <el-button
:disabled="form.statusDisabled" :disabled="form.statusDisabled"
type="primary" @click="onSubmit" type="primary" @click="onSubmit('formRef')"
>确定</el-button >确定</el-button
> >
</span> </span>
@ -311,14 +323,14 @@
</template> </template>
<script setup> <script setup>
import {ArrowDown} from '@element-plus/icons'
// table // table
import {onMounted, ref} from "vue"; import {onMounted, ref} from "vue";
const tableRef = ref(null); const tableRef = ref(null);
// table // table
const tableHeight = ref(); const tableHeight = ref();
const formRef = ref(null);
onMounted(() => { onMounted(() => {
// innerHeight-offsetTop- // innerHeight-offsetTop-
tableHeight.value = window.innerHeight - tableRef.value.$el.offsetTop - 70; tableHeight.value = window.innerHeight - tableRef.value.$el.offsetTop - 70;
@ -343,9 +355,34 @@ export default {
return { return {
dialogVisible: false, dialogVisible: false,
form: {}, 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: [], workitems: [],
defaultTime: new Date(1970, 1, 1, 12, 0, 0), defaultTime: new Date(1970, 1, 1, 12, 0, 0),
maps: new Map() maps: new Map(),
} }
}, },
watch: { watch: {
@ -362,14 +399,14 @@ export default {
}, },
methods: { methods: {
statusDisabled(row) { statusDisabled(row) {
return !(row.editable || return row.taskStatus==='已完成'||row.taskStatus==='关闭'||!(row.editable ||
(this.$store.state.staff && row.taskHolderId === this.$store.state.staff.staffId)) (this.$store.state.staff && row.taskHolderId === this.$store.state.staff.staffId))
}, },
onRowClick(row, column, event) { onRowClick(row, column, event) {
if (column.property === "operations") if (column.property === "operations")
return return
this.form = { this.form = {
disabled: !row.editable, disabled: row.taskStatus==='已完成'||row.taskStatus==='关闭'||!row.editable,
statusDisabled: this.statusDisabled(row), statusDisabled: this.statusDisabled(row),
title: '修改' + row.taskType, title: '修改' + row.taskType,
taskId: row.taskId, taskId: row.taskId,
@ -437,113 +474,144 @@ export default {
that.loadChildren(rtr.row, rtr.treeNode, rtr.resolve) 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({ ElMessage({
message: '修改成功', message: '修改成功',
type: 'success', type: 'success',
}) })
that.dialogVisible = false that.dialogVisible = false
} }
else
Promise.reject(response)
}).catch(function (error) { }).catch(function (error) {
console.log(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() { onSubmit() {
let submitForm = { if( !this.$refs['formRef'])
taskType: this.form.taskType, {
taskFatherId: this.form.taskFatherId, console.log('formRef error')
taskName: this.form.taskName, return
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
} }
switch (this.form.taskType) { this.$refs['formRef'].validate((valid) => {
case '需求': console.log(valid)
submitForm['attachedInfo'] = { if(valid)
demandSource: this.form.demandSource {
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; switch (this.form.taskType) {
case '任务': case '需求':
submitForm['attachedInfo'] = { submitForm['attachedInfo'] = {
estimatedManHours: this.form.estimatedManHours demandSource: this.form.demandSource
}
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)
} }
} break;
case '任务':
ElMessage({ submitForm['attachedInfo'] = {
message: '新增成功', estimatedManHours: this.form.estimatedManHours
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 '缺陷':
ElMessage({ submitForm['attachedInfo'] = {
message: '修改成功', severity: this.form.severity,
type: 'success', recurrenceProbability: this.form.recurrenceProbability
}) }
that.dialogVisible = false break;
} }
}).catch(function (error) { console.log(submitForm)
console.log(error) 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) { onEditClick(row) {
@ -668,6 +736,37 @@ export default {
console.log(error) 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) { dateFormatter(row, column) {
const moment = require('moment'); const moment = require('moment');