Files
geg-gas-web/src/views/contract/ContractSales/components/createForm.vue

672 lines
28 KiB
Vue
Raw Normal View History

2026-01-06 17:46:04 +08:00
<template>
<a-spin :spinning="spinning" tip="加载中...">
<div class="page-bg-wrap formViewStyle">
<a-form ref="formRef" :model="formState" :rules="rules" v-bind="layout">
<Card title="合同档案" :bordered="false" >
<a-row>
<a-col :span="8">
<a-form-item label="合同号" name="kNo">
<a-input v-model:value="formState.kNo" :disabled="isDisable" style="width: 65%" /><a-button v-if="!isDisable" type="primary" @click="onContract">关联合同</a-button>
</a-form-item>
</a-col>
<a-col :span="16">
<a-form-item label="合同名称" name="kName" :label-col="{ span: 4 }" :wrapper-col="{ span: 24 }">
<a-input v-model:value="formState.kName" placeholder="请输入合同名称" :disabled="isDisable"/>
</a-form-item>
</a-col>
<a-col :span="8">
2026-01-07 17:38:57 +08:00
<a-form-item label="合同期限" name="kPeriod">
<a-select v-model:value="formState.kPeriod" :disabled="isDisable" placeholder="请选择合同期限" style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.kPeriodList" :key="item.code" :value="item.code">
2026-01-06 17:46:04 +08:00
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="有效期开始" name="dateFrom">
<a-date-picker v-model:value="formState.dateFrom" style="width: 100%" :disabled="isDisable" :disabled-date="disabledDateStart" placeholder="请选择开始日期" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="有效期结束" name="dateTo">
<a-date-picker v-model:value="formState.dateTo" style="width: 100%" :disabled="isDisable" :disabled-date="disabledDateEnd" placeholder="请选择结束日期" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="合同签订日期" name="dateSign">
<a-date-picker v-model:value="formState.dateSign" style="width: 100%" :disabled="isDisable" placeholder="请选择合同签订日期" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="确认函开始日" name="dateCfmFrom">
<a-date-picker v-model:value="formState.dateCfmFrom" style="width: 100%" :disabled="isDisable" :disabled-date="disabledDateCfmStart" placeholder="请选择确认函开始日" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="确认函结束日" name="dateCfmTo">
<a-date-picker v-model:value="formState.dateCfmTo" style="width: 100%" :disabled="isDisable" :disabled-date="disabledDateCfmEnd" placeholder="请选择确认函结束日" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="客户" name="cpName">
<a-input-search v-model:value="formState.cpName" :disabled="isDisable" placeholder="请选择客户" readonly @search="onSearchCustomer"/>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="业务人员" name="empName">
<a-input-search v-model:value="formState.empName" :disabled="isDisable" placeholder="请选择业务联系人" readonly @search="onSearchUser"/>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="业务部门" name="bDeptName">
<a-input-search v-model:value="formState.bDeptName" :disabled="isDisable" placeholder="请选择业务部门" readonly @search="onSearch"/>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="合同主体" name="comName">
<a-input v-model:value="formState.comName" disabled />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="定价机制" name="prcTypeCode">
2026-01-07 17:38:57 +08:00
<a-select v-model:value="formState.prcTypeCode" :disabled="isDisable" style="width: 100%" allow-clear>
2026-01-06 17:46:04 +08:00
<a-select-option v-for="item in optionSelect.prcTypeCodeList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="量价周期" name="periodTypeCode">
2026-01-07 17:38:57 +08:00
<a-select v-model:value="formState.periodTypeCode" :disabled="isDisable" style="width: 100%" allow-clear>
2026-01-06 17:46:04 +08:00
<a-select-option v-for="item in optionSelect.periodTypeCodeList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="主计量单位" name="uomCode">
2026-01-07 17:38:57 +08:00
<a-select v-model:value="formState.uomCode" :disabled="isDisable" style="width: 100%" allow-clear>
2026-01-06 17:46:04 +08:00
<a-select-option v-for="item in optionSelect.uomCodeList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</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>
<a-col :span="22">
<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>
</a-row>
</Card>
<Card title="业务信息" :bordered="false" >
<h4>交割点</h4>
<a-button type="primary" style="margin-bottom: 10px;margin-right: 10px;" @click="addUpLoad" v-if="!isDisable">新增</a-button>
<a-button type="primary" @click="deleteUpLoad" v-if="!isDisable">删除</a-button>
2026-01-07 17:38:57 +08:00
<div v-for="(item, idx) in dataListPoint" class="tbStyle">
2026-01-06 17:46:04 +08:00
<a-row>
<a-col :span="8">
2026-01-07 17:38:57 +08:00
<a-form-item name="pointDelyName">
<template #label>
<span><span style="color:red">*</span>计量交割点</span>
</template>
2026-01-06 17:46:04 +08:00
<a-input-search v-model:value="item.pointDelyName" :disabled="isDisable" placeholder="请选择计量交割点" readonly @search="onSearchDownLoad('dely', idx)"/>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="交气点" name="pointTransName">
<a-input-search v-model:value="item.pointTransName" :disabled="isDisable" placeholder="请选择交气点" readonly @search="onSearchDownLoad('trans', idx)"/>
</a-form-item>
</a-col>
<a-col :span="8">
2026-01-07 17:38:57 +08:00
<a-form-item name="transSign">
<template #label>
<span><span style="color:red">*</span>是否托运</span>
</template>
2026-01-08 11:39:56 +08:00
<a-select v-model:value="item.transSign" :disabled="isDisable" style="width: 100%" allow-clear>
2026-01-06 17:46:04 +08:00
<a-select-option v-for="item in optionSelect.transSignList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="备注" name="note" :label-col="{ span: 3 }" :wrapper-col="{ span: 24 }">
<a-textarea v-model:value="item.note" :disabled="isDisable" placeholder="请输入备注" :auto-size="{ minRows: 2, maxRows: 5 }"/>
</a-form-item>
</a-col>
2026-01-07 17:38:57 +08:00
<h4 style="margin: 5px 0">上载信息</h4>
<a-table style="width: 100%" :columns="columnsUp" :data-source="item.purList || []" :pagination="false" :scroll="{x: 300}"></a-table>
<h4 style="margin: 5px 0">管输(是否托运)</h4>
<a-table style="width: 100%" :columns="columnsTrans" :data-source="item.transList || []" :pagination="false" :scroll="{x: 300}"></a-table>
2026-01-06 17:46:04 +08:00
</a-row>
</div>
</Card>
<Card title="合同约定" :bordered="false" >
2026-01-08 11:39:56 +08:00
<contractQtyList :list="dataListContractAgree" :disabled="isDisable" :optionSelect="optionSelect" ref="contractQty"></contractQtyList>
2026-01-06 17:46:04 +08:00
</Card>
<Card title="附件信息" :bordered="false" >
<UploadList :disabled="isDisable" :list="dataFile" :value="formState.filePath" :tableName="tableName" :columnName="columnName" @change="uploadListChange"/>
</Card>
2026-01-08 11:39:56 +08:00
<Card title="关联合同信息" :bordered="false" >
<correlationContractFactList :list="dataListContractFact" :disabled="isDisable" @change="getApproContractFactList"></correlationContractFactList>
</Card>
<Card title="签报列表" :bordered="false" >
<correlationApproList :list="dataListAppro" :disabled="isDisable" @change="getApproList"></correlationApproList>
</Card>
2026-01-06 17:46:04 +08:00
</a-form>
</div>
<deptUserModal @register="register" @success="handleSuccess"/>
<deptListModal @register="registerDept" @success="handleSuccessDept" />
<contractFactListModal @register="registerContractFact" @success="handleSuccessContractFact" />
<downloadPointModal @register="registerDownLoad" @success="handleSuccessDownLoad" />
2026-01-07 17:38:57 +08:00
<customerListModal @register="registerCustomer" @success="handleSuccessCustomer" selectType="radio" />
2026-01-06 17:46:04 +08:00
</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';
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-07 17:38:57 +08:00
import { addLngContract,updateLngContract, getLngContract, getTransList, getPurList } from '/@/api/contract/ContractSales';
2026-01-06 17:46:04 +08:00
import { getLngAppro,getCompDept } from '/@/api/approve/Appro';
import dayjs from 'dayjs';
import { getAppEnvConfig } from '/@/utils/env';
import { message } from 'ant-design-vue';
import UploadList from '/@/components/Form/src/components/UploadList.vue';
import deptUserModal from '/@/components/common/deptUserModal.vue';
import deptListModal from '/@/components/common/deptListModal.vue';
import correlationApproList from '/@/components/common/correlationApproList.vue';
import correlationContractFactList from '/@/components/common/correlationContractFactList.vue';
import contractFactListModal from '/@/components/common/contractFactListModal.vue';
import downloadPointModal from '/@/components/common/downloadPointModal.vue';
import customerListModal from '/@/components/common/customerListModal.vue';
2026-01-08 11:39:56 +08:00
import contractQtyList from '/@/components/common/contractQtyList.vue';
2026-01-06 17:46:04 +08:00
import { useUserStore } from '/@/store/modules/user';
const userStore = useUserStore();
const userInfo = userStore.getUserInfo;
2026-01-07 17:38:57 +08:00
const tableName = 'ContractSales';
const columnName = 'ContractSales'
2026-01-06 17:46:04 +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 11:39:56 +08:00
const contractQty = ref()
2026-01-06 17:46:04 +08:00
const spinning = ref(false);
const curIdx = ref(null)
const { notification } = useMessage();
const { t } = useI18n();
2026-01-07 17:38:57 +08:00
const hasDel = ref(false)
2026-01-06 17:46:04 +08:00
const formState = reactive({
approCode: 'WTJ',
typeCode: 'SP',
onlineSign: 'N',
cpTableName: 'lng_customer',
2026-01-07 17:38:57 +08:00
curCode: 'CNY',
lngContractSalesPngList: [{}]
2026-01-06 17:46:04 +08:00
});
const [register, { openModal:openModal}] = useModal();
const [registerDept, { openModal:openModalDept}] = useModal();
const [registerContractFact, { openModal:openModalContractFact}] = useModal();
const [registerDownLoad, { openModal:openModalDownLoad}] = useModal();
const [registerCustomer, { openModal:openModalCustomer}] = useModal();
const rules= reactive({
kNo: [{ required: true, message: "该项为必填项", trigger: 'change' }],
kName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
cpName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
prcTypeCode: [{ required: true, message: "该项为必填项", trigger: 'change' }],
uomCode: [{ required: true, message: "该项为必填项", trigger: 'change' }],
empName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
bDeptName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
dateTo:[{ required: true, message: "该项为必填项", trigger: 'change' }],
dateFrom:[{ required: true, message: "该项为必填项", trigger: 'change' }]
});
const layout = {
labelCol: { span: 8 },
wrapperCol: { span: 16 },
}
const columnsUp = ref([
{ title: t('序号'), dataIndex: 'index', key: 'index', sorter: true, customRender: (column) => `${column.index + 1}` ,width: 80},
{ title: t('交割点'), dataIndex: 'pointDelyName', sorter: true, width:150},
{ title: t('是否托运'), dataIndex: 'transName', sorter: true, width: 150},
{ title: t('供应商'), dataIndex: 'cpName', sorter: true, width: 130},
{ title: t('合同名称'), dataIndex: 'kName', sorter: true, width: 100},
{ title: t('上载点'), dataIndex: 'pointUpName', sorter: true, width: 150},
{ title: t('有效期开始'), dataIndex: 'dateFrom', sorter: true, width: 150},
{ title: t('有效期结束'), dataIndex: 'dateTo', sorter: true, width: 150},
{ title: t('备注)'), dataIndex: 'note', sorter: true, width: 180}
])
const columnsTrans = ref([
{ title: t('序号'), dataIndex: 'index', key: 'index', sorter: true, customRender: (column) => `${column.index + 1}` ,width: 80},
{ title: t('交割点'), dataIndex: 'pointDelyName', sorter: true, width:150},
{ title: t('是否托运'), dataIndex: 'transName', sorter: true, width: 150},
{ title: t('托运商'), dataIndex: 'cpName', sorter: true, width: 130},
{ title: t('合同名称'), dataIndex: 'kName', sorter: true, width: 100},
{ title: t('管输上载点'), dataIndex: 'pointUpTransName', sorter: true, width: 150},
{ title: t('管输下载点'), dataIndex: 'pointDelyTransName', sorter: true, width: 150},
{ title: t('有效期开始'), dataIndex: 'dateFrom', sorter: true, width: 150},
{ title: t('有效期结束'), dataIndex: 'dateTo', sorter: true, width: 150},
{ title: t('备注)'), dataIndex: 'note', sorter: true, width: 180}
])
const dataListContractAgree = ref([])
const dataFile = ref([]);
const dataListAppro = ref([])
const dataListContractFact = ref([])
const dataListPoint = ref([{
2026-01-07 17:38:57 +08:00
"pointTransCode": "",
2026-01-06 17:46:04 +08:00
"transSign": "",
"note": null,
2026-01-07 17:38:57 +08:00
'pointDelyCode':'',
2026-01-06 17:46:04 +08:00
}])
let optionSelect= reactive({
approCodeList: [],
2026-01-07 17:38:57 +08:00
kPeriodList: [],
2026-01-06 17:46:04 +08:00
prcTypeCodeList: [],
uomCodeList: [],
periodTypeCodeList: [],
transSignList: [],
baseIncList: [],
zfbyTypeCodeList: []
});
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)
} else {
formState.empName = userInfo.name
formState.empId = userInfo.id
formState.tel = userInfo.mobile
}
});
const uploadListChange = (val) => {
dataFile.value = val
}
async function getInfo(id) {
spinning.value = true
try {
let data = await getLngContract(id)
spinning.value = false
Object.assign(formState, {...data})
2026-01-07 17:38:57 +08:00
Object.assign(dataListPoint.value, formState.lngContractSalesPngPointList || [{}])
Object.assign(dataListContractAgree.value, formState.lngContractSalesPngQtyList || [])
2026-01-06 17:46:04 +08:00
Object.assign(dataFile.value, formState.lngFileUploadList || [])
2026-01-07 17:38:57 +08:00
Object.assign(dataListContractFact.value, formState.lngContractFactList || [])
Object.assign(dataListAppro.value, formState.lngApproVoList || [])
2026-01-06 17:46:04 +08:00
formState.dateCfmFrom = formState.dateCfmFrom ? dayjs(formState.dateCfmFrom) : null
formState.dateCfmTo = formState.dateCfmTo ? dayjs(formState.dateCfmTo) : null
formState.dateSign = formState.dateSign ? dayjs(formState.dateSign) : null
formState.dateFrom = formState.dateFrom ? dayjs(formState.dateFrom) : null
formState.dateTo = formState.dateTo ? dayjs(formState.dateTo) : null
2026-01-07 17:38:57 +08:00
formState.prcTypeCode = (formState?.lngContractSalesPngList[0] || {}).prcTypeCode
formState.periodTypeCode = (formState?.lngContractSalesPngList[0] || {}).periodTypeCode
formState.uomCode = (formState?.lngContractSalesPngList[0] || {}).uomCode
dataListAppro.value.forEach(v => {
v.approId = v.id
})
dataListContractFact.value.forEach(v => {
v.kFactId = v.id
})
dataListContractAgree.value.forEach(v => {
2026-01-06 17:46:04 +08:00
v.qtyM3Month = Number(v.qtyM3Month)/10000
v.qtyM3Day = Number(v.qtyM3Day)/10000
2026-01-07 17:38:57 +08:00
v.dateFrom = v.dateFrom ? dayjs(v.dateFrom) : null
v.dateTo = v.dateTo ? dayjs(v.dateTo) : null
2026-01-06 17:46:04 +08:00
});
2026-01-07 17:38:57 +08:00
getList()
2026-01-06 17:46:04 +08:00
} catch (error) {
2026-01-07 17:38:57 +08:00
console.log(error, 'error')
2026-01-06 17:46:04 +08:00
spinning.value = false
}
}
2026-01-07 17:38:57 +08:00
async function getList () {
for (let i = 0; i < dataListPoint.value.length; i++) {
dataListPoint.value[i].transList = await getTransList(dataListPoint.value[i].pointDelyCode)
dataListPoint.value[i].purList = await getPurList(dataListPoint.value[i].pointDelyCode)
}
}
2026-01-06 17:46:04 +08:00
async function getOption() {
2026-01-07 17:38:57 +08:00
optionSelect.kPeriodList = await getDictionary('LNG_K_PER')
2026-01-06 17:46:04 +08:00
optionSelect.prcTypeCodeList = await getDictionary('LNG_PRC')
optionSelect.periodTypeCodeList = await getDictionary('LNG_PRC_P')
optionSelect.uomCodeList = await getDictionary('LNG_UOM')
optionSelect.approCodeList = await getDictionary('LNG_APPRO')
optionSelect.transSignList = await getDictionary('LNG_YN')
optionSelect.baseIncList = await getDictionary('LNG_BASE')
optionSelect.zfbyTypeCodeList = await getDictionary('LNG_ZFBY')
if (!pageId.value) {
const res = await getCompDept(userInfo.id)
formState.bDeptName = res?.dept?.name
formState.bDeptId = res?.dept?.id
formState.comName = res?.comp?.name
formState.comId = res?.comp?.id
}
}
const getApproList = (val) => {
dataListAppro.value = val
}
const getApproContractFactList = (val) => {
2026-01-07 17:38:57 +08:00
console.log(val, 'dataListContractFact')
2026-01-06 17:46:04 +08:00
dataListContractFact.value = val
}
const disabledDateStart = (startValue) => {
const endValue = formState?.dateTo;
if (!startValue || !endValue) {
return false
}
return startValue.valueOf() >= endValue.valueOf();
}
const disabledDateEnd = (endValue) => {
const startValue = formState?.dateFrom;
if (!endValue || !startValue) {
return false
}
return endValue.valueOf() <= startValue.valueOf();
}
const disabledDateCfmStart = (startValue) => {
const endValue = formState?.dateCfmTo;
if (!startValue || !endValue) {
return false
}
return startValue.valueOf() >= endValue.valueOf();
}
const disabledDateCfmEnd = (endValue) => {
const startValue = formState?.dateCfmFrom;
if (!endValue || !startValue) {
return false
}
return endValue.valueOf() <= startValue.valueOf();
}
const onSearch = (val)=> {
openModalDept(true,{isUpdate: false})
}
const onSearchCustomer = () => {
openModalCustomer(true,{isUpdate: false})
}
const onSearchUser = (val)=> {
openModal(true,{isUpdate: false})
}
const onContract = (val)=> {
openModalContractFact(true,{isUpdate: false})
}
const onSearchDownLoad = (val, index)=> {
curIdx.value = index
openModalDownLoad(true,{isUpdate: false, type: val})
}
const addUpLoad = ()=> {
dataListPoint.value.push({
2026-01-07 17:38:57 +08:00
"pointTransCode": "",
2026-01-06 17:46:04 +08:00
"transSign": "",
"note": null,
2026-01-07 17:38:57 +08:00
'pointDelyCode':'',
transList: [],
purList: []
2026-01-06 17:46:04 +08:00
})
}
const deleteUpLoad = () => {
2026-01-07 17:38:57 +08:00
if (dataListPoint.value[dataListPoint.value.length -1].id) {
hasDel.value = true
}
2026-01-06 17:46:04 +08:00
if (dataListPoint.value.length == 1) return
dataListPoint.value.pop()
}
const handleSuccess = (val) => {
formState.empName = val[0].name
formState.empId = val[0].id
formState.tel = val[0].mobile
}
const handleSuccessDept = (val, info) => {
formState.bDeptName = val[0].name
formState.bDeptId = val[0].id
formState.comName = info.name
formState.comId = info.id
}
2026-01-07 17:38:57 +08:00
const handleSuccessCustomer = (val) => {
formState.cpCode = val[0].cuCode
formState.cpName = val[0].cuName
2026-01-06 17:46:04 +08:00
}
const handleSuccessContractFact = (val) => {
val.forEach(v => {
2026-01-07 17:38:57 +08:00
v.kFactId = v.id
v.id = null
2026-01-06 17:46:04 +08:00
})
if (!dataListContractFact.value.length) {
dataListContractFact.value = val
return
}
let arr = []
val.forEach(v => {
dataListContractFact.value.forEach(i => {
if (v.kNo == i.kNo){
message.warning(v.kNo + '已重复, 合同不需要重复选择')
} else {
arr.push(v)
}
})
})
dataListContractFact.value = unique([...dataListContractFact.value, ...arr], 'kNo')
}
2026-01-07 17:38:57 +08:00
const handleSuccessDownLoad = async (val, type) => {
2026-01-06 17:46:04 +08:00
if (type == 'trans') {
dataListPoint.value[curIdx.value].pointTransCode = val[0].code
dataListPoint.value[curIdx.value].pointTransName = val[0].fullName
} else {
dataListPoint.value[curIdx.value].pointDelyCode = val[0].code
dataListPoint.value[curIdx.value].pointDelyName = val[0].fullName
2026-01-07 17:38:57 +08:00
dataListPoint.value[curIdx.value].transList = await getTransList(dataListPoint.value[curIdx.value].pointDelyCode)
dataListPoint.value[curIdx.value].purList = await getPurList(dataListPoint.value[curIdx.value].pointDelyCode)
2026-01-06 17:46:04 +08:00
}
}
function unique(arr, u_key) {
const map = new Map()
arr.forEach((item, index) => {
if (!map.has(item[u_key])) {
map.set(item[u_key], item)
}
})
return [...map.values()]
}
function close() {
tabStore.closeTab(currentRoute.value, router);
}
async function getFormValue() {
return formState
}
2026-01-14 11:05:28 +08:00
async function handleSubmit(type, updateType) {
2026-01-06 17:46:04 +08:00
try {
await formRef.value.validateFields();
2026-01-08 11:39:56 +08:00
let arr = contractQty.value.getQtyList()
2026-01-06 17:46:04 +08:00
for(let i=0; i<arr.length; i++) {
2026-01-08 17:53:29 +08:00
let isFlag = !arr[i].dateFrom || !arr[i].dateTo || !arr[i].baseInc || arr[i].qtyGjMonth == null || arr[i].qtyGjMonth === ''|| arr[i].qtyM3Month == null || arr[i].qtyM3Month === ''
2026-01-06 17:46:04 +08:00
if (isFlag) {
message.warn('请完善合同约定必选项')
return
}
arr[i].dateFrom = dayjs(arr[i].dateFrom).format('YYYY-MM-DD HH:mm:ss')
arr[i].dateTo = dayjs(arr[i].dateTo).format('YYYY-MM-DD HH:mm:ss')
arr[i].qtyM3Month = Number(arr[i].qtyM3Month)*10000
arr[i].qtyM3Day = Number(arr[i].qtyM3Day)*10000
}
2026-01-07 17:38:57 +08:00
dataListAppro.value.forEach((v,idx)=>{
v.tableName = 'Ing_contract'
v.sort = idx
2026-01-06 17:46:04 +08:00
})
2026-01-07 17:38:57 +08:00
dataListContractFact.value.forEach((v,idx)=> {
v.sort = idx
})
for(let i=0; i<dataListPoint.value.length; i++) {
dataListPoint.value[i].hasDel = hasDel.value
if (!dataListPoint.value[i].pointDelyCode || !dataListPoint.value[i].transSign) {
message.warn('请完善交割点必选项')
return
}
}
let newArr = dataListPoint.value.map(v=>v.pointTransCode)
let codeList = dataListPoint.value.map(v =>v.pointDelyCode)
2026-01-06 17:46:04 +08:00
const isRepeat=codeList.some((item,index,arr)=>arr.indexOf(item)!=index);
const isRepeatNew=newArr.some((item,index,arr)=>arr.indexOf(item)!=index);
if(isRepeat){
2026-01-07 17:38:57 +08:00
message.warn('交割点不可重复');
2026-01-06 17:46:04 +08:00
return
}
if(isRepeatNew){
2026-01-07 17:38:57 +08:00
message.warn('交气点不可重复');
2026-01-06 17:46:04 +08:00
return
}
let obj = {
...formState,
2026-01-07 17:38:57 +08:00
lngContractSalesPngPointList: dataListPoint.value,
lngContractSalesPngQtyList: arr,
2026-01-06 17:46:04 +08:00
lngFileUploadList: dataFile.value,
lngContractFactRelList: dataListContractFact.value,
lngContractApproRelList: dataListAppro.value,
2026-01-07 17:38:57 +08:00
lngContractSalesPngList: [
2026-01-06 17:46:04 +08:00
{
2026-01-07 17:38:57 +08:00
...formState.lngContractSalesPngList[0],
2026-01-06 17:46:04 +08:00
"kId": formState.id,
"prcTypeCode": formState.prcTypeCode,
"periodTypeCode": formState.periodTypeCode,
"uomCode": formState.uomCode,
}
],
2026-01-14 11:05:28 +08:00
approCode: pageType.value=='update'&&updateType ? 'WTJ' : formState.approCode
2026-01-06 17:46:04 +08:00
}
spinning.value = true;
let request = !formState.id ? addLngContract :updateLngContract
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) {
2026-01-07 17:38:57 +08:00
console.log(errorInfo, 'errorInfo')
2026-01-06 17:46:04 +08:00
spinning.value = false;
errorInfo?.errorFields?.length && notification.warning({
message: 'Tip',
description: '请完善信息'
});
return false
}
}
defineExpose({
handleSubmit,
getFormValue
});
</script>
<style lang="less" scoped>
:deep(.ant-form-item .ant-form-item-label) {
width: 135px !important;
max-width: 135px !important;
}
.page-bg-wrap {
background-color: #fff;
}
.top-toolbar {
min-height: 44px;
margin-bottom: 12px;
border-bottom: 1px solid #eee;
}
.redStyle {
color: red;
}
.iconStyle {
position: absolute;
color: rgba(0, 0, 0, 0.45);
// top: 0;
}
2026-01-07 17:38:57 +08:00
.tbStyle {
border: 1px dashed #d9d9d9;
padding: 10px;
margin-bottom: 10px;
}
2026-01-06 17:46:04 +08:00
</style>