<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
|
:disabled="disableSubmit"
|
:placeholder="disableSubmit?'':'请选择使用部门'"
|
:options="this.departs"
|
style="width: 100%"
|
v-decorator="['departId', validatorRules.departId]"
|
@change="(e)=>handle2Change(e)"
|
/> -->
|
<a-input-search
|
:disabled="disableSubmit"
|
placeholder="请选择使用部门"
|
enter-button
|
@search="onDepartList()"
|
:read-only="true"
|
v-decorator="['useDepartName', validatorRules.useDepartName]"
|
/>
|
</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="mom_eam_inspection_cycle,name,id, del_flag!='1'"
|
v-decorator="['inspectionCycleId', validatorRules.inspectionCycleId]"
|
@change="(e)=>handle2Change(e)"
|
/> -->
|
<a-select
|
:disabled="disableSubmit"
|
:placeholder="disableSubmit?'':'请点检周期'"
|
:options="this.inspectionCycles"
|
style="width: 100%"
|
v-decorator="['inspectionCycleId', validatorRules.inspectionCycleId]"
|
@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_base_team,name,id,status = '1' and del_flag!='1'"
|
v-decorator="['teamId', validatorRules.teamId]"
|
/>
|
<!-- <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?'':'请输入使用部门id'"
|
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"
|
>
|
<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="图片名称"
|
>
|
<!-- :labelCol="{span:3}"
|
:wrapperCol="{span:21}" -->
|
<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="点检路线图"
|
>
|
<!-- :labelCol="{span:3}"
|
:wrapperCol="{span:21}" -->
|
<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-row>
|
|
<a-row :gutter="24">
|
<a-col :span="24">
|
<a-form-item
|
:labelCol="{span:3}"
|
:wrapperCol="{span:21}"
|
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="selectInspectionProjects()"
|
>专业点检标准</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>
|
|
<depart-list
|
ref="DepartList"
|
@sendDepartRecord='sendDepartRecord'
|
></depart-list>
|
|
<j-select-specialtylnspection-standard-modal ref="specialtyInspectionStandardModalForm"></j-select-specialtylnspection-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 DepartList from './DepartList'
|
import JSelectSpecialtylnspectionStandardModal from './JSelectSpecialtylnspectionStandardModal'
|
|
export default {
|
name: "SpecialtyInspectionPlanModal",
|
components: {
|
JInput,
|
Tooltip,
|
JEllipsis,
|
JSelectSpecialtylnspectionStandardModal,
|
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: 'num'
|
},
|
{
|
title: '版本',
|
align: 'center',
|
dataIndex: 'version',
|
},
|
{
|
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: {},
|
// departs: [],
|
inspectionCycles: [],
|
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: '请输入点检计划编码!' },
|
// ]
|
// },
|
inspectionCycleId: {
|
rules: [
|
{ required: true, message: '请选择点检周期!' },
|
]
|
},
|
useDepartName: {
|
rules: [
|
{ required: true, message: '请选择使用部门!' },
|
]
|
},
|
assignMode: {
|
rules: [
|
{ required: true, message: '请选择派工方式!' },
|
]
|
},
|
|
teamId: {
|
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/specialtyInspectionPlan/add",
|
edit: "/eam/specialtyInspectionPlan/edit",
|
listByBusIdAndBusType: "/system/sysUploadRela/listByBusIdAndBusType",
|
getInspectionCycle: "/eam/inspectionStandardDetail/getInspectionCycle",
|
// getSysDeparts: "/eam/specialtyInspectionPlan/getSysDeparts",
|
getNum: '/eam/sysIdentity/getNumNew',
|
},
|
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,
|
specialtyInspectionStandardId: data[i].specialtyInspectionStandardId,
|
num: data[i].num,
|
version: data[i].version,
|
equipmentId: data[i].equipmentId,
|
equipmentNum: data[i].equipmentNum,
|
equipmentName: data[i].equipmentName,
|
equipmentModel: data[i].equipmentModel,
|
})
|
}
|
})
|
},
|
|
methods: {
|
|
//专业点检标准
|
selectInspectionProjects: 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(['inspectionCycleId']);
|
if (data.inspectionCycleId == "" || data.inspectionCycleId == null || data.inspectionCycleId == undefined) {
|
this.$message.warning("请选择点检周期!");
|
return
|
}
|
let ids = [];
|
for (let i = 0; i < this.dataSource.length; i++) {
|
ids.push(this.dataSource[i].specialtyInspectionStandardId);
|
}
|
let departId = dataDepartId.departId;
|
let inspectionCycleId = data.inspectionCycleId;
|
this.$refs.specialtyInspectionStandardModalForm.showModals(ids, departId, inspectionCycleId);
|
this.$refs.specialtyInspectionStandardModalForm.title = '选择点检项目';
|
this.$refs.specialtyInspectionStandardModalForm.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({ specialtyInspectionPlanDetailList: [] })
|
},
|
|
edit(record) {
|
let that = this;
|
// that.getSysDeparts()
|
that.getInspectionCycle()
|
that.visible = true;
|
that.isFileChange = false;
|
that.model = Object.assign({}, record);
|
that.$nextTick(() => {
|
that.form.setFieldsValue(pick(that.model, 'num', 'assignMode', 'departId', 'useDepartName', 'inspectionCycleId', 'teamId', 'remark'))
|
});
|
that.fileList = [];
|
that.form.resetFields();
|
that.uploadId = ''
|
if (record.specialtyInspectionPlanDetailList != undefined) {
|
const temp = [...record.specialtyInspectionPlanDetailList];
|
that.dataSource = temp;
|
}
|
if (record.isNoPhotoFlag) {
|
//获取当前文件对应附件
|
getAction(that.url.listByBusIdAndBusType, { busId: record.id, busType: 'inspection_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;
|
},
|
|
handleOk() {
|
const that = this;
|
// 触发表单验证
|
that.form.validateFields(async (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);
|
if(!formData.num){
|
await getAction(this.url.getNum, { type: 'SpecialtyInspectionPlan', length: '4' }).then((res) => {
|
if (res.success) {
|
formData.num = res.message;
|
}
|
});
|
}
|
formData.type = "inspection_path_photo";
|
formData.uploadId = that.uploadId;
|
formData.fileType = "7";//文件类型 7:图片
|
var saveDate = new FormData();
|
|
formData.isFileChange = that.isFileChange;
|
formData.specialtyInspectionPlanDetails = 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 = [];
|
},
|
|
onDepartList() {
|
this.$refs.DepartList.list();
|
this.$refs.DepartList.title = "选择使用部门";
|
},
|
sendDepartRecord(data) {
|
this.dataSource = [];
|
let record = data.record;
|
this.form.setFieldsValue({ departId: record.id, useDepartName: record.orgCode + "/" + record.departName });
|
},
|
|
getInspectionCycle() {
|
getAction(this.url.getInspectionCycle).then((res) => {
|
if (res.success) {
|
this.inspectionCycles = res.result
|
}
|
})
|
},
|
|
// getSysDeparts() {
|
// getAction(this.url.getSysDeparts).then((res) => {
|
// if (res.success) {
|
// this.departs = res.result
|
// }
|
// })
|
// },
|
|
},
|
|
created() {
|
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
|
};
|
},
|
}
|
</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>
|