马宇豪
2024-01-09 cb7cff7884fad86e47a5132d59986065b64c771f
src/views/usermng/user.vue
@@ -114,29 +114,30 @@
                  </el-option>
              </el-select>
          </div>
          <div class="basic_search">
              <el-select v-model="queryForm.town" clearable filterable @change="changeArea('town')" >
                  <el-option
                      v-for="item in streetList"
                      :key="item.id"
                      :label="item.name"
                      :value="item.name"
                  >
                  </el-option>
              </el-select>
          </div>
          <div class="basic_search">
              <el-select v-model="queryForm.community" clearable filterable>
                  <el-option
                      v-for="item in committeeList"
                      :key="item.id"
                      :label="item.name"
                      :value="item.name"
                  >
                  </el-option>
              </el-select>
          </div>
<!--          <div class="basic_search">-->
<!--              <el-select v-model="queryForm.town" clearable filterable @change="changeArea('town')" >-->
<!--                  <el-option-->
<!--                      v-for="item in streetList"-->
<!--                      :key="item.id"-->
<!--                      :label="item.name"-->
<!--                      :value="item.name"-->
<!--                  >-->
<!--                  </el-option>-->
<!--              </el-select>-->
<!--          </div>-->
<!--          <div class="basic_search">-->
<!--              <el-select v-model="queryForm.community" clearable filterable>-->
<!--                  <el-option-->
<!--                      v-for="item in committeeList"-->
<!--                      :key="item.id"-->
<!--                      :label="item.name"-->
<!--                      :value="item.name"-->
<!--                  >-->
<!--                  </el-option>-->
<!--              </el-select>-->
<!--          </div>-->
      </div>
      <br/>
    <div class="table_content">
      <el-table
        v-loading="listLoading"
@@ -159,6 +160,11 @@
            <span>{{ scope.row.company }}</span>
          </template>
        </el-table-column>
          <el-table-column label="级别" prop="unittype" align="center" width="150" sortable="custom">
              <template slot-scope="scope">
                  <span>{{ scope.row.unittype == 1? '省级':(scope.row.unittype == 2 ? '地(州、市)级' : '区、县级') }}</span>
              </template>
          </el-table-column>
        <el-table-column label="办公电话" prop="phone" align="center" sortable="custom">
        <template slot-scope="scope">
          <span>{{ scope.row.phone }}</span>
@@ -201,7 +207,7 @@
        </el-table-column>
        <el-table-column label="管辖地区" prop="province" align="center" width="300" sortable="custom">
          <template slot-scope="scope">
            <span>{{ scope.row.province+'-'+scope.row.city+'-'+scope.row.area+'-'+scope.row.town+'-'+scope.row.community | parseGX}}</span>
            <span>{{ scope.row.province+'-'+scope.row.city+'-'+scope.row.area | parseGX}}</span>
          </template>
        </el-table-column>
        <el-table-column label="更新时间" prop="lastmodifieddate" align="center" sortable="custom">
