<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="小区名称" prop="community">
        <el-select v-model="queryParams.community" placeholder="请选择小区名称" clearable size="small">
          <el-option
            v-for="community in communitys"
            :key="community.id"
            :label="community.name"
            :value="community.id"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="用户信息" prop="userInfo">
        <el-input
          v-model="queryParams.userInfo"
          placeholder="请输入用户信息"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开通状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择开通状态" clearable size="small">
          <el-option
            v-for="dict in statusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="安检用户" prop="taskType">
        <el-select v-model="queryParams.taskType" placeholder="请选择安检用户" clearable size="small">
          <el-option
            v-for="dict in inspectUserTypeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="表具厂家" prop="meterCompany">
        <el-select v-model="queryParams.meterCompany" placeholder="请选择表具厂家" clearable size="small">
          <el-option
            v-for="dict in bjcjList"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>

      <!--<el-form-item label="表具类型" prop="meterType">-->
        <!--<el-select v-model="queryParams.meterType" placeholder="请选择表具类型" clearable size="small">-->
          <!--<el-option-->
            <!--v-for="dict in bjlxList"-->
            <!--:key="dict.id"-->
            <!--:label="dict.name"-->
            <!--:value="dict.id"-->
          <!--/>-->
        <!--</el-select>-->
      <!--</el-form-item>-->

      <el-form-item label="表具位置" prop="position">
        <el-select v-model="queryParams.position" placeholder="请选择表具位置" clearable size="small">
          <el-option
            v-for="dict in positionOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>



      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:user:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:user:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:user:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['system:user:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="姓名" align="center" prop="username" />
      <el-table-column label="联系电话" align="center" prop="phone" />
      <el-table-column label="用户编号" align="center" prop="usernum" />
      <el-table-column label="所属区域" align="center" prop="countyName" :show-overflow-tooltip="true"  width="250">
        <template slot-scope="scope">
          {{ scope.row.countyName }}
          <span v-if="scope.row.streetName">-{{ scope.row.streetName }}</span>
          <span v-else></span>
          <span v-if="scope.row.villageName">-{{ scope.row.villageName }}</span>
          <span v-else></span>
        </template>
      </el-table-column>
     <!-- <el-table-column label="所属街道" align="center" prop="streetName" />
      <el-table-column label="所属小区" align="center" prop="villageName" >
        <template slot-scope="scope">
          <span v-if="scope.row.villageName">{{ scope.row.villageName}}</span>
          <span v-else>-</span>
        </template>
      </el-table-column>-->
      <!--<el-table-column label="具体地址" align="center" prop="address" />-->
      <!--<el-table-column label="表具编号" align="center" prop="meternum" />-->
      <el-table-column label="表具位置" align="center" prop="position" :formatter="positionFormat"/>
      <el-table-column label="开通状态" align="center" prop="status" :formatter="statusFormat" />
      <el-table-column label="通气日期" align="center" prop="starttime" width="180">
        <template slot-scope="scope">
          <span v-if="scope.row.starttime">{{ parseTime(scope.row.starttime, '{y}-{m}-{d}') }}</span>
          <span v-else>-</span>
        </template>
      </el-table-column>
      <!--<el-table-column label="用气设施" align="center" prop="device" />-->
      <!--<el-table-column label="表具类型" align="center" prop="meterType" />-->
      <!--<el-table-column label="表具厂家" align="center" prop="meterCompany" />-->
      <!--<el-table-column label="表具型号" align="center" prop="meterModel" />-->
      <!--<el-table-column label="进气方向" align="center" prop="direction" />-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-document"
            @click="handleDetail(scope.row)"
          >详情</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:user:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:user:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改居民用户对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body destroy-on-close @close="closedialog" :close-on-click-modal="false">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="用户姓名" prop="username">
              <el-input v-model="form.username" placeholder="请输入用户姓名" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系电话" prop="phone">
              <el-input v-model="form.phone" placeholder="请输入联系电话" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="身份证" prop="idcard">
              <el-input v-model="form.idcard" placeholder="请输入用户姓名" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="营业网点" prop="branch">
              <el-select v-model="form.branch" placeholder="请选择营业网点">
                <el-option
                  v-for="dict in sceneOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="用户编号" prop="usernum">
              <el-input v-model="form.usernum" placeholder="请输入用户编号" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="表具厂家" prop="meterCompany">
              <el-select v-model="form.meterCompany" placeholder="请选择表具厂家">
                <el-option
                  v-for="dict in bjcjList"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                />
              </el-select>
            </el-form-item>
          </el-col>

        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="表具编号" prop="meternum">
              <el-input v-model="form.meternum" placeholder="请输入表具编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="表具位置" prop="position">
              <el-select v-model="form.position" placeholder="请选择表具位置">
                <el-option
                  v-for="dict in positionOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-form-item label="所属区域" prop="city">
              <!--<el-col :span="5">
                  <el-select v-model="form.city" placeholder="所属市" @change="(id) =>getAreaList(id,2)">
                    <el-option
                      v-for="dict in oneAreaList"
                      :key="dict.id"
                      :label="dict.areaName"
                      :value="dict.id"
                    />
                  </el-select>
              </el-col>

              <el-col :span="6" style="margin-left: 8px">
                  <el-select v-model="form.county" placeholder="所属区县" @change="(id) =>getAreaList(id,3)">
                    <el-option
                      v-for="dict in twoAreaList"
                      :key="dict.id"
                      :label="dict.areaName"
                      :value="dict.id"
                    />
                  </el-select>
              </el-col>-->

              <el-col :span="6" style="margin-left: 8px" >
                <el-select v-model="form.street" placeholder="所属乡镇" @change="(id) =>getAreaList(id,4)">
                  <el-option
                    v-for="dict in threeAreaList"
                    :key="dict.id"
                    :label="dict.areaName"
                    :value="dict.id"
                  />
                </el-select>
              </el-col>

              <el-col :span="6" style="margin-left: 8px">
                <el-select v-model="form.village" placeholder="所属小区（村）">
                  <el-option
                    v-for="dict in fourAreaList"
                    :key="dict.id"
                    :label="dict.name"
                    :value="dict.id"
                  />
                </el-select>
              </el-col>
          </el-form-item>
          <!--<el-col :span="1">-->
            <!--<img style="width: 30px;height: 30px;margin-left: 8px;margin-top: 4px;cursor: pointer" src="@/assets/icons/address.png"></img>-->
          <!--</el-col>-->
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="地址坐标" prop="longitude">
              <el-col :span="8">
                <el-input v-model="form.longitude" placeholder="请输入经度"/>
              </el-col>
              <el-col :span="8" style="margin-left: 20px">
                <el-input v-model="form.latitude" placeholder="请输入纬度"/>
              </el-col>
              <el-col :span="4" style="margin-left: 30px">
                <el-button type="primary" plain @click="MapdialogFun">选择经纬度</el-button>
              </el-col>
            </el-form-item>
          </el-col>
        </el-row>
        <!--<el-form-item label="所属小区" prop="village">-->
          <!--<el-input v-model="form.village" placeholder="请输入所属小区" />-->
        <!--</el-form-item>-->
        <el-form-item label="具体地址" prop="address">
          <el-input v-model="form.address" placeholder="请输入具体地址" />
        </el-form-item>

        <el-form-item label="开通状态" prop="status">
          <el-radio-group v-model="form.status">
            <el-radio
              v-for="dict in statusOptions"
              :key="dict.dictValue"
              :label="dict.dictValue"
            >{{dict.dictLabel}}</el-radio>
          </el-radio-group>
        </el-form-item>

        <el-row>
          <el-col :span="12">
              <el-form-item label="通气日期" prop="starttime">
                <el-date-picker clearable size="small"
                                v-model="form.starttime"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="选择通气日期">
                </el-date-picker>
              </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="安检类型" prop="taskType">
              <el-select v-model="form.taskType" placeholder="请选择安检类型">
                <el-option
                  v-for="dict in inspectUserTypeOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <!--<el-col :span="12">-->
            <!--<el-form-item label="表具类型" prop="meterType">-->
              <!--<el-select v-model="form.meterType" placeholder="请选择表具类型">-->
                <!--<el-option-->
                  <!--v-for="dict in bjlxList"-->
                  <!--:key="dict.id"-->
                  <!--:label="dict.name"-->
                  <!--:value="dict.id"-->
                <!--/>-->
              <!--</el-select>-->
            <!--</el-form-item>-->
          <!--</el-col>-->

        </el-row>

        <el-row>
          <!--<el-col :span="12">-->
            <!--<el-form-item label="表具厂家" prop="meterCompany">-->
              <!--<el-select v-model="form.meterCompany" placeholder="请选择表具厂家">-->
                <!--<el-option-->
                  <!--v-for="dict in bjcjList"-->
                  <!--:key="dict.id"-->
                  <!--:label="dict.name"-->
                  <!--:value="dict.id"-->
                <!--/>-->
              <!--</el-select>-->
            <!--</el-form-item>-->
          <!--</el-col>-->
          <el-col :span="12">
            <el-form-item label="进气方向" prop="direction">
              <el-select v-model="form.direction" placeholder="请选择进气方向">
                <el-option
                  v-for="dict in jqfxList"
                  :key="dict.id"
                  :label="dict.name"
                  :value="dict.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="用户照片" prop="imgurl">
              <MultipleImageUpload
                :limit="9"
                v-model="form.imgurl"
                ref="userImageInfo"
              />
            </el-form-item>
          </el-col>
        </el-row>


        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>

    </el-dialog>
    <GetPos
      :dialogVisible.sync="dialogTableVisibles"
      :devicePos="devicePos"
      @close="dialogcancelFun"
      @getPath="getPath"
      style="z-index: 3000"
    />
    <DetailInfo ref="detail"/>
  </div>

</template>

<script>
  import { listCommunity } from "@/api/baseinfo/community";
  import GetPos from '@/components/GetPos';
  import { listUser, getUser, delUser, addUser, updateUser, exportUser } from "@/api/baseinfo/user";
  import { listArea} from "@/api/baseinfo/area";
  import DetailInfo from "./components/DetailInfo"
  import { communityList } from "@/api/baseinfo/community";
  import MultipleImageUpload from "@/components/MultipleImageUpload";
  export default {
    name: "User",
    components: {
      GetPos,
      DetailInfo,
      MultipleImageUpload,
    },
    data() {
      return {
        devicePos: [],
        // 遮罩层
        loading: true,
        // 导出遮罩层
        exportLoading: false,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 居民用户表格数据
        userList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 开通状态字典
        statusOptions: [],
        typeOptions:[],
        sceneOptions:[],
        dialogTableVisibles: false,
        bjlxList:[
          {
            id:1,
            name:'皮膜'
          },
          {
            id:2,
            name:"超声"
          }
        ],
        bjcjList:[
          {
            id:1,
            name:'金卡'
          },
          {
            id:2,
            name:"秦川"
          }
        ],
        bjxhList:[
          {
            id:1,
            name:'G1.5'
          },
          {
            id:2,
            name:"G2.5"
          },
          {
            id:3,
            name:"G4"
          }
        ],
        jqfxList:[
          {
            id:1,
            name:'左'
          },
          {
            id:2,
            name:"右"
          }
        ],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          meternum: null,
          street: null,
          village: null,
          username: null,
          status: null,
          community: null,
          userInfo: null,
          taskType: null,
          meterCompany: null,
          meterType: null,
          position: null
        },
        //地区关联查询
        queryParams2: {
          pageNum: 1,
          pageSize: 100,
          parentId:0
        },
        queryParams3: {
          pageNum: 1,
          pageSize: 100,
          street:''
        },
        oneAreaList:[],
        twoAreaList:[],
        threeAreaList:[],
        fourAreaList:[],
        // 表单参数
        form: {
        },
        // 表单校验
        rules: {
          username: [
            { required: true, message: "用户名称不能为空", trigger: "blur" }
          ],
          phone: [
            { required: true, message: "用户手机不能为空", trigger: "blur" },
            {
              type: 'number',
              message: '手机号格式不正确',
              trigger: 'blur',
              transform(value) {
                let phonereg = 11 && /^((13|14|15|16|17|18|19)[0-9]{1}\d{8})$/
                if (!phonereg.test(value)) {
                  return false
                } else {
                  return Number(value)
                }
              }
            }
          ],
          usernum: [
            { required: true, message: "用户编号不能为空", trigger: "blur" }
          ],
          type: [
            { required: true, message: "表计类型不能为空", trigger: "change" }
          ],
          city: [
            { required: true, message: "区域不能为空", trigger: "change" }
          ],
          /*longitude: [
            { required: true, message: "经纬度不能为空", trigger: "blur" }
          ],*/
          status: [
            { required: true, message: "开通状态不能为空", trigger: "blur" }
          ],
          /*position: [
            { required: true, message: "请选择表具位置", trigger: "change" }
          ],*/
          taskType: [
            { required: true, message: "请选择安检类型", trigger: "blur" }
          ],
          meternum: [
            { required: true, message: "表具编号不能为空", trigger: "blur" }
          ],
        },
        communitys: [],
        positionOptions: [],
        inspectUserTypeOptions: []
      };
    },
    created() {
      this.getList();
      this.getAreaList(0,1)
      this.getDicts("t_user_status").then(response => {
          this.statusOptions = response.data;
      });
      this.getDicts("t_meter_company").then(response => {
        this.bjcjList = response.data;
      });
      this.getDicts("t_branch").then(response => {
        this.sceneOptions = response.data;
      });
      this.getDicts("t_meter_position").then(response => {
        this.positionOptions = response.data;
      });
      this.getDicts("t_inspect_user_type").then(response => {
        this.inspectUserTypeOptions = response.data;
      });
      this.getCommunityInfo();
    },
    methods: {
      /** 查询居民用户列表 */
      getList() {
        this.loading = true;
        listUser(this.queryParams).then(response => {
          this.userList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
      },
      getAreaList(e,level) {
        this.queryParams2.parentId = e;
        if(level==4){
          this.queryParams3.street = e;
          listCommunity(this.queryParams3).then(response => {
            this.fourAreaList = response.rows;
            this.form.village ='';
          })
          return
        }
        listArea(this.queryParams2).then(response => {
          if(level==1){
            this.oneAreaList = response.rows;
          }else if(level==2){
            this.twoAreaList = response.rows;
            this.form.county ='';
            this.form.street ='';
            this.form.village ='';
          }else if(level==3){
            this.threeAreaList = response.rows;
            this.form.street ='';
            this.form.village ='';
          }
      });
      },
      closedialog(){
        this.twoAreaList =[];
        this.threeAreaList =[];
        this.fourAreaList =[];
      },
      //开启地图
      MapdialogFun() {
        this.dialogTableVisibles = true;
      },
      getPath(res){
        //确认选择经纬度
        this.form.longitude = res[0];
        this.form.latitude = res[1];
      },
      /**
       * 地图关闭方法
       */
      dialogcancelFun() {
        this.dialogTableVisibles = false;
      },
      //用来回显
      getAreaListtwo(e,level) {
        this.queryParams2.parentId = e;
        if(level==4){
          return
        }
        listArea(this.queryParams2).then(response => {
          if(level==1){
            this.oneAreaList = response.rows;
          }else if(level==2){
            this.twoAreaList = response.rows;
          }else if(level==3){
            this.threeAreaList = response.rows;
          }
        });
      },
      // 开通状态字典翻译
      statusFormat(row, column) {
        return this.selectDictLabel(this.statusOptions, row.status);
      },
      typeFormat(row, column) {
        return this.selectDictLabel(this.typeOptions, row.type);
      },
      positionFormat(row, column) {
        let position = this.selectDictLabel(this.positionOptions, row.position);
        return position? position : "-";
      },
      companyFormat(row, column) {
        console.log(row)
        return this.selectDictLabel(this.bjcjList, row.meterCompany);
      },
      branchFormat(row, column) {
        console.log("branch",row)
        return this.selectDictLabel(this.sceneOptions, row.branch);
      },

      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          usernum: null,
          city: 1,
          county: 8,
          street: null,
          village: null,
          address: null,
          username: null,
          phone: null,
          idcard: null,
          branch: null,
          type: null,
          status: "0100",
          starttime: null,
          device: null,
          meterType: null,
          meterCompany: null,
          meterModel: null,
          direction: null,
          taskId: null,
          remark: null,
          imgurl: null,
          position: null,
          taskType: null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.getAreaListtwo(this.form.county,3);
        this.open = true;
        this.title = "添加居民用户";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const id = row.id || this.ids
        getUser(id).then(response => {
          this.form = response.data;
          if(this.form.device!=null&&this.form.device!=''){
            this.form.device = this.form.device.split(',')
          }
          this.getAreaListtwo(this.form.city,2);
          this.getAreaListtwo(this.form.county,3);
          this.getxiaoqu(this.form.street);
          this.getReloadFile(this.form.imgurl,"userImageInfo");
        this.open = true;
        this.title = "修改居民用户";
      });
      },
      getxiaoqu(e){
        this.queryParams3.street = e;
        listCommunity(this.queryParams3).then(response => {
          this.fourAreaList = response.rows;
        })
      },
      //详情
      handleDetail(row){
        this.$refs.detail.getDetailInfo(row.id);
      },
      /** 提交按钮 */
      submitForm() {
        console.log(this.form)

        this.$refs["form"].validate(valid => {
          if (valid) {

            if(this.form.device!=null&&this.form.device!=''){
              this.form.device = this.form.device.join(",")
            }else{
              this.form.device=''
            }

            if (this.form.id != null) {
              updateUser(this.form).then(response => {
                this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
            } else {
              addUser(this.form).then(response => {
                this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        this.$confirm('是否确认删除居民表具编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delUser(ids);
        }).then(() => {
          this.getList();
        this.msgSuccess("删除成功");
      }).catch(() => {});
      },
      /** 导出按钮操作 */
      handleExport() {
        const queryParams = this.queryParams;
        this.$confirm('是否确认导出所有居民用户数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
        return exportUser(queryParams);
      }).then(response => {
          this.download(response.msg);
        this.exportLoading = false;
      }).catch(() => {});
      },
      //小区列表
      getCommunityInfo(){
        communityList().then(res =>{
          if(res.code == 200){
             this.communitys = res.data;
          }
        })
      },
      getReloadFile(file,ref){
        this.$nextTick(() => {
          if(file){
            let temp = 1;
            this.$refs[ref].fileList = file.split(",").map(item => { return{ url:item,uid: new Date().getTime() + temp++ }});
          }
        })
      }
    }
  };
</script>
<style lang="scss" scoped>
  ::v-deep .el-select{
    width: 100%;
  }
  ::v-deep .el-date-editor.el-input, .el-date-editor.el-input__inner {
    width: 100%;
  }
</style>
