projects/mesxc-zhp #161

Closed
zhp wants to merge 119 commits from projects/mesxc-zhp into projects/mes-test
2 changed files with 264 additions and 117 deletions
Showing only changes of commit fd4b0088dc - Show all commits

View File

@ -9,12 +9,59 @@
<el-form <el-form
ref="form" ref="form"
:model="form" :model="form"
:size="size"
:label-position="labelPosition" :label-position="labelPosition"
v-loading="formLoading"> v-loading="formLoading">
<el-row :gutter="20"> <el-row :gutter="20">
<!-- 设备大类 --> <!-- 是否计划保养 -->
<el-col :span="8"> <el-col :span="8">
<el-form-item
label="是否计划保养"
prop="relatePlan"
:rules="[
{
required: true,
message: '是否计划保养不能为空',
trigger: 'blur',
},
]">
<el-select
v-model="form.relatePlan"
:placeholder="`是否计划保养`"
:disabled="disabled"
@change="handlePlanChange">
<el-option
v-for="opt in [
{ label: '是', value: 1 },
{ label: '否', value: 2 },
]"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
</el-form-item>
</el-col>
<!-- 所属计划 -->
<el-col :span="8" v-if="form.relatePlan == 1">
<el-form-item label="所属计划" prop="maintainPlanId">
<el-select
v-model="form.maintainPlanId"
:placeholder="`请选择所属计划`"
:disabled="disabled"
filterable
clearable
@change="$emit('update', form)">
<el-option
v-for="opt in planOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
</el-form-item>
</el-col>
<!-- 设备大类 -->
<el-col :span="8" v-if="form.relatePlan == 1">
<el-form-item <el-form-item
label="设备大类" label="设备大类"
prop="equipmentCategory" prop="equipmentCategory"
@ -25,6 +72,8 @@
v-model="form.equipmentCategory" v-model="form.equipmentCategory"
:placeholder="`请选择设备大类`" :placeholder="`请选择设备大类`"
:disabled="disabled" :disabled="disabled"
clearable
filterable
@change="handleEqTypeChange"> @change="handleEqTypeChange">
<el-option <el-option
v-for="opt in equipmentTypeOptions" v-for="opt in equipmentTypeOptions"
@ -47,6 +96,8 @@
v-model="form.equipmentId" v-model="form.equipmentId"
:placeholder="`请选择设备`" :placeholder="`请选择设备`"
:disabled="disabled" :disabled="disabled"
filterable
clearable
@change="handleEqChange"> @change="handleEqChange">
<el-option <el-option
v-for="opt in equipmentOptions" v-for="opt in equipmentOptions"
@ -57,96 +108,6 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<!-- 保养单号 -->
<el-col :span="8">
<el-form-item label="保养单号" prop="maintainOrderNumber">
<el-input
v-model="form.name"
@change="$emit('update', form)"
:placeholder="`请输入保养单号`"
:disabled="disabled" />
</el-form-item>
</el-col>
<!-- 保养人员 -->
<el-col :span="8">
<el-form-item
label="保养人员"
prop="maintainWorker"
:rules="[
{ required: true, message: '保养人员不能为空', trigger: 'blur' },
]">
<el-select
v-model="form.maintainWorker"
:placeholder="`请选择保养人员`"
:disabled="disabled"
@change="$emit('update', form)">
<el-option
v-for="opt in workerOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
</el-form-item>
</el-col>
<!-- 是否计划保养 -->
<el-col :span="8">
<el-form-item
label="是否计划保养"
prop="relatePlan"
:rules="[
{
required: true,
message: '是否计划保养不能为空',
trigger: 'blur',
},
]">
<el-select
v-model="form.relatePlan"
:placeholder="`是否计划保养`"
:disabled="disabled"
@change="$emit('update', form)">
<el-option
v-for="opt in [
{ label: '是', value: 1 },
{ label: '否', value: 2 },
]"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
</el-form-item>
</el-col>
<!-- 所属计划 -->
<el-col :span="8">
<el-form-item label="所属计划" prop="maintainPlanId">
<el-select
v-model="form.maintainPlanId"
:placeholder="`请选择所属计划`"
:disabled="disabled"
@change="$emit('update', form)">
<el-option
v-for="opt in planOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
</el-form-item>
</el-col>
<!-- 保养用时 -->
<el-col :span="8">
<el-form-item label="保养用时(h)" prop="timeUsed">
<el-input
v-model="form.timeUsed"
@change="$emit('update', form)"
:placeholder="`请输入保养用时(h)`"
:disabled="disabled" />
</el-form-item>
</el-col>
<!-- 开始时间 --> <!-- 开始时间 -->
<el-col :span="8"> <el-col :span="8">
<el-form-item <el-form-item
@ -187,6 +148,53 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<!-- 保养人员 -->
<el-col :span="8">
<el-form-item
label="保养人员"
prop="maintainWorker"
:rules="[
{ required: true, message: '保养人员不能为空', trigger: 'blur' },
]">
<el-select
v-model="form.maintainWorker"
:placeholder="`请选择保养人员`"
:disabled="disabled"
filterable
clearable
multiple
@change="$emit('update', form)">
<el-option
v-for="opt in workerOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
</el-form-item>
</el-col>
<!-- 保养单号 -->
<el-col :span="8">
<el-form-item label="保养单号" prop="maintainOrderNumber">
<el-input
v-model="form.maintainOrderNumber"
@change="$emit('update', form)"
:placeholder="`请输入保养单号`"
:disabled="disabled" />
</el-form-item>
</el-col>
<!-- 保养用时 -->
<el-col :span="8">
<el-form-item label="保养用时(h)" prop="timeUsed">
<el-input
v-model="form.timeUsed"
@change="$emit('update', form)"
:placeholder="`请输入保养用时(h)`"
:disabled="disabled" />
</el-form-item>
</el-col>
<!-- 上传文件 --> <!-- 上传文件 -->
<el-col :span="24"> <el-col :span="24">
<el-form-item label="上传文件" prop="files"> <el-form-item label="上传文件" prop="files">
@ -209,11 +217,7 @@
icon="el-icon-upload2" icon="el-icon-upload2"
:disabled="disabled" :disabled="disabled"
:before-upload="beforeUpload" :before-upload="beforeUpload"
:on-success=" :on-success="handleUploadSuccess">
(response, file, fileList) => {
handleUploadSuccess(response, file, col.prop);
}
">
<el-button size="mini" :disabled="disabled"> <el-button size="mini" :disabled="disabled">
<svg-icon <svg-icon
icon-class="icon-upload" icon-class="icon-upload"
@ -241,23 +245,25 @@
<el-form-item label="保养描述" prop="maintenanceDes"> <el-form-item label="保养描述" prop="maintenanceDes">
<div style="position: relative"> <div style="position: relative">
<div <div
v-if="1" v-if="disabled"
class="modal" class="modal"
style=" style="
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
z-index: 1000;
width: 100%; width: 100%;
height: 100%; height: 100%;
background: rgba(0, 0, 0, 0.3); background: #ccc3;
backdrop-filter: blur(2px); user-select: none;
cursor: not-allowed;
"></div> "></div>
<Editor <Editor
style="margin-top: 40px" class="record-add__editor"
v-model="form.maintenanceDes" :value="form.maintenanceDes"
:min-height="192" :min-height="192"
:disabled="disabled" :disabled="disabled"
@change="$emit('update', form)" /> @input="handleEditorInput" />
</div> </div>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -269,6 +275,68 @@
import { getAccessToken } from '@/utils/auth'; import { getAccessToken } from '@/utils/auth';
import Editor from '@/components/Editor'; import Editor from '@/components/Editor';
import tupleImg from '@/assets/images/tuple.png';
const uploadedFile = {
name: 'UploadedFile',
props: ['file', 'disabled'],
data() {
return {};
},
methods: {
handleDelete() {
this.$emit('delete', this.file);
},
async handleDownload() {
const data = await this.$axios({
url: this.file.fileUrl,
method: 'get',
responseType: 'blob',
});
await this.$message.success('开始下载');
// create download link
const url = window.URL.createObjectURL(data);
const link = document.createElement('a');
link.href = url;
link.download = this.file.fileName;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
},
},
mounted() {},
render: function (h) {
return (
<div
title={this.file.fileName}
onClick={this.handleDownload}
style={{
background: `url(${tupleImg}) no-repeat`,
backgroundSize: '14px',
backgroundPosition: '0 55%',
paddingLeft: '20px',
paddingRight: '24px',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
overflow: 'hidden',
cursor: 'pointer',
display: 'inline-block',
}}>
{this.file.fileName}
{!this.disabled && (
<el-button
type="text"
icon="el-icon-close"
style="float: right; position: relative; top: 2px; left: 8px; z-index: 100"
class="dialog__upload_component__close"
onClick={this.handleDelete}
/>
)}
</div>
);
},
};
export default { export default {
name: 'DialogForm', name: 'DialogForm',
model: { model: {
@ -276,7 +344,7 @@ export default {
event: 'update', event: 'update',
}, },
emits: ['update'], emits: ['update'],
components: { Editor }, components: { Editor, uploadedFile },
props: { props: {
dataForm: { dataForm: {
type: Object, type: Object,
@ -286,6 +354,10 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
labelPosition: {
type: String,
default: 'top',
},
}, },
data() { data() {
return { return {
@ -301,6 +373,8 @@ export default {
{ label: '消防设备', value: 2 }, { label: '消防设备', value: 2 },
{ label: '特种设备', value: 3 }, { label: '特种设备', value: 3 },
], ],
workerOptions: [],
planOptions: [],
uploadHeaders: { Authorization: 'Bearer ' + getAccessToken() }, uploadHeaders: { Authorization: 'Bearer ' + getAccessToken() },
uploadUrl: process.env.VUE_APP_BASE_API + '/admin-api/infra/file/upload', // headersurl uploadUrl: process.env.VUE_APP_BASE_API + '/admin-api/infra/file/upload', // headersurl
}; };
@ -335,7 +409,6 @@ export default {
}, },
mounted() { mounted() {
this.initOptions(); this.initOptions();
this.getEquipmentList();
this.getCode('/base/equipment-maintain-plan/getCode'); this.getCode('/base/equipment-maintain-plan/getCode');
}, },
methods: { methods: {
@ -361,12 +434,12 @@ export default {
this.initPlan(); this.initPlan();
}, },
async initEquipment() { async initEquipment(type = 'special-equipment') {
this.formLoading = true; this.formLoading = true;
const response = await this.$axios('/base/core-equipment/listAll'); const response = await this.$axios('/base/core-equipment/listAll');
this.equipmentList = response.data || []; this.equipmentList = response.data || [];
const equipmentOptions = (response.data || []) const equipmentOptions = (response.data || [])
.filter((item) => item.special) .filter((item) => (type == 'special-equipment' ? item.special : true))
.map((item) => ({ .map((item) => ({
label: item.name, label: item.name,
value: item.id, value: item.id,
@ -376,9 +449,30 @@ export default {
this.formLoading = false; this.formLoading = false;
}, },
async initWorker() {}, async initWorker() {
this.formLoading = true;
const response = await this.$axios({
url: '/base/core-worker/listAll',
});
this.workerOptions = (response.data || []).map((item) => ({
label: item.name,
value: item.id,
}));
this.formLoading = false;
},
async initPlan() {}, async initPlan() {
this.formLoading = true;
const response = await this.$axios({
url: '/base/equipment-maintain-plan/page',
params: { pageNo: 1, pageSize: 100, speical: true },
});
this.planOptions = (response.data?.list || []).map((item) => ({
label: item.name,
value: item.id,
}));
this.formLoading = false;
},
// handlers // handlers
handleEqTypeChange(type) { handleEqTypeChange(type) {
@ -396,12 +490,40 @@ export default {
// this.$emit('update', this.form) // this.$emit('update', this.form)
}, },
handleEqChange() {
this.$emit('update', this.form);
},
//
handlePlanChange(val) {
console.log('handlePlanChange', val);
this.form.equipmentCategory = null;
this.form.equipmentId = null;
this.$emit('update', { ...this.form, relatePlan: val });
this.initEquipment(val == 1 ? 'special-equipment' : null);
},
handleEditorInput(html) {
this.$emit('update', {
...this.form,
maintenanceDes: html,
});
},
// upload // upload
handleFilesOpen() {}, handleFilesOpen() {},
beforeUpload() {}, beforeUpload() {},
handleUploadSuccess() {}, handleUploadSuccess(response, file) {
this.$modal.msgSuccess('上传成功');
console.log('file', file);
this.form.files.push({
fileName: file.name,
fileUrl: response.data,
});
this.$emit('update', this.form);
},
handleDeleteFile(file) {}, handleDeleteFile(file) {},
}, },
@ -424,7 +546,7 @@ export default {
position: relative; position: relative;
overflow: hidden; overflow: hidden;
transition: height 0.3s ease-out; transition: height 0.3s ease-out;
margin-top: 40px; // margin-top: 40px;
} }
.upload-in-dialog { .upload-in-dialog {
@ -460,4 +582,10 @@ export default {
.height-48 { .height-48 {
height: 35px !important; height: 35px !important;
} }
:deep(.record-add__editor) {
.ql-picker-label {
display: flex;
}
}
</style> </style>

View File

@ -519,7 +519,7 @@ export default {
relatePlan: null, relatePlan: null,
maintainPlanId: null, maintainPlanId: null,
equipmentId: null, equipmentId: null,
maintainWorker: null, maintainWorker: [],
maintainOrderNumber: null, maintainOrderNumber: null,
startTime: null, startTime: null,
endTime: null, endTime: null,
@ -582,10 +582,12 @@ export default {
if (!valid) { if (!valid) {
return; return;
} }
this.form.maintainWorker = this.form.maintainWorker.join(',');
// //
if (this.form.id != null) { if (this.form.id != null) {
this.put(this.form).then((response) => { this.put({
...this.form,
maintainWorker: this.form.maintainWorker.join(','),
}).then((response) => {
this.$modal.msgSuccess('修改成功'); this.$modal.msgSuccess('修改成功');
this.open = false; this.open = false;
this.getList(); this.getList();
@ -593,12 +595,29 @@ export default {
return; return;
} }
// //
this.post(this.form).then((response) => { this.post({
...this.form,
maintainWorker: this.form.maintainWorker.join(','),
}).then((response) => {
this.$modal.msgSuccess('新增成功'); this.$modal.msgSuccess('新增成功');
//
const toSparePartsMaintain = () => {
this.open = false;
//
};
this.$confirm('是否有备品备件更换?', '提示', {
confirmButtonText: '有',
cancelButtonText: '没有',
})
.then(toSparePartsMaintain)
.catch(() => {
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
}); });
});
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {