| | |
| | | :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type:'checkbox'}" |
| | | @change="handleTableChange"> |
| | | |
| | | <template v-for="col in columns" :slot="col.dataIndex" slot-scope="text, record, index"> |
| | | <div :key="col.dataIndex"> |
| | | |
| | | <a-input-number |
| | | v-if="col.dataIndex === 'ratedLife'" |
| | | :disabled="record.accuracyClass !== '1'" |
| | | :value="text" |
| | | @change="(e) => handleChange(e, record.key, col, index)" |
| | | :min="1" |
| | | /> |
| | | <div v-if="col.dataIndex === 'ratedLife' && record.accuracyClass === '1' && isFieldEmpty(record.ratedLife)" |
| | | style="color: #ff4d4f; font-size: 12px;"> |
| | | 必填 |
| | | </div> |
| | | |
| | | <a-input-number |
| | | v-if="col.dataIndex === 'useLife'" |
| | | :disabled="record.accuracyClass !== '1'" |
| | | :value="text" |
| | | @change="(e) => handleChange(e, record.key, col, index)" |
| | | :min="1" |
| | | /> |
| | | <div v-if="col.dataIndex === 'useLife' && record.accuracyClass === '1' && isFieldEmpty(record.useLife)" |
| | | style="color: #ff4d4f; font-size: 12px;"> |
| | | 必填 |
| | | </div> |
| | | |
| | | </div> |
| | | </template> |
| | | |
| | | <span slot="action" slot-scope="text, record"> |
| | | <a @click="handleOutbound(record)">出库</a> |
| | | </span> |
| | |
| | | align:"left", |
| | | dataIndex: 'outboundQuantity' |
| | | }, |
| | | { |
| | | title:'额定寿命', |
| | | align:"center", |
| | | dataIndex: 'ratedLife', |
| | | scopedSlots: { customRender: 'ratedLife' }, |
| | | }, |
| | | { |
| | | title:'使用寿命', |
| | | align:"center", |
| | | dataIndex: 'useLife', |
| | | scopedSlots: { customRender: 'useLife' }, |
| | | }, |
| | | // { |
| | | // title:'已出库数量', |
| | | // align:"left", |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | isFieldEmpty(value) { |
| | | return value === undefined || value === null || value === ''; |
| | | }, |
| | | onSelectChange(selectedRowKeys, selectionRows) { |
| | | this.selectedRowKeys = selectedRowKeys; |
| | | this.selectionRows = selectionRows; |
| | |
| | | this.ipagination.current = 1 |
| | | }, |
| | | handleOutbound(record) { |
| | | console.log(this.mainId) |
| | | console.log(record) |
| | | // 先进行必填校验 |
| | | const errors = this.validateRequiredFields(record); |
| | | if (errors.length > 0) { |
| | | this.$message.error(errors.join(',')); |
| | | return; |
| | | } |
| | | const params = [ |
| | | { |
| | | outBoundOrderId: this.mainId, |
| | | outboundDetailId: record.id, |
| | | outboundQuantity: record.outboundQuantity |
| | | outboundQuantity: record.outboundQuantity, |
| | | ratedLife: record.ratedLife, |
| | | useLife: record.useLife |
| | | } |
| | | ] |
| | | postAction(this.url.outbound, params).then(res=>{ |
| | |
| | | this.$message |
| | | } |
| | | }) |
| | | }, |
| | | handleChange(value, key, column, index) { |
| | | console.log(value, key, column, index) |
| | | const temp = [...this.dataSource] |
| | | const target = temp.filter(item => key === item.key)[index]; |
| | | if (target) { |
| | | target[column.dataIndex] = value |
| | | this.dataSource = temp |
| | | } |
| | | }, |
| | | validateRequiredFields(record) { |
| | | const errors = []; |
| | | // 只有在不禁用状态下才需要校验必填 |
| | | if (record.accuracyClass === '1') { |
| | | if (this.isFieldEmpty(record.ratedLife)) { |
| | | errors.push('额定寿命为必填项'); |
| | | } |
| | | if (this.isFieldEmpty(record.useLife)) { |
| | | errors.push('使用寿命为必填项'); |
| | | } |
| | | } |
| | | return errors; |
| | | } |
| | | |
| | | } |
| | | } |
| | | </script> |