update repair

This commit is contained in:
lb 2024-02-21 14:44:15 +08:00
parent eb0445f479
commit f8c2889abc
3 changed files with 268 additions and 59 deletions

View File

@ -107,6 +107,9 @@ export const DICT_TYPE = {
// ============== EQUIPMENT - 设备模块 ============= // ============== EQUIPMENT - 设备模块 =============
MAINTAIN_TYPE: 'maintain_type', MAINTAIN_TYPE: 'maintain_type',
FAULT_LEVEL: 'fault-level', FAULT_LEVEL: 'fault-level',
FAULT_TYPE: 'fault-type',
REPAIR_MODE: 'repair-mode',
REPAIR_RESULT: 'repair-result',
// ============== ENVIRONMENTAL - 环保模块 ============= // ============== ENVIRONMENTAL - 环保模块 =============
ENVIRONMENT_CHECK_UNIT: 'environment_check_unit' ENVIRONMENT_CHECK_UNIT: 'environment_check_unit'

View File

@ -37,7 +37,7 @@
:disabled="disabled" :disabled="disabled"
clearable clearable
filterable filterable
@change="handleEqTypeChange"> @change="initSections">
<el-option <el-option
v-for="opt in lineOptions" v-for="opt in lineOptions"
:key="opt.value" :key="opt.value"
@ -158,7 +158,7 @@
:disabled="disabled" :disabled="disabled"
@change="$emit('update', form)"> @change="$emit('update', form)">
<el-option <el-option
v-for="opt in getDictDatas(DICT_TYPE.FAULT_LEVEL)" v-for="opt in getDictDatas(DICT_TYPE.FAULT_TYPE)"
:key="opt.value" :key="opt.value"
:label="opt.label" :label="opt.label"
:value="opt.value" /> :value="opt.value" />
@ -222,11 +222,20 @@
:rules="[ :rules="[
{ required: true, message: '维修工不能为空', trigger: 'blur' }, { required: true, message: '维修工不能为空', trigger: 'blur' },
]"> ]">
<el-input <el-select
v-model="form.repairman" v-model="form.repairman"
@change="$emit('update', form)" @change="$emit('update', form)"
placeholder="请输入维修工" placeholder="请选择维修工"
:disabled="disabled" /> filterable
clearable
multiple
:disabled="disabled">
<el-option
v-for="opt in workerOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -264,7 +273,7 @@
:disabled="disabled" :disabled="disabled"
@change="$emit('update', form)"> @change="$emit('update', form)">
<el-option <el-option
v-for="opt in getDictDatas(DICT_TYPE.FAULT_LEVEL)" v-for="opt in getDictDatas(DICT_TYPE.REPAIR_MODE)"
:key="opt.value" :key="opt.value"
:label="opt.label" :label="opt.label"
:value="opt.value" /> :value="opt.value" />
@ -290,7 +299,7 @@
:disabled="disabled" :disabled="disabled"
@change="$emit('update', form)"> @change="$emit('update', form)">
<el-option <el-option
v-for="opt in getDictDatas(DICT_TYPE.FAULT_LEVEL)" v-for="opt in getDictDatas(DICT_TYPE.REPAIR_RESULT)"
:key="opt.value" :key="opt.value"
:label="opt.label" :label="opt.label"
:value="opt.value" /> :value="opt.value" />
@ -320,17 +329,73 @@
message: '故障明细不能为空', message: '故障明细不能为空',
trigger: 'blur', trigger: 'blur',
}, },
]"></el-form-item> ]">
<Editor
key="fault-detail"
:height="200"
v-model="form.faultDetail"
@on-change="$emit('update', form)" />
</el-form-item>
</el-col> </el-col>
<!-- 维修描述 --> <!-- 维修描述 -->
<el-col :span="24"> <el-col :span="24">
<el-form-item label="维修描述" prop="maintenanceDetail"></el-form-item> <el-form-item label="维修描述" prop="maintenanceDetail">
<Editor
key="maintenance-detail"
:height="200"
v-model="form.maintenanceDetail"
@on-change="$emit('update', form)" />
</el-form-item>
</el-col> </el-col>
<!-- 维修附件 --> <!-- 维修附件 -->
<el-col :span="24"> <el-col :span="24">
<el-form-item label="维修附件" prop="files"></el-form-item> <el-form-item label="维修附件" prop="files">
<div
class="upload-area"
:class="uploadOpen ? '' : 'height-48'"
ref="uploadArea">
<span class="close-icon" :class="uploadOpen ? 'open' : ''">
<el-button
type="text"
icon="el-icon-arrow-right"
@click="uploadOpen = !uploadOpen" />
</span>
<!-- :file-list="uploadedFileList" -->
<el-upload
class="upload-in-dialog"
:action="uploadUrl"
:headers="uploadHeaders"
:show-file-list="false"
icon="el-icon-upload2"
:disabled="disabled"
:before-upload="beforeUpload"
:on-success="
(response, file, fileList) => {
handleUploadSuccess(response, file, 'files');
}
">
<el-button size="mini" :disabled="disabled || false">
<svg-icon
icon-class="icon-upload"
style="color: inherit"></svg-icon>
上传文件
</el-button>
<div class="el-upload__tip" slot="tip">
只能上传jpg/png文件, 大小不超过2MB
</div>
</el-upload>
<uploadedFile
class="file"
v-for="file in form.files"
:file="file"
:key="file.fileUrl"
:disabled="disabled"
@delete="!disabled && handleDeleteFile(file, col.prop)" />
</div>
</el-form-item>
</el-col> </el-col>
<!-- 设备大类 --> <!-- 设备大类 -->
@ -361,6 +426,71 @@
</template> </template>
<script> <script>
import Editor from '@/components/Editor';
import { getAccessToken } from '@/utils/auth';
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: {
@ -368,7 +498,7 @@ export default {
event: 'update', event: 'update',
}, },
emits: ['update'], emits: ['update'],
components: {}, components: { Editor, uploadedFile },
props: { props: {
dataForm: { dataForm: {
type: Object, type: Object,
@ -385,8 +515,8 @@ export default {
}, },
data() { data() {
return { return {
isInit: true,
allSpeicalEquipments: [], allSpeicalEquipments: [],
uploadOpen: false,
form: {}, form: {},
formFilters: { formFilters: {
lineId: null, lineId: null,
@ -405,6 +535,9 @@ export default {
planOptions: [], planOptions: [],
sectionOptions: [], sectionOptions: [],
lineOptions: [], lineOptions: [],
uploadOpen: false,
uploadUrl: process.env.VUE_APP_BASE_API + '/admin-api/infra/file/upload', // headersurl
uploadHeaders: { Authorization: 'Bearer ' + getAccessToken() },
}; };
}, },
watch: { watch: {
@ -437,7 +570,6 @@ export default {
}, },
mounted() { mounted() {
this.initOptions(); this.initOptions();
// this.getCode('/base/equipment-maintain-plan/getCode');
}, },
methods: { methods: {
/** 模拟透传 ref */ /** 模拟透传 ref */
@ -447,23 +579,61 @@ export default {
resetFields(args) { resetFields(args) {
return this.$refs.form.resetFields(args); return this.$refs.form.resetFields(args);
}, },
// getCode // getCode
// async getCode(url) { async getCode() {
// this.formLoading = true; const response = await this.$axios('/base/equipment-repair-log/getCode');
// const response = await this.$axios(url); this.form.repairOrderNumber = response.data || '';
// this.formLoading = false; },
// this.form.code = response.data || '';
// },
// initialize // initialize
async initOptions() { async initOptions() {
this.initEquipment(); this.formLoading = true;
// this.initWorker(); await this.getCode();
// this.initPlan(); await this.initEquipment();
await this.initLines();
await this.initWorker();
await this.initSections();
this.formLoading = false;
this.isInit = false;
this.setInitWorker();
}, },
/** 设置默认维修工为用户自己 */
setInitWorker() {
/** 获取用户自身id */
const userId = this.$store.getters.userId;
this.$nextTick(() => {
this.form.repairman = [userId];
});
},
/** 获取产线 */
async initLines() {
const res = await this.$axios('/base/core-production-line/listAll');
this.lineOptions = (res.data || []).map((item) => ({
label: item.name,
value: item.id,
}));
},
/** 获取工段 */
async initSections(byLineId) {
this.formLoading = !this.isInit && true;
const res = await this.$axios({
url:
byLineId && !this.isInit
? '/base/core-workshop-section/listByParentId?id=' + byLineId
: '/base/core-workshop-section/listAll',
});
this.sectionOptions = (res.data || []).map((item) => ({
label: item.name,
value: item.id,
}));
this.formLoading = !this.isInit && false;
},
/** 获取设备 */
async initEquipment(type = 'special-equipment') { async initEquipment(type = 'special-equipment') {
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 || [])
@ -474,32 +644,55 @@ export default {
})); }));
this.equipmentOptions = equipmentOptions; this.equipmentOptions = equipmentOptions;
this.allSpeicalEquipments = equipmentOptions; this.allSpeicalEquipments = equipmentOptions;
this.formLoading = false; },
/** 获取维修工 - 同时从用户表和员工表拉取数据 */
async initWorker() {
let list = [];
/** user */
const userList = await this.$axios({
url: '/system/user/page',
params: {
pageNo: 1,
pageSize: 100,
},
});
list = list.concat(
(userList.data?.list || []).map((item) => ({
label: item.username,
value: item.id,
}))
);
/** worker */
const workerList = await this.$axios({
url: '/base/core-worker/listAll',
});
list = list.concat(
(workerList.data || []).map((item) => ({
label: item.name,
value: item.id,
}))
);
/** setting */
this.workerOptions = list;
}, },
// async initWorker() { beforeUpload(file) {
// this.formLoading = true; const checkFileSize = () => {
// const response = await this.$axios({ const isLt2M = file.size / 1024 / 1024 < 2;
// url: '/base/core-worker/listAll', if (!isLt2M) {
// }); this.$modal.msgError('上传文件大小不能超过 2MB!');
// this.workerOptions = (response.data || []).map((item) => ({ }
// label: item.name, return isLt2M;
// value: item.id, };
// })); const checkFileType = () => {
// this.formLoading = false; const isJPG =
// }, file.type === 'image/jpeg' ||
// async initPlan() { file.type === 'image/png' ||
// this.formLoading = true; file.type === 'image/jpg';
// const response = await this.$axios({ return isJPG;
// url: '/base/equipment-maintain-plan/page', };
// params: { pageNo: 1, pageSize: 100, speical: true }, return checkFileSize() && checkFileType();
// }); },
// this.planOptions = (response.data?.list || []).map((item) => ({
// label: item.name,
// value: item.id,
// }));
// this.formLoading = false;
// },
// handlers // handlers
handleEqTypeChange(type) { handleEqTypeChange(type) {
@ -540,19 +733,22 @@ export default {
// upload // upload
handleFilesOpen() {}, handleFilesOpen() {},
beforeUpload() {}, handleUploadSuccess(response, file, prop) {
handleUploadSuccess(response, file) {
this.$modal.msgSuccess('上传成功');
console.log('file', file);
this.form.files.push({ this.form.files.push({
fileName: file.name, fileName: file.name,
fileUrl: response.data, fileUrl: response.data,
fileType: prop == 'files' ? 2 : 1,
}); });
this.$modal.msgSuccess('上传成功');
this.$emit('update', this.form); this.$emit('update', this.form);
}, },
handleDeleteFile(file) {}, handleDeleteFile(file, prop) {
this.form.files = this.form.files.filter(
(item) => item.fileUrl != file.fileUrl
);
this.$emit('update', this.form);
},
}, },
}; };
</script> </script>

View File

@ -164,9 +164,15 @@ export default {
{ {
prop: 'maintenanceResult', prop: 'maintenanceResult',
label: '维修结果', label: '维修结果',
showOverflowtooltip: true,
filter: (v) => (v != null ? ['成功', '失败'][v] : ''), filter: (v) => (v != null ? ['成功', '失败'][v] : ''),
}, },
{ prop: 'maintenanceDetail', label: '维修描述', width: 110 }, {
prop: 'maintenanceDetail',
label: '维修描述',
showOverflowtooltip: true,
width: 110,
},
{ {
prop: 'remark', prop: 'remark',
label: '备注', label: '备注',
@ -397,12 +403,13 @@ export default {
if (!valid) { if (!valid) {
return; return;
} }
// if (this.form.repairman) {
// this.form.repairman = this.form.repairman.join(',')
// }
// //
if (this.form.id != null) { if (this.form.id != null) {
this.put(this.form).then((response) => { this.put({
...this.form,
repairman: this.form.repairman.join(','),
}).then((response) => {
this.$modal.msgSuccess('修改成功'); this.$modal.msgSuccess('修改成功');
this.open = false; this.open = false;
this.getList(); this.getList();
@ -410,7 +417,10 @@ export default {
return; return;
} }
// //
this.post(this.form).then((response) => { this.post({
...this.form,
repairman: this.form.repairman.join(','),
}).then((response) => {
this.$modal.msgSuccess('新增成功'); this.$modal.msgSuccess('新增成功');
this.open = false; this.open = false;
this.getList(); this.getList();