projects/mesxc-lb #205

Merged
gtz217 merged 38 commits from projects/mesxc-lb into projects/mesxc-test 2024-02-26 02:14:07 +08:00
2 changed files with 312 additions and 174 deletions
Showing only changes of commit 564a4a42d2 - Show all commits

View File

@ -71,6 +71,11 @@
</base-dialog>
<!-- 编辑 -->
<UnplannedEditDrawer
ref="unplanned"
v-if="openUnplannedDrawer"
@destroy="openUnplannedDrawer = false" />
<!-- <RecordDetail
v-if="recordDetailVisible"
ref="recordDetailDrawer"
@ -84,6 +89,7 @@
import moment from 'moment';
import basicPageMixin from '@/mixins/lb/basicPageMixin';
import DialogFormUnplanned from './WaitingList--add--unplanned.vue';
import UnplannedEditDrawer from './WaitingListUnplanned--edit.vue';
import {
deleteEqMaintainLog,
exportMaintainLogExcel,
@ -117,7 +123,7 @@ const btn = {
export default {
name: 'SpecialEquipmentMaintainRecord',
components: { DialogFormUnplanned, WaitingListTable, WaitingListTable },
components: { DialogFormUnplanned, WaitingListTable, UnplannedEditDrawer },
mixins: [basicPageMixin],
data() {
return {
@ -441,8 +447,8 @@ export default {
basePath: '/base/equipment-maintain-log',
mode: null,
allSpecialEquipments: [],
openPlannedDialog: false,
openUnplannedDialog: false,
openPlannedDrawer: false,
openUnplannedDrawer: false,
};
},
watch: {
@ -669,23 +675,7 @@ export default {
this.open = true;
this.title = '添加待确认保养记录';
},
/** 修改按钮操作 */
async handleUpdate(row) {
this.reset();
if (row.relatePlan == 1) {
//
const res = await this.info();
this.form = res.data;
this.form.maintainWorker = res.data.maintainWorker.split(',');
this.openPlannedDialog = true;
} else {
// 2
const res = await this.info();
this.form = res.data;
this.form.maintainWorker = res.data.maintainWorker.split(',');
this.openUnplannedDialog = true;
}
},
/** 提交按钮 */
submitForm() {
this.$refs['form'].validate((valid) => {
@ -739,8 +729,24 @@ export default {
console.log('confirm', row);
},
/** 编辑 */
handleEdit(row) {
console.log('edit', row);
async handleEdit(row) {
this.reset();
if (row.relatePlan == 1) {
//
const res = await this.info({ id: row.id });
this.form = res.data;
this.form.maintainWorker = res.data.maintainWorker.split(',');
this.openPlannedDrawer = true;
} else {
// 2
// const res = await this.info({ id: row.id });
// this.form = res.data;
// this.form.maintainWorker = res.data.maintainWorker.split(',');
this.openUnplannedDrawer = true;
this.$nextTick(() => {
this.$refs.unplanned.init(row);
});
}
},
/** 删除按钮操作 */
handleDelete(row) {

View File

@ -14,20 +14,12 @@
custom-class="mes-drawer"
size="60%"
@closed="$emit('destroy')">
<SmallTitle slot="title">
{{
mode.includes('detail')
? '详情'
: mode.includes('edit')
? '编辑'
: '新增'
}}
</SmallTitle>
<SmallTitle slot="title">编辑</SmallTitle>
<div class="drawer-body flex">
<div class="drawer-body__content">
<div class="form-part" style="margin-bottom: 32px">
<el-skeleton v-if="!showForm" animated />
<!-- <el-skeleton v-if="!showForm" animated /> -->
<el-form
class="equipment-info-form"
ref="form"
@ -36,73 +28,156 @@
label-position="top"
v-loading="formLoading">
<el-row :gutter="20">
<el-col :span="12">
<el-col :span="8">
<el-form-item
label="设备名称"
prop="name"
label="保养计划单号"
prop="maintainOrderNumber"
:rules="[
{
required: true,
message: '设备名称不能为空',
message: '请输入保养计划单号',
trigger: 'blur',
},
]">
<el-input
v-model="form.name"
:disabled="disabled"
placeholder="请输入设备名称"></el-input>
v-model="form.maintainOrderNumber"
:placeholder="`请输入保养计划单号`" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="设备编码" prop="code" :rules="[]">
<el-input
v-model="form.code"
:disabled="disabled"
placeholder="请输入设备编码"></el-input>
<el-col :span="8">
<el-form-item label="保养计划名称" prop="name">
<el-input value="---" disabled />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="所在区域" prop="location">
<el-input
v-model="form.location"
:disabled="disabled"
placeholder="请输入所在区域"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="负责人" prop="responsiblePeopleId">
<el-col :span="8">
<el-form-item
label="部门"
prop="departmentId"
:rules="[
{ required: true, message: '请选择部门', trigger: 'blur' },
]">
<el-select
v-model="form.responsiblePeopleId"
:disabled="disabled"
placeholder="请输入负责人">
v-model="form.departmentId"
:placeholder="`请选择部门`"
clearable
filterable>
<el-option
v-for="rp in rpList"
:key="rp.id"
:label="rp.name"
:value="rp.id"></el-option>
v-for="opt in departmentOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col v-if="isFireEquipment" :span="12">
<el-form-item label="有效期至" prop="dueDate" :rules="[]">
<el-col :span="8">
<el-form-item
label="产线"
prop="lineId"
:rules="[
{ required: true, message: '请选择产线', trigger: 'blur' },
]">
<el-select
v-model="form.lineId"
:placeholder="`请选择产线`"
clearable
filterable>
<el-option
v-for="opt in lineOptions"
: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="maintainer">
<el-input value="---" disabled />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="计划开始时间" prop="planStartTime">
<el-input value="---" disabled />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="计划结束时间" prop="planEndTime">
<el-input value="---" disabled />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item
label="实际开始时间"
prop="startTime"
:rules="[
{
required: true,
message: '请选择实际开始时间',
trigger: 'blur',
},
]">
<el-date-picker
v-model="form.dueDate"
:disabled="disabled"
v-model="form.startTime"
type="datetime"
placeholder="请选择生产日期"
placeholder="请选择实际开始时间"
value-format="timestamp"></el-date-picker>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<!-- 上传资料 -->
<el-col>
<el-form-item label="上传图片" prop="assets" :rules="[]">
<AssetsUpload v-model="form.assets" :disabled="disabled" />
<el-col :span="8">
<el-form-item
label="实际结束时间"
prop="endTime"
:rules="[
{
required: true,
message: '请选择实际结束时间',
trigger: 'blur',
},
]">
<el-date-picker
v-model="form.endTime"
type="datetime"
placeholder="请选择实际结束时间"
value-format="timestamp"></el-date-picker>
</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="`请选择实际保养人员`"
multiple
clearable
filterable>
<el-option
v-for="opt in maintainerOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" :placeholder="`请输入备注`" />
</el-form-item>
</el-col>
</el-row>
@ -112,9 +187,12 @@
<SmallTitle>保养内容</SmallTitle>
<div style="margin-top: 12px; position: relative">
<div
v-if="!mode.includes('detail')"
style="position: absolute; top: -40px; right: 0">
<SearchBar
:formConfigs="searchBarFormConfig"
ref="attr-search-bar"
@headBtnClick="handleSearchBarBtnClick" />
<div style="position: absolute; top: -40px; right: 0">
<el-button @click="handleAddAttr" type="text">
<i class="el-icon-plus"></i>
添加属性
@ -122,13 +200,12 @@
</div>
<base-table
v-loading="attrListLoading"
:table-props="section.props"
:table-props="attrTableProps"
:page="attrQuery?.params.pageNo || 1"
:limit="attrQuery?.params.pageSize || 10"
:table-data="list"
:table-data="attrList"
@emitFun="handleEmitFun">
<method-btn
v-if="section.tableBtn"
slot="handleBtn"
label="操作"
:method-list="tableBtn"
@ -137,8 +214,8 @@
<!-- 分页组件 -->
<pagination
v-show="total > 0"
:total="total"
v-show="attrTotal > 0"
:total="attrTotal"
:page.sync="attrQuery.params.pageNo"
:limit.sync="attrQuery.params.pageSize"
@pagination="getAttrList" />
@ -147,10 +224,7 @@
<div class="drawer-body__footer">
<el-button style="" @click="handleCancel">取消</el-button>
<el-button v-if="mode == 'detail'" type="primary" @click="toggleEdit">
编辑
</el-button>
<el-button v-else type="primary" @click="handleConfirm">保存</el-button>
<el-button type="primary" @click="handleConfirm">保存</el-button>
<!-- sections的第二项必须是 属性列表 -->
<!-- <el-button
v-if="sections[1].allowAdd"
@ -163,7 +237,6 @@
<!-- 属性对话框 -->
<base-dialog
v-if="sections[1].allowAdd"
:dialogTitle="attrTitle"
:dialogVisible="attrFormVisible"
width="35%"
@ -172,19 +245,16 @@
@close="closeAttrForm"
@cancel="closeAttrForm"
@confirm="submitAttrForm">
<DialogForm
<!-- <DialogForm
v-if="attrFormVisible"
ref="attrForm"
:dataForm="attrForm"
:rows="attrRows" />
:rows="attrRows" /> -->
</base-dialog>
</el-drawer>
</template>
<script>
import DialogForm from './DialogForm';
import EquipmentInfoForm from './EquipmentInfoForm.vue';
const SmallTitle = {
name: 'SmallTitle',
props: ['size'],
@ -212,16 +282,32 @@ const SmallTitle = {
};
export default {
components: { SmallTitle, DialogForm, EquipmentInfoForm },
props: ['sections', 'mode', 'dataId'], // dataId id
components: { SmallTitle },
props: ['dataId'], // dataId id
data() {
return {
visible: false,
showForm: false,
btnLoading: false,
total: 0,
form: {},
list: [],
lineList: [],
maintainerList: [],
departmentList: [],
attrTableProps: [
{
prop: 'equipmentName',
label: '设备名称',
},
{
prop: 'program',
label: '保养项目',
},
{
prop: 'maintenanceDes',
label: '保养描述',
},
],
attrList: [],
attrTotal: 0,
attrTitle: '',
attrForm: {
id: null,
@ -253,71 +339,68 @@ export default {
params: {
pageNo: 1,
pageSize: 10,
equipmentName: null,
},
}, //
infoQuery: null, //
searchBarFormConfig: [
{
type: 'input',
label: '设备',
placeholder: '请输入设备名称',
param: 'equipmentName',
},
{
type: 'button',
btnName: '查询',
name: 'search',
color: 'primary',
},
],
attrFormSubmitting: false,
attrListLoading: false,
syncFileListFlag: null,
// syncFileListFlag: null,
tableBtn: [],
row: null,
};
},
computed: {
formRows() {
return this.sections[0].rows.map((row) => {
return row.map((col) => {
if (col.key == 'eq-pics') {
//
return {
...col,
bind: {
...col.bind,
departmentOptions() {
return (this.departmentList || []).map((item) => ({
id: item.id,
label: item.name,
value: item.id,
}));
},
style: {
left: 0,
right: 'unset',
lineOptions() {
return (this.lineList || []).map((item) => ({
id: item.id,
label: item.name,
value: item.id,
}));
},
};
}
return {
...col,
bind: {
...col.bind,
//
disabled: this.mode == 'detail',
},
};
});
});
},
tableBtn() {
return this.mode == 'detail' ? [] : this.sections[1].tableBtn;
maintainerOptions() {
return (this.maintainerList || []).map((item) => ({
id: item.id,
label: item.name,
value: item.name,
}));
},
},
mounted() {
for (const section of this.sections) {
//
if ('url' in section) {
const query = {
url: section.url,
method: section.method || 'get',
params: section.queryParams || null,
data: section.data || null,
};
this.$axios(query).then(({ data }) => {
if (section.key == 'base') {
this.form = data;
this.showForm = true;
this.infoQuery = query;
} else if (section.key == 'attrs') {
this.attrQuery = query;
this.list = data.list;
this.total = data.total;
}
});
}
}
this.getList('maintainer');
this.getList('department');
this.getList('line');
},
methods: {
handleSearchBarBtnClick(btn) {
console.log('btn', btn);
switch (btn.btnName) {
case 'search':
this.attrQuery.params.equipmentName = btn['key'];
this.handleQuery();
break;
}
},
handleTableBtnClick({ type, data }) {
switch (type) {
case 'edit':
@ -330,11 +413,11 @@ export default {
},
async handleConfirm() {
this.btnLoading = true;
this.syncFileListFlag = Math.random();
// this.syncFileListFlag = Math.random();
this.$nextTick(async () => {
const { code, data } = await this.$axios({
url: this.sections[0].urlUpdate,
url: '/update', // this.sections[0].urlUpdate,
method: 'put',
data: this.form,
});
@ -352,28 +435,76 @@ export default {
console.log('handleEmitFun', val);
},
init() {
init(row) {
this.visible = true;
this.row = row;
this.getInfo(row);
this.getAttrList(row);
},
async getAttrList() {
this.attrListLoading = true;
const res = await this.$axios(this.attrQuery);
async getInfo(row) {
this.formLoading = true;
const res = await this.$axios(
'/base/equipment-maintain-log/get?id=' + row.id
);
if (res.code == 0) {
this.list = res.data.list;
this.total = res.data.total;
this.form = res.data;
this.form.maintainWorker = res.data.maintainWorker.split(',');
this.formLoading = false;
}
this.formLoading = false;
},
async getAttrList(row, condition = {}) {
if (!row) row = this.row;
this.attrListLoading = true;
const res = await this.$axios({
url: '/base/equipment-maintain-log-det/page',
method: 'get',
params: {
...this.attrQuery.params,
logId: row.id,
...condition,
},
});
if (res.code == 0) {
this.attrList = res.data.list;
this.attrTotal = res.data.total;
}
this.attrListLoading = false;
},
async getList(source = 'department') {
const urls = [
'/base/core-production-line/listAll',
'/base/core-department/listAll',
'/base/core-worker/listAll',
];
let res;
switch (source) {
case 'department':
res = await this.$axios(urls[1]);
this.departmentList = res.data || [];
break;
case 'maintainer':
res = await this.$axios(urls[2]);
this.maintainerList = res.data || [];
break;
case 'line':
res = await this.$axios(urls[0]);
this.lineList = res.data || [];
break;
}
this.formLoading = false;
},
//
handleSave() {
this.$refs['form'][0].validate(async (valid) => {
this.$refs.form.validate(async (valid) => {
if (valid) {
const isEdit = this.mode == 'edit';
await this.$axios({
url: this.sections[0][isEdit ? 'urlUpdate' : 'urlCreate'],
method: isEdit ? 'put' : 'post',
url: '/urlupdate', // this.sections[0][isEdit ? 'urlUpdate' : 'urlCreate'],
method: 'post', // isEdit ? 'put' : 'post',
data: this.form,
});
this.$modal.msgSuccess(`${isEdit ? '更新' : '创建'}成功`);
@ -387,11 +518,6 @@ export default {
this.visible = false;
},
//
toggleEdit() {
this.$emit('update-mode', 'edit');
},
//
handleAddAttr() {
if (!this.dataId) return this.$message.error('请先创建设备信息');
@ -408,7 +534,7 @@ export default {
//
async handleEditAttr(attrId) {
const res = await this.$axios({
url: this.sections[1].urlDetail,
url: 'urlpudate', // this.sections[1].urlDetail,
method: 'get',
params: { id: attrId },
});
@ -428,7 +554,7 @@ export default {
})
.then(async () => {
const res = await this.$axios({
url: this.sections[1].urlDelete,
url: 'url delete', // this.sections[1].urlDelete,
method: 'delete',
params: { id: attrId },
});
@ -457,9 +583,10 @@ export default {
const isEdit = this.attrForm.id != null;
this.attrFormSubmitting = true;
const res = await this.$axios({
url: isEdit
? this.sections[1].urlUpdate
: this.sections[1].urlCreate,
url: 'url edit',
// isEdit
// ? this.sections[1].urlUpdate
// : this.sections[1].urlCreate,
method: isEdit ? 'put' : 'post',
data: this.attrForm,
});
@ -532,6 +659,11 @@ export default {
border-radius: 8px 0 0 8px;
}
.drawer >>> .el-date-editor,
.drawer >>> .el-select {
width: 100%;
}
.drawer >>> .el-drawer__header {
margin: 0;
padding: 32px 32px 24px;