|
@@ -45,7 +45,8 @@
|
|
|
class="sTable"
|
|
|
ref="chooseTable"
|
|
|
size="small"
|
|
|
- :rowKey="(record,i) => i"
|
|
|
+ :rowKey="(record,i) => record.sparePartsDetailSn"
|
|
|
+ rowKeyName="sparePartsDetailSn"
|
|
|
:row-selection="{ columnWidth: 40,getCheckboxProps: record => ({ props: { disabled: record.currentStockQty == 0 || record.isCheckedFlag} }) }"
|
|
|
@rowSelection="rowSelectionFun"
|
|
|
:columns="columns"
|
|
@@ -120,7 +121,7 @@ export default {
|
|
|
isZero: 0
|
|
|
},
|
|
|
warehousingDate: [], // 入库时间
|
|
|
- selectArr: null,
|
|
|
+ rowSelectionInfo: null,
|
|
|
isChecked: false,
|
|
|
repeatList: null,
|
|
|
// 加载数据方法 必须为 Promise 对象
|
|
@@ -150,7 +151,7 @@ export default {
|
|
|
{ title: '产品编码', dataIndex: 'product.code', width: '24%', align: 'center', customRender: function (text) { return text || '--' } },
|
|
|
{ title: '产品名称', dataIndex: 'product.name', width: '27%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
|
|
|
{ title: '单位', dataIndex: 'product.unit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
|
|
|
- { title: '批次号', dataIndex: 'sparePartsBatchNo', width: '24%', align: 'center', customRender: function (text) { return text || '--' } },
|
|
|
+ { title: '批次号', dataIndex: 'sparePartsBatchNo', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
|
|
|
{ title: '入库数量', dataIndex: 'productQty', width: '9%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
|
|
|
{ title: '已退数量', dataIndex: 'returnedQty', width: '9%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
|
|
|
{ title: '最大可退数量', dataIndex: 'currentStockQty', width: '9%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
|
|
@@ -158,12 +159,12 @@ export default {
|
|
|
{ title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
|
|
|
]
|
|
|
if (this.$hasPermissions('B_isShowCost')) {
|
|
|
- arr.splice(6, 0, { title: '入库单价', dataIndex: 'productCost', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? toThousands(text, 2) : '--') } })
|
|
|
+ arr.splice(6, 0, { title: '入库单价', dataIndex: 'productCost', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? toThousands(text, 2) : '--') } })
|
|
|
}
|
|
|
return arr
|
|
|
},
|
|
|
selNums () {
|
|
|
- return this.selectArr && this.selectArr.length || 0
|
|
|
+ return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length || 0
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
@@ -194,9 +195,15 @@ export default {
|
|
|
},
|
|
|
// 添加
|
|
|
handleAdd (row) {
|
|
|
- if (this.selectArr && this.selectArr.length > 0) {
|
|
|
- const pot = this.selectArr.findIndex(item => { return item.sparePartsDetailSn == row.sparePartsDetailSn })
|
|
|
- this.selectArr.splice(pot, 1)
|
|
|
+ const selectArr = this.rowSelectionInfo ? this.rowSelectionInfo.selectedRowKeys : null
|
|
|
+ if (selectArr && selectArr.length > 0) {
|
|
|
+ const pot = selectArr.findIndex(item => { return item == row.sparePartsDetailSn })
|
|
|
+ selectArr.splice(pot, 1)
|
|
|
+ const index = this.rowSelectionInfo.selectedRows.findIndex(item => { return item.sparePartsDetailSn == row.sparePartsDetailSn })
|
|
|
+ this.rowSelectionInfo.selectedRows.splice(index, 1)
|
|
|
+ this.$nextTick(() => { // 页面渲染完成后的回调
|
|
|
+ this.$refs.chooseTable.setTableSelected(selectArr, this.rowSelectionInfo.selectedRows) // 设置表格选中项
|
|
|
+ })
|
|
|
}
|
|
|
this.$emit('add', row)
|
|
|
},
|
|
@@ -204,16 +211,17 @@ export default {
|
|
|
refreshLength (row) {
|
|
|
this.$refs.chooseTable.clearSelected()
|
|
|
},
|
|
|
+ // 表格选中项
|
|
|
rowSelectionFun (obj) {
|
|
|
- this.selectArr = obj.selectedRows
|
|
|
+ this.rowSelectionInfo = obj || null
|
|
|
},
|
|
|
// 批量添加
|
|
|
handleBatchAdd () {
|
|
|
- if (!this.selectArr) {
|
|
|
+ if (this.rowSelectionInfo.selectedRowKeys.length == 0) {
|
|
|
this.$message.warning('请先选择要添加的产品!')
|
|
|
return
|
|
|
}
|
|
|
- this.$emit('bachAdd', this.selectArr)
|
|
|
+ this.$emit('bachAdd', this.rowSelectionInfo.selectedRows)
|
|
|
},
|
|
|
getRepeatResult (sn) {
|
|
|
queryDetailSnListBySn({ sn }).then(res => {
|