@@ -209,7 +215,7 @@
            <span>{{ scope.row.lastmodifieddate | parseTime('{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width">
        <el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width" fixed="right">
          <template slot-scope="scope">
            <el-button type="text" @click="showEditHandle(scope.row)">编辑</el-button>
            <el-button  v-show="userType != 3" :disabled="disableRole(scope.row)" type="text" align="center" @click="showAssignRole(scope.row)">分配角色</el-button>
@@ -232,7 +238,7 @@
      />
    </div>
    <el-dialog :title="dialogStatus==='create'?'新增':'编辑'" :visible.sync="dialogFormVisible" :modal-append-to-body="false" :close-on-click-modal="false" width="700px">
      <el-form ref="dataForm" :rules="dataFormRules" :model="dataForm" label-position="right" label-width="100px" style="margin-left:50px;width:500px;" element-loading-text="保存中...">
      <el-form ref="dataForm" :rules="dataFormRules" :model="dataForm" label-position="right" label-width="120px" style="margin-left:50px;width:500px;" element-loading-text="保存中...">
        <el-form-item label="用户名:" prop="username">
          <el-input v-model.trim="dataForm.username"/>
        </el-form-item>
@@ -281,7 +287,17 @@
          <el-form-item label="统一社会信用代码:" prop="job">
              <el-input v-model.trim="dataForm.code"/>
          </el-form-item>
        <el-form-item label="管辖地区:">
          <el-form-item label="选择监管级别:" prop="unittype">
              <el-select v-model="dataForm.unittype" filterable placeholder="请选择级别">
                  <el-option
                      v-for="item in unitTypeList"
                      :key="item.name"
                      :label="item.name"
                      :value="item.value">
                  </el-option>
              </el-select>
          </el-form-item>
        <el-form-item label="管辖省份:" prop="province">
          <el-select v-model="dataForm.province" filterable placeholder="请选择省份" @change="resetCity">
            <el-option
              v-for="item in provinceList"
@@ -290,7 +306,9 @@
              :value="item.name">
            </el-option>
          </el-select>
          <el-select v-model="dataForm.city"  placeholder="请选择城市" @change="resetArea">
        </el-form-item>
          <el-form-item label="管辖地(州、市):" v-if="dataForm.unittype == 2 || dataForm.unittype == 3" prop="city">
          <el-select v-model="dataForm.city" placeholder="请选择城市" @change="resetArea">
            <el-option
              v-for="item in cityList"
              :key="item.name"
@@ -299,7 +317,9 @@
              >
            </el-option>
          </el-select>
          <el-select v-model="dataForm.area"  placeholder="请选择区县" @change="resetTown">
          </el-form-item>
          <el-form-item label="管辖区县:" v-if="dataForm.unittype == 3" prop="area">
          <el-select v-model="dataForm.area" placeholder="请选择区县" @change="resetTown">
            <el-option
              v-for="item in areaList"
              :key="item.name"
@@ -308,25 +328,25 @@
              >
            </el-option>
          </el-select>
          <el-select v-model="dataForm.town"  placeholder="请选择街道" @change="resetCommunity">
            <el-option
              v-for="item in townList"
              :key="item.name"
              :label="item.name"
              :value="item.name"
             >
            </el-option>
          </el-select>
          <el-select v-model="dataForm.community"  placeholder="请选择社区">
            <el-option
              v-for="item in communityList"
              :key="item.name"
              :label="item.name"
              :value="item.name"
              >
            </el-option>
          </el-select>
        </el-form-item>
          </el-form-item>
<!--          <el-select v-model="dataForm.town"  placeholder="请选择街道" @change="resetCommunity">-->
<!--            <el-option-->
<!--              v-for="item in townList"-->
<!--              :key="item.name"-->
<!--              :label="item.name"-->
<!--              :value="item.name"-->
<!--             >-->
<!--            </el-option>-->
<!--          </el-select>-->
<!--          <el-select v-model="dataForm.community"  placeholder="请选择社区">-->
<!--            <el-option-->
<!--              v-for="item in communityList"-->
<!--              :key="item.name"-->
<!--              :label="item.name"-->
<!--              :value="item.name"-->
<!--              >-->
<!--            </el-option>-->
<!--          </el-select>-->
        <el-form-item label="用户类型:" prop="type">
          <el-select v-model.trim="dataForm.type" placeholder="请选择用户类型" auto-complete="on" style="width:100%;">
            <el-option v-show="userType != 3" :value="2" label="管理员"/>
@@ -452,19 +472,13 @@
      for (let i = 0; i < arr.length; i++){
        if (arr[i] == null || arr[i] == '' || arr[i] == 'null'){
          if (i == 0){
            guanxia = '全部省份';
            guanxia = '';
          }
          if (i == 1){
            guanxia += '-全部城市';
            guanxia += '';
          }
          if (i == 2){
            guanxia += '-全部区县';
          }
          if (i == 3){
            guanxia += '-全部街道';
          }
          if (i == 4){
            guanxia += '-全部居委会';
            guanxia += '';
          }
        }else {
          if (i == 0){
@@ -486,7 +500,6 @@
  data() {
    let _ref = this;
    const validateEmail = (rule, value, callback) => {
      if (value == null || value == '') {
        callback()
      } else {
@@ -507,6 +520,7 @@
      currentPage: 1,
      pageTotal: 0,
      tableKey: 0,
      unittype: null,
      userData: null,
      listLoading: true,
      queryForm: {
@@ -516,9 +530,7 @@
          job:'',
          province:'',
          city:'',
          area:'',
          town:'',
          community:'',
          area:''
      },
      dataForm: {
        id: '',
@@ -532,11 +544,10 @@
        province: '',
        city: '',
        area: '',
        town: '',
        community: '',
        type:'',
        job:'',
        code:'',
        unittype: null
      },
      importDialogFormVisible: false,
      importDialogFormVisible2: false,
@@ -550,8 +561,26 @@
        email: [{ validator: validateEmail, trigger: 'blur' }],
        password: [{ required: true, message: '密码不能为空', trigger: 'blur' }],
        confirmPassword: [{ required: true, message: '确认密码不能为空', trigger: 'blur' }],
        type: [{ required: true, message: '用户类型不能为空', trigger: 'blur' }]
        type: [{ required: true, message: '用户类型不能为空', trigger: 'blur' }],
        unittype: [{ required: true, message: '监管级别不能为空', trigger: 'blur' }],
        province: [{ required: true, message: '请选择管辖范围', trigger: 'blur' }],
        city: [{ required: true, message: '请选择管辖范围', trigger: 'blur' }],
        area: [{ required: true, message: '请选择管辖范围', trigger: 'blur' }]
      },
        unitTypeList:[
            {
                name: '省级',
                value: 1
            },
            {
                name: '地(州、市)级',
                value: 2
            },
            {
                name: '区、县级',
                value: 3
            }
        ],
      provinceList:[],
      cityList:[],
      areaList:[],
@@ -577,7 +606,6 @@
    }
  },
  created() {
      console.log(this.userType)
    this.getUserList()
    this.getProvince()
  },
@@ -634,6 +662,13 @@
            parseError({ error: '密码输入不一致', vm: _this })
            return
          }
          if(_this.dataForm.unittype == 1){
              _this.dataForm.city = ''
              _this.dataForm.area = ''
          }
            if(_this.dataForm.unittype == 2){
                _this.dataForm.area = ''
            }
          const userName = Cookies.get('userName')
          _this.dataForm['operator'] = userName
          createUser(_this.dataForm).then(response => {
@@ -701,9 +736,8 @@
        province: '',
        city: '',
        area: '',
        town: '',
        community: '',
        type: '',
        unittype: null,
        job: ''
      }
      this.cityList = []
@@ -729,6 +763,13 @@
              return
            }
          }
            if(_this.dataForm.unittype == 1){
                _this.dataForm.city = ''
                _this.dataForm.area = ''
            }
            if(_this.dataForm.unittype == 2){
                _this.dataForm.area = ''
            }
          const userName = Cookies.get('userName')
          _this.dataForm['lastmodifiedby'] = userName
          updateUser(_this.dataForm).then(response => {
@@ -817,10 +858,9 @@
      this.dataForm.province = row.province
      this.dataForm.city = row.city
      this.dataForm.area = row.area
      this.dataForm.town = row.town
      this.dataForm.community = row.community
      this.dataForm.job = row.job
      this.dataForm.type = row.type
      this.dataForm.unittype = row.unittype
      this.dialogFormVisible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].clearValidate()
@@ -830,16 +870,12 @@
      params['province'] = row.province
      params['city'] = row.city
      params['area'] = row.area
      params['town'] = row.town
      params['community'] = row.community
      getDistrictByName(params).then(response => {
        const res = response.data
        if (res.code == 200){
          this.provinceList = res.result.provinceList;
          this.cityList = res.result.cityList;
          this.areaList = res.result.areaList;
          this.townList = res.result.townList;
          this.communityList = res.result.communityList;
        } else {
          parseError({ error: res.message, vm: _this })
        }