<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"
|
>
|
<!-- <a-input-search
|
:disabled="disableSubmit"
|
placeholder="请选择使用部门"
|
enter-button
|
@search="onDepartList()"
|
:read-only="true"
|
v-decorator="['useDepartName', validatorRules.useDepartName]"
|
/>
|
<a-tree-select
|
style="width: 100%"
|
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
|
:tree-data="treeData"
|
placeholder="请选择使用部门"
|
tree-default-expand-all
|
v-decorator="['useId', validatorRules.useId ]"
|
/>-->
|
|
<j-dict-select-tag
|
allow-clear
|
:disabled="disableSubmit"
|
:placeholder="disableSubmit?'':'请选择使用部门'"
|
:triggerChange="true"
|
dictCode="sys_depart,depart_name,id,del_flag!='1'"
|
v-decorator="['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-search
|
:disabled="disableSubmit"
|
placeholder="请选择设备"
|
enter-button
|
@search="onEquipmentList()"
|
:read-only="true"
|
v-decorator="['equipmentName', validatorRules.equipmentName]"
|
/>
|
</a-form-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-item
|
label="责任班组"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<a-input
|
allow-clear
|
:disabled="true"
|
:placeholder="disableSubmit?'':'请输入责任班组'"
|
v-decorator="['teamName', validatorRules.teamName ]"
|
/>
|
</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-select
|
v-if="col.dataIndex == 'inspectionCycleId'"
|
:value="text"
|
:options="record.inspectionCycles"
|
@change="(e) => handleChange(e, record.key, col, index)"
|
style="width: 100%"
|
:disabled="false"
|
/>
|
<!-- <j-image-upload
|
:value="text"
|
v-if="col.dataIndex == 'photo'"
|
:isMultiple="false"
|
auto-size
|
placeholder="请上传图片"
|
@change="(e)=>handleChange(e, record.key, col, index)"
|
>
|
</j-image-upload> -->
|
<a-input
|
:value="text"
|
v-if="col.dataIndex == 'location'"
|
:maxLength="32"
|
auto-size
|
placeholder="请输入部位"
|
@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>
|
<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>
|
|
<depart-list
|
ref="DepartList"
|
@sendDepartRecord='sendDepartRecord'
|
></depart-list>
|
|
<j-select-dailylnspection-standard-modal ref="inspectionStandardModalForm"></j-select-dailylnspection-standard-modal>
|
</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 JSelectDailylnspectionStandardModal from './JSelectDailylnspectionStandardModal'
|
import EquipmentList from './EquipmentList'
|
import DepartList from './DepartList'
|
|
export default {
|
name: "DailylnspectionStandardModal",
|
components: {
|
JMultiSelectTag,
|
Tooltip,
|
JSelectDailylnspectionStandardModal,
|
EquipmentList,
|
DepartList
|
},
|
data() {
|
return {
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key: 'rowIndex',
|
align: 'center',
|
customRender: function (t, r, index) {
|
return parseInt(index) + 1
|
},
|
width: 50,
|
},
|
{
|
title: '点检项目',
|
align: 'center',
|
dataIndex: 'name'
|
},
|
{
|
title: '完成数据/要求',
|
align: 'center',
|
dataIndex: 'detectionStandard'
|
},
|
// {
|
// title: '合格范围',
|
// align: 'center',
|
// dataIndex: 'acceptabilityLimit'
|
// },
|
// {
|
// title: '方法',
|
// align: 'center',
|
// dataIndex: 'inspectionMethodName'
|
// },
|
// {
|
// title: '工具',
|
// align: 'center',
|
// dataIndex: 'inspectionTool'
|
// },
|
{
|
title: '周期',
|
align: 'center',
|
dataIndex: 'inspectionCycleId',
|
scopedSlots: { customRender: 'inspectionCycleId' },
|
},
|
// {
|
// title: '示意图',
|
// align: 'center',
|
// dataIndex: 'photo',
|
// scopedSlots: { customRender: 'photo' },
|
// width: 170,
|
// },
|
// {
|
// title: '部位',
|
// align: 'center',
|
// dataIndex: 'location',
|
// scopedSlots: { customRender: 'location' },
|
// width: 170,
|
// },
|
{
|
title: '操作',
|
align: 'center',
|
dataIndex: 'action',
|
scopedSlots: {
|
customRender: 'action'
|
},
|
}
|
],
|
title: "操作",
|
visible: false,
|
disableSubmit: false,
|
codeDisable: true,
|
isRevise: false,
|
model: {},
|
inspectionCycles: {},
|
treeData: [],
|
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: '请输入点检标准编码!' },
|
]
|
},
|
equipmentName: {
|
rules: [
|
{ required: true, message: '请选择设备!' },
|
// { validator: this.validateEquipmentId },
|
]
|
},
|
assignMode: {
|
rules: [
|
{ required: true, message: '请选择派工方式!' },
|
]
|
},
|
version: {
|
rules: [
|
{ required: true, message: '请输入版本!' },
|
]
|
},
|
historyVersion: {
|
rules: [
|
{ required: true, message: '请输入历史版本!' },
|
]
|
},
|
disUda1: {
|
rules: [
|
{ required: true, message: '请输入管理制度!' },
|
]
|
},
|
},
|
url: {
|
add: "/eam/inspectionStandard/add",
|
edit: "/eam/inspectionStandard/edit",
|
getInspectionCycle: "/eam/inspectionStandardDetail/getInspectionCycle",
|
revise: '/eam/inspectionStandard/revise',
|
getReviseVersion: "/eam/inspectionStandard/getReviseVersion",
|
loadOptions: '/sys/sysDepart/loadDepartTreeOptions',
|
getNum: '/eam/sysIdentity/getNumNew'
|
},
|
|
dataSource: [],
|
}
|
},
|
|
|
mounted() {
|
this.$bus.$on('selectionRows', (data) => {
|
for (let i = 0; i < data.length; i++) {
|
debugger
|
this.dataSource.push({
|
id: data[i].id,
|
inspectionProjectId: data[i].id,
|
name: data[i].name,
|
detectionStandard: data[i].detectionStandard,
|
acceptabilityLimit: data[i].acceptabilityLimit,
|
inspectionMethodName: data[i].inspectionMethod_dictText,
|
inspectionTool: data[i].inspectionTool,
|
inspectionCycles: this.inspectionCycles,
|
})
|
}
|
})
|
},
|
|
|
methods: {
|
|
//选择点检项目
|
selectInspectionProjects: function () {
|
let ids = [];
|
for (let i = 0; i < this.dataSource.length; i++) {
|
ids.push(this.dataSource[i].inspectionProjectId);
|
}
|
this.$refs.inspectionStandardModalForm.showModals(ids);
|
this.$refs.inspectionStandardModalForm.title = '选择点检项目';
|
this.$refs.inspectionStandardModalForm.disableSubmit = false;
|
},
|
|
add() {
|
this.edit({ dailyInspectionStandardDetaillist: [] })
|
this.getSeq()
|
},
|
|
edit(record) {
|
let that = this;
|
that.getInspectionCycle()
|
// that.initOptions();
|
that.dataSource = [];
|
that.form.resetFields();
|
that.model = Object.assign({}, record);
|
that.visible = true;
|
if (record.dailyInspectionStandardDetaillist != undefined) {
|
const temp = [...record.dailyInspectionStandardDetaillist];
|
that.dataSource = temp;
|
}
|
that.$nextTick(() => {
|
that.form.setFieldsValue(pick(that.model, 'num', 'equipmentId', 'equipmentName', 'useDepartName', 'disUda1', 'useId', 'teamName', 'assignMode', 'version', 'remark'));
|
});
|
if (record.id) {
|
that.codeDisable = true;
|
that.$nextTick(() => {
|
if (that.isRevise) {
|
requestPut(that.url.getReviseVersion, record).then((res) => {
|
if (res.success) {
|
that.form.setFieldsValue({ version: res.result, historyVersion: record.version })
|
}
|
})
|
}
|
}, 200);
|
} else {
|
that.codeDisable = false;
|
that.$nextTick(() => {
|
that.form.setFieldsValue({ "version": "1.0", })
|
});
|
}
|
},
|
|
getSeq() {
|
getAction(this.url.getNum, { type: 'DailylnspectionStandard', length: 4 }).then(res => {
|
if (res.success) {
|
this.form.setFieldsValue({ "num": res.result })
|
}
|
})
|
},
|
|
initOptions() {
|
getAction(this.url.loadOptions).then(res => {
|
if (res.success) {
|
this.treeData = res.result
|
} else {
|
this.$message.warning(res.message)
|
}
|
})
|
},
|
onEquipmentList() {
|
let data = this.form.getFieldsValue(['useId']);
|
this.$refs.EquipmentList.list(data.useId);
|
this.$refs.EquipmentList.title = "选择设备信息";
|
},
|
sendEquipmentRecord(data) {
|
this.dataSource = [];
|
let record = data.record;
|
this.form.setFieldsValue({ equipmentId: record.id, equipmentName: record.num + "/" + record.name + "/" + record.model, teamName: record.teamId_dictText });
|
},
|
|
onDepartList() {
|
this.$refs.DepartList.list();
|
this.$refs.DepartList.title = "选择使用部门";
|
},
|
sendDepartRecord(data) {
|
this.dataSource = [];
|
let record = data.record;
|
this.form.setFieldsValue({ useId: record.id, useDepartName: record.departName });
|
},
|
|
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.dailyInspectionStandardDetaillist = that.dataSource;
|
let obj;
|
if (!this.model.id) {
|
formData.versionStatus = '1'
|
formData.approvalStatus = '1'
|
obj = postAction(this.url.add, formData);
|
} else {
|
if (this.isRevise) {
|
formData.versionStatus = '1'
|
formData.approvalStatus = '1'
|
obj = postAction(this.url.revise, 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);
|
},
|
|
getInspectionCycle() {
|
getAction(this.url.getInspectionCycle).then((res) => {
|
if (res.success) {
|
this.inspectionCycles = res.result
|
}
|
})
|
},
|
|
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 == 'inspectionCycleId') {
|
target[column.dataIndex] = value;
|
}
|
if ('photo' == column.dataIndex) {
|
target['photo'] = value;
|
}
|
if ('location' == column.dataIndex) {
|
target['location'] = value.target.value;
|
}
|
//显示带过来的数据
|
that.dataSource = temp;
|
}
|
},
|
//验证 编号
|
validateEquipmentId(rule, value, callback) {
|
var params = {
|
tableName: 'mom_eam_daily_inspection_standard',
|
fieldName: 'equipment_id',
|
fieldVal: value,
|
dataId: this.model.id,
|
//数据库中存在字段del_flag并使用该字段作为未删除策略,真删除:false 假删除:true
|
delFlag: 'true',
|
};
|
duplicateCheck(params).then((res) => {
|
if (res.success) {
|
callback();
|
} else {
|
callback("该设备已维护点检标准!");
|
}
|
})
|
},
|
|
},
|
}
|
</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>
|