From e4ca54e71efe08d9e7f9ffce719f44a216c889ab Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Tue, 13 Jul 2021 14:44:01 +0800
Subject: [PATCH] 角色页面标题修改,用户列表字段修改

---
 src/views/securityGuard/securityGuard.vue | 1072 ++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 623 insertions(+), 449 deletions(-)

diff --git a/src/views/securityGuard/securityGuard.vue b/src/views/securityGuard/securityGuard.vue
index 9a23823..94256a5 100644
--- a/src/views/securityGuard/securityGuard.vue
+++ b/src/views/securityGuard/securityGuard.vue
@@ -1,15 +1,19 @@
 <template>
   <el-row>
-    <!-- <el-col :span="5">
-      <div class="box">
-        <el-scrollbar>
-          <basic-container>
-            <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick"/>
-          </basic-container>
-        </el-scrollbar>
-      </div>
-    </el-col> -->
-    <el-col>
+      <el-col :span="0" style="display: none">
+        <div class="box">
+          <el-scrollbar>
+            <basic-container>
+              <avue-tree
+                :option="treeOption"
+                :data="treeData"
+                @node-click="nodeClick"
+              />
+            </basic-container>
+          </el-scrollbar>
+        </div>
+      </el-col>
+      <el-col :span="24">
       <basic-container>
         <avue-crud :option="option"
                    :search.sync="search"
@@ -21,6 +25,7 @@
                    @row-del="rowDel"
                    @row-update="rowUpdate"
                    @row-save="rowSave"
+                   @row-click="rowClick"
                    :before-open="beforeOpen"
                    :page.sync="page"
                    @search-change="searchChange"
@@ -30,15 +35,87 @@
                    @size-change="sizeChange"
                    @refresh-change="refreshChange"
                    @on-load="onLoad">
-          <!-- <template slot="menuLeft">
-            <el-button type="danger"
-                       size="small"
-                       plain
-                       icon="el-icon-delete"
-                       v-if="permission.user_delete"
-                       @click="handleDelete">删 除
-            </el-button>
-          </template> -->
+          <template slot="menuLeft">
+              <el-button
+                type="danger"
+                style="display: none"
+                size="small"
+                plain
+                icon="el-icon-delete"
+                v-if="permission.user_delete"
+                @click="handleDelete"
+                >注 销
+              </el-button>
+              <el-button
+                type="info"
+                style="display: none"
+                size="small"
+                plain
+                v-if="permission.user_role"
+                icon="el-icon-user"
+                @click="handleGrant"
+                >角色配置
+              </el-button>
+              <el-button
+                type="info"
+                style="display: none"
+                size="small"
+                plain
+                v-if="permission.user_reset"
+                icon="el-icon-refresh"
+                @click="handleReset"
+                >密码重置
+              </el-button>
+              <el-button
+                type="info"
+                style="display: none"
+                size="small"
+                plain
+                v-if="userInfo.role_name.includes('admin')"
+                icon="el-icon-setting"
+                @click="handlePlatform"
+                >平台配置
+              </el-button>
+              <el-button
+                type="success"
+                style="display: none"
+                size="small"
+                plain
+                v-if="userInfo.role_name.includes('admin')"
+                icon="el-icon-upload2"
+                @click="handleImport"
+                >导入
+              </el-button>
+              <el-button
+                type="warning"
+                style="display: none"
+                size="small"
+                plain
+                v-if="userInfo.role_name.includes('admin')"
+                icon="el-icon-download"
+                @click="handleExport"
+                >导出
+              </el-button>
+            </template>
+
+            <template slot-scope="{ type, size, row }" slot="menu">
+              <!-- <el-button
+                style="display:none"
+                icon="el-icon-edit"
+                :size="size"
+                :type="type"
+                @click.stop="addOrUpdateHandle(row.id)"
+                >修改
+              </el-button> -->
+              <el-button
+                icon="el-icon-edit"
+                :size="size"
+                :type="type"
+                @click.stop="rowDel(row)"
+                >离职登记
+              </el-button>
+            </template>
+            
           <template slot-scope="{row}"
                     slot="tenantName">
             <el-tag>{{row.tenantName}}</el-tag>
