Browse Source

优化缺陷状态更新呢

qinzhipeng_v 5 years ago
parent
commit
411b72807d

+ 11 - 3
src/views/projectManage/bugList/details/statusChange.vue

@@ -1,5 +1,5 @@
 <template>
-  <div>
+  <div v-if="bugDatas.id === bugIds">
     <el-select
       v-model="status"
       :class="{
@@ -60,12 +60,15 @@ import '@/styles/PublicStyle/index.scss'
 import { bugGetEnum, bugUpdate } from '@/api/defectManage'
 export default {
   props: {
+    bugId: { type: Number, default: null },
     statusCode: { type: Number, default: null }, // 状态值
     bugData: { type: Object, default: null } // 行数据
   },
   data() {
     return {
       status: this.statusCode, // 状态
+      bugIds: this.bugId,
+      bugDatas: this.bugData,
       bugEnumList: [], // 状态option
       userData: { id: '', ename: localStorage.getItem('username'), name: localStorage.getItem('realname') }, // 用户信息
       statusDialogForm: { // 修复结果
@@ -83,8 +86,11 @@ export default {
     }
   },
   watch: {
-    statusCode(newVal, oldVal) {
-      this.status = newVal
+    statusCode: {
+      handler(newV) {
+        this.status = newV
+      },
+      immediate: true
     }
   },
   mounted() {
@@ -92,6 +98,7 @@ export default {
   },
   methods: {
     getBugSelect() { //  获取下拉菜单option
+      console.log(this.bugDatas.id === this.bugIds)
       bugGetEnum().then(res => {
         this.bugEnumList = res.data.bugEnumList // status
         this.repairResultEnumList = res.data.repairResultEnumList // 修复结果
@@ -101,6 +108,7 @@ export default {
     statusDialogConfirm() { // 点击确定 验证 修改
       this.$refs.statusDialogForm.validate((valid) => {
         if (valid) {
+          console.log(this.statusCode, 'code')
           const data = {}
           data.id = this.bugData.id
           data.status = this.status

+ 15 - 15
src/views/workbench/bugTableList.vue

@@ -8,7 +8,7 @@
         <el-dropdown-item v-for="(item, index) in bugProcessStatusList" :key="index" @click.native="handleClick(item)">{{ item.name }}</el-dropdown-item>
       </el-dropdown-menu>
     </el-dropdown>
-    <el-table size="small" :data="tableData" class="bug_tableHeader" show-overflow-tooltip="true" :header-cell-style="{ color: '#4A4A4A', fontSize: '14px', fontWeight: '500' }">
+    <el-table ref="bug_tableHeader" size="small" :data="tableData" class="bug_tableHeader" show-overflow-tooltip="true" :header-cell-style="{ color: '#4A4A4A', fontSize: '14px', fontWeight: '500' }">
       <el-table-column label="优先级" prop="priorityCode" min-width="100" sortable align="center">
         <template slot-scope="scope" style="text-align: center;">
           <span class="div_priority" :class="[{'priority_color': scope.row.priorityLevel === 'High'},{'priority_color1': scope.row.priorityLevel === 'Medium'},{'priority_color3': scope.row.priorityLevel === 'Low'}]">
@@ -26,7 +26,7 @@
       <el-table-column prop="priorityName" label="缺陷等级" align="center" />
       <el-table-column prop="bugStatusName" label="状态" min-width="110" align="center">
         <template slot-scope="scope">
-          <statusChange :status-code="Number(scope.row.status)" :bug-data="scope.row" @bugGet="bugGetTableList" />
+          <statusChange :bug-id="scope.row.id" :status-code="Number(scope.row.status)" :bug-data="scope.row" @bugGet="bugGetTableList" />
         </template>
       </el-table-column>
       <el-table-column prop="taskName" label="所属任务" align="center" min-width="250" show-overflow-tooltip />
@@ -135,7 +135,7 @@ export default {
         }
       })
     },
-    bugGetTableList(name, value) {
+    async bugGetTableList(name, value) {
       const teamSearchInfo = value || { teamId: this.teamId, bizId: this.bizId }
       if (value) {
         this.curIndex = 1
@@ -144,20 +144,20 @@ export default {
       pageInfoDO.pageSize = this.pageSize
       pageInfoDO.curIndex = this.curIndex
       if (this.name === '团队') {
-        bugTeamList({ pageInfoDO, status: this.statusCode, teamSearchInfo }).then(res => {
-          if (res.code === 200) {
-            this.tableData = res.data.map(item => { return { ...item, isSelected: false } })
-            this.total = res.total
-          }
-        })
+        const res = await bugTeamList({ pageInfoDO, status: this.statusCode, teamSearchInfo })
+        if (res.code === 200) {
+          this.$forceUpdate()
+          this.tableData = res.data.map(item => { return { ...item, isSelected: false } })
+          this.total = res.total
+        }
       }
       if (this.name === '个人') {
-        bugSelfList({ pageInfoDO, status: this.statusCode }).then(res => {
-          if (res.code === 200) {
-            this.tableData = res.data.map(item => { return { ...item, isSelected: false } })
-            this.total = res.total
-          }
-        })
+        const res = await bugSelfList({ pageInfoDO, status: this.statusCode })
+        if (res.code === 200) {
+          this.$forceUpdate()
+          this.tableData = res.data.map(item => { return { ...item, isSelected: false } })
+          this.total = res.total
+        }
       }
     },
     handleSizeChange(val) {