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 - 设备模块 =============
MAINTAIN_TYPE: 'maintain_type',
FAULT_LEVEL: 'fault-level',
FAULT_TYPE: 'fault-type',
REPAIR_MODE: 'repair-mode',
REPAIR_RESULT: 'repair-result',
// ============== ENVIRONMENTAL - 环保模块 =============
ENVIRONMENT_CHECK_UNIT: 'environment_check_unit'

View File

@ -37,7 +37,7 @@
:disabled="disabled"
clearable
filterable
@change="handleEqTypeChange">
@change="initSections">
<el-option
v-for="opt in lineOptions"
:key="opt.value"
@ -158,7 +158,7 @@
:disabled="disabled"
@change="$emit('update', form)">
<el-option
v-for="opt in getDictDatas(DICT_TYPE.FAULT_LEVEL)"
v-for="opt in getDictDatas(DICT_TYPE.FAULT_TYPE)"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
@ -222,11 +222,20 @@
:rules="[
{ required: true, message: '维修工不能为空', trigger: 'blur' },
]">
<el-input
<el-select
v-model="form.repairman"
@change="$emit('update', form)"
placeholder="请输入维修工"
:disabled="disabled" />
placeholder="请选择维修工"
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-col>
@ -264,7 +273,7 @@
:disabled="disabled"
@change="$emit('update', form)">
<el-option
v-for="opt in getDictDatas(DICT_TYPE.FAULT_LEVEL)"
v-for="opt in getDictDatas(DICT_TYPE.REPAIR_MODE)"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
@ -290,7 +299,7 @@
:disabled="disabled"
@change="$emit('update', form)">
<el-option
v-for="opt in getDictDatas(DICT_TYPE.FAULT_LEVEL)"
v-for="opt in getDictDatas(DICT_TYPE.REPAIR_RESULT)"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
@ -320,17 +329,73 @@
message: '故障明细不能为空',
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 :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 :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>
<!-- 设备大类 -->
@ -361,6 +426,71 @@
</template>
<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 {
name: 'DialogForm',
model: {
@ -368,7 +498,7 @@ export default {
event: 'update',
},
emits: ['update'],
components: {},
components: { Editor, uploadedFile },
props: {
dataForm: {
type: Object,
@ -385,8 +515,8 @@ export default {
},
data() {
return {
isInit: true,
allSpeicalEquipments: [],
uploadOpen: false,
form: {},
formFilters: {
lineId: null,
@ -405,6 +535,9 @@ export default {
planOptions: [],
sectionOptions: [],
lineOptions: [],
uploadOpen: false,
uploadUrl: process.env.VUE_APP_BASE_API + '/admin-api/infra/file/upload', // headersurl
uploadHeaders: { Authorization: 'Bearer ' + getAccessToken() },
};
},
watch: {
@ -437,7 +570,6 @@ export default {
},
mounted() {
this.initOptions();
// this.getCode('/base/equipment-maintain-plan/getCode');
},
methods: {
/** 模拟透传 ref */
@ -447,23 +579,61 @@ export default {
resetFields(args) {
return this.$refs.form.resetFields(args);
},
// getCode
// async getCode(url) {
// this.formLoading = true;
// const response = await this.$axios(url);
// this.formLoading = false;
// this.form.code = response.data || '';
// },
async getCode() {
const response = await this.$axios('/base/equipment-repair-log/getCode');
this.form.repairOrderNumber = response.data || '';
},
// initialize
async initOptions() {
this.initEquipment();
// this.initWorker();
// this.initPlan();
this.formLoading = true;
await this.getCode();
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') {
this.formLoading = true;
const response = await this.$axios('/base/core-equipment/listAll');
this.equipmentList = response.data || [];
const equipmentOptions = (response.data || [])
@ -474,32 +644,55 @@ export default {
}));
this.equipmentOptions = 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() {
// 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() {
// 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;
// },
beforeUpload(file) {
const checkFileSize = () => {
const isLt2M = file.size / 1024 / 1024 < 2;
if (!isLt2M) {
this.$modal.msgError('上传文件大小不能超过 2MB!');
}
return isLt2M;
};
const checkFileType = () => {
const isJPG =
file.type === 'image/jpeg' ||
file.type === 'image/png' ||
file.type === 'image/jpg';
return isJPG;
};
return checkFileSize() && checkFileType();
},
// handlers
handleEqTypeChange(type) {
@ -540,19 +733,22 @@ export default {
// upload
handleFilesOpen() {},
beforeUpload() {},
handleUploadSuccess(response, file) {
this.$modal.msgSuccess('上传成功');
console.log('file', file);
handleUploadSuccess(response, file, prop) {
this.form.files.push({
fileName: file.name,
fileUrl: response.data,
fileType: prop == 'files' ? 2 : 1,
});
this.$modal.msgSuccess('上传成功');
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>

View File

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