update 保养工单工作流

master
yinq 3 months ago
parent eeeedfae2a
commit 77711b0c5d

@ -142,6 +142,10 @@ export interface DmsBillsMaintInstanceForm extends BaseEntity {
*/
remark?: string;
/**
* draft稿 waiting processing completed cancel back退
*/
status?: string;
}
export interface DmsBillsMaintInstanceQuery extends PageQuery {

@ -376,7 +376,21 @@ export const dynamicRoutes: RouteRecordRaw[] = [
meta: { title: '流程设计', activeMenu: '/workflow/processDefinition', noCache: true }
}
]
}
},
{
path: '/dms/maint/maintEdit',
component: Layout,
hidden: true,
permissions: ['dms:dmsBillsMaintInstance:add'],
children: [
{
path: 'index',
component: () => import('@/views/dms/dmsBillsMaintInstance/maintEdit.vue'),
name: 'maintEdit',
meta: { title: '保养工单申请', activeMenu: '/dms/maint/maintEdit', noCache: true }
}
]
},
];
/**

@ -102,7 +102,7 @@
<el-table-column label="流程定义" align="center" prop="wfDefinitionId" v-if="columns[3].visible"/>
<el-table-column label="保养单号" align="center" prop="billsMaintCode" v-if="columns[4].visible"/>
<el-table-column label="保养组别" align="center" prop="maintGroup" v-if="columns[5].visible"/>
<el-table-column label="保养负责人" align="center" prop="maintSupervisor" v-if="columns[6].visible"/>
<el-table-column label="保养负责人" align="center" prop="maintSupervisor" v-if="columns[6].visible" width="100" />
<el-table-column label="保养级别" align="center" prop="maintLevel" v-if="columns[7].visible">
<template #default="scope">
<dict-tag :options="maint_level" :value="scope.row.maintLevel"/>
@ -133,7 +133,7 @@
<dict-tag :options="maint_status" :value="scope.row.maintStatus"/>
</template>
</el-table-column>
<el-table-column label="保养完成率" align="center" prop="maintCompRate" v-if="columns[13].visible"/>
<el-table-column label="保养完成率" align="center" prop="maintCompRate" v-if="columns[13].visible" width="100" />
<el-table-column label="备注" align="center" prop="remark" v-if="columns[14].visible"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
@ -371,21 +371,21 @@ const handleSelectionChange = (selection: DmsBillsMaintInstanceVO[]) => {
}
/** 新增按钮操作 */
const handleAdd = () => {
reset();
dialog.visible = true;
dialog.title = "添加保养工单";
}
// const handleAdd = () => {
// reset();
// dialog.visible = true;
// dialog.title = "";
// }
/** 修改按钮操作 */
const handleUpdate = async (row?: DmsBillsMaintInstanceVO) => {
reset();
const _maintInstanceId = row?.maintInstanceId || ids.value[0]
const res = await getDmsBillsMaintInstance(_maintInstanceId);
Object.assign(form.value, res.data);
dialog.visible = true;
dialog.title = "修改保养工单";
}
// const handleUpdate = async (row?: DmsBillsMaintInstanceVO) => {
// reset();
// const _maintInstanceId = row?.maintInstanceId || ids.value[0]
// const res = await getDmsBillsMaintInstance(_maintInstanceId);
// Object.assign(form.value, res.data);
// dialog.visible = true;
// dialog.title = "";
// }
/** 提交按钮 */
const submitForm = () => {
@ -420,6 +420,41 @@ const handleExport = () => {
}, `dmsBillsMaintInstance_${new Date().getTime()}.xlsx`)
}
/** 新增按钮操作 */
const handleAdd = () => {
proxy.$tab.closePage(proxy.$route);
proxy.$router.push({
path: `/dms/maint/maintEdit/index`,
query: {
type: 'add'
}
});
};
/** 修改按钮操作 */
const handleUpdate = (row?: DmsBillsMaintInstanceVO) => {
proxy.$tab.closePage(proxy.$route);
proxy.$router.push({
path: `/workflow/leaveEdit/index`,
query: {
id: row.maintInstanceId,
type: 'update'
}
});
};
/** 查看按钮操作 */
const handleView = (row?: DmsBillsMaintInstanceVO) => {
proxy.$tab.closePage(proxy.$route);
proxy.$router.push({
path: `/workflow/leaveEdit/index`,
query: {
id: row.maintInstanceId,
type: 'view'
}
});
};
onMounted(() => {
getList();
});

