<template>
  <basic-container>
    <div class="avue-crud">
      <el-row :hidden="!search" style="padding:6px 18px">
        <!-- 查询模块 -->
        <el-form :inline="true" :model="query">
          <el-form-item label="客户名称:">
            <el-input v-model="query.clientName" placeholder="请输入客户名称"></el-input>
          </el-form-item>
          <el-form-item label="客户类型:">
<!--            <el-input v-model="query.typeService" placeholder="请输入客户类型;1 C端  2 B端"></el-input>-->
            <el-select v-model="query.typeService" class="m-2" placeholder="请选择客户类型" >
              <el-option
                v-for="item in clientType"
                :key="item.dictKey"
                :label="item.dictValue"
                :value="item.dictKey"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="地址:">
<!--            <el-input v-model="query.bladeRegionProvinceId" placeholder="请输入省份"></el-input>-->
            <el-cascader :options="optioner"  v-model="query.bladeRegionProvinceId">
              <template #default="{ node, data }">
                <span>{{ data.label }}</span>
                <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
              </template>
            </el-cascader>
          </el-form-item>

<!--          <el-form-item label="市:">-->
<!--            <el-input v-model="query.bladeRegionCityId" placeholder="请输入市"></el-input>-->

<!--          </el-form-item>-->
<!--          <el-form-item label="区/县:">-->
<!--            <el-input v-model="query.bladeRegionAreaId" placeholder="请输入区/县"></el-input>-->
<!--            -->
<!--          </el-form-item>-->
          <el-form-item label="合同开始时间:">
<!--            <el-input v-model="query.contractStartTime" placeholder="请输入合同开始时间"></el-input>-->
            <div class="block">
<!--              <span class="demonstration">With quick options</span>-->
              <el-date-picker
                v-model="dataShi"
                type="daterange"
                unlink-panels
                range-separator="至"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
                :shortcuts="shortcuts"
                :size="'default'"
                format="YYYY/MM/DD"
                value-format="YYYY-MM-DD HH:mm:ss"
              />
            </div>
          </el-form-item>
<!--          <el-form-item label="合同结束时间:">-->
<!--            <el-input v-model="query.contractEntTime" placeholder="请输入合同结束时间"></el-input>-->
<!--          </el-form-item>-->
          <!-- 查询按钮 -->
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="searchChange">搜 索</el-button>
            <el-button icon="el-icon-delete" @click="searchReset()">清 空</el-button>
          </el-form-item>
        </el-form>
      </el-row>
      <el-row>
        <div class="avue-crud__header">
          <!-- 头部左侧按钮模块 -->
          <div class="avue-crud__left">
            <el-button type="primary" icon="el-icon-plus" @click="handleAdd">新 增</el-button>
            <el-button type="danger" icon="el-icon-delete" @click="handleDelete" plain>删 除</el-button>
          </div>
          <!-- 头部右侧按钮模块 -->
          <div class="avue-crud__right">
            <el-button icon="el-icon-refresh" @click="searchChange" circle></el-button>
            <el-button icon="el-icon-search" @click="searchHide" circle></el-button>
          </div>
        </div>
      </el-row>
      <el-row>
        <!-- 列表模块 -->
        <el-table ref="table" v-loading="loading"
                  @selection-change="selectionChange"
                  :data="data"
                  :height="height"
                  tooltip-effect="dark"
                  style="width: 100%"
                  :border="option.border">
          <el-table-column type="selection" v-if="option.selection" width="55" align="center"></el-table-column>
          <el-table-column type="expand" v-if="option.expand" align="center"></el-table-column>
          <el-table-column v-if="option.index" label="序号" type="index" width="60" align="center">
          </el-table-column>
          <template v-for="(item,index) in option.column">
            <!-- table字段 -->
            <el-table-column v-if="item.hide!==true"
                             :prop="item.prop"
                             :label="item.label"
                             :width="item.width"
                             show-overflow-tooltip
                             :key="index" align="center">
