From 4222e5f316b022fa01f566416f5d501c116f4d98 Mon Sep 17 00:00:00 2001
From: xiebin <123456>
Date: Wed, 21 Sep 2022 16:52:52 +0800
Subject: [PATCH] 任务计划新增设置巡检人员模块

---
 src/router/views/index.js           |  229 +++++++++++-----------
 src/views/taskinfo/taskplanUser.vue |  191 +++++++++++++++++++
 src/const/taskinfo/taskplanUser.js  |   77 +++++++
 src/api/taskinfo/taskplanUser.js    |   50 +++++
 src/views/taskinfo/taskinfoPlan.vue |    5 
 5 files changed, 441 insertions(+), 111 deletions(-)

diff --git a/src/api/taskinfo/taskplanUser.js b/src/api/taskinfo/taskplanUser.js
new file mode 100644
index 0000000..c5dde76
--- /dev/null
+++ b/src/api/taskinfo/taskplanUser.js
@@ -0,0 +1,50 @@
+import request from '@/router/axios';
+
+export const getList = (current, size, params) => {
+  return request({
+    url: '/api/taskplanUser/taskplanUser/page',
+    method: 'get',
+    params: {
+      ...params,
+      current,
+      size,
+    }
+  })
+}
+
+export const getDetail = (id) => {
+  return request({
+    url: '/api/taskplanUser/taskplanUser/detail',
+    method: 'get',
+    params: {
+      id
+    }
+  })
+}
+
+export const remove = (ids) => {
+  return request({
+    url: '/api/taskplanUser/taskplanUser/remove',
+    method: 'post',
+    params: {
+      ids,
+    }
+  })
+}
+
+export const add = (row) => {
+  return request({
+    url: '/api/taskplanUser/taskplanUser/submit',
+    method: 'post',
+    data: row
+  })
+}
+
+export const update = (row) => {
+  return request({
+    url: '/api/taskplanUser/taskplanUser/submit',
+    method: 'post',
+    data: row
+  })
+}
+
diff --git a/src/const/taskinfo/taskplanUser.js b/src/const/taskinfo/taskplanUser.js
new file mode 100644
index 0000000..810b707
--- /dev/null
+++ b/src/const/taskinfo/taskplanUser.js
@@ -0,0 +1,77 @@
+export default {
+  height:'auto',
+  calcHeight: 30,
+  tip: false,
+  searchShow: true,
+  searchMenuSpan: 6,
+  border: true,
+  index: true,
+  viewBtn: false,
+  editBtn: false,
+  selection: true,
+  dialogClickModal: false,
+  column: [
+    {
+      label: "主键",
+      prop: "id",
+      type: "input",
+      addDisplay: false,
+      editDisplay: false,
+      viewDisplay: false,
+      hide: true,
+    },
+    {
+      label: "巡检计划id",
+      prop: "planId",
+      type: "input",
+      hide: true,
+      addDisplay: false,
+      editDisplay: false,
+      viewDisplay: false,
+    },
+    {
+      label: "用户",
+      prop: "userId",
+      type: "select",
+      dicUrl: "/api/blade-user/user-list",
+      props: {
+        label: "name",
+        value: "id"
+      },
+    },
+    {
+      label: "开始时间",
+      prop: "startTime",
+      type: 'time',
+      format:'HH:mm',
+      valueFormat:'HH:mm',
+      pickerOptions:{
+        start: '08:30',
+        step: '00:15',
+        end: '18:30'
+      }
+    },
+    {
+      label: "结束时间",
+      prop: "endTime",
+      type: 'time',
+      format:'HH:mm',
+      valueFormat:'HH:mm',
+      pickerOptions:{
+        start: '08:30',
+        step: '00:15',
+        end: '18:30',
+        minTime: '${startTime}'
+      }
+    },
+    {
+      label: "是否已删除",
+      prop: "isDeleted",
+      type: "input",
+      addDisplay: false,
+      editDisplay: false,
+      viewDisplay: false,
+      hide: true,
+    },
+  ]
+}
diff --git a/src/router/views/index.js b/src/router/views/index.js
index 84ebe06..832e1d9 100644
--- a/src/router/views/index.js
+++ b/src/router/views/index.js
@@ -2,127 +2,127 @@
 
 export default [
   {
-  path: '/wel',
-  component: Layout,
-  redirect: '/wel/index',
-  children: [{
-    path: 'index',
-    name: '首页',
-    meta: {
-      i18n: 'dashboard'
-    },
-    component: () =>
-      import( /* webpackChunkName: "views" */ '@/views/wel/index')
-  }, {
-    path: 'dashboard',
-    name: '控制台',
-    meta: {
-      i18n: 'dashboard',
-      menu: false,
-    },
-    component: () =>
-      import( /* webpackChunkName: "views" */ '@/views/wel/dashboard')
-  }]
-},
+    path: '/wel',
+    component: Layout,
+    redirect: '/wel/index',
+    children: [{
+      path: 'index',
+      name: '首页',
+      meta: {
+        i18n: 'dashboard'
+      },
+      component: () =>
+        import( /* webpackChunkName: "views" */ '@/views/wel/index')
+    }, {
+      path: 'dashboard',
+      name: '控制台',
+      meta: {
+        i18n: 'dashboard',
+        menu: false,
+      },
+      component: () =>
+        import( /* webpackChunkName: "views" */ '@/views/wel/dashboard')
+    }]
+  },
   {
-  path: '/test',
-  component: Layout,
-  redirect: '/test/index',
-  children: [{
-    path: 'index',
-    name: '测试页',
-    meta: {
-      i18n: 'test'
-    },
-    component: () =>
-      import( /* webpackChunkName: "views" */ '@/views/util/test')
-  }]
-},
+    path: '/test',
+    component: Layout,
+    redirect: '/test/index',
+    children: [{
+      path: 'index',
+      name: '测试页',
+      meta: {
+        i18n: 'test'
+      },
+      component: () =>
+        import( /* webpackChunkName: "views" */ '@/views/util/test')
+    }]
+  },
   {
-  path: '/dict-horizontal',
-  component: Layout,
-  redirect: '/dict-horizontal/index',
-  children: [{
-    path: 'index',
-    name: '字典管理',
-    meta: {
-      i18n: 'dict'
-    },
-    component: () =>
-      import( /* webpackChunkName: "views" */ '@/views/util/demo/dict-horizontal')
-  }]
-},
+    path: '/dict-horizontal',
+    component: Layout,
+    redirect: '/dict-horizontal/index',
+    children: [{
+      path: 'index',
+      name: '字典管理',
+      meta: {
+        i18n: 'dict'
+      },
+      component: () =>
+        import( /* webpackChunkName: "views" */ '@/views/util/demo/dict-horizontal')
+    }]
+  },
   {
-  path: '/dict-vertical',
-  component: Layout,
-  redirect: '/dict-vertical/index',
-  children: [{
-    path: 'index',
-    name: '字典管理',
-    meta: {
-      i18n: 'dict'
-    },
-    component: () =>
-      import( /* webpackChunkName: "views" */ '@/views/util/demo/dict-vertical')
-  }]
-},
+    path: '/dict-vertical',
+    component: Layout,
+    redirect: '/dict-vertical/index',
+    children: [{
+      path: 'index',
+      name: '字典管理',
+      meta: {
+        i18n: 'dict'
+      },
+      component: () =>
+        import( /* webpackChunkName: "views" */ '@/views/util/demo/dict-vertical')
+    }]
+  },
   {
-  path: '/info',
-  component: Layout,
-  redirect: '/info/index',
-  children: [{
-    path: 'index',
-    name: '个人信息',
-    meta: {
-      i18n: 'info'
-    },
-    component: () =>
-      import( /* webpackChunkName: "views" */ '@/views/system/userinfo')
-  }]
-},
+    path: '/info',
+    component: Layout,
+    redirect: '/info/index',
+    children: [{
+      path: 'index',
+      name: '个人信息',
+      meta: {
+        i18n: 'info'
+      },
+      component: () =>
+        import( /* webpackChunkName: "views" */ '@/views/system/userinfo')
+    }]
+  },
   {
-  path: '/work/process/leave',
-  component: Layout,
-  redirect: '/work/process/leave/form',
-  children: [{
-    path: 'form/:processDefinitionId',
-    name: '请假流程',
-    meta: {
-      i18n: 'work'
-    },
-    component: () =>
-      import( /* webpackChunkName: "views" */ '@/views/work/process/leave/form')
-  }, {
-    path: 'handle/:taskId/:processInstanceId/:businessId',
-    name: '处理请假流程',
-    meta: {
-      i18n: 'work'
-    },
-    component: () =>
-      import( /* webpackChunkName: "views" */ '@/views/work/process/leave/handle')
-  }, {
-    path: 'detail/:processInstanceId/:businessId',
-    name: '请假流程详情',
-    meta: {
-      i18n: 'work'
-    },
-    component: () =>
-      import( /* webpackChunkName: "views" */ '@/views/work/process/leave/detail')
-  }]
-},
+    path: '/work/process/leave',
+    component: Layout,
+    redirect: '/work/process/leave/form',
+    children: [{
+      path: 'form/:processDefinitionId',
+      name: '请假流程',
+      meta: {
+        i18n: 'work'
+      },
+      component: () =>
+        import( /* webpackChunkName: "views" */ '@/views/work/process/leave/form')
+    }, {
+      path: 'handle/:taskId/:processInstanceId/:businessId',
+      name: '处理请假流程',
+      meta: {
+        i18n: 'work'
+      },
+      component: () =>
+        import( /* webpackChunkName: "views" */ '@/views/work/process/leave/handle')
+    }, {
+      path: 'detail/:processInstanceId/:businessId',
+      name: '请假流程详情',
+      meta: {
+        i18n: 'work'
+      },
+      component: () =>
+        import( /* webpackChunkName: "views" */ '@/views/work/process/leave/detail')
+    }]
+  },
   {
     path: '/taskinfo',
     component: Layout,
     children: [
       {
-      path: 'index',
-      name: '巡检任务管理',
-      meta: {
-        i18n: 'taskinfo'
+        path: 'index',
+        name: '巡检任务管理',
+        meta: {
+          i18n: 'taskinfo'
+        },
+        component: () =>
+          import ( /* webpackChunkName: "views" */ '@/views/taskinfo/taskinfo')
       },
-      component: () =>
-        import ( /* webpackChunkName: "views" */ '@/views/taskinfo/taskinfo')
-    },
       {
         path: 'taskinfoDetail',
         name: '巡检任务详情信息',
@@ -131,6 +131,15 @@
         },
         component: () =>
           import ( /* webpackChunkName: "views" */ '@/views/taskinfo/taskinfoDetail')
+      },
+      {
+        path: 'taskplanUser',
+        name: '设置巡检人员',
+        meta: {
+          i18n: 'detail',
+        },
+        component: () =>
+          import ( /* webpackChunkName: "views" */ '@/views/taskinfo/taskplanUser')
       }
     ]
   },
