liuyg
2021-07-10 8ef98bfd45d97a4c7d494d5a4e51b573df8da268
src/views/securityGuard/securityGuardRegistration.vue
@@ -1,15 +1,18 @@
<template>
  <el-row>
    <el-col>
      <basic-container>
    <el-dialog
      :title="!form.id?'新增':'修改'"
      width="60%"
      modal-append-to-body='false'
      append-to-body='true'
      :close-on-click-model="true"
      :visible.sync="visible"
    >
        <avue-form :option="option" v-model="form" @submit="update">
            <template slot-scope="{row}" slot="input">
                <el-tag>{{row}}</el-tag>
            </template>
        </avue-form>
      </basic-container>
    </el-col>
  </el-row>
    </el-dialog>
</template>
<script>
@@ -17,55 +20,60 @@
    getUser,
    update,
    getUserPractitionersInfo,
    saveOrUpdateUserPractitionersInfo
  saveOrUpdateUserPractitionersInfo,
  } from "@/api/system/user";
  import {getDeptLazyTree} from "@/api/system/dept";
  export default {
  name: "securityGuardRegistration",
    data() {
      return {
        loading: true,
        userId:"",
      visible: false,
        init: {
          deptTree: [],
        },
        props: {
          label: "title",
          value: "key"
        value: "key",
        },
        roleGrantList: [],
        roleTreeObj: [],
        treeDeptId: '',
      treeDeptId: "",
        treeData: [],
        form:{
            UserPractitionersInfo:[]
        UserPractitionersInfo: [],
        title: "标题",
        },
        treeOption: {
          nodeKey: 'id',
        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 => {
          const parentId = node.level === 0 ? 0 : node.data.id;
          getDeptLazyTree(parentId).then((res) => {
            resolve(
              res.data.data.map((item) => {
                return {
                  ...item,
                  leaf: !item.hasChildren
                }
              }))
                  leaf: !item.hasChildren,
                };
              })
            );
            });
          },
          addBtn: false,
          menu: false,
          size: 'small',
        size: "small",
          props: {
            labelText: '标题',
            label: 'title',
            value: 'value',
            children: 'children'
          }
          labelText: "标题",
          label: "title",
          value: "value",
          children: "children",
        },
        },
        option: {
          height: 'auto',
        height: "auto",
          calcHeight: 54,
          tip: false,
          searchShow: true,
@@ -77,19 +85,29 @@
          dialogClickModal: false,
          group: [
            {
              label: '基础信息',
            label: "",
            prop: "title",
            type: "title",
            span: 24,
            labelWidth: 140,
            style: {
              fontsize: 24,
            },
          },
          {
            label: "基础信息",
              labelWidth:"110",
              prop: 'baseInfo',
              icon: 'el-icon-user-solid',
            prop: "baseInfo",
            icon: "el-icon-user-solid",
              column: [
                {
                  label: "所属保安单位",
                  prop: "tenantId",
                label: "所属组织机构",
                prop: "deptId",
                  type: "tree",
                  dicUrl: "/api/blade-system/tenant/select",
                dicUrl: "/api/blade-system/dept/lazy-tree?parentId=0",
                  props: {
                    label: "tenantName",
                    value: "tenantId"
                  label: "title",
                  value: "id",
                  },
                  disabled:true,
                  span: 24,
@@ -97,97 +115,100 @@
                {
                  label: "登录账号",
                  prop: "account",
                  disabled:true
                disabled: true,
                },
                {
                  label: "用户姓名",
                  prop: "realName",
                  rules: [{
                rules: [
                  {
                    required: true,
                    message: "请输入用户姓名",
                    trigger: "blur"
                  }, {
                    trigger: "blur",
                  },
                  {
                    min: 2,
                    max: 5,
                    message: '姓名长度在2到5个字符'
                  }]
                    message: "姓名长度在2到5个字符",
                  },
                ],
                },
                {
                  label: "用户昵称",
                  prop: "name"
                prop: "name",
                },
                {
                  label: "手机号码",
                  prop: "phone",
                  overHidden: true,
                  rules: [{
                rules: [
                  {
                    required: true,
                    message: "请输入手机号",
                    trigger: "blur"
                  }]
                    trigger: "blur",
                  },
                ],
                },
                {
                  label: "电子邮箱",
                  prop: "email"
                prop: "email",
                },
                {
                  label: "身份证号",
                  prop: "cardid",
                  hide: true,
                  overHidden: true,
                  rules: [{
                rules: [
                  {
                    required: true,
                    message: "请输入身份证号",
                    trigger: "blur"
                  }]
                    trigger: "blur",
                  },
                ],
                },
                {
                  label: "籍贯",
                  prop: "nativeplace"
                prop: "nativeplace",
                },
                {
                  label: "民族",
                  prop: "nation"
                prop: "nation",
                },
                {
                  label: "最高学历",
                  prop: "education",
                  type: "select",
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=educationType",
                dicUrl:
                  "/api/blade-system/dict-biz/dictionary?code=educationType",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  value: "dictKey",
                  },
                  dataType: "number",
                  slot: true,
                  rules: [{
                    required: true,
                    message: "请选择学历",
                    trigger: "blur"
                  }]
                slot: true
                },
                {
                  label: "政治面貌",
                  prop: "politicaloutlook"
                prop: "politicaloutlook",
                },
                {
                  label: "身高",
                  prop: "height"
                prop: "height",
                },
                {
                  label: "联系地址",
                  prop: "address"
                prop: "address",
                },
                {
                  label: "户口所在地",
                  prop: "registered"
                prop: "registered",
                },
                {
                  label: "入职时间",
                  prop: "rtime",
                  type:'date',
                type: "date",
                  format: "yyyy-MM-dd",
                  valueFormat: "yyyy-MM-dd"
                valueFormat: "yyyy-MM-dd",
                },
                {
                  label: "用户性别",
@@ -196,43 +217,43 @@
                  dicData: [
                    {
                      label: "男",
                      value: 1
                    value: 1,
                    },
                    {
                      label: "女",
                      value: 2
                    value: 2,
                    },
                    {
                      label: "未知",
                      value: 3
                    }
                  ]
                    value: 3,
                  },
                ],
                },
                {
                  label: "用户生日",
                  type: "date",
                  prop: "birthday"
                }
              ]
                prop: "birthday",
              },
            ],
            },
            {
              label: '从业信息',
              prop: 'detailInfo',
              icon: 'el-icon-s-order',
            label: "从业信息",
            prop: "detailInfo",
            icon: "el-icon-s-order",
              column: [
                    {
                    prop: 'UserPractitionersInfo',
                    type: 'dynamic',
                prop: "UserPractitionersInfo",
                type: "dynamic",
                    border: false,
                    span:24,
                    children: {
                        align: 'left',
                        headerAlign: 'center',
                        type:'form',
                  align: "left",
                  headerAlign: "center",
                  type: "form",
                        rowAdd:(done)=>{
                            console.log(done,111);
                            done({
                                input:'默认值'
                      input: "默认值",
                            });
                        },
                        rowDel:(row,done)=>{
@@ -242,90 +263,100 @@
                        column: [
                                {
                                    width: 200,
                                    label: '单位名称',
                      label: "单位名称",
                                    prop: "companyname",
                                    formslot: true,
                                }, {
                    },
                    {
                                    width: 200,
                                    label: '部门',
                      label: "部门",
                                    prop: "department",
                                    formslot: true,
                                }, {
                    },
                    {
                                    width: 200,
                                    label: '岗位',
                      label: "岗位",
                                    prop: "post",
                                    formslot: true,
                                },  {
                    },
                    {
                                    width: 200,
                                    label: '岗位职责',
                      label: "岗位职责",
                                    prop: "responsibilities",
                                    formslot: true,
                                },  {
                    },
                    {
                                    width: 200,
                                    label: '入职时间',
                                    type:'date',
                      label: "入职时间",
                      type: "date",
                                    format: "yyyy-MM-dd",
                                    valueFormat: "yyyy-MM-dd",
                                    prop: "entryTime",
                                    formslot: true,
                                },  {
                    },
                    {
                                    width: 200,
                                    label: '离职时间',
                                    type:'date',
                      label: "离职时间",
                      type: "date",
                                    format: "yyyy-MM-dd",
                                    valueFormat: "yyyy-MM-dd",
                                    prop: "departureTime",
                                    formslot: true,
                                },  {
                    },
                    {
                                    width: 200,
                                    label: '离职原因',
                      label: "离职原因",
                                    prop: "leaving",
                                    formslot: true,
                                }
                            ]
                        }
                    },
                ]
            }
          ]
                  ],
        },
        data: []
              },
            ],
          },
        ],
      },
      data: [],
      };
    },
    watch: {
      'form.tenantId'() {
        if (this.form.tenantId !== '' && this.initFlag) {
    "form.tenantId"() {
      if (this.form.tenantId !== "" && this.initFlag) {
          this.initData(this.form.tenantId);
        }
      },
      'excelForm.isCovered'() {
        if (this.excelForm.isCovered !== '') {
    "excelForm.isCovered"() {
      if (this.excelForm.isCovered !== "") {
          const column = this.findObject(this.excelOption.column, "excelFile");
          column.action = `/api/blade-user/import-user?isCovered=${this.excelForm.isCovered}`;
        }
      }
    },
    computed: {
    },
  computed: {},
    mounted() {
      //获取userId
      this.userId = JSON.parse(window.localStorage.getItem("saber-userInfo")).content.user_id;
    this.userId = JSON.parse(
      window.localStorage.getItem("saber-userInfo")
    ).content.user_id;
      //获取用户信息
      this.getUserDetail();
    },
    methods: {
    inits(id) {
      this.form.id = id || 0;
      this.visible = true;
    },
      //获取用户信息
      getUserDetail(){
         var that = this;
          //获取用户基本信息
         getUser(this.userId).then(res => {
      getUser(this.userId).then((res) => {
            this.form = res.data.data;
            var userInfo = res.data.data;
            //获取用户从业信息
            getUserPractitionersInfo(userInfo.cardid).then(res1 =>{
        getUserPractitionersInfo(userInfo.cardid).then((res1) => {
               that.form.UserPractitionersInfo = res1.data.data;
            })
        });
            if (this.form.hasOwnProperty("deptId")) {
              this.form.deptId = this.form.deptId.split(",");
            }
@@ -339,7 +370,7 @@
        const userPractitionersList = [];
        var userPractitionersInfo = row.UserPractitionersInfo;
        if(userPractitionersInfo.length>0){
            userPractitionersInfo.forEach(item => {
        userPractitionersInfo.forEach((item) => {
                const info = {
                    companyname: item.companyname,
                    department: item.department,
@@ -349,34 +380,37 @@
                    leaving: item.leaving,
                    cardid:row.cardid,
                    post: item.post,
                    responsibilities: item.responsibilities
                }
            responsibilities: item.responsibilities,
          };
                userPractitionersList.push(info);
            });
        }
        var IdCardNo = row.cardid; 
        row.deptId = row.deptId.join(",");
        row.postId = row.postId.join(",");
        update(row).then(() => {
      update(row).then(
        () => {
           const experience = {
               cardid:IdCardNo,
               userPractitionersInfo:userPractitionersList
           }
            userPractitionersInfo: userPractitionersList,
          };
           //更新从业信息
            saveOrUpdateUserPractitionersInfo(experience).then(()=>{
                this.$message({
                    type: "success",
                    message: "操作成功!"
              message: "操作成功!",
                 });
            })
          });
           this.loading = false;
          done();
        }, error => {
        },
        (error) => {
          window.console.log(error,111);
          loading();
        });
      }
    }
      );
    },
  },
  };
</script>
@@ -400,4 +434,29 @@
  /* .el-form-item__content{
      margin-left: 0px !important;
  } */
.addorupdatetitle{
  position: absolute;
  left: 10px;
  top: 70px;
  width: 10px;
  height: 10px;
  font-size: 10px;
  cursor: pointer;
}
.xx {
  position: absolute;
  right: 50px;
  top: 70px;
  height: 10px;
  font-size: 24px;
  z-index: 600;
}
.flaots {
  width: 70%;
  padding-top: 50px;
  position: absolute;
}
</style>