Merge pull request 'projects/mesxc-dy' (#226) from projects/mesxc-dy into projects/mesxc-test

Reviewed-on: #226
This commit is contained in:
朱菊兰 2024-03-04 07:52:03 +08:00
commit 3b6483f013
10 muutettua tiedostoa jossa 605 lisäystä ja 36 poistoa

Näytä tiedosto

@ -1,8 +1,8 @@
###
# @Author: Do not edit
# @Date: 2023-08-29 09:40:39
# @LastEditTime: 2024-03-01 15:27:52
# @LastEditors: zhp
# @LastEditTime: 2024-03-01 20:40:47
# @LastEditors: DY
# @Description:
###
# 开发环境配置

Näytä tiedosto

@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: DY
* @LastEditTime: 2024-02-18 13:53:09
* @LastEditTime: 2024-03-01 19:52:55
* @Description:
-->
<template>
@ -33,14 +33,13 @@
<el-select
v-model="dataForm.roomNameDict"
filterable
:disabled="isdetail || isedit"
style="width: 100%"
placeholder="请选择车间名称">
<el-option
v-for="(dict, index) in getDictDatas('workshop')"
:key="index"
:label="dict.label"
:value="dict.value" />
:value="Number(dict.value)" />
</el-select>
</el-form-item>
</el-col>
@ -125,6 +124,26 @@ export default {
this.getDict()
},
methods: {
init(id) {
this.dataForm.id = id || "";
this.visible = true;
if (this.urlOptions.getOption) {
this.getArr()
}
this.$nextTick(() => {
this.$refs["dataForm"].resetFields();
if (this.dataForm.id) {
this.urlOptions.infoURL(id).then(response => {
this.dataForm = response.data
// this.dataForm.roomNameDict = String(this.dataForm.roomNameDict)
});
} else {
if (this.urlOptions.isGetCode) {
this.getCode()
}
}
});
},
async getDict() {
//
const factoryRes = await getFactoryList();

Näytä tiedosto

@ -38,7 +38,7 @@
import SmallTitle from './SmallTitle';
import { getworkerAll } from '@/api/base/materialUseLog';
import Editor from '@/components/Editor';
import DialogForm from '@/components/DialogForm';
import DialogForm from './DialogForm';
export default {
name: 'AlarmHandle',

Näytä tiedosto

@ -0,0 +1,520 @@
<!--
filename: dialogForm.vue
author: liubin
date: 2023-08-15 10:32:36
description: 弹窗的表单组件
-->
<template>
<el-form
ref="form"
:model="form"
:label-width="`${labelWidth}px`"
:size="size"
:label-position="labelPosition"
v-loading="formLoading">
<el-row :gutter="20" v-for="(row, rindex) in rows" :key="rindex">
<el-col v-for="col in row" :key="col.label" :span="24 / row.length">
<el-form-item :label="col.label" :prop="col.prop" :rules="col.rules">
<el-input
v-if="col.input"
v-model="form[col.prop]"
@change="$emit('update', form)"
:placeholder="`请输入${col.label}`"
:disabled="disabled"
v-bind="col.bind" />
<el-input
v-if="col.textarea"
type="textarea"
v-model="form[col.prop]"
:disabled="disabled"
@change="$emit('update', form)"
:placeholder="`请输入${col.label}`"
v-bind="col.bind" />
<el-select
v-if="col.select"
v-model="form[col.prop]"
:placeholder="`请选择${col.label}`"
:disabled="disabled"
@change="$emit('update', form)"
v-bind="col.bind">
<el-option
v-for="opt in optionListOf[col.prop]"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
<el-date-picker
v-if="col.datetime"
v-model="form[col.prop]"
type="datetime"
:disabled="disabled"
:placeholder="`请选择${col.label}`"
value-format="timestamp"
@change="$emit('update', form)"
v-bind="col.bind"></el-date-picker>
<el-switch
v-if="col.switch"
v-model="form[col.prop]"
:disabled="disabled"
active-color="#0b58ff"
inactive-color="#e1e1e1"
@change="$emit('update', form)"
v-bind="col.bind"></el-switch>
<component
v-if="col.subcomponent"
:key="col.key"
:disabled="disabled"
:read-only="disabled"
:is="col.subcomponent"
v-model="form[col.prop]"
:inlineStyle="col.style"
@on-change="$emit('update', form)"
v-bind="col.bind"></component>
<div
class="upload-area"
:class="uploadOpen ? '' : 'height-48'"
ref="uploadArea"
:key="col.prop"
v-if="col.upload">
<span class="close-icon" :class="uploadOpen ? 'open' : ''">
<el-button
type="text"
icon="el-icon-arrow-right"
@click="handleFilesOpen" />
</span>
<!-- :file-list="uploadedFileList" -->
<el-upload
v-if="col.upload"
class="upload-in-dialog"
:key="col.prop + '__el-upload'"
: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, col.prop);
}
"
v-bind="col.bind">
<el-button
size="mini"
:disabled="disabled || col.bind?.disabled || false">
<svg-icon
icon-class="icon-upload"
style="color: inherit"></svg-icon>
上传文件
</el-button>
<div class="el-upload__tip" slot="tip" v-if="col.uploadTips">
{{ col.uploadTips || '只能上传jpg/png文件, 大小不超过2MB' }}
</div>
</el-upload>
<uploadedFile
class="file"
v-for="file in form[col.prop]"
:file="file"
:key="file.fileUrl"
:disabled="disabled"
@delete="!disabled && handleDeleteFile(file, col.prop)" />
</div>
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>
import { getAccessToken } from '@/utils/auth';
import tupleImg from '@/assets/images/tuple.png';
import cache from '@/utils/cache';
/**
* 找到最长的label
* @param {*} options
*/
function findMaxLabelWidth(rows) {
let max = 0;
rows.forEach((row) => {
row.forEach((opt) => {
// debugger;
if (!opt.label) return 0;
if (opt.label.length > max) {
max = opt.label.length;
if (opt.label.includes('(')) {
max = max - 3;
}
}
});
});
return max;
}
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: {
prop: 'dataForm',
event: 'update',
},
emits: ['update'],
components: { uploadedFile },
props: {
rows: {
type: Array,
default: () => [],
},
dataForm: {
type: Object,
default: () => ({}),
},
disabled: {
type: Boolean,
default: false,
},
hasFiles: {
type: Boolean | Array,
default: false,
},
labelPosition: {
type: String,
default: 'right',
},
size: {
type: String,
default: '',
},
},
data() {
return {
uploadOpen: false,
form: {},
formLoading: true,
optionListOf: {},
uploadedFileList: [],
dataLoaded: false,
uploadHeaders: { Authorization: 'Bearer ' + getAccessToken() },
uploadUrl: process.env.VUE_APP_BASE_API + '/admin-api/infra/file/upload', // headersurl
};
},
computed: {
labelWidth() {
let max = findMaxLabelWidth(this.rows);
// 20px
return max * 20;
// return max * 20 + 'px';
},
},
watch: {
rows: {
handler() {
this.$nextTick(() => {
this.handleOptions('watch');
});
},
deep: true,
immediate: false,
},
dataForm: {
handler(val) {
this.form = JSON.parse(JSON.stringify(val));
if (this.hasFiles) {
if (typeof this.hasFiles == 'boolean' && this.hasFiles) {
this.form.files = this.form.files ?? [];
} else if (Array.isArray(this.hasFiles)) {
this.hasFiles.forEach((prop) => {
this.form[prop] = this.form[prop] ?? [];
});
}
}
},
deep: true,
immediate: true,
},
},
mounted() {
// options
this.handleOptions();
},
methods: {
/** 模拟透传 ref */
validate(cb) {
return this.$refs.form.validate(cb);
},
resetFields(args) {
return this.$refs.form.resetFields(args);
},
// getCode
async getCode(url) {
const response = await this.$axios(url);
return response.data;
},
async handleOptions(trigger = 'monuted') {
console.log('[dialogForm:handleOptions]');
const promiseList = [];
this.rows.forEach((cols) => {
cols.forEach((opt) => {
if (opt.value && !this.form[opt.prop]) {
//
this.form[opt.prop] = opt.value;
}
if (opt.options) {
this.$set(this.optionListOf, opt.prop, opt.options);
} else if (opt.url) {
// dependswatcher
if (opt.depends) {
this.$watch(
() => this.form[opt.depends],
(id) => {
console.log('<', opt.depends, '>', 'changed', id);
if (id == null) return;
//
this.form[opt.prop] = null;
//
this.$axios({
url: `${opt.url}?id=${id}`,
}).then((res) => {
this.$set(
this.optionListOf,
opt.prop,
res.data.map((item) => ({
label: item[opt.labelKey ?? 'name'],
value: item[opt.valueKey ?? 'id'],
}))
);
});
},
{
immediate: false,
}
);
return;
}
//
if (opt.select || (opt.input && !this.form?.id)) {
promiseList.push(async () => {
const response = await this.$axios(opt.url, {
method: opt.method ?? 'get',
// data: opt.method == 'post' ? opt.queryParams : null
});
// console.log('[dialogForm:handleOptions:response]', response);
if (opt.select) {
//
const list =
'list' in response.data
? response.data.list
: response.data;
if (opt.cache) {
cache.store(opt.cache, list);
}
this.$set(
this.optionListOf,
opt.prop,
list.map((item) => ({
label: item[opt.labelKey ?? 'name'],
value: item[opt.valueKey ?? 'id'],
}))
);
} else if (opt.input) {
console.log('setting code: ', response.data);
//
this.form[opt.prop] = response.data;
// dataFormcodebug
this.$emit('update', this.form);
}
});
}
}
});
});
console.log('[dialogForm:handleOptions] done!');
// watch
if (trigger == 'watch') {
this.formLoading = false;
return;
}
try {
await Promise.all(promiseList.map((fn) => fn()));
this.formLoading = false;
this.dataLoaded = true;
// console.log("[dialogForm:handleOptions:optionListOf]", this.optionListOf)
} catch (error) {
console.log('[dialogForm:handleOptions:error]', error);
this.formLoading = false;
}
if (!promiseList.length) 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();
return checkFileSize();
},
// bind
handleUploadSuccess(response, file, prop) {
console.log('[handleUploadSuccess]', response, file, prop);
this.form[prop].push({
fileName: file.name,
fileUrl: response.data,
fileType: prop == 'files' ? 2 : 1,
});
this.$modal.msgSuccess('上传成功');
this.$emit('update', this.form);
},
getFileName(fileUrl) {
return fileUrl.split('/').pop();
},
handleFilesOpen() {
this.uploadOpen = !this.uploadOpen;
},
handleDeleteFile(file, prop) {
this.form[prop] = this.form[prop].filter(
(item) => item.fileUrl != file.fileUrl
);
this.$emit('update', this.form);
},
},
};
</script>
<style scoped lang="scss">
.el-date-editor,
.el-select {
width: 100%;
}
.upload-area {
// background: #ccc;
// display: grid;
// grid-auto-rows: 34px;
// grid-template-columns: repeat(6, minmax(32px, max-content));
// gap: 8px;
// align-items: center;
position: relative;
overflow: hidden;
transition: height 0.3s ease-out;
}
.upload-in-dialog {
// display: inline-block;
margin-right: 24px;
// background: #ccc;
position: relative;
// top: -13px;
float: left;
}
.close-icon {
// background: #ccc;
position: absolute;
top: 0;
right: 12px;
z-index: 100;
transition: transform 0.3s ease-out;
}
.close-icon.open {
transform: rotateZ(90deg);
}
</style>
<style>
.dialog__upload_component__close {
color: #ccc;
}
.dialog__upload_component__close:hover {
/* color: #777; */
color: red;
}
.height-48 {
height: 35px !important;
}
</style>

Näytä tiedosto

@ -218,9 +218,9 @@ export default {
label: '是否采集', // 0 , 1
prop: 'collection',
bind: {
'active-value': 1,
'active-value': 1,
'inactive-value': 0,
value: 1,
value: 1,
},
},
],
@ -294,7 +294,7 @@ export default {
name: undefined,
enName: undefined,
description: undefined,
collection: undefined,
collection: 1,
};
this.resetForm('form');
},

