<template>
  <basic-container>
    <div class="avue-crud">
      <el-row   v-if="!search" style="padding:6px 18px">
        <!-- 查询模块 -->
        <el-form :inline="true" :model="query">
          <el-form-item label="始发地地址:">
<!--            <el-input v-model="query.province" placeholder="请输入省"></el-input>-->
            <el-cascader :options="optioner" v-model="query.province"  :props="{ checkStrictly: true }" popper-class='ca'>
              <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.province" placeholder="请输入省"></el-input>-->
            <el-cascader :options="optioner" v-model="query.provinceEnd"  :props="{ checkStrictly: true }" popper-class='ca'>
              <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.city" placeholder="请输入市"></el-input>-->
<!--          </el-form-item>-->
<!--          <el-form-item label="区/县:">-->
<!--            <el-input v-model="query.district" placeholder="请输入区/县"></el-input>-->
<!--          </el-form-item>-->
          <el-form-item label="品牌:">
            <el-input v-model="query.brand" placeholder="请输入品牌"></el-input>
          </el-form-item>
          <el-form-item label="费用类型:">
<!--            <el-input v-model="query.freightMark" placeholder="请输入费用标识"></el-input>-->
            <el-select v-model="query.freightMark" 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.goalGranary" placeholder="请输入末端仓"></el-input>
          </el-form-item>
<!--          <el-form-item label="状态:">-->
<!--            <el-input v-model="query.condition" 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>
        <!-- 列表模块 -->
        <tablecmt
          :columnList="columnList"
          :tableData="data"
          :loading="loading"
          @inputTxt="inputsc"
          @timeCheck="timesc"
          @btnCheck="btnsc"
          @selectCheck="selectsc"
          @selection="selectionChange"
        >
          <template #default="slotProps">
            
            <el-text type="primary" text icon="el-icon-view" @click="handleView(slotProps.scope.row)">查看</el-text>
              <el-text type="primary" text icon="el-icon-edit" @click="handleEdit(slotProps.scope.row)">编辑</el-text>
              <el-text type="primary" text icon="el-icon-delete" @click="rowDel(slotProps.scope.row)">删除</el-text>
              <el-text type="primary" text icon="el-icon-setting" @click="handleDrawer(slotProps.scope.row)">费用明细</el-text>
          </template>
        </tablecmt>
        
      </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="[30, 50,80, 120]"
                         :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" label-width="120px" :rules="rules">
          <!-- 表单字段 -->
          <el-form-item label="始发仓地址" prop="province">
<!--            <el-input v-model="form.province" placeholder="请输入省"/>-->
            <el-cascader :options="optioner" v-model="form.province" style="width: 100%;" :props="{ checkStrictly: true }" popper-class='ca'>
              <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="goalGranary">
            <!--            <el-input v-model="form.goalGranary" placeholder="请输入末端仓"/>-->
            <el-select style="width: 100%"
                       v-model="form.beginGranary"
                       filterable
                       remote
                       reserve-keyword
                       placeholder="请输入始发仓"
                       :remote-method="remoteMethodBin"
                       :loading="loading"
            >
              <el-option
                  v-for="item in optionser"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
              />
            </el-select>



          </el-form-item>
          <el-form-item label="目的仓地址" prop="province">
<!--            <el-input v-model="form.province" placeholder="请输入省"/>-->
            <el-cascader :options="optioner" v-model="form.provinceEnd" style="width: 100%;" :props="{ checkStrictly: true }"  popper-class='ca'>
              <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="goalGranary">
            <!--            <el-input v-model="form.goalGranary" placeholder="请输入末端仓"/>-->
            <el-select style="width: 100%"
                       v-model="form.goalGranary"
                       filterable
                       remote
                       reserve-keyword
                       placeholder="请输入目的仓"
                       :remote-method="remoteMethodBin"
                       :loading="loading"
            >
              <el-option
                  v-for="item in optionser"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
              />
            </el-select>



          </el-form-item>
<!--          <el-form-item label="市" prop="city">-->
<!--            <el-input v-model="form.city" placeholder="请输入市"/>-->
<!--          </el-form-item>-->
<!--          <el-form-item label="区/县" prop="district">-->
<!--            <el-input v-model="form.district" placeholder="请输入区/县"/>-->
<!--          </el-form-item>-->
          <el-form-item label="品类" prop="brand">
