add.vue 25.6 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 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773
<template>
  <div class="addWrap" v-loading="loading">
    <div class="d2-container-content">
      <div style="padding: 10px 20px">
        <el-form :inline="true" size="small" :model="editAllocationForm" ref="editAllocationFormRef" :rules="formRules" class="demo-form-inline">
          <el-form-item>调出方:</el-form-item>
          <el-form-item label="调出仓库:" prop="callOutYqMerchantId">
            <el-select v-model="editAllocationForm.callOutYqMerchantId" style="width: 300px" filterable>
              <el-option v-for="item in callOutYqMerchantList" :key="item.merchantNo" :label="item.merchantName" :value="item.merchantNo" />
            </el-select>
          </el-form-item>
          <el-form-item label="调出门店:" prop="callOutMerchantId">
            <el-select v-model="editAllocationForm.callOutMerchantId" filterable style="width: 300px">
              <el-option v-for="item in callOutMerchantList" :key="item.merchantId" :label="item.merchantName" :value="item.merchantId" />
            </el-select>
          </el-form-item>
          <br />
          <el-form-item>调入方:</el-form-item>
          <el-form-item label="调入仓库:" prop="callInYqMerchantId">
            <el-select v-model="editAllocationForm.callInYqMerchantId" filterable @change="changeCallInYqMerchant(editAllocationForm.callInYqMerchantId)" style="width: 300px">
              <el-option v-for="item in callInYqMerchantList" :key="item.merchantNo" :label="item.merchantName" :value="item.merchantNo" />
            </el-select>
          </el-form-item>
          <el-form-item label="调入门店:" prop="callInMerchantId">
            <el-select v-model="editAllocationForm.callInMerchantId" filterable style="width: 300px">
              <el-option v-for="item in callInMerchantList" :key="item.merchantId" :label="item.merchantName" :value="item.merchantId" />
            </el-select>
          </el-form-item>
        </el-form>
      </div>
      <div>
        <div class="gl-form-min">
          <div>调拨列表</div>
          <el-form :inline="true" size="small" :model="editAllocationForm">
            <el-form-item label="调拨:">
              <el-input v-model="searchForm.upgradeGoodsNameOrSeries" style="width: 200px" placeholder="请输入产品名称/系列" maxlength="20" clearable />
            </el-form-item>
            <el-button @click="handleSearch" size="small" type="primary">查询</el-button>
          </el-form>
        </div>
      </div>
      <GLTable ref="allocationTable" :getListApi="getListApi" :pageConf="pageConf" :searchForm="searchFormSearch" :tableParams="tableParams" :beforeSearchFn="beforeSearchFn" @setTableFinishFun="setTableFinishFun">
        <div slot="auth-button" slot-scope="scope">
          <el-button type="text" @click="allocation(scope.scope)" :disabled="setDisabled(scope.scope)">选择</el-button>
        </div>
      </GLTable>
    </div>
    <div class="d2-container-content">
      <p class="title">调拨确认单</p>
      <GLTable ref="allocationTable2" :tableData="chooseDataList" :tableParams="tableParams2" :hasPage="false">
        <div slot="auth-button" slot-scope="scope">
          <el-button type="text" @click="cancelAllocation(scope.scope, scope.index)">取消</el-button>
        </div>
      </GLTable>
    </div>
    <div class="addRefundForm">
      <!-- <glsx-form ref="allocationForm" :rules="allocationFormRules" :origin-data="editData" :form-list="editForm" form-ref="inveFormRef" @handleAddConfirm="handleAddConfirm" @handleClose="handleAddClose"></glsx-form> -->
      <glsx-form ref="allocationFormRef" :rules="allocationFormRules" :origin-data="editData" :form-list="editForm" form-ref="inveFormRef" :isShowBtn="false"></glsx-form>
    </div>
    <div style="margin-top: 40px;text-align: center;">
      <el-button class="btn" @click="handleAddClose">
        取消
      </el-button>
      <el-button @click="beforeConfirm('save')" class="btn" plain>
        保存
      </el-button>
      <el-button @click="beforeConfirm('invalid')" class="btn" plain v-if="oprType == 'edit'">
        作废
      </el-button>
      <el-button @click="beforeConfirm('review')" type="primary" class="btn">
        提交审核
      </el-button>
    </div>
    <!-- 盘点 -->
    <allocation-num-dialog :allocation-num-visible="allocationNumVisible" :allocation-info="allocationInfo" v-if="allocationNumVisible" @dialogClose="dialogClose" />
  </div>