@ -0,0 +1,393 @@
<template>
<div class='p-2'>
<el-card shadow='never'>
<div style='display: flex; justify-content: space-between'>
<div>
<el-button v-if='submitButtonShow' :loading='buttonLoading' type='info' @click="submitForm('draft')">
</el-button>
<el-button v-if='submitButtonShow' :loading='buttonLoading' type='primary' @click="submitForm('submit')">
</el-button>
<el-button v-if='approvalButtonShow' :loading='buttonLoading' type='primary' @click='approvalVerifyOpen'>
审批
</el-button>
<el-button v-if="form && form.maintInstanceId !== null && form.status !== 'draft'" type='primary'
@click='handleApprovalRecord'>
流程进度
</el-button>
</div>
<div>
<el-button style='float: right' @click='goBack()'>返回</el-button>
</div>
</div>
</el-card>
<el-card shadow='never' style='height: 78vh; overflow-y: auto'>
<el-form ref='dmsBillsMaintInstanceFormRef' v-loading='loading' :disabled="routeParams.type === 'view'"
:model='form' :rules='rules' label-width='120px'>
<el-row :gutter='20'>
<el-col :span='12'>
<el-form-item label='保养计划' prop='planMaintId'>
<!-- <el-input v-model="form.planMaintId" placeholder="请输入保养计划" />-->
</el-form-item>
</el-col>
<el-col :span='12'>
<el-form-item label='保养单号' prop='billsMaintCode'>
<el-input v-model='form.billsMaintCode' placeholder='请输入保养单号' />
</el-form-item>
</el-col>
<el-col :span='12'>
<el-form-item label='保养组别' prop='maintGroup'>
<el-input v-model='form.maintGroup' placeholder='请输入保养组别' />
</el-form-item>
</el-col>
<el-col :span='12'>
<el-form-item label='保养负责人' prop='maintSupervisor'>
<el-input v-model='form.maintSupervisor' placeholder='请输入保养负责人' />
</el-form-item>
</el-col>
<el-col :span='12'>
<el-form-item label='保养级别' prop='maintLevel'>
<el-select v-model='form.maintLevel' placeholder='请选择保养级别' style='width: 100%'>
<el-option
v-for='dict in maint_level'
:key='dict.value'
:label='dict.label'
:value='dict.value'
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span='12'>
<el-form-item label='保养状态' prop='maintStatus'>
<el-select v-model='form.maintStatus' placeholder='请选择保养状态' style='width: 100%' disabled>
<el-option
v-for='dict in maint_status'
:key='dict.value'
:label='dict.label'
:value='dict.value'
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span='12'>
<el-form-item label='计划保养时间' prop='planBeginTime'>
<el-date-picker clearable
v-model='form.planBeginTime'
type='datetime'
value-format='YYYY-MM-DD HH:mm:ss'
placeholder='请选择计划保养时间'
style='width: 100%'>
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span='12'>
<el-form-item label='计划完成时间' prop='planEndTime'>
<el-date-picker clearable
v-model='form.planEndTime'
type='datetime'
value-format='YYYY-MM-DD HH:mm:ss'
placeholder='请选择计划完成时间'
style='width: 100%'>
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span='12'>
<el-form-item label='实际开始时间' prop='realBeginTime'>
<el-date-picker clearable
v-model='form.realBeginTime'
type='datetime'
value-format='YYYY-MM-DD HH:mm:ss'
placeholder='请选择实际开始时间'
style='width: 100%'>
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span='12'>
<el-form-item label='实际完成时间' prop='realEndTime'>
<el-date-picker clearable
v-model='form.realEndTime'
type='datetime'
value-format='YYYY-MM-DD HH:mm:ss'
placeholder='请选择实际完成时间'
style='width: 100%'>
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span='12'>
<el-form-item label='保养完成率' prop='maintCompRate'>
<el-input-number v-model='form.maintCompRate' :min='0' :max='100' :precision='2' :step='1' />
</el-form-item>
</el-col>
<el-col :span='12'>
<el-form-item label='流程状态' prop='status'>
<el-select v-model='form.status' placeholder='请选择流程状态' disabled>
<el-option
v-for='dict in status_dict'
:key='dict.value'
:label='dict.label'
:value='dict.value'
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span='24'>
<el-form-item label='备注' prop='remark'>
<el-input v-model='form.remark' type='textarea' :rows='3' placeholder='请输入备注' />
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
<!-- 提交组件 -->
<submitVerify ref='submitVerifyRef' :task-variables='taskVariables' @submit-callback='submitCallback' />
<!-- 审批记录 -->
<approvalRecord ref='approvalRecordRef' />
<el-dialog v-model='dialogVisible.visible' :title='dialogVisible.title' :before-close='handleClose' width='500'>
<el-select v-model='flowCode' placeholder='Select' style='width: 240px'>
<el-option v-for='item in flowCodeOptions' :key='item.value' :label='item.label' :value='item.value' />
</el-select>
<template #footer>
<div class='dialog-footer'>
<el-button @click='handleClose'>取消</el-button>
<el-button type='primary' @click='submitFlow()'> 确认</el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name='MaintEdit' lang='ts'>
import { startWorkFlow } from '@/api/workflow/task';
import SubmitVerify from '@/components/Process/submitVerify.vue';
import ApprovalRecord from '@/components/Process/approvalRecord.vue';
import { AxiosResponse } from 'axios';
import { StartProcessBo } from '@/api/workflow/workflowCommon/types';
import {
DmsBillsMaintInstanceForm,
DmsBillsMaintInstanceQuery,
DmsBillsMaintInstanceVO
} from '@/api/dms/dmsBillsMaintInstance/types';
import {
getDmsBillsMaintInstance,
addDmsBillsMaintInstance,
updateDmsBillsMaintInstance
} from '@/api/dms/dmsBillsMaintInstance';
import { ElMessage } from 'element-plus';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const buttonLoading = ref(false);
const loading = ref(true);
//
const routeParams = ref<Record<string, any>>({});
const flowCodeOptions = [
{
value: 'planmaint',
label: '保养工单申请'
}
];
const flowCode = ref<string>('');
const dialogVisible = reactive<DialogOption>({
visible: false,
title: '流程定义'
});
//
const submitVerifyRef = ref<InstanceType<typeof SubmitVerify>>();
//
const approvalRecordRef = ref<InstanceType<typeof ApprovalRecord>>();
const dmsBillsMaintInstanceFormRef = ref<ElFormInstance>();
const submitFormData = ref<StartProcessBo>({
businessId: '',
flowCode: '',
variables: {}
});
const taskVariables = ref<Record<string, any>>({});
const initFormData: DmsBillsMaintInstanceForm = {
maintInstanceId: undefined,
planMaintId: undefined,
wfDefinitionId: undefined,
billsMaintCode: '',
maintGroup: '',
maintSupervisor: '',
maintLevel: '',
planBeginTime: '',
realBeginTime: '',
planEndTime: '',
realEndTime: '',
maintStatus: '1',
maintCompRate: 0,
remark: '',
status: 'waiting'
};
const data = reactive<PageData<DmsBillsMaintInstanceForm, DmsBillsMaintInstanceQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10
},
rules: {
billsMaintCode: [
{ required: true, message: '保养单号不能为空', trigger: 'blur' }
]
}
});
const handleClose = () => {
dialogVisible.visible = false;
flowCode.value = '';
buttonLoading.value = false;
};
const { form, rules } = toRefs(data);
/** 表单重置 */
const reset = () => {
if (!dmsBillsMaintInstanceFormRef.value) return;
dmsBillsMaintInstanceFormRef.value.resetFields();
Object.assign(form, initFormData);
};
/** 获取详情 */
const getInfo = async (id: string | number) => {
try {
const res = await getDmsBillsMaintInstance(id);
form.value = { ...res.data };
} catch (error) {
console.error('获取保养工单详情失败:', error);
}
};
/** 提交按钮 */
const submitForm = (status: string) => {
try {
dmsBillsMaintInstanceFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
let res: AxiosResponse<DmsBillsMaintInstanceVO>;
if (form.value.maintInstanceId) {
res = await updateDmsBillsMaintInstance(form.value);
} else {
res = await addDmsBillsMaintInstance(form.value);
}
form.value = res.data;
if (status === 'draft') {
buttonLoading.value = false;
proxy?.$modal.msgSuccess('暂存成功');
proxy.$tab.closePage(proxy.$route);
proxy.$router.go(-1);
} else {
if ((form.value.status === 'draft' && (flowCode.value === '' || flowCode.value === null)) || routeParams.value.type === 'add') {
flowCode.value = flowCodeOptions[0].value;
dialogVisible.visible = true;
return;
}
//穿
if (flowCode.value === '' || flowCode.value === null) {
flowCode.value = 'xx';
}
await handleStartWorkFlow(res.data);
}
}
});
} finally {
buttonLoading.value = false;
}
};
const submitFlow = async () => {
handleStartWorkFlow(form.value);
dialogVisible.visible = false;
};
//
const handleStartWorkFlow = async (data: DmsBillsMaintInstanceForm) => {
try {
submitFormData.value.flowCode = flowCode.value;
submitFormData.value.businessId = data.maintInstanceId;
//
taskVariables.value = {
data: data
};
submitFormData.value.variables = taskVariables.value;
const resp = await startWorkFlow(submitFormData.value);
if (submitVerifyRef.value) {
buttonLoading.value = false;
submitVerifyRef.value.openDialog(resp.data.taskId);
}
} finally {
buttonLoading.value = false;
}
};
//
const handleApprovalRecord = () => {
approvalRecordRef.value.init(form.value.maintInstanceId);
};
//
const submitCallback = async () => {
await proxy.$tab.closePage(proxy.$route);
proxy.$router.go(-1);
};
//
const goBack = () => {
proxy.$tab.closePage(proxy.$route);
proxy.$router.go(-1);
};
//
const approvalVerifyOpen = async () => {
submitVerifyRef.value.openDialog(routeParams.value.taskId);
};
//
const submitButtonShow = computed(() => {
return (
routeParams.value.type === 'add' ||
(routeParams.value.type === 'update' &&
form.value.status &&
(form.value.status === 'draft' || form.value.status === 'cancel' || form.value.status === 'back'))
);
});
//
const approvalButtonShow = computed(() => {
return routeParams.value.type === 'approval' && form.value.status && form.value.status === 'waiting';
});
//
const maint_level = ref([
{ value: '1', label: '日常保养' },
{ value: '2', label: '月度保养' },
{ value: '3', label: '年度保养' }
]);
//
const maint_status = ref([
{ value: '1', label: '待保养' },
{ value: '2', label: '保养中' },
{ value: '3', label: '已完成' }
]);
//
const status_dict = ref([
{ value: 'draft', label: '草稿' },
{ value: 'waiting', label: '待处理' },
{ value: 'processing', label: '处理中' },
{ value: 'completed', label: '已完成' },
{ value: 'cancel', label: '已取消' },
{ value: 'back', label: '已退回' }
]);
onMounted(() => {
nextTick(async () => {
routeParams.value = proxy.$route.query;
reset();
loading.value = false;
if (routeParams.value.type === 'update' || routeParams.value.type === 'view' || routeParams.value.type === 'approval') {
getInfo(routeParams.value.id);
}
});
});
</script>
Loading…
Cancel
Save