智慧农业后台管理页面
guoshilong
2022-11-08 082613d446e29e4ec1c16bfaa52345106a498b23
src/views/system/user.vue
@@ -31,13 +31,13 @@
                   @refresh-change="refreshChange"
                   @on-load="onLoad">
          <template slot-scope="{type,row,size}" slot="menu">
            <el-button
            <el-button
              :type="type"
              :size="size"
              icon="el-icon-edit"
              :disabled="row.roleId == '1123598816738675201' "
              @click="update(row)">编辑</el-button>
            <el-button
            <el-button
              :type="type"
              :size="size"
              icon="el-icon-delete"
@@ -52,13 +52,13 @@
                       v-if="permission.user_delete"
                       @click="handleDelete">删 除
            </el-button>
            <el-button type="info"
                       size="small"
                       plain
                       v-if="permission.user_role"
                       icon="el-icon-user"
                       @click="handleGrant">角色配置
            </el-button>
<!--            <el-button type="info"-->
<!--                       size="small"-->
<!--                       plain-->
<!--                       v-if="permission.user_role"-->
<!--                       icon="el-icon-user"-->
<!--                       @click="handleGrant">角色配置-->
<!--            </el-button>-->
            <el-button type="info"
                       size="small"
                       plain
@@ -66,13 +66,13 @@
                       icon="el-icon-refresh"
                       @click="handleReset">密码重置
            </el-button>
            <el-button type="info"
                       size="small"
                       plain
                       v-if="userInfo.role_name.includes('admin')"
                       icon="el-icon-setting"
                       @click="handlePlatform">平台配置
            </el-button>
<!--            <el-button type="info"-->
<!--                       size="small"-->
<!--                       plain-->
<!--                       v-if="userInfo.role_name.includes('admin')"-->
<!--                       icon="el-icon-setting"-->
<!--                       @click="handlePlatform">平台配置-->
<!--            </el-button>-->
            <el-button type="info"
                       size="small"
                       plain
@@ -80,20 +80,20 @@
                       icon="el-icon-coordinate"
                       @click="handleLock">账号解封
            </el-button>
            <el-button type="success"
                       size="small"
                       plain
                       v-if="userInfo.role_name.includes('admin')"
                       icon="el-icon-upload2"
                       @click="handleImport">导入
            </el-button>
            <el-button type="warning"
                       size="small"
                       plain
                       v-if="userInfo.role_name.includes('admin')"
                       icon="el-icon-download"
                       @click="handleExport">导出
            </el-button>
<!--            <el-button type="success"-->
<!--                       size="small"-->
<!--                       plain-->
<!--                       v-if="userInfo.role_name.includes('admin')"-->
<!--                       icon="el-icon-upload2"-->
<!--                       @click="handleImport">导入-->
<!--            </el-button>-->
<!--            <el-button type="warning"-->
<!--                       size="small"-->
<!--                       plain-->
<!--                       v-if="userInfo.role_name.includes('admin')"-->
<!--                       icon="el-icon-download"-->
<!--                       @click="handleExport">导出-->
<!--            </el-button>-->
          </template>
          <template slot-scope="{row}"
                    slot="tenantName">
@@ -225,7 +225,6 @@
  import {dateNow} from "@/util/date";
  import NProgress from 'nprogress';
  import 'nprogress/nprogress.css';
  export default {
    data() {
      const validatePass = (rule, value, callback) => {
@@ -245,28 +244,28 @@
        }
      };
      const validatePhone = (rule, value, callback) => {
        if (!/^[1]([3-9])[0-9]{9}$/.test(value)) {
          callback(new Error("请输入正确的手机号格式"));
        } else {
        if (value){
          if (!/^[1]([3-9])[0-9]{9}$/.test(value)) {
            callback(new Error("请输入正确的手机号格式"));
          } else {
            callback();
          }
        }else {
          callback();
        }
      };
      const validateEmail = (rule, value, callback) => {
        const mal = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
      // const mailReg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/
        if (rule.required && !value) {
          return callback(new Error('不能为空'))
        }
        if (value) {
        if (value){
          if (!(mal.test(value))) {
            callback(new Error('请输入正确邮箱'))
          } else {
            callback()
          }
        }else {
          callback()
        }
      }
      };
      return {
        form: {},
        search:{},
@@ -370,6 +369,19 @@
              prop: "roleName",
              slot: true,
              display: false
            },
            {
              display: false,
              label: "账号状态",
              prop: "bannedState",
              slot: true,
              dicData: [{
                label: '已封禁',
                value: "1"
              }, {
                label: '正常',
                value: "0"
              }],
            },
            {
              label: "所属部门",
@@ -859,7 +871,10 @@
        row['deptId'] = this.userInfo.dept_id;
        row.roleId = row.roleId.join(",");
        row.farmId = row.farmId.join(",");
        // row.postId = row.postId.join(",");
        row.id = null
        if (!row.sex){
          row.sex = 3
        }
        add(row).then(() => {
          this.initFlag = false;
          this.onLoad(this.page);
@@ -892,6 +907,10 @@
        });
      },
      update(row){
        this.dialogVisible = true
        this.$nextTick(()=>{
          this.$refs.form.clearValidate()
        })
        this.form = {
          id:row.id,
          account:row.account,
@@ -908,12 +927,14 @@
        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(",")
        if (!row.sex){
          row.sex = 3
        }
        update(this.form).then(() => {
          this.initFlag = false;
          this.onLoad(this.page);
@@ -1043,6 +1064,7 @@
              type: "success",
              message: "操作成功!"
            });
            this.onLoad(this.page)
          });
      },
      handleImport() {
@@ -1073,13 +1095,14 @@
        })
      },
      beforeOpen(done, type) {
        this.initFlag = true;
        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.form = {id:null}
          this.initData(website.tenantId)
        }
        if (["edit", "view"].includes(type)) {
@@ -1101,7 +1124,12 @@
            // }
          });
        }
        this.initFlag = true;
        if (type == "add"){
          if (this.$refs.form){
            this.$refs.form.resetForm()
          }
          this.form = {id :null }
        }
        done();
      },
      currentChange(currentPage) {