<template>
  <div class="app-container">
    <el-form ref="form" :model="form" :rules="rules" label-width="150px" :disabled="readonly">

      <el-form-item :label="$t('商品类型')" prop="productType">
        <el-select v-model="form.productType" :disabled="!!$route.query.ids">
          <el-option v-for="type in productTypeList" :key="type.id" :label="type.titleZh" :value="type.id" />
        </el-select>
      </el-form-item>

      <el-form-item :label="$t('商品名称')" prop="titleZh">
        <product-selector v-model="form.productId" :product-type="form.productType" @change="product = $event" :disabled="!!$route.query.ids" />
      </el-form-item>

      <el-form-item :label="$t('英文名称')" prop="titleEn">
        <el-input :value="product ? product.titleEn : ''" disabled />
      </el-form-item>

      <!--单条路线修改-->
      <!-- <el-form-item label="路线" prop="lineChannelList" v-if="!$route.query.ids">
        <el-input
          v-for="item in lineList"
          :key="item.lineId"
          :value="'【' + getDictDataLabel(DICT_TYPE.ECW_TRANSPORT_TYPE, item.warehouseLineDO.transportType) + '】从【' + item.warehouseLineDO.startTitleZh + '】发往【' + item.warehouseLineDO.destTitleZh + '】'"
          disabled/>
      </el-form-item>-->
      <!--多条路线批量修改-->
      <el-form-item :label="$t('路线')" prop="lineChannelList" v-if="lineList.length">
        <template v-if="lineList.length == 1">
          <el-input
          v-for="item in lineList"
          :key="item.id"
          :value="!item.warehouseLineDO ? $t('数据异常,缺少warehouseLineDO字段') : $t('【{transport}】从【{from}】发往【{to}】', {
            transport: getDictDataLabel(DICT_TYPE.ECW_TRANSPORT_TYPE, item.warehouseLineDO.transportType),
            from: $l(item.warehouseLineDO, 'startTitle'),
            to: $l(item.warehouseLineDO, 'destTitle')
          })"
          disabled />
        </template>
        <el-checkbox-group v-else v-model="checkList">
          <el-checkbox
          v-for="item in lineList"
          :key="item.id"
          :label="item.id"
          :disabled="!item.warehouseLineDO"
          style="display:block"
          >
            {{
              !item.warehouseLineDO ? $t('数据异常,缺少warehouseLineDO字段') : $t('【{transport}】从【{from}】发往【{to}】', {
                transport: getDictDataLabel(DICT_TYPE.ECW_TRANSPORT_TYPE, item.warehouseLineDO.transportType),
                from: $l(item.warehouseLineDO, 'startTitle'),
                to: $l(item.warehouseLineDO, 'destTitle')
              })
            }}
          </el-checkbox>
        </el-checkbox-group>
      </el-form-item>

      <!--有路线则不显示路线选择器-->
      <routers-selector v-else v-model="selectedRoutes" />

      <el-card style="margin-bottom: 10px">
        <div slot="header" style="font-size:20px;">
          {{$t('价格设置')}}
          <span>
            <el-checkbox v-if="$route.query.action != 'batchUpdate'" label="" v-model="needPay">{{$t('预付')}}</el-checkbox>
            <el-checkbox label="" v-model="stepPrice">{{$t('阶梯定价')}}</el-checkbox>
          </span>
        </div>
        <el-form-item :label="$t('预付')" prop="needPay" v-if="$route.query.action == 'batchUpdate'" >
          <el-radio-group v-model="form.needPay">
            <el-radio :label="1">{{$t('预付')}}</el-radio>
            <el-radio :label="0">{{$t('均可')}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item :label="$t('单价模式')" prop="priceType">
          <dict-selector :type="DICT_TYPE.ECW_PRICE_TYPE" v-model="form.priceType" form-type="radio" formatter="number" defaultable2 />
        </el-form-item>
        <!--阶梯定价-->
        <template v-if="form.stepPrice==1" >
          <div v-for="(item, index) in form.priceStepList" :key="index">
            <div style="font-size:14px; margin:10px 0">
              {{$t('第{index}阶梯定价方案', {index: index+1})}}：
              <template v-if="index == form.priceStepList.length - 1">
                <el-link type="primary" @click.native="form.priceStepList.push({})">{{$t('添加区间')}}</el-link>
                <el-divider direction="vertical"></el-divider>
                <el-link type="danger" @click.native="form.priceStepList.splice(index, 1)">{{$t('删除')}}</el-link>
              </template>
            </div>
            <el-form-item :label="$t(`第{index}阶梯`, {index: index + 1})">
              <el-input v-model="item.startNum" type="number" placeholder="" class="w-100"></el-input>
              -
              <el-input v-model="item.endNum" type="number" placeholder="" class="w-100"></el-input>
              /
              <selector v-model="form.weightUnit" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2  class="w-100" />
            </el-form-item>
            <el-form-item :label="$t('默认运费')" v-if="form.priceType != 1" :prop="`priceStepList.${index}.transportPrice`" :rules="{validator: priceValidator, trigger: 'blur',   message: '价格错误'}">
              <inputor default2="0" v-model.number="item.transportPrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10"/>
              <selector v-model="item.transportPriceUnit" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" defaultable2  class="w-100" />
              / <selector v-model="item.transportVolumeUnit" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2  class="w-100" />
            </el-form-item>
            <el-form-item :label="$t('默认清关费')" v-if="form.priceType != 1" :prop="`priceStepList.${index}.transportPrice`" :rules="{validator: priceValidator, trigger: 'blur',   message: '价格错误'}">
              <inputor default2="0" v-model.number="item.clearancePrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" :rules="{validator: priceValidator, trigger: 'blur',   message: '价格错误'}"/>
              <selector v-model="item.clearancePriceUnit" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" defaultable2  class="w-100" />
              / <selector v-model="item.clearanceVolumeUnit" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2  class="w-100" />
            </el-form-item>

            <el-form-item
              :label="$t('默认全包价')"
              v-if="form.priceType == 1"
              :prop="`priceStepList.${index}.allPrice`"
              :rules="{validator: priceValidator, trigger: 'blur',   message: '价格错误'}"
              >
              <selector v-model="item.allPriceUnit" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" defaultable2  class="w-100" />
              <inputor default2="0" v-model.number="item.allPrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" :rules="{validator: priceValidator, trigger: 'blur',   message: '价格错误'}"/>
              / <selector v-model="item.allVolumeUnit" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2  class="w-100" />
            </el-form-item>
          </div>
        </template>

        <template v-else>
          <el-form-item :label="$t('默认全包价')" v-if="form.priceType == 1" prop="allPrice" :rules="{validator: priceValidator, trigger: 'blur',   message: '价格错误'}">
            <selector test="allPriceUnit" v-model="form.allPriceUnit" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2  class="w-100 mr-10 aaa" />
            <inputor default2="0" v-model.number="form.allPrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 mr10" />
            <span class="mr-10">/</span>
            <selector v-model="form.allVolumeUnit" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2  class="w-100" />
          </el-form-item>
          <template v-else>
            <el-form-item :label="$t('默认运费')" prop="transportPrice" :rules="{validator: priceValidator, trigger: 'blur',   message: '价格错误'}">
                <selector v-model="form.transportPriceUnit" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 class="w-100 mr-10" />
                <inputor default2="0" v-model.number="form.transportPrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100  mr-10" />
                <span class="mr-10">/</span>
                <selector v-model="form.transportVolumeUnit" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 class="w-100" />
            </el-form-item>
            <el-form-item :label="$t('默认清关费')" prop="clearancePrice" :rules="{validator: priceValidator, trigger: 'blur',   message: '价格错误'}">
                <selector v-model="form.clearancePriceUnit" :options="currencyList" :label-field="$l('title')" value-field="id" defaultable2 class="w-100 mr-10" />
                <inputor default2="0" v-model.number="form.clearancePrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" />
                <span class="mr-10">/</span>
                <selector v-model="form.clearanceVolumeUnit" :options="unitList" :label-field="$l('title')" value-field="id" defaultable2 class="w-100" />
            </el-form-item>
          </template>

          <!--特需-->
          <template v-if="form.priceType==1">
            <el-form-item
              v-for="(special, specialIndex) in this.form.specialList"
              :label="getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + $t('全包价')"
              :key="specialIndex + 'transport'"
              :prop="`specialList.${specialIndex}`.allPrice"
              :rules="{validator: priceValidator, trigger: 'blur',   message: '价格错误'}"
              >
                  <selector v-model="special.allPriceUnit" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100 mr-10" />
                  <inputor default2="0" v-model.number="special.allPrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" />
                  <span class="mr-10">/</span>
                  <selector v-model="special.allVolumeUnit" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100" />
            </el-form-item>
          </template>
          <template v-else v-for="(special, specialIndex) in this.form.specialList">
            <el-form-item
              :label="getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + $t('运费')"
              :key="specialIndex + 'transport'"
              :prop="`specialList.${specialIndex}.transportPrice`"
              :rules="{validator: priceValidator, trigger: 'blur',   message: '价格错误'}"
              >
              <selector v-model="special.transportPriceUnit" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100 mr-10" />
              <inputor default2="0" v-model.number="special.transportPrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" />
              <span class="mr-10">/</span>
              <selector v-model="special.transportVolumeUnit" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100" />
            </el-form-item>
            <el-form-item
              :label="getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + $t('清关费')"
              :key="specialIndex + 'clearance'"
              :prop="`specialList.${specialIndex}.clearancePrice`"
              :rules="{validator: priceValidator, trigger: 'blur',   message: '价格错误'}"
              >
              <selector v-model="special.clearancePriceUnit" :options="currencyList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100 mr-10" />
              <inputor default2="0" v-model.number="special.clearancePrice" type="number" :placeholder="$t('整数或者两位小数')" class="w-100 mr-10" />
              <span class="mr-10">/</span>
              <selector v-model="special.clearanceVolumeUnit" :options="unitList" :label-field="$l(null, 'title')" value-field="id" defaultable2 class="w-100" />
            </el-form-item>
          </template>
        </template>

        <el-form-item :label="$t('价格有效期')">
            <el-date-picker v-model="form.validateStartDate" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
            -
            <el-date-picker v-model="form.validateEndDate" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
        </el-form-item>
      </el-card>


      <el-card>
        <div slot="header" style="font-size:20px;">
          {{$t('基础信息')}}
        </div>

        <el-form-item :label="$t('是否预约入仓')" prop="needBook">
          <el-radio v-model.number="form.needBook" :label="1">{{$t('是')}}</el-radio>
          <el-radio v-model.number="form.needBook" :label="0">{{$t('否')}}</el-radio>
        </el-form-item>

        <el-form-item :label="$t('每日入仓上限')" prop="dayLimit" v-if="form.needBook == 1">
          <el-input v-model.number="form.dayLimit" type="number" class="w-100" />{{$t('立方米')}}
        </el-form-item>

        <el-form-item :label="$t('货柜位置')" prop="containerLocation">
          <dict-selector :type="DICT_TYPE.ECW_CONTAINER_LOCATION" v-model="form.containerLocation" />
        </el-form-item>

        <el-form-item :label="$t('订单方数上限')" prop="square">
          <el-input v-model.number="form.square" type="number" style="width:200px" />
        </el-form-item>
      </el-card>
    </el-form>

    <div style="margin: 20px 0">
      <el-button @click="submitForm" type="primary" v-if="!readonly" :loading="loading">{{$t('确认提交')}}</el-button>
      <el-button type="default" @click="$router.back()">{{$t('返回上一页')}}</el-button>
    </div>
  </div>
</template>
<script>
import RoutersSelector from '@/components/RoutersSelector'
import { createProductPrice, updateProductPrice, batchUpdateProductPrice, deleteProductPrice, getProductPrice, getProductPriceList, getProductPricePage, exportProductPriceExcel } from "@/api/ecw/productPrice";
import { getProductType, getProductTypeList } from '@/api/ecw/productType'
import { getCurrencyList } from '@/api/ecw/currency';
import { getUnitList } from '@/api/ecw/unit';
import ProductSelector from '@/components/ProductSelector'
import { arrryToKeyedObjectBy } from '@/utils/index'
import Selector from '@/components/Selector'
import Inputor from '@/components/Inputor'
import {parseTime} from '@/utils/ruoyi'
export default {
  components: { RoutersSelector, ProductSelector, Selector, Inputor },
  data() {
    return {
      checkList: [],
      selectedRoutes: [], // 勾选的路线渠道
      form: {
        priceStepList: [{},{}], // 阶梯价格
        specialList: []
      },
      needPay: false, // 是否需要预付
      stepPrice: false, // 是否阶梯订单
      // specialProducts: [],
      // priceStepList: [{},{}], // 阶梯价格
      // specialList:[], // 特殊需求,默认四个
      rules: {
        transportPrice: [{ required: true, message: this.$t("海运费不能为空"), trigger: "blur" }],
        clearancePrice: [{ required: true, message: this.$t("清关费不能为空"), trigger: "blur" }],
        advanceStatus: [{ required: true, message: this.$t("是否预付不能为空"), trigger: "blur" }]
      },
      product: null,
      /* productType: null, */
      currencyList: [],
      unitList: [],
      productTypeList: [],
      productDisabled: true,
      readonly: false,
      lineList: [], //路线数组
      loading: false
    }
  },
  computed: {

  },
  watch: {
    checkList() { //选择路线
      if (this.checkList.length > 0) {
        this.form.lineChannelList = this.checkList.map(item => {
          return { lineId: item, shippingChannelId: 0 }
        })
      } else {
        this.form.lineChannelList = []
      }
    },
    product() {
      this.$set(this.form, 'productType', this.product.typeId)
      /* getProductType(this.product.typeId).then(res => {
        this.productType = res.data
      }) */
      // 只有新建才需要把参数带过来
      if(!this.$route.query.action){
        this.$set(this.form, 'needBook', this.product.needBook)
        this.$set(this.form, 'square', this.product.square)
        this.$set(this.form, 'dayLimit', this.product.dayLimit)
        this.$set(this.form, 'containerLocation', this.product.containerLocation)
      }

    },
    form(val) {
      if (!val) return
      // 特殊需求回显
      if (val.specialList) {
        val.specialList.forEach(item => {
          let index = this.form.specialList.findIndex(special => special.specialDictType == item.specialDictType)
          if(index > -1)this.form.specialList[index] = item
        })
      }
    },
    'form.priceType'(priceType){
      // 切换全包价的时候给默认货币单位
      if(priceType == 1){
        this.$set(this.form, 'allPriceUnit', 1)
      }
    },
    'form.transportVolumeUnit'(val){
      this.form.specialList.forEach(item => {
        item.transportVolumeUnit = val
      })
    },
    'form.clearanceVolumeUnit'(val){
      this.form.specialList.forEach(item => {
        item.clearanceVolumeUnit = val
      })
    },
    'form.transportPriceUnit'(val){
      this.form.specialList.forEach(item => {
        item.transportPriceUnit = val
      })
    },
    'form.clearancePriceUnit'(val){
      this.form.specialList.forEach(item => {
        item.clearancePriceUnit = val
      })
    },
    'form.allPriceUnit'(val){
      this.form.specialList.forEach(item => {
        item.allPriceUnit = val
      })
    },
    'form.allVolumeUnit'(val){
      this.form.specialList.forEach(item => {
        item.allVolumeUnit = val
      })
    },
    'form.needBook'(val){
      if(val) this.$set(this.form, 'dayLimit', 10000)
      else delete this.form.dayLimit
    },
    'form.stepPrice'(stepPrice){
      if(stepPrice == 1 && (!this.form.priceStepList || !this.form.priceStepList.length)){
          this.$set(this.form, 'priceStepList', [{},{}])
      }
    },
    needPay(val){
      this.$set(this.form, 'needPay', val ? 1 : 0)
    },
    stepPrice(val){
      this.$set(this.form, 'stepPrice', val ? 1 : 0)
    },
    selectedRoutes(routers) {
      let transportIds = []
      routers.forEach(item => {
        item.shippingChannelId = item.channelId
        transportIds.push(+item.transportId)
      })

      // 如果只选择了空运（3），则默认体积单位改成千克
      transportIds = new Set(transportIds)
      console.log(transportIds)
      window.transportIds = transportIds
      if(transportIds.size == 1 && transportIds.has(3)){
        this.setDefaultVolumeUnit(6)
      }else this.setDefaultVolumeUnit(7)
    }
  },
  async created() {
    if(this.$route.query.readonly){
      this.readonly = true
    }
    // action=batchUpdate 表示批量修改单个商品的价格（一条或者多条），如果没有ids显示路线选择组件,否则不显示路线组件
    // action=update 表示修改单个商品的单条路线价格,需要回显
    if(this.$route.query.action == 'update'){
      let res = await getProductPrice(this.$route.query.id)
      this.$set(this, 'form', res.data)
      if(this.form.needPay){
        this.needPay = true
      }
      if(res.data.validateStartDate){
        this.form.validateStartDate = parseTime(res.data.validateStartDate)
      }
      if(res.data.validateEndDate){
        this.form.validateEndDate = parseTime(res.data.validateEndDate)
      }
      this.lineList = [res.data]
    }

    // action=batchUpdate且ids不为空
    if(this.$route.query.action == 'batchUpdate'){
      delete this.form.needBook
    }
    if (this.$route.query.ids) {
      let query = {
        ids: this.$route.query.ids
      }
      getProductPriceList(query).then(res => {
        this.lineList = res.data
        this.lineList.forEach(item =>{
          this.checkList.push(item.id)
        })
      })
    }

    // 未指定商品则不禁用商品选择
    if(!this.$route.query.product_id){
        this.productDisabled = false
    }

    // 获取类型列表
    getProductTypeList().then(res => this.productTypeList = res.data)


    // 没有操作标识的就是新建，给有效期默认值
    if(!this.$route.query.action){
      this.form = {
        priceType: 0,
        stepPrice: 0,
        advanceStatus: 0,
        needBook: 0,
        // dayLimit: 10000,
        validateEndDate: undefined,
        validateStartDate: undefined,
        clearancePrice: 0,
        transportPrice: 0
      }
      // 默认体积单位（立方米）
      this.setDefaultVolumeUnit(7)
      // 默认货币单位（美元）
      this.setDefaultPriceUnit(1)
      this.form.validateStartDate = parseTime(Date.now())
      this.form.validateEndDate = parseTime(Date.now() + 86400*365*2*1000)

    }

    if (this.$route.query.product_type) {
      this.$set(this.form, 'productType', +this.$route.query.product_type)
    }
    if (this.$route.query.product_id) {
      this.$set(this.form, 'productId', +this.$route.query.product_id)
    }

    getCurrencyList().then(res => this.currencyList = res.data)
    getUnitList().then(res => this.unitList = res.data)

    if(!this.form.specialList){
      this.$set(this.form, 'specialList', [])
    }
    this.getDictDatas(this.DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS).forEach(item => {
      this.form.specialList.push({
        "clearancePrice": !this.$route.query.action ? 0 : null, // 新建默认给0，否则默认是null
        "clearancePriceUnit": null,
        "clearanceVolumeUnit": null,
        "specialDictType": item.value,
        "transportPrice": !this.$route.query.action ? 0 : null, // 新建默认给0，否则默认是null
        "transportPriceUnit": null,
        "transportVolumeUnit": null,
      })
    })
  },
  methods: {
    priceValidator(rule, value, callback){
      if(!value || value == '') return callback()
      value = parseFloat(value)
      if(!value || value < 0){
        return callback(new Error('价格错误'))
      }
      callback()
    },
    setDefaultVolumeUnit(unit){
      this.$set(this.form, 'transportVolumeUnit', unit)
      this.$set(this.form, 'clearanceVolumeUnit', unit)
      this.$set(this.form, 'allVolumeUnit', unit)
    },
    setDefaultPriceUnit(priceUnit){
      this.$set(this.form, 'transportPriceUnit', priceUnit)
      this.$set(this.form, 'clearancePriceUnit', priceUnit)
      this.$set(this.form, 'allPriceUnit', priceUnit)
    },
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (!valid) {
          return;
        }

        // 只有修改单条路线的时候，不需要选择路线
        /* if (this.$route.query.action !== 'update' && (!this.selectedRoutes || !this.selectedRoutes.length)) {
          this.$message.error('请选择线路');
          return;
        } */
        if(!this.lineList.length && (!this.selectedRoutes || !this.selectedRoutes.length)) {
          this.$message.error(this.$t('请选择线路'));
          return;
        }
        let data = Object.assign({}, this.form, {
          // lineChannelList: this.selectedRoutes,
          specialList: this.specialProducts,
          isAllProduct: 0
        })
        if(this.form.stepPrice != 1){
          // data.priceStepList = this.priceStepList
          delete data.priceStepList
        }

        // 修改单条路线
        if (this.$route.query.action == 'update') {
          this.loading = true
          return updateProductPrice(data).then(res => {
            this.$modal.msgSuccess(this.$t("请求成功"));
            this.$router.back()
          }).finally(res => this.loading = false)
        }

        // 批量修改（单个商品的单个路线，多个路线，或者全部路线）的提交
        if (this.$route.query.action == 'batchUpdate') {
          // 指定一条路线
          if(this.lineList.length == 1){
            data.lineChannelList = {
              lineId: this.lineList[0].warehouseLineId,
              shippingChannelId: this.lineList[0].shippingChannelId || 0
            }
          }
          // 指定多条路线的需要过滤未勾选的
          else if(this.lineList.length > 1){
            data.lineChannelList = []
            this.lineList.forEach(item => {
              if(this.checkList.indexOf(item.id) > -1){
                data.lineChannelList.push({
                    lineId: item.warehouseLineId,
                    shippingChannelId: item.shippingChannelId || 0
                  }
                )
              }
            })
          }
          // 未指定路线的从路线选择组件里获取
          if(!this.lineList.length){
            data.lineChannelList = this.selectedRoutes
          }
          if(data.lineChannelList.length < 1){
            return this.$message.error(this.$t('请选择需要修改的路线'))
          }
          data.productIdList = [this.form.productId]
          this.loading = true
          batchUpdateProductPrice(data).then(response => {
            this.$modal.msgSuccess(this.$t("修改成功"));
            this.$router.replace('/product/product-price?' + (new URLSearchParams(this.$route.query)).toString())
          }).finally(res => this.loading = false)
          return;
        }
        // 添加的提交
        data.productId = this.product.id;
        data.lineChannelList = this.selectedRoutes

        if((this.form.priceType == 0 && !this.form.transportPrice) || (this.form.priceType == 1 && !this.form.allPrice)){
          return this.$message.error(this.$t('运费/全包价不能为0'))
        }
        this.loading = true
        createProductPrice(data).then(response => {
          this.$modal.msgSuccess(this.$t("请求成功"));
          this.$router.replace('/product/product-price?' + (new URLSearchParams(this.$route.query)).toString())
        }).finally(res => this.loading = false);
      });
    },
  }
}
</script>
<style scoped>
.w-100{
  width: 100px;
}
.mr10{
  margin-right: 10px;
}
</style>
