Files
geg-gas-web/src/views/dayPlan/LngDemand/components/basicForm.vue
2026-03-19 17:51:57 +08:00

370 lines
18 KiB
Vue

<template>
<a-form ref="formRef" :model="formState" :rules="rules" v-bind="layout">
<a-row>
<a-col :span="8">
<a-form-item label="计划日期" name="datePlan">
<div v-if="pageType=='compare'" :class="diffResultList.includes('datePlan')?'changeStyle':''">
{{ formState.datePlan ? dayjs(formState.datePlan).format('YYYY-MM-DD'): null }}
</div>
<a-date-picker :inputReadOnly="true" v-else v-model:value="formState.datePlan" :disabled-date="disabledDateStart" style="width: 100%" :disabled="disable||pageType=='edit'||pageType=='update'" placeholder="请选择计划日期" @change="datePlanChange" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="合同" name="kName">
<div v-if="pageType=='compare'" :class="diffResultList.includes('kName')?'changeStyle':''">{{ formState.kName }}</div>
<a-input-search v-else v-model:value="formState.kName" :disabled="disable||pageType=='edit'||pageType=='update'" placeholder="请选择合同" readonly @search="onSearch"/>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="气源地" name="staName">
<div v-if="pageType=='compare'" :class="diffResultList.includes('staName')?'changeStyle':''">{{ formState.staName }}</div>
<a-input-search v-else v-model:value="formState.staName" :disabled="disable||pageType=='edit'||pageType=='update'" placeholder="请选择气源地" readonly @search="onSearchUpLoad"/>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="车头号" name="noTractor" :class="diffResultList.includes('noTractor')?'changeStyle':''">
<a-input v-model:value="formState.noTractor" :disabled="disable" placeholder="请输入车头号" @change="handleCheck('noTractor')"/>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="挂车号" name="noTrailer" :class="diffResultList.includes('noTrailer')?'changeStyle':''">
<a-input v-model:value="formState.noTrailer" :disabled="disable" placeholder="请输入挂车号" @change="handleCheck('noTrailer')" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="承运商" name="carrName" :class="diffResultList.includes('carrName')?'changeStyle':''">
<a-input v-model:value="formState.carrName" :disabled="disable" placeholder="请输入承运商" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="驾驶员身份证号" name="idNoDriver" :class="diffResultList.includes('idNoDriver')?'changeStyle':''">
<a-input v-model:value="formState.idNoDriver" :disabled="disable" placeholder="请输入驾驶员身份证号" @change="handleCheck('idNoDriver')"/>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="驾驶员姓名" name="nameDriver" :class="diffResultList.includes('nameDriver')?'changeStyle':''">
<a-input v-model:value="formState.nameDriver" :disabled="disable||formState.onlineSign == 'Y'" placeholder="请输入驾驶员姓名" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="驾驶员手机号" name="phoneDriver" :class="diffResultList.includes('phoneDriver')?'changeStyle':''">
<a-input v-model:value="formState.phoneDriver" :disabled="disable||formState.onlineSign == 'Y'" placeholder="驾驶员手机号" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="押运员身份证号" name="idNoEscort" :class="diffResultList.includes('idNoEscort')?'changeStyle':''">
<a-input v-model:value="formState.idNoEscort" :disabled="disable" placeholder="请输入押运员身份证号" @change="handleCheck('idNoEscort')"/>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="押运员姓名" name="nameEscort" :class="diffResultList.includes('nameEscort')?'changeStyle':''">
<a-input v-model:value="formState.nameEscort" :disabled="disable||formState.onlineSign == 'Y'" placeholder="请输入押运员姓名" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="押运员手机号" name="phoneEscort" :class="diffResultList.includes('phoneEscort')?'changeStyle':''">
<a-input v-model:value="formState.phoneEscort" :disabled="disable||formState.onlineSign == 'Y'" placeholder="请输入押运员手机号" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="卸货站点" name="unloadingName" :class="diffResultList.includes('unloadingName')?'changeStyle':''">
<a-input-search v-model:value="formState.unloadingName" :disabled="disable" placeholder="请选择卸货站点" readonly @search="onSearchPlace"/>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="预约时间段" name="timePeriod" :class="diffResultList.includes('timePeriod')?'changeStyle':''">
<a-select v-model:value="formState.timePeriod" :disabled="disable" placeholder="请选择预约时间段" style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.timePeriodList" :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="timeUnloading">
<div v-if="pageType=='compare'" :class="diffResultList.includes('timeUnloading')?'changeStyle':''">
{{ formState.timeUnloading ? dayjs(formState.timeUnloading).format('YYYY-MM-DD'): null }}
</div>
<a-date-picker :inputReadOnly="true" showTime v-else v-model:value="formState.timeUnloading" style="width: 100%" :disabled="disable" placeholder="请选择预计卸货时间" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="车辆类型" name="supplyCode" :class="diffResultList.includes('supplyCode')?'changeStyle':''">
<a-select v-model:value="formState.supplyCode" :disabled="disable" placeholder="请选择车辆类型" style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.supplyCodeList" :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="noTank" :class="diffResultList.includes('noTank')?'changeStyle':''">
<a-input v-model:value="formState.noTank" :disabled="disable" placeholder="请输入压力容器登记证号" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="充装量(吨)" name="qtyTon" :class="diffResultList.includes('qtyTon')?'changeStyle':''">{{ formState.qtyTon }}</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="供应商" name="comName" :class="diffResultList.includes('comName')?'changeStyle':''">{{ formState.comName }}</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="版本号" name="verNo" :class="diffResultList.includes('verNo')?'changeStyle':''">{{ formState.verNo }}</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="审批状态" name="approName" :class="diffResultList.includes('approName')?'changeStyle':''">
<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="24">
<a-form-item label="备注" name="note" :label-col="{ span: 3 }" :wrapper-col="{ span: 24 }">
<div v-if="pageType=='compare'" :class="diffResultList.includes('note')?'changeStyle':''">{{ formState.note }}</div>
<a-textarea v-else v-model:value="formState.note" :disabled="disable" placeholder="请输入备注" :auto-size="{ minRows: 2, maxRows: 5 }"/>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="批复意见" name="reply" :label-col="{ span: 3 }" :wrapper-col="{ span: 24 }">
<div v-if="pageType=='compare'" :class="diffResultList.includes('reply')?'changeStyle':''">{{ formState.reply }}</div>
<a-textarea v-else v-model:value="formState.reply" disabled :auto-size="{ minRows: 1, maxRows: 5 }"/>
</a-form-item>
</a-col>
</a-row>
</a-form>
<contractDemandListModal @register="registerContract" @success="handleSuccessContract" />
<pointDelyDemandListModal @register="registerStation" @success="handleSuccessStation" />
<placeLngUnloadModal @register="registerPlace" @success="handleSuccessPlace"/>
</template>
<script lang="ts" setup>
import { useI18n } from '/@/hooks/web/useI18n';
import { useRouter } from 'vue-router';
import { ref, computed, onMounted, onBeforeMount, nextTick, defineAsyncComponent, reactive, defineComponent, watch} from 'vue';
import contractDemandListModal from '/@/components/common/contractDemandListModal.vue';
import pointDelyDemandListModal from '/@/components/common/pointDelyDemandListModal.vue';
import placeLngUnloadModal from '/@/components/common/placeLngUnloadModal.vue';
import { useModal } from '/@/components/Modal';
import { message } from 'ant-design-vue';
import dayjs from 'dayjs';
import { getCompDept } from '/@/api/approve/Appro';
import { useUserStore } from '/@/store/modules/user';
import { getDictionary } from '/@/api/sales/Customer';
import { getLngLngDemandContractList, getLngLngDemandStationList,carCheck,getCategory } from '/@/api/dayPlan/LngDemand';
const userStore = useUserStore();
const userInfo = userStore.getUserInfo;
const router = useRouter();
const { currentRoute } = router;
const pageId = ref(currentRoute.value.query?.id)
const pageType = ref(currentRoute.value.query?.type)
const formRef = ref()
const rules= reactive({
staName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
datePlan: [{ required: true, message: "该项为必填项", trigger: 'change' }],
kName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
noTractor: [{ required: true, message: "该项为必填项", trigger: 'change' }],
noTrailer: [{ required: true, message: "该项为必填项", trigger: 'change' }],
carrName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
idNoDriver: [{ required: true, message: "该项为必填项", trigger: 'change' }],
nameDriver: [{ required: true, message: "该项为必填项", trigger: 'change' }],
phoneDriver: [{ required: true, message: "该项为必填项", trigger: 'change' }],
idNoEscort: [{ required: true, message: "该项为必填项", trigger: 'change' }],
nameEscort: [{ required: true, message: "该项为必填项", trigger: 'change' }],
phoneEscort: [{ required: true, message: "该项为必填项", trigger: 'change' }],
unloadingName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
timePeriod: [{ required: true, message: "该项为必填项", trigger: 'change' }],
});
const layout = {
labelCol: { span: 9 },
wrapperCol: { span: 18 },
}
const { t } = useI18n();
const [registerContract, { openModal:openModalContractSales}] = useModal();
const [registerStation, { openModal:openModalUpLoad}] = useModal();
const [registerPlace, { openModal:openModalPlace}] = useModal();
const props = defineProps({
formObj: {},
disable: false,
changeList: []
});
const optionSelect= reactive({
timePeriodList: [],
supplyCodeList: [],
approCodeList: []
})
const diffResultList = ref([])
const formState = ref({})
const contractList = ref([])
const stationList = ref([])
onMounted(async () =>{
getOption()
if (!pageType.value) {
formState.value.lastVerSign = 'Y'
formState.value.carrCode = '123'
// formState.value.validSign = 'N'
formState.value.alterSign = 'I'
formState.value.approCode = 'WTJ'
const res = await getCompDept(userInfo.id)
formState.value.cuCode = res?.comp?.cuCode
formState.value.comId = res?.comp?.id
let a = await getCategory({code: 'LNG'})||[]
formState.value.qtyTon = a[0]?.coefficient
}
})
async function getOption() {
optionSelect.timePeriodList = await getDictionary('LNG_TIME_P')
optionSelect.supplyCodeList = await getDictionary('LNG_SUPPLY')
optionSelect.approCodeList = await getDictionary('LNG_APPRO')
}
const datePlanChange = async (val) => {
if (!val) {
contractList.value = []
return
}
let obj = {
cuCode:formState.value.cuCode,
datePlan: dayjs(formState.value.datePlan).format('YYYY-MM-DD')
}
let res = await getLngLngDemandContractList(obj)
contractList.value = res || []
if (contractList.value.length == 1) {
formState.value.kName = contractList.value[0].kName
formState.value.ksId = contractList.value[0].id
formState.value.comId = contractList.value[0].comId
formState.value.comName = contractList.value[0].comName
getStation()
}
}
const onSearch = ()=> {
if (!formState.value.datePlan) {
message.warn('请选择计划日期')
return
}
openModalContractSales(true,{isUpdate: false, list: contractList.value})
}
const handleSuccessContract = (val) => {
formState.value.kName = val[0].kName
formState.value.ksId = val[0].id
formState.value.comId = contractList.value[0].comId
formState.value.comName = contractList.value[0].comName
getStation()
}
const onSearchUpLoad = (val)=> {
if (!formState.value.kName) {
message.warn('请选择合同')
return
}
openModalUpLoad(true,{isUpdate: false, list: stationList.value})
}
const handleSuccessStation = (val) => {
formState.value.staName = val[0].pointDelyName
formState.value.staCode = val[0].pointDelyCode
formState.value.onlineSign = val[0].onlineSign
changeRules()
}
const changeRules = () => {
if (formState.value.onlineSign == 'Y') {
rules.nameDriver = [{ required: false, message: "该项为必填项", trigger: 'change' }]
rules.phoneDriver = [{ required: false, message: "该项为必填项", trigger: 'change' }]
rules.nameEscort = [{ required: false, message: "该项为必填项", trigger: 'change' }]
rules.phoneEscort = [{ required: false, message: "该项为必填项", trigger: 'change' }]
} else {
rules.nameDriver = [{ required: true, message: "该项为必填项", trigger: 'change' }]
rules.phoneDriver = [{ required: true, message: "该项为必填项", trigger: 'change' }]
rules.nameEscort = [{ required: true, message: "该项为必填项", trigger: 'change' }]
rules.phoneEscort = [{ required: true, message: "该项为必填项", trigger: 'change' }]
}
}
const onSearchPlace = ()=> {
openModalPlace(true,{isUpdate: false})
}
const handleSuccessPlace= (val) => {
formState.value.unloadingName = val[0].fullName
formState.value.unloadingCode = val[0].code
}
const getStation = async () => {
let res = await getLngLngDemandStationList({ksId: formState.value.ksId})
stationList.value = res || []
stationList.value.forEach(v => {
v.pointDelyName = v.fullName
v.pointDelyCode = v.code
})
if (stationList.value.length == 1) {
formState.value.staName = stationList.value[0].fullName
formState.value.staCode = stationList.value[0].code
formState.value.onlineSign = stationList.value[0].onlineSign
changeRules()
}
}
const handleCheck = async (type) => {
if (formState.value.onlineSign == 'Y' && ((type == 'noTractor'&& !formState.value.noTrailer) || (type == 'noTrailer'&& !formState.value.noTractor)) ) {
// formState.value.carrCode = ''
// formState.value.carrName = ''
}
}
const disabledDateStart = (current) => {
const today = new Date();
today.setHours(0, 0, 0, 0); // 清除时分秒,确保比较时不考虑时间部分
// 获取明天的日期
const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + (pageType.value?1: 2));
tomorrow.setHours(0, 0, 0, 0); // 清除时分秒
// 当前日期小于今天或大于明天,则禁用
return current < today || current > tomorrow;
}
async function getFormValue () {
await formRef.value.validateFields();
let obj = {
formInfo: formState.value,
}
return obj
}
watch(
() => props.formObj,
(val) => {
if (val) {
formState.value = val
}
},
{
immediate: true,
deep: true,
}
);
watch(
() => props.changeList,
(val) => {
diffResultList.value = val || []
},
{
immediate: true,
deep: true,
}
);
defineExpose({
getFormValue
});
</script>
<style lang="less" scoped>
.changeStyle {
color: red !important;
}
:deep(.changeStyle .ant-input) {
color: red !important;
}
:deep(.changeStyle .ant-select-selection-item) {
color: red !important;
}
</style>