Näytä tiedosto

@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: DY
* @LastEditTime: 2024-02-29 14:59:28
* @LastEditTime: 2024-03-01 18:57:31
* @Description:
-->
<template>
@ -78,7 +78,7 @@
v-for="opt in inspectorOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
:value="opt.label" />
</el-select>
</el-form-item>
</el-col>
@ -418,7 +418,7 @@ export default {
});
},
getConfirmed() {
return this.$confirm('是否直接确认巡检记录', '提示', {
return this.$confirm('是否直接确认巡检', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
@ -431,10 +431,16 @@ export default {
}
this.$nextTick(() => {
this.getConfirmed().then(confirm => {
let checkPersonParam = '';
if (!this.dataForm.checkPerson || this.dataForm.checkPerson.trim() == '') {
/** 如有必要,更新巡检人 */
checkPersonParam = `&checkPerson=${this.$store.getters.nickname}`;
} else {
checkPersonParam = `&checkPerson=${this.dataForm.checkPerson}`
}
this.$axios({
url:
'/base/equipment-check-order/confirm?confirmPerson=' +
this.$store.getters.userId,
`/base/equipment-check-order/confirm?confirmPerson=${this.$store.getters.nickname}` + checkPersonParam,
method: 'put',
data: [this.dataForm.id],
}).then(res =>{

Näytä tiedosto

@ -179,8 +179,13 @@ export default {
this.$modal
.confirm('是否确认所有选中巡检单"?')
.then(() => {
let checkPersonParam = '';
if (!row.checkPerson || row.checkPerson.trim() == '') {
/** 如有必要,更新巡检人 */
checkPersonParam = `&checkPerson=${this.$store.getters.nickname}`;
}
return this.$axios({
url: '/base/equipment-check-order/confirm?confirmPerson=' + this.$store.getters.userId,
url: `/base/equipment-check-order/confirm?confirmPerson=${this.$store.getters.nickname}` + checkPersonParam,
method: 'put',
data: this.$refs['waiting-list-table'].selectedPlan.map(
(item) => item.id
@ -394,11 +399,17 @@ export default {
this.$modal
.confirm('是否确认巡检单"' + row.name + '"?')
.then(() => {
let checkPersonParam = '';
const nickname = this.$store.getters.nickname;
if (!row.checkPerson || row.checkPerson.trim() == '') {
/** 如有必要,更新巡检人 */
checkPersonParam = `&checkPerson=${nickname}`;
} else {
checkPersonParam = `&checkPerson=${row.checkPerson}`
}
return this.$axios({
url:
'/base/equipment-check-order/confirm?confirmPerson=' +
this.$store.getters.userId,
// '/base/equipment-check-order/confirm?ids=' + JSON.stringify([id]).replaceAll("\"", ''),
`/base/equipment-check-order/confirm?confirmPerson=${nickname}` + checkPersonParam,
method: 'put',
data: [row.id],
});

Näytä tiedosto

@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: DY
* @LastEditTime: 2024-02-29 14:58:37
* @LastEditTime: 2024-03-01 19:44:59
* @Description:
-->
<template>
@ -11,7 +11,7 @@
:rules="dataRule"
ref="dataForm"
@keyup.enter.native="dataFormSubmit()"
label-width="120px">
label-width="150px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="巡检单名称" prop="name">
@ -27,8 +27,6 @@
placeholder="请输入巡检单编码" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item
label="部门"
@ -57,8 +55,13 @@
style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="巡检频率(天/次)" prop="checkPeriod">
<el-input
v-model="dataForm.checkPeriod"
placeholder="请输入巡检频率(天/次)" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="确认时限 (时)" prop="confirmTimeLimit">
<el-input
@ -83,8 +86,6 @@
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="备注" prop="remark">
<el-input v-model="dataForm.remark" placeholder="请输入备注" />
@ -121,7 +122,8 @@ export default {
planCheckTime: null,
confirmTimeLimit: null,
groupClass: null,
remark: null
remark: null,
checkPeriod: null
},
groupOptions: [],
departmentOptions: [],
@ -137,6 +139,15 @@ export default {
],
planCheckTime: [
{ required: true, message: '计划巡检时间不能为空', trigger: 'blur' }
],
checkPeriod: [
{ required: true, message: '巡检频率不能为空', trigger: 'blur' },
{
type: 'number',
message: '请输入正确的数字类型',
trigger: 'blur',
transform: (val) => Number(val),
}
]
}
};

Näytä tiedosto

@ -160,6 +160,7 @@ import Editor from "@/components/Editor";
import { getDictDatas } from "@/utils/dict";
import { parseTime } from '@/utils/ruoyi'
import { getDictDataLabel } from '@/utils/dict';
import tupleImg from '@/assets/images/tuple.png';
const uploadedFile = {
name: 'UploadedFile',

Näytä tiedosto

@ -29,7 +29,7 @@
</el-col>
<!-- 产线名 -->
<el-col :span="8">
<!-- <el-col :span="8">
<el-form-item label="产线名" prop="lineId">
<el-select
v-model="formFilters.lineId"
@ -45,10 +45,10 @@
:value="opt.value" />
</el-select>
</el-form-item>
</el-col>
</el-col> -->
<!-- 工段名 -->
<el-col :span="8">
<!-- <el-col :span="8">
<el-form-item label="工段名" prop="sectionId">
<el-select
v-model="formFilters.sectionId"
@ -64,7 +64,7 @@
:value="opt.value" />
</el-select>
</el-form-item>
</el-col>
</el-col> -->
<!-- 设备名称 -->
<el-col :span="8">
@ -234,7 +234,7 @@
v-for="opt in workerOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
:value="opt.label" />
</el-select>
</el-form-item>
</el-col>
@ -597,9 +597,9 @@ export default {
/** 设置默认维修工为用户自己 */
setInitWorker() {
/** 获取用户自身id */
const userId = this.$store.getters.userId;
const nickname = this.$store.getters.nickname;
this.$nextTick(() => {
this.form.repairman = [userId];
this.form.repairman = [nickname];
});
},
@ -630,8 +630,8 @@ export default {
/** 获取设备 */
async initEquipment() {
const response = await this.$axios('/base/core-equipment/listAll');
this.equipmentList = response.data || [];
this.equipmentOptions = response.data || [];
this.equipmentList = response.data.filter(item => item.special === false) || [];
this.equipmentOptions = response.data.filter(item => item.special === false) || [];
// this.allSpeicalEquipments = equipmentOptions;
},
/** 获取维修工 - 同时从用户表和员工表拉取数据 */
@ -737,6 +737,7 @@ export default {
fileType: prop == 'files' ? 2 : 1,
});
this.$modal.msgSuccess('上传成功');
console.log('为我', this.form.files)
this.$emit('update', this.form);
},