<!--            <el-input v-model="form.brand" placeholder="请输入品牌"/>-->
            <el-select style="width: 100%"
              v-model="form.brand"
              filterable
              remote
              reserve-keyword
              placeholder="品类"
              :remote-method="remoteMethod"
              :loading="loading"
            >
              <el-option
                v-for="item in optionsr"
                :key="item.id"
                :label="item.brandName"
                :value="item.id"
              />
            </el-select>


          </el-form-item>
          <el-form-item label="费用类型" prop="freightMark">
<!--            <el-input v-model="form.freightMark" placeholder="请输入费用标识;1 运费 2 送货费用 3提货费用 4仓库管理费用 5 仓储费用 6装卸费用 7 其他费用 8仓储时间端费用"/>-->
<!--            <el-select v-model="form.freightMark" 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-checkbox-group v-model="form.freightMark" @change="handleCheckedCitiesChange">
              <el-checkbox
                v-for="(item,index) in clientType"
                :key="index"
                :label="item.dictValue"
                :value="item.dictKey"
                 >{{item.dictValue}}
                <el-input type="number"   v-model="item.remark" placeholder="请输入费用" :disabled = !item.pitch  @change="textbox($event,index)"/>
              </el-checkbox>

            </el-checkbox-group>

          </el-form-item>
<!--          <el-form-item label="费用" prop="cost">-->
<!--&lt;!&ndash;            <el-input v-model="form.cost" placeholder="请输入费用1111" v-for="(item,index)  in costList" :key="index"/>&ndash;&gt;-->
<!--          </el-form-item>-->
<!--          <el-form-item label="仓储时间端" prop="warehousingTimeStatus">-->
<!--&lt;!&ndash;            <el-input v-model="form.warehousingTimeStatus" placeholder="请输入仓储时间端状态;1 0-30天  2 0-60天 3 60天以上"/>&ndash;&gt;-->
<!--&lt;!&ndash;            <el-select v-model="form.warehousingTimeStatus" class="m-2" placeholder="请输入仓储时间端状态" >&ndash;&gt;-->
<!--&lt;!&ndash;              <el-option&ndash;&gt;-->
<!--&lt;!&ndash;                v-for="item in wareType"&ndash;&gt;-->
<!--&lt;!&ndash;                :key="item.dictKey"&ndash;&gt;-->
<!--&lt;!&ndash;                :label="item.dictValue"&ndash;&gt;-->
<!--&lt;!&ndash;                :value="item.dictKey"&ndash;&gt;-->
<!--&lt;!&ndash;              />&ndash;&gt;-->
<!--&lt;!&ndash;            </el-select>&ndash;&gt;-->
<!--            <el-checkbox-group v-model="form.warehousingTimeStatus" @change="handleCheckedCities">-->
<!--              <el-checkbox-->
<!--                v-for="(item,index) in wareType"-->
<!--                :key="item.dictKey"-->
<!--                :label="item.dictValue"-->
<!--                :value="item.dictKey"-->
<!--              >{{item.dictValue}}-->
<!--                 <el-input type="number" v-model="item.remark" placeholder="请输入仓储时间端费用" :disabled = !item.pitch  @change="textWarebox($event,index)"/>-->
<!--              </el-checkbox>-->
<!--            </el-checkbox-group>-->
<!--          </el-form-item>-->
<!--          <el-form-item label="仓储时间端费用" prop="warehousingTimeCharge">-->
<!--            <el-input type="number" v-model="form.warehousingTimeCharge" placeholder="请输入仓储时间端费用"/>-->
<!--          </el-form-item>-->
<!--          <el-form-item label="标识" prop="identification">-->
<!--            <el-input v-model="form.identification" placeholder="请输入标识"/>-->
<!--          </el-form-item>-->
<!--          <el-form-item label="状态" prop="condition">-->
<!--            <el-input v-model="form.condition" placeholder="请输入状态"/>-->
<!--          </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="40%"
        v-model="drawer"
        :direction="direction"
        :before-close="handleDrawerClose">
        <basicdata-cost-correlation :mainId="costCorrelationId"></basicdata-cost-correlation>
      </el-drawer>
    </div>
  </basic-container>
</template>

<script>
import { getList, getDetail, add, update, remove } from "@/api/basicdata/basicZonePrice";
import { getListBinName} from "@/api/basicdata/basicdataWarehouse";
import {getListName} from "@/api/basicdata/basicBrand";
import option from "@/option/basicdata/basicZonePrice";
import { mapGetters } from "vuex";
import { getLazyTreeAll } from '@/api/base/region';
import { getDictionaryBiz } from '@/api/system/dict';
import BasicdataCostCorrelation from '@/views/basicdata/brand/basicdataCostCorrelation.vue'