@@ -55,21 +132,28 @@
                     slot="userTypeName">
             <el-tag>{{row.userTypeName}}</el-tag>
           </template>
-          <template slot-scope="{ row }" slot="status">
-            <el-tag
-            >{{
-              row.status == "0" ? "已离职" : row.status == "1" ? "在职" : "已离职"
-              }}
-            </el-tag>
-          </template>
-          <template slot-scope="{ row }" slot="sex">
-            <el-tag
-            >{{
-              row.sex == 1 ? "男" : "女"
-              }}
-            </el-tag>
-          </template>
         </avue-crud>
+        <el-dialog title="用户角色配置"
+                   append-to-body
+                   :visible.sync="roleBox"
+                   width="345px">
+
+          <el-tree :data="roleGrantList"
+                   show-checkbox
+                   check-strictly
+                   default-expand-all
+                   node-key="id"
+                   ref="treeRole"
+                   :default-checked-keys="roleTreeObj"
+                   :props="props">
+          </el-tree>
+
+          <span slot="footer" class="dialog-footer">
+            <el-button @click="roleBox = false">取 消</el-button>
+            <el-button type="primary"
+                       @click="submitRole">确 定</el-button>
+          </span>
+        </el-dialog>
         <el-dialog title="用户数据导入"
                    append-to-body
                    :visible.sync="excelBox"
@@ -118,37 +202,54 @@
 
 <script>
   import {
+    getList,
     getUser,
     getUserPlatform,
+    remove,
     update,
     updatePlatform,
     add,
     grant,
-    getUserPractitionersInfo
+    resetPassword,
+    getUserPractitionersInfo,
+    saveOrUpdateUserPractitionersInfo
   } from "@/api/system/user";
-    import {getList} from "@/api/securityGuard/securityGuard";
-  import {getDeptTree} from "@/api/system/dept";
+  import {getDeptTree, getDeptLazyTree} from "@/api/system/dept";
   import {getRoleTree} from "@/api/system/role";
   import {getPostList} from "@/api/system/post";
   import {mapGetters} from "vuex";
   import website from '@/config/website';
   import {getToken} from '@/util/auth';