</template>

<script>
import allocationNumDialog from './allocationNumDialog'
// import { membraneTypeList } from '@/utils/constants.js'
export default {
  name: 'allocationList',
  components: {
    allocationNumDialog
  },
  data() {
    return {
      oprType: 'add',
      routeInfo: {},
      loading: false,
      // isDisabled: false,
      // 编辑首次进
      editFirst: false,
      editMerFirst: false,
      callOutYqMerchantList: [],
      callInYqMerchantList: [],
      callOutMerchantList: [],
      callInMerchantList: [],
      // membraneTypeList: membraneTypeList,
      searchForm: {
        queryOtherMerchant: true,
        upgradeGoodsNameOrSeries: '',
        stockFlag: true
      },
      searchFormSearch: {},
      searchSelectObj: {},
      showFormData: [
        {
          // label: '产品名称/系列',
          placeholder: '请输入产品名称/系列',
          name: 'upgradeGoodsNameOrSeries',
          type: 'input',
          maxlength: '20',
          isClear: true
        }
      ],
      // getListApi: this.$apis.stockManage.stockRemainPage,
      getListApi: null,
      pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: true,
        tableColumns: [
          {
            label: '产品名称',
            prop: 'upgradeGoodsName'
          },
          {
            label: '产品ID',
            prop: 'commodityCode'
          },
          {
            label: '规格',
            prop: 'specificationData',
            width: 180,
            line: 1
          },
          {
            label: '产品编码',
            prop: 'productCode',
            width: '250px'
          },
          {
            label: '系列',
            prop: 'goodsSeries'
          },
          {
            label: '所属分类',
            prop: 'goodsTypeName'
          },
          // {
          //   label: '库存',
          //   prop: 'stock',
          //   formatter: cellValue => {
          //     return cellValue.stock || cellValue.stock == 0 ? parseFloat(cellValue.stock).toFixed(2) + (this.$membraneTypeList.includes(cellValue.goodsType) ? '米' : '件') : '-'
          //   }
          // },
          {
            label: '所属仓库',
            prop: 'yqMerchantName'
          },
          {
            label: '所属门店',
            prop: 'merchantName'
          },
          {
            label: '膜卷号',
            prop: 'filmRollNo'
          }
        ]
      },
      tableParams2: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: true,
        tableColumns: [
          {
            label: '产品名称',
            prop: 'goodsName'
          },
          {
            label: '产品ID',
            prop: 'commodityCode'
          },
          {
            label: '规格',
            prop: 'specificationData',
            width: 180,
            line: 1
          },
          {
            label: '产品编码',
            prop: 'productCode',
            width: '250px'
          },
          {
            label: '系列',
            prop: 'sourceMaterialName'
          },
          {
            label: '所属分类',
            prop: 'goodsTypeName'
          },
          // {
          //   label: '库存',
          //   prop: 'outStockQty',
          //   formatter: cellValue => {
          //     return cellValue.outStockQty || cellValue.outStockQty == 0 ? parseFloat(cellValue.outStockQty).toFixed(2) + (this.$membraneTypeList.includes(cellValue.goodsType) ? '米' : '件') : '-'
          //   }
          // },
          {
            label: '调拨库存',
            prop: 'allocateNumber ',
            formatter: cellValue => {
              return cellValue.allocateNumber || cellValue.allocateNumber == 0 ? parseFloat(cellValue.allocateNumber).toFixed(2) + (this.$membraneTypeList.includes(cellValue.goodsType) ? '米' : '件') : '-'
            }
          },
          {
            label: '膜卷号',
            prop: 'filmRollNo'
          }
        ]
      },

      editData: {
        receiver: '',
        phone: '',
        address: '',
        remark: ''
      },
      editForm: [
        {
          formBlock: [
            {
              name: 'receiver',
              label: '收货人',
              type: 'input',
              maxlength: 30,
              width: '284px',
              placeholder: '请输入'
            },
            {
              name: 'phone',
              label: '收货人电话',
              type: 'input',
              maxlength: 12,
              width: '284px',
              placeholder: '请输入'
            },
            {
              name: 'address',
              label: '收货地址',
              type: 'input',
              maxlength: 30,
              width: '284px',
              placeholder: '请输入'
            },
            {
              name: 'remark',
              label: '备注说明',
              width: '432px',
              type: 'textarea',
              rows: 5,
              maxlength: 200,
              placeholder: '请输入'
            }
          ]
        }
      ],

      editAllocationForm: {
        callOutYqMerchantId: '', //调出仓库
        callOutMerchantId: '', //调出门店
        callInYqMerchantId: '', //调入仓库
        callInMerchantId: '' //调入门店
      },

      allocationNumVisible: false,
      allocationInfo: null,
      chooseDataList: [],
      formRules: {
        callOutYqMerchantId: [
          {
            required: true,
            message: '请选择调出仓库',
            trigger: 'change'
          }
        ],
        callOutMerchantId: [
          {
            required: true,
            message: '请选择调出门店',
            trigger: 'change'
          }
        ],
        callInYqMerchantId: [
          {
            required: true,
            message: '请选择调入仓库',
            trigger: 'change'
          }
        ],
        callInMerchantId: [
          {
            required: true,
            message: '请选择调入门店',
            trigger: 'change'
          }
        ]
      },
      allocationFormRules: {
        receiver: [
          {
            required: true,
            message: '请输入收货人',
            trigger: 'change'
          },
          {
            pattern: /^[\u4e00-\u9fa5a-zA-Z0-9]+$/,
            message: '收货人仅支持输入字母、中文和数字',
            trigger: 'change'
          }
        ],
        phone: [
          {
            required: true,
            message: '请输入收货人电话',
            trigger: 'change'
          },
          {
            pattern: /^\d+$/,
            message: '收货人电话仅支持输入数字',
            trigger: 'change'
          }
        ],
        address: [
          {
            required: true,
            message: '请输入收货地址',
            trigger: 'change'
          },
          {
            pattern: /^[\u4e00-\u9fa5a-zA-Z0-9]+$/,
            message: '收货地址仅支持输入字母、中文和数字',
            trigger: 'change'
          }
        ]
      },
      oldyqMerchantId: '', //之前选择的调出仓库
      oldMerchantId: '', //之前选择的调出门店
      //保存/作废/提交审核,弹窗提示和状态值适配
      btnTypeMap: {
        save: {
          title: '提示',
          confirmMsg: '调拨单保存后,系统自动按照调拨数量对调出和调入门店进行库存更新;是否确定保存?',
          billStatus: 0
        },
        invalid: {
          title: '调拨申请作废确定',
          confirmMsg: '作废后无法恢复调拨单,是否确认作废?',
          billStatus: '-1'
        },
        review: {
          title: '提交确定',
          confirmMsg: '调拨申请单,确认提交申请?',
          billStatus: 1
        }
      }
    }
  },
  created() {
    // if (window.__POWERED_BY_QIANKUN__) {
    //   this.callOutYqMerchantList = [{ merchantNo: this.$globalState.session.merchantId + '', merchantName: this.$globalState.session.merchantName }]
    // }
  },
  watch: {
    'editAllocationForm.callOutYqMerchantId'(val, oldval) {
      // console.log(val, oldval, '监听callOutYqMerchantId')
      // this.getListApi = this.$apis.stockManage.stockRemainPage
      if (this.callOutYqMerchantList.length == 1) {
        //当只有一个选项时不弹提示框
        // this.$refs.allocationTable.refreshTable()
      } else {
        if (val != this.oldyqMerchantId) {
          //与之前的选项不一样
          if (!this.editFirst) {
            this.editAllocationForm.callOutMerchantId = ''
            this.switchData(val, oldval, 'yqMerchant')
          }
          this.editFirst = false
        }
      }
    },

    'editAllocationForm.callOutMerchantId'(val, oldval) {
      console.log(val, oldval, '监听callOutMerchantId')
      this.getListApi = this.$apis.stockManage.stockRemainPage
      if (this.callOutMerchantList.length == 1) {
        //当只有一个选项时不弹提示框
        this.$refs.allocationTable.refreshTable()
      } else {
        if (val != this.oldMerchantId) {
          //与之前的选项不一样
          if (!this.editMerFirst) {
            this.switchData(val, oldval, 'merchant')
          }
          this.editMerFirst = false
        }
      }
    }
  },
  mounted() {
    this.routeInfo = this.$route.query?.row || {}
    console.log(this.routeInfo)
    if (this.routeInfo?.id) {
      this.oprType = 'edit'
      this.editFirst = true
      this.editMerFirst = true
      // this.isDisabled = true
      this.getDetail()
    }
    // 调入仓库
    this.$apis.stockManage.getyqMerchantList({ mainPartnerMerchant: true }).then(res => {
      this.callInYqMerchantList = this.$common.utils.deepClone(res)
      if (this.callInYqMerchantList && this.callInYqMerchantList.length == 1 && this.oprType == 'add') {
        this.editAllocationForm.callInYqMerchantId = this.callInYqMerchantList[0].merchantNo
        this.getServicemerchantrefList(this.editAllocationForm.callInYqMerchantId, 'in')
      }
    })
    //调出仓库
    this.$apis.stockManage.getyqMerchantPageList({ currentPage: 1, pageSize: 10000 }).then(res => {
      this.callOutYqMerchantList = this.$common.utils.deepClone(res.list)
      if (this.callOutYqMerchantList && this.callOutYqMerchantList.length == 1 && this.oprType == 'add') {
        this.editAllocationForm.callOutYqMerchantId = this.callOutYqMerchantList[0].merchantNo
        this.getServicemerchantrefList(this.editAllocationForm.callOutYqMerchantId, 'out')
      }
    })
  },

  methods: {
    beforeSearchFn() {
      return new Promise(resolve => {
        this.editAllocationForm.yqMerchantId = this.editAllocationForm.callOutYqMerchantId
        this.editAllocationForm.merchantId = this.editAllocationForm.callOutMerchantId
        let _form = {
          ...this.searchForm,
          yqMerchantId: this.editAllocationForm.yqMerchantId,
          merchantId: this.editAllocationForm.merchantId,
          callOutMerchantId: this.editAllocationForm.callOutMerchantId,
          callOutYqMerchantId: this.editAllocationForm.callOutYqMerchantId,
          callInMerchantId: this.editAllocationForm.callInMerchantId,
          callInYqMerchantId: this.editAllocationForm.callInYqMerchantId
        }
        this.searchFormSearch = this.$common.utils.deepClone(_form)
        resolve()
      })
    },
    setTableFinishFun() {
      this.$refs.allocationTable?.data.forEach(val => {
        val.goodsId = val.upgradeGoodsId
        val.outStockQty = val.stock
      })
    },
    handleSearch() {
      this.getListApi = this.$apis.stockManage.stockRemainPage
      this.$refs.allocationTable.refreshTable()
    },
    // 获取仓库门店
    getServicemerchantrefList(merchantId, type) {
      this.$apis.stockManage
        .getServicemerchantrefList({
          yqMerchantId: merchantId
        })
        .then(res => {
          res.forEach((item, idx) => {
            res[idx].merchantId = item.merchantId + ''
          })
          if (type == 'out') {
            this.callOutMerchantList = res || []
            //总店
            let _headOffice = this.callOutYqMerchantList.find(item => item.merchantNo === merchantId)
            _headOffice.merchantId = _headOffice.merchantNo
            //门店选项中加入总店
            this.callOutMerchantList.push(_headOffice)
            if (this.callOutMerchantList && this.callOutMerchantList.length == 1) {
              this.editAllocationForm.callOutMerchantId = this.callOutMerchantList[0].merchantId
            }
          } else if (type == 'in') {
            this.callInMerchantList = res || []
            //总店
            let _headOffice = this.callInYqMerchantList.find(item => item.merchantNo === merchantId)
            _headOffice.merchantId = _headOffice.merchantNo
            //门店选项中加入总店
            this.callInMerchantList.push(_headOffice)
            if (this.callInMerchantList && this.callInMerchantList.length == 1) {
              this.editAllocationForm.callInMerchantId = this.callInMerchantList[0].merchantId
            }
          }
        })
    },

    switchData(val, oldval, type) {
      if (this.chooseDataList && this.chooseDataList.length > 0) {
        //当盘存确认单有数据时提示
        this.$confirm('切换调出仓库和调出门店,自动重置已调拨内容;是否确定切换?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            if (type == 'yqMerchant') {
              this.getServicemerchantrefList(val, 'out')
            } else {
              //选择门店以后才更新盘存数据
              this.$refs.allocationTable.refreshTable()
            }
            //清空调拨确认单数据
            this.chooseDataList = []
          })
          .catch(err => {
            console.log(err)
            if (type == 'yqMerchant') {
              //调出仓库
              this.editAllocationForm.callOutYqMerchantId = oldval
              this.oldyqMerchantId = oldval
            } else if (type == 'merchant') {
              //调出门店
              this.editAllocationForm.callOutMerchantId = oldval
              this.oldMerchantId = oldval
            }
          })
      } else {
        if (type == 'yqMerchant') {
          this.getServicemerchantrefList(val, 'out')
        } else {
          //选择门店以后才更新盘存数据
          this.$refs.allocationTable.refreshTable()
        }
      }
    },

    changeCallInYqMerchant(merchantId) {
      this.editAllocationForm.callInMerchantId = ''
      this.getServicemerchantrefList(merchantId, 'in')
    },

    // 调拨
    allocation(row) {
      this.allocationInfo = row
      this.allocationNumVisible = true
    },

    //设置禁选
    setDisabled(row) {
      const index = this.chooseDataList.findIndex(item => item.goodsId == row.goodsId && item.filmRollNo === row.filmRollNo)
      if (index == -1) {
        return false
      } else {
        return true
      }
    },

    dialogClose(chooseData) {
      this.allocationNumVisible = !this.allocationNumVisible
      console.log(chooseData)
      if (chooseData) {
        chooseData = this.fieldConvert(chooseData)
        this.chooseDataList.push(chooseData)
      }
    },

    //选择的数据与提交数据之间的字段转换
    fieldConvert(obj) {
      obj.goodsId = obj.upgradeGoodsId
      obj.goodsName = obj.upgradeGoodsName
      obj.sourceMaterialName = obj.goodsSeries
      return obj
    },
    getDetail() {
      this.$apis.stockManage
        .stockAllocateInfo({
          allocateCode: this.routeInfo.allocateCode
        })
        .then(res => {
          console.log(res)
          this.routeInfo.id = res.id
          this.editAllocationForm = res
          this.editAllocationForm.callOutYqMerchantId = this.editAllocationForm.callOutYqMerchantId + ''
          this.editAllocationForm.callInYqMerchantId = this.editAllocationForm.callInYqMerchantId + ''
          this.editAllocationForm.callOutMerchantId = this.editAllocationForm.callOutMerchantId + ''
          this.editAllocationForm.callInMerchantId = this.editAllocationForm.callInMerchantId + ''
          this.chooseDataList = res.stockAllocateDetailList
          // this.getListApi = this.$apis.stockManage.stockRemainPage
          this.chooseDataList.forEach((item, idx) => {
            this.setDisabled(item)
          })
          // this.editData.receiver = res.receiver || ''
          // this.editData.phone = res.phone || ''
          // this.editData.address = res.address || ''
          // this.editData.remark = res.remark || ''
          Object.assign(this.editData, res)
          // console.log(this.editData, 'this.editData')
          this.getServicemerchantrefList(this.editAllocationForm.callOutYqMerchantId, 'out')
          this.getServicemerchantrefList(this.editAllocationForm.callInYqMerchantId, 'in')
          this.$refs.allocationTable.refreshTable()
        })
    },

    // 取消
    cancelAllocation(row, index) {
      this.chooseDataList = this.chooseDataList.filter(item => !(item.goodsId == row.goodsId && item.filmRollNo === row.filmRollNo))
    },

    /** 保存/作废/提交申请之前,表单校验等
     * 按钮类型 - 单据状态
     * 保存按钮(save) - 1:待提交
     * 提交审核按钮(review) - 2:待总部审核
     * 作废按钮(invalid) - 5:作废
     **/
    beforeConfirm(btnType = 'save') {
      const p1 = new Promise(resolve => {
        this.$refs.editAllocationFormRef.validate(valid => {
          resolve(valid)
        })
      })
      const p2 = new Promise(resolve => {
        this.$refs.allocationFormRef.$refs.inveFormRefd2FormRuleForm.validate(valid => {
          resolve(valid)
        })
      })
      Promise.all([p1, p2]).then(([valid1, valid2]) => {
        if (valid1 && valid2) {
          if (this.chooseDataList.length == 0) {
            this.$message.error('请选择调拨商品')
            return
          }
          const data = this.$refs.allocationFormRef.formData
          var params = {}
          params = {
            ...params,
            ...this.editAllocationForm,
            receiver: data.receiver || '',
            phone: data.phone || '',
            address: data.address || '',
            remark: data.remark || ''
          }
          params.stockCheckDetailList = this.chooseDataList
          console.log(params, 'params')
          // 调不同按钮的方法
          this.handleConfirm(params, btnType)
        }
      })
    },

    saveApi(params, btnType = 'save') {
      const tipTxtObj = {
        save: '保存成功',
        review: '提交审核成功',
        invalid: '作废成功'
      }
      this.loading = true
      this.$apis.stockManage[this.routeInfo.id ? 'updateStockAllocate' : 'saveStockAllocate'](params)
        .then(res => {
          this.$notify({
            type: res.code == 0 ? 'success' : 'error',
            title: res.code == 0 ? tipTxtObj[btnType] || '操作成功' : res.message
          })
          if (res.code == 0) {
            if (btnType == 'save') {
              this.routeInfo.allocateCode = res.data
              this.oprType = 'edit'
              this.editFirst = true
              this.editMerFirst = true
              // this.isDisabled = true
              this.getDetail()
            } else {
              this.handleAddClose()
            }
          }
        })
        .finally(() => {
          this.loading = false
        })
    },

    /** 保存/作废/审核提交,弹窗提示不一样
     * 按钮类型 - 单据状态
     * 保存按钮(save) - 创建 - 0:待提交
     * 提交审核按钮(review) - 1:待审核
     * 作废按钮(invalid) - -1:作废
     **/
    handleConfirm(params, btnType = 'save') {
      if (this.loading) {
        return true
      }
      const btnObj = this.btnTypeMap[btnType]
      params.billStatus = btnObj.billStatus
      if (btnType == 'save') {
        this.saveApi(params, btnType)
      } else {
        this.$confirm(btnObj.confirmMsg, btnObj.title, {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            this.saveApi(params, btnType)
          })
          .catch(err => {
            console.log(err)
          })
      }
    },

    handleAddClose(isRefresh = false) {
      this.$router.go(-1)
    }
  }
}
</script>
<style lang="scss" scoped>
.d2-container-content {
  background: #fff;
  padding: 20px;
  margin-bottom: 20px;
}
.gl-form-min {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #333333;
  font-size: 16px;
  margin-right: 104px;
  .el-form--inline .el-form-item {
    margin-right: 8px;
  }
}
.count-txt {
  font-weight: 700;
  color: #2a58ad;
  margin: 0 2px;
}

.title {
  font-weight: 600;
  font-size: 16px;
  color: #333333;
  padding: 17px 0;
}

.leftSpan {
  display: inline-block;
  box-sizing: border-box;
  margin-right: 10px;
}

.addRefundForm {
  /deep/.d2-container-content {
    padding: 0px;
  }
  /deep/.d2-form .d2-form-block {
    border-bottom: none !important;
    padding: 16px 20px 0;
  }
}
.btn {
  height: 32px;
  border-radius: 4px;
  padding: 7.5px 18px;
}
</style>