<template>
|
<j-modal
|
:title="title"
|
:width="900"
|
:visible="visible"
|
:confirmLoading="confirmLoading"
|
switchFullscreen
|
centered
|
:mask-closable="false"
|
@ok="handleOk"
|
@cancel="handleCancel"
|
cancelText="关闭"
|
>
|
|
<a-spin :spinning="spinning">
|
<a-form-model
|
ref="form"
|
:model="model"
|
:rules="validatorRules"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<a-form-model-item
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
prop="requisitionCode"
|
label="请购单编码"
|
>
|
<a-input
|
placeholder="请购单编码自动生成"
|
v-model="model.requisitionCode"
|
:disabled="true"
|
/>
|
</a-form-model-item>
|
<a-form-model-item
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
prop="remark"
|
label="备注"
|
>
|
<a-textarea
|
placeholder="请输入备注"
|
v-model="model.remark"
|
/>
|
</a-form-model-item>
|
<a-row :gutter="24">
|
<j-vxe-table
|
ref="editableDetailTable"
|
:rowNumber="true"
|
:rowSelection="true"
|
:bordered="true"
|
:alwaysEdit="true"
|
:toolbar="true"
|
keep-source
|
:height="300"
|
:loading="detail.loading"
|
:dataSource="detail.dataSource"
|
:columns="detail.columns"
|
style="margin-top: 8px;"
|
/>
|
</a-row>
|
</a-form-model>
|
</a-spin>
|
</j-modal>
|
</template>
|
|
<script>
|
import { getAction, httpAction } from '@/api/manage'
|
import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js'
|
import { JVXETypes } from '@/components/jeecg/JVxeTable'
|
|
export default {
|
name: 'EamSparePartIntoModal',
|
mixins: [JVxeTableModelMixin],
|
components: {},
|
data() {
|
return {
|
title: '操作',
|
visible: false,
|
model: {},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 6 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 15 }
|
},
|
confirmLoading: false,
|
spinning: false,
|
disabled: false,
|
validatorRules: {},
|
url: {
|
//add: '/eam/eamSparePartInventory/add',
|
//edit: '/eam/eamSparePartInventory/edit',
|
add: "/eam/eamSparePartRequisition/add",
|
edit: "/eam/eamSparePartRequisition/edit",
|
getDetails: "/eam/eamSparePartRequisitionDetail/list",
|
generateRequisitionCode: "sys/sysBusinessCodeRule/generateBusinessCodeSeq"
|
},
|
detail: {
|
loading: false,
|
dataSource: [],
|
columns: [
|
{
|
title: '备件',
|
key: 'partId',
|
type: JVXETypes.select,
|
width: '30%',
|
align: 'center',
|
dictCode: 'eam_spare_parts,part_name,id, del_flag!=\'1\'',
|
validateRules: [
|
{ required: true, message: '备件不能为空!' }
|
]
|
},
|
// {
|
// title: '批次号',
|
// key: 'batchNum',
|
// type: JVXETypes.input,
|
// width: '10%',
|
// align: 'center',
|
// validateRules: [
|
// { required: true, message: '批次号不能为空!' }
|
// ]
|
// },
|
{
|
title: '数量',
|
key: 'requisitionNum',
|
type: JVXETypes.inputNumber,
|
width: '30%',
|
align: 'center',
|
validateRules: [
|
{ required: true, message: '数量不能为空!' }
|
]
|
},
|
// {
|
// title: '出厂日期(生产日期)',
|
// key: 'manufactureDate',
|
// type: JVXETypes.datetime,
|
// width: '16%',
|
// align: 'center',
|
// validateRules: [
|
// { required: false, message: '出厂日期(生产日期)不能为空!' }
|
// ]
|
// },
|
|
]
|
}
|
}
|
},
|
created() {
|
},
|
methods: {
|
add() {
|
|
const that = this
|
this.visible = true;
|
let params = {
|
businessCode: "SpareRequisitionCodeRule"
|
}
|
getAction(that.url.generateRequisitionCode, params).then((res) => {
|
if (res.success) {
|
this.model = {
|
requisitionCode: res.result
|
}
|
} else {
|
that.$message.warning(res.message);
|
}
|
})
|
//初始化默认值
|
that.edit(this.model);
|
},
|
edit(record) {
|
this.model = Object.assign({}, record);
|
this.detail.dataSource = record.sparePartRequisitionDetails
|
this.visible = true;
|
},
|
|
async handleOk() {
|
const that = this
|
let errMap = await that.$refs.editableDetailTable.validateTable()
|
if (errMap) {
|
this.$message.warning('数据校验失败!')
|
return
|
}
|
// 触发表单验证
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
let tableData = that.$refs.editableDetailTable.getTableData()
|
let removeData = that.$refs.editableDetailTable.getDeleteData()
|
that.model.sparePartRequisitionDetails = [...tableData]
|
that.model.removeDetailList = [...removeData]
|
|
that.confirmLoading = that.spinning = true
|
let httpurl = ''
|
let method = ''
|
if (!this.model.id) {
|
httpurl += this.url.add
|
method = 'post'
|
} else {
|
httpurl += this.url.edit
|
method = 'put'
|
}
|
httpAction(httpurl, this.model, method).then((res) => {
|
|
if (res.success) {
|
that.$message.success(res.message)
|
that.$emit('ok')
|
that.close()
|
} else {
|
that.$message.warning(res.message)
|
}
|
}).finally(() => {
|
that.confirmLoading = that.spinning = false
|
})
|
} else {
|
return false
|
}
|
})
|
},
|
|
|
|
handleCancel() {
|
this.close()
|
},
|
|
close() {
|
this.$emit('close')
|
this.visible = false
|
this.$refs.form.clearValidate()
|
}
|
}
|
}
|
</script>
|
|
<style lang="less" scoped>
|
</style>
|