<!--              <template slot-scope="{item}" v-if="item.prop === 'fileName'">-->
                <template #default="{row,$index}" v-if="item.prop === 'fileName'">
                    <el-link  target="_blank" @click="downloadLink(row)">{{row.fileName}}</el-link>
                </template>
              <!--                <el-link href="https://element.eleme.io" target="_blank" v-if="item.prop === 'fileName'">{{scope}}</el-link>-->
              <template #default="{row,$index}" v-if="item.prop === 'cargoControl'" >
                <el-switch
                           v-model="row.cargoControl"
                           active-text="开"
                           inactive-text="关"
                           @click="makeCargo(row)"
                >
                </el-switch>
              </template>
            </el-table-column>
          </template>
          <!-- 操作栏模块 -->
          <el-table-column prop="menu" label="操作" :width="300" align="center">
            <template #="{row}">
              <el-button type="primary" text icon="el-icon-view" @click="handleView(row)">查看</el-button>
              <el-button type="primary" text icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>
              <el-button type="primary" text icon="el-icon-delete" @click="rowDel(row)">删除</el-button>
              <el-button type="primary" text icon="el-icon-setting" @click="handleHistory(row)">合同历史记录</el-button>
              <el-button type="primary" text icon="el-icon-setting" @click="handleEntrepot(row)">服务仓</el-button>
<!--              <el-button type="primary" text icon="el-icon-setting" @click="handleDrawer(row)">仓库</el-button>-->
            </template>
          </el-table-column>
        </el-table>
      </el-row>
      <el-row>
        <div class="avue-crud__pagination" style="width:100%">
          <!-- 分页模块 -->
          <el-pagination align="right"
                         background
                         @size-change="sizeChange"
                         @current-change="currentChange"
                         :current-page="page.currentPage"
                         :page-sizes="[10, 20, 30, 40, 50, 100]"
                         :page-size="page.pageSize"
                         layout="total, sizes, prev, pager, next, jumper"
                         :total="page.total">
          </el-pagination>
        </div>
      </el-row>
      <!-- 表单模块 -->
      <el-dialog :title="title"
                 v-model="box"
                 width="35%"
                 :before-close="beforeClose"
                 append-to-body>
        <el-form :disabled="view" ref="form" :model="form" :rules="rules" label-width="120px">
          <!-- 表单字段 -->
          <el-form-item label="客户名称" prop="clientName">
            <el-input v-model="form.clientName" placeholder="请输入客户名称"  style="width: 100%"/>
          </el-form-item>
          <el-form-item label="客户类型" prop="typeService">
<!--            <el-input v-model="form.typeService" placeholder="请输入客户类型"/>-->
<!--            <el-input v-model="form.typeService" placeholder="请输入客户类型;1 C端  2 B端"/>-->
            <el-select v-model="form.typeService" class="m-2" placeholder="请选择客户类型" style="width: 100%">
              <el-option
                v-for="item in clientType"
                :key="item.dictKey"
                :label="item.dictValue"
                :value="item.dictKey"

              />
            </el-select>
          </el-form-item>
          <el-form-item label="地址" prop="bladeRegionProvinceId" >
<!--            <el-input v-model="form.bladeRegionProvinceId" placeholder="请输入省份"/>-->
            <el-cascader :options="optioner" style="width: 100%" v-model="form.bladeRegionProvinceId">
              <template #default="{ node, data }">
                <span>{{ data.label }}</span>
                <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
              </template>
            </el-cascader>
          </el-form-item>
<!--          <el-form-item label="市" prop="bladeRegionCityId">-->
<!--            <el-input v-model="form.bladeRegionCityId" placeholder="请输入市"/>-->
<!--          </el-form-item>-->
<!--          <el-form-item label="区/县" prop="bladeRegionAreaId">-->
<!--            <el-input v-model="form.bladeRegionAreaId" placeholder="请输入区/县"/>-->
<!--          </el-form-item>-->
          <el-form-item label="合同附件" prop="leaseAccessories" style="width: 100%">
<!--            <el-input v-model="form.leaseAccessories" placeholder="请输入合同附件"/>-->
            <el-upload
              v-model:file-list="fileList"
              class="upload-demo"
              :action="action"
              :headers="headers"
              multiple
              :on-preview="handlePreview"
              :on-success="(response, file, fileList) => {uploadSuccess(fileList)}"
              :on-remove="handleRemove"
              :before-remove="beforeRemove"
              :limit="3"
              :on-exceed="handleExceed"
            >
              <el-button >上传</el-button>
              <template #tip>
                <div class="el-upload__tip">
                  大小不超过500KB的jpg/png文件。
                </div>
              </template>
            </el-upload>
            <el-image-viewer
              v-if="showImgViewer"
              :url-list="imgPreviewUrl"
              @close="handleCo"
              :z-index="300"
              fit="cover"
            />
          </el-form-item>
          <el-form-item label="合同开始时间" prop="contractStartTime" label-width="120px">
