From fec7909e8552e98c60f3e14efc7d208e109dc4f8 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Fri, 26 Aug 2022 11:07:41 +0800
Subject: [PATCH] 增加秧苗

---
 src/views/system/user.vue |  299 ++++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 214 insertions(+), 85 deletions(-)

diff --git a/src/views/system/user.vue b/src/views/system/user.vue
index 831b2df..9dfd586 100644
--- a/src/views/system/user.vue
+++ b/src/views/system/user.vue
@@ -1,6 +1,6 @@
 <template>
   <el-row>
-    <el-col :span="5">
+    <!-- <el-col :span="5">
       <div class="box">
         <el-scrollbar>
           <basic-container>
@@ -8,8 +8,8 @@
           </basic-container>
         </el-scrollbar>
       </div>
-    </el-col>
-    <el-col :span="19">
+    </el-col> -->
+    <el-col :span="24">
       <basic-container>
         <avue-crud :option="option"
                    :search.sync="search"
@@ -30,6 +30,20 @@
                    @size-change="sizeChange"
                    @refresh-change="refreshChange"
                    @on-load="onLoad">
+          <template slot-scope="{type,row,size}" slot="menu">
+            <el-button 
+              :type="type"
+              :size="size"
+              icon="el-icon-edit"
+              :disabled="row.roleId == '1123598816738675201' "
+              @click="update(row)">编辑</el-button>
+            <el-button 
+              :type="type"
+              :size="size"
+              icon="el-icon-delete"
+              :disabled="row.roleId == '1123598816738675201' "
+              @click="rowDel(row)">删除</el-button>
+          </template>
           <template slot="menuLeft">
             <el-button type="danger"
                        size="small"
@@ -160,6 +174,28 @@
             </template>
           </avue-crud>
         </el-dialog>
+        <el-drawer
+            title="编辑"
+            size="60%"
+            :visible.sync="dialogVisible"
+            width="width"
+            :modal="true"
+            :modal-append-to-body="false"
+            :append-to-body="true"
+            :close-on-click-modal="false"
+            :close-on-press-escape="false"
+          >
+            <div>
+              <avue-form
+                ref="form"
+                :option="option"
+                v-model="form"
+                @reset-change="emptytChange"
+                @submit="submitUpdate"
+              >
+              </avue-form>
+            </div>
+          </el-drawer>
       </basic-container>
     </el-col>
   </el-row>
@@ -179,6 +215,7 @@
   } from "@/api/system/user";
   import {exportBlob} from "@/api/common";
   import {getDeptTree, getDeptLazyTree} from "@/api/system/dept";
+  import {getFarmList} from "@/api/farm/farm";
   import {getRoleTree} from "@/api/system/role";
   import {getPostList} from "@/api/system/post";
   import {mapGetters} from "vuex";
@@ -213,6 +250,7 @@
         roleBox: false,
         excelBox: false,
         platformBox: false,
+        dialogVisible:false,
         initFlag: true,
         selectionList: [],
         query: {},
@@ -274,8 +312,16 @@
           index: true,
           selection: true,
           viewBtn: true,
+          delBtn:false,
+          editBtn:false,
           dialogType: 'drawer',
           dialogClickModal: false,
+          refreshBtn:false,
+          columnBtn:false,
+          searchShowBtn:false,
+          selectable:(row,index)=>{
+            return row.roleId != "1123598816738675201";
+          },
           column: [
             {
               label: "登录账号",
@@ -287,7 +333,8 @@
               label: "所属租户",
               prop: "tenantName",
               slot: true,
-              display: false
+              display: false,
+              hide:true
             },
             {
               label: "用户姓名",
@@ -305,33 +352,34 @@
               label: "所属部门",
               prop: "deptName",
               slot: true,
-              display: false
-            },
-            {
-              label: "用户平台",
-              prop: "userTypeName",
-              slot: true,
-              display: false
-            },
-            {
-              label: "用户平台",
-              type: "select",
-              dicUrl: "/api/blade-system/dict/dictionary?code=user_type",
-              props: {
-                label: "dictValue",
-                value: "dictKey"
-              },
-              dataType: "number",
-              search: true,
-              hide: true,
               display: false,
-              prop: "userType",
-              rules: [{
-                required: true,
-                message: "请选择用户平台",
-                trigger: "blur"
-              }]
+              hide:true
             },
+            // {
+            //   label: "用户平台",
+            //   prop: "userTypeName",
+            //   slot: true,
+            //   display: false
+            // },
+            // {
+            //   label: "用户平台",
+            //   type: "select",
+            //   dicUrl: "/api/blade-system/dict/dictionary?code=user_type",
+            //   props: {
+            //     label: "dictValue",
+            //     value: "dictKey"
+            //   },
+            //   dataType: "number",
+            //   search: true,
+            //   hide: true,
+            //   display: false,
+            //   prop: "userType",
+            //   rules: [{
+            //     required: true,
+            //     message: "请选择用户平台",
+            //     trigger: "blur"
+            //   }]
+            // },
           ],
           group: [
             {
@@ -343,6 +391,8 @@
                   label: "所属租户",
                   prop: "tenantId",
                   type: "tree",
+                  value:"000000",
+                  display:false,
                   dicUrl: "/api/blade-system/tenant/select",
                   props: {
                     label: "tenantName",
@@ -368,28 +418,28 @@
                     trigger: "blur"
                   }],
                 },