diff --git a/src/views/taskinfo/taskinfoPlan.vue b/src/views/taskinfo/taskinfoPlan.vue
index 27e7d70..279b585 100644
--- a/src/views/taskinfo/taskinfoPlan.vue
+++ b/src/views/taskinfo/taskinfoPlan.vue
@@ -28,7 +28,7 @@
         </el-button>
       </template>
       <template slot-scope="scope" slot="menu">
-        <el-button style="margin-left:10px;" size="small" type="text" icon="el-icon-user" >设置巡检人</el-button>
+        <el-button style="margin-left:10px;" size="small" type="text" icon="el-icon-user" @click="goToTaskplanUser(scope.row.id)">设置巡检人</el-button>
       </template>
       <template slot-scope="{type,size,row,index}" slot="menuBtn">
         <el-row style="width: 150px">
@@ -221,6 +221,9 @@
           });
           this.$refs.crud.toggleSelection();
         })
+      },
+      goToTaskplanUser(planId) {
+        this.$router.push({ path: "/taskinfo/taskplanUser", query: {planId:planId} });
       }
     }
   };
diff --git a/src/views/taskinfo/taskplanUser.vue b/src/views/taskinfo/taskplanUser.vue
new file mode 100644
index 0000000..b16c1a3
--- /dev/null
+++ b/src/views/taskinfo/taskplanUser.vue
@@ -0,0 +1,191 @@
+<template>
+  <basic-container>
+    <avue-crud :option="option"
+               :table-loading="loading"
+               :data="data"
+               :page.sync="page"
+               :permission="permissionList"
+               :before-open="beforeOpen"
+               v-model="form"
+               ref="crud"
+               @row-update="rowUpdate"
+               @row-save="rowSave"
+               @row-del="rowDel"
+               @search-change="searchChange"
+               @search-reset="searchReset"
+               @selection-change="selectionChange"
+               @current-change="currentChange"
+               @size-change="sizeChange"
+               @refresh-change="refreshChange"
+               @on-load="onLoad">
+      <template slot="menuLeft">
+        <el-button type="danger"
+                   size="small"
+                   icon="el-icon-delete"
+                   plain
+                   @click="handleDelete">删 除
+        </el-button>
+      </template>
+    </avue-crud>
+  </basic-container>
+</template>
+
+<script>
+  import {getList, getDetail, add, update, remove} from "@/api/taskinfo/taskplanUser";
+  import option from "@/const/taskinfo/taskplanUser";
+  import {mapGetters} from "vuex";
+
+  export default {
+    name: "taskplanUser",
+    data() {
+      return {
+        form: {},
+        query: {},
+        loading: true,
+        page: {
+          pageSize: 10,
+          currentPage: 1,
+          total: 0
+        },
+        selectionList: [],
+        option: option,
+        data: []
+      };
+    },
+    computed: {
+      ...mapGetters(["permission"]),
+      permissionList() {
+        return {
+          addBtn: true,
+          viewBtn: true,
+          delBtn: true,
+          editBtn: true
+        };
+      },
+      ids() {
+        let ids = [];
+        this.selectionList.forEach(ele => {
+          ids.push(ele.id);
+        });
+        return ids.join(",");
+      }
+    },
+    created() {
+      this.form = this.$route.query;
+    },
+    methods: {
+      rowSave(row, done, loading) {
+        add(row).then(() => {
+          this.onLoad(this.page);
+          this.$message({
+            type: "success",
+            message: "操作成功!"
+          });
+          done();
+        }, error => {
+          loading();
+          window.console.log(error);
+        });
+      },
+      rowUpdate(row, index, done, loading) {
+        update(row).then(() => {
+          this.onLoad(this.page);
+          this.$message({
+            type: "success",
+            message: "操作成功!"
+          });
+          done();
+        }, error => {
+          loading();
+          console.log(error);
+        });
+      },
+      rowDel(row) {
+        this.$confirm("确定将选择数据删除?", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        })
+          .then(() => {
+            return remove(row.id);
+          })
+          .then(() => {
+            this.onLoad(this.page);
+            this.$message({
+              type: "success",
+              message: "操作成功!"
+            });
+          });
+      },
+      handleDelete() {
+        if (this.selectionList.length === 0) {
+          this.$message.warning("请选择至少一条数据");
+          return;
+        }
+        this.$confirm("确定将选择数据删除?", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        })
+          .then(() => {
+            return remove(this.ids);
+          })
+          .then(() => {
+            this.onLoad(this.page);
+            this.$message({
+              type: "success",
+              message: "操作成功!"
+            });
+            this.$refs.crud.toggleSelection();
+          });
+      },
+      beforeOpen(done, type) {
+        if (["edit", "view"].includes(type)) {
+          getDetail(this.form.id).then(res => {
+            this.form = res.data.data;
+          });
+        }
+        done();
+      },
+      searchReset() {
+        this.query = {};
+        this.onLoad(this.page);
+      },
+      searchChange(params, done) {
+        this.query = params;
+        this.page.currentPage = 1;
+        this.onLoad(this.page, params);
+        done();
+      },
+      selectionChange(list) {
+        this.selectionList = list;
+      },
+      selectionClear() {
+        this.selectionList = [];
+        this.$refs.crud.toggleSelection();
+      },
+      currentChange(currentPage){
+        this.page.currentPage = currentPage;
+      },
+      sizeChange(pageSize){
+        this.page.pageSize = pageSize;
+      },
+      refreshChange() {
+        this.onLoad(this.page, this.query);
+      },
+      onLoad(page, params = {}) {
+        this.loading = true;
+        getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
+          const data = res.data.data;
+          this.page.total = data.total;
+          this.data = data.records;
+          this.loading = false;
+          this.selectionClear();
+        });
+      }
+    }
+  };
+</script>
+
+<style>
+</style>

--
Gitblit v1.9.3