index.vue 14.1 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
<!-- 调拨发货 -->
<template>
  <div class="purchase transferShipment">
    <div class="container">
      <GLCombiForm ref="showSearch" :rowNumber="1" :formObj="searchForm" :formData="showFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
      <div class="table-header">
        <h2>调拨发货</h2>
        <div>
          <GLButton type="primary" plain size="small" @click="batchShipment" fn="批量发货">批量发货</GLButton>
        </div>
      </div>

      <GLTable ref="transferShipmentTable" :searchForm="tableSearchForm" :tableParams="tableParams" :pageConf="pageConf" :getListApi="getListApi" :beforeSearchFn="beforeSearchFn" @selectionTable="handleSelectionChange">
        <template slot="receiver" slot-scope="scope">
          <div v-if="scope.scope.receiver">
            <el-popover v-if="scope.scope.receiver.length > 12" placement="top" effect="dark" width="300" trigger="hover">
              <div class="merchant-name-box">
                {{ spanFilter(scope.scope.receiver) }}
              </div>
              <template #reference>
                <div>
                  {{ spanFilter(scope.scope.receiver, 12) }}
                </div>
              </template>
            </el-popover>
            <div v-else>
              {{ scope.scope.receiver }}
            </div>
          </div>
          <span v-else>-</span>
        </template>
        <template slot="address" slot-scope="scope">
          <div v-if="scope.scope.address">
            <el-popover v-if="scope.scope.address.length > 12" placement="top" effect="dark" width="300" trigger="hover">
              <div class="merchant-name-box">
                {{ spanFilter(scope.scope.address) }}
              </div>
              <template #reference>
                <div>
                  {{ spanFilter(scope.scope.address, 12) }}
                </div>
              </template>
            </el-popover>
            <div v-else>
              {{ scope.scope.address }}
            </div>
          </div>
          <span v-else>-</span>
        </template>
        <div class="table-btns" slot="auth-button" slot-scope="scope">
          <el-button :data="scope.scope" type="text" size="small" @click="handleDetail(scope.scope)">查看</el-button>

          <el-button v-if="scope.scope.deliveryStatus != 2 && scope.scope.billStatus != 7" :data="scope.scope" type="text" size="small" @click="handleShipment(scope.scope)">发货</el-button>

          <el-button v-if="scope.scope.billStatus != 7 && scope.scope.deliveryStatus == 1" :data="scope.scope" type="text" size="small" @click="handleReject(scope.scope)">驳回</el-button>
        </div>
      </GLTable>
    </div>
    <shipment-dialog :shipment-visible="shipmentVisible" :table-list="shipmentTableList" :params-obj="shipmentDialogData" v-if="shipmentVisible" @shipmentClose="shipmentDialogClose" />
    <reject-dialog :reject-visible="rejectVisible" :reject-data="rejectData" v-if="rejectVisible" @rejectClose="handleRejectClose" />
    <transfer-detail-dialog :visible="transferDetailVisible" :params-obj="transferObj" v-if="transferDetailVisible" @dialogClose="handleTransferDetailClose" />
  </div>
</template>

<script>
import transferDetailDialog from './components/transferDetailDialog.vue'
import RejectDialog from './components/rejectDialog.vue'
import shipmentDialog from './components/shipmentDialog.vue'

