<template>
|
<a-modal
|
:title="title"
|
:width="1250"
|
:visible="visible"
|
:maskClosable="false"
|
:confirmLoading="confirmLoading"
|
:okButtonProps="{ props: {disabled: disableSubmit} }"
|
@ok="handleOk"
|
@cancel="handleCancel"
|
cancelText="关闭"
|
>
|
<a-spin :spinning="confirmLoading">
|
<a-form :form="form">
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-item
|
label="保养方案编码"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<a-input
|
allow-clear
|
:disabled="disableSubmit"
|
: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-select
|
:placeholder="disableSubmit?'':'请选择对象部门'"
|
:options="this.departs"
|
style="width: 100%"
|
:disabled="disableSubmit"
|
v-decorator="['departId', validatorRules.departId]"
|
@change="(e)=>handle2Change(e)"
|
/> -->
|
<a-tree-select
|
style="width: 100%"
|
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
|
:tree-data="treeData"
|
placeholder="请选择对象部门"
|
tree-default-expand-all
|
v-decorator="['departId', validatorRules.departId]"
|
@change="(e)=>handle2Change(e)"
|
/>
|
</a-form-item>
|
</a-col>
|
</a-row>
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-item
|
label="保养周期"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<a-select
|
:placeholder="disableSubmit?'':'请选择保养周期'"
|
:options="this.maintenanceCycles"
|
@change="(e)=>handle2Change(e)"
|
style="width: 100%"
|
:disabled="disableSubmit"
|
v-decorator="['maintenanceCycleId', validatorRules.maintenanceCycleId]"
|
/>
|
</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="mom_base_team,name,id,status='1' and del_flag='0'"
|
v-decorator="['teamId', validatorRules.teamId]"
|
/>
|
</a-form-item>
|
</a-col>
|
</a-row>
|
<a-row :gutter="24">
|
<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="maintenance_method"
|
v-decorator="['maintenanceMode', validatorRules.maintenanceMode]"
|
@change="(e)=>handle2Change(e)"
|
/>
|
</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="mom_eam_maintenance_type,name,id,del_flag!='1'"
|
v-decorator="['maintenanceTypeId', validatorRules.maintenanceTypeId]"
|
/>
|
</a-form-item>
|
</a-col>
|
</a-row>
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-item
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
label="保养路线图"
|
>
|
<a-upload-dragger
|
name="file"
|
:customRequest="customRequest"
|
@change="handleChange"
|
:file-list="fileList"
|
:multiple="false"
|
>
|
<p class="ant-upload-drag-icon">
|
<a-icon type="inbox" />
|
</p>
|
<p class="ant-upload-text">
|
点击上传或拖拽图片至该区域进行上传
|
</p>
|
<p class="ant-upload-hint">
|
仅支持单图片上传
|
</p>
|
</a-upload-dragger>
|
</a-form-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-item
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
label="图片名称"
|
>
|
<a-input
|
:disabled=true
|
placeholder="请上传图片"
|
v-decorator="['name', validatorRules.name ]"
|
/>
|
</a-form-item>
|
</a-col>
|
</a-row>
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-item
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
label="派工方式"
|
>
|
<j-dict-select-tag
|
allow-clear
|
:disabled="disableSubmit"
|
:placeholder="disableSubmit?'':'请选择派工方式'"
|
:triggerChange="true"
|
dictCode="assign_mode"
|
v-decorator="['assignMode', validatorRules.assignMode]"
|
/>
|
</a-form-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-item
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
label="备注"
|
>
|
<a-textarea
|
:disabled="disableSubmit"
|
placeholder="请输入备注"
|
allow-clear
|
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="selectMaintenanceProjects()"
|
>专业保养标准</a-button>
|
<a-table
|
ref="table"
|
bordered
|
size="middle"
|
rowKey='id'
|
:columns="columns"
|
:dataSource="dataSource"
|
>
|
|
<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>
|
<j-select-specialty-maintenance-standard-modal ref="specialtyMaintenanceStandardModalForm"></j-select-specialty-maintenance-standard-modal>
|
</a-modal>
|
</template>
|
|
<script>
|
import { getAction, postAction, postFileAction } from '@/api/manage'
|
import Vue from 'vue'
|
import JInput from '@/components/jeecg/JInput'
|
import Tooltip from 'ant-design-vue/es/tooltip'
|
import JEllipsis from "@/components/jeecg/JEllipsis";
|
import { ajaxGetDictItems } from '@/api/api'
|
import { ACCESS_TOKEN, TENANT_ID } from "@/store/mutation-types"
|
import pick from 'lodash.pick'
|
|
import JSelectSpecialtyMaintenanceStandardModal from './JSelectSpecialtyMaintenanceStandardModal'
|
|
export default {
|
name: "SpecialtyMaintenancePlanModal",
|
components: {
|
JInput,
|
Tooltip,
|
JEllipsis,
|
JSelectSpecialtyMaintenanceStandardModal
|
},
|
data() {
|
return {
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key: 'rowIndex',
|
align: 'center',
|
customRender: function (t, r, index) {
|
return parseInt(index) + 1
|
},
|
width: 50,
|
},
|
{
|
title: '专业保养标准',
|
align: 'center',
|
dataIndex: 'num'
|
},
|
{
|
title: '版本',
|
align: 'center',
|
dataIndex: 'version'
|
},
|
{
|
title: '版本状态',
|
align: 'center',
|
dataIndex: 'versionStatusName'
|
},
|
{
|
title: '设备编码',
|
align: 'center',
|
dataIndex: 'equipmentNum'
|
},
|
{
|
title: '设备名称',
|
align: 'center',
|
dataIndex: 'equipmentName'
|
},
|
{
|
title: '设备型号',
|
align: 'center',
|
dataIndex: 'equipmentModel'
|
},
|
{
|
title: '操作',
|
align: 'center',
|
dataIndex: 'action',
|
scopedSlots: {
|
customRender: 'action'
|
},
|
}
|
],
|
title: "操作",
|
visible: false,
|
disableSubmit: false,
|
codeDisable: true,
|
model: {},
|
maintenanceCycles: [],
|
treeData: [],
|
departs: [],
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 6 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 18 },
|
},
|
confirmLoading: false,
|
form: this.$form.createForm(this),
|
headers: {},
|
validatorRules: {
|
num: {
|
rules: [
|
{ required: true, message: '请输入保养方案编码!' },
|
]
|
},
|
maintenanceCycleId: {
|
rules: [
|
{ required: true, message: '请选择保养周期!' },
|
]
|
},
|
departId: {
|
rules: [
|
{ required: true, message: '请选择对象部门!' },
|
]
|
},
|
teamId: {
|
rules: [
|
{ required: true, message: '请选择责任班组!' },
|
]
|
},
|
maintenanceMode: {
|
rules: [
|
{ required: true, message: '请选择维保方式!' },
|
]
|
},
|
assignMode: {
|
rules: [
|
{ required: true, message: '请选择派工方式!' },
|
]
|
},
|
maintenanceTypeId: {
|
rules: [
|
{ required: true, message: '请选择保养类型!' },
|
]
|
},
|
name: {
|
rules: [
|
{ required: true, message: '请输入文件名称!' },
|
{ min: 0, max: 150, message: '最长 30 个字符', trigger: 'blur' },
|
]
|
},
|
description: {
|
rules: [
|
{ min: 0, max: 100, message: '最长 100 个字符', trigger: 'blur' },
|
]
|
},
|
},
|
url: {
|
add: "/eam/specialtyMaintenancePlan/add",
|
edit: "/eam/specialtyMaintenancePlan/edit",
|
listByBusIdAndBusType: "/system/sysUploadRela/listByBusIdAndBusType",
|
getMaintenanceCycles: "/eam/maintenanceStandardDetail/getMaintenanceCycle",
|
getSysDeparts: "/eam/equipment/getSysDeparts",
|
loadOptions: '/sys/sysDepart/loadDepartTreeOptions',
|
},
|
dataSource: [],
|
//用于展示文件
|
fileList: [],
|
fileObject: {},
|
//用于判断附件的状态 add:新增页面的附件 edit:编辑页面的附件为被修改i editUpdate:编辑页面的附件被修改
|
isFileChange: false,
|
uploadId: '',
|
}
|
},
|
|
mounted() {
|
this.$bus.$on('selectionRows', (data) => {
|
for (let i = 0; i < data.length; i++) {
|
this.dataSource.push({
|
id: data[i].id,
|
maintenanceStandardId: data[i].id,
|
num: data[i].num,
|
equipmentId: data[i].equipmentId,
|
version: data[i].version,
|
versionStatus: data[i].versionStatus,
|
versionStatusName: data[i].versionStatusName,
|
equipmentNum: data[i].equipmentNum,
|
equipmentName: data[i].equipmentName,
|
equipmentModel: data[i].equipmentModel,
|
})
|
}
|
})
|
},
|
|
created() {
|
this.getMaintenanceCycles()
|
// this.getSysDeparts()
|
const token = Vue.ls.get(ACCESS_TOKEN);
|
const tenantid = Vue.ls.get(TENANT_ID)
|
this.headers = {
|
'Content-Type': 'multipart/form-data',
|
"X-Access-Token": token,
|
'X-Access-Tenant': tenantid
|
};
|
},
|
|
methods: {
|
|
//专保养检标准
|
selectMaintenanceProjects: function () {
|
let dataDepartId = this.form.getFieldsValue(['departId']);
|
if (dataDepartId.departId === "" || dataDepartId.departId === null || dataDepartId.departId === undefined) {
|
this.$message.warning("请选择对象部门!");
|
return
|
}
|
let data = this.form.getFieldsValue(['maintenanceCycleId']);
|
if (data.maintenanceCycleId === "" || data.maintenanceCycleId === null || data.maintenanceCycleId === undefined) {
|
this.$message.warning("请选择保养周期!");
|
return
|
}
|
let dataMode = this.form.getFieldsValue(['maintenanceMode']);
|
if (dataMode.maintenanceMode === "" || dataMode.maintenanceMode === null || dataMode.maintenanceMode === undefined) {
|
this.$message.warning("请选择维保方式!");
|
return
|
}
|
let ids = [];
|
for (let i = 0; i < this.dataSource.length; i++) {
|
ids.push(this.dataSource[i].maintenanceStandardId);
|
}
|
this.$refs.specialtyMaintenanceStandardModalForm.showModals(ids, dataDepartId.departId, data.maintenanceCycleId, dataMode.maintenanceMode);
|
this.$refs.specialtyMaintenanceStandardModalForm.title = '选择保养项目';
|
this.$refs.specialtyMaintenanceStandardModalForm.disableSubmit = false;
|
},
|
|
customRequest(val) {
|
if (this.fileList.length == 0) {
|
this.fileObject = val;
|
}
|
},
|
|
handleChange(info) {
|
//默认给附件状态,仅控制样式
|
let file = info.file;
|
//文件更改,标记更新
|
if (this.model.id) {
|
this.isFileChange = true;
|
}
|
//删除
|
if (file.status == "removed") {
|
this.fileList = [];
|
this.fileObject.file = {};
|
this.form.setFieldsValue({ name: '' });
|
return false;
|
}
|
//单文件控制
|
if (this.fileList.length > 0) {
|
this.$message.warning("当前仅允许上传一个文件!");
|
return false;
|
}
|
file.status = 'done';
|
//页面展示上传文件
|
this.fileList.push(file);
|
this.form.setFieldsValue({ name: file.name });
|
},
|
|
add() {
|
this.edit({ specialtyMaintenancePlanDetailList: [] })
|
},
|
|
edit(record) {
|
let that = this;
|
that.visible = true;
|
that.isFileChange = false;
|
that.initOptions();
|
that.model = Object.assign({}, record);
|
that.$nextTick(() => {
|
that.form.setFieldsValue(pick(that.model, 'num', 'departId', 'teamId', 'teamName', 'assignMode', 'maintenanceCycleId', 'dutyDepartId', 'maintenanceTypeId', 'maintenanceMode', 'remark'))
|
});
|
that.fileList = [];
|
that.form.resetFields();
|
|
that.uploadId = ''
|
if (record.specialtyMaintenancePlanDetailList != undefined) {
|
const temp = [...record.specialtyMaintenancePlanDetailList];
|
that.dataSource = temp;
|
}
|
if (record.isNoPhotoFlag) {
|
//获取当前文件对应附件
|
getAction(that.url.listByBusIdAndBusType, { busId: record.id, busType: 'maintenance_path_photo' }).then((res) => {
|
if (res.success) {
|
for (let i = 0; i < res.result.length; i++) {
|
that.fileList.push({
|
uid: res.result[i].upload.id,
|
name: res.result[i].upload.name,
|
status: "done",
|
})
|
that.$nextTick(() => {
|
that.form.setFieldsValue({ name: res.result[i].upload.name });
|
});
|
}
|
}
|
})
|
}
|
if (record.id) {
|
this.codeDisable = true;
|
} else {
|
this.codeDisable = false;
|
}
|
},
|
|
close() {
|
this.$emit('close');
|
this.visible = false;
|
},
|
|
initOptions() {
|
getAction(this.url.loadOptions).then(res => {
|
if (res.success) {
|
this.treeData = res.result
|
} else {
|
this.$message.warning(res.message)
|
}
|
})
|
},
|
|
handleOk() {
|
const that = this;
|
// 触发表单验证
|
that.form.validateFields((err, values) => {
|
if (JSON.stringify(that.fileObject.file) == '{}' && that.uploadId == '' && that.fileList.length == 0) {
|
that.$message.warning("请上传文件");
|
return false
|
}
|
if (that.dataSource.length == 0) {
|
that.$message.warning("请选择专业点检标准!");
|
return false
|
}
|
if (!err) {
|
that.confirmLoading = true;
|
let httpurl = ''
|
let method = ''
|
if (!that.model.id) {
|
httpurl += that.url.add;
|
method = 'post';
|
} else {
|
httpurl += that.url.edit;
|
method = 'put';
|
}
|
let formData = Object.assign(that.model, values);
|
|
formData.type = "maintenance_path_photo";
|
formData.uploadId = that.uploadId;
|
formData.fileType = "7";//文件类型 7:图片
|
var saveDate = new FormData();
|
|
formData.isFileChange = that.isFileChange;
|
formData.specialtyMaintenancePlanDetails = that.dataSource;
|
saveDate.append("file", that.fileObject.file);
|
saveDate.append('data', JSON.stringify(formData));
|
|
postFileAction(httpurl, saveDate, this.headers).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();
|
})
|
}
|
}).catch((e) => { })
|
},
|
|
handleDelete(text, record, index) {
|
this.dataSource.splice(index, 1);
|
},
|
|
handleCancel() {
|
this.close();
|
},
|
|
handle2Change(val) {
|
this.dataSource = [];
|
},
|
|
getMaintenanceCycles() {
|
getAction(this.url.getMaintenanceCycles).then((res) => {
|
if (res.success) {
|
this.maintenanceCycles = res.result
|
}
|
})
|
},
|
|
getSysDeparts() {
|
getAction(this.url.getSysDeparts).then((res) => {
|
if (res.success) {
|
this.departs = res.result
|
}
|
})
|
},
|
|
},
|
|
|
}
|
</script>
|
<style scoped>
|
.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>
|