<template>
  <div class="app-container">
    <el-collapse accordion style="margin-bottom: 10px" v-model="activeNames">
      <el-collapse-item name="search">
        <template slot="title">
          <div class="margin-top" style="border-left: solid 2px #419eff;padding-left: 10px;font-size: 18px !important;color: #000;">
            搜索
          </div>
        </template>
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
          <el-popover placement="top-start" width="200" trigger="click" content="手机号码和用户编号，满足其中之一内容即可">
            <el-form-item label="用户编号" prop="userIdList" slot="reference">
              <el-input style="width: 200px" v-model="queryParams.userIdList" placeholder="搜索多个请用英文逗号隔开"
                        clearable
                        @keyup.enter.native="handleQuery"/>
            </el-form-item>
          </el-popover>
          <el-form-item label="会员昵称" prop="nickname">
            <el-input
              style="width: 200px" v-model="queryParams.nickname" placeholder="请输入单个会员昵称进行搜索" clearable
              @keyup.enter.native="handleQuery"/>
          </el-form-item>
          <el-popover placement="top-start" width="200" trigger="click" content="手机号码和用户编号，满足其中之一内容即可">
            <el-form-item label="手机号码" prop="mobile" slot="reference">
              <el-input style="width: 200px" v-model="queryParams.mobile" placeholder="搜索多个请用英文逗号隔开" clearable
                        @keyup.enter.native="handleQuery"/>
            </el-form-item>
          </el-popover>
          <el-form-item label="省" prop="provinceId">
            <el-select style="width: 120px" v-model="queryParams.provinceId" @change="getCityList(queryParams.provinceId)"
                       placeholder="请选择省" @keyup.enter.native="handleQuery" filterable clearable
                       @clear="clearOption(1)">
              <el-option v-for="item in provinceList" :key="item.id" :label="item.name" :value="item.id"/>
            </el-select>
          </el-form-item>
          <el-form-item label="市" prop="cityId">
            <el-select style="width: 120px" v-model="queryParams.cityId" @change="getAreaByPid(queryParams.cityId)"
                       @clear="clearOption(2)" @keyup.enter.native="handleQuery" filterable clearable
                       placeholder="请选择市">
              <el-option v-for="item in cityList" :key="item.id" :label="item.name" :value="item.id"/>
            </el-select>
          </el-form-item>
          <el-form-item label="区" prop="areaId">
            <el-select style="width: 120px" v-model="queryParams.areaId" @keyup.enter.native="handleQuery" filterable
                       clearable placeholder="请选择区">
              <el-option v-for="item in areaList" :key="item.id" :label="item.name" :value="item.id"/>
            </el-select>
          </el-form-item>
          <el-popover placement="top-start" width="200" trigger="click" content="外部标签和小程序标签，同时满足所选内容">
            <el-form-item label="外部标签" prop="wecomTagList" slot="reference">
              <el-select v-model="queryParams.wecomTagList" multiple placeholder="请选择">
                <el-option v-for="item in wecomTagList" :key="item.value" :label="item.label" :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-popover>
          <el-form-item label="仪器" prop="instrumentIdList">
            <el-select v-model="queryParams.instrumentIdList" placeholder="请选择仪器" multiple :style="{ width: '100%' }"
                       clearable>
              <el-option v-for="item in instrumentList" :key="item.id" :label="item.name" :value="item.id"/>
            </el-select>
          </el-form-item>
          <el-popover placement="top-start" width="200" trigger="click" content="外部标签和小程序标签，同时满足所选内容">
            <el-form-item label="小程序标签" label-width="100" prop="miniProgramTagList" slot="reference">
              <el-select v-model="queryParams.miniProgramTagList" multiple placeholder="请选择">
                <el-option v-for="item in miniProgramTagList" :key="item.value" :label="item.label" :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-popover>
          <el-form-item label="模式" prop="modeIdList">
            <el-select v-model="queryParams.modeIdList" placeholder="请选择模式" multiple :style="{ width: '100%' }"
                       clearable>
              <el-option v-for="item in modeList" :key="item.id" :label="item.modeName" :value="item.id"/>
            </el-select>
          </el-form-item>
          <el-form-item label="最新护理时间" prop="updateTimeRange" label-width="150">
            <el-date-picker style="width: 360px" v-model="queryParams.updateTimeRange" type="datetimerange"
                            range-separator="至"
                            start-placeholder="开始日期" value-format="yyyy-MM-dd HH:mm:ss" end-placeholder="结束日期"
                            align="right">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="护理时长范围" prop="nursingTimeRange" label-width="150">
            <el-time-picker is-range v-model="queryParams.nursingTimeRange" range-separator="至"
                            start-placeholder="开始时间"
                            end-placeholder="结束时间" placeholder="请选择护理时长范围" clearable value-format="HH:mm:ss">
            </el-time-picker>
          </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-collapse-item>
    </el-collapse>

    <!-- 批量操作下拉选项   -->
    <div class="margin-top"
         style="border-left: solid 2px #419eff;padding-left: 10px;font-size: 18px;color: #000;margin-bottom: 10px;">批量操作
    </div>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-select v-model="batchOperate.operateValue" placeholder="批量操作" size="mini" clearable>
          <el-option label="批量添加小程序标签" :value="1"></el-option>
          <el-option label="批量删除小程序标签" :value="2"></el-option>
          <el-option label="全量添加小程序标签" :value="3"></el-option>
          <el-option label="全量删除小程序标签" :value="4"></el-option>
          <el-option label="导出批量数据" :value="5"></el-option>
          <el-option label="导出全量数据" :value="6"></el-option><!-- @click="handleExport" -->
        </el-select>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-warning" size="mini" @click="batchOperatePop()">确认</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"/>
    </el-row>

    <el-table v-loading="loading" :data="nursingLogList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="序号" align="center" prop="id"/>
      <el-table-column label="头像" align="center">
        <template slot-scope="scope">
          <el-avatar shape="circle" :size="50" :src="scope.row.headimg"/>
        </template>
      </el-table-column>
      <el-table-column label="会员昵称" align="center" prop="nickname"/>
      <el-table-column label="用户编号" align="center" prop="userId"/>
      <el-table-column label="手机号码" align="center" prop="mobile"/>
      <el-table-column label="仪器" align="center" prop="instrumentName"/>
      <el-table-column label="模式名称" align="center" prop="modeName"/>
      <el-table-column label="在线状态" align="center" prop="online">
        <template slot-scope="scope">
          <span v-show="scope.row.online == 1">在线</span>
          <span v-show="scope.row.online == 2">离线</span>
        </template>
      </el-table-column>
      <el-table-column label="陪伴模式" align="center" prop="accompanyMode"/>
      <el-table-column label="创建时间" align="center" min-width="100" prop="createTime"/>
      <el-table-column label="护理时长" align="center" prop="nursingTime" width="100"/>
      <el-table-column label="挡位1" align="center" prop="gearPositionOne"/>
      <el-table-column label="挡位2" align="center" prop="gearPositionTwo"/>
      <el-table-column label="挡位3" align="center" prop="gearPositionThree"/>
      <el-table-column label="挡位4" align="center" prop="gearPositionFour"/>
      <el-table-column label="能量总值" align="center" prop="energyValue"/>
      <el-table-column label="水分数据1" align="center" prop="waterDataOne"/>
      <el-table-column label="水分数据2" align="center" prop="waterDataTwo"/>
      <el-table-column label="水分数据3" align="center" prop="waterDataThree"/>
      <el-table-column label="总护理天数" min-width="100" align="center" prop="nursingDays"/>
      <el-table-column label="本周护理天数" min-width="100" align="center" prop="nursingDaysWeek"/>
      <el-table-column label="本月护理天数" min-width="100" align="center" prop="nursingDaysMonth"/>
      <el-table-column label="本年护理天数" min-width="100" align="center" prop="nursingDaysYear"/>
      <el-table-column label="最新护理时间" min-width="100" align="center" prop="updateTime"/>
      <el-table-column label="小程序标签" min-width="100" align="center" prop="miniProgramTagListStr"/>
      <el-table-column label="外部标签" align="center" prop="wecomTagListStr"/>
      <el-table-column label="用户注册时间" min-width="100" align="center" prop="userMemberCreateTime"/>
      <el-table-column label="仪器绑定时间" min-width="100" align="center" prop="instrumentBindingTime"/>
    </el-table>

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


    <!-- 小程序标签批量操作   -->
    <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="batchOperate.tagOperateVisible" width="50%"
               :before-close="cancelMiniProgramDialog">
      <el-form ref="miniProgramForm" :model="miniProgramForm" :rules="batchMiniProgramRules" label-width="150px">
        <el-row>
          <el-col :span="100">
            <el-form-item label="小程序标签" prop="tagIdArray" label-width="100px">
              <treeselect v-model="miniProgramForm.tagIdArray" :options="batchOperate.tagTree" :multiple="true"
                          :show-count="true" placeholder="请选择小程序标签" :disable-branch-nodes="true"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancelMiniProgramDialog(false)">重 置</el-button>
        <el-button type="primary" @click="submitBatchOperate">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 导出字段选择弹窗   -->
    <el-dialog :close-on-click-modal="false" title="自定义导出字段" :visible.sync="batchOperate.exportFieldsVisible" width="50%"
               :before-close="cancelExportFieldsDialog">
      <el-form ref="form" label-width="150px">
        <el-form-item label="全部字段" prop="allFields">
          <el-switch v-model="allFields" @click.native="isExportAllFields()"/>
        </el-form-item>
      </el-form>
      <el-form :inline="true" ref="form" :model="exportFieldList" label-width="150px">
        <el-form-item label="会员昵称" prop="nickname">
          <el-switch v-model="exportFieldList.nickname" active-value="nickname" :inactive-value="null"/>
        </el-form-item>
        <el-form-item label="序号" prop="id">
          <el-switch v-model="exportFieldList.id" active-value="id" :inactive-value="null"/>
        </el-form-item>
        <el-form-item label="用户编号 " prop="userId">
          <el-switch v-model="exportFieldList.userId" active-value="userId" :inactive-value="null"/>
        </el-form-item>
        <el-form-item label="手机号 " prop="mobile">
          <el-switch v-model="exportFieldList.mobile" active-value="mobile" :inactive-value="null"/>
        </el-form-item>
        <el-form-item label="总护理天数 " prop="nursingDays">
          <el-switch v-model="exportFieldList.nursingDays" active-value="nursingDays" :inactive-value="null"/>
        </el-form-item>
        <el-form-item label="本月护理天数 " prop="nursingDaysMonth">
          <el-switch v-model="exportFieldList.nursingDaysMonth" active-value="nursingDaysMonth" :inactive-value="null"/>
        </el-form-item>
        <el-form-item label="本周护理天数 " prop="nursingDaysWeek">
          <el-switch v-model="exportFieldList.nursingDaysWeek" active-value="nursingDaysWeek" :inactive-value="null"/>
        </el-form-item>
        <el-form-item label="本年护理天数 " prop="nursingDaysYear">
          <el-switch v-model="exportFieldList.nursingDaysYear" active-value="nursingDaysYear" :inactive-value="null"/>
        </el-form-item>
        <el-form-item label="最新的护理时间 " prop="updateTime">
          <el-switch v-model="exportFieldList.updateTime" active-value="updateTime" :inactive-value="null"/>
        </el-form-item>
        <el-form-item label="外部标签 " prop="wecomTagListStr">
          <el-switch v-model="exportFieldList.wecomTagListStr" active-value="wecomTagListStr" :inactive-value="null"/>
        </el-form-item>
        <el-form-item label="小程序标签 " prop="miniProgramTagListStr">
          <el-switch v-model="exportFieldList.miniProgramTagListStr" active-value="miniProgramTagListStr"
                     :inactive-value="null"/>
        </el-form-item>
        <el-form-item label="仪器绑定时间 " prop="instrumentBindingTime">
          <el-switch v-model="exportFieldList.instrumentBindingTime" active-value="instrumentBindingTime"
                     :inactive-value="null"/>
        </el-form-item>
        <el-form-item label="用户注册时间 " prop="userMemberCreateTime">
          <el-switch v-model="exportFieldList.userMemberCreateTime" active-value="userMemberCreateTime"
                     :inactive-value="null"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancelExportFieldsDialog()">取 消</el-button>
        <el-button type="primary" @click="submitBatchOperate">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {listNursingLog, allAddMiniProgramTag, allDelMiniProgramTag} from "@/api/system/nursingLog";
