Files
geg-gas-web/src/views/approve/Appro/components/createForm.vue

332 lines
13 KiB
Vue
Raw Normal View History

2025-12-19 16:24:12 +08:00
<template>
<a-spin :spinning="spinning" tip="加载中...">
2026-01-08 17:53:29 +08:00
<div class="page-bg-wrap formViewStyle" :class="isViewForm ? 'pdcss':''">
2026-01-09 17:10:56 +08:00
<a-form ref="formRef" :model="formState" :rules="rules" v-bind="isViewFormTask?layoutNew:layout">
<viewForm v-if='isViewFormTask' :formState="formState" :isDisable="isDisable" :optionSelect="optionSelect"></viewForm>
<Card title="" :bordered="false" v-else>
2025-12-19 16:24:12 +08:00
<a-row>
<a-col :span="8">
2025-12-19 17:50:27 +08:00
<a-form-item label="编号" name="code">
<a-input v-model:value="formState.code" disabled />
2025-12-19 16:24:12 +08:00
</a-form-item>
</a-col>
2025-12-19 17:50:27 +08:00
<a-col :span="16">
2025-12-24 17:38:00 +08:00
<a-form-item label="标题" name="title" :label-col="{ span: 4 }" :wrapper-col="{ span: 24 }">
<a-input v-model:value="formState.title" :disabled="isDisable" placeholder="请输入标题"/>
2025-12-19 16:24:12 +08:00
</a-form-item>
</a-col>
<a-col :span="8">
2025-12-19 17:50:27 +08:00
<a-form-item label="签报类型" name="typeCode">
<a-select v-model:value="formState.typeCode" :disabled="isDisable" placeholder="请选择签报类型" style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.typeCodeList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
2025-12-30 15:28:43 +08:00
<!-- <a-col :span="8">
2025-12-19 17:50:27 +08:00
<a-form-item label="密级" name="securityCode">
<a-select v-model:value="formState.securityCode" :disabled="isDisable" placeholder="请选择密级" style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.securityCodeList" :key="item.code" :value="item.code">
{{ item.name }}
2025-12-19 16:24:12 +08:00
</a-select-option>
</a-select>
</a-form-item>
2025-12-30 15:28:43 +08:00
</a-col> -->
2025-12-19 17:50:27 +08:00
<a-col :span="8">
<a-form-item label="缓急" name="urgencyCode">
<a-select v-model:value="formState.urgencyCode" :disabled="isDisable" placeholder="请选择缓急" style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.urgencyCodeList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="8">
2025-12-23 17:51:40 +08:00
<a-form-item label="拟稿人" name="empName">
2025-12-24 17:38:00 +08:00
<a-input-search v-model:value="formState.empName" :disabled="isDisable" placeholder="请选择拟稿人" readonly @search="onSearchUser"/>
2025-12-19 17:50:27 +08:00
</a-form-item>
</a-col>
<a-col :span="8">
2025-12-25 17:51:53 +08:00
<a-form-item label="拟稿人所属部门" name="bDeptName">
<a-input-search v-model:value="formState.bDeptName" :disabled="isDisable" placeholder="请选择拟稿人部门" readonly @search="onSearch"/>
2025-12-19 17:50:27 +08:00
</a-form-item>
2025-12-19 16:24:12 +08:00
</a-col>
<a-col :span="8">
2025-12-23 17:51:40 +08:00
<a-form-item label="拟稿人所属公司" name="comName">
<a-input v-model:value="formState.comName" disabled/>
2025-12-19 16:24:12 +08:00
</a-form-item>
</a-col>
<a-col :span="8">
2025-12-19 17:50:27 +08:00
<a-form-item label="拟稿日期" name="dateAppro">
2025-12-24 17:38:00 +08:00
<a-date-picker v-model:value="formState.dateAppro" :disabled="isDisable" style="width: 100%" placeholder="请选择评价日期" />
2025-12-19 16:24:12 +08:00
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="审批状态" name="approCode">
<a-select v-model:value="formState.approCode" disabled style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.approCodeList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
2025-12-24 17:38:00 +08:00
<a-col :span="22">
2025-12-19 17:50:27 +08:00
<a-form-item label="内容摘要" name="content" :label-col="{ span: 3 }" :wrapper-col="{ span: 24 }">
<a-textarea v-model:value="formState.content" :disabled="isDisable" placeholder="请输入备注最多1000字" :maxlength="1000" :auto-size="{ minRows: 4, }"/>
</a-form-item>
</a-col>
2025-12-24 17:38:00 +08:00
<a-col :span="22">
2025-12-19 17:50:27 +08:00
<a-form-item label="备注" name="note" :label-col="{ span: 3 }" :wrapper-col="{ span: 24 }">
<a-textarea v-model:value="formState.note" :disabled="isDisable" placeholder="请输入备注最多200字" :maxlength="200" :auto-size="{ minRows: 2, maxRows: 5 }"/>
</a-form-item>
</a-col>
2025-12-19 16:24:12 +08:00
</a-row>
2025-12-31 10:10:53 +08:00
</Card>
<Card title="附件信息" :bordered="false" >
2025-12-19 16:24:12 +08:00
<UploadList :disabled="isDisable" :list="dataFile" :value="formState.filePath" :tableName="tableName" :columnName="columnName" @change="uploadListChange"/>
2025-12-31 10:10:53 +08:00
</Card>
2025-12-19 16:24:12 +08:00
</a-form>
</div>
2025-12-23 17:51:40 +08:00
<deptUserModal @register="register" @success="handleSuccess"/>
<deptListModal @register="registerDept" @success="handleSuccessDept" />
2025-12-19 16:24:12 +08:00
</a-spin>
</template>
<script lang="ts" setup>
2025-12-31 10:10:53 +08:00
import { Card } from 'ant-design-vue';
2025-12-19 16:24:12 +08:00
import { useRouter } from 'vue-router';
import { FromPageType, RecordType } from '/@/enums/workflowEnum';
import { ref, computed, onMounted, onBeforeMount, nextTick, defineAsyncComponent, reactive, defineComponent, watch} from 'vue';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { useMultipleTabStore } from '/@/store/modules/multipleTab';
import useEventBus from '/@/hooks/event/useEventBus';
import type { Rule } from 'ant-design-vue/es/form';
import { getDictionary } from '/@/api/sales/Customer';
import { useModal } from '/@/components/Modal';
2025-12-23 17:51:40 +08:00
import { addLngAppro,updateLngAppro,getLngAppro,getCompDept } from '/@/api/approve/Appro';
2025-12-19 16:24:12 +08:00
import dayjs from 'dayjs';
import { getAppEnvConfig } from '/@/utils/env';
import { message } from 'ant-design-vue';
import UploadList from '/@/components/Form/src/components/UploadList.vue';
2025-12-23 17:51:40 +08:00
import deptUserModal from '/@/components/common/deptUserModal.vue';
import deptListModal from '/@/components/common/deptListModal.vue';
2026-01-09 17:10:56 +08:00
import viewForm from './viewForm.vue';
2025-12-19 16:24:12 +08:00
import { Modal } from 'ant-design-vue';
2025-12-23 17:51:40 +08:00
import { useUserStore } from '/@/store/modules/user';
const userStore = useUserStore();
const userInfo = userStore.getUserInfo;
2025-12-19 16:24:12 +08:00
2025-12-22 17:27:18 +08:00
const tableName = 'Appro';
const columnName = 'Appro'
2025-12-19 16:24:12 +08:00
const formType = ref('2'); // 0 新建 1 修改 2 查看
const formRef = ref();
const props = defineProps({
disabled: false,
id: ''
});
const { bus, FORM_LIST_MODIFIED } = useEventBus();
const router = useRouter();
const { currentRoute } = router;
const isDisable = ref(false);
const { formPath } = currentRoute.value.query;
const pathArr = [];
const tabStore = useMultipleTabStore();
const formProps = ref(null);
const formId = ref(currentRoute.value?.params?.id);
const pageType = ref(currentRoute.value.query?.type);
const pageId = ref(currentRoute.value.query?.id)
2026-01-08 17:53:29 +08:00
const isViewForm = currentRoute.value.path.includes('viewForm')
2026-01-09 17:10:56 +08:00
const isViewFormTask = currentRoute.value.path.includes('processtasks')
2025-12-19 16:24:12 +08:00
const spinning = ref(false);
const curIdx = ref(null)
const { notification } = useMessage();
const { t } = useI18n();
const formState = reactive({
approCode: 'WTJ',
2025-12-19 17:50:27 +08:00
dateAppro: dayjs(new Date()),
2025-12-19 16:24:12 +08:00
});
const [register, { openModal:openModal}] = useModal();
2025-12-23 17:51:40 +08:00
const [registerDept, { openModal:openModalDept}] = useModal();
2025-12-19 16:24:12 +08:00
const rules: Record<string, Rule[]> = {
2025-12-22 17:27:18 +08:00
title: [{ required: true, message: "该项为必填项", trigger: 'change' }],
typeCode: [{ required: true, message: "该项为必填项", trigger: 'change' }],
securityCode: [{ required: true, message: "该项为必填项", trigger: 'change' }],
urgencyCode: [{ required: true, message: "该项为必填项", trigger: 'change' }],
2025-12-23 17:51:40 +08:00
empName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
2025-12-25 17:51:53 +08:00
bDeptName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
2025-12-30 15:28:43 +08:00
comName: [{ required: false, message: "该项为必填项", trigger: 'change' }],
2025-12-22 17:27:18 +08:00
dateAppro: [{ required: true, message: "该项为必填项", trigger: 'change' }],
content: [{ required: true, message: "该项为必填项", trigger: 'change' }],
2025-12-19 16:24:12 +08:00
};
const layout = {
2025-12-24 17:38:00 +08:00
labelCol: { span: 8 },
wrapperCol: { span: 16 },
2025-12-19 16:24:12 +08:00
}
2026-01-09 17:10:56 +08:00
const layoutNew = {
labelCol: { span: 6 },
wrapperCol: { span: 18 },
}
2025-12-19 16:24:12 +08:00
const dataFile = ref([]);
let optionSelect= reactive({
approCodeList: [],
2025-12-19 17:50:27 +08:00
typeCodeList: [],
securityCodeList: [],
urgencyCodeList: []
2025-12-19 16:24:12 +08:00
});
watch(
() => props.id,
(val) => {
if (val) {
getInfo(val)
}
},
{
immediate: true
}
);
watch(
() => props.disabled,
(val) => {
isDisable.value = val
},
{
immediate: true
}
);
onMounted(() => {
getOption()
if (pageId.value) {
getInfo(pageId.value)
2025-12-30 17:12:37 +08:00
if (currentRoute.value.query?.disabled) {
isDisable.value = true
}
2025-12-23 17:51:40 +08:00
} else {
formState.empName = userInfo.name
formState.empId = userInfo.id
2025-12-19 16:24:12 +08:00
}
});
const uploadListChange = (val) => {
dataFile.value = val
}
async function getInfo(id) {
spinning.value = true
try {
2025-12-23 17:51:40 +08:00
let data = await getLngAppro(id)
2025-12-19 16:24:12 +08:00
spinning.value = false
Object.assign(formState, {...data})
Object.assign(dataFile.value, formState.lngFileUploadList || [])
2025-12-19 17:50:27 +08:00
formState.dateAppro = formState.dateAppro ? dayjs(formState.dateAppro) : null
2025-12-19 16:24:12 +08:00
} catch (error) {
spinning.value = false
}
}
async function getOption() {
2025-12-19 17:50:27 +08:00
optionSelect.typeCodeList = await getDictionary('LNG_QB')
optionSelect.securityCodeList = await getDictionary('LNG_SECRET')
optionSelect.urgencyCodeList = await getDictionary('LNG_URGEN')
2025-12-19 16:24:12 +08:00
optionSelect.approCodeList = await getDictionary('LNG_APPRO')
2025-12-23 17:51:40 +08:00
2025-12-24 17:38:00 +08:00
if (!pageId.value) {
const res = await getCompDept(userInfo.id)
2025-12-25 17:51:53 +08:00
formState.bDeptName = res?.dept?.name
2025-12-24 17:38:00 +08:00
formState.bDeptId = res?.dept?.id
formState.comName = res?.comp?.name
formState.comId = res?.comp?.id
}
2025-12-23 17:51:40 +08:00
2025-12-19 16:24:12 +08:00
}
const onSearch = (val)=> {
2025-12-23 17:51:40 +08:00
openModalDept(true,{isUpdate: false})
}
const onSearchUser = (val)=> {
2025-12-19 16:24:12 +08:00
openModal(true,{isUpdate: false})
}
const handleSuccess = (val) => {
2025-12-23 17:51:40 +08:00
formState.empName = val[0].name
formState.empId = val[0].id
}
2025-12-24 17:38:00 +08:00
const handleSuccessDept = (val, info) => {
2025-12-25 17:51:53 +08:00
formState.bDeptName = val[0].name
2025-12-23 17:51:40 +08:00
formState.bDeptId = val[0].id
2025-12-24 17:38:00 +08:00
formState.comName = info.name
formState.comId = info.id
2025-12-19 16:24:12 +08:00
}
2025-12-19 17:50:27 +08:00
2025-12-19 16:24:12 +08:00
function close() {
tabStore.closeTab(currentRoute.value, router);
}
async function getFormValue() {
return formState
}
2026-01-14 11:27:01 +08:00
async function handleSubmit(type) {
2025-12-19 16:24:12 +08:00
try {
await formRef.value.validateFields();
let obj = {
...formState,
2026-01-06 17:46:04 +08:00
lngFileUploadList: dataFile.value,
2026-01-14 11:27:01 +08:00
approCode: pageType.value=='update' ? 'WTJ' : formState.approCode
2025-12-19 16:24:12 +08:00
}
spinning.value = true;
2025-12-23 17:51:40 +08:00
let request = !formState.id ? addLngAppro :updateLngAppro
2025-12-19 16:24:12 +08:00
try {
const data = await request(obj);
// 新增保存
if (data?.id) {
getInfo(data?.id)
}
// 同意保存不提示
if (!type) {
notification.success({
message: 'Tip',
description: data?.id ? t('新增成功!') : t('修改成功!')
}); //提示消息
}
return data?.id ? data : obj
} finally {
spinning.value = false;
}
} catch (errorInfo) {
spinning.value = false;
errorInfo?.errorFields?.length && notification.warning({
message: 'Tip',
description: '请完善信息'
});
return false
}
}
defineExpose({
handleSubmit,
getFormValue
});
</script>
<style lang="less" scoped>
.page-bg-wrap {
background-color: #fff;
}
.top-toolbar {
min-height: 44px;
margin-bottom: 12px;
border-bottom: 1px solid #eee;
}
2026-01-08 17:53:29 +08:00
.pdcss {
padding: 6px 12px !important;
}
2025-12-19 16:24:12 +08:00
</style>