+  import { securityFormPageColumn, securityBaseInfoColumns } from "./data";
 
   export default {
     data() {
+      const validatePass = (rule, value, callback) => {
+        if (value === '') {
+          callback(new Error('请输入密码'));
+        } else {
+          callback();
+        }
+      };
+      const validatePass2 = (rule, value, callback) => {
+        if (value === '') {
+          callback(new Error('请再次输入密码'));
+        } else if (value !== this.form.password) {
+          callback(new Error('两次输入密码不一致!'));
+        } else {
+          callback();
+        }
+      };
       return {
-        baseUrl:"/map/index.html?ISinit=1",
         form: {},
-        search: {},
+        search:{},
         roleBox: false,
         excelBox: false,
         platformBox: false,
-        showMap: false,
         initFlag: true,
         selectionList: [],
         query: {},
         loading: true,
-        roleId:"",
         platformLoading: false,
         page: {
           pageSize: 10,
@@ -172,367 +273,355 @@
         roleTreeObj: [],
         treeDeptId: '',
         treeData: [],
+        treeOption: {
+          nodeKey: 'id',
+          lazy: true,
+          treeLoad: function (node, resolve) {
+            const parentId = (node.level === 0) ? 0 : node.data.id;
+            getDeptLazyTree(parentId).then(res => {
+              resolve(res.data.data.map(item => {
+                return {
+                  ...item,
+                  leaf: !item.hasChildren
+                }
+              }))
+            });
+          },
+          addBtn: false,
+          menu: false,
+          size: 'small',
+          props: {
+            labelText: '标题',
+            label: 'title',
+            value: 'value',
+            children: 'children'
+          }
+        },
         option: {
           height: 'auto',
-          calcHeight: 54,
+          calcHeight: 80,
           tip: false,
           searchShow: true,
           searchMenuSpan: 6,
           border: false,
           stripe: true,
           index: true,
+          delBtnText: "注销",
           selection: true,
           viewBtn: true,
-          delBtnText:'离职登记',
-          editBtnText:'修改',
-          menuWidth:200,
           //dialogType: 'drawer',
           dialogClickModal: false,
-          column: [
-            
-           
-            {
-              label: "用户姓名",
-              prop: "realName",
-              search: true,
-              searchSpan:4,
-              display: false
-            },
-            {
-              label: "性别",
-              prop: "sex",
-              type: "select",
-              slot:true,
-              display: false
-            },
-            
-             {
-              label: "籍贯",
-              prop: "nativePlace",
-              display: false
-            },
-             {
-              label: "民族",
-              prop: "nation",
-              display: false
-            },
-            {
-              label: "出生日期",
-              prop: "birthday",
-              type: "date",
-              format: "yyyy-MM-dd",
-              valueFormat: "yyyy-MM-dd",
-              display: false
-            },
-            {
-              label: "学历",
-              prop: "education",
-              display: false,
-              dicUrl: "/api/blade-system/dict-biz/dictionary?code=educationType",
-              props: {
-                label: "dictValue",
-                value: "dictKey"
-              },
-              type:"select",
-              rules: [{
-                required: true,
-                message: "请选择学历",
-                trigger: "blur"
-              }],
-            },
-            {
-              label: "联系电话",
-              prop: "phone",
-              display: false
-            },
-            {
-              label: "邮箱",
-              prop: "email",
-              display: false,
-              width:150
-            },
-            {
-              label: "入职时间",
-              prop: "rtime",
-              display: false
-            },
-            {
-              label: "所属部门",
-              prop: "deptName",
-              slot: true,
-              searchSpan:4,
-              display: false,
-              search:true,
-              width:260
-            },
-            {
-              label: "岗位",
-              prop: "postName",
-              slot: true,
-              display: false
-            },
-            {
-              label: "入职时间",
-              prop: "rtime",
-              type: "datetime",
-              format: "yyyy-MM-dd",
-              valueFormat: "yyyy-MM-dd",
-              searchRange: true,
-              searchSpan: 6,
-              hide: true,
-              addDisplay: false,
-              editDisplay: false,
-              viewDisplay: false,
-              search: true,
-              rules: [
-                {
-                  required: true,
-                  message: "请输入时间",
-                  trigger: "blur"
-                }
-              ]
-            },
-            
-             {
-              label: "在职状态",
-              prop: "status",
-              slot: true,
-              display: false,
-              searchSpan:3,
-              search:true
-            }
-          ],
+          column: securityFormPageColumn,
           group: [
-            {
-              label: '基础信息',
-              prop: 'baseInfo',
-              labelWidth:"110",
-              icon: 'el-icon-user-solid',
-              column: [
-                {
-                  label: "所属保安单位",
-                  prop: "tenantId",
-                  type: "tree",
-                  dicUrl: "/api/blade-system/tenant/select",
-                  props: {
-                    label: "tenantName",
-                    value: "tenantId"
-                  },
-                  disabled:true,
-                  span: 24,
+          {
+            label: "基础信息",
+            labelWidth: "110",
+            prop: "baseInfo",
+            icon: "el-icon-user-solid",
+            column: [
+              {
+                label: "所属组织机构",
+                prop: "deptId",
+                type: "tree",
+                // dicUrl: "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697",
+                dicUrl: "/api/blade-system/dept/lazy-tree?parentId=0",
+                props: {
+                  label: "title",
+                  value: "id",
+                },
+                // disabled: true,
+                span: 24,
+                rules: [
+                  {
+                    required: true,
+                    message: "请选择组织机构",
+                    trigger: "blur",
+                  }
+                ],
+              },
+              {
+                label: "登录账号",
+                prop: "account",
+                rules: [
+                  {
+                    required: true,
+                    message: "请输入登录账号",
+                    trigger: "blur",
+                  }
+                ],
+                // disabled: true,
+              },{
+                  label: '密码',
+                  prop: 'password',
+                  hide: true,
+                  editDisplay: false,
+                  viewDisplay: false,
+                  rules: [{required: true, validator: validatePass, trigger: 'blur'}]
                 },
                 {
-                  label: "登录账号",
-                  prop: "account",
-                  disabled:true
+                  label: '确认密码',
+                  prop: 'password2',
+                  hide: true,
+                  editDisplay: false,
+                  viewDisplay: false,
+                  rules: [{required: true, validator: validatePass2, trigger: 'blur'}]
                 },
-                {
-                  label: "用户姓名",
-                  prop: "realName",
-                  rules: [{
+              {
+                label: "用户姓名",
+                prop: "realName",
+                rules: [
+                  {
                     required: true,
                     message: "请输入用户姓名",
-                    trigger: "blur"
-                  }, {
+                    trigger: "blur",
+                  },
+                  {
                     min: 2,
                     max: 5,
-                    message: '姓名长度在2到5个字符'
-                  }]
+                    message: "姓名长度在2到5个字符",
+                  },
+                ],
+              },
+              {
+                label: "用户编号",
+                prop: "code",
+              },
+              {
+                label: "用户昵称",
+                prop: "name",
+              }, {
+                label: "所属行政区",
+                prop: "jurisdiction",
+                // multiple: true,
+                type: "tree",
+                dicUrl: "/api/jurisdiction/lazy-tree?parentId=0",
+                props: {
+                  label: "title",
+                  value: "id",
                 },
-                {
-                  label: "用户昵称",
-                  prop: "name"
+                checkStrictly: true,
+                slot: true,
+                rules: [
+                  {
+                    required: true,
+                    message: "请选择所属行政区",
+                    trigger: "click",
+                  },
+                ],
+              },{
+                label: "所属角色",
+                prop: "roleId",
+                multiple: true,
+                type: "tree",
+                dicData: [],
+                props: {
+                  label: "title",
                 },
-                {
-                  label: "手机号码",
-                  prop: "phone",
-                  overHidden: true,
-                  rules: [{
+                checkStrictly: true,
+                slot: true,
+                rules: [
+                  {
+                    required: false,
+                    message: "请选择所属角色",
+                    trigger: "click",
+                  },
+                ],
+              },{
+                label: "所属岗位",
+                prop: "postId",
+                type: "tree",
+                multiple: true,
+                dicData: [],
+                props: {
+                  label: "postName",
+                  value: "id",
+                },
+                rules: [
+                  {
+                    required: false,
+                    message: "请选择所属岗位",
+                    trigger: "click",
+                  },
+                ],
+              },
+              {
+                label: "手机号码",
+                prop: "phone",
+                overHidden: true,
+                rules: [
+                  {
                     required: true,
                     message: "请输入手机号",
-                    trigger: "blur"
-                  }]
-                },
-                {
-                  label: "电子邮箱",
-                  prop: "email",
-                  hide: true,
-                  overHidden: true
-                },
-                {
-                  label: "身份证号",
-                  prop: "cardid",
-                  hide: true,
-                  overHidden: true,
-                  rules: [{
+                    trigger: "blur",
+                  },
+                ],
+              },
+              {
+                label: "电子邮箱",
+                prop: "email",
+              },
+              {
+                label: "身份证号",
+                prop: "cardid",
+                hide: true,
+                overHidden: true,
+                rules: [
+                  {
                     required: true,
                     message: "请输入身份证号",
-                    trigger: "blur"
-                  }]
-                },
-                {
-                  label: "籍贯",
-                  prop: "nativePlace",
-                  hide: true,
-                  overHidden: true
-                },
-                {
-                  label: "民族",
-                  prop: "nation",
-                  hide: true,
-                  overHidden: true
-                },
-                {
-                  label: "最高学历",
-                  prop: "education",
-                  type: "select",
-                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=educationType",
-                  props: {
-                    label: "dictValue",
-                    value: "dictKey"
+                    trigger: "blur",
                   },
-                  dataType: "number",
-                  slot: true,
-                  rules: [{
-                    required: true,
-                    message: "请选择学历",
-                    trigger: "blur"
-                  }]
+                ],
+              },
+              {
+                label: "籍贯",
+                prop: "nativeplace",
+              },
+              {
+                label: "民族",
+                prop: "nation",
+              },
+              {
+                label: "最高学历",
+                prop: "education1",
+                type: "select",
+                dicUrl:
+                  "/api/blade-system/dict-biz/dictionary?code=educationType",
+                props: {
+                  label: "dictValue",
+                  value: "dictKey",
                 },
-                {
-                  label: "政治面貌",
-                  prop: "politicaloutlook",
-                  hide: true,
-                  overHidden: true
-                },
-                {
-                  label: "身高",
-                  prop: "height",
-                  hide: true,
-                  overHidden: true
-                },
-                {
-                  label: "联系地址",
-                  prop: "address",
-                  hide: true,
-                  overHidden: true
-                },
-                {
-                  label: "户口所在地",
-                  prop: "registered",
-                  hide: true,
-                  overHidden: true
-                },
-                {
-                  label: "入职时间",
-                  prop: "rtime",
-                  type:'date',
-                  format: "yyyy-MM-dd",
-                  valueFormat: "yyyy-MM-dd",
-                  hide: true,
-                  overHidden: true
-                },
-                {
-                  label: "用户性别",
-                  prop: "sex",
-                  type: "select",
-                  dicData: [
+                dataType: "number",
+                slot: true
+              },
+              {
+                label: "政治面貌",
+                prop: "politicaloutlook",
+              },
+              {
+                label: "身高",
+                prop: "height",
+              },
+              {
+                label: "联系地址",
+                prop: "address",
+              },
+              {
+                label: "户口所在地",
+                prop: "registered",
+              },
+              {
+                label: "入职时间",
+                prop: "rtime",
+                type: "date",
+                format: "yyyy-MM-dd",
+                valueFormat: "yyyy-MM-dd",
+              },
+              {
+                label: "用户性别",
+                prop: "sex",
+                type: "select",
+                dicData: [
+                  {
+                    label: "男",
+                    value: 1,
+                  },
+                  {
+                    label: "女",
+                    value: 2,
+                  },
+                  {
+                    label: "未知",
+                    value: 3,
+                  },
+                ],
+              },
+              {
+                label: "用户生日",
+                type: "date",
+                prop: "birthday",
+              },
+            ],
+          },
+          {
+            label: "从业信息",
+            prop: "detailInfo",
+            icon: "el-icon-s-order",
+            column: [
+              {
+                prop: "UserPractitionersInfo",
+                type: "dynamic",
+                border: false,
+                span: 24,
+                children: {
+                  align: "left",
+                  headerAlign: "center",
+                  type: "form",
+                  rowAdd: (done) => {
+                    console.log(done, 111);
+                    done({
+                      input: "默认值",
+                    });
+                  },
+                  rowDel: (row, done) => {
+                    console.log(row, 222);
+                    done();
+                  },
+                  column: [
                     {
-                      label: "男",
-                      value: 1
+                      width: 200,
+                      label: "单位名称",
+                      prop: "companyname",
+                      formslot: true,
                     },
                     {
-                      label: "女",
-                      value: 2
+                      width: 200,
+                      label: "部门",
+                      prop: "department",
+                      formslot: true,
                     },
                     {
-                      label: "未知",
-                      value: 3
-                    }
+                      width: 200,
+                      label: "岗位",
+                      prop: "post",
+                      formslot: true,
+                    },
+                    {
+                      width: 200,
+                      label: "岗位职责",
+                      prop: "responsibilities",
+                      formslot: true,
+                    },
+                    {
+                      width: 200,
+                      label: "入职时间",
+                      type: "date",
+                      format: "yyyy-MM-dd",
+                      valueFormat: "yyyy-MM-dd",
+                      prop: "entryTime",
+                      formslot: true,
+                    },
+                    {
+                      width: 200,
+                      label: "离职时间",
+                      type: "date",
+                      format: "yyyy-MM-dd",
+                      valueFormat: "yyyy-MM-dd",
+                      prop: "departureTime",
+                      formslot: true,
+                    },
+                    {
+                      width: 200,
+                      label: "离职原因",
+                      prop: "leaving",
+                      formslot: true,
+                    },
                   ],
-                  hide: true
                 },
-                {
-                  label: "用户生日",
-                  type: "date",
-                  prop: "birthday",
-                  hide: true
-                }
-              ]
-            },
-            {
-              label: '从业信息',
-              prop: 'detailInfo',
-              icon: 'el-icon-s-order',
-              column: [
-                    {
-                    prop: 'UserPractitionersInfo',
-                    type: 'dynamic',
-                    border: false,
-                    span:24,
-                    children: {
-                        align: 'left',
-                        headerAlign: 'center',
-                        type:'form',
-                        rowAdd:(done)=>{
-                            console.log(done,111);
-                            done({
-                                input:'默认值'
-                            });
-                        },
-                        rowDel:(row,done)=>{
-                            console.log(row,222);
-                            done();
-                        },
-                        column: [
-                                {
-                                    width: 200,
-                                    label: '单位名称',
-                                    prop: "companyname",
-                                    formslot: true,
-                                }, {
-                                    width: 200,
-                                    label: '部门',
-                                    prop: "department",
-                                    formslot: true,
-                                }, {
-                                    width: 200,
-                                    label: '岗位',
-                                    prop: "post",
-                                    formslot: true,
-                                },  {
-                                    width: 200,
-                                    label: '岗位职责',
-                                    prop: "responsibilities",
-                                    formslot: true,
-                                },  {
-                                    width: 200,
-                                    label: '入职时间',
-                                    type:'date',
-                                    format: "yyyy-MM-dd",
-                                    valueFormat: "yyyy-MM-dd",
-                                    prop: "entryTime",
-                                    formslot: true,
-                                },  {
-                                    width: 200,
-                                    label: '离职时间',
-                                    type:'date',
-                                    format: "yyyy-MM-dd",
-                                    valueFormat: "yyyy-MM-dd",
-                                    prop: "departureTime",
-                                    formslot: true,
-                                },  {
-                                    width: 200,
-                                    label: '离职原因',
-                                    prop: "leaving",
-                                    formslot: true,
-                                }
-                            ]
-                        }
-                    },
-                ]
-            }
-          ]
+              },
+            ],
+          },
+        ],
         },
         data: [],
         platformQuery: {},
@@ -558,7 +647,7 @@
               display: false
             },
             {
-              label: "所属租户",
+              label: "所属保安单位",
               prop: "tenantName",
               slot: true,
               display: false
@@ -677,11 +766,10 @@
       ...mapGetters(["userInfo", "permission"]),
       permissionList() {
         return {
-          addBtn: this.vaildData(null, false),
-          // addBtn: this.vaildData(this.permission.user_add, false),
+          addBtn: this.vaildData(this.permission.user_add, false),
           viewBtn: this.vaildData(null, false),
-          delBtn: this.vaildData(this.permission.user_delete, false),
-          editBtn: this.vaildData(null, false)
+          delBtn: this.vaildData(null, false),
+          editBtn: this.vaildData(this.permission.user_edit, false),
         };
       },
       platformPermissionList() {
@@ -701,13 +789,19 @@
       },
     },
     mounted() {
-      // 非租户模式默认加载管理组数据
+      // 非保安单位模式默认加载管理组数据
       if (!website.tenantMode) {
         this.initData(website.tenantId);
       }
-
     },
     methods: {
+      //行点击事件
+      rowClick(row) {
+        this.$router.push({
+          path: "/securityGuard/securityGuardDetail",
+          query: { row: row },
+        });
+      },
       nodeClick(data) {
         this.treeDeptId = data.id;
         this.page.currentPage = 1;
@@ -715,23 +809,8 @@
       },
       initData(tenantId) {
         getRoleTree(tenantId).then(res => {
-          var that = this;
           const column = this.findObject(this.option.group, "roleId");
           column.dicData = res.data.data;
-          //数组
-          var roleData = res.data.data;
-          //遍历
-          roleData.forEach((item)=>{
-            if(item.title=="处警员"){
-                that.roleId = item.id;
-            }
-            if(item.hasChildren){
-              //取出title对比
-              if(item.title=="处警员"){
-                that.roleId = item.id;
-              }
-            }
-          })
         });
         getDeptTree(tenantId).then(res => {
           const column = this.findObject(this.option.group, "deptId");
@@ -754,54 +833,127 @@
         });
       },
       rowSave(row, done, loading) {
-        row.deptId = row.deptId.join(",");
-        row.roleId = this.roleId;
-        row.postId = row.postId.join(",");
-        add(row).then(() => {
-          this.initFlag = false;
-          this.onLoad(this.page);
-          this.$message({
-            type: "success",
-            message: "操作成功!"
+        debugger;
+        if(row.deptId){
+            row.deptId = row.deptId;
+        }
+        if(row.roleId){
+            row.roleId = row.roleId.join(",");
+        }
+        if(row.postId){
+            row.postId = row.postId.join(",");
+        }
+        const userPractitionersList = [];
+        var userPractitionersInfo = row.UserPractitionersInfo;
+        if (userPractitionersInfo.length > 0) {
+          userPractitionersInfo.forEach((item) => {
+            const info = {
+              companyname: item.companyname,
+              department: item.department,
+              departureTime: item.departureTime,
+              entryTime: item.entryTime,
+              name: row.realName,
+              leaving: item.leaving,
+              cardid: row.cardid,
+              post: item.post,
+              responsibilities: item.responsibilities,
+            };
+            userPractitionersList.push(info);
           });
-          done();
-        }, error => {
-          window.console.log(error);
-          loading();
-        });
+        }
+        var IdCardNo = row.cardid;
+        add(row).then(
+          () => {
+            const experience = {
+              cardid: IdCardNo,
+              userPractitionersInfo: userPractitionersList,
+            };
+            //新增从业信息
+            saveOrUpdateUserPractitionersInfo(experience).then(() => {
+              this.$message({
+                type: "success",
+                message: "操作成功!",
+              });
+            });
+            this.initFlag = false;
+            this.onLoad(this.page);
+            // this.$message({
+            //   type: "success",
+            //   message: "操作成功!",
+            // });
+            done();
+          },
+          (error) => {
+            window.console.log(error);
+            loading();
+          }
+        );
       },
       rowUpdate(row, index, done, loading) {
-        row.deptId = row.deptId.join(",");
+        row.deptId = row.deptId;
         row.roleId = row.roleId.join(",");
         row.postId = row.postId.join(",");
-        update(row).then(() => {
-          this.initFlag = false;
-          this.onLoad(this.page);
-          this.$message({
-            type: "success",
-            message: "操作成功!"
+        const userPractitionersList = [];
+        var userPractitionersInfo = row.UserPractitionersInfo;
+        if (userPractitionersInfo.length > 0) {
+          userPractitionersInfo.forEach((item) => {
+            const info = {
+              companyname: item.companyname,
+              department: item.department,
+              departureTime: item.departureTime,
+              entryTime: item.entryTime,
+              name: row.realName,
+              leaving: item.leaving,
+              cardid: row.cardid,
+              post: item.post,
+              responsibilities: item.responsibilities,
+            };
+            userPractitionersList.push(info);
           });
-          done();
-        }, error => {
-          window.console.log(error);
-          loading();
-        });
+        }
+        var IdCardNo = row.cardid;
+        update(row).then(
+          () => {
+            const experience = {
+              cardid: IdCardNo,
+              userPractitionersInfo: userPractitionersList,
+            };
+            //更新从业信息
+            saveOrUpdateUserPractitionersInfo(experience).then(() => {
+              this.$message({
+                type: "success",
+                message: "操作成功!",
+              });
+            });
+            this.initFlag = false;
+            this.onLoad(this.page);
+            // this.$message({
+            //   type: "success",
+            //   message: "操作成功!",
+            // });
+            done();
+          },
+          (error) => {
+            window.console.log(error);
+            loading();
+          }
+        );
       },
       rowDel(row) {
         this.$confirm("确定将选择用户登记离职?", {
           confirmButtonText: "确定",
           cancelButtonText: "取消",
-          type: "warning"
+          type: "warning",
         })
           .then(() => {
-            row.status="0";
+            row.status = "0";
             return update(row);
           })
           .then(() => {
             this.onLoad(this.page);
             this.$message({
               type: "success",
-              message: "操作成功!"
+              message: "操作成功!",
             });
           });
       },
@@ -823,28 +975,49 @@
         this.selectionList = [];
         this.$refs.crud.toggleSelection();
       },
-      // 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();
-      //     });
-      // },
+      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();
+          });
+      },
+      handleReset() {
+        if (this.selectionList.length === 0) {
+          this.$message.warning("请选择至少一条数据");
+          return;
+        }
+        this.$confirm("确定将选择账号密码重置为123456?", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        })
+          .then(() => {
+            return resetPassword(this.ids);
+          })
+          .then(() => {
+            this.$message({
+              type: "success",
+              message: "操作成功!"
+            });
+            this.$refs.crud.toggleSelection();
+          });
+      },
       handleGrant() {
         if (this.selectionList.length === 0) {
           this.$message.warning("请选择至少一条数据");
@@ -865,7 +1038,8 @@
       handleImport() {
         this.excelBox = true;
       },
-      uploadAfter(done) {
+      uploadAfter(res, done, loading, column) {
+        window.console.log(column);
         this.excelBox = false;
         this.refreshChange();
         done();
@@ -887,20 +1061,20 @@
         if (["edit", "view"].includes(type)) {
           getUser(this.form.id).then(res => {
             this.form = res.data.data;
-            var userInfo = res.data.data;
-            //获取用户从业信息
-            getUserPractitionersInfo(userInfo.cardid).then(res1 =>{
-               that.form.UserPractitionersInfo = res1.data.data;
-            })
-            if (this.form.hasOwnProperty("deptId")) {
-              this.form.deptId = this.form.deptId.split(",");
+            if(this.form.hasOwnProperty("deptId")){
+              this.form.deptId = this.form.deptId;
             }
-            if (this.form.hasOwnProperty("roleId")) {
+            if(this.form.hasOwnProperty("roleId")){
               this.form.roleId = this.form.roleId.split(",");
             }
-            if (this.form.hasOwnProperty("postId")) {
+            if(this.form.hasOwnProperty("postId")){
               this.form.postId = this.form.postId.split(",");
             }
+            var userInfo = res.data.data;
+            //获取用户从业信息
+            getUserPractitionersInfo(userInfo.cardid).then((res1) => {
+              that.form.UserPractitionersInfo = res1.data.data;
+            });
           });
         }
         this.initFlag = true;

--
Gitblit v1.9.3