drawerPeriodItemEdit.vue 26.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665
<template>
  <div class="shoppingCartDrawerCon">
    <el-drawer title="考核方案" size="1000px" :visible.sync="drawerShow" :direction="direction">
      <!-- <glsx-combi-form class="edit-form-container" ref="editFormRef" label-width="100px" default-width="350px"
      :form-ref="editChildRef" :form-obj="editForm" :form-data="editFormData" :form-rules="editRule"></glsx-combi-form> -->
      <el-form ref="periodItem" :model="periodItemForm" :rules="rulesItem" label-suffix=":" label-width="180px">
        <el-form-item label="月度" prop="checkMonth" required>
          <el-select :disabled="mode == 'edit'" style="width: 300px;" width="300px" v-model="periodItemForm.checkMonth"
                     filterable placeholder="请选择月度" @change="restData">
            <el-option v-for="item in baseData.MonthList " :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="周期" prop="checkPeriod" required>
          <el-radio-group :disabled="mode == 'edit'" v-model="periodItemForm.checkPeriod" @change="restData">
            <el-radio :label="1">上半月</el-radio>
            <el-radio :label="2">下半月</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="车主类型" prop="selectCarType" required>
          <el-radio-group v-model="periodItemForm.selectCarType">
            <el-radio :label="0">无</el-radio>
            <el-radio :label="1">车辆价格</el-radio>
            <el-radio :label="2">车辆类型</el-radio>
          </el-radio-group>
          <div v-if="periodItemForm.selectCarType == '1'" class="inputCon">
            <!-- @input="(e) => { handleUpgradeNum(e, 'minCarPrice') }" -->
            <el-form-item prop="minCarPrice"
                          :rules="[{ required: true, message: '请输入最低价格', trigger: ['blur', 'change'] }, { validator: validateStart, trigger: 'blur' },]"
                          required>
              <el-input v-model="periodItemForm.minCarPrice" style="width: 140px;"
                        @input="(e) => { handleUpgradeNum(e, 'minCarPrice') }">
                <i slot="suffix" style="font-style:normal;">万</i>
              </el-input>
            </el-form-item>
            <span style="margin: 0 10px;">-</span>
            <el-form-item prop="maxCarPrice"
                          :rules="[{ required: true, message: '请输入最高价格', trigger: ['blur', 'change'] }, { validator: validateEnd, trigger: 'blur' },]"
                          required>
              <el-input v-model="periodItemForm.maxCarPrice" @input="(e) => { handleUpgradeNum(e, 'maxCarPrice') }"
                        style="width: 140px;">
                <i slot="suffix" style="font-style:normal;">万</i>
              </el-input>
            </el-form-item>

          </div>
          <div v-if="periodItemForm.selectCarType == 2">
            <el-button type="primary" @click="selectCarDialog">选择车型</el-button>
            <el-table :data="echoData" border stripe :header-cell-style="rowClass" style="width: 500px;">
              <el-table-column label="序号" type="index" align="center" width="100px" />
              <el-table-column label="车系名称" align="center">
                <template slot-scope="scope">
                  {{ scope.row.carSeriesName }}
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-form-item>
        <el-form-item label="商品分类" prop="selectGoodsType" required>
          <el-radio-group v-model="periodItemForm.selectGoodsType" @change="restPackageList">
            <el-radio :label="0">无</el-radio>
            <el-radio :label="1">选择分类</el-radio>
          </el-radio-group>
          <div v-if="periodItemForm.selectGoodsType == '1'">
            <el-button type="primary" @click="selectGoodsTypeDialog">选择分类</el-button>
            <el-table :data="periodItemForm.goodsTypeList" border stripe :header-cell-style="rowClass"
                      style="width: 500px;">
              <el-table-column label="序号" type="index" align="center" width="100px" />
              <el-table-column label="分类名称" align="center">

                <template slot-scope="scope">
                  {{ scope.row.goodsTypeName }}
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-form-item>
        <el-form-item label="主推产品套餐" prop="selectPackageType" required>
          <el-radio-group v-model="periodItemForm.selectPackageType" @change="restPackList">
            <el-radio :label="0">无</el-radio>
            <el-radio :label="1">单商品或多个商品</el-radio>
            <el-radio :label="2">商品组合</el-radio>
          </el-radio-group>
          <div>
            <el-button v-if="periodItemForm.selectPackageType != '0'" type="primary"
                       @click="goodsDialogVisible = true">选择商品</el-button>
          </div>
          <el-table v-if="periodItemForm.selectPackageType == 2" :data="periodItemForm.packageList" border stripe
                    :header-cell-style="rowClass" style="width: 800px;">
            <el-table-column label="序号" type="index" align="center" width="50px" />
            <el-table-column prop="upgradeGoodsName" align="center" label="商品名称"></el-table-column>
            <el-table-column prop="thumbUrl" align="center" label="商品图">

              <template slot-scope="scope">
                <img :src="scope.row.thumbUrl" style="width: 50px; height: 50px" />
              </template>
            </el-table-column>
            <el-table-column prop="sellPrice" align="center" label="价格">

              <template slot-scope="scope">
                <span>{{ scope.row.sellPrice }}</span>
              </template>
            </el-table-column>
          </el-table>
          <el-table v-if="periodItemForm.selectPackageType == 1" :data="periodItemForm.packageList" border stripe
                    :header-cell-style="rowClass" style="width: 750px;">
            <el-table-column label="序号" type="index" align="center" width="50px" />
            <el-table-column prop="upgradeGoodsName" align="center" label="商品名称"></el-table-column>
            <el-table-column prop="thumbUrl" align="center" label="商品图">

              <template slot-scope="scope">
                <img :src="scope.row.thumbUrl" style="width: 50px; height: 50px" />
              </template>
            </el-table-column>
            <el-table-column prop="sellPrice" align="center" label="价格">

              <template slot-scope="scope">
                <span>{{ scope.row.sellPrice }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="conversionRate" align="center" label="目标转化率">

              <template slot-scope="scope">
                <!-- <span>{{ scope.row.goodsInfo.shopPrice }}</span> -->
                <!-- -->
                <!-- <el-form-item :prop="`periodItem.packageList[${scope.index}].conversionRate`"
                  :rules="[{ required: true, message: `请输入目标转化率`, trigger: 'change' }]"> -->
                <el-input v-model="scope.row.conversionRate" style="width: 70px;"
                          @input="(e) => { handleUpgradeNumTable(e, 'conversionRate', 0, scope.$index,) }">
                  <i slot="suffix" style="font-style:normal;">%</i>
                </el-input>
                <!-- </el-form-item> -->
              </template>
            </el-table-column>
            <el-table-column prop="conversionRatePercentage" align="center" label="提成系数">

              <template slot-scope="scope">
                <!-- <span>{{ scope.row.goodsInfo.shopPrice }}</span> -->
                <el-input v-model="scope.row.conversionRatePercentage"
                          @input="(e) => { handleUpgradeNumTable(e, 'conversionRatePercentage', 0, scope.$index,) }"
                          style="width: 70px;">
                  <i slot="suffix" style="font-style:normal;">%</i>
                </el-input>
              </template>
            </el-table-column>
            <el-table-column prop="customerUnitPrice" align="center" label="目标客单价">

              <template slot-scope="scope">
                <!-- <span>{{ scope.row.goodsInfo.shopPrice }}</span> -->
                <el-input v-model="scope.row.customerUnitPrice"
                          @input="(e) => { handleUpgradeNumTable(e, 'customerUnitPrice', 3, scope.$index,) }"
                          style="width: 70px;">
                  <i slot="suffix" style="font-style:normal;">元</i>
                </el-input>
              </template>
            </el-table-column>
            <el-table-column prop="customerUnitPricePercentage" align="center" label="提成系数">

              <template slot-scope="scope">
                <!-- <span>{{ scope.row.goodsInfo.shopPrice }}</span> -->
                <el-input v-model="scope.row.customerUnitPricePercentage"
                          @input="(e) => { handleUpgradeNumTable(e, 'customerUnitPricePercentage', 0, scope.$index,) }"
                          style="width: 70px;">
                  <i slot="suffix" style="font-style:normal;">%</i>
                </el-input>
              </template>
            </el-table-column>
          </el-table>
        </el-form-item>
        <div v-if="periodItemForm.selectPackageType != '1'">
          <el-form-item label="目标转化率" :rules="[{ required: true, message: '请输入目标转化率', trigger: ['blur', 'change'] },]"
                        prop="conversionRate" required>
            <el-input v-model="periodItemForm.conversionRate" @input="(e) => { handleUpgradeNum(e, 'conversionRate') }"
                      style="width: 300px;">
              <i slot="suffix" style="font-style:normal;">%</i>
            </el-input>
          </el-form-item>
          <el-form-item label="提成系数" :rules="[{ required: true, message: '请输入提成系数', trigger: ['blur', 'change'] }]"
                        prop="conversionRatePercentage" required>
            <el-input v-model="periodItemForm.conversionRatePercentage"
                      @input="(e) => { handleUpgradeNum(e, 'conversionRatePercentage') }" style="width: 300px;">
              <i slot="suffix" style="font-style:normal;">%</i>
            </el-input>
          </el-form-item>
          <el-form-item label="目标客单价" :rules="[{ required: true, message: '请输入目标客单价', trigger: ['blur', 'change'] }]"
                        prop="customerUnitPrice" required>
            <el-input v-model="periodItemForm.customerUnitPrice"
                      @input="(e) => { handleUpgradeNum(e, 'customerUnitPrice') }" style="width: 300px;">
              <i slot="suffix" style="font-style:normal;">元</i>
            </el-input>
          </el-form-item>
          <el-form-item label="提成系数" :rules="[{ required: true, message: '请输入提成系数', trigger: ['blur', 'change'] }]"
                        prop="customerUnitPricePercentage" required>
            <el-input v-model="periodItemForm.customerUnitPricePercentage"
                      @input="(e) => { handleUpgradeNum(e, 'customerUnitPricePercentage') }" style="width: 300px;">
              <i slot="suffix" style="font-style:normal;">%</i>
            </el-input>
          </el-form-item>
        </div>

      </el-form>
      <div class="footer">
        <el-button @click="submitPeriodItem" type="primary">保存</el-button>
        <el-button @click="drawerShow = false">取消</el-button>

      </div>
    </el-drawer>
    <selectGoodsTypeDialog :store-config-con-obj-search-obj="storeConfigConObjSearchObj"
                           :goods-type-list="periodItemForm.goodsTypeList" :dialog-visible.sync="dialogVisible"
                           @handleAddConfirm="handleAddConfirmSelectGoodsType" v-if="dialogVisible">
    </selectGoodsTypeDialog>
    <selectGoodsDialog :store-config-con-obj-search-obj="storeConfigConObjSearchObj" :period-item-form="periodItemForm"
                       :package-list="periodItemForm.packageList" :goods-type-list="periodItemForm.goodsTypeList"
                       :dialog-visible.sync="goodsDialogVisible" @handleAddConfirm="handleAddConfirmSelectGoods"
                       v-if="goodsDialogVisible">
    </selectGoodsDialog>
    <selectCarDialog v-if="carDialogVisible" :single-choice="false" @handleClose="handleClose"
                     :echo-data="echoData || []" @handleConfirm="handleConfirm" :dialog-visible="carDialogVisible">
    </selectCarDialog>
  </div>
</template>

<script>
import { deepClone } from '@/common/util'
import { limitPrice } from '@/common/format'

// import { getCarInfo } from '@api/editCustomer'
import selectCarDialog from './selectCarDialog'
import selectGoodsTypeDialog from './selectGoodsTypeDialog'
import selectGoodsDialog from './selectGoodsDialog'
const defaultFormValue = {
  // defaultFlag: 'Y',
  // checkMonth: '1',
  // checkPeriod: '1',
  selectCarType: '0',
  selectGoodsType: '0',
  selectPackageType: '0',
  conversionRate: '',
  conversionRatePercentage: '',
  customerUnitPrice: '',
  customerUnitPricePercentage: ''
}
export default {
  name: 'DrawerPeriodItemEdit',
  components: {
    selectGoodsTypeDialog,
    selectGoodsDialog,
    selectCarDialog
  },
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    storeConfigConObjSearchObj: {
      type: Object,
      default: () => ({})
    },
    periodItem: {
      type: Object,
      default: () => ({})
    },
    mode: {
      type: String,
      default: 'add'
    }

  },
  data() {
    return {
      carDialogVisible: false,
      dialogVisible: false,
      goodsDialogVisible: false,
      baseData: {
        MonthList: [{
          value: 1,
          label: '首月'
        },
        {
          value: 2,
          label: '次月'
        },
        {
          value: 3,
          label: '第三月'
        }]
      },
      direction: 'rtl',
      // form: this.$form.createForm(this),
      periodItemForm: {
        defaultFlag: 'Y',
        checkMonth: 1,
        checkPeriod: 1,
        defaultFormValue
        // selectCarType: [],
      },
      rulesItem: {
        checkMonth: [{ required: true, message: '请选择月度', trigger: 'change' }],
        checkPeriod: [{ required: true, message: '请选择周期', trigger: 'change' }],
        selectCarType: [{ required: true, message: '请选择车主类型', trigger: 'change' },
          {
            validator: (rule, value, callback) => {
              console.log(value, this.periodItemForm, "value")
              if (value && value == 2 && (this.periodItemForm?.carList && this.periodItemForm?.carList.length == 0)) {
                callback(new Error('请选择车辆类型'))
              } else {
                callback()
              }
            },
            trigger: 'change'
          }
        ],
        selectGoodsType: [{ required: true, message: '请选择商品分类', trigger: 'change' }, {
          validator: (rule, value, callback) => {
            console.log(this.periodItemForm?.goodsTypeList && this.periodItemForm?.goodsTypeList.length == 0)
            console.log(value, this.periodItemForm, "value")
            if (value && (!this.periodItemForm?.goodsTypeList || (this.periodItemForm?.goodsTypeList && this.periodItemForm?.goodsTypeList.length == 0))) {
              callback(new Error('请选择商品分类'))
            } else {
              callback()
            }
          },
          trigger: 'change'
        }],
        selectPackageType: [{ required: true, message: '请选择主推产品套餐', trigger: 'change' }, {
          validator: (rule, value, callback) => {
            console.log(value, this.periodItemForm, "value")
            if (value && (!this.periodItemForm?.packageList || this.periodItemForm?.packageList.length == 0)) {
              callback(new Error('请选择商品'))
            } else {
              callback()
            }
          },
          trigger: 'change'
        }],
        conversionRate: [{ required: true, message: '请输入目标转化率', trigger: 'change' }]
        // conversionRatePercentage: [{ required: true, message: '请输入提成系数', trigger: 'change' }],
        // customerUnitPrice: [{ required: true, message: '请输入目标客单价', trigger: 'change' }],
        // customerUnitPricePercentage: [{ required: true, message: '请输入提成系数', trigger: 'change' }]
      },
      oldVal: {
        conversionRate: '',
        conversionRatePercentage: '',
        customerUnitPrice: '',
        customerUnitPricePercentage: ''
      }
    }
  },
  computed: {
    drawerShow: {
      get() {
        return this.visible
      },
      set(val) {
        this.$emit('update:visible', val)
      }
    },
    echoData() {
      let list = []
      if (this.periodItemForm.carList) {
        list = this.periodItemForm.carList.map(item => {
          if (!item.brandId) {
            item.brandId = item.carBrandId
            item.brandName = item.carBrand
            item.childBrandId = item.carChildsBrandId
            item.childBrandName = item.carChildsBrandName
            item.vehicleSeriesId = item.carSeriesId
            item.vehicleSeriesName = item.carSeriesName
          }
          return item
        })
      }
      return list
    }
  },
  watch: {
    periodItem: {
      handler(val) {
        this.periodItemForm = deepClone(val)
      },
      deep: true
    },
    visible(val) {
      if (val) {
        this.$refs.periodItem && this.$refs.periodItem.resetFields()
      }
    }
  },
  methods: {
    restPackageList() {
      console.log(this.periodItemForm.selectGoodsType, 'this.periodItemForm.selectGoodsType')
      if (this.periodItemForm.selectGoodsType == 1) {
        this.periodItemForm = {
          ...this.periodItemForm,
          packageList: [],
          conversionRate: '',
          conversionRatePercentage: '',
          customerUnitPrice: '',
          customerUnitPricePercentage: ''
        }
      }
    },
    handleConfirm(list) {
      this.periodItemForm.carList = this.extractArrays(list).map(item => {
        item.carBrandId = item.rootId
        item.carBrand = item.rootName
        item.carChildsBrandId = item.parentId
        item.carChildsBrandName = item.parentName
        item.carSeriesId = item.id
        item.carSeriesName = item.name
        return item
      })
      this.handleClose()
      this.$nextTick(() => {
        this.$refs.periodItem.validateField('selectCarType')
      })
      console.log(this.periodItemForm.carList)
    },
    handleClose() {
      this.carDialogVisible = false
    },
    selectCarDialog() {
      this.carDialogVisible = true
    },
    extractArrays(obj) {
      var result = []

      function traverse(obj) {
        for (var key in obj) {
          if (typeof obj[key] === 'object' && obj[key] !== null) {
            if (Array.isArray(obj[key])) {
              result = result.concat(obj[key])
            } else {
              traverse(obj[key])
            }
          }
        }
      }

      traverse(obj)
      return result
    },
    // selectCarTypeChange () {
    //   if (this.periodItemForm.selectCarType == 1) {
    //     this.carDialogVisible = true
    //   }
    // },
    restPackList() {
      // this.periodItemForm.packageList = []
      this.periodItemForm = {
        ...this.periodItemForm,
        packageList: [],
        conversionRate: '',
        conversionRatePercentage: '',
        customerUnitPrice: '',
        customerUnitPricePercentage: ''
      }
    },
    handleUpgradeNumTable(newValue, name, type, index) {
      // 'expenseCategoryValue'
      // expenseCategoryValue
      // debugger
      console.log(name, this.periodItemForm[index], "this.classificationObj")
      // let valueName
      // if (ChildrenIndex != undefined) {
      //   valueName = this.classificationObj[name][index].children[ChildrenIndex]
      // } else {
      // }
      const valueName = this.periodItemForm.packageList[index]
      console.log(valueName, "valueName")
      // debugger
      // const obj = this.classificationObj[name][index]
      // console.log(obj)
      // // obj.expenseCategoryValue = newValue
      // // this.$set(this.classificationObj[name], index, obj)
      // return
      newValue = newValue.replace(/[^\d.]/g, "") // 清除“数字”和“.”以外的字符
      console.log(newValue)
      console.log(name, "name", type, "type", index, "index")
      // const handleName = this.classificationObj[name][index]
      // 按金额
      if (type == 3) {
        // this.classificationObj[name][index].expenseCategoryValue = limitPrice(newValue, this.accountSecondSetForm[name], 10, 2)
        valueName[name] = limitPrice(
          newValue,
          valueName[name],
          10,
          2
        )
        // 按百分比
      } else {
        // console.log(newValue)
        // 验证第一个字符是数字
        newValue = newValue.replace(/^\./g, "")
        // 只保留第一个, 清除多余的
        newValue = newValue.replace(/\.{2,}/g, ".")
        newValue = newValue
          .replace(".", "$#$")
          .replace(/\./g, "")
          .replace("$#$", ".")
        // 只能输入两个小数
        // eslint-disable-next-line no-useless-escape
        newValue = newValue.replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3")
        // 先去除这个最大100 的校验
        if (newValue > 1000) newValue = 999

        if (newValue < 0) newValue = 0
        console.log(newValue)
        valueName[name] = newValue
        // this.$set(this.classificationObj[name][index], 'expenseCategoryValue', newValue)
        // console.log(this.classificationObj[name][index].expenseCategoryValue)
      }
      this.$forceUpdate() // 强制更新
    },
    handleAddConfirmSelectGoods(list) {
      console.log(list, 'handleAddConfirmSelectGoods')
      // const newList = [...list, ...this.periodItemForm.packageList]
      // //  根据id去重
      // const obj = {}
      // const setList = newList.reduce((cur, next) => {
      //   obj[next.id] ? "" : obj[next.id] = true && cur.push(next)
      //   return cur
      // }, [])
      if (this.periodItemForm.selectPackageType == '1') {
        // this.periodItemForm.packageList = deepClone(list)
        list = list.map(item => {
          this.periodItemForm?.packageList && this.periodItemForm.packageList.map(ele => {
            // 有就取原来的值,没有就取空
            if (item.merchantGoodsId == ele.merchantGoodsId) {
              item.conversionRate = ele.conversionRate
              item.conversionRatePercentage = ele.conversionRatePercentage
              item.customerUnitPrice = ele.customerUnitPrice
              item.customerUnitPricePercentage = ele.customerUnitPricePercentage
            }
          })
          return {
            conversionRate: '',
            conversionRatePercentage: '',
            customerUnitPrice: '',
            customerUnitPricePercentage: '',
            ...item
          }
        })
      } else {
        // this.periodItemForm.packageList = deepClone(list)
      }
      this.periodItemForm.packageList = deepClone(list)
      this.$nextTick(() => {
        console.log(this.periodItemForm.goodsTypeList, 'this.periodItemForm.goodsTypeList')
        this.$refs.periodItem.validateField('selectPackageType')
      })
    },
    handleAddConfirmSelectGoodsType(list) {
      list.map(item => {
        item.goodsTypeName = item.categoryName
        item.goodsType = item.categoryType
        // delete item.categoryName
        // delete item.categoryType
      })
      this.periodItemForm.goodsTypeList = deepClone(list)
      this.$nextTick(() => {
        this.restPackageList()
        console.log(this.periodItemForm.goodsTypeList, 'this.periodItemForm.goodsTypeList')
        this.$refs.periodItem.validateField('selectGoodsType')
      })
    },
    selectGoodsTypeDialog() {
      this.dialogVisible = true
    },
    validateStart(rule, value, callback) {
      if (this.periodItemForm.maxCarPrice) {
        this.$refs.periodItem.validateField('endObj')
      }
      callback()
    },
    validateEnd(rule, value, callback) {
      if (this.periodItemForm.minCarPrice) {
        if (Number(this.periodItemForm.minCarPrice) < Number(value)) {
          callback()
        } else {
          callback(new Error('最高价格必须大于最小价格'))
        }
      } else {
        callback()
      }
    },
    restData() {
      this.periodItemForm = {
        ...this.periodItemForm,
        defaultFormValue
      }
    },
    // selectGoodsType() {

    // },
    // 设置表头的颜色
    rowClass({ row, rowIndex }) {
      // console.log(rowIndex) // 表头行标号为0
      return 'background:#F4F6FC'
    },
    // handleUpgradeNumPrice(newVal, name) {
    //   console.log('newVal', newVal, name)
    //   this.periodItemForm[name] = limitPrice(parseInt(newVal), this.oldVal[name], 5, 2, parseInt(this.periodItemForm.minCarPrice || 0), 999999)
    //   this.oldVal[name] = deepClone(this.periodItemForm[name])
    // },
    handleUpgradeNum(newVal, name) {
      console.log('newVal', newVal, name)
      let maxLength = 3
      let maxNum = 1000
      if (['customerUnitPrice', 'minCarPrice', 'maxCarPrice'].includes(name)) {
        maxLength = 6
        maxNum = 999999
      }
      this.periodItemForm[name] = limitPrice(newVal, this.oldVal[name], maxLength, 2, 0, maxNum)
      this.oldVal[name] = deepClone(this.periodItemForm[name])
    },
    handleCancel() {
      this.$emit('cancel')
    },
    handleOk() {
      this.form.validateFields((err, values) => {
        if (!err) {
          this.$emit('ok', this.periodItemForm)
        }
      })
    },
    submitPeriodItem() {
      this.$refs.periodItem.validate(valid => {
        console.log('valid', valid)
        if (valid) {
          this.drawerShow = false
          this.$emit('submitPeriodItem', this.periodItemForm)
        }
      })
    }
  }

}
</script>

<style lang="scss" scoped>
.inputCon {
  display: flex;
}

.shoppingCartDrawerCon {

  // position: relative;
  ::v-deep.el-drawer__header {
    border-bottom: 1px solid #e7eaec;
    margin-bottom: 20px;
    padding-bottom: 10px;
    font-weight: 600;
    font-size: 20px;
  }

  ::v-deep.el-drawer__body {
    // padding: 0 20px;
    overflow: auto;
  }

  .footer {
    text-align: center;
  }
}
</style>