<template>
  <div style="height: 100%; overflow-y: auto;">
    <div style="text-align: right;">
      <el-button type="primary" style="margin: 10px 20px 10px 7px;" size='mini' icon="el-icon-arrow-left" plain @click="closeDialog">返回列表</el-button>
    </div>
    <el-card style="margin: 0 20px;">
      <h3 class="tipTitle">运费计算规则</h3>
      <div class="tipContent">
        <p>1、当【限制地区】有设置时，会优先验证，若用户的收货地址在【限制地区】范围内，则用户无法下单。</p>
        <p>2、收货地址在【配送地区】范围内，根据【配送地区】设置的规则计算商品运费。</p>
        <p>3、添加【配送地区】时，默认为全国，若单独设置【指定地区】后，会验证地区的配送规则，根据【指定地区】的设置进行运费计算</p>
        <p>4、当商品的【配送地区】均不在设置范围内的时候，用户无法下单</p>
      </div>
    </el-card>
    <el-card style="margin: 20px;">
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="80px" class="demo-ruleForm" style="width: 80%;">
        <el-form-item label="排序" prop="sort" style="width: 400px;">
          <el-input v-model="ruleForm.sort" placeholder="请输入排序序号" @input="onClickInputKeyBoard3('ruleForm', 'sort')"></el-input>
        </el-form-item>
        <el-form-item label="模板名称" prop="name" style="width: 400px;">
          <el-input v-model="ruleForm.name" placeholder="请输入模板名称"></el-input>
        </el-form-item>
        <el-form-item label="是否默认">
          <el-radio-group v-model="ruleForm.is_default">
            <el-radio :label="1">是</el-radio>
            <el-radio :label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="计费方式">
          <el-radio-group v-model="ruleForm.charge_type">
            <el-radio :label="1">按重量</el-radio>
            <el-radio :label="2">按数量</el-radio>
            <el-radio :label="3">按体积</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="配送地区">
          <div>
            <div style="display: flex; justify-content: space-between; margin-bottom: 5px;">
              <span style="font-size: 12px; color: #85878A;">除指定地区外，其余地区运费采用：“全国默认运费”</span>
              <div>
                <el-button plain size="mini" @click="delDelivery('2')">删除</el-button>
                <el-button type="primary" plain size="mini" @click="addDelivery">添加地区</el-button>
              </div>
            </div>
            <div style="background: #F9F9FA; padding: 20px;">
              <el-table
                class="multipleTable"
                ref="multipleTable"
                :data="deliveryTableData"
                tooltip-effect="dark"
                style="width: 100%"
                @selection-change="handleSelectionChange">
                <el-table-column
                  type="selection"
                  :selectable="selectEnable"
                  width="55">
                </el-table-column>
                <el-table-column
                  label="配送区域"
                  >
                  <template slot-scope="scope">
                    <div v-if="scope.row.a.length && scope.row.a[0].province_id == 0">【默认】全国</div>
                    <div v-if="scope.row.a.length && scope.row.a[0].province_id != 0">
                      【指定】
                      <span v-for="(item, index) in scope.row.value" :key="index">
                        <span>{{ item.province_name }}{{ item.city_name.length ? `(${ item.city_name.join() })` : '' }}</span>
                        <span v-if="index < scope.row.value.length - 1">,&nbsp;</span>
                      </span>
                    </div>
                    <div v-if="!scope.row.a.length" style="color: #1890ff; cursor: pointer;" @click="editAddress(scope.row, scope.$index, 'add')">【点击选择配送地区】</div>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="name"
                  label="首件（个）"
                  width="150"
                  >
                  <template slot="header" slot-scope="scope">
                    <span v-if="ruleForm.charge_type == 2">首件（个）</span>
                    <span v-if="ruleForm.charge_type == 1">首重（克）</span>
                    <span v-if="ruleForm.charge_type == 3">首件（立方米）</span>
                  </template>
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.f" class="inputWidth" @input="onClickInputKeyBoard2('deliveryTableData', scope.$index, 'f')"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="fp"
                  label="运费（元）"
                  width="150"
                  >
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.fp" class="inputWidth" @input="onClickInputKeyBoard('deliveryTableData', scope.$index, 'fp')"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="n"
                  label="续件（个）"
                  width="150"
                  >
                  <template slot="header" slot-scope="scope">
                    <span v-if="ruleForm.charge_type == 2">续件（个）</span>
                    <span v-if="ruleForm.charge_type == 1">续重（克）</span>
                    <span v-if="ruleForm.charge_type == 3">续件（立方米）</span>
                  </template>
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.n" class="inputWidth" @input="onClickInputKeyBoard2('deliveryTableData', scope.$index, 'n')"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="np"
                  label="续费（元）"
                  width="150"
                  >
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.np" class="inputWidth" @input="onClickInputKeyBoard('deliveryTableData', scope.$index, 'np')"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  label="操作"
                  width="120"
                  >
                  <template slot-scope="scope" v-if="scope.$index > 0">
                    <el-button type="text" size="small" @click="delDelivery('1', scope.$index)">删除</el-button>
                    <el-button type="text" size="small" @click="editAddress(scope.row, scope.$index)" v-if="scope.row.a.length">修改地区</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>
        </el-form-item>
        <el-form-item label="限制地区">
          <div>
            <div style="display: flex; justify-content: space-between; margin-bottom: 5px;">
              <span style="font-size: 12px; color: #85878A;">收货地址在限制下单区域内的用户将无法完成下单</span>
              <div>
                <el-button type="primary" plain size="mini" @click="addNoDelivery" v-if="!noDeliveryTableData.length">添加地区</el-button>
              </div>
            </div>
            <div style="background: #F9F9FA; padding: 20px;">
              <el-table
                class="multipleTable"
                :data="noDeliveryTableData"
                tooltip-effect="dark"
                style="width: 100%"
                >
                <!-- 样式占位 -->
                <el-table-column
                  label=""
                  width="10"
                  >
                </el-table-column>
                <el-table-column
                  label="限制配送地区"
                  prop="dis_dispatching"
                  >
                  <template slot-scope="scope">
                    <span v-for="(item, index) in scope.row.value" :key="index">
                      <span>{{ item.province_name }}{{ item.city_name.length ? `(${ item.city_name.join() })` : '' }}</span>
                      <span v-if="index < scope.row.value.length - 1">,&nbsp;</span>
                    </span>
                  </template>
                </el-table-column>
                <!-- 样式占位 -->
                <el-table-column
                  label=""
                  width="200"
                  >
                </el-table-column>
                <el-table-column
                  label="操作"
                  width="120"
                  >
                  <template slot-scope="scope">
                    <el-button type="text" size="small" @click="noDeliveryTableData = []">删除</el-button>
                    <el-button type="text" size="small" @click="editAddress(scope.row, scope.$index, 2)">修改地区</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>
        </el-form-item>
        <el-form-item label="启用状态">
          <el-radio-group v-model="ruleForm.publish">
            <el-radio :label="1">是</el-radio>
            <el-radio :label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <div style="text-align: center;">
        <el-button size="mini" @click="closeDialog">取消</el-button>
        <el-button type="primary" size="mini" @click="handleSubmit">提交</el-button>
      </div>
    </el-card>
    <el-dialog 
      title="选择地区" 
      :visible.sync="dialogAddress" 
      v-if="dialogAddress" 
      width="600px" 
      :close-on-click-modal="false"
      :append-to-body="true">
      <div style="height: 500px;">
        <el-cascader-panel ref="cascaderPanel" v-model="selectAddress" :options="addressOptions" :props="props" style="height: 100%;"></el-cascader-panel>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogAddress = false" size="mini">取消</el-button>
        <el-button type="primary" @click="saveAddress" size="mini">提交</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  import { addFreight, updateFreight} from '@/api/module/freight'

  export default {
    props: {
      option: {
        type: Object,
        required: true
      },
      addressAll: {
        type: Array,
        required: true
      }
    },
    data() {
      return {
        ruleForm: {
          id: 0,
          sort: 0,
          name: '',
          is_default: 0,
          charge_type: 1,
          publish: 0
        },
        // 表单校验
        rules: {
          sort: [
            {required: true, message: "排序不能为空", trigger: "blur"}
          ],
          name: [
            {required: true, message: "模板名称不能为空", trigger: "blur"}
          ],
        },
        deliveryTableData: [
          {
            a: [{
              province_id: 0,
              province_name: '全国'
            }],
            f: '',
            fp: '',
            n: '',
            np: ''
          }
        ],
        noDeliveryTableData: [],
        multipleSelection: [],
        dialogAddress: false,
        props: { 
          multiple: true,
          value: 'id',
          label: 'name'
        },
        addressOptions: [],
        rowItem: null,
        rowItem2: null,
        selectAddress: [],
        addType: 1 // 1 配送添加  2不配送添加
      }
    },
    mounted() {
      this.addressOptions = this.addressAll
      this.initData()
    },
    methods: {
      // 初始化数据
      initData() {
        if (this.option.id == 0) {
          this.ruleForm = {
            id: 0,
            sort: 0,
            name: '',
            is_default: 0,
            charge_type: 1,
            publish: 0
          }
          this.deliveryTableData = [
            {
              a: [{
              province_id: 0,
              province_name: '全国'
            }],
              f: '',
              fp: '',
              n: '',
              np: ''
            }
          ]
          this.noDeliveryTableData = []
        } else {
          this.ruleForm = {
            id: this.option.id,
            sort: this.option.sort,
            name: this.option.name,
            is_default: this.option.is_default,
            charge_type: this.option.charge_type,
            publish: this.option.publish
          }
          this.deliveryTableData = this.option.new_dispatching
          if (this.option.new_dispatching) {
            this.deliveryTableData.forEach(item=>{
              item.fp = Number(item.fp / 100)
              item.np = Number(item.np / 100)
              item.value = this.getSelectData(item.a)
              item.id = this.getBackData(item.a)
            })
          }
          
          if (this.option.new_dis_dispatching.length) {
            this.noDeliveryTableData[0] = {
              a: this.option.new_dis_dispatching,
              value: this.getSelectData(this.option.new_dis_dispatching),
              id: this.getBackData(this.option.new_dis_dispatching)
            }
          }
        }
      },
      // 设置全国选项不可选
      selectEnable(row) {
        if (row.a.length && row.a[0].province_id == 0) {
          return false
        } else {
          return true
        }
      },
      onClickInputKeyBoard(str, index, from) {
        this[str][index][from] = this[str][index][from].toString().match(/^\d*(\.?\d{0,2})/g)[0]
      },
      onClickInputKeyBoard2(str, index, from) {
        this[str][index][from] = this[str][index][from].toString().match(/^\d*/g)[0]
      },
      onClickInputKeyBoard3(str, from) {
        this[str][from] = this[str][from].toString().match(/^\d*/g)[0]
      },
      closeDialog() {
        this.$emit('closeIndexbtn', false)
      },
      // 多选数据
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      // 添加配送地区
      addDelivery() {
        this.selectAddress = []
        this.addType = 1
        this.deliveryTableData.push(
          {
            a: [],
            f: '',
            fp: '',
            n: '',
            np: '',
          }
        )
      },
      // 处理已经添加的数据不可重复添加
      async repeatAdd() {
        await this.cancelDisabled()
        let arr = [] // 已添加的数据合并到一个数组中
        this.deliveryTableData.map(item => {
          arr = arr.concat(item.a)
        })

        if (arr.length) {
          for(let i = 0; i < arr.length; i++) {
            for(let j = 0; j < this.addressOptions.length; j++) {
              if (arr[i].city_id) {
                if (arr[i].province_id == this.addressOptions[j].id) {
                  for(let k = 0; k < this.addressOptions[j].children.length; k++) {
                    if (arr[i].city_id == this.addressOptions[j].children[k].id) {
                      this.$set(this.addressOptions[j].children[k], 'disabled', true)
                    }
                  }
                }
              } else {
                if (arr[i].province_id == this.addressOptions[j].id) {
                  this.$set(this.addressOptions[j], 'disabled', true)
                }
              }
            }
          }
        }
      },
      // 编辑时取消禁用的按钮
      cancelDisabled() {
        for(let i = 0; i < this.addressOptions.length; i++) {
          if (this.addressOptions[i].disabled) {
            this.$set(this.addressOptions[i], 'disabled', false)
          }
          for(let j = 0; j < this.addressOptions[i].children.length; j++) {
            if (this.addressOptions[i].children[j].disabled) {
              this.$set(this.addressOptions[i].children[j], 'disabled', false)
            }
          }
        }
      },
      // 添加不配送地区
      addNoDelivery() {
        this.cancelDisabled()
        this.selectAddress = []
        this.addType = 2
        this.dialogAddress = true
      },
      // 删除配送地区
      delDelivery(type, index) {
        if (type == 1) {
          this.deliveryTableData.splice(index, 1);
        } else {
          for(let i = 0, len = this.multipleSelection.length; i < len; i++) {
            for(let j = 0, len = this.deliveryTableData.length; j < len; j++) {
              if (this.multipleSelection[i] == this.deliveryTableData[j]) {
                this.deliveryTableData.splice(j, 1);
              }
            }
          }
        }
      },
      // 修改地区
      async editAddress(row, index, type) {
        // type 2 限制配送区域   1 配送区域
        this.selectAddress = []
        if (type == 2) {
          this.rowItem2 = row
          this.addType = 2
          this.cancelDisabled()
        } else {
          this.rowItem = row
          this.addType = 1

          await this.repeatAdd()
          // 修改时取消当前行的禁用
          let arr = row.a
          if (arr.length) {
            for(let i = 0; i < arr.length; i++) {
              for(let j = 0; j < this.addressOptions.length; j++) {
                if (arr[i].city_id) {
                  if (arr[i].province_id == this.addressOptions[j].id) {
                    for(let k = 0; k < this.addressOptions[j].children.length; k++) {
                      if (arr[i].city_id == this.addressOptions[j].children[k].id) {
                        this.$set(this.addressOptions[j].children[k], 'disabled', false)
                      }
                    }
                  }
                } else {
                  if (arr[i].province_id == this.addressOptions[j].id) {
                    this.$set(this.addressOptions[j], 'disabled', false)
                  }
                }
              }
            }
          }

          // 子元素全部禁用后父级也禁用
          for(let i = 0; i < this.addressOptions.length; i++) {
            if (!this.addressOptions[i].disabled) {
              let isDisabled = true
              for(let j = 0; j < this.addressOptions[i].children.length; j++) {
                if (!this.addressOptions[i].children[j].disabled) {
                  isDisabled = false
                }
              }
              this.$set(this.addressOptions[i], 'disabled', isDisabled)
            }
          }
        }

        // 添加时 已添加的不可重复添加
        if (type == 'add') {
          this.repeatAdd()
        } 
        
        this.selectAddress = row.id
        this.dialogAddress = true
      },
      // 选择的地区赋值
      saveAddress() {
        let a = []
        let b = []
        let c = [] // 将每个省的数据组合到一个数组中
        for(let i = 0; i < this.selectAddress.length; i++) {
          a.push(this.selectAddress[i][0])
        }
        b = Array.from(new Set(a))
        if (b.length == this.addressOptions.length) {
          this.$message.warning('已存在全国默认运费')
          return
        }

        if (this.addType == 1) {
          this.rowItem.a = this.getAfferentData()
          this.rowItem.value = []
          this.rowItem.id = []
          this.rowItem.value = this.getSelectData(this.rowItem.a)
          this.rowItem.id = this.getBackData(this.rowItem.a)
        } else {
          this.noDeliveryTableData = []
          this.noDeliveryTableData.push({
            a: this.getAfferentData(this.getAfferentData()),
            value: this.getSelectData(this.getAfferentData()),
            id: this.getBackData(this.getAfferentData())
          })
        }
        this.dialogAddress = false
      },
      // 获取对应数据显示的地址名称
      getSelectData(data) {
        let a = []
        let b = []
        let c = [] // 地址名称 省 市
        for(let i = 0; i < data.length; i++) {
          a.push(data[i].province_id)
        }
        b = Array.from(new Set(a))

        for(let i = 0; i < b.length; i++) {
          let name = ''
          let arr = []
          for(let j = 0; j < data.length; j++) {
            if (b[i] == data[j].province_id) {
              if (data[j].city_id) {
                name = data[j].province_name
                arr.push(data[j].city_name)
              } else {
                name = data[j].province_name
              }
            }
          }
          c.push({
            province_name: name,
            city_name: arr
          })
        }
        return c
      },
      // 将后台返回的格式处理成组件需要的格式
      getBackData(data) {
        let arr = []
        for(let i = 0; i < data.length; i++) {
          let arrItem = []

          if (data[i].city_id) {
            arrItem.push(data[i].province_id)
            arrItem.push(data[i].city_id)
            arr.push(arrItem)
          } else {
            for(let j = 0; j < this.addressOptions.length; j++) {
              if (data[i].province_id == this.addressOptions[j].id) {
                for(let k = 0; k < this.addressOptions[j].children.length; k++) {
                  arrItem.push(data[i].province_id)
                  arrItem.push(this.addressOptions[j].children[k].id)
                  arr.push(arrItem)
                  arrItem = []
                }
              }
            }
          }
        }
        return arr
      },
      // 组装成后台需要的格式 省市
      getAfferentData() {
        let a = []
        let b = []
        let c = [] // 将每个省的数据组合到一个数组中
        for(let i = 0; i < this.selectAddress.length; i++) {
          a.push(this.selectAddress[i][0])
        }
        b = Array.from(new Set(a))
        for(let i = 0; i < b.length; i++) {
          c[i] = []
          for(let j = 0; j < this.selectAddress.length; j++) {
            if (b[i] == this.selectAddress[j][0]) {
              c[i].push(this.selectAddress[j])
            }
          }
        }
        let selectData = []

        for(let i = 0; i < c.length; i++) {
          let arr1 = []
          for(let j = 0; j < this.addressOptions.length; j++) {
            if (c[i][0][0] == this.addressOptions[j].id) {
              let d = []
              let e = []
              c[i].map(item => {
                d.push(item[1])
              })
              e = Array.from(new Set(d))

              if (e.length == this.addressOptions[j].children.length) {
                arr1.push({
                  province_id: this.addressOptions[j].id,
                  province_name: this.addressOptions[j].name
                })
              } else {
                for (let k = 0; k < e.length; k++) {
                  for(let l = 0; l < this.addressOptions[j].children.length; l++) {
                    if (e[k] == this.addressOptions[j].children[l].id) {
                      arr1.push({
                        province_id: this.addressOptions[j].id,
                        province_name: this.addressOptions[j].name,
                        city_id: this.addressOptions[j].children[l].id,
                        city_name: this.addressOptions[j].children[l].name
                      })
                    }
                  }
                }
              }
            }
          }
          selectData = selectData.concat(arr1)
        }
        return selectData
      },
      // 将数据组合成省市县及是否选中的是全部地区 山东省【济南市（市中区，天桥区，长清区，济阳县）】 河北省（全部地区）
      // getAddressName() {
      //   let a = []
      //   let b = []
      //   let c = [] // 将每个省的数据组合到一个数组中
      //   for(let i = 0; i < this.selectAddress.length; i++) {
      //     a.push(this.selectAddress[i][0])
      //   }
      //   b = Array.from(new Set(a))
      //   for(let i = 0; i < b.length; i++) {
      //     c[i] = []
      //     for(let j = 0; j < this.selectAddress.length; j++) {
      //       if (b[i] == this.selectAddress[j][0]) {
      //         c[i].push(this.selectAddress[j])
      //       }
      //     }
      //   }

      //   let addressName = []
      //   for(let i = 0; i < c.length; i++) {
      //     let name1 = []
      //     let name2 = []
      //     let name3 = []
      //     let str = ''

      //     for(let j = 0; j < this.addressOptions.length; j++) {
      //       if (c[i][0][0] == this.addressOptions[j].id) {
      //         name1.push(this.addressOptions[j].name)
    
      //         let d = []
      //         let e = []
      //         c[i].map(item => {
      //           d.push(item[1])
      //         })
      //         e = Array.from(new Set(d))
              
      //         if (e.length == this.addressOptions[j].children.length) {
      //           name2.push('全部地区')
      //         } else {
      //           if ('children' in this.addressOptions[j]) {
      //             for(let k = 0; k < e.length; k++) {
      //               let data = ''
      //               let h = []
      //               for(let p = 0; p < d.length; p++) {
      //                 if (e[k] == d[p]) {
      //                   h.push(d[p])
      //                 }
      //               }
                    
      //                 for(let l = 0; l < this.addressOptions[j].children.length; l++) {
      //                   if (e[k] == this.addressOptions[j].children[l].id) {
      //                     data += (this.addressOptions[j].children[l].name)

      //                     let f = []
      //                     let g = []
      //                     c[i].map(item => {
      //                       if (e[k] == item[1]) {
      //                         g.push(item[2])
      //                       }
      //                     })
      //                     if ('children' in this.addressOptions[j].children[l]) {
      //                       if (h.length == this.addressOptions[j].children[l].children.length) {
      //                         name3.push('全部地区')
      //                       } else {
      //                         for(let m = 0; m < g.length; m++) {
      //                           for(let n = 0; n < this.addressOptions[j].children[l].children.length; n++) {
      //                             if (g[m] == this.addressOptions[j].children[l].children[n].id) {
      //                               name3.push(this.addressOptions[j].children[l].children[n].name)
      //                             }
      //                           }
      //                         }
      //                       }
      //                     }
      //                   }
      //                 }
      //               data += `(${name3.join()})`
      //               name2.push(data)
      //               data = []
      //               name3 = []
      //             }
      //           }
      //         }
      //       }
      //     }
      //     str = name1.join() + `【${name2.join()}】`
      //     addressName.push(str)
      //     name2 = []
      //     name3 = []
      //   }
      //   return addressName
      // },
      // 提交
      handleSubmit() {
        // 校验配送区域不能为空
        let isContinue = true
        if (this.deliveryTableData.length) {
          for(let i = 0; i < this.deliveryTableData.length; i++) {
            if (!this.deliveryTableData[i].a.length || !String(this.deliveryTableData[i].f) || !String(this.deliveryTableData[i].fp) || !String(this.deliveryTableData[i].n) || !String(this.deliveryTableData[i].np)) {
              isContinue = false
            }
          }
        }

        this.$refs['ruleForm'].validate((valid) => {
          if (valid) {
            if (!isContinue) {
              this.$message.warning('配送区域不能为空')
              return
            }

            if (this.option.id == 0) {
              let params = JSON.parse(JSON.stringify(Object.assign({}, this.ruleForm, {new_dispatching: this.deliveryTableData})))
              if (params.new_dispatching.length) {
                params.new_dispatching.forEach(item=>{
                  item.fp = Number(item.fp * 100)
                  item.np = Number(item.np * 100)
                  item.value = undefined
                  item.id = undefined
                })
              }
              params.new_dis_dispatching = this.noDeliveryTableData.length ? this.noDeliveryTableData[0].a : []
              if (params.new_dis_dispatching.length) {
                this.noDeliveryTableData[0].value = undefined
                this.noDeliveryTableData[0].id = undefined
              }
              addFreight(params).then(res => {
                if (res.code == 1) {
                  this.$message.success('新增成功')
                  this.closeDialog()
                }
              })
            } else {
              let params = JSON.parse(JSON.stringify(Object.assign({}, this.ruleForm, {new_dispatching: this.deliveryTableData})))
              if (params.new_dispatching.length) {
                params.new_dispatching.forEach(item=>{
                  item.fp = Number(item.fp * 100)
                  item.np = Number(item.np * 100)
                  item.value = undefined
                  item.id = undefined
                })
              }
              params.new_dis_dispatching = this.noDeliveryTableData.length ? this.noDeliveryTableData[0].a : []
              if (params.new_dis_dispatching.length) {
                this.noDeliveryTableData[0].value = undefined
                this.noDeliveryTableData[0].id = undefined
              }
              updateFreight(params).then(res => {
                if (res.code == 1) {
                  this.$message.success('修改成功')
                  this.closeDialog()
                }
              })
            }
          }
        })
      }
    }
  }
</script>

<style scoped>
  ::v-deep .el-dialog__header {
    background: #F5F7FA;
    padding: 10px 20px !important;
    border-bottom: 1px solid #DCDEE1;
    margin-bottom: 0;
    font-size: 16px;
  }
  .tipTitle {
    font-size: 16px;
    margin-top: 10px;
  }
  .tipContent {
    font-size: 12px;
    color: #515361;
  }
  ::v-deep .multipleTable .el-table__header-wrapper th {
    background: #fff;
  }
  .inputWidth ::v-deep .el-input__inner {
    width: 100px;
  }
  ::v-deep .el-cascader-menu__wrap {
    height: 100%;
  }
</style>