<template>
|
<j-modal
|
:title="title"
|
:width="width"
|
:visible="visible"
|
:confirmLoading="confirmLoading"
|
switchFullscreen
|
@ok="handleOk"
|
@cancel="handleCancel"
|
cancelText="关闭">
|
<a-spin :spinning="confirmLoading">
|
<a-form-model ref="form" :model="model" :rules="validatorRules">
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="classifyNum" label="工具分类编码">
|
<a-input placeholder="请输入工具分类编码" v-model="model.classifyNum" :disabled="true" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="classifyName" label="工具分类名称">
|
<a-input placeholder="请输入工具分类名称" v-model="model.classifyName" :disabled="true" />
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item label="出库类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="outStorehouseType">
|
<j-dict-select-tag :disabled="disableSubmit" @change="handleTypeChange" type="list" v-model="model.outStorehouseType" dictCode="out_storehouse_type" placeholder="请选择出库类型" />
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
</a-form-model>
|
</a-spin>
|
|
<a-button v-show="selectBorrowTool" type="primary" :style="{ marginBottom: '8px' }" @click="selectBorrowOutBoundTool">选择出库工具</a-button>
|
<a-button v-show="selectSharpenTool" type="primary" :style="{ marginBottom: '8px' }" @click="selectSharpenOutBoundTool">选择刃磨工具</a-button>
|
<a-table
|
ref="table"
|
size="middle"
|
bordered
|
rowKey="id"
|
:scroll="{x:true}"
|
:columns="columns"
|
:dataSource="dataSource"
|
:pagination="ipagination"
|
:loading="loading"
|
:rowSelection="null"
|
@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 === 'outboundQuantity'"
|
:disabled="record.accuracyClass === '1'"
|
:value="text"
|
@change="(e) => handleChange(e, record.key, col, index)"
|
:min="1"
|
/>
|
<a-input-number
|
v-if="col.dataIndex === 'ratedLife'"
|
:disabled="record.accuracyClass != '1'"
|
:value="text"
|
@change="(e) => handleChange(e, record.key, col, index)"
|
:min="1"
|
/>
|
<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>
|
</template>
|
<span slot="action" v-if="disableSubmit === false" slot-scope="text, record, index">
|
<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record, index)">
|
<a>删除</a>
|
</a-popconfirm>
|
</span>
|
</a-table>
|
<template slot="footer" v-if="disableSubmit === false">
|
<a-button :style="{ marginRight: '8px' }" @click="handleCancel">关闭</a-button>
|
<a-button @click="handleOk" :disabled="isDisabled" type="primary">出库</a-button>
|
</template>
|
|
<j-select-borrow-outbound-tool-modal ref="selectBorrowOutBoundToolModal"></j-select-borrow-outbound-tool-modal>
|
<j-select-sharpen-outbound-tool-modal ref="selectSharpenOutBoundToolModal"></j-select-sharpen-outbound-tool-modal>
|
</j-modal>
|
|
</template>
|
|
<script>
|
|
import { validateDuplicateValue } from '@/utils/util'
|
import OutboundDetailList from '../../OutboundDetailList.vue'
|
import JSelectBorrowOutboundToolModal from './JSelectBorrowOutboundToolModal.vue'
|
import JSelectSharpenOutboundToolModal from './JSelectSharpenOutboundToolModal.vue'
|
import { postAction } from '../../../../api/manage'
|
import title from 'ant-design-vue/lib/skeleton/Title'
|
|
export default {
|
name: "OutboundOrderModal",
|
components: {
|
OutboundDetailList,
|
JSelectBorrowOutboundToolModal,
|
JSelectSharpenOutboundToolModal
|
},
|
data () {
|
return {
|
title: '',
|
width:1200,
|
visible: false,
|
disableSubmit: false,
|
isDisabled: false,
|
addShow: true,
|
selectBorrowTool: false,
|
selectSharpenTool: false,
|
model:{
|
},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 },
|
},
|
//表格参数
|
ipagination: {
|
current: 1,
|
pageSize: 10,
|
total: 0,
|
},
|
dataSource: [],
|
loading: false,
|
// 表头
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key:'rowIndex',
|
width:60,
|
align:"center",
|
customRender:function (t,r,index) {
|
return parseInt(index)+1;
|
}
|
},
|
{
|
title:'工具编码',
|
align:"center",
|
dataIndex: 'toolNum'
|
},
|
{
|
title:'工具编号',
|
align:"center",
|
dataIndex: 'toolId'
|
},
|
{
|
title:'可用库存',
|
align:"center",
|
dataIndex: 'quantity'
|
},
|
{
|
title:'出库数量',
|
align:"center",
|
dataIndex: 'outboundQuantity',
|
scopedSlots: { customRender: 'outboundQuantity' },
|
},
|
{
|
title:'出库仓库',
|
align:"center",
|
dataIndex: 'warehouseName'
|
},
|
{
|
title:'出库库位',
|
align:"center",
|
dataIndex: 'outboundLocation'
|
},
|
{
|
title:'额定寿命',
|
align:"center",
|
dataIndex: 'ratedLife',
|
scopedSlots: { customRender: 'ratedLife' },
|
},
|
{
|
title:'使用寿命',
|
align:"center",
|
dataIndex: 'useLife',
|
scopedSlots: { customRender: 'useLife' },
|
},
|
// {
|
// title:'出库状态;1.未出库;2.部分出库;3.出库完成',
|
// align:"center",
|
// dataIndex: 'status'
|
// },
|
{
|
title: '操作',
|
dataIndex: 'action',
|
align:"center",
|
fixed:"right",
|
width:147,
|
scopedSlots: { customRender: 'action' },
|
}
|
],
|
confirmLoading: false,
|
validatorRules: {
|
outStorehouseType: [
|
{ required: true, message: '请选择出库类型!'},
|
]
|
},
|
url: {
|
outbound: "/tms/outboundOrder/outBoundByAdd",
|
list: "/tms/outboundOrder/listOutboundDetailByMainId",
|
add: "/tms/outboundOrder/addTotal",
|
edit: "/tms/outboundOrder/editTotal",
|
},
|
classifyId: ''
|
}
|
},
|
created () {
|
//备份model原始值
|
this.modelDefault = JSON.parse(JSON.stringify(this.model));
|
},
|
mounted() {
|
this.$bus.$on('selectionRows', (data) => {
|
for (let i = 0; i < data.length; i++) {
|
this.dataSource.push({
|
id: data[i].id,
|
toolLedgerDetailId: data[i].toolLedgerDetailId,
|
toolCode:data[i].toolCode,
|
toolNum:data[i].toolNum,
|
toolId: data[i].toolId,
|
quantity: data[i].quantity,
|
outboundQuantity: data[i].quantity,
|
storageLocation: data[i].warehouseId,
|
warehouseName: data[i].warehouseName,
|
outboundLocation: data[i].positionCode,
|
accuracyClass:data[i].accuracyClass
|
})
|
}
|
this.ipagination.total = this.dataSource.length
|
})
|
},
|
methods: {
|
handleTypeChange(value) {
|
if (value === '1') {
|
this.selectBorrowTool = true
|
this.selectSharpenTool = false
|
this.dataSource = []
|
}
|
if (value === '2') {
|
this.selectBorrowTool = false
|
this.selectSharpenTool = false
|
this.dataSource = []
|
}
|
if (value === '3') {
|
this.selectBorrowTool = false
|
this.selectSharpenTool = false
|
this.dataSource = []
|
}
|
if (value === '4') {
|
this.selectBorrowTool = false
|
this.selectSharpenTool = true
|
this.dataSource = []
|
}
|
},
|
handleDelete(record, index) {
|
this.dataSource.splice(index, 1)
|
},
|
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
|
if(column.dataIndex === 'outboundQuantity'){
|
if(target['quantity']<value){
|
this.$message.error('出库数量不能大于可用库存!')
|
this.isDisabled = true
|
}else{
|
this.isDisabled = false
|
}
|
}
|
this.dataSource = temp
|
}
|
},
|
selectBorrowOutBoundTool() {
|
console.log(this.dataSource)
|
let ids = this.dataSource.map(item => item.id).join(',')
|
this.$refs.selectBorrowOutBoundToolModal.showModal(ids, this.classifyId)
|
},
|
selectSharpenOutBoundTool() {
|
console.log(this.dataSource)
|
let ids = this.dataSource.map(item => item.id).join(',')
|
this.$refs.selectSharpenOutBoundToolModal.showModal(ids, this.classifyId)
|
},
|
add (nodeSelected) {
|
this.addShow = false
|
this.classifyId = nodeSelected.key
|
this.model.classifyNum = nodeSelected.entity.classifyId
|
this.model.classifyName = nodeSelected.entity.typeName
|
this.dataSource = []
|
this.visible = true;
|
},
|
close () {
|
this.$emit('close');
|
this.addShow = true
|
this.selectBorrowTool = false
|
this.model = {}
|
this.visible = false;
|
this.$refs.form.clearValidate();
|
},
|
handleTableChange(pagination, filters, sorter) {
|
this.ipagination = pagination
|
},
|
handleOk () {
|
// 触发表单验证
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
if (this.dataSource == null || this.dataSource.length === 0) {
|
this.$message.warning('请选择出库工具!');
|
return
|
}
|
const params = this.dataSource.map(item => {
|
return {
|
toolLedgerDetailId: item.toolLedgerDetailId,
|
toolCode: item.toolCode,
|
toolId: item.toolId,
|
outboundQuantity: item.outboundQuantity,
|
outStorehouseType: this.model.outStorehouseType,
|
storageLocation: item.storageLocation,
|
ratedLife:item.ratedLife,
|
useLife:item.useLife
|
}
|
})
|
this.confirmLoading = true;
|
postAction(this.url.outbound, params).then((res)=>{
|
if(res.success){
|
this.$message.success(res.message)
|
this.$emit("ok")
|
} else {
|
this.$message.warning(res.message)
|
}
|
}).finally(() => {
|
this.confirmLoading = false;
|
this.close();
|
})
|
}else{
|
return false
|
}
|
})
|
},
|
handleCancel () {
|
this.close()
|
},
|
|
|
}
|
}
|
</script>
|