<!--            <el-input v-model="form.contractStartTime" placeholder="请输入合同开始时间"/>-->
            <div class="demo-date-picker" style="width: 60%">
              <div class="block">
<!--                <span class="demonstration">Default</span>-->
                <el-date-picker
                  v-model="form.contractStartTime"
                  type="date"
                  placeholder="选择时间"
                  format="YYYY/MM/DD"
                  value-format="YYYY-MM-DD HH:mm:ss"
                />
              </div>
            </div>
          </el-form-item>

          <el-form-item label="合同结束时间" prop="contractEntTime" label-width="120px">
<!--            <el-input v-model="form.contractEntTime" placeholder="请输入合同结束时间"/>-->
            <div class="demo-date-picker">
              <div class="block">
                <!--                <span class="demonstration">Default</span>-->
                <el-date-picker
                  v-model="form.contractEntTime"
                  type="date"
                  placeholder="选择时间"
                  format="YYYY/MM/DD"
                  value-format="YYYY-MM-DD HH:mm:ss"
                />
              </div>
            </div>
          </el-form-item>
        </el-form>
        <!-- 表单按钮 -->
        <template #footer>
          <span v-if="!view" class="dialog-footer">
            <el-button type="primary" icon="el-icon-circle-check" @click="handleSubmit('form')">提 交</el-button>
            <el-button icon="el-icon-circle-close" @click="box = false">取 消</el-button>
          </span>
        </template>
      </el-dialog>
      <el-drawer
        title="子表操作"
        append-to-body
        size="60%"
        v-model="drawer"
        :direction="direction"
        :before-close="handleDrawerClose">
        <BasicShopSub :mainId="basicClientId"></BasicShopSub>
      </el-drawer>
<!--      <el-drawer-->
<!--        title="历史记录"-->
<!--        append-to-body-->
<!--        size="60%"-->
<!--        v-model="drawer"-->
<!--        :direction="direction"-->
<!--        :before-close="handleDrawerClose">-->
<!--        <BasicShopSub :mainId="basicClientId"></BasicShopSub>-->
<!--      </el-drawer>-->
    </div>
  </basic-container>
</template>

<script >
import {getList, getDetail, add, update, updateCargoControl} from "@/api/basicdata/basicClient";
import option from "@/option/basicdata/basicClient";
import {mapGetters} from "vuex";
import BasicShopSub from "@/views/basicdata/brand/basicShopSub.vue";
import { getDictionaryBiz } from '@/api/system/dict'
import { getSelect,getLazyTree,getLazyList,getLazyTreeAll } from '@/api/base/region';
import { getToken } from '@/utils/auth';
import globalc from '@/api/basicdata/globalc';


