| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412 |
- <template>
- <el-dialog
- :title="title"
- v-model="dialogVisible"
- :width="'1000px'"
- append-to-body
- destroy-on-close
- @closed="handleCancel"
- >
- <div class="flex flex-col">
- <div class="w-full">
- <el-form
- ref="formRef"
- :model="formData"
- :rules="formRules"
- label-width="120px"
- >
- <div v-if="props.selectedRows.length > 1" class="mb-4 text-gray-500">
- 已选择 {{ props.selectedRows.length }} 条记录进行批量排期
- </div>
- <el-form-item label="检验性质" prop="checkType" labelWidth="80px">
- <el-radio-group v-model="formData.checkType">
- <el-radio
- v-for="(label, value) in PressureBoilerCheckTypeMap"
- :key="value"
- :value="value"
- >
- {{ label }}
- </el-radio>
- </el-radio-group>
- </el-form-item>
- <!-- 内部检验配置 -->
- <div class="plan-section" v-if="formData.checkType == PressureBoilerCheckType.IN">
- <div class="section-title">
- <span>内部检验</span>
- <span class="section-info">
- 待检设备数量: {{ inEquipCount }} 最近临期时间: {{ inLatestTime }}
- </span>
- </div>
- <el-form-item label="内检日期" prop="inDate">
- <el-date-picker
- v-model="formData.inDate"
- type="date"
- placeholder="选择日期"
- value-format="YYYY-MM-DD"
- :disabled-date="(time) => time.getTime() < Date.now() - 8.64e7"
- :disabled="inEquipCount === 0"
- class="!w-240px"
- />
- <el-checkbox
- v-if="!isFrontDesk"
- v-model="formData.inIsOrderConfirm"
- class="ml-4"
- :disabled="inEquipCount === 0"
- >
- 由前台约检确认
- </el-checkbox>
- </el-form-item>
- <el-form-item label="检验员" v-if="inEquipCount > 0">
- <CheckerSelect
- ref="checkerInRef"
- v-model="inSelectedCheckers"
- required
- @change="(v: CheckerItem[]) => handleCheckerSelectChange('in', v)"
- />
- </el-form-item>
- <el-form-item label="收费形式" prop="inChargeType" v-if="inEquipCount > 0">
- <div class="flex items-center gap-4">
- <el-select v-model="formData.inChargeType" placeholder="请选择收费形式"
- class="!w-120px">
- <el-option label="非合同收费" value="1"/>
- </el-select>
- <span class="text-gray-600">是否免征:</span>
- <el-select v-model="formData.inIsExempt" placeholder="请选择是否免征"
- class="!w-60px" @change="handleInExemptChange">
- <el-option label="否" value="0"/>
- <el-option label="是" value="1"/>
- </el-select>
- <span class="text-gray-600">应收法定金额: {{ formData.inShouldAmount }}</span>
- <span class="text-gray-600">服务收费金额: {{ formData.inServiceAmount }}</span>
- <span class="text-gray-600">免征费用: {{ formData.inReduceFee }}</span>
- </div>
- </el-form-item>
- </div>
- <!-- 外部检验配置 -->
- <div class="plan-section" v-if="formData.checkType == PressureBoilerCheckType.OUT">
- <div class="section-title">
- <span>外部检验</span>
- <span class="section-info">
- 待检设备数量: {{ outEquipCount }} 最近临期时间: {{ outLatestTime }}
- <template v-if="isSameYear(inLatestTime, outLatestTime)"> 内检临期时间: {{ inLatestTime }}</template>
- </span>
- </div>
- <el-form-item label="外检日期" prop="outDate">
- <el-date-picker
- v-model="formData.outDate"
- type="date"
- placeholder="选择日期"
- value-format="YYYY-MM-DD"
- :disabled-date="(time) => time.getTime() < Date.now() - 8.64e7"
- :disabled="outEquipCount === 0"
- class="!w-240px"
- />
- <el-checkbox
- v-if="!isFrontDesk"
- v-model="formData.outIsOrderConfirm"
- class="ml-4"
- :disabled="outEquipCount === 0"
- >
- 由前台约检确认
- </el-checkbox>
- </el-form-item>
- <el-form-item label="检验员" v-if="outEquipCount > 0">
- <CheckerSelect
- ref="checkerOutRef"
- v-model="outSelectedCheckers"
- required
- @change="(v: CheckerItem[]) => handleCheckerSelectChange('out', v)"
- />
- </el-form-item>
- <el-form-item label="收费形式" prop="outChargeType" v-if="outEquipCount > 0">
- <div class="flex items-center gap-4">
- <el-select v-model="formData.outChargeType" placeholder="请选择收费形式"
- class="!w-120px">
- <el-option label="非合同收费" value="1"/>
- </el-select>
- <span class="text-gray-600">是否免征:</span>
- <el-select v-model="formData.outIsExempt" placeholder="请选择是否免征"
- class="!w-60px" @change="handleOutExemptChange">
- <el-option label="否" value="0"/>
- <el-option label="是" value="1"/>
- </el-select>
- <span class="text-gray-600">应收法定金额: {{ formData.outShouldAmount }}</span>
- <span class="text-gray-600">服务收费金额: {{ formData.outServiceAmount }}</span>
- <span class="text-gray-600">免征费用: {{ formData.outReduceFee }}</span>
- </div>
- </el-form-item>
- </div>
- <!-- 耐压检验配置 -->
- <div class="plan-section" v-if="formData.checkType == PressureBoilerCheckType.PRESSURE">
- <div class="section-title">
- <span>耐压检验</span>
- <span class="section-info">
- 待检设备数量: {{ preEquipCount }} 最近临期时间: {{ preLatestTime }}
- <template v-if="isSameYear(inLatestTime, preLatestTime)"> 内检临期时间: {{ inLatestTime }}</template>
- <template v-if="isSameYear(outLatestTime, preLatestTime)"> 外检临期时间: {{ outLatestTime }}</template>
- </span>
- </div>
- <el-form-item label="耐压检验日期" prop="preDate">
- <el-date-picker
- v-model="formData.preDate"
- type="date"
- placeholder="选择日期"
- value-format="YYYY-MM-DD"
- :disabled-date="(time) => time.getTime() < Date.now() - 8.64e7"
- :disabled="preEquipCount == 0"
- class="!w-240px"
- />
- <el-checkbox
- v-if="!isFrontDesk"
- v-model="formData.pressureIsOrderConfirm"
- class="ml-4"
- :disabled="preEquipCount == 0"
- >
- 由前台约检确认
- </el-checkbox>
- </el-form-item>
- <el-form-item label="检验员" v-if="preEquipCount !== 0">
- <CheckerSelect
- ref="checkerPreRef"
- v-model="preSelectedCheckers"
- required
- @change="(v: CheckerItem[]) => handleCheckerSelectChange('pre', v)"
- />
- </el-form-item>
- <el-form-item label="收费形式" prop="preChargeType" v-if="preEquipCount !== 0">
- <div class="flex items-center gap-4">
- <el-select v-model="formData.preChargeType" placeholder="请选择收费形式"
- class="!w-120px">
- <el-option label="非合同收费" value="1"/>
- </el-select>
- <span class="text-gray-600">是否免征:</span>
- <el-select v-model="formData.preIsExempt" placeholder="请选择是否免征"
- class="!w-60px" @change="handlePreExemptChange">
- <el-option label="否" value="0"/>
- <el-option label="是" value="1"/>
- </el-select>
- <span class="text-gray-600">应收法定金额: {{ formData.preShouldAmount }}</span>
- <span class="text-gray-600">服务收费金额: {{ formData.preServiceAmount }}</span>
- <span class="text-gray-600">免征费用: {{ formData.preReduceFee }}</span>
- </div>
- </el-form-item>
- </div>
- <!-- 检验项目 -->
- <div
- class="checkItemContent"
- v-for="checkItem in checkItemList"
- :key="checkItem.inspectionNature + '-' + checkItem.type"
- >
- <div v-if="checkItem.inspectionNature == formData.checkType && getEquipCountByType(checkItem.inspectionNature) != 0">
- <div class="content-title" @click="toggleCheckItemCollapse(checkItem)">
- <el-icon class="collapse-icon" :class="{ 'is-collapsed': !checkItem.isExpanded }">
- <ArrowDown />
- </el-icon>
- {{ checkItem.inspectionNatureName }}
- </div>
- <div class="inspection-grid" v-show="checkItem.isExpanded">
- <template v-if="checkItem.itemList.length > 0">
- <!-- Grid 容器 -->
- <div
- class="grid-container"
- :style="{
- 'grid-template-columns':
- checkItem.itemList.length < 3
- ? `repeat(${checkItem.itemList.length}, 1fr)`
- : `repeat(3, 1fr)`
- }"
- >
- <!-- 循环渲染子项(模拟数据) -->
- <div class="grid-item" v-for="(item, index) in checkItem.itemList" :key="index">
- <el-checkbox
- v-model="item.use"
- :disabled="item.isMainProject === '1'"
- />
- <!-- @change="(val) => handleCheckItemSelectedChange(item, val)"-->
- <div style="display: flex; align-items: center; gap: 4px;">
- <span v-if="item.isMainProject === '1'"
- style="display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; background-color: #6cbcf5; color: #fff; font-size: 12px; border-radius: 2px; font-weight: bold;">主</span>
- <span>{{ item.name }}</span>
- </div>
- <span v-if="item.isFee === '1'">
- (
- <el-button link type="primary" @click="() => {
- openFeeDialog(item)
- }"
- >费用:{{ item.fee || '无' }}</el-button
- >
- )
- </span>
- </div>
- </div>
- </template>
- <el-empty style="height: 200px;" v-else
- :description="`暂无【${checkItem.inspectionNatureName}】检验项目`"/>
- </div>
- </div>
- </div>
- </el-form>
- </div>
- </div>
- <template #footer>
- <div class="flex justify-end">
- <el-button @click="handleCancel">取消</el-button>
- <el-button
- type="primary"
- @click="handleConfirm"
- :disabled="isConfirmDisabled"
- :loading="submitLoading"
- >
- 确定
- </el-button>
- </div>
- </template>
- <!-- 费用计算弹窗 -->
- <CalcProjectFee
- v-if="showCalcCheckItemFeeDialog"
- v-model="showCalcCheckItemFeeDialog"
- :project-id="currentFeeItem.connectId"
- :old-fee="currentFeeItem.fee || 0"
- :fee-calculate-json-str="currentFeeItem.feeCalculateJson || ''"
- @save="handleFeeSave"
- />
- </el-dialog>
- </template>
- <script setup lang="ts">
- import {FormInstance} from 'element-plus'
- import {ArrowDown} from '@element-plus/icons-vue'
- import {useMessage} from '@/hooks/web/useMessage'
- import dayjs from 'dayjs';
- import {
- EquipBoilerSchedulingVO,
- EquipBoilerSchedulingApi
- } from "@/api/pressure2/equipboilerscheduling";
- import {
- PressureBoilerCheckType,
- PressureBoilerCheckTypeMap,
- PressurePipeCheckTypeMap
- } from "@/utils/constants";
- import {BoilerTaskOrderApi} from "@/api/pressure2/boilertaskorder";
- import {is} from "@/utils/is";
- import {EquipBoilerApi} from "@/api/pressure2/equipboiler";
- import {InspectionNatureTypeApi} from "@/api/pressure2/inspectionnaturetype";
- import {getDept} from "@/api/system/dept";
- import {ClientUnitApi} from "../../../../api/system/clientunit";
- import CalcProjectFee from './calcProjectFee.vue'
- import CheckerSelect from '@/views/pressure2/components/CheckerSelect/index.vue'
- import type { CheckerItem } from '@/views/pressure2/components/CheckerSelect'
- const message = useMessage()
- const {queryCheckItemList, querySchedulingCheckItemList} = BoilerTaskOrderApi
- const props = defineProps({
- selectedRows: {
- type: Array as PropType<EquipBoilerSchedulingVO[]>,
- default: () => []
- },
- selectedInList: {
- type: Array as PropType<EquipBoilerSchedulingVO[]>,
- default: () => []
- },
- selectedOutList: {
- type: Array as PropType<EquipBoilerSchedulingVO[]>,
- default: () => []
- },
- selectedPreList: {
- type: Array as PropType<EquipBoilerSchedulingVO[]>,
- default: () => []
- },
- source: {
- type: String as PropType<string>,
- default: 'pressure'
- }
- })
- // 是否前台约检来源:前台约检跳过计划表提交+约检确认,直接生成受理单
- const isFrontDesk = computed(() => props.source === 'plan')
- const emit = defineEmits(['success', 'close', 'clear-selected-rows'])
- const dialogVisible = ref(false)
- const formRef = ref<FormInstance>()
- const submitLoading = ref(false) // 提交按钮 loading
- const isBatch = ref(false)
- const title = computed(() => props.selectedRows.length > 1 ? '批量计划排期' : '计划排期')
- // 判断确定按钮是否禁用
- const isConfirmDisabled = computed(() => {
- // 根据当前选择的检验类型,判断对应设备数量是否为0
- if (formData.value.checkType == PressureBoilerCheckType.IN) {
- return inEquipCount.value === 0
- } else if (formData.value.checkType == PressureBoilerCheckType.OUT) {
- return outEquipCount.value === 0
- } else if (formData.value.checkType == PressureBoilerCheckType.PRESSURE) {
- return preEquipCount.value === 0
- }
- return false
- })
- // 根据检验类型获取设备数量
- const getEquipCountByType = (type: string) => {
- if (type === PressureBoilerCheckType.IN) {
- return inEquipCount.value
- } else if (type === PressureBoilerCheckType.OUT) {
- return outEquipCount.value
- } else if (type === PressureBoilerCheckType.PRESSURE) {
- return preEquipCount.value
- }
- return 0
- }
- // 检验项目
- const checkItemList = ref<any[]>([])
- const showCalcCheckItemFeeDialog = ref(false)
- const currentFeeItem = ref<any>(null)
- const equipList = ref<any[]>([])
- // 内部检验设备数量
- const inEquipCount = computed(() => {
- return props.selectedInList.length
- })
- // 外部检验设备数量
- const outEquipCount = computed(() => {
- return props.selectedOutList.length
- })
- // 耐压检验设备数量
- const preEquipCount = computed(() => {
- return props.selectedPreList.length
- })
- // 内部检验最近临期时间
- const inLatestTime = computed(() => {
- const latestTime = props.selectedRows.reduce((nextInCheckDate, row) => {
- if (!row.nextInCheckDate) return nextInCheckDate
- if (!nextInCheckDate || row.nextInCheckDate < nextInCheckDate) {
- return row.nextInCheckDate
- }
- return nextInCheckDate
- }, '')
- return latestTime ? dayjs(latestTime).format('YYYY-MM-DD') : '无'
- })
- // 外部检验最近临期时间
- const outLatestTime = computed(() => {
- const latestTime = props.selectedRows.reduce((nextOutCheckDate, row) => {
- if (!row.nextOutCheckDate) return nextOutCheckDate
- if (!nextOutCheckDate || row.nextOutCheckDate < nextOutCheckDate) {
- return row.nextOutCheckDate
- }
- return nextOutCheckDate
- }, '')
- return latestTime ? dayjs(latestTime).format('YYYY-MM-DD') : '无'
- })
- // 超年限检验最近临期时间
- const preLatestTime = computed(() => {
- const latestTime = props.selectedRows.reduce((nextPressureCheckDate, row) => {
- if (!row.nextPressureCheckDate) return nextPressureCheckDate
- if (!nextPressureCheckDate || row.nextPressureCheckDate < nextPressureCheckDate) {
- return row.nextPressureCheckDate
- }
- return nextPressureCheckDate
- }, '')
- return latestTime ? dayjs(latestTime).format('YYYY-MM-DD') : '无'
- })
- /** 判断两个临检时间是否同一年 */
- const isSameYear = (time1: string, time2: string) => {
- if (time1 === '无' || time2 === '无') return false
- return time1.substring(0, 4) === time2.substring(0, 4)
- }
- const formData = ref({
- checkType: '100',
- // 内部检验
- inDate: '',
- inTeamList: [{
- groupTeamId: '',
- leaderId: '',
- memberIdList: []
- }],
- inTaskList: [],
- inIsOrderConfirm: true,
- inChargeType: '1',
- inIsExempt: '0',
- inShouldAmount: 0,
- inServiceAmount: 0,
- inReduceFee: 0,
- // 外部检验
- outDate: '',
- outTeamList: [{
- groupTeamId: '',
- leaderId: '',
- memberIdList: []
- }],
- outTaskList: [],
- outIsOrderConfirm: true,
- outChargeType: '1',
- outIsExempt: '0',
- outShouldAmount: 0,
- outServiceAmount: 0,
- outReduceFee: 0,
- // 耐压检验
- preDate: '',
- preTeamList: [{
- groupTeamId: '',
- leaderId: '',
- memberIdList: []
- }],
- pressureTaskList: [],
- pressureIsOrderConfirm: true,
- preChargeType: '1',
- preIsExempt: '0',
- preShouldAmount: 0,
- preServiceAmount: 0,
- preReduceFee: 0,
- taskList: [{
- inEquipIds: '',
- outEquipIds: '',
- preEquipIds: ''
- }]
- })
- // 各类型检验员选择状态
- const inSelectedCheckers = ref<CheckerItem[]>([])
- const outSelectedCheckers = ref<CheckerItem[]>([])
- const preSelectedCheckers = ref<CheckerItem[]>([])
- // CheckerSelect 组件引用
- const checkerInRef = ref()
- const checkerOutRef = ref()
- const checkerPreRef = ref()
- // 表单验证规则
- const formRules = {
- inDate: [{
- validator: (rule, value, callback) => {
- if (!value) {
- callback(new Error('请选择内检日期'))
- } else {
- callback()
- }
- },
- trigger: 'change'
- }],
- outDate: [{
- validator: (rule, value, callback) => {
- if (!value) {
- callback(new Error('请选择外检日期'))
- } else {
- callback()
- }
- },
- trigger: 'change'
- }],
- outTeamList: [{
- validator: (rule, value, callback) => {
- if ((!value || value.length === 0)) {
- callback(new Error('请选择检验员'))
- } else {
- callback()
- }
- },
- trigger: 'change'
- }],
- preDate: [{
- validator: (rule, value, callback) => {
- if (!value) {
- callback(new Error('请选择耐压检验日期'))
- } else {
- callback()
- }
- },
- trigger: 'change'
- }],
- preTeamList: [{
- validator: (rule, value, callback) => {
- if ((!value || value.length === 0)) {
- callback(new Error('请选择检验员'))
- } else {
- callback()
- }
- },
- trigger: 'change'
- }]
- }
- /** 处理统一 CheckerSelect 组件的选择变化 */
- const handleCheckerSelectChange = (type: 'in' | 'out' | 'pre', checkers: CheckerItem[]) => {
- updateTeamList(type)
- syncCheckers(type, checkers)
- }
- /** 监听检验性质变化 */
- watch(() => formData.value.checkType, (newType, oldType) => {
- if (newType && newType !== oldType && !isOpening.value) {
- handleQueryCheckItemList(newType)
- }
- })
- watch(() => formData.value.inDate, (newDate) => {
- if (newDate) {
- // 只有在未设置且未勾选"无需安排"的情况下才自动填充
- if (!formData.value.outDate) {
- formData.value.outDate = newDate
- }
- if (!formData.value.preDate) {
- formData.value.preDate = newDate
- }
- }
- })
- watch(() => formData.value.outDate, (newDate) => {
- if (newDate) {
- if (!formData.value.outDate) {
- formData.value.outDate = newDate
- }
- if (!formData.value.preDate) {
- formData.value.preDate = newDate
- }
- }
- })
- watch(() => formData.value.preDate, (newDate) => {
- if (newDate) {
- if (!formData.value.inDate) {
- formData.value.inDate = newDate
- }
- if (!formData.value.outDate) {
- formData.value.outDate = newDate
- }
- }
- })
- /** 监听检验员变化 */
- const syncCheckers = (sourceType: string, checkers: CheckerItem[]) => {
- const typeMap = {
- in: ['out', 'pre'],
- out: ['in', 'pre'],
- pre: ['in', 'out']
- }
- typeMap[sourceType].forEach(type => {
- const checkerMap = {
- in: inSelectedCheckers,
- out: outSelectedCheckers,
- pre: preSelectedCheckers
- }
- // 只有在未选择检验员且未勾选"无需安排"的情况下才自动同步
- if (checkerMap[type].value.length === 0) {
- checkerMap[type].value = [...checkers]
- updateTeamList(type)
- }
- })
- }
- const openFeeDialog = (item) => {
- showCalcCheckItemFeeDialog.value = true
- currentFeeItem.value = item
- }
- const handleFeeSave = (result: { fee: number; feeCalculateJson: string }) => {
- if (currentFeeItem.value) {
- currentFeeItem.value.fee = result.fee
- currentFeeItem.value.feeCalculateJson = result.feeCalculateJson
- }
- currentFeeItem.value = null
- handleCheckItemFeeConfirm()
- showCalcCheckItemFeeDialog.value = false
- }
- /** 处理内部检验免征变化 */
- const handleInExemptChange = (val: string) => {
- calculateInAmounts()
- }
- /** 处理外部检查免征变化 */
- const handleOutExemptChange = (val: string) => {
- calculateOutAmounts()
- }
- /** 处理耐压检查免征变化 */
- const handlePreExemptChange = (val: string) => {
- calculatePreAmounts()
- }
- /** 计算内部检验金额 */
- const calculateInAmounts = () => {
- const inItems = checkItemList.value.filter(i => i.inspectionNature == PressureBoilerCheckType.IN)
- if (!inItems) return
- // 分离法定收费项目和服务收费项目
- const find = inItems?.find(item => item.type === '1');
- if (!find) return;
- const statutoryItems = find.itemList.filter(item => item.use)
- const find1 = inItems?.find(item => item.type === '2');
- if (!find1) return;
- const serviceItems = find1.itemList.filter(item => item.use)
- // 计算法定金额总和
- const totalStatutoryAmount = statutoryItems.reduce((sum, item) => sum + (item.fee || 0), 0)
- // 计算服务收费金额总和
- const totalServiceAmount = serviceItems.reduce((sum, item) => sum + (item.fee || 0), 0)
- if (formData.value.inIsExempt === '1') {
- // 免征:免征费用=应收法定金额,应收法定金额=0
- formData.value.inReduceFee = totalStatutoryAmount
- formData.value.inShouldAmount = 0
- } else {
- // 不免征:免征费用=0,应收法定金额=总金额
- formData.value.inReduceFee = 0
- formData.value.inShouldAmount = totalStatutoryAmount
- }
- formData.value.inServiceAmount = totalServiceAmount
- }
- /** 外部检验金额 */
- const calculateOutAmounts = () => {
- const outItems = checkItemList.value.filter(i => i.inspectionNature == PressureBoilerCheckType.OUT)
- if (!outItems) return
- // 分离法定收费项目和服务收费项目
- const find = outItems?.find(item => item.type === '1');
- if (!find) return;
- const statutoryItems = find.itemList.filter(item => item.use)
- const find1 = outItems?.find(item => item.type === '2');
- if (!find1) return;
- const serviceItems = find1.itemList.filter(item => item.use)
- // 计算法定金额总和
- const totalStatutoryAmount = statutoryItems.reduce((sum, item) => sum + (item.fee || 0), 0)
- // 计算服务收费金额总和
- const totalServiceAmount = serviceItems.reduce((sum, item) => sum + (item.fee || 0), 0)
- if (formData.value.outIsExempt === '1') {
- // 免征:免征费用=应收法定金额,应收法定金额=0
- formData.value.outReduceFee = totalStatutoryAmount
- formData.value.outShouldAmount = 0
- } else {
- // 不免征:免征费用=0,应收法定金额=总金额
- formData.value.outReduceFee = 0
- formData.value.outShouldAmount = totalStatutoryAmount
- }
- formData.value.outServiceAmount = totalServiceAmount
- }
- /** 计算耐压检验金额 */
- const calculatePreAmounts = () => {
- const preItems = checkItemList.value.filter(i => i.inspectionNature == PressureBoilerCheckType.PRESSURE)
- if (!preItems) return
- // 分离法定收费项目和服务收费项目
- const find = preItems?.find(item => item.type === '1');
- if (!find) return;
- const statutoryItems = find.itemList.filter(item => item.use)
- const find1 = preItems?.find(item => item.type === '2');
- if (!find1) return;
- const serviceItems = find1.itemList.filter(item => item.use)
- // 计算法定金额总和
- const totalStatutoryAmount = statutoryItems.reduce((sum, item) => sum + (item.fee || 0), 0)
- // 计算服务收费金额总和
- const totalServiceAmount = serviceItems.reduce((sum, item) => sum + (item.fee || 0), 0)
- if (formData.value.preIsExempt === '1') {
- // 免征:免征费用=应收法定金额,应收法定金额=0
- formData.value.preReduceFee = totalStatutoryAmount
- formData.value.preShouldAmount = 0
- } else {
- // 不免征:免征费用=0,应收法定金额=总金额
- formData.value.preReduceFee = 0
- formData.value.preShouldAmount = totalStatutoryAmount
- }
- formData.value.preServiceAmount = totalServiceAmount
- }
- const handleCheckItemFeeConfirm = () => {
- // formData.value.actualAmount = 0
- // checkItemList.value.forEach(item => {
- // item.itemList.forEach(item => {
- // let num= 0
- // if (PressureBoilerCheckType.IN == item.inspectionNature){
- // num = nextInCheckCount.value
- // }
- // if (PressureBoilerCheckType.OUT == item.inspectionNature){
- // num = nextOutCheckCount.value
- // }
- // if (PressureBoilerCheckType.PRESSURE == item.inspectionNature){
- // num = nextPressureCheckCount.value
- // }
- // formData.value.actualAmount += item.fee * num
- // })
- // })
- calculateInAmounts()
- calculateOutAmounts()
- calculatePreAmounts()
- }
- // 监听检验项目使用状态变化,自动重新计算金额
- watch(() => checkItemList.value, () => {
- calculateInAmounts()
- calculateOutAmounts()
- calculatePreAmounts()
- }, {deep: true})
- /** 更新 teamList */
- const updateTeamList = (type) => {
- const checkerMap = {
- in: inSelectedCheckers,
- out: outSelectedCheckers,
- pre: preSelectedCheckers
- }
- const teamListMap = {
- in: 'inTeamList',
- out: 'outTeamList',
- pre: 'preTeamList'
- }
- const groupedTeams = checkerMap[type].value.reduce((acc, checker) => {
- const {groupTeamId} = checker
- if (!acc[groupTeamId]) {
- acc[groupTeamId] = {
- groupTeamId,
- leaderId: '',
- memberIdList: []
- }
- }
- if (checker.isLeader) {
- acc[groupTeamId].leaderId = checker.memberId
- } else {
- acc[groupTeamId].memberIdList.push(checker.memberId)
- }
- return acc
- }, {})
- formData.value[teamListMap[type]] = Object.values(groupedTeams)
- }
- // 查询项目列表(按当前检验性质查询,并缓存结果)
- const checkItemListCache = ref<Record<string, any[]>>({})
- const isOpening = ref(false) // 标记弹窗是否正在打开,防止watch在数据未就绪时触发查询
- const handleQueryCheckItemList = async (checkType?: string) => {
- const targetType = checkType || formData.value.checkType
- // 如果已缓存,直接使用缓存数据
- if (checkItemListCache.value[targetType]) {
- // 合并缓存数据到 checkItemList(保留其他类型的数据,更新当前类型)
- const cachedItems = checkItemListCache.value[targetType]
- checkItemList.value = [
- ...checkItemList.value.filter(i => i.inspectionNature != targetType),
- ...cachedItems
- ]
- return
- }
- // 校验所有选中的任务列表中的设备类型是否一致
- const allTasks = [
- ...formData.value.inTaskList,
- ...formData.value.outTaskList,
- ...formData.value.pressureTaskList
- ]
- if (allTasks.length > 0) {
- const firstType = allTasks[0].type
- const firstUnit = allTasks[0].unitId
- const hasDifferentType = allTasks.some(task => task.type !== firstType)
- const hasDifferentUnit = allTasks.some(task => task.unitId !== firstUnit)
- if (hasDifferentType) {
- ElMessage.error('请选择同一类型设备')
- dialogVisible.value = false
- return
- }
- if (hasDifferentUnit) {
- ElMessage.error('请选择同一单位设备')
- dialogVisible.value = false
- return
- }
- if (firstUnit){
- ClientUnitApi.getClientUnit(firstUnit).then(res => {
- formData.value.inIsExempt = res.isExempt
- formData.value.outIsExempt = res.isExempt
- formData.value.preIsExempt = res.isExempt
- })
- }
- }
- // 获取统一的设备类型,如果列表为空则设为 undefined
- const equipType = allTasks.length > 0 ? allTasks[0].type : undefined
- const type = Number(targetType) || targetType
- const params = {
- orderId: "0",
- itemIds: equipList.value.map(item => item.id),
- equipmentCategory: 200,
- inspectionNature: [type],
- equipType:equipType
- };
- const queryResult = await querySchedulingCheckItemList(params);
- const inspectionNatureType = await InspectionNatureTypeApi.getInspectionNatureTypePage({
- pageNo: 1,
- pageSize: 1,
- equip: '200',
- nature: type
- })
- const inType = inspectionNatureType.list[0].type
- const newItems: any[] = []
- newItems.push({
- inspectionNatureName: PressureBoilerCheckTypeMap[type] + " 法定收费项目",
- inspectionNature: type,
- type: '1',
- isExpanded: inType == 1,
- itemList: (queryResult || []).map((item) => (
- {
- ...item,
- isAutoAmount: '0',
- inspectionNature: type,
- type: '1',
- use: inType == 1 ? item.use : false
- }
- ))
- });
- newItems.push({
- inspectionNatureName: PressureBoilerCheckTypeMap[type] + " 服务收费项目",
- inspectionNature: type,
- type: '2',
- isExpanded: inType == 2,
- itemList: (queryResult || []).map((item) => (
- {
- ...item,
- isAutoAmount: '0',
- inspectionNature: type,
- type: '2',
- use: inType == 2 ? item.use : false
- }
- ))
- });
- // 缓存当前类型的结果
- checkItemListCache.value[type] = newItems
- // 合并到 checkItemList
- checkItemList.value = [
- ...checkItemList.value.filter(i => i.inspectionNature != type),
- ...newItems
- ]
- }
- /** 切换检验项目展开/收缩状态 */
- const toggleCheckItemCollapse = (checkItem: any) => {
- checkItem.isExpanded = !checkItem.isExpanded
- }
- // 判断当前用户部门是否为锅炉检验部
- const isBoilerInspectionDept = ref(false)
- /** 检查设备部门是否为锅炉检验部 */
- const checkEquipDept = async (selectedRows: any[]) => {
- console.log(selectedRows)
- if (!selectedRows || selectedRows.length === 0) {
- isBoilerInspectionDept.value = false
- return
- }
-
- try {
- // 获取第一个设备的部门ID(假设选中的设备都属于同一个部门)
- const firstRow = selectedRows[0]
- const deptId = firstRow.relatedDepartment
-
- if (!deptId) {
- console.warn('设备数据中没有部门信息')
- isBoilerInspectionDept.value = false
- return
- }
-
- const deptInfo = await getDept(deptId)
- // 判断部门名称是否包含"锅炉检验部"
- isBoilerInspectionDept.value = deptInfo?.name?.includes('锅炉检验部') || false
- } catch (error) {
- console.error('获取设备部门信息失败:', error)
- isBoilerInspectionDept.value = false
- }
- }
- /** 打开弹窗 */
- const open = async (selectedInList, selectedOutList, selectedPreList, type?: string) => {
- //console.log('open', props.selectedRows)
- isOpening.value = true
- dialogVisible.value = true
- // 合并所有选中的设备列表
- const allSelectedRows = [
- ...(selectedInList.value || []),
- ...(selectedOutList.value || []),
- ...(selectedPreList.value || [])
- ]
-
- // 检查设备部门
- await checkEquipDept(allSelectedRows)
- // 重置所有检验员选择
- inSelectedCheckers.value = []
- outSelectedCheckers.value = []
- preSelectedCheckers.value = []
- // 重置校验状态(需等 nextTick 组件 ref 就绪)
- nextTick(() => {
- checkerInRef.value?.resetValidation()
- checkerOutRef.value?.resetValidation()
- checkerPreRef.value?.resetValidation()
- })
- // 根据设备部门设置默认的约检确认状态
- const defaultOrderConfirm = !isBoilerInspectionDept.value
- // 重置表单数据
- formData.value = {
- checkType: type || '100',
- inDate: '',
- inTeamList: [],
- inTaskList: [],
- inIsOrderConfirm: defaultOrderConfirm,
- inChargeType: '1',
- inIsExempt: '0',
- inShouldAmount: 0,
- inServiceAmount: 0,
- inReduceFee: 0,
- outDate: '',
- outTeamList: [],
- outTaskList: [],
- outChargeType: '1',
- outIsOrderConfirm: defaultOrderConfirm,
- outIsExempt: '0',
- outShouldAmount: 0,
- outServiceAmount: 0,
- outReduceFee: 0,
- preDate: '',
- preTeamList: [],
- pressureTaskList: [],
- pressureIsOrderConfirm: defaultOrderConfirm,
- preChargeType: '1',
- preIsExempt: '0',
- preShouldAmount: 0,
- preServiceAmount: 0,
- preReduceFee: 0,
- }
- formData.value.inTaskList = selectedInList
- formData.value.outTaskList = selectedOutList
- formData.value.pressureTaskList = selectedPreList
- // 清空缓存和项目列表,只查询当前检验性质
- checkItemList.value = []
- checkItemListCache.value = {}
- await handleQueryCheckItemList(formData.value.checkType)
- isOpening.value = false
- // 检验员选择由统一的 CheckerSelect 组件自行管理,无需手动加载
- }
- /** 取消操作 */
- const handleCancel = () => {
- dialogVisible.value = false
- checkItemList.value = []
- checkItemListCache.value = {}
- if (!isBatch.value) {
- emit('clear-selected-rows') // 新增事件用于清空选中行
- }
- emit('close')
- }
- /** 确认操作 */
- const handleConfirm = async () => {
- const form = unref(formRef)
- if (!form) return
- submitLoading.value = true
- try {
- // 验证日期
- await form.validate()
- // 验证检验员必填
- const validations: boolean[] = []
- if (inEquipCount.value > 0) validations.push(checkerInRef.value?.validate())
- if (outEquipCount.value > 0) validations.push(checkerOutRef.value?.validate())
- if (preEquipCount.value !== 0) validations.push(checkerPreRef.value?.validate())
- if (validations.some(v => v === false)) return
- // 组装新的数据结构
- const submitData: { taskList: any[]; source: number } = {
- taskList: [],
- source: props.source === 'pressure' ? 100 : 200
- }
- const inUnitList = formData.value.inTaskList.reduce((acc, item) => {
- const key = item.unitId;
- if (!acc[key]) {
- acc[key] = [];
- }
- acc[key].push(item)
- return acc;
- }, {})
- const outUnitList = formData.value.outTaskList.reduce((acc, item) => {
- const key = item.unitId;
- if (!acc[key]) {
- acc[key] = [];
- }
- acc[key].push(item)
- return acc;
- }, {})
- const preUnitList = formData.value.pressureTaskList.reduce((acc, item) => {
- const key = item.unitId;
- if (!acc[key]) {
- acc[key] = [];
- }
- acc[key].push(item)
- return acc;
- }, {})
- // 遍历 formData.value.taskList 中的每个项目
- if (formData.value.checkType == '100') {
- Object.values(inUnitList).forEach(item => {
- // 处理内部检验
- if (formData.value.inDate && formData.value.inTaskList.length > 0) {
- let actualAmount = 0
- console.log(checkItemList.value.find(i => i.inspectionNature == PressureBoilerCheckType.IN))
- checkItemList.value.find(i => i.inspectionNature == PressureBoilerCheckType.IN).itemList.filter(i => i.use).forEach(i => {
- actualAmount += i.fee
- })
- submitData.taskList.push({
- equipIds: item.map(item => item.id).join(','),
- type: '100',
- hasOrderConfirm: isFrontDesk.value ? false : formData.value.inIsOrderConfirm,
- date: formData.value.inDate,
- teamList: formData.value.inTeamList,
- chargeType: formData.value.inChargeType,
- isExempt: formData.value.inIsExempt,
- shouldAmount: formData.value.inShouldAmount,
- serviceAmount: formData.value.inServiceAmount,
- reduceFee: formData.value.inReduceFee,
- actualAmount,
- checkItemList: [...checkItemList.value.filter(i => i.inspectionNature == PressureBoilerCheckType.IN)[0].itemList.filter(i => i.use).map(
- i => {
- return {
- //reportId: i.templateId,
- reportId: i.connectId,
- newAmount: i.fee,
- type: i.type,
- feeCalculateJson: i.feeCalculateJson || '',
- defaultCount: i.defaultCount || 1,
- sort: i.sort || 0,
- }
- }
- ), ...checkItemList.value.filter(i => i.inspectionNature == PressureBoilerCheckType.IN)[1].itemList.filter(i => i.use).map(
- i => {
- return {
- //reportId: i.templateId,
- reportId: i.connectId,
- newAmount: i.fee,
- type: i.type,
- feeCalculateJson: i.feeCalculateJson || '',
- defaultCount: i.defaultCount || 1,
- sort: i.sort || 0,
- }
- }
- ),]
- })
- }
- })
- }
- // 处理外部检验
- if (formData.value.checkType == '200') {
- Object.values(outUnitList).forEach(item => {
- // 处理内部检验
- if (formData.value.outDate && formData.value.outTaskList.length > 0) {
- let actualAmount = 0
- checkItemList.value.find(i => i.inspectionNature == PressureBoilerCheckType.OUT).itemList.filter(i => i.use).forEach(i => {
- actualAmount += i.fee
- })
- submitData.taskList.push({
- equipIds: item.map(item => item.id).join(','),
- type: '200',
- hasOrderConfirm: isFrontDesk.value ? false : formData.value.outIsOrderConfirm,
- date: formData.value.outDate,
- teamList: formData.value.outTeamList,
- chargeType: formData.value.outChargeType,
- isExempt: formData.value.outIsExempt,
- shouldAmount: formData.value.outShouldAmount,
- serviceAmount: formData.value.outServiceAmount,
- reduceFee: formData.value.outReduceFee,
- actualAmount,
- checkItemList: [...checkItemList.value.filter(i => i.inspectionNature == PressureBoilerCheckType.OUT)[0].itemList.filter(i => i.use).map(
- i => {
- return {
- //reportId: i.templateId,
- reportId: i.connectId,
- newAmount: i.fee,
- type: i.type,
- feeCalculateJson: i.feeCalculateJson || '',
- defaultCount: i.defaultCount || 1,
- sort: i.sort || 0,
- }
- }
- ), ...checkItemList.value.filter(i => i.inspectionNature == PressureBoilerCheckType.OUT)[1].itemList.filter(i => i.use).map(
- i => {
- return {
- //reportId: i.templateId,
- reportId: i.connectId,
- newAmount: i.fee,
- type: i.type,
- feeCalculateJson: i.feeCalculateJson || '',
- defaultCount: i.defaultCount || 1,
- sort: i.sort || 0,
- }
- }
- ),]
- })
- }
- })
- }
- // 处理耐压检验
- if (formData.value.checkType == '300') {
- Object.values(preUnitList).forEach(item => {
- // 处理耐压检验
- if (formData.value.preDate && formData.value.pressureTaskList.length > 0) {
- let actualAmount = 0
- checkItemList.value.find(i => i.inspectionNature == PressureBoilerCheckType.PRESSURE).itemList.filter(i => i.use).forEach(i => {
- actualAmount += i.fee
- })
- submitData.taskList.push({
- equipIds: item.map(item => item.id).join(','),
- type: '300',
- hasOrderConfirm: isFrontDesk.value ? false : formData.value.pressureIsOrderConfirm,
- date: formData.value.preDate,
- teamList: formData.value.preTeamList,
- chargeType: formData.value.preChargeType,
- isExempt: formData.value.preIsExempt,
- shouldAmount: formData.value.preShouldAmount,
- serviceAmount: formData.value.preServiceAmount,
- reduceFee: formData.value.preReduceFee,
- actualAmount,
- checkItemList: [...checkItemList.value.filter(i => i.inspectionNature == PressureBoilerCheckType.PRESSURE)[0].itemList.filter(i => i.use).map(
- i => {
- return {
- //reportId: i.templateId,
- reportId: i.connectId,
- newAmount: i.fee,
- type: i.type,
- feeCalculateJson: i.feeCalculateJson || '',
- defaultCount: i.defaultCount || 1,
- sort: i.sort || 0,
- }
- }
- ), ...checkItemList.value.filter(i => i.inspectionNature == PressureBoilerCheckType.PRESSURE)[1].itemList.filter(i => i.use).map(
- i => {
- return {
- //reportId: i.templateId,
- reportId: i.connectId,
- newAmount: i.fee,
- type: i.type,
- feeCalculateJson: i.feeCalculateJson || '',
- defaultCount: i.defaultCount || 1,
- sort: i.sort || 0,
- }
- }
- ),]
- })
- }
- })
- }
- console.log('submitData', submitData)
- const res = await EquipBoilerSchedulingApi.planSchedulingAssign(submitData)
- //console.log(res)
- message.success('保存成功')
- dialogVisible.value = false
- emit('success')
- } catch
- (error) {
- console.error( error)
- message.error('保存失败')
- } finally {
- submitLoading.value = false
- }
- }
- // 向父组件暴露方法
- defineExpose({
- open
- })
- </script>
- <style lang="scss" scoped>
- .plan-section {
- margin-bottom: 24px;
- padding: 16px;
- border: 1px solid #EBEEF5;
- border-radius: 4px;
- .section-title {
- margin: -16px -16px 16px -16px;
- padding: 8px 16px;
- background-color: #F5F7FA;
- border-bottom: 1px solid #EBEEF5;
- font-weight: bold;
- display: flex;
- align-items: center;
- .section-info {
- font-weight: normal;
- font-size: 13px;
- color: #606266;
- margin-left: 26px;
- }
- }
- }
- .content-title {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- width: 100%;
- height: 36px;
- line-height: 36px;
- background-color: var(--el-color-primary-light-9);
- cursor: pointer;
- user-select: none;
- transition: background-color 0.3s;
- &:hover {
- background-color: var(--el-color-primary-light-8);
- }
- .collapse-icon {
- margin-right: 8px;
- transition: transform 0.3s;
- font-size: 14px;
- &.is-collapsed {
- transform: rotate(-90deg);
- }
- }
- &::before {
- content: '';
- height: 70%;
- width: 4px;
- margin-right: 12px;
- background-color: var(--el-color-primary);
- }
- }
- /* 外层容器 */
- .inspection-grid {
- width: 100%;
- padding: 16px;
- }
- /* 标题行 */
- .grid-header {
- font-size: 16px;
- font-weight: bold;
- text-align: center;
- height: 38px;
- line-height: 38px;
- border: 1px solid var(--el-border-color-light);
- border-bottom: 0;
- background-color: var(--el-color-primary-light-9);
- }
- /* Grid 容器核心配置 */
- .grid-container {
- display: grid;
- /* 5列等宽,列间距 12px,行间距 16px */
- grid-template-columns: repeat(5, 1fr);
- align-items: center; /* 垂直居中 */
- grid-gap: 1px;
- background-color: var(--el-border-color-light);
- border: 1px solid var(--el-border-color-light);
- }
- /* 子项布局:复选框 + 文本 + 图标 */
- .grid-item {
- display: flex;
- align-items: center;
- padding-left: 20px;
- padding-right: 12px;
- height: 52px;
- background-color: #fff;
- .el-checkbox {
- margin-right: 6px;
- }
- }
- .form-row {
- display: flex;
- align-items: center;
- .info-label {
- font-weight: bold;
- text-align: right;
- margin-right: 10px;
- }
- .info-value {
- flex: 1;
- }
- }
- .fee-amount {
- font-weight: bold;
- color: #e6a23c;
- font-size: 16px;
- }
- .fee-form-item {
- margin-top: 20px;
- :deep(.el-form-item__label) {
- font-weight: bold;
- }
- }
- .leader-tag {
- display: inline-block;
- width: 14px;
- height: 14px;
- line-height: 12px;
- text-align: center;
- border: 1px solid #4475d6;
- font-size: 10px;
- margin-right: 4px;
- color: #4475d6;
- }
- </style>
|