-                {
-                  label: "用户平台",
-                  type: "select",
-                  dicUrl: "/api/blade-system/dict/dictionary?code=user_type",
-                  props: {
-                    label: "dictValue",
-                    value: "dictKey"
-                  },
-                  dataType: "number",
-                  slot: true,
-                  prop: "userType",
-                  rules: [{
-                    required: true,
-                    message: "请选择用户平台",
-                    trigger: "blur"
-                  }]
-                },
+                // {
+                //   label: "用户平台",
+                //   type: "select",
+                //   dicUrl: "/api/blade-system/dict/dictionary?code=user_type",
+                //   props: {
+                //     label: "dictValue",
+                //     value: "dictKey"
+                //   },
+                //   dataType: "number",
+                //   slot: true,
+                //   prop: "userType",
+                //   rules: [{
+                //     required: true,
+                //     message: "请选择用户平台",
+                //     trigger: "blur"
+                //   }]
+                // },
                 {
                   label: '密码',
                   prop: 'password',
                   hide: true,
-                  editDisplay: false,
+                  display: false,
                   viewDisplay: false,
                   rules: [{required: true, validator: validatePass, trigger: 'blur'}]
                 },
@@ -397,7 +447,7 @@
                   label: '确认密码',
                   prop: 'password2',
                   hide: true,
-                  editDisplay: false,
+                  display: false,
                   viewDisplay: false,
                   rules: [{required: true, validator: validatePass2, trigger: 'blur'}]
                 },
@@ -483,10 +533,10 @@
               prop: 'dutyInfo',
               icon: 'el-icon-s-custom',
               column: [
-                {
-                  label: "用户编号",
-                  prop: "code",
-                },
+                // {
+                //   label: "用户编号",
+                //   prop: "code",
+                // },
                 {
                   label: "所属角色",
                   prop: "roleId",
@@ -505,38 +555,57 @@
                   }]
                 },
                 {
-                  label: "所属部门",
-                  prop: "deptId",
+                  label: "负责的农场",
+                  prop: "farmId",
+                  labelWidth:110,
                   type: "tree",
                   multiple: true,
                   dicData: [],
                   props: {
-                    label: "title"
+                    label: "farmName",
+                    value:"id"
                   },
                   checkStrictly: true,
                   slot: true,
                   rules: [{
                     required: true,
-                    message: "请选择所属部门",
+                    message: "请选择负责的农场",
                     trigger: "click"
                   }]
                 },
-                {
-                  label: "所属岗位",
-                  prop: "postId",
-                  type: "tree",
-                  multiple: true,
-                  dicData: [],
-                  props: {
-                    label: "postName",
-                    value: "id"
-                  },
-                  rules: [{
-                    required: true,
-                    message: "请选择所属岗位",
-                    trigger: "click"
-                  }],
-                },
+                // {
+                //   label: "所属部门",
+                //   prop: "deptId",
+                //   type: "tree",
+                //   multiple: true,
+                //   dicData: [],
+                //   props: {
+                //     label: "title"
+                //   },
+                //   checkStrictly: true,
+                //   slot: true,
+                //   rules: [{
+                //     required: true,
+                //     message: "请选择所属部门",
+                //     trigger: "click"
+                //   }]
+                // },
+                // {
+                //   label: "所属岗位",
+                //   prop: "postId",
+                //   type: "tree",
+                //   multiple: true,
+                //   dicData: [],
+                //   props: {
+                //     label: "postName",
+                //     value: "id"
+                //   },
+                //   rules: [{
+                //     required: true,
+                //     message: "请选择所属岗位",
+                //     trigger: "click"
+                //   }],
+                // },
               ]
             },
           ]
@@ -568,6 +637,7 @@
               label: "所属租户",
               prop: "tenantName",
               slot: true,