import {listAllMode, listInstrument} from "@/api/system/instrument";
import {
  batchAddMiniProgramTag, batchDelMiniProgramTag,
  getMiniProgramTags,
  getRegionByPid,
  getWecomTags
} from "@/api/system/member";
import {tagTreeSelect} from "@/api/system/wechatTab";
import Treeselect from "@riophae/vue-treeselect";
import '@riophae/vue-treeselect/dist/vue-treeselect.css'

export default {
  name: "NursingLog",
  components: {Treeselect},
  data() {
    return {
      // 折叠搜索
      activeNames: ['search'],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户护理日志表格数据
      nursingLogList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userIdList: null,
        nickname: null,
        mobile: null,
        // 省市区
        provinceId: null,
        cityId: null,
        areaId: null,
        // 外部标签
        wecomTagList: [],
        // 仪器ID列表
        instrumentIdList: null,
        // 小程序标签
        miniProgramTagList: [],
        // 模式列表
        modeIdList: [],
        // 最新护理时间
        updateTimeRange: null,
        // 护理时长
        nursingTimeRange: null,
      },
      // 查询条件：省市区
      provinceList: null,
      cityList: null,
      areaList: null,
      // 查询条件：外部标签，小程序标签
      wecomTagList: [],
      miniProgramTagList: [],
      // 查询条件：模式列表
      modeList: [],
      // 查询条件：仪器列表
      instrumentList: [],

      // 批量操作值
      batchOperate: {
        operateValue: null,
        tagOperateVisible: false,
        title: null,
        tagTree: [],
        userIdList: [],
        exportFieldsVisible: false,
      },
      miniProgramForm: {
        tagIdArray: [],
      },
      exportFieldsForm: {
        idList: null,
        exportFields: null,
      },
      allFields: false,
      exportFieldList: {
        nickname: null,
        userId: null,
        mobile: null,
        nursingDays: null,
        nursingDaysMonth: null,
        nursingDaysWeek: null,
        nursingDaysYear: null,
        updateTime: null,
        wecomTagListStr: null,
        miniProgramTagListStr: null,
        instrumentBindingTime: null,
        userMemberCreateTime: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        userId: [
          {required: true, message: "用户id不能为空", trigger: "blur"}
        ],
        instrumentId: [
          {required: true, message: "设备id不能为空", trigger: "blur"}
        ],
      },
      batchMiniProgramRules: {
        tagIdArray: [
          {required: true, message: '请选择小程序标签', trigger: 'change'},
        ],
      }
    };
  },
  created() {
    this.getList();
    // 初始化查询条件：仪器列表
    this.queryInstrument();
    // 初始化查询条件：省
    this.getProvinceList();
    // 初始化查询条件：标签
    this.getMiniProgramTagList();
    this.getWecomTagList();
    // 初始化查询条件：模式列表
    this.getModeList();
  },
  methods: {
    /** 查询用户护理日志列表 */
    getList() {
      this.loading = true;
      listNursingLog(this.queryParams).then(response => {
        this.nursingLogList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        userId: null,
        instrumentId: null,
        instrumentName: null,
        online: null,
        modeId: null,
        modeName: null,
        nursingTime: null,
        completionPercentage: null,
        status: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: 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.batchOperate.userIdList = selection.map(item => item.userId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/nursingLog/export', {
        ...this.queryParams
      }, `nursingLog_${new Date().getTime()}.xlsx`)
    },
    /** 批量操作按钮，显示批量操作弹窗 */
    batchOperatePop() {
      if (this.batchOperate.operateValue == null) {
        this.$message({
          message: '请选择要批量操作类型',
          type: 'warning',
        })
        return
      } else {
        /* 批量操作 */
        if (this.batchOperate.operateValue == 1 || this.batchOperate.operateValue == 2 || this.batchOperate.operateValue == 5) {
          if (this.ids.length == 0) {
            this.$message({
              message: '请选择要操作的数据',
              type: 'warning',
            })
            return
          }
          if (this.batchOperate.operateValue == 1) {
            this.batchOperate.title = '批量添加小程序标签';
            // 获取标签树
            this.getTagTree();
            this.batchOperate.tagOperateVisible = true;
          }

          if (this.batchOperate.operateValue == 2) {
            this.batchOperate.title = '批量删除小程序标签';
            // 获取标签树
            this.getTagTree();
            this.batchOperate.tagOperateVisible = true;
          }
          /* 批量操作：导出数据 */
          if (this.batchOperate.operateValue == 5) {
            if (this.ids.length == 0) {
              this.$message({
                message: '请选择要操作的数据',
                type: 'warning',
              })
              return
            }
            this.batchOperate.exportFieldsVisible = true
          }
        } else {
          /* 全量操作 */
          if (this.batchOperate.operateValue == 3) {
            this.batchOperate.title = '全量添加小程序标签';
            // 获取标签树
            this.getTagTree();
            this.batchOperate.tagOperateVisible = true;
          }
          if (this.batchOperate.operateValue == 4) {
            this.batchOperate.title = '全量删除小程序标签';
            // 获取标签树
            this.getTagTree();
            this.batchOperate.tagOperateVisible = true;
          }
          if (this.batchOperate.operateValue == 6) {
            this.batchOperate.exportFieldsVisible = true
          }
        }
      }
    },
    /** 查询小程序标签树 */
    getTagTree() {
      tagTreeSelect({type: 1}).then((response) => {
        this.batchOperate.tagTree = response.data
      })
    },
    // 关闭添加小程序标签窗口
    cancelMiniProgramDialog(isClose) {
      this.$refs.miniProgramForm.clearValidate();
      this.miniProgramForm.tagIdArray = [];
      if (isClose) {
        this.batchOperate.title = null;
        this.batchOperate.tagOperateVisible = false;
      }
    },
    /* 批量操作提交按钮 */
    submitBatchOperate() {
      // 批量添加小程序标签
      if (this.batchOperate.operateValue == 1) {
        this.$refs['miniProgramForm'].validate((valid) => {
          if (valid) {
            batchAddMiniProgramTag(
              this.miniProgramForm.tagIdArray,
              Array.from(new Set(this.batchOperate.userIdList))
            ).then((Response) => {
              this.$modal.msgSuccess('批量添加小程序标签成功');
              this.cancelMiniProgramDialog(true)
              this.getList();
            })
          }
        })
      }
      // 批量删除小程序标签
      if (this.batchOperate.operateValue == 2) {
        this.$refs['miniProgramForm'].validate((valid) => {
          if (valid) {
            batchDelMiniProgramTag(
              this.miniProgramForm.tagIdArray,
              Array.from(new Set(this.batchOperate.userIdList))
            ).then((Response) => {
              this.$modal.msgSuccess('批量删除小程序标签成功')
              this.cancelMiniProgramDialog(true)
              this.getList();
            })
          }
        })
      }
      // 全量添加小程序标签
      if (this.batchOperate.operateValue == 3) {
        this.$refs['miniProgramForm'].validate((valid) => {
          if (valid) {
            allAddMiniProgramTag(
              this.miniProgramForm.tagIdArray, this.queryParams
            ).then((Response) => {
              this.$modal.msgSuccess('全量添加小程序标签成功')
              this.cancelMiniProgramDialog(true)
              this.getList();
            })
          }
        })
      }
      // 全量删除小程序标签
      if (this.batchOperate.operateValue == 4) {
        this.$refs['miniProgramForm'].validate((valid) => {
          if (valid) {
            allDelMiniProgramTag(
              this.miniProgramForm.tagIdArray, this.queryParams
            ).then((Response) => {
              this.$modal.msgSuccess('全量删除小程序标签成功')
              this.cancelMiniProgramDialog(true)
              this.getList();
            })
          }
        })
      }
      // 导出用户数据
      if (this.batchOperate.operateValue == 5) {
        let exportFields = Object.values(this.exportFieldList).filter((val) => val != null)
        if (exportFields.length == 0) {
          this.$modal.msgError('请选择导出字段')
          return
        }
        this.exportFieldsForm.idList = this.ids
        this.exportFieldsForm.exportFields = exportFields
        this.download('/system/nursingLog/batchExport', {
            ...this.exportFieldsForm,
          },
          `护理记录数据_${new Date().getTime()}.xlsx`
        )
        this.cancelExportFieldsDialog();
      }

      if (this.batchOperate.operateValue == 6) {
        let exportFields = Object.values(this.exportFieldList).filter(
          (val) => val != null
        )
        if (exportFields.length == 0) {
          this.$modal.msgError('请选择导出字段')
          return
        }
        this.download('/system/nursingLog/allExport', {
            ...Object.assign({}, this.queryParams, {
              exportFields: exportFields,
            }),
          }, `护理记录数据_${new Date().getTime()}.xlsx`
        )
        this.cancelExportFieldsDialog();
      }
    },

    cancelExportFieldsDialog() {
      this.allFields = false
      this.batchOperate.exportFieldsVisible = false
      this.exportFieldList = {
        nickname: null,
        userId: null,
        mobile: null,
        nursingDays: null,
        nursingDaysMonth: null,
        nursingDaysWeek: null,
        nursingDaysYear: null,
        updateTime: null,
        wecomTagListStr: null,
        miniProgramTagListStr: null,
        instrumentBindingTime: null,
        userMemberCreateTime: null,
      }
    },
    isExportAllFields() {
      if (this.allFields) {
        this.exportFieldList.nickname = 'nickname';
        this.exportFieldList.userId = 'userId';
        this.exportFieldList.mobile = 'mobile';
        this.exportFieldList.nursingDays = 'nursingDays';
        this.exportFieldList.nursingDaysMonth = 'nursingDaysMonth';
        this.exportFieldList.nursingDaysWeek = 'nursingDaysWeek';
        this.exportFieldList.nursingDaysYear = 'nursingDaysYear';
        this.exportFieldList.updateTime = 'updateTime';
        this.exportFieldList.wecomTagListStr = 'wecomTagListStr';
        this.exportFieldList.miniProgramTagListStr = 'miniProgramTagListStr';
        this.exportFieldList.instrumentBindingTime = 'instrumentBindingTime';
        this.exportFieldList.userMemberCreateTime = 'userMemberCreateTime';
      } else {
        this.exportFieldList.nickname = null;
        this.exportFieldList.userId = null;
        this.exportFieldList.mobile = null;
        this.exportFieldList.nursingDays = null;
        this.exportFieldList.nursingDaysMonth = null;
        this.exportFieldList.nursingDaysWeek = null;
        this.exportFieldList.nursingDaysYear = null;
        this.exportFieldList.updateTime = null;
        this.exportFieldList.wecomTagListStr = null;
        this.exportFieldList.miniProgramTagListStr = null;
        this.exportFieldList.instrumentBindingTime = null;
        this.exportFieldList.userMemberCreateTime = null;
      }
    },
    // 查询仪器列表
    queryInstrument() {
      listInstrument({}).then(response => {
        this.instrumentList = response.rows;
      });
    },
    // 查询条件-获取省市区
    getProvinceList() {
      getRegionByPid(0).then((Response) => {
        this.provinceList = Response.data
      })
    },
    getCityList(pid) {
      if (pid == '') {
        return
      }
      this.queryParams.cityId = null
      this.queryParams.areaId = null
      getRegionByPid(pid).then((Response) => {
        this.cityList = Response.data
      })
    },
    getAreaByPid(pid) {
      if (pid == '') {
        return
      }
      this.queryParams.areaId = null
      getRegionByPid(pid).then((Response) => {
        this.areaList = Response.data
      })
    },
    // 查询条件-省市区清空
    clearOption(option) {
      // 省级清空
      if (option == 1) {
        this.queryParams.cityId = null
        this.queryParams.areaId = null
        this.cityList = null
        this.areaList = null
      }
      // 市级清空
      if (option == 2) {
        this.queryParams.areaId = null
        this.areaList = null
      }
    },
    // 获取小程序标签
    getMiniProgramTagList() {
      getMiniProgramTags().then((Response) => {
        this.miniProgramTagList = Response.data
      })
    },
    // 获取外部标签
    getWecomTagList() {
      getWecomTags().then((Response) => {
        this.wecomTagList = Response.data
      })
    },
    // 获取模式列表
    getModeList() {
      listAllMode().then((response) => {
        if (response.code != 200) {
          this.$message.error('模式获取失败')
        }
        this.modeList = response.data
      })
    }
  }
};
</script>
