<template>
|
<a-modal
|
:title="title"
|
:width="1250"
|
:visible="visible"
|
:maskClosable="false"
|
@ok="handleOk"
|
cancelText="关闭"
|
@cancel="handleCancel"
|
:confirmLoading="confirmLoading"
|
>
|
|
<a-spin :spinning="confirmLoading">
|
<a-form :form="form">
|
|
<!-- title="工艺路径基本信息" -->
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-item
|
label="请购单号"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<a-input
|
allow-clear
|
:disabled="codeDisable"
|
:placeholder="disableSubmit?'':'请输入请购单号'"
|
v-decorator="['num', validatorRules.num ]"
|
/>
|
</a-form-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-item
|
label="使用部门"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
|
<j-dict-select-tag
|
allow-clear
|
:disabled="disableSubmit"
|
:placeholder="disableSubmit?'':'请选择使用部门'"
|
:triggerChange="true"
|
dictCode="sys_depart,depart_name,id,del_flag!='1'"
|
v-decorator="['departId',validatorRules.departId]"
|
/>
|
</a-form-item>
|
</a-col>
|
</a-row>
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-item
|
label="设备名称"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<a-input-search
|
:disabled="disableSubmit"
|
placeholder="请选择设备"
|
enter-button
|
@search="onEquipmentList()"
|
:read-only="true"
|
v-decorator="['equipmentNumNameModel', validatorRules.equipmentNumNameModel]"
|
/>
|
</a-form-item>
|
</a-col>
|
</a-row>
|
<a-row
|
hidden
|
:gutter="24"
|
>
|
<a-col :span="12">
|
<a-form-item
|
label="设备Id"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<a-input
|
allow-clear
|
:disabled="true"
|
:placeholder="disableSubmit?'':'请输入统一编码/名称/型号'"
|
v-decorator="['equipmentId', validatorRules.equipmentId ]"
|
/>
|
</a-form-item>
|
</a-col>
|
<!-- <a-col :span="12">
|
<a-form-item
|
label="使用部门Id"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<a-input
|
allow-clear
|
:disabled="true"
|
:placeholder="disableSubmit?'':'请输入使用部门id'"
|
v-decorator="['useId', validatorRules.useId ]"
|
/>
|
</a-form-item>
|
</a-col> -->
|
</a-row>
|
<!-- <a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-item
|
label="管理制度"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<a-input
|
allow-clear
|
:disabled="false"
|
:placeholder="disableSubmit?'':'请输入管理制度'"
|
v-decorator="['disUda1', validatorRules.disUda1 ]"
|
/>
|
</a-form-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-item
|
label="版本"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<a-input
|
allowClear
|
:disabled="true"
|
:placeholder="disableSubmit?'':'请输入版本号'"
|
v-decorator="[ 'version', validatorRules.version]"
|
/>
|
</a-form-item>
|
</a-col>
|
</a-row> -->
|
<!-- <a-row :gutter="24">
|
<a-col
|
v-if="this.isRevise == true"
|
:span="12"
|
>
|
<a-form-item
|
label="历史版本"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<a-input
|
allowClear
|
:disabled="true"
|
:placeholder="disableSubmit?'':'请输入历史版本号'"
|
v-decorator="[ 'historyVersion', validatorRules.historyVersion]"
|
/>
|
</a-form-item>
|
</a-col>
|
</a-row> -->
|
<a-row :gutter="24">
|
<a-col :span="24">
|
<a-form-item
|
label="备注"
|
:labelCol="{span:3}"
|
:wrapperCol="{span:21}"
|
>
|
<a-textarea
|
allowClear
|
:disabled="disableSubmit"
|
:placeholder="disableSubmit?'':'请输入备注'"
|
v-decorator="[ 'remark', validatorRules.remark]"
|
/>
|
</a-form-item>
|
</a-col>
|
</a-row>
|
</a-form>
|
</a-spin>
|
<!-- <a-button
|
type="primary"
|
:style="{ marginRight: '8px',marginBottom:'8px' }"
|
:loading="confirmLoading"
|
@click="selectInspectionProjects()"
|
>点检项目</a-button> -->
|
<a-table
|
ref="table"
|
bordered
|
size="middle"
|
rowKey='id'
|
:columns="columns"
|
:dataSource="dataSource"
|
:pagination="false"
|
>
|
<template
|
v-for='col in columns'
|
:slot='col.dataIndex'
|
slot-scope='text, record, index'
|
>
|
<div :key='col.dataIndex'>
|
<a-input
|
v-if="col.dataIndex == 'spartPartNum'"
|
:value='text'
|
@change='(e) => handleChange(e, record.key, col, index)'
|
/>
|
<a-input
|
v-if="col.dataIndex == 'spartPartName'"
|
:value='text'
|
@change='(e) => handleChange(e, record.key, col, index)'
|
/>
|
<a-input
|
v-if="col.dataIndex == 'spartPartModel'"
|
:value='text'
|
@change='(e) => handleChange(e, record.key, col, index)'
|
/>
|
<a-input-number
|
:value='text'
|
v-if="col.dataIndex == 'quantity'"
|
:min='0'
|
:max='99999'
|
@change='(e)=>handleChange(e, record.key, col, index)'
|
/>
|
<a-input
|
v-if="col.dataIndex == 'unitName'"
|
:value='text'
|
@change='(e) => handleChange(e, record.key, col, index)'
|
/>
|
</div>
|
</template>
|
<span
|
slot="action"
|
slot-scope="text, record, index"
|
>
|
<a-popconfirm
|
title="确定删除吗?"
|
@confirm="() => handleDelete(text,record, index)"
|
>
|
<a>删除</a>
|
</a-popconfirm>
|
</span>
|
</a-table>
|
<a-button
|
style='width: 100%; margin-top: 16px; margin-bottom: 8px'
|
type='dashed'
|
icon='plus'
|
@click='addSpart'
|
>增加备件
|
</a-button>
|
<template slot="footer">
|
<a-button
|
:style="{marginRight: '8px'}"
|
@click="handleCancel()"
|
>
|
关闭
|
</a-button>
|
|
<a-button
|
@click="handleOk()"
|
type="primary"
|
:loading="confirmLoading"
|
>确定</a-button>
|
</template>
|
|
<equipment-list
|
ref="EquipmentList"
|
@sendEquipmentRecord='sendEquipmentRecord'
|
></equipment-list>
|
|
</a-modal>
|
|
</template>
|
|
<script>
|
import { getAction, postAction, requestPut } from '@/api/manage'
|
import pick from 'lodash.pick'
|
import JMultiSelectTag from '@/components/dict/JMultiSelectTag'
|
import { duplicateCheck } from '@/api/api'
|
import Tooltip from 'ant-design-vue/es/tooltip'
|
import EquipmentList from './EquipmentList'
|
|
export default {
|
name: "SpartPartRequirementModal",
|
components: {
|
JMultiSelectTag,
|
Tooltip,
|
EquipmentList,
|
},
|
data() {
|
return {
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key: 'rowIndex',
|
align: 'center',
|
customRender: function (t, r, index) {
|
return parseInt(index) + 1
|
},
|
width: 50,
|
},
|
{
|
title: '备件编号',
|
align: 'center',
|
dataIndex: 'spartPartNum',
|
scopedSlots: { customRender: 'spartPartNum' },
|
},
|
{
|
title: '备件名称',
|
align: 'center',
|
dataIndex: 'spartPartName',
|
scopedSlots: { customRender: 'spartPartName' },
|
},
|
{
|
title: '型号',
|
align: 'center',
|
dataIndex: 'spartPartModel',
|
scopedSlots: { customRender: 'spartPartModel' },
|
},
|
{
|
title: '数量',
|
align: 'center',
|
dataIndex: 'quantity',
|
scopedSlots: { customRender: 'quantity' },
|
},
|
{
|
title: '单位',
|
align: 'center',
|
dataIndex: 'unitName',
|
scopedSlots: { customRender: 'unitName' },
|
},
|
{
|
title: '操作',
|
align: 'center',
|
dataIndex: 'action',
|
scopedSlots: {
|
customRender: 'action'
|
},
|
}
|
],
|
title: "操作",
|
visible: false,
|
disableSubmit: false,
|
codeDisable: true,
|
// isRevise: false,
|
model: {},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 6 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 18 },
|
},
|
confirmLoading: false,
|
form: this.$form.createForm(this),
|
validatorRules: {
|
num: {
|
rules: [
|
{ required: true, message: '请输入请购单号!' },
|
]
|
},
|
equipmentNumNameModel: {
|
rules: [
|
{ required: true, message: '请选择设备!' },
|
]
|
},
|
departId: {
|
rules: [
|
{ required: true, message: '请选择部门!' },
|
]
|
},
|
},
|
url: {
|
add: "/spare/sparePartRequirement/addNew",
|
edit: "/spare/sparePartRequirement/editNew",
|
getNum: '/eam/sysIdentity/getNumNew'
|
},
|
dataSource: [],
|
}
|
},
|
|
|
methods: {
|
add() {
|
this.edit({ sparePartRequirementDeatilList: [] })
|
this.getSeq()
|
},
|
|
edit(record) {
|
let that = this;
|
that.dataSource = [];
|
that.form.resetFields();
|
that.model = Object.assign({}, record);
|
that.visible = true;
|
if (record.sparePartRequirementDeatilList != undefined) {
|
const temp = [...record.sparePartRequirementDeatilList];
|
that.dataSource = temp;
|
}
|
that.$nextTick(() => {
|
that.form.setFieldsValue(pick(that.model, 'num', 'equipmentId', 'equipmentNumNameModel', 'departId', 'remark'));
|
});
|
},
|
|
getSeq() {
|
getAction(this.url.getNum, { type: 'SpartPartRequirement', length: 4 }).then(res => {
|
if (res.success) {
|
this.form.setFieldsValue({ "num": res.result })
|
}
|
})
|
},
|
|
onEquipmentList() {
|
let data = this.form.getFieldsValue(['departId']);
|
this.$refs.EquipmentList.list(data.departId);
|
this.$refs.EquipmentList.title = "选择设备信息";
|
},
|
sendEquipmentRecord(data) {
|
this.dataSource = [];
|
let record = data.record;
|
this.form.setFieldsValue({ equipmentId: record.id, equipmentNumNameModel: record.num + "/" + record.name + "/" + record.model });
|
},
|
|
close() {
|
this.$emit('close');
|
this.visible = false;
|
},
|
|
handleCancel() {
|
this.close();
|
},
|
|
handleOk() {
|
const that = this;
|
this.form.validateFields((err, values) => {
|
if (!err) {
|
that.confirmLoading = true;
|
let formData = Object.assign(this.model, values);
|
formData.sparePartRequirementDeatilList = that.dataSource;
|
let obj;
|
if (!this.model.id) {
|
formData.auditStatus = '0'
|
obj = postAction(this.url.add, formData);
|
} else {
|
obj = requestPut(this.url.edit, formData, { id: this.model.id });
|
}
|
obj.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();
|
})
|
}
|
})
|
},
|
|
handleDelete(text, record, index) {
|
this.dataSource.splice(index, 1);
|
},
|
|
addSpart() {
|
this.dataSource.push({})
|
},
|
|
handleChange(value, key, column, index) {
|
let that = this;
|
const temp = [...that.dataSource];
|
const target = temp.filter(item => key === item.key)[index];
|
if (target) {
|
if (column.dataIndex == 'spartPartNum') {
|
target[column.dataIndex] = value.target.value;
|
}
|
if ('spartPartName' == column.dataIndex) {
|
target['spartPartName'] = value.target.value;
|
}
|
if ('spartPartModel' == column.dataIndex) {
|
target['spartPartModel'] = value.target.value;
|
}
|
if ('quantity' == column.dataIndex) {
|
target['quantity'] = value;
|
}
|
if ('unitName' == column.dataIndex) {
|
target['unitName'] = value.target.value;
|
}
|
//显示带过来的数据
|
that.dataSource = temp;
|
}
|
},
|
|
},
|
}
|
</script>
|
|
<style lang="less" scoped>
|
/deep/ .frozenRowClass {
|
color: #c9c9c9;
|
}
|
.fontweight {
|
font-weight: bold;
|
}
|
.ant-btn {
|
padding: 0 10px;
|
margin-left: 3px;
|
}
|
|
.ant-form-item-control {
|
line-height: 0px;
|
}
|
|
/** 主表单行间距 */
|
.ant-form .ant-form-item {
|
margin-bottom: 10px;
|
}
|
|
/** Tab页面行间距 */
|
.ant-tabs-content .ant-form-item {
|
margin-bottom: 0px;
|
}
|
</style>
|