+              hide:true,
               display: false
             },
             {
@@ -723,14 +793,18 @@
           const column = this.findObject(this.option.group, "roleId");
           column.dicData = res.data.data;
         });
-        getDeptTree(tenantId).then(res => {
-          const column = this.findObject(this.option.group, "deptId");
+        getFarmList().then(res => {
+          const column = this.findObject(this.option.group, "farmId");
           column.dicData = res.data.data;
         });
-        getPostList(tenantId).then(res => {
-          const column = this.findObject(this.option.group, "postId");
-          column.dicData = res.data.data;
-        });
+        // getDeptTree(tenantId).then(res => {
+        //   const column = this.findObject(this.option.group, "deptId");
+        //   column.dicData = res.data.data;
+        // });
+        // getPostList(tenantId).then(res => {
+        //   const column = this.findObject(this.option.group, "postId");
+        //   column.dicData = res.data.data;
+        // });
       },
       submitRole() {
         const roleList = this.$refs.treeRole.getCheckedKeys().join(",");
@@ -744,9 +818,10 @@
         });
       },
       rowSave(row, done, loading) {
-        row.deptId = row.deptId.join(",");
+        row['deptId'] = this.userInfo.dept_id;
         row.roleId = row.roleId.join(",");
-        row.postId = row.postId.join(",");
+        row.farmId = row.farmId.join(",");
+        // row.postId = row.postId.join(",");
         add(row).then(() => {
           this.initFlag = false;
           this.onLoad(this.page);
@@ -761,9 +836,10 @@
         });
       },
       rowUpdate(row, index, done, loading) {
-        row.deptId = row.deptId.join(",");
+        debugger;
+        row['deptId'] = this.userInfo.dept_id;
         row.roleId = row.roleId.join(",");
-        row.postId = row.postId.join(",");
+        row.farmId = row.farmId.join(",");
         update(row).then(() => {
           this.initFlag = false;
           this.onLoad(this.page);
@@ -775,6 +851,45 @@
         }, error => {
           window.console.log(error);
           loading();
+        });
+      },
+      update(row){
+        this.form = {
+          id:row.id,
+          account:row.account,
+          name:row.name,
+          realName:row.realName,
+          phone:row.phone,
+          email:row.email,
+          sex:row.sex,
+          birthday:row.birthday,
+          roleId:row.roleId.split(','),
+          farmId : row.farmId.split(",")
+        }
+        var passwordColumn = this.findObject(this.option.group,"password");
+        var password2Column = this.findObject(this.option.group,"password2")
+        passwordColumn.display = false;
+        password2Column.display = false;
+        this.dialogVisible = true
+      },
+      submitUpdate(row, done, loading){
+        this.form['deptId'] = this.userInfo.dept_id;
+        this.form.roleId = this.form.roleId.join(",")
+        this.form.farmId = this.form.farmId.join(",")
+        update(this.form).then(() => {
+          this.initFlag = false;
+          this.onLoad(this.page);
+          this.$message({
+            type: "success",
+            message: "操作成功!"
+          });
+          this.dialogVisible = false
+          done();
+
+        }, error => {
+          window.console.log(error);
+          loading();
+          done();
         });
       },
       rowDel(row) {
@@ -920,18 +1035,32 @@
         })
       },
       beforeOpen(done, type) {
+        const column = this.findObject(this.option.group, "farmId");
+        var passwordColumn = this.findObject(this.option.group,"password");
+        var password2Column = this.findObject(this.option.group,"password2")
+        passwordColumn.display = true;
+        password2Column.display = true;
+        if(type == "add"&& column.dicData == ""){
+          this.form = {}
+          this.initData(website.tenantId)
+        }
         if (["edit", "view"].includes(type)) {
+          passwordColumn.display = false;
+          password2Column.display = false;
           getUser(this.form.id).then(res => {
             this.form = res.data.data;
             if(this.form.hasOwnProperty("deptId")){
               this.form.deptId = this.form.deptId.split(",");
             }
+            if(this.form.hasOwnProperty("farmId")){
+              this.form.farmId = this.form.farmId.split(",");
+            }
             if(this.form.hasOwnProperty("roleId")){
               this.form.roleId = this.form.roleId.split(",");
             }
-            if(this.form.hasOwnProperty("postId")){
-              this.form.postId = this.form.postId.split(",");
-            }
+            // if(this.form.hasOwnProperty("postId")){
+            //   this.form.postId = this.form.postId.split(",");
+            // }
           });
         }
         this.initFlag = true;

--
Gitblit v1.9.3