<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>
|
<!-- <a-col :span="12">-->
|
<!-- <a-form-model-item label="入库单状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderStatus">-->
|
<!--<!– <j-dict-select-tag type="list" v-model="model.orderStatus" dictCode="" placeholder="请选择入库单状态" />–>-->
|
<!-- <a-input type="list" v-model="model.orderStatus" placeholder="请选择入库单状态" />-->
|
<!-- </a-form-model-item>-->
|
<!-- </a-col>-->
|
<a-col :span="12">
|
<a-form-model-item label="入库人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="receiver">
|
<a-input :disabled="disableSubmit" v-model="model.receiver" placeholder="请输入入库人" ></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="入库时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="receiveTime">
|
<j-date :disabled="disableSubmit" :show-time="true" dateFormat="YYYY-MM-DD HH:mm" placeholder="请选择入库时间" v-model="model.receiveTime" style="width: 100%" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="入库说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="receiveComment">
|
<a-textarea :disabled="disableSubmit" v-model="model.receiveComment" rows="4" placeholder="请输入入库说明" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="确认人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="confirmer">
|
<a-input :disabled="disableSubmit" v-model="model.confirmer" placeholder="请输入确认人" ></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="确认时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="confirmTime">
|
<j-date :disabled="disableSubmit" :show-time="true" dateFormat="YYYY-MM-DD HH:mm" placeholder="请选择确认时间" v-model="model.confirmTime" style="width: 100%" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="确认意见" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="confirmComment">
|
<a-textarea :disabled="disableSubmit" v-model="model.confirmComment" placeholder="请输入确认意见" ></a-textarea>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
</a-form-model>
|
</a-spin>
|
|
<a-button v-show="selectInboundToolFlag" type="primary" :style="{ marginBottom: '8px' }" @click="selectInboundTool">选择入库工装</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 === 'receiveNumber'"
|
: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-inbound-tool-modal ref="selectInboundToolModal"></j-select-inbound-tool-modal>
|
</j-modal>
|
</template>
|
|
<script>
|
|
import { httpAction } from '@/api/manage'
|
import { validateDuplicateValue } from '@/utils/util'
|
import JSelectInboundToolModal from './JSelectInboundToolModal.vue'
|
import { getAction } from '../../../api/manage'
|
|
export default {
|
name: "TmsToolInboundModal",
|
components: {
|
JSelectInboundToolModal
|
},
|
data () {
|
return {
|
title:"",
|
width:1200,
|
visible: false,
|
model:{
|
},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 },
|
},
|
confirmLoading: false,
|
validatorRules: {
|
},
|
url: {
|
list: "/tms/tmsToolInbound/listTmsToolInboundDetailByMainId",
|
add: "/tms/tmsToolInbound/add",
|
edit: "/tms/tmsToolInbound/edit",
|
},
|
disableSubmit: false,
|
isDisabled: false,
|
selectInboundToolFlag: true,
|
loading: false,
|
//表格参数
|
ipagination: {
|
current: 1,
|
pageSize: 10,
|
total: 0,
|
},
|
dataSource: [],
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key:'rowIndex',
|
width:60,
|
align:"center",
|
customRender:function (t,r,index) {
|
return parseInt(index)+1;
|
}
|
},
|
{
|
title:'工装名称',
|
align:"center",
|
dataIndex: 'toolName'
|
},
|
{
|
title:'工装编码',
|
align:"center",
|
dataIndex: 'toolCode'
|
},
|
{
|
title:'工装分类',
|
align:"center",
|
dataIndex: 'toolCategory'
|
},
|
{
|
title:'型号',
|
align:"center",
|
dataIndex: 'toolModel'
|
},
|
{
|
title:'规格',
|
align:"center",
|
dataIndex: 'toolSpecification'
|
},
|
{
|
title:'单位',
|
align:"center",
|
dataIndex: 'toolUnit'
|
},
|
{
|
title:'存放位置',
|
align:"center",
|
dataIndex: 'storeLocation'
|
},
|
{
|
title:'供应商',
|
align:"center",
|
dataIndex: 'supplierId'
|
},
|
{
|
title:'入库数量',
|
align:"center",
|
dataIndex: 'receiveNumber',
|
scopedSlots: { customRender: 'receiveNumber' },
|
},
|
{
|
title: '操作',
|
dataIndex: 'action',
|
align:"center",
|
fixed:"right",
|
scopedSlots: { customRender: 'action' },
|
}
|
],
|
}
|
},
|
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,
|
toolId: data[i].id,
|
toolName:data[i].toolName,
|
toolCode:data[i].toolCode,
|
toolCategory: data[i].toolCategory,
|
toolModel: data[i].toolModel,
|
toolSpecification: data[i].toolSpecification,
|
toolUnit: data[i].toolUnit,
|
storeLocation: data[i].storeLocation,
|
supplierId: data[i].supplierId
|
})
|
}
|
this.ipagination.total = this.dataSource.length
|
})
|
},
|
methods: {
|
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 === 'receiveNumber'){
|
if(target['receiveNumber']<1){
|
this.$message.error('入库数量不能小于1!')
|
this.isDisabled = true
|
}else{
|
this.isDisabled = false
|
}
|
}
|
this.dataSource = temp
|
}
|
},
|
selectInboundTool() {
|
console.log(this.dataSource)
|
let ids = this.dataSource.map(item => item.toolId).join(',')
|
this.$refs.selectInboundToolModal.showOrderModal(ids)
|
},
|
add () {
|
this.edit(this.modelDefault);
|
},
|
edit (record) {
|
this.model = Object.assign({}, record);
|
this.visible = true;
|
if (record.id) {
|
getAction(this.url.list, { orderId: record.id }).then(res => {
|
if (res.success) {
|
this.dataSource = res.result.records
|
this.ipagination.total = res.result.length
|
}
|
this.selectInboundToolFlag = this.title !== '详情';
|
})
|
}
|
},
|
handleTableChange(pagination, filters, sorter) {
|
this.ipagination = pagination
|
},
|
close () {
|
this.$emit('close');
|
this.visible = false;
|
this.selectInboundToolFlag = true
|
this.dataSource = []
|
this.$refs.form.clearValidate();
|
},
|
handleOk () {
|
const that = this;
|
// 触发表单验证
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
that.confirmLoading = true;
|
let httpurl = '';
|
let method = '';
|
if(!this.model.id){
|
httpurl+=this.url.add;
|
method = 'post';
|
}else{
|
httpurl+=this.url.edit;
|
method = 'put';
|
}
|
this.model.tmsToolInboundDetailList = this.dataSource.map(
|
item => {
|
return {
|
toolId: item.toolId,
|
receiveNumber: item.receiveNumber
|
}
|
}
|
)
|
httpAction(httpurl,this.model,method).then((res)=>{
|
if(res.success){
|
that.$message.success(res.message);
|
that.$emit('ok');
|
}else{
|
that.$message.warning(res.message);
|
}
|
}).finally(() => {
|
that.confirmLoading = false;
|
that.close();
|
})
|
}else{
|
return false
|
}
|
})
|
},
|
handleCancel () {
|
this.close()
|
},
|
}
|
}
|
</script>
|