scorpio 2 years ago
parent
commit
4fef8caa0e

+ 9 - 0
src/api/role/index.js

@@ -10,6 +10,15 @@ export default {
     // 用户列表
     return fetch('/blade-user/noRolePage', params, 'get')
   },
+  /**
+   * 用户列表
+   * @param params
+   * @returns {Promise | Promise<unknown>}
+   */
+  userList(params) {
+    // 用户列表
+    return fetch('/blade-user/noRoleList', params, 'get')
+  },
   roleStart(params) {
     // 用户启用/停用
     return fetch('/blade-user/startOrStop', params, 'post')

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

@@ -21,6 +21,17 @@ export default {
   taskList(params) {
     return fetch('/blade-project-manage-v2/task-management/v2/page', params)
   },
+  /**
+   * 项目任务列表
+   * @param params
+   * @returns {Promise | Promise<unknown>}
+   */
+  taskListByProject(params) {
+    return fetch(
+      '/blade-project-manage-v2/task-management/v2/project-task-page',
+      params
+    )
+  },
   /**
    * 任务详情
    * @param params

+ 7 - 3
src/views/home/component/params/params8.vue

@@ -8,6 +8,8 @@
         :option="option"
         :data="data"
         :project-id="detail.id"
+        :total="total"
+        @refresh="list"
       ></task-table>
     </div>
   </div>
@@ -36,8 +38,9 @@ export default {
   },
   data() {
     return {
-      data: [{ title: '33' }],
+      data: [],
       task: {},
+      total: 0,
       option: {
         showCheckBox: false,
         folderChecked: true,
@@ -46,7 +49,7 @@ export default {
             label: '共20个任务',
             prop: 'title',
             display: false,
-            width: 400
+            width: 300
           },
           {
             label: '标签',
@@ -67,10 +70,11 @@ export default {
   methods: {
     list() {
       this.$api.task
-        .taskList({ projectId: this.detail.id, level: 1 })
+        .taskListByProject({ projectId: this.detail.id, level: 1 })
         .then(res => {
           if (res.code === 200) {
             this.data = res.data.records
+            this.total = res.data.total
           }
         })
     }

+ 65 - 17
src/views/task/component/task-table.vue

@@ -1,11 +1,12 @@
 <template>
   <div>
-    <div class="full-width flex flex-center flex-justify-start">
+    <div class="full-width flex flex-center flex-justify-between">
       <el-button type="primary" icon="el-icon-plus" @click="addTask"
         >新增任务
       </el-button>
+      <el-button circle icon="Refresh" @click="refresh" />
     </div>
-    <div class="header flex flex-justify-between full-width">
+    <div class="header flex flex-justify-between full-width mt-10">
       <div
         v-for="(item, index) in option.column"
         :key="item.label"
@@ -16,7 +17,7 @@
           class="flex-child-shrink flex flex-justify-start first"
           :style="`width:` + item.width + 'px'"
         >
-          {{ item.label }}
+          共 {{ total }}个任务
         </div>
         <div v-else class="flex-child-average">
           {{ item.label }}
@@ -43,8 +44,20 @@
             <div
               class="full-width full-height flex flex-justify-start flex-align-center"
             >
-              <div class="level" />
-              <wt-tag :data="status" @change="changeStatus()" />
+              <div
+                class="level"
+                :style="
+                  `background-color:` + row && row.currentLevel
+                    ? row.currentLevel.color
+                    : 'white'
+                "
+              ></div>
+              <wt-tag
+                :data="status"
+                :status="row.taskStatus"
+                :disabled="true"
+                @change="changeStatus()"
+              />
               {{ row[column.prop] }}
             </div>
           </div>
@@ -53,8 +66,9 @@
             class="flex-child-average full-height full-width flex flex-center"
           >
             <div>
-              <el-tag>新编</el-tag>
-              <el-tag class="ml-5">项目建议书</el-tag>
+              <el-tag v-for="tag in row.tagsArray" :key="tag" class="mr-10">{{
+                tag
+              }}</el-tag>
             </div>
           </div>
           <div
@@ -110,18 +124,23 @@ export default {
     option: {
       type: Object,
       default: null
+    },
+    total: {
+      type: Number,
+      default: 0
+    }
+  },
+  watch: {
+    data: {
+      handler(val) {
+        val.forEach(item => {
+          const tmp = this.level.find(ele => ele.value === item.level)
+          item.currentLevel = tmp
+        })
+      },
+      immediate: true
     }
   },
-  // watch: {
-  //   data: {
-  //     handler(val) {
-  //       if (val) {
-  //         this.status = this.fetchIndex(this.status, val[0].taskStatus)
-  //       }
-  //     },
-  //     immediate: true
-  //   }
-  // },
   data() {
     return {
       task: null,
@@ -159,6 +178,32 @@ export default {
           color: '#C72A29',
           checked: false
         }
+      ],
+      level: [
+        {
+          title: 'P1',
+          value: 0,
+          color: '#C72A29',
+          checked: true
+        },
+        {
+          title: 'P2',
+          value: 1,
+          color: '#E89D42',
+          checked: false
+        },
+        {
+          title: 'P3',
+          value: 2,
+          color: '#47A6EA',
+          checked: false
+        },
+        {
+          title: 'P4',
+          value: 3,
+          color: '#A0A0A0',
+          checked: false
+        }
       ]
     }
   },
@@ -186,6 +231,9 @@ export default {
       this.info.taskStatus = res.value
       this.submit()
     },
+    refresh() {
+      this.$emit('refresh')
+    },
     submit() {
       this.$api.task.addTask(this.info).then(res => {
         this.showDialog = false

+ 10 - 2
src/views/task/component/task.vue

@@ -10,7 +10,11 @@
       <div class="mt-10">
         <div class="flex flex-center flex-justify-start">
           <span class="mr-10 title flex flex-justify-start">状态:</span>
-          <wt-tag :data="status" @change="changeStatus($event, 1)" />
+          <wt-tag
+            :data="status"
+            @change="changeStatus($event, 1)"
+            :disabled="false"
+          />
         </div>
 
         <div class="mt-10 flex flex-center flex-justify-start">
@@ -50,7 +54,10 @@
         <div class="mt-10 flex lex-align-start flex-justify-start">
           <span class="mr-10 title flex flex-justify-start">执行者:</span>
           <div>
-            <tasker :data="task.users" @success="selected" />
+            <tasker
+              :data="task === null ? [] : task.users"
+              @success="selected"
+            />
           </div>
         </div>
         <div class="mt-10 flex flex-align-start flex-justify-start">
@@ -262,6 +269,7 @@ export default {
       this.form.executeUser = list.map(ele => ele.id).join(',')
     },
     handleTags(tags) {
+      console.log(tags)
       this.form.tags = tags
     },
     close() {

+ 34 - 27
src/views/task/component/tasker.vue

@@ -24,32 +24,41 @@
 
     <el-dialog v-model="show" width="500">
       <div>
-        <el-input placeholder="搜索"></el-input>
+        <div class="flex flex-center">
+          <el-input placeholder="搜索" v-model="keyword">
+            <template #append>
+              <el-button icon="Search" @click="getUser" />
+            </template>
+          </el-input>
+        </div>
         <div
           class="mt-20 padding-left padding-right"
           style="height: 300px; overflow-y: scroll"
         >
-          <div
-            v-for="i in list"
-            :key="i.id"
-            class="full-width flex flex-justify-between flex-center border-bottom padding-bottom padding-top"
-            @click="change(i)"
-          >
-            <div class="flex flex-center flex-justify-start">
-              <el-icon v-if="i.checked" color="#ab7630" size="18px">
-                <CircleCheckFilled />
-              </el-icon>
-              <el-icon v-else color="grey" size="18px">
-                <CircleCheck />
-              </el-icon>
-              <el-avatar
-                class="ml-10 mr-10"
-                :size="25"
-                :src="i.avatar"
-              ></el-avatar>
-              <div class="ml-5">{{ i.name }}</div>
+          <el-empty v-if="list.length === 0" description="暂无数据" />
+          <div v-else>
+            <div
+              v-for="i in list"
+              :key="i.id"
+              class="full-width flex flex-justify-between flex-center border-bottom padding-bottom padding-top"
+              @click="change(i)"
+            >
+              <div class="flex flex-center flex-justify-start">
+                <el-icon v-if="i.checked" color="#ab7630" size="18px">
+                  <CircleCheckFilled />
+                </el-icon>
+                <el-icon v-else color="grey" size="18px">
+                  <CircleCheck />
+                </el-icon>
+                <el-avatar
+                  class="ml-10 mr-10"
+                  :size="25"
+                  :src="i.avatar"
+                ></el-avatar>
+                <div class="ml-5">{{ i.name }}</div>
+              </div>
+              <el-tag>出差中</el-tag>
             </div>
-            <el-tag>出差中</el-tag>
           </div>
         </div>
         <div class="full-width flex flex-center flex-justify-end mt-20">
@@ -82,6 +91,7 @@ export default {
   watch: {
     data: {
       handler(val) {
+        console.log(val)
         if (val && val.length > 0) {
           this.selectedList = val
         }
@@ -97,15 +107,12 @@ export default {
       selectedList: []
     }
   },
-  created() {
-    this.getUser()
-  },
   methods: {
     getUser() {
-      const data = { key: this.keyword, deptId: this.user.info.deptId }
-      this.$api.role.roleList(data).then(res => {
+      const data = { realName: this.keyword, deptId: this.user.info.deptId }
+      this.$api.role.userList(data).then(res => {
         if (res.code === 200) {
-          this.list = res.data.records.map(ele => {
+          this.list = res.data.map(ele => {
             ele.avatar = ele.avatar
               ? ele.avatar
               : 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'

+ 32 - 11
src/views/task/component/wt-label.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="flex flex-wrap flex-center">
-    <div class="tag flex flex-center" v-for="i in tags" :key="i.label">
-      {{ i.label }}
+    <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>
@@ -20,17 +20,17 @@
         <el-select v-model="form.tag1" class="mr-10" placeholder="请选择">
           <el-option
             v-for="item in options"
-            :key="item.value"
-            :label="item.label"
-            :value="item"
+            :key="item.dictKey"
+            :label="item.dictValue"
+            :value="item.dictKey"
           />
         </el-select>
         <el-select v-model="form.tag2" placeholder="请选择">
           <el-option
             v-for="item in options1"
-            :key="item.value"
-            :label="item.label"
-            :value="item"
+            :key="item.dictKey"
+            :label="item.dictValue"
+            :value="item.dictKey"
           />
         </el-select>
       </div>
@@ -74,15 +74,36 @@ export default {
       ]
     }
   },
+  created() {
+    this.init()
+  },
   methods: {
+    init() {
+      this.$api.common.dicList({ code: 'edit_task_type' }).then(res => {
+        if (res.code === 200) {
+          this.options = res.data
+        }
+      })
+      this.$api.common.dicList({ code: 'edit_task' }).then(res => {
+        if (res.code === 200) {
+          this.options1 = res.data
+        }
+      })
+    },
     submit() {
-      this.tags = [this.form.tag1, this.form.tag2]
+      this.tags = [
+        this.options.find(ele => ele.dictKey === this.form.tag1),
+        this.options1.find(ele => ele.dictKey === this.form.tag2)
+      ]
       this.show = false
       this.form = {}
-      this.$emit('submit', { tags: this.tags })
+      const tmps = this.tags.map(ele => ele.id).join(',')
+      this.$emit('submit', tmps)
     },
     remove(res) {
-      this.tags = this.tags.filter(ele => ele.label !== res.label)
+      this.tags = this.tags.filter(ele => ele.id !== res.id)
+      const tmps = this.tags.map(ele => ele.id).join(',')
+      this.$emit('submit', tmps)
     }
   }
 }

+ 14 - 2
src/views/task/component/wt-tag.vue

@@ -1,5 +1,5 @@
 <template>
-  <el-dropdown @command="dropDown">
+  <el-dropdown @command="dropDown" :disabled="disabled">
     <span class="flex flex-center">
       <div
         class="tag flex flex-center"
@@ -40,13 +40,25 @@ export default {
     data: {
       type: Array,
       default: []
+    },
+    status: {
+      type: Number,
+      default: -1
+    },
+    disabled: {
+      type: Boolean,
+      default: false
     }
   },
   watch: {
     data: {
       handler(val) {
         if (val && val.length > 0) {
-          this.current = val.find(e => e.checked)
+          if (this.status !== -1) {
+            this.current = val.find(e => e.value === this.status)
+          } else {
+            this.current = val.find(e => e.checked)
+          }
         }
       },
       immediate: true

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

@@ -20,6 +20,7 @@
           :option="option"
           :data="data"
           @rowClick="rowClick"
+          @refresh="getTaskList"
         ></task-table>
       </div>
       <task ref="task" :task="task"></task>