export default {
  components:{
    BasicShopSub,

  },
  data () {
    return {
      height: 0,
      showImgViewer: false,
      imgPreviewUrl: [] ,// 当前要放大的图片存放位置
      fileList: [],

      // 主键
      basicClientId: '',
      // fileList:[], // 上传数据
      // 弹框标题
      title: '',
      // 是否展示弹框
      box: false,
      // 是否展示抽屉
      drawer: false,
      // 抽屉方向
      direction: 'rtl',
      // 是否显示查询
      search: true,
      // 加载中
      loading: true,
      // 是否为查看模式
      view: false,
      // 查询信息
      query: {},
      //查询时间
      dataShi:'',
      // 分页信息
      page: {
        currentPage: 1,
        pageSize: 10,
        total: 40
      },

      // 表单数据
      form: {
        contractStartTime:'',
        contractEntTime:'',
      },
      // 选择行
      selectionList: [],
      testForm: { },
      // 表单配置
      option: option,
      // 表单列表
      data: [],
      clientType:[],
      optioner:[],
      shortcuts : [
        {
          text: '上周',
          value: () => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
            return [start, end]
          },
        },
        {
          text: '上个月',
          value: () => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            return [start, end]
          },
        },
        {
          text: '最近3个月',
          value: () => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
            return [start, end]
          },
        },
      ],
      rules: {
        clientName: [
          { required: true, message: '请输入客户名称', trigger: 'blur' },
          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        typeService: [
          { required: true, message: '请选择客户类型', trigger: 'change' }
        ],
        contractEntTime : [
          { type: 'date', required: true, message: '请选择合同结束时间', trigger: 'change' }
        ],
        contractStartTime: [
          { type: 'date', required: true, message: '请选择合同开始时间', trigger: 'change' }
        ],
      bladeRegionProvinceId: [
          { required: true, message: '请选择地址', trigger: 'change' }
        ],
        leaseAccessories: [
          { required: true, message: '请上传合同文件', trigger: 'blur' }
        ]
      },
      bianji: false,
    }
  },
  created() {

  },
  mounted () {
    this.init();
    getLazyTreeAll().then(res => {
      if(res.data.success){
        this.optioner = res.data.data;
        this.onLoad(this.page);
      }
    })
  },
  computed: {
    ...mapGetters(["permission"]),
    ids () {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    headers() {
      return {
        "Blade-Auth":'Bearer ' + getToken()
      }
    },
    action() {
      return '/api/logpm-basicdata/common/uploadFile'
      // return '/api/blade-resource/oss/endpoint/put-file-attach'
    }
  },
  methods: {
    //打开文件
    downloadLink(row){
      console.log(">>>>>",row);
    },
    //控制控货
    makeCargo(row){
      console.log("控货操作！！",row);
      let r = {
        id : row.id,
        cargoControl: row.cargoControl
      }
      this.$confirm(`确定要修改${row.clientName}的控货状态吗？`, {
        type: "warning",
        //beforeClose 阻止关闭弹窗
        beforeClose: async (action, instance, done) => {
          //下面这行代码就是弹出的确认删除和取消删除
          if (action === "confirm") {
            // 调取接口
            updateCargoControl(r).then(res => {
              console.log(res);
              if(res.statusText == 'OK' ){
                this.onLoad(this.page);
                this.$message({
                  type: "success",
                  message: "操作成功!"
                });
                done();
              }else{
                this.$message({
                  type: "warning",
                  message: "操作失败!"
                });
              }

            });
          }else {
            //点击其他地方时就相当于点击了false
            //done 关闭窗口
            done();
          }
        }
      });





    },
    uploadSuccess(fileList) {
      console.log("123123123",fileList);
      // this.form.fileName =
      // this.$set(row, 'imageCos', fileList);
      if(this.title == '编辑'){
        this.bianji = true;
      }
    },
    handleRemove(file) {
      console.log('3333333',file);
      let id1 = this.fileList.findIndex(item => {
        if (item.id == file.url) {
          return true
        }
      })
      this.fileList.splice(id1, 1);
      console.log("fileList",this.fileList);
    },
    handleCo(file, fileList) {
      // console.log('3333333',file, fileList);
      this.showImgViewer = false
    },
    handlePreview(file) {
      console.log("111111",file);
      this.imgPreviewUrl[0] = file.response.data.link;
      // this.imgPreviewUrl[0] = file.url;
      // this.imgPreviewUrl[0] = this.$api + file.response.data.id
      this.showImgViewer = true;

      console.log("-=-=sc上传",this.fileList);

    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${ file.name }？`);
    },
   async init() {
      //字典
      getDictionaryBiz('client_type').then(res => {
        // console.log("字典》》》",res);
        this.clientType = res.data.data;
      });
     // console.log("globalc.optioner===",globalc.optioner);
     // let optioner = JSON.parse(localStorage.getItem('optioner'));
     // // console.log("-=-=-=-=",optioner);
     //  if(optioner.length > 0){
     //    this.optioner = optioner
     //    console.log("打印》》》",this.optioner);
     //  }else{
     //     globalc.useGetGlobalProperties().then(res =>{
     //       this.optioner = res;
     //       console.log("打印》》》",this.optioner);
     //       localStorage.setItem("optioner",JSON.stringify(globalc.optioner))
     //    });
     //  }



      // console.log('市111', this.optioner);
      this.height = this.setPx(document.body.clientHeight - 340);
    },
    searchHide () {
      this.search = !this.search;
    },
    searchChange () {
      this.onLoad(this.page);
    },
    searchReset () {
      this.query = {};
      this.dataShi = '';
      this.page.currentPage = 1;
      this.onLoad(this.page);
    },
    handleSubmit (from) {

      console.log("上传的集合。。",JSON.parse(JSON.stringify(this.fileList)) );
      if(this.title == '编辑' && this.bianji == false  ){
        console.log("编辑1111");
        if(this.fileList.length > 0){
          let li = [];
          this.fileList.forEach(it => {
            li.push( it.url);

          })
          this.form.leaseAccessories  = li.length > 0 ? li.join(",") : null ;
        }else{
          return this.$message.warning('请上传文件！');
        }
      }else{
        if(this.fileList.length > 0){
          let li = [];
          this.fileList.forEach(it => {
            li.push( it.response.data.link);
            this.form.fileName = it.response.data.originalName;
          })
          this.form.leaseAccessories  = li.length > 0 ? li.join(",") : null ;
        }else{
          return this.$message.warning('请上传文件！');
        }
      }

      if (!this.form.id) {

        console.log("提交的数据：",this.form);
        this.$refs[from].validate((valid) => {
          if (valid) {
            this.form.typeService = !!this.form.typeService ? parseInt(this.form.typeService) : undefined;
            this.form.bladeRegionCityId = this.form.bladeRegionProvinceId[1];
            this.form.bladeRegionAreaId = this.form.bladeRegionProvinceId[2];
            this.form.bladeRegionProvinceId = this.form.bladeRegionProvinceId[0];
            add(this.form).then(() => {
              this.box = false;
              this.onLoad(this.page);
              this.$message({
                type: "success",
                message: "操作成功!"
              });
            });
          } else {
            console.log('error submit!!');
            return false;
          }
        });

      } else {
        console.log("提交的数据：",this.form);
        this.$refs[from].validate((valid) => {
          if (valid) {
            this.form.typeService = !!this.form.typeService ? parseInt(this.form.typeService) : undefined;
            this.form.bladeRegionCityId = this.form.bladeRegionProvinceId[1];
            this.form.bladeRegionAreaId = this.form.bladeRegionProvinceId[2];
            this.form.bladeRegionProvinceId = this.form.bladeRegionProvinceId[0];
            update(this.form).then(() => {
              this.box = false;
              this.onLoad(this.page);
              this.$message({
                type: "success",
                message: "操作成功!"
              });
            })
          } else {
            console.log('error submit!!');
            return false;
          }
        });



      }
    },
    handleAdd () {
      this.title = '新增'
      this.form = {}
      this.fileList = [];
      this.box = true
    },
    handleEdit (row) {
      this.title = '编辑';
      this.fileList = [];
      this.box = true
      getDetail(row.id).then(res => {
        res.data.data.typeService = res.data.data.typeService.toString();
        console.log(res.data.data);
        this.form = res.data.data;
        console.log( this.form);
        let a= [];
        if(!!this.form.bladeRegionProvinceId){
          a.push(res.data.data.bladeRegionProvinceId);
          a.push(res.data.data.bladeRegionCityId);
          a.push(res.data.data.bladeRegionAreaId);
        }
        this.form.bladeRegionProvinceId = a;
        if(!!this.form.leaseAccessories){
          if(this.form.leaseAccessories.includes(",")){
            let le = [];
            let d =    this.form.leaseAccessories.splice(",");
            d.forEach( i => {
              let q ={
                name : "",
                url : i
              }
              le.push(q);
            })
            this.fileList = le;
          }else{
            this.fileList =[{name : "",
              url : this.form.leaseAccessories}];
          }
        }

      });
    },
    handleView (row) {
      this.title = '查看'
      this.view = true;
      this.box = true;
      this.fileList =[];
      getDetail(row.id).then(res => {
        res.data.data.typeService = res.data.data.typeService.toString();
        console.log(">>>>>",res.data.data);
        this.form = res.data.data;
        let a= [];
        if(!!this.form.bladeRegionProvinceId){
          a.push(res.data.data.bladeRegionProvinceId);
          a.push(res.data.data.bladeRegionCityId);
          a.push(res.data.data.bladeRegionAreaId);
        }
        this.form.bladeRegionProvinceId = a;
        if(!!this.form.leaseAccessories){
          if(this.form.leaseAccessories.includes(",")){
            let le = [];
            let d =    this.form.leaseAccessories.splice(",");
            d.forEach( i => {
              let q ={
                name : "",
                url : i
              }
              le.push(q);
            })
            this.fileList = le;
          }else{
            this.fileList =[{name : "",
              url : this.form.leaseAccessories}];
          }
        }

      });
    },
    handleDrawer(row) {
      this.basicClientId = row.id;
      this.drawer = true;
    },
    //历史记录
    handleHistory(row) {
      // this.basicClientId = row.id;
      // this.drawer = true;
      // this.$router.push('/basicdata/brand/basicHistoricalContract?id='+row.id+";name="+row.clientName);

      this.$router.push({
        path:'/basicdata/brand/basicHistoricalContract',
        query:{
          id: row.id,
          name: "历史记录 - "+row.clientName
        }
      });

    },
    //仓库
    handleEntrepot(row) {
      // this.basicClientId = row.id;
      // this.drawer = true;
      // this.$router.push('/basicdata/brand/basicHistoricalContract?id='+row.id+";name="+row.clientName);

      this.$router.push({
        path:'/basicdata/brand/basicStorageServices',
        query:{
          id: row.id,
          name: "服务仓 - "+row.clientName,
          type: '2'
        }
      });

    },
    handleDrawerClose(){
      this.basicClientId = '';
      this.drawer = false;
    },
    handleDelete () {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return remove(this.ids);
        })
        .then(() => {
          this.selectionClear();
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        });
    },
    rowDel (row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        });
    },
    beforeClose (done) {
      done()
      this.form = {};
      this.view = false;
    },
    selectionChange (list) {
      this.selectionList = list;
    },
    selectionClear () {
      this.selectionList = [];
      this.$refs.table.clearSelection();
    },
    currentChange (currentPage) {
      this.page.currentPage = currentPage;
      this.onLoad(this.page);
    },
    sizeChange (pageSize) {
      this.page.pageSize = pageSize;
      this.onLoad(this.page);
    },
    onLoad (page, params = {}) {
      this.loading = true;
      console.log( "-=-=",this.query);
      if(this.dataShi.length > 0){
        console.log( "-=-=",this.dataShi);
        this.query.contractStartTime  = this.dataShi[0];
        this.query.contractEntTime =  this.dataShi[1];
      }
      if(!!this.query.bladeRegionProvinceId){
        this.query.bladeRegionCityId = this.query.bladeRegionProvinceId[1];
        this.query.bladeRegionAreaId = this.query.bladeRegionProvinceId[2];
        this.query.bladeRegionProvinceId = this.query.bladeRegionProvinceId[0];
      }
      getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
        const data = res.data.data;
        // console.log(data);
        this.clientType.forEach(it =>{
          data.records.forEach(i =>{
            if(parseInt( it.dictKey ) == parseInt(i.typeService)){
              i.typeService = it.dictValue
            }
            if(i.typeService == '-1'){
              i.typeService = '无'
            }
          })
        })
        let dz ="";
        data.records.forEach(it =>{
          let arrsheng = this.optioner.filter((i) => {
            return it.bladeRegionProvinceId == i.value;
          });
          // console.log("========",JSON.parse(JSON.stringify(arrsheng)) );
          let arrshi = arrsheng[0].children.filter((i) => {
            return it.bladeRegionCityId == i.value;
          });
          // console.log("========",JSON.parse(JSON.stringify(arrsheng)) );
          let arrqu = arrshi[0].children.filter((i) => {
            return it.bladeRegionAreaId == i.value;
          });
          // console.log("========",JSON.parse(JSON.stringify(arrsheng)) );
          dz = arrsheng[0].label+"/"+arrshi[0].label+"/"+arrqu[0].label;
          it.bladeRegionProvinceId = dz;
        })

        // console.log("dzdz",dz);
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
        this.selectionClear();
      });
    }
  }
};
</script>

