update waitinglist unplanned--edit

This commit is contained in:
lb 2024-02-19 16:37:50 +08:00
parent 8e081342f0
commit 564a4a42d2
2 changed files with 312 additions and 174 deletions

View File

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

View File

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