Browse Source

report time

scorpio 2 years ago
parent
commit
8446f7041b

+ 6 - 6
src/api/fetch.js

@@ -105,12 +105,12 @@ function fetch(
           }
           ElMessage.error(msg)
         } else {
-          // resolve(err.data)
-          ElMessage.error(
-            err.data.error_description
-              ? err.data.error_description
-              : '网络异常,请点击重试'
-          )
+          resolve(err.data)
+          // ElMessage.error(
+          //   err.data.error_description
+          //     ? err.data.error_description
+          //     : '网络异常,请点击重试'
+          // )
         }
       })
   })

+ 11 - 0
src/api/task/index.js

@@ -61,5 +61,16 @@ export default {
       '/blade-project-manage-v2/task-management/v2/file-list',
       params
     )
+  },
+  /**
+   * 任务晚抽,移动文件到文件夹
+   * @param params
+   * @returns {Promise<unknown>}
+   */
+  fileMove(params) {
+    return fetch(
+      '/blade-project-manage-v2/task-management/v2/move-file',
+      params
+    )
   }
 }

+ 9 - 3
src/views/task/component/move.vue

@@ -112,6 +112,12 @@ export default {
         }
       },
       immediate: true
+    },
+    stageId: {
+      handler(val) {
+        this.getFolderList()
+      },
+      immediate: false
     }
   },
   data() {
@@ -130,7 +136,7 @@ export default {
     }
   },
   methods: {
-    show() {
+    showDialog() {
       this.show = true
     },
     /**
@@ -215,8 +221,8 @@ export default {
       }
     },
     move() {
-      this.$api.resource
-        .fileMove({ fileId: this.fileId, folderId: this.currentFolder.id })
+      this.$api.task
+        .fileMove({ fileIds: this.fileId, folderId: this.currentFolder.id })
         .then(res => {
           if (res.code === 200) {
             this.$message.success(res.msg)

+ 16 - 5
src/views/task/component/task-table.vue

@@ -72,9 +72,9 @@
             class="flex-child-average full-height full-width flex flex-center"
           >
             <div>
-              <el-tag v-for="tag in row.tagsArray" :key="tag" class="mr-10">{{
-                tag
-              }}</el-tag>
+              <el-tag v-for="tag in row.tagsArray" :key="tag" class="mr-10"
+                >{{ tag }}
+              </el-tag>
             </div>
           </div>
           <div
@@ -246,9 +246,20 @@ export default {
       this.$refs.task.show(1)
     },
     rowClick(item) {
+      this.getTaskInfo(item.id)
       this.$emit('rowClick', item)
-      this.task = item
-      this.$refs.task.show(2)
+    },
+    getTaskInfo(id) {
+      this.$api.task.taskInfo({ id }).then(res => {
+        if (res.code === 200) {
+          this.task = res.data
+          this.$nextTick(() => {
+            this.$refs.task.show(2)
+          })
+        } else {
+          this.$message.error(res.msg)
+        }
+      })
     },
     refresh() {
       this.$emit('refresh')

+ 55 - 39
src/views/task/component/task.vue

@@ -64,7 +64,11 @@
         <div class="mt-20 flex lex-align-start flex-justify-start">
           <span class="mr-10 title flex flex-justify-start">标签:</span>
           <div>
-            <wt-label @submit="handleTags" :disabled="!canEdit" />
+            <wt-label
+              @submit="handleTags"
+              :ids="form.tags.split(',')"
+              :disabled="!canEdit"
+            />
           </div>
         </div>
         <div class="mt-20 flex lex-align-start flex-justify-start">
@@ -142,8 +146,9 @@
       </div>
       <move
         ref="move"
-        :file-id="resultFiles.map(ele => ele.id).join(',')"
+        :file-id="resultFiles.map(ele => ele.fileId).join(',')"
         :project-id="form.projectId"
+        @on-success="moveSucc"
       />
     </div>
   </el-dialog>
@@ -161,6 +166,9 @@ import uploadOffice from '@/components/upload-office/index.vue'
 import move from '@/views/task/component/move.vue'
 
 export default {
+  /**
+   * 任务添加、查看
+   */
   computed: {
     api() {
       return api
@@ -187,31 +195,6 @@ export default {
       }
     }
   },
-  watch: {
-    task: {
-      handler(val) {
-        if (val !== null) {
-          this.form = val
-          if (val.users !== undefined) {
-            this.executeUser = [...val.users]
-          }
-          this.canEdit = this.form.createUser === this.user.info.userId
-          if (val.taskStatus > 1) {
-            this.canEdit = false
-          }
-          if (val.files !== undefined && val.files.length > 0) {
-            this.fileList = val.files
-          }
-          this.resultFileInfo()
-        } else {
-          this.form.taskStatus = 0
-          this.form.level = 0
-          this.canEdit = true
-        }
-      },
-      immediate: true
-    }
-  },
   setup() {
     const user = useStore()
     return { user }
@@ -224,6 +207,8 @@ export default {
       canEdit: true,
       executeUser: [],
       resultFiles: [],
+      editResult: false,
+      isMove: false,
       form: {
         title: '',
         taskStatus: -1,
@@ -296,6 +281,22 @@ export default {
     }
   },
   methods: {
+    init() {
+      this.form = this.task
+      console.log(this.task)
+      if (this.task.users !== undefined) {
+        this.executeUser = [...this.task.users]
+      }
+      this.canEdit = this.form.createUser === this.user.info.userId
+      if (this.task.taskStatus > 1) {
+        this.canEdit = false
+      }
+      if (this.task.files !== undefined && this.task.files.length > 0) {
+        this.fileList = this.task.files
+        console.log(this.fileList)
+      }
+      this.resultFileInfo()
+    },
     fetchIndex(list, key) {
       const index = list.findIndex(ele => ele.value === key)
       if (index > -1) {
@@ -313,11 +314,12 @@ export default {
      */
     show(type) {
       if (type !== 1) {
-        this.canEdit = true
         this.form = this.task
-      }
-      if (this.form !== null && this.form.users !== undefined) {
-        this.executeUser = [...this.form.users]
+        this.init(this.task)
+      } else {
+        this.form.taskStatus = 0
+        this.form.level = 0
+        this.canEdit = true
       }
       this.showDialog = true
     },
@@ -348,12 +350,15 @@ export default {
         this.saveResultFile()
       }
 
-      if (this.form.taskStatus === 3) {
+      if (this.form.taskStatus === 3 && this.isMove === false) {
         // 已完成 需要转移文件
-        this.$refs.move.show()
+        this.$refs.move.showDialog()
         return
       }
-      this.form.projectId = this.projectId
+      // 从项目详情,添加任务
+      if (this.projectId !== undefined && this.projectId.length > 0) {
+        this.form.projectId = this.projectId
+      }
       this.form.relatedIds = this.fileList.map(ele => ele.id).join(',')
       this.$api.task.addTask(this.form).then(res => {
         this.showDialog = false
@@ -366,6 +371,9 @@ export default {
       })
     },
     saveResultFile() {
+      if (this.editResult === false) {
+        return
+      }
       this.$api.task
         .taskFile({
           taskId: this.form.id,
@@ -377,8 +385,10 @@ export default {
           }
         })
     },
-    selection(list) {
-      this.fileList = list
+    selection(list, extra) {
+      this.fileList = list.map(ele => {
+        return ele
+      })
     },
     selected(list) {
       this.form.executeUser = list.map(ele => ele.id).join(',')
@@ -388,9 +398,10 @@ export default {
     },
     /**
      * 成果文件上传成果
-     * @param res
+     * @param list
      */
     uploadResult(list) {
+      this.editResult = true
       this.resultFiles = list.map(ele => {
         return {
           id: ele.id,
@@ -415,9 +426,14 @@ export default {
       this.executeUser.length = 0
       this.fileList.length = 0
       this.showDialog = false
+      this.editResult = false
+      this.isMove = false
     },
-    upload(res) {
-      console.log(res)
+    /**
+     * 文件移动成功
+     */
+    moveSucc() {
+      this.isMove = true
     }
   }
 }

+ 19 - 6
src/views/task/component/tasker.vue

@@ -26,7 +26,7 @@
     <el-dialog v-model="show" width="500">
       <div>
         <div class="flex flex-center">
-          <el-input placeholder="搜索" v-model="keyword">
+          <el-input placeholder="搜索" v-model="keyword" @keyup.enter="getUser">
             <template #append>
               <el-button icon="Search" @click="getUser" />
             </template>
@@ -64,11 +64,11 @@
         </div>
         <div class="full-width flex flex-center flex-justify-end mt-20">
           <el-button plain type="primary" size="small" @click="show = false"
-            >取 消</el-button
-          >
+            >取 消
+          </el-button>
           <el-button type="primary" size="small" @click="submit"
-            >确 定</el-button
-          >
+            >确 定
+          </el-button>
         </div>
       </div>
     </el-dialog>
@@ -132,7 +132,20 @@ export default {
       res.checked = !res.checked
     },
     submit() {
-      this.selectedList = this.list.filter(ele => ele.checked)
+      const tmps = this.list.filter(ele => ele.checked)
+      const newAddList = []
+      if (this.selectedList.length > 0) {
+        tmps.forEach(ele => {
+          const tmp = this.selectedList.findIndex(sub => sub.id === ele.id)
+          if (tmp === -1) {
+            newAddList.push(ele)
+          }
+        })
+        this.selectedList = this.selectedList.concat(newAddList)
+      } else {
+        this.selectedList = tmps
+      }
+
       this.$emit('success', this.selectedList)
       this.show = false
     },

+ 27 - 25
src/views/task/component/wt-label.vue

@@ -1,10 +1,12 @@
 <template>
   <div class="flex flex-wrap flex-center">
-    <div class="tag flex flex-center" v-for="i in tags" :key="i.dictValue">
-      {{ i.dictValue }}
-      <el-icon class="ml-10" @click="remove(i)">
-        <CircleCloseFilled />
-      </el-icon>
+    <div v-if="tags.length > 0" class="flex flex-center flex-justify-start">
+      <div class="tag flex flex-center" v-for="i in tags" :key="i.id">
+        {{ i.dictValue }}
+        <el-icon class="ml-10" @click="remove(i)" v-if="!disabled">
+          <CircleCloseFilled />
+        </el-icon>
+      </div>
     </div>
     <el-icon
       size="30"
@@ -46,6 +48,14 @@
 <script>
 export default {
   props: {
+    // 初始化id
+    ids: {
+      type: Array,
+      default: () => {
+        return null
+      }
+    },
+    // 是否可以编辑
     disabled: {
       type: Boolean,
       default: false
@@ -59,26 +69,8 @@ export default {
         tag1: '',
         tag2: ''
       },
-      options: [
-        {
-          label: '新编',
-          value: 1
-        },
-        {
-          label: '修改',
-          value: 2
-        }
-      ],
-      options1: [
-        {
-          label: '项目建议书',
-          value: 1
-        },
-        {
-          label: '可研报告',
-          value: 2
-        }
-      ]
+      options: [],
+      options1: []
     }
   },
   created() {
@@ -89,11 +81,21 @@ export default {
       this.$api.common.dicList({ code: 'edit_task_type' }).then(res => {
         if (res.code === 200) {
           this.options = res.data
+          if (this.ids.length > 0) {
+            const tmp = this.options.find(ele => ele.id === this.ids[0])
+            if (tmp) {
+              this.tags.push(tmp)
+            }
+          }
         }
       })
       this.$api.common.dicList({ code: 'edit_task' }).then(res => {
         if (res.code === 200) {
           this.options1 = res.data
+          if (this.ids.length > 1) {
+            const tmp = this.options1.find(ele => ele.id === this.ids[1])
+            this.tags.push(tmp)
+          }
         }
       })
     },

+ 15 - 8
src/views/task/component/wt-tag.vue

@@ -8,7 +8,7 @@
         style="min-width: 60px"
       >
         <div class="font-12 bold black white">{{ current.title }}</div>
-        <el-icon class="el-icon--right" color="white">
+        <el-icon class="el-icon--right" color="white" v-if="disabled === false">
           <arrow-down />
         </el-icon>
       </div>
@@ -38,14 +38,20 @@
 <script>
 export default {
   props: {
+    // 需要显示的数组
     data: {
+      require: true,
       type: Array,
-      default: []
+      default: () => {
+        return []
+      }
     },
+    // 默认状态值
     status: {
       type: Number,
-      default: -1
+      default: 1
     },
+    // 是否可以编辑
     disabled: {
       type: Boolean,
       default: false
@@ -54,14 +60,15 @@ export default {
   watch: {
     status: {
       handler(val) {
-        console.log(this.data)
         setTimeout(() => {
-          if (val !== -1) {
-            this.current = this.data.find(e => e.value === this.status)
-          } else {
+          if (this.val === -1) {
+            // 新增任务时候 val 为-1
             this.current = this.data[0]
+            console.log(this.current)
+          } else {
+            this.current = this.data.find(e => e.value === val)
           }
-        }, 200)
+        }, 500)
       },
       immediate: true
     }

+ 0 - 10
src/views/task/index.vue

@@ -93,16 +93,6 @@ export default {
     },
     rowClick(res) {
       this.taskId = res.id
-      this.getTaskInfo()
-    },
-    getTaskInfo() {
-      this.$api.task.taskInfo({ id: this.taskId }).then(res => {
-        if (res.code === 200) {
-          this.task = res.data
-        } else {
-          this.$message.error(res.msg)
-        }
-      })
     }
   }
 }