Files
geg-gas-web/src/views/dayPlan/PngAppro/components/createForm.vue

245 lines
8.3 KiB
Vue
Raw Normal View History

2026-01-15 17:55:02 +08:00
<template>
<a-spin :spinning="spinning" tip="加载中...">
<div class="page-bg-wrap formViewStyle pdcss">
2026-01-20 17:32:35 +08:00
<div class="top-toolbar" >
2026-01-16 17:28:00 +08:00
<a-button style="margin-right: 10px" @click="close">
<slot name="icon"><close-outlined /></slot>关闭
</a-button>
2026-01-20 17:32:35 +08:00
<template v-if="currentRoute.query.type!=='compare'">
<a-button style="margin-right: 10px" type="primary" @click="checkBtn('agree')" v-if="!currentRoute.query.type">
<slot name="icon"><check-circle-outlined /></slot>通过
</a-button>
<a-button style="margin-right: 10px" @click="checkBtn('reject')" v-if="!currentRoute.query.type">
<slot name="icon"><stop-outlined /></slot>驳回
</a-button>
</template>
2026-01-16 17:28:00 +08:00
</div>
2026-01-15 17:55:02 +08:00
<a-form ref="formRef" :model="formState" :rules="rules" v-bind="layout">
2026-01-20 17:32:35 +08:00
<a-row v-if="!currentRoute.query.type">
2026-01-15 17:55:02 +08:00
<a-col :span="24">
<a-form-item label="批复意见" name="reply" :label-col="{ span: 3 }" :wrapper-col="{ span: 24 }">
2026-01-16 17:28:00 +08:00
<a-textarea v-model:value="formState.reply" :disabled="currentRoute.query.type=='view'" placeholder="请输入备注" :auto-size="{ minRows: 2, maxRows: 5 }"/>
2026-01-15 17:55:02 +08:00
</a-form-item>
</a-col>
</a-row>
2026-01-20 17:32:35 +08:00
<Card :title="titleNew" :bordered="false" v-if="currentRoute.query.type=='compare'&&titleNew">
2026-01-22 17:31:32 +08:00
<basicForm ref="basicFormRef" :formObj="formStateNew" :changeList="diffResultList" :list="dataListNew" :disable="currentRoute.query.type"></basicForm>
2026-01-15 17:55:02 +08:00
</Card>
2026-01-23 11:20:27 +08:00
<Card :title="title" :bordered="false" v-if="title">
2026-01-21 18:09:53 +08:00
<basicForm ref="basicFormRef" :formObj="formState" :list="dataList" :disable="currentRoute.query.type"></basicForm>
</Card>
2026-01-15 17:55:02 +08:00
</a-form>
</div>
</a-spin>
</template>
<script lang="ts" setup>
import { Card } from 'ant-design-vue';
import { useRouter } from 'vue-router';
import { FromPageType, RecordType } from '/@/enums/workflowEnum';
import { ref, computed, onMounted, onBeforeMount, nextTick, defineAsyncComponent, reactive, defineComponent, watch} from 'vue';
2026-01-16 17:28:00 +08:00
import { CheckCircleOutlined, StopOutlined, CloseOutlined, } from '@ant-design/icons-vue';
2026-01-15 17:55:02 +08:00
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';
2026-01-20 17:32:35 +08:00
import { getLngPngAppro,approveLngPngAppro,getLngPngApproCompare,approveLngPngApproSZ,approveLngPngApproGD } from '/@/api/dayPlan/PngAppro';
2026-01-15 17:55:02 +08:00
import dayjs from 'dayjs';
import { getAppEnvConfig } from '/@/utils/env';
import { message } from 'ant-design-vue';
import { useUserStore } from '/@/store/modules/user';
2026-01-16 17:28:00 +08:00
import basicForm from './basicForm.vue'
2026-01-26 17:41:30 +08:00
import NP from 'number-precision';
2026-01-15 17:55:02 +08:00
const userStore = useUserStore();
const userInfo = userStore.getUserInfo;
const { bus, FORM_LIST_MODIFIED } = useEventBus();
const router = useRouter();
const { currentRoute } = router;
const { formPath } = currentRoute.value.query;
const pathArr = [];
const tabStore = useMultipleTabStore();
2026-01-23 11:20:27 +08:00
2026-01-15 17:55:02 +08:00
const pageId = ref(currentRoute.value.query?.id)
const spinning = ref(false);
const { notification } = useMessage();
const { t } = useI18n();
const formState = reactive({
2026-01-20 17:32:35 +08:00
});
const formStateNew = reactive({
2026-01-15 17:55:02 +08:00
});
const [register, { openModal:openModal}] = useModal();
const rules= reactive({
// kNo: [{ required: true, message: "该项为必填项", trigger: 'change' }],
});
const layout = {
labelCol: { span: 9 },
wrapperCol: { span: 18 },
}
2026-01-16 17:28:00 +08:00
const title = ref('日计划审批')
2026-01-20 17:32:35 +08:00
const titleNew = ref('')
2026-01-15 17:55:02 +08:00
const dataList = ref([])
2026-01-20 17:32:35 +08:00
const dataListNew = ref([])
2026-01-16 17:28:00 +08:00
const basicFormRef = ref()
2026-01-22 17:31:32 +08:00
const diffResultList = ref([])
2026-01-15 17:55:02 +08:00
onMounted(() => {
if (pageId.value) {
2026-01-16 17:28:00 +08:00
if (currentRoute.value.query.type=='compare') {
getCompareInfo(pageId.value)
return
}
2026-01-15 17:55:02 +08:00
getInfo(pageId.value)
}
});
2026-01-16 17:28:00 +08:00
async function getCompareInfo(id) {
spinning.value = true
2026-01-15 17:55:02 +08:00
try {
2026-01-23 11:20:27 +08:00
let data = await getLngPngApproCompare(id) || {}
2026-01-15 17:55:02 +08:00
spinning.value = false
2026-01-22 17:31:32 +08:00
diffResultList.value = data.diffResultList || []
2026-01-28 18:21:33 +08:00
let obj = changeData(data.oldBean || {})
2026-01-20 17:32:35 +08:00
Object.assign(formState, {...obj.params})
2026-01-23 11:20:27 +08:00
Object.assign(dataList.value, obj.list || [])
title.value = formState.verNo? ('版本V'+ formState.verNo) : ''
2026-01-20 17:32:35 +08:00
2026-01-22 17:31:32 +08:00
let obj1 = changeData(data.newBean || {})
2026-01-20 17:32:35 +08:00
Object.assign(formStateNew, {...obj1.params})
2026-01-23 11:20:27 +08:00
Object.assign(dataListNew.value, obj1.list || [])
2026-01-22 17:31:32 +08:00
titleNew.value = formStateNew.verNo ? ('版本V'+ formStateNew.verNo) : ''
2026-01-15 17:55:02 +08:00
} catch (error) {
2026-01-28 18:21:33 +08:00
console.log(error, 'error')
2026-01-15 17:55:02 +08:00
spinning.value = false
}
2026-01-16 17:28:00 +08:00
2026-01-15 17:55:02 +08:00
}
2026-01-16 17:28:00 +08:00
async function getInfo(id) {
spinning.value = true
try {
let data = await getLngPngAppro(id)
spinning.value = false
2026-01-20 17:32:35 +08:00
let obj = changeData(data)
Object.assign(formState, {...obj.params})
2026-01-23 11:20:27 +08:00
Object.assign(dataList.value, obj.list || [])
2026-01-20 17:32:35 +08:00
} catch (error) {
spinning.value = false
2026-01-16 17:28:00 +08:00
}
2026-01-20 17:32:35 +08:00
}
const changeData = (obj) => {
2026-01-28 18:21:33 +08:00
if (Object.keys(obj).length === 0) return {
list : [],
params: {}
}
2026-01-23 11:20:27 +08:00
let arr = obj.lngPngApproPurList || []
2026-01-26 17:41:30 +08:00
obj.qtyContractM3 = NP.divide(Number(obj.qtyContractM3), 10000)
obj.qtyPlanM3 = NP.divide(Number(obj.qtyPlanM3), 10000)
obj.qtyDemandM3 = NP.divide(Number(obj.qtyDemandM3), 10000)
obj.qtySalesM3 = NP.divide(Number(obj.qtySalesM3), 10000)
2026-01-15 17:55:02 +08:00
let num = 0;
2026-01-16 17:28:00 +08:00
let num1 = 0;
2026-01-22 17:31:32 +08:00
arr.length && arr.forEach(v => {
2026-01-26 17:41:30 +08:00
v.qtyDemandM3 = NP.divide(Number(v.qtyDemandM3), 10000)
v.qtySalesM3 = NP.divide(Number(v.qtySalesM3), 10000)
num=NP.plus(num, (Number(v.qtySalesGj) || 0))
num1=NP.plus(num1, (Number(v.qtySalesM3) || 0))
2026-01-16 17:28:00 +08:00
});
2026-01-20 17:32:35 +08:00
obj.qtySalesGj = num
obj.qtySalesM3 = num1
return {
list : arr,
params: obj
2026-01-16 17:28:00 +08:00
}
2026-01-20 17:32:35 +08:00
}
2026-01-15 17:55:02 +08:00
function close() {
tabStore.closeTab(currentRoute.value, router);
}
2026-01-16 17:28:00 +08:00
async function checkBtn(type) {
let data = basicFormRef.value.getFormValue()
let arr = JSON.parse(JSON.stringify(data.list))
arr.forEach(v=> {
2026-01-26 17:41:30 +08:00
v.qtyDemandM3 = NP.times(Number(v.qtyDemandM3), 10000)
v.qtySalesM3 = NP.times(Number(v.qtySalesM3), 10000)
2026-01-16 17:28:00 +08:00
})
let obj = {
...data.formInfo,
2026-01-26 17:41:30 +08:00
qtyContractM3: NP.times(Number(data.formInfo.qtyContractM3), 10000),
qtyPlanM3: NP.times(Number(data.formInfo.qtyPlanM3), 10000),
qtyDemandM3: NP.times(Number(data.formInfo.qtyDemandM3), 10000),
qtySalesM3: NP.times(Number(data.formInfo.qtySalesM3), 10000),
2026-01-16 17:28:00 +08:00
lngPngApproPurList:arr
}
let params = {
result: type == 'agree' ? 'C' : 'R',
remark: formState.reply,
2026-01-20 17:32:35 +08:00
data: [obj]
2026-01-16 17:28:00 +08:00
}
2026-01-23 11:20:27 +08:00
2026-01-15 17:55:02 +08:00
try {
2026-01-16 17:28:00 +08:00
if (type == 'reject') {
if (!formState.reply) {
message.warn('请输入批复意见')
return
2026-01-15 17:55:02 +08:00
}
}
2026-01-23 11:20:27 +08:00
spinning.value = true;
2026-01-29 13:34:08 +08:00
await approveLngPngAppro(params);
2026-01-16 17:28:00 +08:00
spinning.value = false;
notification.success({
2026-01-15 17:55:02 +08:00
message: 'Tip',
2026-01-16 17:28:00 +08:00
description: type == 'agree' ? '审批通过':'已驳回'
}); //提示消息
setTimeout(() => {
bus.emit(FORM_LIST_MODIFIED, {});
close();
}, 500);
}catch (errorInfo) {
spinning.value = false;
2026-01-15 17:55:02 +08:00
}
}
</script>
<style lang="less" scoped>
.page-bg-wrap {
background-color: #fff;
}
.top-toolbar {
min-height: 44px;
margin-bottom: 12px;
border-bottom: 1px solid #eee;
}
.pdcss {
2026-01-16 17:28:00 +08:00
padding:0px 12px 6px 12px !important;
2026-01-15 17:55:02 +08:00
}
.dot {
margin-right: 10px;
display: flex;
align-items: center;
i{
padding: 5px;
font-style: normal;
}
span{
width: 10px !important;
height: 10px !important;
border-radius: 50%;
background: red;
display: block;
}
}
</style>