SaveShippingRecord6JQuery.vue 12.2 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
<template>
  <a-card :bordered='false'>
    <!-- 操作按钮区域 -->
    <div class='table-operator'>
      <a-button v-has="'inventoryDetail:export'" type='primary' icon='download' @click="handleExportXls('发运记录')">
        导出
      </a-button>
      <a-button type='primary' icon='download' @click="downloadFile('saveShippingRecord6JQuery.xls')">6J码查询发运记录模板下载
      </a-button>
      <a-upload name='file' :showUploadList='false' :multiple='false'
                :headers='tokenHeader' :action='saveShippingRecord6JQuery'
                @change='handleImportUniqueList'>
        <a-button type='primary' icon='import'>导入6J码查询发运记录</a-button>
      </a-upload>
    </div>
    <!-- table区域-begin -->
    <div>
      <a-table
        ref='table'
        size='middle'
        :scroll='{x:true}'
        bordered
        rowKey='id'
        :columns='columns'
        :dataSource='dataSource'
        :loading='loading'
        :pagination="false"
        :rowSelection='{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, fixed: true}'
        class='j-table-force-nowrap'>
        <template slot="title" slot-scope="currentPageData">
          {{ `共 ${collectInv(currentPageData).snSize} 个6J码, ${collectInv(currentPageData).sumQty} 根` }}
        </template>
        <span slot='companyCode' slot-scope='companyCode'>
          <a-tag :key='companyCode' color='blue'>
            {{ solutionCompany(companyCode) }}
          </a-tag>
        </span>
        <span slot='zoneCode' slot-scope='zoneCode'>
          <a-tag :key='zoneCode' color='blue'>
            {{ solutionZoneCode(zoneCode) }}
          </a-tag>
        </span>
      </a-table>
    </div>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import {mixinDevice} from '@/utils/mixin'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import {getCompanyList, getZoneList} from '@api/api'
import {postAction} from '@/api/manage'


