<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="preparationOrderNum">
|
<a-input v-model="model.preparationOrderNum" placeholder="请输入准备单编号" disabled></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="零件图号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="partDrawingNo">
|
<a-input v-model="model.partDrawingNo" placeholder="请输入零件图号" disabled></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="零件名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="partName">
|
<a-input v-model="model.partName" placeholder="请输入零件名称" disabled></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="零件材料" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="partMaterial">
|
<a-input v-model="model.partMaterial" placeholder="请输入零件材料" disabled></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="工序(工步号)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionProcessesNo">
|
<a-input v-model="model.productionProcessesNo" placeholder="请输入工序(工步号)" disabled></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="加工批次" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="batchCode">
|
<a-input v-model="model.batchCode" placeholder="请输入加工批次" disabled></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="加工设备" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentCode">
|
<a-input v-model="model.equipmentCode" placeholder="请输入加工设备" disabled></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="程序名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ncName">
|
<a-input v-model="model.ncName" placeholder="请输入程序名" disabled></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="加工数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="machiningCount">
|
<a-input v-model="model.machiningCount" placeholder="请输入加工数量" disabled></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
|
<a-textarea :disable="disableSubmit" v-model="model.remark" placeholder="请输入备注" ></a-textarea>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
</a-form-model>
|
|
<a-table
|
ref="table"
|
size="middle"
|
bordered
|
rowKey="id"
|
:scroll="{x:true}"
|
:columns="columns"
|
:dataSource="dataSource"
|
:pagination="ipagination"
|
:loading="loading"
|
:rowSelection="null">
|
|
<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'"
|
: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>
|
</a-spin>
|
|
<template slot="footer">
|
<a-button :style="{ marginRight: '8px' }" @click="handleCancel">关闭</a-button>
|
<a-button @click="handleOk" v-if="disableSubmit === false" type="primary">确定</a-button>
|
</template>
|
</j-modal>
|
</template>
|
|
<script>
|
|
import { httpAction } from '@/api/manage'
|
import { validateDuplicateValue } from '@/utils/util'
|
import { getAction } from '../../../../api/manage'
|
|
export default {
|
name: "PreparationOrderModal",
|
components: {
|
},
|
data () {
|
return {
|
title: "操作",
|
width: 1200,
|
visible: false,
|
model:{
|
},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 },
|
},
|
loading: false,
|
dataSource: [],
|
/* 分页参数 */
|
ipagination:{
|
current: 1,
|
pageSize: 10,
|
pageSizeOptions: ['10', '20', '30'],
|
showTotal: (total, range) => {
|
return range[0] + "-" + range[1] + " 共" + total + "条"
|
},
|
showQuickJumper: true,
|
showSizeChanger: true,
|
total: 0
|
},
|
// 表头
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key:'rowIndex',
|
width:60,
|
align:"center",
|
customRender:function (t,r,index) {
|
return parseInt(index)+1;
|
}
|
},
|
{
|
title:'工具编码',
|
align:"left",
|
dataIndex: 'toolNum'
|
},
|
{
|
title:'工具类型',
|
align:"center",
|
dataIndex: 'applicationType_dictText'
|
},
|
{
|
title:'中文名称',
|
align:"center",
|
dataIndex: 'chineseName'
|
},
|
{
|
title:'型号/图号',
|
align:"left",
|
dataIndex: 'toolModel'
|
},
|
{
|
title:'刀具材料',
|
align:"center",
|
dataIndex: 'toolMaterial'
|
},
|
{
|
title:'零件材料',
|
align:"center",
|
dataIndex: 'partMaterial'
|
},
|
{
|
title:'厂家',
|
align:"center",
|
dataIndex: 'supplierId'
|
},
|
{
|
title:'出库数量',
|
align:"left",
|
dataIndex: 'outboundQuantity',
|
scopedSlots: { customRender: 'outboundQuantity' }
|
},
|
{
|
title: '操作',
|
dataIndex: 'action',
|
align:"center",
|
fixed:"right",
|
width:147,
|
scopedSlots: { customRender: 'action' },
|
}
|
],
|
confirmLoading: false,
|
validatorRules: {
|
outboundQuantity: [
|
{ required: true, message: '请输入准备单出库数量!'},
|
],
|
orderStatus: [
|
{ required: true, message: '请输入单子状态;1.未审核;2.调机员已审核;3.已转出库申请!'},
|
],
|
outboundTime: [
|
{ required: true, message: '请输入准备单提交时间;提交至出库申请单的时间!'},
|
],
|
},
|
url: {
|
list: "/tms/preparationOrder/listPreparationOrderDetailByMainId",
|
add: "/tms/preparationOrder/add",
|
edit: "/tms/preparationOrder/editTotal",
|
delete: "/tms/preparationOrder/deletePreparationOrderDetail"
|
}
|
|
}
|
},
|
created () {
|
//备份model原始值
|
this.modelDefault = JSON.parse(JSON.stringify(this.model));
|
},
|
methods: {
|
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
|
}
|
},
|
add () {
|
this.edit(this.modelDefault);
|
},
|
edit (record) {
|
this.model = Object.assign({}, record);
|
getAction(this.url.list, { preparationOrderId: record.id}).then(res => {
|
if (res.success) {
|
this.dataSource = res.result.records || res.result;
|
if (res.result.total)
|
{
|
this.ipagination.total = res.result.total;
|
} else {
|
this.ipagination.total = 0;
|
}
|
} else {
|
this.$message.warning(res.message)
|
}
|
})
|
this.visible = true;
|
},
|
handleDelete(record, index) {
|
deleteAction(this.url.delete, { id: record.id }).then((res) => {
|
if (res.success) {
|
this.dataSource.splice(index, 1);
|
this.$message.success(res.message)
|
} else {
|
this.$message.warning(res.message)
|
}
|
});
|
},
|
close () {
|
this.$emit('close');
|
this.visible = false;
|
this.$refs.form.clearValidate();
|
},
|
handleOk () {
|
const that = this;
|
// 触发表单验证
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
that.confirmLoading = true;
|
let httpurl = '';
|
let method = '';
|
this.model.preparationOrderDetailList = this.dataSource
|
if(!this.model.id){
|
httpurl+=this.url.add;
|
method = 'post';
|
}else{
|
httpurl+=this.url.edit;
|
method = 'put';
|
if (this.title === '审核') {
|
this.model.orderStatus = '2';
|
}
|
}
|
console.log(this.model)
|
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>
|