Ver Fonte

task适配类型字段

ximinghao há 3 semanas atrás
pai
commit
d09020be69
2 ficheiros alterados com 100 adições e 37 exclusões
  1. 22 22
      src/api/rwgl.js
  2. 78 15
      src/views/rwgl/Index.vue

+ 22 - 22
src/api/rwgl.js

@@ -9,14 +9,14 @@ const multiSearch = dmsPath + "/content/multipleFormsOfJointInvestigation"
 
 const taskDmsId = 1662
 
-export function getTaskStatus() {
+export function getCName(cName) {
     return resolveResult(content.getCategoryDetail({
         type: 0,
-        cName: "task_status",
+        cName: cName,
     }))
 }
 
-export function getTasks(page, pageSize, name, status) {
+export function getTasks(page, pageSize, name, status,type) {
     let data = {
         "columnId": taskDmsId,
         "autoSelectItem": true,
@@ -25,42 +25,42 @@ export function getTasks(page, pageSize, name, status) {
         "columnAlias": "main",
         "orderBy":"main,c_start_time,desc",
         "conditionsList": JSON.stringify([
-            ...getNameChecker(name),
-            ...getStatusChecker(status)
+            ...getEqualChecker(name,"c_name"),
+            ...getTypeChecker(status,"c_state"),
+            ...getTypeChecker(type,"c_type"),
         ]),
     }
 
     return resolveDmsMultiTableResult(postform(multiSearch, data));
 }
 
-function getNameChecker(name) {
-    if (name == null||name=="") {
+function getEqualChecker(value,param) {
+    if (value == null||value=="") {
         return []
     }
     return [{
         "columnId": "main",
-        "columnName": "c_name",
+        "columnName": param,
         "condition": "like",
-        "value": `%${name}%`
+        "value": `%${value}%`
     }]
 }
-function getStatusChecker(status) {
+function getTypeChecker(value,param) {
     
-    if (status == null || status.length == 0) {
+    if (value == null || value.length == 0) {
         return []
     }
-    let output = ["or"]
-    for (let i = 0; i < status.length; i++) {
-        const e = status[i];
-        
-        output.push({
-            "columnId": "main",
-            "columnName": "c_state",
-            "condition": "=",
-            "value": `${e}`
-        })
+    let output = []
+    for (let i = 0; i < value.length; i++) {
+        const e = value[i];
+        output.push(e+"")
     }
-    return [output]
+    return [{
+            "columnId": "main",
+            "columnName": param,
+            "condition": "in",
+            "value": output
+        }]
 }
 
 async function resolveResult(result) {

+ 78 - 15
src/views/rwgl/Index.vue

@@ -15,6 +15,19 @@
                         </el-tag>
                     </template>
                 </div>
+                <div>
+                    <div>类别:</div>
+                    <el-tag size="large" :effect="focusTaskType.includes('all') ? 'dark' : ''" type="primary"
+                        @click="changeTaskType()">
+                        全部
+                    </el-tag>
+                    <template v-for="type in taskType" :key="type.index">
+                        <el-tag size="large" :effect="focusTaskType.includes(type.index) ? 'dark' : ''" type="primary"
+                            @click="changeTaskType(type)">
+                            {{ type.name }}
+                        </el-tag>
+                    </template>
+                </div>
             </span>
             <div class="row">
                 <el-input class="searcher" v-model="searcher" placeholder="请输入任务名称相关关键字" />
@@ -27,9 +40,16 @@
             <el-table table-layout="fixed" row-key="main_id" :data="taskData" class="table">
                 <el-table-column prop="main_c_name" label="名称" />
                 <el-table-column prop="main_c_user_name" label="用户" />
+                <el-table-column prop="main_c_state" label="类型">
+                    <template #default="scope">
+                        <el-tag effect="dark" v-show="getType(scope.row.main_c_type) != null" disable-transitions>{{
+                            getType(scope.row.main_c_type)?.name ?? '' }}
+                        </el-tag>
+                    </template>
+                </el-table-column>
                 <el-table-column prop="main_c_state" label="状态">
                     <template #default="scope">
-                        <el-tag effect="dark" :type="statusStaticInfo[scope.row.main_c_state]?.tagType ?? ''"
+                        <el-tag effect="dark" v-show="getStatus(scope.row.main_c_state)!=null" :type="statusStaticInfo[scope.row.main_c_state]?.tagType ?? ''"
                             disable-transitions>{{
                                 getStatus(scope.row.main_c_state)?.name ?? '' }}</el-tag>
                     </template>
@@ -88,6 +108,11 @@
                 <el-descriptions-item label="任务描述">
                     {{ focusTask.main_c_comment }}
                 </el-descriptions-item>
+                <el-descriptions-item label="任务类型">
+                    <el-tag effect="dark" v-show="getType(focusTask.main_c_type) != null" disable-transitions>{{
+                            getType(focusTask.main_c_type)?.name ?? '' }}
+                        </el-tag>
+                </el-descriptions-item>
                 <el-descriptions-item label="用户名">
                     {{ focusTask.main_c_user_name }}
                 </el-descriptions-item>
@@ -137,7 +162,7 @@
 </template>
 
 <script>
-import { getTasks, getTaskStatus } from '@/api/rwgl';
+import { getTasks, getCName } from '@/api/rwgl';
 
 export default {
     data() {
@@ -145,8 +170,6 @@ export default {
             searcher: "",
             taskStatus: [],
             focusTaskStatus: ["all"],
-            taskData: [],
-            taskNum: 0,
             statusStaticInfo: {
                 0: {
                     tagType: "primary"
@@ -161,6 +184,10 @@ export default {
                     tagType: "danger"
                 },
             },
+            taskType: [],
+            focusTaskType: ["all"],
+            taskData: [],
+            taskNum: 0,
             focusTask: {},
             dialog: false,
             page: 1
@@ -168,11 +195,12 @@ export default {
     },
     mounted() {
         this.pullTaskStatus()
+        this.pullTaskType()
         this.pullTaskData(1)
     },
     methods: {
         async pullTaskStatus() {
-            this.taskStatus = (await getTaskStatus()).sort((a, b) => a.index - b.index)
+            this.taskStatus = (await getCName("task_status")).sort((a, b) => a.index - b.index)
         },
         changeTaskStatus(status) {
             if (status == null) {
@@ -194,17 +222,11 @@ export default {
         },
         getCheckedStatus() {
             if (this.focusTaskStatus.includes("all")) {
-                return this.taskStatus.map(t => t.index)
+                return null
             } else {
                 return this.focusTaskStatus
             }
         },
-        async pullTaskData(page) {
-            if (page != null) this.page = page
-            let res = await getTasks(this.page, 10, this.searcher, this.getCheckedStatus())
-            this.taskNum = res.count
-            this.taskData = res.data
-        },
         getStatus(index) {
             for (let i = 0; i < this.taskStatus.length; i++) {
                 const e = this.taskStatus[i];
@@ -213,11 +235,52 @@ export default {
                 }
             }
         },
-        timeFormatter(time) {
-            if(time==null) return;
+        async pullTaskType() {
+            this.taskType = (await getCName("yzt_task_type")).sort((a, b) => a.index - b.index)
+        },
+        changeTaskType(types) {
+            if (types == null) {
+                this.focusTaskType = ["all"]
+            } else {
+                let set = new Set(this.focusTaskType)
+                set.delete("all")
+                let index = types.index
+                if (this.focusTaskType.includes(index)) {
+                    set.delete(index)
+                } else {
+                    set.add(index)
+                }
+                this.focusTaskType = Array.from(set)
+            }
+        },
+        getCheckedType() {
+            if (this.focusTaskType.includes("all")) {
+                return null
+            } else {
+                return this.focusTaskType
+            }
+        },
+        getType(index) {
+            console.log(index);
             
+            for (let i = 0; i < this.taskType.length; i++) {
+                const e = this.taskType[i];
+                if (e.index == index) {
+                    return e;
+                }
+            }
+        },
+        async pullTaskData(page) {
+            if (page != null) this.page = page
+            let res = await getTasks(this.page, 10, this.searcher, this.getCheckedStatus(), this.getCheckedType())
+            this.taskNum = res.count
+            this.taskData = res.data
+        },
+        timeFormatter(time) {
+            if (time == null) return;
+
             let date = new Date(time)
-            
+
             return date.toLocaleString()
         },
         async downloadWithBlob(url, filename) {