export default {
  name: "SaveShippingRecord6JQuery.vue",
  mixins: [JeecgListMixin, mixinDevice],
  components: {
  },
  data() {
    return {
      description: '序列号查询库存页面',
      companyList: [],
      zoneList: [],
      // 表头
      columns: [{
        title: '#',
        dataIndex: '',
        key: 'rowIndex',
        width: 60,
        align: 'center',
        customRender: function (t, r, index) {
          return parseInt(index) + 1
        }
      },
        {
          title: '出库单号',
          align: 'center',
          dataIndex: 'shipmentCode'
        },
        {
          title: 'DN号',
          align: 'center',
          dataIndex: 'referCode'
        },
        {
          title: '托序列号',
          align: 'center',
          dataIndex: 'tuoSerialNumber'
        },
        {
          title: '箱序列号',
          align: 'center',
          dataIndex: 'boxSerialNumber'
        },
        {
          title: '箱号',
          align: 'center',
          dataIndex: 'uniqueCode'
        },
        {
          title: '安波福号',
          align: 'center',
          dataIndex: 'materialCode'
        },
        {
          title: '物料名称',
          align: 'center',
          dataIndex: 'materialName'
        },
        {
          title: '客户料号',
          align: 'center',
          dataIndex: 'customMaterialCode'
        },
        {
          title: '数量',
          align: 'center',
          dataIndex: 'qty'
        },
        {
          title: '托标签1面',
          align: 'center',
          dataIndex: 'largeBlackCodeA'
        },
        {
          title: '托标签2面',
          align: 'center',
          dataIndex: 'largeBlackCodeB'
        },
        {
          title: '托标签3面',
          align: 'center',
          dataIndex: 'largeBlackCodeC'
        },
        {
          title: '托标签4面',
          align: 'center',
          dataIndex: 'largeBlackCodeD'
        },
        {
          title: '客户码1',
          align: 'center',
          dataIndex: 'customCode1'
        },
        {
          title: '客户码2',
          align: 'center',
          dataIndex: 'customCode2'
        },
        {
          title: '混托序列号a面',
          align: 'center',
          dataIndex: 'mixedTuoSerialNumberA'
        },
        {
          title: '混托序列号b面',
          align: 'center',
          dataIndex: 'mixedTuoSerialNumberB'
        },
        {
          title: '混托序列号c面',
          align: 'center',
          dataIndex: 'mixedTuoSerialNumberC'
        },
        {
          title: '混托序列号d面',
          align: 'center',
          dataIndex: 'mixedTuoSerialNumberD'
        },
        {
          title: '扫描日期',
          align: 'center',
          dataIndex: 'createTime'
        },
        {
          title: '扫描人',
          align: 'center',
          dataIndex: 'createBy'
        }
      ],
      url: {
        exportXlsUrl: 'saveShippingRecord/saveShippingRecord/exportXls',
        saveShippingRecord6JQuery: 'saveShippingRecord/saveShippingRecord/saveShippingRecord6JQuery'
      },
      dictOptions: {},
      selectRecord: [],
    }
  },
  created() {
    this.loadFrom()
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
    saveShippingRecord6JQuery: function () {
      return `${window._CONFIG['domianURL']}/${this.url.saveShippingRecord6JQuery}`
    }
  },
  methods: {
    collectInv(data) {
      if (data === null || data === undefined || data.length === 0) {
        return {
          snSize: 0,
          sumQty: 0,
        }
      } else {
        return {
          snSize: data.length,
          sumQty: data.map(x => x.qty).reduce((prev, curr) => {
            return prev + curr
          }),
        }
      }
    },
    loadData() {
    },
    refreshData() {
      let snList = this.dataSource.map(t => t.uniqueCode);
      postAction(this.url.getInventoryDetailBySnList, snList).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records || res.result;
        } else {
          this.$message.warning(res.message)
        }
      }).finally(() => {
      })
    },
    loadFrom() {
      getCompanyList().then((res) => {
        if (res.success) {
          this.companyList = res.result
        }
      })
      getZoneList().then((res) => {
        if (res.success) {
          this.zoneList = res.result
        }
      })
    },
    solutionZoneCode(value) {
      let actions = []
      Object.keys(this.zoneList).some((key) => {
        if (this.zoneList[key].code === ('' + value)) {
          actions.push(this.zoneList[key].name)
          return true
        }
      })
      return actions.join('')
    },
    solutionCompany(value) {
      let actions = []
      Object.keys(this.companyList).some((key) => {
        if (this.companyList[key].code === ('' + value)) {
          actions.push(this.companyList[key].name)
          return true
        }
      })
      return actions.join('')
    },
    onSelectChange(selectedRowKeys, record) {
      this.selectedRowKeys = selectedRowKeys
      this.selectRecord = record
    },
    quickShipment() {
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录!')
      } else {
        let zoneCodes = this.selectRecord.map(row => row.zoneCode)
        if (new Set(zoneCodes).size !== 1) {
          this.$message.warning('所选数据非同库区')
          return
        }
        if ('D' !== this.selectRecord[0].zoneCode) {
          this.$refs.QuickShipmentModel.model.containerCode = this.selectRecord[0].containerCode
          this.$refs.QuickShipmentModel.edit()
          this.$refs.QuickShipmentModel.title = '选择出库口'
        } else {
          this.quickShipmentModalFormOk(null)
        }
      }
    },
    quickShipmentModalFormOk(params) {
      let that = this
      if (params !== '') {
        that.loading = true
        postAction(that.url.quickShipment, {ids: that.selectedRowKeys, outPortCode: params}).then((res) => {
          that.$message.warning(res.message)
          that.onClearSelected()
          that.refreshData();
        }).finally(() => {
          that.loading = false
        })
      }
    },
    handleImportUniqueList(info) {
      this.loading = false
      if (info.file.status === 'done') {
        if (info.file.response.success) {
          let res = info.file.response
          this.dataSource = res.result.records || res.result
          this.$message.success(info.file.response.message)
        } else {
          this.$message.error(`${info.file.name} ${info.file.response.message}.`)
        }
      }
    },
    batchLock: function () {
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录!')
      } else {
        this.$refs.LockMaterialModel.edit()
        this.$refs.LockMaterialModel.isLock = true
      }
    },
    lockMaterialModelFormOk(isLock, lockBillCode, lockReason) {
      let that = this
      that.loading = true
      let url = isLock ? this.url.batchLock : this.url.batchGood
      postAction(url, {
        lockBillCode: lockBillCode,
        lockReason: lockReason,
        inventoryDetailIds: this.selectedRowKeys
      }).then((res) => {
        if (res.success) {
          that.$message.success(res.message)
          that.onClearSelected()
          this.refreshData();
        } else {
          that.$message.warning(res.message)
          this.selectedRowKeys = []
        }
      }).finally(() => {
        that.loading = false;
      })
    },
    batchGood() {
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录!')
      } else {
        if (this.selectedRowKeys.length <= 0) {
          this.$message.warning('请选择一条记录!')
        } else {
          this.$refs.LockMaterialModel.edit()
          this.$refs.LockMaterialModel.isLock = false
        }
      }
    },
    scrap() {
      let record = this.selectRecord
      if (record.length <= 0) {
        this.$message.warning('请选择一条记录!')
      } else {
        try {
          record.forEach((x) => {
            if (x.zoneCode !== 'F') {
              throw new Error('报废失败,只能报废成品地面库的库存!')
            }
            if (x.inventoryStatus !== 'lock') {
              throw new Error('报废失败,只能报废红牌状态的库存!')
            }
          })
        } catch (e) {
          this.$message.warning(e.message)
          return;
        }
        let that = this
        this.$confirm({
          title: '确认报废',
          content: '是否报废选中数据?',
          onOk: function () {
            that.loading = true
            postAction(that.url.scrap, that.selectedRowKeys).then((res) => {
              if (res.success) {
                that.$message.success(res.message)
                that.onClearSelected()
                that.refreshData();
              } else {
                that.$message.warning(res.message)
              }
            }).finally(() => {
              that.loading = false
            })
          }
        })
      }
    },
    returnLabel() {
      let record = this.selectRecord
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录!')
      } else {
        try {
          record.forEach((x) => {
            if (x.zoneCode !== 'F') {
              throw new Error('退标签失败,只能退掉成品地面库的库存!')
            }
          })
        } catch (e) {
          this.$message.warning(e.message)
          return;
        }
        this.$refs.returnLabelModel.edit()
      }
    },
    returnLabelModelFormOk(returnLabelReason) {
      let that = this
      that.loading = true
      postAction(that.url.returnLabel, {
        inventoryDetailIds: that.selectedRowKeys,
        returnLabelReason: returnLabelReason
      }).then((res) => {
        if (res.success) {
          that.$message.success(res.message)
          that.onClearSelected()
          that.refreshData();
        } else {
          that.$message.warning(res.message)
        }
      }).finally(() => {
        that.loading = false
      })
    },
  }

}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>