export default {
  components:{
    BasicdataCostCorrelation
  },
  data () {
    return {
      columnList: [
        {
          prop: '',
          label: '序号',
          type: 0,
          values: '',
          width: 55,
          checkarr: [],
          fixed: true,
        },
        {
          prop: 'brandName',
          label: '品类',
          type: 2,
          values: '',
          width: '200',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'beginName',
          label: '始发仓',
          type: 2,
          values: '',
          width: '200',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'province',
          label: '始发仓地址',
          type: 2,
          values: '',
          width: '200',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'endName',
          label: '末端仓',
          type: 2,
          values: '',
          width: '',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'provinceEnd',
          label: '末端仓地址',
          type: 2,
          values: '',
          width: '',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'createTime',
          label: '创建时间',
          type: 2,
          values: '',
          width: '',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: '',
          label: '操作',
          type: 6,
          values: '',
          width: '300',
          checkarr: [],
          fixed: 'right',
          hide: true,
        },
      ],
      optionProps:{
        value: 'id',
        label: 'cName',
        children: 'childrenList',    //子元素字段名
        emitPath : false,
        checkStrictly:true,
        expandTrigger: 'hover'    //设置鼠标悬浮展开，如果点击展开的话，会出现点击父节点后选择器直接关闭，不能选择子节点了
      },
      cascaderKey : 1,//防止搜索选项清空数据后出现报错,在加载级联选择器数据的时候+1
      height: 0,
      // 弹框标题
      title: '',
      costCorrelationId: '',
      // 是否展示弹框
      box: false,
      // 是否展示抽屉
      drawer: false,
      // 抽屉方向
      direction: 'rtl',
      // 是否显示查询
      search: true,
      // 加载中
      loading: true,
      // 是否为查看模式
      view: false,
      // 查询信息
      query: {},
      clientType:[], //字典
      wareType:[], //字典
      costList:[], //字典
      costListName:[], //字典
      costWraeList:[], //字典
      costWraeListName:[], //字典
      // 分页信息
      page: {
        currentPage: 1,
        pageSize: 30,
        total: 40
      },
      // 表单数据
      form: {},
      pan: false,
      // 选择行
      selectionList: [],
      // 表单配置
      option: option,
      // 表单列表
      data: [],
      optioner:[],
      optionsr:[],
      optionser:[],
      rules: {
        province: [
          { required: true, message: '请选择地址', trigger: 'blur' },
          // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        brand: [
          { required: true, message: '请选择品牌', trigger: 'change' }
        ],
        freightMark : [
          { required: true, message: '请选择费用类型', trigger: 'blur' }
        ],
        cost: [
          { required: true, message: '请输入费用', trigger: 'blur' }
        ],
        warehousingTimeStatus: [
          { required: true, message: '请选择时间段', trigger: 'change' }
        ],
        warehousingTimeCharge: [
          { required: true, message: '请选择时间段费用', trigger: 'blur' }
        ],
        goalGranary: [
          { required: true, message: '请选择末端仓', trigger: 'blur' }
        ],
      },
    }
  },
  watch: {
    'form.province'() {
      if (this.$refs.refHandle) {
        this.$refs.refHandle.dropDownVisible = false; //监听值发生变化就关闭它
      }
    }
  },
  created() {
     getLazyTreeAll().then( res => {
      if(res.data.success){
        console.log("this.optioner>>>>>>>>>>>>>>");
        this.optioner = res.data.data;
        this.onLoad(this.page);
      }
    })
  },
  mounted () {
    this.init();

  },
  computed: {
    ...mapGetters(["permission"]),
    ids () {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    }
  },
  methods: {
    //关闭浮层
    hideCascaderInp(){

      this.$refs.cascaderRef.value.togglePopperVisible(false)

    },
    handleDrawerClose(){
      this.costCorrelationId = '';
      this.drawer = false;
    },
    handleDrawer(row) {
      this.costCorrelationId = row.id;
      this.drawer = true;
    },
    textWarebox(e,index) {
      console.log(e,index)
      this.costWraeList[index] = e;
    },
    textbox(e,index) {
      console.log(e,index)
      this.costList[index] = e;
    },
    handleCheckedCities(value) {
      console.log(value);
      if(value.length < 1){
        this.costWraeList = [];
      }
        this.wareType.forEach(i =>{
          if(value.includes(i.dictValue)){
            // console.log(i);
            i.pitch = true;
            // this.$set(i,'pitch',false);
            this.costWraeListName = value;
          }else{
            i.pitch = false;
            this.costWraeList[i] = null;
            i.remark = null;
          }
        });
      // let checkedCount = value.length;
      // this.checkAll = checkedCount === this.cities.length;
      // this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
    },
    handleCheckedCitiesChange(value) {
      // console.log(value);
      if(value.length < 1){
        this.costList = [];
        this.costListName = [];
      }
        this.clientType.forEach(i =>{
          if(value.includes(i.dictValue)){
            // console.log(i);
            i.pitch = true;
            this.costListName = value;
            // console.log(this.costListName);
            // this.$set(i,'pitch',false);
          }else{
            i.pitch = false;
            this.costList[i] = null;
            i.remark = null;
          }
        });
      // let checkedCount = value.length;
      // this.checkAll = checkedCount === this.cities.length;
      // this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
    },
    remoteMethod(query){
      if (query) {
        this.loading = true
        setTimeout(async () => {
          this.loading = false;
          let list = await getListName(this.page.currentPage, this.page.pageSize, { brandName: query });
         this.optionsr = list.data.data.records.filter((item) => {
            return item.brandName.toLowerCase().includes(query.toLowerCase())
          })
        }, 200)
      } else {
        this.optionsr = [];
      }
    },
    remoteMethodBin(query){
      if (query) {
        this.loading = true
        setTimeout(async () => {
          this.loading = false;
          let list = await getListBinName(this.page.currentPage, this.page.pageSize, { name: query });
         this.optionser = list.data.data.records.filter((item) => {
            return item.name.toLowerCase().includes(query.toLowerCase())
          })
        }, 200)
      } else {
        this.optionser = [];
      }
    },
    init () {
      this.height = this.setPx(document.body.clientHeight - 340);
      //字典
      getDictionaryBiz('jg_freight_mark').then(res => {
        // console.log("字典》》》",res);
        this.clientType = res.data.data;
      });
      //字典
      // getDictionaryBiz('warehousing_time_status').then(res => {
      //   // console.log("字典》》》",res);
      //   this.wareType = res.data.data;
      // });
    },
    searchHide () {
      this.search = !this.search;
    },
    searchChange () {
      this.onLoad(this.page);
    },
    searchReset () {
      this.query = {};
      this.page.currentPage = 1;
      this.onLoad(this.page);
    },
    bianli(costListName,clientType,costList,fei){
      // console.log(">>>>>>>>>",costListName,clientType,costList,fei);
      this.pan = false;
      // fei = [];
      for (let i = 0;i< costListName.length;i++){
        if(!costList){ this.pan = true; return }
        let zhi = costList[i];
        if(!zhi){
          this.pan = true;
          continue;
        }
        clientType.forEach( it =>{
          if(it.dictValue == costListName[i]){
            // console.log("进来了",it.dictValue , costListName[i]);
            //2.添加
            fei.set(it.dictKey,zhi)
          }
        })

      }
    },
    handleSubmit (from) {
      this.$refs[from].validate(async (valid) => {
        if (valid) {
          if (!this.form.id) {
            // console.log("提交的数据》》》",this.form);
            let fei = new Map();
          await this.bianli(this.costListName,this.clientType,this.costList,fei);
           this.form.fei = Object.fromEntries(fei);
            // console.log("fei",fei);
           this.form.freightMark = undefined;
          //  let feishi = new Map();
          // await this.bianli(this.costWraeListName,this.wareType,this.costWraeList,feishi);
          //  this.form.feishi = Object.fromEntries(feishi);
          //   // console.log("feishi",feishi);
          //  this.form.warehousingTimeStatus = undefined;
            if(this.pan){
              this.$message.warning("请填写完整已勾选的数据费用");
              return
            }
            this.form.city = this.form.province[1];
            this.form.district = this.form.province[2];
            this.form.province = this.form.province[0];
            console.log("提交的数据》》》",this.form);
            add(this.form).then(() => {
              this.box = false;
              this.onLoad(this.page);
              this.$message({
                type: "success",
                message: "操作成功!"
              });
            });


          } else {
            this.form.city = this.form.province[1];
            this.form.district = this.form.province[2];
            this.form.province = this.form.province[0];
            if(JSON.stringify(this.form.goalGranary).length < 15){
              this.form.goalGranary = null;
            }
            if(JSON.stringify(this.form.brand).length < 15){
              this.form.brand = null;
            }
            update(this.form).then(() => {
              this.box = false;
              this.onLoad(this.page);
              this.$message({
                type: "success",
                message: "操作成功!"
              });
            })
          }
        }
      })

    },
    handleAdd () {
      // this.title = '新增'
      // this.form = {}
      // this.init ();
      // this.box = true;
      this.$router.push({
        path:"/basicdata/brand/basicZonePriceFrom",
        query: {
          id : '',
          name : '新增',
          type: 0
        }
      });


    },
    handleEdit (row) {
      // this.title = '编辑'
      // this.box = true
      // getDetail(row.id).then(res => {
      //   this.form = res.data.data;
      //   let a= [];
      //   if(!!this.form.province){
      //     a.push(res.data.data.province);
      //     a.push(res.data.data.city);
      //     a.push(res.data.data.district);
      //   }
      //   this.form.province = a;
      //   this.form.goalGranary = row.name;
      //   this.form.brand = row.brandName;
      // });
      this.$router.push({
        path:"/basicdata/brand/basicZonePriceFrom",
        query: {
          id : row.id,
          name : '编辑 — '+row.brandName,
          type: 2
        }
      });
    },
    handleView (row) {
      // console.log("row>>>>>>>>",row);
      // this.title = '查看'
      // this.view = true;
      // this.box = true;
      // getDetail(row.id).then(res => {
      //   this.form = res.data.data;
      //   let a= [];
      //   if(!!this.form.province){
      //     a.push(res.data.data.province);
      //     a.push(res.data.data.city);
      //     a.push(res.data.data.district);
      //   }
      //   this.form.province = a;
      //   this.form.goalGranary = row.name;
      //   this.form.brand = row.brandName;
      // });

      this.$router.push({
        path:"/basicdata/brand/basicZonePriceFrom",
        query: {
          id : row.id,
          name : '查看 — '+row.brandName,
          type: 1
        }
      });

    },
    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;
      if(!!this.query.province){
        this.query.city = this.query.province[1];
        this.query.district = this.query.province[2];
        this.query.province = this.query.province[0];
      }
      getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
        const data = res.data.data;
        this.clientType.forEach(it =>{
          data.records.forEach(i =>{
            if(parseInt( it.dictKey ) == parseInt(i.freightMark)){
              i.freightMark = it.dictValue
            }
            if(i.freightMark == '-1'){
              i.freightMark = '无'
            }
          })
        })
        // this.wareType.forEach(it =>{
        //   data.records.forEach(i =>{
        //     if(parseInt( it.dictKey ) == parseInt(i.warehousingTimeStatus)){
        //       i.warehousingTimeStatus = it.dictValue
        //     }
        //     if(i.warehousingTimeStatus == '-1'){
        //       i.warehousingTimeStatus = '无'
        //     }
        //   })
        // })
        this.page.total = data.total;
        this.data = data.records;
        let dz ="";
        let mdz ="";
        data.records.forEach(it =>{
          if(!!it.provinceEnd){
            let arrshe = this.optioner.filter((i) => {
              return it.provinceEnd == i.value;
            });
            let moshi = arrshe[0].children.filter((i) => {
              return it.cityEnd == i.value;
            });
            if(!!it.districtEnd){
              let moqu = moshi[0].children.filter((i) => {
                return it.districtEnd == i.value;
              });
              mdz = arrshe[0].label+"/"+moshi[0].label+"/"+moqu[0].label;
            }else{
              mdz = arrshe[0].label+"/"+moshi[0].label
            }
            it.provinceEnd = mdz;
          }

          let arrsheng = this.optioner.filter((i) => {
            return it.province == i.value;
          });
          // console.log("========",JSON.parse(JSON.stringify(arrsheng)) );
          let arrshi = arrsheng[0].children.filter((i) => {
            return it.city == i.value;
          });
         if(!!it.district){
           let arrqu = arrshi[0].children.filter((i) => {
             return it.district == i.value;
           });
           dz = arrsheng[0].label+"/"+arrshi[0].label+"/"+arrqu[0].label;
         }else{
           dz = arrsheng[0].label+"/"+arrshi[0].label;
         }
          it.province = dz;
        })
        this.loading = false;
        this.selectionClear();
      });
    }
  }
};
</script>
<style>
.ca .el-radio__inner {
  top: -18px;
  left: -19px;
  border-radius: 0;
  border: 0;
  width: 170px;
  height: 34px;
  background-color: transparent;
  cursor: pointer;
  box-sizing: border-box;
  position: absolute;
}

.ca .el-radio__input.is-checked .el-radio__inner {
  background: transparent;
}

</style>