export default {
  name: 'TransferShipment',
  components: {
    ShipmentDialog: shipmentDialog,
    'shipment-dialog': shipmentDialog,
    RejectDialog,
    'reject-dialog': RejectDialog,
    TransferDetailDialog: transferDetailDialog,
    'transfer-detail-dialog': transferDetailDialog
  },
  data() {
    return {
      searchForm: {
        queryCallOutMerchant: true,
        allocateCode: '',
        callInName: '',
        deliveryStatus: '',
        goodsName: '',
        productCode: '',
        purchaseOrderCode: ''
      },
      tableSearchForm: {},
      tableData: [],
      pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
      showFormData: [
        {
          label: '调拨单号',
          name: 'allocateCode',
          type: 'input',
          isClear: true
        },
        {
          label: '调入方',
          name: 'callInName',
          type: 'input',
          isClear: true
        },
        {
          label: '发货状态',
          name: 'deliveryStatus',
          type: 'select',
          optionList: [],
          optionId: 'confId',
          optionLabel: 'confLabel',
          optionsName: 'deliveryStatusOptions'
        },
        {
          label: '产品名称',
          name: 'goodsName',
          type: 'input',
          isClear: true
        },
        {
          label: '产品编码',
          name: 'productCode',
          type: 'input',
          isClear: true
        },
        {
          label: '采购单号',
          name: 'purchaseOrderCode',
          type: 'input',
          isClear: true
        },
        {
          label: '产品ID',
          name: 'commodityCode',
          type: 'input',
          isClear: true,
          maxlength: 20
        }
      ],
      getListApi: this.$apis.stockManage.getTransferShipmentList,
      // 表格参数
      tableParams: {
        btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
        listName: 'list',
        mutiSelectUniqueKey: 'id',
        mutiSelectName: 'list',
        checkSelectable: (row, index) => this.selectableFn(row, index),
        tableOption: {
          width: '160'
        },
        tableColumns: [
          {
            label: '调拨单号',
            prop: 'allocateCode',
            width: 150
          },
          {
            label: '关联采购单号',
            prop: 'purchaseOrderCode',
            width: 150
          },
          {
            label: '产品名称',
            prop: 'goodsName',
            width: 120
          },
          {
            label: '产品ID',
            prop: 'commodityCode',
            width: 120
          },
          {
            label: '产品编码',
            prop: 'productCode',
            width: 120
          },
          {
            label: '规格',
            prop: 'specificationData'
          },
          {
            label: '系列',
            prop: 'sourceMaterialName'
          },
          {
            label: '所属分类',
            prop: 'goodsTypeName'
          },
          {
            label: '调拨数量',
            prop: 'allocateNumber',
            formatter: cellValue => {
              const qty = cellValue.allocateNumber ?? '-'
              const unit = this.$membraneTypeList.includes(cellValue.goodsType) ? '米' : '件'
              return qty === '-' ? '-' : `${qty}${unit}`
            }
          },
          {
            label: '调拨人',
            prop: 'createdBy'
          },
          {
            label: '调入门店',
            prop: 'callInMerchantName'
          },
          {
            label: '调入仓库',
            prop: 'callInYqMerchantName'
          },
          {
            label: '调出门店',
            prop: 'callOutMerchantName'
          },
          {
            label: '调出仓库',
            prop: 'callOutYqMerchantName'
          },
          {
            label: '收货人',
            prop: 'receiver',
            width: 120,
            addHtml: 'receiver'
          },
          {
            label: '收货人电话',
            prop: 'phone',
            width: 130
          },
          {
            label: '收货地址',
            prop: 'address',
            width: 120,
            addHtml: 'address'
          },
          {
            label: '发货状态',
            prop: 'deliveryStatus',
            formatter: cellValue => {
              return this.baseData.deliveryStatusOptions.find(item => item.confId === `${cellValue.deliveryStatus}`)?.confLabel || '-'
            },
            className: cellValue => {
              return {
                1: 'ashSpot',
                2: 'greenSpot',
                3: 'yellowSpot'
              }[cellValue.deliveryStatus]
            }
          },
          {
            label: '订单状态',
            prop: 'billStatus',
            formatter: cellValue => {
              return this.baseData.billStatusOptions.find(item => item.confId == cellValue.billStatus)?.confLabel || '-'
            },
            className: cellValue => {
              return {
                5: 'greenSpot',
                7: 'redSpot'
              }[cellValue.billStatus]
            }
          }
        ]
      },
      // 查看
      transferDetailVisible: false,
      // 驳回
      rejectVisible: false,
      // 发货
      shipmentVisible: false,
      // 基本数据
      baseData: {
        deliveryStatusOptions: [
          {
            confId: '1',
            confLabel: '未发货'
          },
          {
            confId: '3',
            confLabel: '部分发货'
          },
          {
            confId: '2',
            confLabel: '全部发货'
          }
        ],
        billStatusOptions: [
          {
            confId: '5',
            confLabel: '已审核'
          },
          {
            confId: '7',
            confLabel: '已驳回'
          }
        ]
      },
      paramsObj: {},
      selectedList: [],
      shipmentTableList: [],
      shipmentDialogData: {},
      rejectData: {}
    }
  },
  watch: {
    rejectVisible(val) {
      if (!val) {
        this.rejectData = {}
        this.$nextTick(() => {
          this.auditDetaiList = []
          this.$refs['delivery-dialog-form'] && this.$refs['delivery-dialog-form'].clearValidate()
        })
      }
    }
  },

  mounted() {
    this.getBaseData()
  },

  methods: {
    getBaseData() {
      const allOpt = {
        confId: '',
        confLabel: '全部'
      }
      this.showFormData.forEach((item, index) => {
        if (item.type === 'select' && this.baseData[item.optionsName]) {
          this.baseData[item.optionsName].unshift(allOpt)
          this.$set(this.showFormData[index], 'optionList', this.baseData[item.optionsName])
        }
      })
    },
    spanFilter(ele, lenght) {
      if (ele) {
        const text = `${ele}`
        return lenght ? (text?.length > lenght ? text.substring(0, lenght) + '\u2026' : text.substring(0, lenght)) : text
      } else {
        return '-'
      }
    },
    selectableFn(row, index) {
      if (this.selectedList.length) {
        return this.selectedList?.some(val => val.allocateCode == row.allocateCode) && (row.deliveryStatus == 1 || row.deliveryStatus == 3)
      } else {
        return row.deliveryStatus == 1 || row.deliveryStatus == 3
      }
    },
    handleSelectionChange(selection) {
      this.selectedList = selection
    },

    beforeSearchFn() {
      return new Promise(resolve => {
        this.tableSearchForm = this.getParams()
        resolve()
      })
    },
    getParams() {
      let params = this.$common.utils.deepClone(this.searchForm)
      return params
    },
    handleSearch() {
      this.$refs.transferShipmentTable.refreshTable(true)
    },
    handleReset() {
      for (const key in this.searchForm) {
        this.searchForm[key] = ''
      }
      this.searchForm.queryCallOutMerchant = true
      this.$refs.transferShipmentTable.refreshTable(true)
    },
    handleExport() {
      let params = this.tableSearchForm
      // params.method = 'dj.api.smarcarlife.purchaseOrder.export.async'
      params.method = 'dj.api.life.operatorreview.exportExcel.async'
      const list = [
        ...this.dowloadList,
        {
          name: '调拨发货',
          exportParam: JSON.stringify(params),
          status: 'waiting',
          timeid: new Date().getTime()
        }
      ]
      this.actionSetDownloadList({ list, type: 'dowloadList' })
    },
    batchShipment() {
      if (!this.selectedList.length) {
        // 未选择
        this.$message.error('请选择要发货的订单')
        return
      }
      const target = this.selectedList[0]
      this.shipmentTableList = this.$common.utils.deepClone(this.selectedList)
      this.shipmentDialogData.callOutYqMerchantName = target.callOutYqMerchantName
      this.shipmentDialogData.callOutMerchantName = target.callOutMerchantName
      this.shipmentDialogData.callInYqMerchantName = target.callInYqMerchantName
      this.shipmentDialogData.callInMerchantName = target.callInMerchantName
      this.shipmentDialogData.remark = target.remark
      this.shipmentDialogData.allocateCode = target.allocateCode
      this.shipmentVisible = true
    },
    shipmentDialogClose(obj) {
      this.shipmentVisible = false
      this.$refs.transferShipmentTable.refreshTable(true)
    },
    // 查看详情
    handleDetail(row) {
      this.transferObj = {
        allocateCode: row.allocateCode,
        merchantName: row.merchantName,
        purchaseType: row.purchaseType
      }
      this.transferDetailVisible = true
    },
    // 发货
    handleShipment(row) {
      this.shipmentTableList = [row]
      this.shipmentDialogData.callOutYqMerchantName = row.callOutYqMerchantName
      this.shipmentDialogData.callOutMerchantName = row.callOutMerchantName
      this.shipmentDialogData.callInYqMerchantName = row.callInYqMerchantName
      this.shipmentDialogData.callInMerchantName = row.callInMerchantName
      this.shipmentDialogData.remark = row.remark
      this.shipmentDialogData.allocateCode = row.allocateCode
      this.shipmentVisible = true
    },
    // 驳回
    handleReject(row) {
      this.rejectData = {
        allocateCode: row.allocateCode
      }
      this.rejectVisible = true
    },
    handleRejectClose(obj) {
      this.rejectVisible = false
      this.$refs.transferShipmentTable.refreshTable(true)
    },
    // 查看详情弹窗关闭
    handleTransferDetailClose() {
      this.transferDetailVisible = !this.transferDetailVisible
    }
  }
}
</script>

<style lang="scss" scoped>
@import '@/assets/css/mixin.scss';
.transferShipment {
  .table-header {
    @include space-between_center;
    margin-bottom: 10px;
    h2 {
      font-weight: 600;
      font-size: 16px;
      color: #333;
    }
  }
  .table-btns {
    display: flex;
    align-items: center;
  }
}

::v-deep .el-table__header-wrapper .has-gutter .el-checkbox {
  display: none;
}
</style>