| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331 |
- <template>
- <ContentWrap v-loading="formLoading">
- <el-form
- ref="formRef"
- :model="formData"
- :rules="formRules"
- label-width="100px"
- v-loading="formLoading"
- >
- <el-row>
- <el-col :span="12">
- <el-form-item label="合同名称" prop="contractName">
- <el-select
- v-model="formData.contractId"
- placeholder="请选择"
- @change="getProjectInfo"
- disabled
- >
- <el-option
- v-for="item in projectList"
- :key="item.id"
- :label="item.contractName"
- :value="item.id"
- clearable
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="合同编号" prop="contractCode">
- <el-input v-model="formData.contractCode" placeholder="请输入合同编号" disabled />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item label="客户名称" prop="manufacturerId">
- <el-select
- clearable
- @clear="zzClear"
- v-model="formData.manufacturerId"
- :placeholder="t('deviceForm.mfgHolder')"
- disabled
- >
- <el-option :label="formData.manufactureName" :value="formData.manufacturerId" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item :label="t('project.payment')" prop="payment">
- <el-select v-model="formData.payment" placeholder="请选择" disabled>
- <el-option
- v-for="dict in getStrDictOptions(DICT_TYPE.PMS_PROJECT_SETTLEMENT)"
- :key="dict.id"
- :label="dict.label"
- :value="dict.value"
- />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item label="开始时间" prop="startTime">
- <el-date-picker
- style="width: 150%"
- v-model="formData.startTime"
- type="date"
- value-format="x"
- placeholder="选择开始时间"
- disabled
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="完成时间" prop="endTime">
- <el-date-picker
- style="width: 150%"
- v-model="formData.endTime"
- type="date"
- value-format="x"
- placeholder="选择完成时间"
- disabled
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-form-item label="备注" prop="remark">
- <el-input v-model="formData.remark" placeholder="请输入备注" type="textarea" disabled />
- </el-form-item>
- </el-form>
- </ContentWrap>
- <ContentWrap v-if="false">
- <div class="content">
- <div class="toolbar">
- <div class="actions">
- <!-- 操作按钮已移动到表单区域 -->
- </div>
- </div>
- <div class="table-container">
- <el-table
- :data="tableData"
- empty-text="暂无数据"
- highlight-current-row
- @current-change="handleRowClick"
- >
- <el-table-column prop="wellName" label="井号" />
- <el-table-column prop="wellType" label="井型">
- <template #default="{ row }">
- {{ getWellTypeLabel(row.wellType) }}
- </template>
- </el-table-column>
- <el-table-column prop="wellCategory" label="井别">
- <template #default="{ row }">
- {{ getWellCategoryLabel(row.wellCategory) }}
- </template>
- </el-table-column>
- <el-table-column prop="location" label="施工地点" />
- <el-table-column :label="t('project.technology')">
- <template #default="{ row }">
- {{ getTechniqueLabel(row.technique) }}
- </template>
- </el-table-column>
- <el-table-column prop="workloadDesign" label="设计工作量" />
- <el-table-column :label="t('project.unit')">
- <template #default="{ row }">
- {{ getWorkloadUnitLabel(row.workloadUnit) }}
- </template>
- </el-table-column>
- <el-table-column prop="deptIds" label="施工队伍">
- <template #default="{ row }">
- <el-tooltip
- effect="dark"
- :content="getAllDeptNames(row.deptIds)"
- placement="top"
- :disabled="!row.deptIds || row.deptIds.length <= 1"
- >
- <span class="dept-names">
- {{ getDeptNames(row.deptIds) }}
- </span>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column prop="deviceIds" label="施工设备">
- <template #default="{ row }">
- <el-tooltip
- :content="getAllDeviceNames(row.deviceIds)"
- placement="top"
- :disabled="row.deviceIds && row.deviceIds.length <= 1"
- >
- <span class="device-names">
- {{ getDeviceNames(row.deviceIds) }}
- </span>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column prop="responsiblePerson" label="责任人">
- <template #default="{ row }">
- <el-tooltip
- :content="getAllResponsiblePersonNames(row.responsiblePerson)"
- placement="top"
- :disabled="!row.responsiblePerson || row.responsiblePerson.length <= 1"
- >
- <span class="responsible-names">
- {{ getResponsiblePersonNames(row.responsiblePerson) }}
- </span>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column prop="remark" label="备注" />
- </el-table>
- </div>
- </div>
- </ContentWrap>
- <!-- 新增任务详情编辑表单 -->
- <ContentWrap>
- <h3 style="margin-bottom: 20px">任务详情</h3>
- <el-form
- ref="taskFormRef"
- :model="currentTask"
- :rules="taskFormRules"
- label-width="120px"
- class="task-edit-form"
- >
- <el-row>
- <el-col :span="8">
- <el-form-item label="井号" prop="wellName">
- <el-input
- v-model="currentTask.wellName"
- placeholder="请输入井号"
- :disabled="currentTask.platformWell === '1'"
- />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item :label="t('project.workArea')" prop="location">
- <el-autocomplete
- ref="workAreaAutocomplete"
- v-model="currentTask.location"
- :fetch-suggestions="querySearch"
- :trigger-on-focus="true"
- placeholder="请输入施工区域"
- @focus="handleWorkAreaFocus"
- @select="handleSelect"
- :disabled="!workAreaOptions.length"
- popper-class="work-area-autocomplete"
- >
- <template #prefix>
- <el-icon v-if="loadingWorkAreaOptions" class="is-loading">
- <Loading />
- </el-icon>
- </template>
- </el-autocomplete>
- <div v-if="!workAreaOptions.length" class="el-form-item__error">
- 暂无可用施工区域选项,请手动输入
- </div>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item :label="t('project.technology')" prop="technique">
- <el-select
- v-model="currentTask.technique"
- placeholder="请选择施工工艺"
- clearable
- :loading="loadingTechnologyOptions"
- >
- <el-option
- v-for="dict in technologyOptions"
- :key="dict.value"
- :label="dict.label"
- :value="dict.value"
- />
- </el-select>
- <div
- v-if="!technologyOptions.length && !loadingTechnologyOptions"
- class="el-form-item__error"
- >
- 暂无可用施工工艺选项
- </div>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="8">
- <el-form-item label="设计工作量" prop="workloadDesign">
- <el-tooltip
- :disabled="!workloadDesignError"
- :content="workloadDesignError"
- placement="top"
- effect="light"
- popper-class="workload-design-tooltip"
- :show-after="0"
- >
- <el-input
- v-model="currentTask.workloadDesign"
- placeholder="请输入设计工作量"
- :disabled="currentTask.platformWell === '1'"
- class="workload-input-with-button"
- :class="{ 'error-input': workloadDesignError }"
- @blur="validateWorkloadDesign"
- >
- <template #append>
- <el-tooltip content="添加多个设计工作量" placement="top">
- <el-button
- class="workload-add-btn"
- @click="openWorkloadDialog"
- :disabled="getWorkloadAddBtnDisabled"
- >
- <span class="btn-text">+</span>
- </el-button>
- </el-tooltip>
- </template>
- </el-input>
- </el-tooltip>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item :label="t('project.unit')" prop="workloadUnit">
- <el-select
- v-model="currentTask.workloadUnit"
- placeholder="请选择工作量单位"
- clearable
- :disabled="currentTask.platformWell === '1'"
- >
- <el-option
- v-for="dict in getStrDictOptions(DICT_TYPE.PMS_PROJECT_WORKLOAD_UNIT)"
- :key="dict.value"
- :label="dict.label"
- :value="dict.value"
- :disabled="
- getFormSelectedWorkloadUnits().includes(dict.value) &&
- dict.value !== currentTask.workloadUnit
- "
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="施工队伍" prop="deptIds">
- <el-tree-select
- multiple
- :multiple-limit="formData.deptId === 157 ? 1 : 0"
- v-model="currentTask.deptIds"
- :data="deptList"
- :props="treeSelectProps"
- :default-expanded-keys="defaultExpandedKeys"
- check-strictly
- node-key="id"
- filterable
- placeholder="请选择施工队伍"
- clearable
- @visible-change="handleTreeVisibleChange"
- collapse-tags
- collapse-tags-tooltip
- :max-collapse-tags="1"
- class="department-tree-select single-line-tree-select"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="8">
- <el-form-item label="施工设备" prop="deviceIds">
- <el-button @click="openDeviceDialogForForm" type="primary" size="small">
- 选择设备
- </el-button>
- <!--
- <span v-if="currentTask.deviceIds && currentTask.deviceIds.length > 0" style="margin-left: 10px;">
- 已选 {{ currentTask.deviceIds.length }} 台设备
- </span> -->
- <el-tooltip
- v-if="currentTask.deviceIds && currentTask.deviceIds.length > 0"
- :content="getAllDeviceNamesForForm(currentTask.deviceIds)"
- placement="top"
- >
- <span style="margin-left: 10px">
- {{ formatDevicesForForm(currentTask.deviceIds) }}
- </span>
- </el-tooltip>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item :label="isSpecialDept ? '带班干部' : '责任人'" prop="responsiblePerson">
- <el-button @click="openResponsiblePersonDialogForForm" type="primary" size="small">
- 选择{{ isSpecialDept ? '带班干部' : '责任人' }}
- </el-button>
- <el-tooltip
- v-if="currentTask.responsiblePerson && currentTask.responsiblePerson.length > 0"
- :content="getAllResponsiblePersonNamesForForm(currentTask.responsiblePerson)"
- placement="top"
- >
- <span style="margin-left: 10px">
- {{ formatResponsiblePersonsForForm(currentTask.responsiblePerson) }}
- </span>
- </el-tooltip>
- </el-form-item>
- </el-col>
- <el-col :span="8" v-if="isSpecialDept">
- <el-form-item label="填报人" prop="submitter">
- <el-button @click="openSubmitterDialogForForm" type="primary" size="small">
- 选择填报人
- </el-button>
- <el-tooltip
- v-if="currentTask.submitter && currentTask.submitter.length > 0"
- :content="getAllSubmitterNamesForForm(currentTask.submitter)"
- placement="top"
- >
- <span style="margin-left: 10px">
- {{ formatSubmittersForForm(currentTask.submitter) }}
- </span>
- </el-tooltip>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="8" v-if="isSpecialDept">
- <el-form-item label="平台井" prop="platformWell">
- <el-switch
- v-model="currentTask.platformWell"
- active-value="1"
- inactive-value="0"
- @change="handlePlatformWellChange"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <!-- 动态属性部分 -->
- <el-row v-if="dynamicAttrs.length > 0">
- <el-col
- v-for="attr in dynamicAttrs"
- :key="attr.id"
- :span="attr.dataType === 'textarea' ? 24 : 8"
- >
- <el-form-item
- :label="attr.name + (attr.unit ? `(${attr.unit})` : '')"
- :prop="attr.identifier"
- :rules="getDynamicAttrRules(attr)"
- >
- <!-- 文本类型 -->
- <el-input
- v-if="attr.dataType === 'text'"
- v-model="currentTask[attr.identifier]"
- :placeholder="`请输入${attr.name}`"
- />
- <!-- 文本域类型 -->
- <el-input
- v-else-if="attr.dataType === 'textarea'"
- v-model="currentTask[attr.identifier]"
- :placeholder="`请输入${attr.name}`"
- type="textarea"
- :rows="3"
- />
- <!-- 数字类型 -->
- <el-input
- v-else-if="attr.dataType === 'double'"
- v-model="currentTask[attr.identifier]"
- :placeholder="`请输入${attr.name}`"
- type="number"
- :min="attr.minValue || undefined"
- :max="attr.maxValue || undefined"
- />
- <!-- 日期类型 -->
- <el-date-picker
- v-else-if="attr.dataType === 'date'"
- v-model="currentTask[attr.identifier]"
- type="date"
- value-format="x"
- :placeholder="`选择${attr.name}`"
- style="width: 100%"
- />
- <!-- 默认文本输入 -->
- <el-input
- v-else
- v-model="currentTask[attr.identifier]"
- :placeholder="`请输入${attr.name}`"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <el-form-item label="备注" prop="remark">
- <el-input v-model="currentTask.remark" placeholder="请输入备注" type="textarea" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-form-item>
- <el-button @click="resetTaskForm" v-if="isNewTask">重置</el-button>
- </el-form-item>
- </el-form>
- </ContentWrap>
- <div
- v-if="companyName === 'ry'"
- class="my-6 bg-white p-4 border-1 border-solid border-[var(--el-border-color-light)]"
- >
- <h3 style="margin-bottom: 20px">附件</h3>
- <el-form-item size="default" label="工程设计">
- <el-upload
- v-model:file-list="constructionFiles"
- :action="uploadUrl"
- multiple
- :headers="{ 'tenant-id': 1, 'device-id': 'undefined' }"
- name="files"
- class="w-50%"
- @preview="handlePreview"
- >
- <el-button type="primary">上传工程设计</el-button>
- <template #tip>
- <div class="el-upload__tip">文件大小不能超过50MB </div>
- </template>
- </el-upload>
- </el-form-item>
- <el-form-item size="default" label="地质设计">
- <el-upload
- v-model:file-list="geologicalFiles"
- :action="uploadUrl"
- multiple
- :headers="{ 'tenant-id': 1, 'device-id': 'undefined' }"
- name="files"
- class="w-50%"
- @preview="handlePreview"
- >
- <el-button type="primary">上传地质设计</el-button>
- <template #tip>
- <div class="el-upload__tip">文件大小不能超过50MB </div>
- </template>
- </el-upload>
- </el-form-item>
- <el-form-item size="default" label="完井报告">
- <el-upload
- v-model:file-list="completionFiles"
- :action="uploadUrl"
- multiple
- :headers="{ 'tenant-id': 1, 'device-id': 'undefined' }"
- name="files"
- class="w-50%"
- @preview="handlePreview"
- >
- <el-button :disabled="tableData[0].status !== 'wg'" type="primary">上传完井报告</el-button>
- <template #tip>
- <div class="el-upload__tip">文件大小不能超过50MB </div>
- </template>
- </el-upload>
- </el-form-item>
- </div>
- <ContentWrap v-if="currentTask.platformWell === '1'">
- <h3 style="margin-bottom: 20px">平台井</h3>
- <el-table :data="currentTask.platformWellDetails" style="width: 100%">
- <el-table-column prop="wellName" label="井号">
- <template #default="{ $index }">
- <el-input
- v-model="currentTask.platformWellDetails[$index].wellName"
- placeholder="请输入井号"
- />
- </template>
- </el-table-column>
- <el-table-column label="工作量单位" width="150">
- <template #default="{ $index }">
- <el-select
- v-model="currentTask.platformWellDetails[$index].workloadUnit"
- placeholder="请选择工作量单位"
- clearable
- :disabled="
- getPlatformWellWorkloadUnits($index).includes(
- currentTask.platformWellDetails[$index].workloadUnit
- ) && currentTask.platformWellDetails[$index].workloadUnit !== currentTask.workloadUnit
- "
- >
- <el-option
- v-for="dict in getStrDictOptions(DICT_TYPE.PMS_PROJECT_WORKLOAD_UNIT)"
- :key="dict.value"
- :label="dict.label"
- :value="dict.value"
- :disabled="
- getPlatformWellWorkloadUnits($index).includes(dict.value) &&
- dict.value !== currentTask.platformWellDetails[$index].workloadUnit
- "
- />
- </el-select>
- </template>
- </el-table-column>
- <el-table-column prop="workloadDesign" label="设计工作量">
- <template #default="{ $index }">
- <el-tooltip
- :disabled="!currentTask.platformWellDetails[$index].workloadDesignError"
- :content="currentTask.platformWellDetails[$index].workloadDesignError"
- placement="top"
- effect="light"
- popper-class="workload-design-tooltip"
- :show-after="0"
- >
- <el-input
- v-model="currentTask.platformWellDetails[$index].workloadDesign"
- placeholder="请输入设计工作量"
- class="workload-input-with-button"
- :class="{
- 'error-input': currentTask.platformWellDetails[$index].workloadDesignError
- }"
- @blur="validatePlatformWellWorkloadDesign($index)"
- >
- <template #append>
- <el-tooltip content="添加多个设计工作量" placement="top">
- <el-button
- class="workload-add-btn"
- @click="openPlatformWellWorkloadDialog($index)"
- :disabled="getPlatformWellWorkloadAddBtnDisabled($index)"
- >
- <span class="btn-text">+</span>
- </el-button>
- </el-tooltip>
- </template>
- </el-input>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="100">
- <template #default="{ $index }">
- <el-button
- type="danger"
- size="small"
- @click="removePlatformWellDetail($index)"
- :disabled="isMainPlatformWellDetail($index)"
- >
- 删除
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- <el-button type="primary" size="small" @click="addPlatformWellDetail" style="margin-top: 10px">
- 添加一行
- </el-button>
- </ContentWrap>
- <ContentWrap>
- <el-form style="float: right">
- <el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
- <el-button @click="close">取 消</el-button>
- </el-form>
- </ContentWrap>
- <!-- 设备选择对话框 -->
- <el-dialog
- v-model="deviceDialogVisible"
- title="选择施工设备"
- width="1000px"
- :before-close="handleDeviceDialogClose"
- class="device-select-dialog"
- >
- <div class="transfer-container">
- <el-transfer
- v-model="selectedDeviceIds"
- :data="filteredDeviceList"
- :titles="['可选设备', '已选设备']"
- :props="{ key: 'id', label: 'deviceCode' }"
- filterable
- :filter-method="filterDeviceMethod"
- class="transfer-component"
- @change="handleTransferChange"
- >
- <template #default="{ option }">
- <el-tooltip
- effect="dark"
- placement="top"
- :content="`${option.deviceCode || ''} - ${option.deviceName || ''}`"
- :disabled="!option.deviceCode && !option.deviceName"
- transition="fade-in-linear"
- >
- <span class="transfer-option-text">
- {{ option.deviceCode }} - {{ option.deviceName }}
- </span>
- </el-tooltip>
- </template>
- </el-transfer>
- </div>
- <template #footer>
- <span class="dialog-footer">
- <el-button @click="handleDeviceDialogClose">取消</el-button>
- <el-button type="primary" @click="confirmDeviceSelection">确定</el-button>
- </span>
- </template>
- </el-dialog>
- <!-- 责任人选择对话框 -->
- <el-dialog
- v-model="responsiblePersonDialogVisible"
- title="选择责任人"
- width="1000px"
- :before-close="handleResponsiblePersonDialogClose"
- class="responsible-person-select-dialog"
- >
- <div class="transfer-container">
- <el-transfer
- v-model="selectedResponsiblePersonIds"
- :data="responsiblePersonList"
- :titles="['可选人员', '已选人员']"
- :props="{ key: 'id', label: 'nickname' }"
- filterable
- class="transfer-component"
- >
- <template #default="{ option }">
- <el-tooltip
- effect="dark"
- placement="top"
- :content="`${option.nickname} - ${option.deptName || '未分配部门'}`"
- >
- <span class="transfer-option-text">
- {{ option.nickname }} - {{ option.deptName || '未分配部门' }}
- </span>
- </el-tooltip>
- </template>
- </el-transfer>
- </div>
- <template #footer>
- <span class="dialog-footer">
- <el-button @click="handleResponsiblePersonDialogClose">取消</el-button>
- <el-button type="primary" @click="confirmResponsiblePersonSelection">确定</el-button>
- </span>
- </template>
- </el-dialog>
- <!-- 填报人选择对话框 -->
- <el-dialog
- v-model="submitterDialogVisible"
- title="选择填报人"
- width="1000px"
- :before-close="handleSubmitterDialogClose"
- class="responsible-person-select-dialog"
- >
- <div class="transfer-container">
- <el-transfer
- v-model="selectedSubmitterIds"
- :data="submitterList"
- :titles="['可选人员', '已选人员']"
- :props="{ key: 'id', label: 'nickname' }"
- filterable
- class="transfer-component"
- >
- <template #default="{ option }">
- <el-tooltip
- effect="dark"
- placement="top"
- :content="`${option.nickname} - ${option.deptName || '未分配部门'}`"
- >
- <span class="transfer-option-text">
- {{ option.nickname }} - {{ option.deptName || '未分配部门' }}
- </span>
- </el-tooltip>
- </template>
- </el-transfer>
- </div>
- <template #footer>
- <span class="dialog-footer">
- <el-button @click="handleSubmitterDialogClose">取消</el-button>
- <el-button type="primary" @click="confirmSubmitterSelection">确定</el-button>
- </span>
- </template>
- </el-dialog>
- <!-- 工作量维护对话框 -->
- <el-dialog v-model="workloadDialogVisible" title="设计工作量" width="600px">
- <el-table :data="workloadList" style="width: 100%">
- <el-table-column prop="workloadUnit" label="工作量单位" width="200">
- <template #default="{ $index }">
- <el-select
- v-model="workloadList[$index].workloadUnit"
- placeholder="请选择工作量单位"
- :disabled="$index === 0 && hasInitialWorkload"
- >
- <el-option
- v-for="dict in getStrDictOptions(DICT_TYPE.PMS_PROJECT_WORKLOAD_UNIT)"
- :key="dict.value"
- :label="dict.label"
- :value="dict.value"
- :disabled="getSelectedWorkloadUnits($index).includes(dict.value)"
- />
- </el-select>
- </template>
- </el-table-column>
- <el-table-column prop="workloadDesign" label="工作量">
- <template #default="{ $index }">
- <el-tooltip
- :disabled="!workloadList[$index].workloadDesignError"
- :content="workloadList[$index].workloadDesignError"
- placement="top"
- effect="light"
- popper-class="workload-design-tooltip"
- :show-after="0"
- >
- <el-input
- v-model="workloadList[$index].workloadDesign"
- placeholder="请输入工作量"
- :disabled="$index === 0 && hasInitialWorkload"
- :class="{ 'error-input': workloadList[$index].workloadDesignError }"
- @blur="validateWorkloadDialogDesign($index)"
- />
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="80">
- <template #default="{ $index }">
- <el-button
- type="danger"
- size="small"
- @click="removeWorkloadItem($index)"
- :disabled="$index === 0 && hasInitialWorkload"
- >
- 删除
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- <el-button type="primary" size="small" @click="addWorkloadItem" style="margin-top: 10px">
- 添加一行
- </el-button>
- <template #footer>
- <span class="dialog-footer">
- <el-button @click="workloadDialogVisible = false">取消</el-button>
- <el-button type="primary" @click="confirmWorkloadSelection">确定</el-button>
- </span>
- </template>
- </el-dialog>
- </template>
- <script setup lang="ts">
- // 导入部分保持不变,与原始代码相同
- import { IotProjectInfoApi, IotProjectInfoVO } from '@/api/pms/iotprojectinfo'
- import { handleTree } from '@/utils/tree'
- import * as DeptApi from '@/api/system/dept'
- import { ref, reactive, computed, onMounted, watch } from 'vue'
- import { useUserStore } from '@/store/modules/user'
- import { IotProjectTaskApi, IotProjectTaskVO } from '@/api/pms/iotprojecttask'
- import { ElMessage } from 'element-plus'
- import { useTagsViewStore } from '@/store/modules/tagsView'
- import { IotDeviceApi, IotDeviceVO } from '@/api/pms/device'
- import * as UserApi from '@/api/system/user'
- import { IotProjectTaskAttrsApi } from '@/api/pms/iotprojecttaskattrs'
- import { DICT_TYPE, getStrDictOptions, getDictLabel } from '@/utils/dict'
- import { IotOpeationFillApi } from '@/api/pms/iotopeationfill'
- import { Base64 } from 'js-base64'
- // 在导入部分添加Plus图标
- // import { Plus } from '@element-plus/icons-vue'
- const { query, params, name } = useRoute() // 查询参数
- const id = params.id
- const uploadUrl = import.meta.env.VITE_BASE_URL + '/admin-api/rq/file/upload'
- const constructionFiles = ref<any>([])
- const geologicalFiles = ref<any>([])
- const completionFiles = ref<any>([])
- // 修改projectId获取逻辑:优先使用params.projectId,其次使用query.projectId
- const projectId = ref<string>('')
- // 获取projectId的逻辑
- if (params.projectId) {
- projectId.value = Array.isArray(params.projectId) ? params.projectId[0] : params.projectId
- } else if (query.projectId) {
- projectId.value = Array.isArray(query.projectId as any)
- ? query.projectId[0]
- : (query.projectId as string)
- }
- function handlePreview(file: any) {
- if (!file.response) {
- message.error('附件路径不存在')
- return
- }
- try {
- const filePath = file.response.data.filePath ?? file.response.data.files[0].filePath
- const encodedPath = encodeURIComponent(Base64.encode(filePath))
- window.open(`http://doc.deepoil.cc:8012/onlinePreview?url=${encodedPath}`)
- } catch (error) {
- console.error('预览附件失败:', error)
- message.error('预览附件失败')
- }
- }
- // 施工队伍 选择树 响应式变量
- const defaultExpandedKeys = ref<number[]>([]) // 默认展开的部门节点keys
- const treeSelectRef = ref() // 树选择组件的引用
- const { delView } = useTagsViewStore() // 视图操作
- const { currentRoute, push } = useRouter()
- const { t } = useI18n() // 国际化
- const message = useMessage() // 消息弹窗
- const deptList = ref<Tree[]>([]) // 树形结构
- const deviceList = ref<IotDeviceVO[]>([]) // 设备列表
- // 设备映射表(ID->设备对象)
- const deviceMap = ref<Record<number, IotDeviceVO>>({})
- const dialogVisible = ref(true) // 弹窗的是否展示
- const dialogTitle = ref('') // 弹窗的标题
- const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
- const taskList = ref<IotProjectTaskVO[]>([]) // 列表的数据
- const projectList = ref<IotProjectInfoVO[]>([])
- const formType = ref('') // 表单的类型:create - 新增;update - 修改
- const loading = ref(true) // 列表的加载中
- // 设备选择相关变量
- const deviceDialogVisible = ref(false)
- const filteredDeviceList = ref<IotDeviceVO[]>([]) // 过滤后的设备列表
- const selectedDeviceIds = ref<number[]>([]) // 选中的设备ID
- // 责任人相关变量
- const responsiblePersonDialogVisible = ref(false)
- const responsiblePersonList = ref([]) // 所有责任人列表
- const selectedResponsiblePersonIds = ref([]) // 选中的责任人ID
- const currentEditingRowForResponsible = ref(null) // 当前正在编辑责任人的行
- const submitterDialogVisible = ref(false)
- const submitterList = ref([]) // 所有填报人列表
- const selectedSubmitterIds = ref([]) // 选中的日报填报人ID
- // 动态属性相关变量
- const dynamicAttrs = ref<any[]>([]) // 存储动态属性列表
- // 跟踪是否已从任务数据中获取动态属性
- const hasDynamicAttrsFromTask = ref(false)
- // 添加 workAreaOptions 引用和加载状态
- const workAreaOptions = ref<any[]>([])
- const loadingWorkAreaOptions = ref(false)
- const workAreaAutocomplete = ref() // 添加对el-autocomplete的引用
- // currentDictLabel 响应式变量
- const currentDictLabel = ref('') // 存储当前项目对应的施工区域字典类型
- // 当前正在操作的平台井索引
- const currentPlatformWellIndex = ref(-1)
- // 施工工艺相关变量
- const technologyOptions = ref<any[]>([])
- const loadingTechnologyOptions = ref(false)
- const currentTechnologyDictLabel = ref('') // 存储当前项目对应的施工工艺字典类型
- // 添加一个变量来保存平台井详情数据
- const platformWellDetailsBackup = ref([])
- // 存储井号到工作量列表的映射(key: wellName, value: Array<{workloadUnit, workloadDesign}>)
- const workloadMap = ref(new Map())
- // 工作量数据备份
- const workloadBackup = ref<Map<string, any[]>>(new Map())
- // 工作量维护相关变量
- const workloadDialogVisible = ref(false)
- const workloadList = ref<any[]>([])
- const hasInitialWorkload = ref(false)
- // 跟踪设备列表是否为空
- const hasDevicesAvailable = ref(false) // 默认假设有设备,等接口返回后更新
- // 设计工作量错误信息
- const workloadDesignError = ref('')
- /** 项目信息 表单 */
- defineOptions({ name: 'IotProjectTaskInfo' })
- const formData = ref({
- id: undefined,
- contractId: undefined,
- contractName: undefined,
- contractCode: undefined,
- workloadTotal: undefined,
- workloadFinish: undefined,
- workloadUnit: undefined,
- startTime: undefined,
- endTime: undefined,
- location: undefined,
- technique: undefined,
- payment: undefined,
- remark: undefined,
- manufactureName: undefined,
- manufacturerId: undefined,
- userName: undefined,
- userId: undefined,
- deptId: undefined // 新增项目部门ID字段
- })
- const close = () => {
- delView(unref(currentRoute))
- push({ name: 'IotProjectTask', params: {} })
- }
- // 添加计算属性来判断是否为特定部门
- const isSpecialDept = computed(() => {
- return formData.value.deptId === 163
- })
- // 定义新的树选择器配置,添加禁用逻辑
- const treeSelectProps = {
- children: 'children',
- label: 'name',
- disabled: (data: any) => {
- // 只有叶子节点(type = 3)可以选择,非叶子节点禁用
- return data.type !== '3'
- }
- }
- const getProjectInfo = async (contractId: number) => {
- const project = projectList.value.find((item) => item.id === contractId)
- if (project) {
- formData.value.contractName = project.contractName
- formData.value.contractCode = project.contractCode
- formData.value.payment = project.payment
- formData.value.workloadTotal = project.workloadTotal
- formData.value.startTime = project.startTime
- formData.value.endTime = project.endTime
- formData.value.remark = project.remark
- formData.value.manufactureName = project.manufactureName
- formData.value.manufacturerId = project.manufacturerId
- formData.value.id = project.id
- formData.value.deptId = project.deptId // 保存项目部门ID
- // 获取施工区域数据字典集合
- await loadWorkAreaOptions(formData.value.deptId)
- // 获取施工工艺数据字典集合
- await loadTechnologyOptions(formData.value.deptId)
- // 获取动态属性
- await fetchDynamicAttrs()
- }
- }
- const queryParams = reactive({
- projectId: undefined,
- id: undefined
- })
- const formRules = reactive({
- contractId: [{ required: true, message: '合同名称不能为空', trigger: 'blur' }],
- manufacturerId: [{ required: true, message: '客户不能为空', trigger: 'blur' }],
- payment: [{ required: true, message: '结算方式不能为空', trigger: 'blur' }],
- // workloadTotal: [{ required: true, message: '工作量总数不能为空', trigger: 'blur' }],
- startTime: [{ required: true, message: '开始时间不能为空', trigger: 'blur' }],
- endTime: [{ required: true, message: '结束时间不能为空', trigger: 'blur' }]
- })
- const formRef = ref() // 表单 Ref
- const zzClear = () => {
- formData.value.manufacturerId = undefined
- formData.value.manufactureName = undefined
- }
- // 根据部门ID获取部门名称
- const getDeptNames = (deptIds) => {
- if (!deptIds || deptIds.length === 0) return ''
- const names = []
- const findDept = (list, id) => {
- for (const item of list) {
- if (item.id === id) {
- names.push(item.name)
- return true
- }
- if (item.children && findDept(item.children, id)) {
- return true
- }
- }
- return false
- }
- deptIds.forEach((id) => findDept(deptList.value, id))
- if (names.length > 1) {
- return `${names[0]}...`
- }
- return names.join(', ')
- }
- const getAllDeptNames = (deptIds) => {
- if (!deptIds || deptIds.length === 0) return '无施工队伍'
- const names = []
- const findDept = (list, id) => {
- for (const item of list) {
- if (item.id === id) {
- names.push(item.name)
- return true
- }
- if (item.children && findDept(item.children, id)) {
- return true
- }
- }
- return false
- }
- deptIds.forEach((id) => findDept(deptList.value, id))
- return names.join(', ') || '无有效施工队伍'
- }
- const getDeviceNames = (deviceIds: number[]) => {
- if (!deviceIds || deviceIds.length === 0) return ''
- // 获取所有有效设备名称
- const deviceNames = deviceIds
- .map((id) => deviceMap.value[id]?.deviceCode)
- .filter((name) => name !== undefined && name !== '')
- if (deviceNames.length === 0) return ''
- // 如果设备数量超过2个,显示前两个加省略号
- if (deviceNames.length > 2) {
- return `${deviceNames[0]}, ${deviceNames[1]}...`
- }
- // 设备数量不超过2个,正常显示所有
- return deviceNames.join(', ')
- }
- const initDynamicAttrsToCurrentTask = () => {
- dynamicAttrs.value.forEach((attr) => {
- if (!currentTask.value.hasOwnProperty(attr.identifier)) {
- // 如果是从任务数据中获取的属性,并且有实际值,使用实际值
- if (
- hasDynamicAttrsFromTask.value &&
- attr.actualValue !== undefined &&
- attr.actualValue !== null &&
- attr.actualValue !== ''
- ) {
- currentTask.value[attr.identifier] = attr.actualValue
- } else {
- // 否则使用默认值
- currentTask.value[attr.identifier] = attr.defaultValue || ''
- }
- }
- })
- }
- // 当前编辑的任务
- const currentTask = ref({
- id: undefined,
- wellName: '',
- wellType: '',
- wellCategory: '',
- location: '',
- dictType: '',
- technique: '',
- workloadDesign: '',
- workloadUnit: '',
- deptIds: [],
- deviceIds: [],
- responsiblePerson: [],
- submitter: [],
- remark: '',
- projectId: '',
- platformWell: '0', // 新增平台井字段,默认非平台井
- platformWellDetails: [] // 新增平台井详情列表
- })
- const isNewTask = ref(false) // 是否是新任务
- const taskFormRef = ref() // 任务表单ref
- const currentEditingIndex = ref(-1) // 当前编辑的行索引
- // 任务表单验证规则
- const taskFormRules = computed(() => {
- const rules = {
- wellName: [
- { required: currentTask.value.platformWell !== '1', message: '井号不能为空', trigger: 'blur' }
- ],
- wellType: [{ required: true, message: '井型不能为空', trigger: 'change' }],
- location: [{ required: true, message: '施工地点不能为空', trigger: 'blur' }],
- technique: [{ required: true, message: '施工工艺不能为空', trigger: 'change' }],
- workloadDesign: [
- {
- required: currentTask.value.platformWell !== '1',
- message: '设计工作量不能为空',
- trigger: 'blur'
- },
- {
- validator: (rule, value, callback) => {
- if (currentTask.value.platformWell === '1') {
- callback()
- return
- }
- if (value === '' || value === null || value === undefined) {
- callback(new Error('设计工作量不能为空'))
- return
- }
- const numValue = Number(value)
- if (isNaN(numValue) || numValue < 0) {
- callback(new Error('请填写大于0的数字'))
- } else {
- callback()
- }
- },
- trigger: 'blur'
- }
- ],
- workloadUnit: [
- {
- required: currentTask.value.platformWell !== '1',
- message: '工作量单位不能为空',
- trigger: 'change'
- }
- ],
- deptIds: [{ required: true, message: '施工队伍不能为空', trigger: 'change' }],
- deviceIds: [
- { required: hasDevicesAvailable.value, message: '施工设备不能为空', trigger: 'change' }
- ],
- responsiblePerson: [
- {
- required: true,
- message: isSpecialDept.value ? '带班干部不能为空' : '责任人不能为空',
- trigger: 'change',
- validator: (rule, value, callback) => {
- if (!value || value.length === 0) {
- callback(new Error(isSpecialDept.value ? '带班干部不能为空' : '责任人不能为空'))
- } else {
- callback()
- }
- }
- }
- ],
- submitter: [
- {
- required: isSpecialDept.value,
- message: '填报人不能为空',
- trigger: 'change',
- validator: (rule, value, callback) => {
- if (isSpecialDept.value && (!value || value.length === 0)) {
- callback(new Error('填报人不能为空'))
- } else {
- callback()
- }
- }
- }
- ]
- }
- return rules
- })
- // 动态属性验证规则
- const getDynamicAttrRules = (attr) => {
- const rules = []
- if (attr.required === 1) {
- rules.push({ required: true, message: `${attr.name}不能为空`, trigger: 'blur' })
- }
- // 数字类型验证
- if (attr.dataType === 'double') {
- rules.push({
- validator: (rule, value, callback) => {
- if (value === '' || value === null || value === undefined) {
- callback()
- return
- }
- const numValue = Number(value)
- if (isNaN(numValue)) {
- callback(new Error(`${attr.name}必须是数字`))
- } else if (attr.minValue !== null && numValue < Number(attr.minValue)) {
- // callback(new Error(`${attr.name}不能小于${attr.minValue}`));
- } else if (attr.maxValue !== null && numValue > Number(attr.maxValue)) {
- // callback(new Error(`${attr.name}不能大于${attr.maxValue}`));
- } else {
- callback()
- }
- },
- trigger: 'blur'
- })
- }
- return rules
- }
- const tableData = ref([])
- // 打开责任人选择对话框(用于表单)
- const openResponsiblePersonDialogForForm = async () => {
- if (!currentTask.value.deptIds || currentTask.value.deptIds.length === 0) {
- ElMessage.warning('请先选择施工队伍')
- return
- }
- selectedResponsiblePersonIds.value = [...(currentTask.value.responsiblePerson || [])]
- try {
- const params = {
- deptIds: currentTask.value.deptIds // 使用当前项目所属部门的deptId
- }
- const response = await UserApi.selectedDeptsEmployee(params)
- responsiblePersonList.value = response
- responsiblePersonDialogVisible.value = true
- } catch (error) {
- ElMessage.error('获取责任人列表失败')
- console.error('获取责任人列表失败:', error)
- }
- }
- // 打开工单人选择对话框(用于表单)
- const openSubmitterDialogForForm = async () => {
- if (!currentTask.value.deptIds || currentTask.value.deptIds.length === 0) {
- ElMessage.warning('请先选择施工队伍')
- return
- }
- selectedSubmitterIds.value = [...(currentTask.value.submitter || [])]
- try {
- const params = {
- deptIds: currentTask.value.deptIds // 使用当前项目所属部门的deptId
- }
- const response = await UserApi.selectedDeptsEmployee(params)
- submitterList.value = response
- submitterDialogVisible.value = true
- } catch (error) {
- ElMessage.error('获取填报人列表失败')
- console.error('获取填报人列表失败:', error)
- }
- }
- // 获取动态属性
- const fetchDynamicAttrs = async () => {
- // 如果已经通过任务数据获取了动态属性,则不再调用接口
- if (hasDynamicAttrsFromTask.value) {
- return
- }
- if (!formData.value.deptId) {
- console.warn('部门ID为空,无法获取动态属性')
- return
- }
- try {
- const queryParams = {
- deptId: formData.value.deptId
- }
- const response = await IotProjectTaskAttrsApi.getIotProjectTaskAttrsList(queryParams)
- dynamicAttrs.value = response || []
- // 初始化动态属性到当前任务
- initDynamicAttrsToCurrentTask()
- } catch (error) {
- console.error('获取动态属性失败:', error)
- ElMessage.error('获取动态属性失败')
- }
- }
- // 打开设备选择对话框(用于表单)
- const openDeviceDialogForForm = async () => {
- if (!currentTask.value.deptIds || currentTask.value.deptIds.length === 0) {
- ElMessage.warning('请先选择施工队伍')
- return
- }
- selectedDeviceIds.value = [...(currentTask.value.deviceIds || [])]
- try {
- const params = {
- deptIds: currentTask.value.deptIds
- }
- const data = await IotDeviceApi.getDevicesByDepts(params)
- // 更新 hasDevicesAvailable 状态
- hasDevicesAvailable.value = data && data.length > 0
- // 更新设备映射表
- const newDeviceMap = { ...deviceMap.value }
- data.forEach((device) => {
- newDeviceMap[device.id] = device
- })
- deviceMap.value = newDeviceMap
- filteredDeviceList.value = data
- deviceDialogVisible.value = true
- // 如果没有设备可用,显示提示信息
- if (!hasDevicesAvailable.value) {
- ElMessage.info('当前施工队伍下没有可用设备,设备字段为非必填项')
- }
- } catch (error) {
- ElMessage.error('获取设备列表失败')
- console.error('获取设备列表失败:', error)
- // 如果获取失败,也设为非必填,避免用户无法提交
- hasDevicesAvailable.value = false
- }
- }
- // 打开工作量维护对话框
- const openWorkloadDialog = () => {
- currentPlatformWellIndex.value = -1 // 设置为-1表示普通井模式
- // 前置校验:设计工作量不合法则直接返回
- if (!validateWorkloadDesign()) {
- ElMessage.error(workloadDesignError.value)
- return
- }
- // 重置列表
- workloadList.value = []
- hasInitialWorkload.value = false
- // 获取当前操作的井号(兼容普通井/平台井)
- let currentWellName = ''
- if (currentTask.value.platformWell === '1') {
- // 平台井:取主井号(优先当前任务wellName,其次取平台井详情第一个)
- currentWellName =
- currentTask.value.wellName ||
- (currentTask.value.platformWellDetails.length > 0
- ? currentTask.value.platformWellDetails[0].wellName
- : '')
- } else {
- // 普通井:直接取当前任务井号
- currentWellName = currentTask.value.wellName
- }
- if (!currentWellName) {
- ElMessage.warning('请先填写井号')
- return
- }
- // 从Map中回显当前井号的工作量数据
- if (workloadMap.value.has(currentWellName)) {
- // 深拷贝避免原数据被修改
- workloadList.value = JSON.parse(JSON.stringify(workloadMap.value.get(currentWellName)))
- hasInitialWorkload.value = workloadList.value.length > 0
- } else {
- // 无历史数据时,沿用原有逻辑(取表单已有值初始化首行)
- if (currentTask.value.workloadUnit && currentTask.value.workloadDesign) {
- workloadList.value.push({
- workloadUnit: currentTask.value.workloadUnit,
- workloadDesign: currentTask.value.workloadDesign
- })
- hasInitialWorkload.value = true
- }
- }
- workloadDialogVisible.value = true
- }
- // 添加工作量项
- const addWorkloadItem = () => {
- workloadList.value.push({
- workloadUnit: '',
- workloadDesign: ''
- })
- }
- // 删除工作量项
- const removeWorkloadItem = (index: number) => {
- workloadList.value.splice(index, 1)
- }
- // 确认工作量选择
- const confirmWorkloadSelection = () => {
- // 验证工作量对话框中的所有数据
- let allValid = true
- workloadList.value.forEach((item, index) => {
- if (!validateWorkloadDialogDesign(index)) {
- allValid = false
- }
- })
- if (!allValid) {
- ElMessage.error('请完善所有工作量信息')
- return
- }
- // 验证工作量单位唯一性
- const unitList = workloadList.value.map((item) => item.workloadUnit).filter(Boolean)
- const uniqueUnits = new Set(unitList)
- if (unitList.length !== uniqueUnits.size) {
- ElMessage.error('工作量单位不能重复,请选择不同的单位')
- return
- }
- // 获取当前井号并存储到Map
- let currentWellName = ''
- if (currentPlatformWellIndex.value >= 0) {
- // 平台井模式
- const wellDetail = currentTask.value.platformWellDetails[currentPlatformWellIndex.value]
- currentWellName = wellDetail.wellName
- // 同步更新平台井表格中的工作量单位
- if (workloadList.value.length > 0) {
- const firstItem = workloadList.value[0]
- if (wellDetail.workloadUnit !== firstItem.workloadUnit) {
- wellDetail.workloadUnit = firstItem.workloadUnit
- }
- wellDetail.workloadDesign = firstItem.workloadDesign
- }
- } else {
- // 普通井模式
- currentWellName = currentTask.value.wellName
- // 同步更新表单中的工作量单位
- if (workloadList.value.length > 0) {
- const firstItem = workloadList.value[0]
- if (currentTask.value.workloadUnit !== firstItem.workloadUnit) {
- currentTask.value.workloadUnit = firstItem.workloadUnit
- }
- currentTask.value.workloadDesign = firstItem.workloadDesign
- }
- }
- // 存储到Map
- if (currentWellName) {
- workloadMap.value.set(currentWellName, JSON.parse(JSON.stringify(workloadList.value)))
- }
- workloadDialogVisible.value = false
- currentPlatformWellIndex.value = -1 // 重置索引
- ElMessage.success('工作量信息已更新')
- }
- // 处理穿梭框变化
- const handleTransferChange = (value, direction, movedKeys) => {
- // 可以添加额外的处理逻辑
- }
- // 确认设备选择(用于表单)
- const confirmDeviceSelection = () => {
- currentTask.value.deviceIds = [...selectedDeviceIds.value]
- // 强制更新视图
- currentTask.value = { ...currentTask.value }
- deviceDialogVisible.value = false
- }
- // 确认责任人选择(用于表单)
- const confirmResponsiblePersonSelection = () => {
- currentTask.value.responsiblePerson = [...selectedResponsiblePersonIds.value]
- responsiblePersonDialogVisible.value = false
- // 立即触发责任人字段验证
- nextTick(() => {
- taskFormRef.value.validateField('responsiblePerson')
- })
- }
- // 确认填报人选择(用于表单)
- const confirmSubmitterSelection = () => {
- currentTask.value.submitter = [...selectedSubmitterIds.value]
- submitterDialogVisible.value = false
- // 立即触发填报人字段验证
- nextTick(() => {
- taskFormRef.value.validateField('submitter')
- })
- }
- // 关闭设备选择对话框
- const handleDeviceDialogClose = () => {
- deviceDialogVisible.value = false
- }
- // 关闭责任人选择对话框
- const handleResponsiblePersonDialogClose = () => {
- responsiblePersonDialogVisible.value = false
- }
- // 关闭填报人选择对话框
- const handleSubmitterDialogClose = () => {
- submitterDialogVisible.value = false
- }
- // 获取井型标签的方法
- const getWellTypeLabel = (value) => {
- const options = getStrDictOptions(DICT_TYPE.PMS_PROJECT_WELL_TYPE)
- const option = options.find((opt) => opt.value === value)
- return option ? option.label : value
- }
- // 获取井别标签的方法
- const getWellCategoryLabel = (value) => {
- const options = getStrDictOptions(DICT_TYPE.PMS_PROJECT_WELL_CATEGORY)
- const option = options.find((opt) => opt.value === value)
- return option ? option.label : value
- }
- // 获取施工工艺标签的方法
- const getTechniqueLabel = (value) => {
- const options = getStrDictOptions(DICT_TYPE.PMS_PROJECT_TECHNOLOGY)
- const option = options.find((opt) => opt.value === value)
- return option ? option.label : value
- }
- // 获取 工作量单位 标签的方法
- const getWorkloadUnitLabel = (value) => {
- const options = getStrDictOptions(DICT_TYPE.PMS_PROJECT_WORKLOAD_UNIT)
- const option = options.find((opt) => opt.value === value)
- return option ? option.label : value
- }
- // 打开平台井工作量对话框
- const openPlatformWellWorkloadDialog = (index) => {
- currentPlatformWellIndex.value = index
- const wellDetail = currentTask.value.platformWellDetails[index]
- // 前置校验
- if (!validatePlatformWellWorkloadDesign(index)) {
- ElMessage.error(wellDetail.workloadDesignError)
- return
- }
- // 重置列表
- workloadList.value = []
- hasInitialWorkload.value = false
- if (!wellDetail.wellName) {
- ElMessage.warning('请先填写井号')
- return
- }
- // 从Map中回显工作量数据
- if (workloadMap.value.has(wellDetail.wellName)) {
- workloadList.value = JSON.parse(JSON.stringify(workloadMap.value.get(wellDetail.wellName)))
- hasInitialWorkload.value = workloadList.value.length > 0
- } else {
- // 无历史数据时,使用当前行的值初始化
- if (wellDetail.workloadUnit && wellDetail.workloadDesign) {
- workloadList.value.push({
- workloadUnit: wellDetail.workloadUnit,
- workloadDesign: wellDetail.workloadDesign
- })
- hasInitialWorkload.value = true
- }
- }
- workloadDialogVisible.value = true
- }
- // 校验平台井设计工作量
- const validatePlatformWellWorkloadDesign = (index) => {
- const wellDetail = currentTask.value.platformWellDetails[index]
- wellDetail.workloadDesignError = ''
- const value = wellDetail.workloadDesign
- if (value === '' || value === null || value === undefined) {
- wellDetail.workloadDesignError = '设计工作量不能为空'
- return false
- }
- const numValue = Number(value)
- if (isNaN(numValue) || numValue < 0) {
- wellDetail.workloadDesignError = '请填写大于0的数字'
- return false
- }
- return true
- }
- /** 同步当前任务表单数据到表格数据 */
- const syncCurrentTaskToTable = () => {
- // 平台井模式特殊处理
- if (currentTask.value.platformWell === '1') {
- if (currentTask.value.platformWellDetails.length === 0) {
- ElMessage.warning('请先添加平台井详情')
- return false
- }
- // 验证平台井详情数据
- const invalidDetails = currentTask.value.platformWellDetails.some(
- (detail) => !detail.wellName || !detail.wellName.trim() || !detail.workloadDesign
- )
- if (invalidDetails) {
- ElMessage.error('请完善平台井的井号和设计工作量信息')
- return false
- }
- // 平台井模式:为每个平台井详情生成任务对象
- const platformTasks = []
- // 查找当前编辑的主任务对应的平台井详情
- let mainTaskDetailIndex = -1
- // 如果有当前任务ID,查找对应的平台井详情
- if (currentTask.value.id) {
- mainTaskDetailIndex = currentTask.value.platformWellDetails.findIndex(
- (detail) => detail.taskId === currentTask.value.id
- )
- }
- // 如果没有找到对应的详情,使用第一个详情作为主任务
- if (mainTaskDetailIndex === -1 && currentTask.value.platformWellDetails.length > 0) {
- mainTaskDetailIndex = 0
- }
- // 处理每个平台井详情
- currentTask.value.platformWellDetails.forEach((detail, index) => {
- // 获取当前井号的工作量数据
- const workloadData = workloadMap.value.get(detail.wellName) || []
- if (index === mainTaskDetailIndex) {
- // 主任务:使用当前任务对象
- currentTask.value.wellName = detail.wellName
- currentTask.value.workloadDesign = detail.workloadDesign
- currentTask.value.workloadUnit = detail.workloadUnit
- // platformWell 保持为 '1' - 主平台井任务
- currentTask.value.platformWell = '1'
- platformTasks.push({ ...currentTask.value })
- } else {
- // 子任务:创建新的任务对象
- const newTask = {
- ...currentTask.value, // 拷贝所有属性
- id: detail.taskId || undefined, // 已有任务使用taskId,新增任务为undefined
- wellName: detail.wellName,
- workloadDesign: detail.workloadDesign,
- workloadUnit: detail.workloadUnit,
- platformWell: detail.taskId ? '2' : '2' // 子任务platformWell设为2
- }
- // 移除不需要的属性
- delete newTask.platformWellDetails
- platformTasks.push(newTask)
- }
- })
- // 设置项目ID
- platformTasks.forEach((task) => {
- task.projectId = formData.value.id
- })
- if (isNewTask.value) {
- // 新增任务 - 为所有任务生成ID
- let maxId =
- tableData.value.length > 0 ? Math.max(...tableData.value.map((item) => item.id)) : 0
- platformTasks.forEach((task) => {
- maxId += 1
- task.id = maxId
- tableData.value.unshift({ ...task })
- })
- isNewTask.value = false
- } else {
- // 更新现有任务 - 比较复杂,需要先删除原有任务再添加新任务
- // 这里简化处理:删除当前任务相关的所有平台井任务,然后重新添加
- const currentTaskId = currentTask.value.id
- tableData.value = tableData.value.filter((item) => item.id !== currentTaskId)
- platformTasks.forEach((task) => {
- tableData.value.unshift({ ...task })
- })
- }
- return true
- } else {
- // 非平台井模式,验证原有字段
- if (!currentTask.value.wellName) {
- ElMessage.warning('请先填写任务详情')
- return false
- }
- // 设置项目ID
- currentTask.value.projectId = formData.value.id
- if (isNewTask.value) {
- // 新增任务 - 生成唯一ID并添加到表格
- const newId =
- tableData.value.length > 0 ? Math.max(...tableData.value.map((item) => item.id)) + 1 : 1
- currentTask.value.id = newId
- tableData.value.unshift({ ...currentTask.value })
- isNewTask.value = false
- } else {
- // 更新现有任务
- const index = tableData.value.findIndex((item) => item.id === currentTask.value.id)
- if (index !== -1) {
- tableData.value.splice(index, 1, { ...currentTask.value })
- } else {
- // 如果没有找到,添加到表格(可能是意外情况)
- tableData.value.unshift({ ...currentTask.value })
- }
- }
- return true
- }
- }
- // 重置任务表单
- const resetTaskForm = () => {
- // 记录旧井号,用于清理Map
- const oldWellName = currentTask.value.wellName
- currentTask.value = {
- id: undefined,
- wellName: '',
- wellType: '',
- wellCategory: '',
- location: '',
- technique: '',
- workloadDesign: '',
- workloadUnit: '',
- deptIds: [],
- deviceIds: [],
- responsiblePerson: [],
- remark: '',
- projectId: formData.value.id,
- platformWell: '0', // 重置平台井状态
- platformWellDetails: [], // 清空平台井详情
- // 如果是特殊部门,初始化填报人字段
- ...(isSpecialDept.value ? { submitter: [] } : {})
- }
- // 清理当前井号对应的Map数据
- if (oldWellName) {
- if (workloadMap.value.has(oldWellName)) {
- workloadMap.value.delete(oldWellName)
- }
- if (workloadBackup.value.has(oldWellName)) {
- workloadBackup.value.delete(oldWellName)
- }
- }
- // 重新初始化动态属性
- initDynamicAttrsToCurrentTask()
- isNewTask.value = false
- taskFormRef.value?.resetFields()
- // 清除表单验证状态
- nextTick(() => {
- taskFormRef.value?.clearValidate()
- })
- }
- // 获取已选的工作量单位(排除当前行) ==========
- const getSelectedWorkloadUnits = (currentIndex) => {
- if (!workloadList.value || workloadList.value.length === 0) {
- return []
- }
- // 过滤当前行 + 空值,收集已选的单位
- return workloadList.value
- .filter((_, index) => index !== currentIndex)
- .map((item) => item.workloadUnit)
- .filter((unit) => unit && unit.trim() !== '')
- }
- // 处理行点击事件
- const handleRowClick = (row, index) => {
- if (row) {
- currentTask.value = { ...row }
- currentEditingIndex.value = index // 保存当前编辑的行索引
- isNewTask.value = false
- }
- }
- // 设备过滤方法
- const filterDeviceMethod = (query: string, item: IotDeviceVO) => {
- if (!query) return true
- const searchText = query.toLowerCase()
- const deviceCode = (item.deviceCode || '').toLowerCase()
- const deviceName = (item.deviceName || '').toLowerCase()
- // 同时匹配设备编码和设备名称
- return deviceCode.includes(searchText) || deviceName.includes(searchText)
- }
- // 根据责任人ID获取责任人名称
- const getResponsiblePersonNames = (responsiblePersonIds: number[]) => {
- if (!responsiblePersonIds || responsiblePersonIds.length === 0) return ''
- // 获取所有有效责任人名称
- const personNames = responsiblePersonIds
- .map((id) => {
- const person = responsiblePersonList.value.find((p) => p.id === id)
- return person ? person.nickname : ''
- })
- .filter((name) => name !== undefined && name !== '')
- if (personNames.length === 0) return ''
- // 如果责任人数量超过2个,显示前两个加省略号
- if (personNames.length > 2) {
- return `${personNames[0]}, ${personNames[1]}...`
- }
- // 责任人数量不超过2个,正常显示所有
- return personNames.join(', ')
- }
- // 获取所有责任人名称(用于tooltip提示)
- const getAllResponsiblePersonNames = (responsiblePersonIds: number[]) => {
- if (!responsiblePersonIds || responsiblePersonIds.length === 0) return '无责任人'
- const personNames = responsiblePersonIds
- .map((id) => {
- const person = responsiblePersonList.value.find((p) => p.id === id)
- return person ? person.nickname : '未知人员'
- })
- .filter((name) => name !== '未知人员')
- return personNames.join(', ') || '无有效责任人'
- }
- // 获取所有设备名称(用于tooltip提示)
- const getAllDeviceNames = (deviceIds: number[]) => {
- if (!deviceIds || deviceIds.length === 0) return '无设备'
- const deviceNames = deviceIds
- .map((id) => deviceMap.value[id]?.deviceCode || '未知设备')
- .filter((name) => name !== '未知设备')
- return deviceNames.join(', ') || '无有效设备'
- }
- const companyName = ref('')
- /** 打开弹窗 */
- const open = async () => {
- resetForm()
- resetTaskForm()
- hasDynamicAttrsFromTask.value = false // 重置标志
- // 修改时,设置数据
- if (id) {
- formType.value = 'update'
- formLoading.value = true
- try {
- queryParams.id = id
- const data = await IotProjectTaskApi.getIotProjectTaskPage(queryParams)
- tableData.value = data.list
- const company = await IotOpeationFillApi.getOrgName(tableData.value[0].deptId)
- companyName.value = company
- // 收集所有设备ID
- const allDeviceIds = new Set<number>()
- // 收集所有责任人ID
- const allResponsiblePersonIds = new Set<number>()
- // 收集所有填报人ID
- const allSubmitterIds = new Set<number>()
- data.list.forEach((item) => {
- if (item.deviceIds?.length) {
- item.deviceIds.forEach((id) => allDeviceIds.add(id))
- }
- if (item.responsiblePerson?.length) {
- item.responsiblePerson.forEach((id) => allResponsiblePersonIds.add(id))
- }
- if (item.submitter?.length) {
- item.submitter.forEach((id) => allSubmitterIds.add(id))
- }
- })
- // 批量获取设备信息
- if (allDeviceIds.size > 0) {
- const deviceIdsArray = Array.from(allDeviceIds)
- const devices = await IotDeviceApi.getDevicesByDepts({
- deviceIds: deviceIdsArray
- })
- // 更新设备列表和映射表
- deviceList.value = devices
- deviceMap.value = {}
- devices.forEach((device) => {
- deviceMap.value[device.id] = device
- })
- }
- // 批量获取责任人信息
- if (allResponsiblePersonIds.size > 0) {
- const personIdsArray = Array.from(allResponsiblePersonIds)
- const params = {
- userIds: personIdsArray
- }
- const persons = await UserApi.companyDeptsEmployee(params)
- // 更新责任人列表
- responsiblePersonList.value = persons
- }
- // 批量获取填报人信息
- if (allSubmitterIds.size > 0) {
- const personIdsArray = Array.from(allSubmitterIds)
- const params = {
- userIds: personIdsArray
- }
- const persons = await UserApi.companyDeptsEmployee(params)
- // 更新责任人列表
- submitterList.value = persons
- }
- if (tableData.value && tableData.value.length > 0) {
- // 使用深拷贝,避免修改表单时直接影响表格数据
- currentTask.value = JSON.parse(JSON.stringify(tableData.value[0]))
- isNewTask.value = false
- // 如果当前任务有施工队伍,立即查询设备并更新 hasDevicesAvailable
- if (currentTask.value.deptIds && currentTask.value.deptIds.length > 0) {
- try {
- const params = {
- deptIds: currentTask.value.deptIds
- }
- const deviceData = await IotDeviceApi.getDevicesByDepts(params)
- // 更新 hasDevicesAvailable 状态
- hasDevicesAvailable.value = deviceData && deviceData.length > 0
- // 更新设备列表和映射表(如果有设备)
- if (hasDevicesAvailable.value) {
- deviceList.value = deviceData
- deviceMap.value = {}
- deviceData.forEach((device) => {
- deviceMap.value[device.id] = device
- })
- }
- } catch (error) {
- console.error('初始化查询设备失败:', error)
- hasDevicesAvailable.value = false
- }
- } else {
- // 如果没有施工队伍,默认没有设备可用
- hasDevicesAvailable.value = false
- }
- // 处理平台井数据
- // 将数字类型的 platformWell 转换为字符串类型
- currentTask.value.platformWell = currentTask.value.platformWell?.toString() || '0'
- // 如果 platformWell 为 1,处理 platformWells 数据
- if (currentTask.value.platformWell === '1' && currentTask.value.platformWells) {
- // 将 platformWells 映射到 platformWellDetails
- currentTask.value.platformWellDetails = currentTask.value.platformWells.map(
- (item: any) => ({
- taskId: item.id,
- wellName: item.wellName,
- workloadUnit: item.workloadUnit || '', // 确保有workloadUnit字段
- workloadDesign: item.workloadDesign || '',
- workloadDesignError: '' // 新增错误信息字段
- })
- )
- // 使用专门的排序方法
- sortPlatformWellDetails()
- // 初始化备份数据
- platformWellDetailsBackup.value = [...currentTask.value.platformWellDetails]
- // 处理每个平台井的工作量数据
- processPlatformWellWorkloadData(currentTask.value.platformWells)
- } else {
- // 非平台井模式,确保 platformWellDetails 是数组
- currentTask.value.platformWellDetails = currentTask.value.platformWellDetails || []
- platformWellDetailsBackup.value = []
- // 处理非平台井的工作量数据
- if (currentTask.value.extProperty?.[0]?.dropdownList) {
- processWorkloadDataForWell(
- currentTask.value.wellName,
- currentTask.value.extProperty[0].dropdownList
- )
- }
- }
- // 检查任务数据中是否有extProperty
- if (tableData.value[0].extProperty && tableData.value[0].extProperty.length > 0) {
- // 使用任务数据中的extProperty作为动态属性
- dynamicAttrs.value = tableData.value[0].extProperty
- hasDynamicAttrsFromTask.value = true
- // 将extProperty中的值设置到当前任务
- tableData.value[0].extProperty.forEach((attr) => {
- if (attr.identifier) {
- // 优先使用actualValue,如果没有则使用defaultValue
- currentTask.value[attr.identifier] =
- attr.actualValue !== undefined &&
- attr.actualValue !== null &&
- attr.actualValue !== ''
- ? attr.actualValue
- : attr.defaultValue || ''
- }
- })
- }
- const attachments = tableData.value[0].attachments || []
- constructionFiles.value = attachments
- .filter((item) => item.type === 'CONSTRUCTION_DESIGN')
- .map((item) => ({
- name: item.filename,
- percentage: 100,
- response: { data: item },
- status: 'success',
- uid: item.createTime
- }))
- geologicalFiles.value = attachments
- .filter((item) => item.type === 'GEOLOGICAL_DESIGN')
- .map((item) => ({
- name: item.filename,
- percentage: 100,
- response: { data: item },
- status: 'success',
- uid: item.createTime
- }))
- completionFiles.value = attachments
- .filter((item) => item.type === 'COMPLETION_DESIGN')
- .map((item) => ({
- name: item.filename,
- percentage: 100,
- response: { data: item },
- status: 'success',
- uid: item.createTime
- }))
- }
- } finally {
- formLoading.value = false
- }
- } else {
- formType.value = 'create'
- // 初始化备份数据
- platformWellDetailsBackup.value = []
- }
- // 如果有projectId参数,自动选中对应的合同
- if (projectId.value) {
- autoSelectContract(projectId.value)
- }
- }
- defineExpose({ open }) // 提供 open 方法,用于打开弹窗
- // 获取平台井已选的工作量单位(排除当前行)
- const getPlatformWellWorkloadUnits = (currentIndex) => {
- if (
- !currentTask.value.platformWellDetails ||
- currentTask.value.platformWellDetails.length === 0
- ) {
- return []
- }
- // 获取当前井号的井名
- const currentWellName = currentTask.value.platformWellDetails[currentIndex]?.wellName
- if (!currentWellName) {
- return []
- }
- // 从workloadMap中获取当前井号的工作量列表
- const currentWellWorkloadList = workloadMap.value.get(currentWellName) || []
- return currentWellWorkloadList
- .filter((_, index) => index !== 0)
- .map((item) => item.workloadUnit)
- .filter((unit) => unit && unit.trim() !== '')
- }
- /** 自动选择合同 */
- const autoSelectContract = async (projectId: string) => {
- console.log('项目id:' + projectId)
- // 查找匹配的合同
- const project = projectList.value.find((item) => item.id === Number(projectId))
- if (project) {
- // 设置选中值
- formData.value.contractId = project.id
- // 触发合同信息加载
- getProjectInfo(project.id)
- } else {
- ElMessage.warning('未找到指定的合同信息')
- }
- }
- /** 校验所有行数据 */
- const validateAllRows = (): boolean => {
- // 判断任务列表是否为空
- if (!tableData.value || tableData.value.length === 0) {
- ElMessage.error('没有任务数据,无法保存')
- return false
- }
- let allValid = true
- tableData.value.forEach((row) => {
- if (!row.wellName || row.wellName.trim() === '') {
- allValid = false
- }
- // 对于平台井模式下的后续任务,platformWell为0,但wellName和workloadDesign仍需验证
- if (!row.workloadDesign) {
- allValid = false
- }
- if (!row.location || row.location.trim() === '') {
- allValid = false
- }
- if (!row.technique || row.technique.trim() === '') {
- allValid = false
- }
- if (!row.deptIds || row.deptIds.length === 0) {
- allValid = false
- }
- // 修改:只有当有设备可用时才验证设备字段
- if (hasDevicesAvailable.value && (!row.deviceIds || row.deviceIds.length === 0)) {
- allValid = false
- }
- if (!row.responsiblePerson || row.responsiblePerson.length === 0) {
- allValid = false
- }
- // 如果是特殊部门,验证填报人
- if (isSpecialDept.value && (!row.submitter || row.submitter.length === 0)) {
- allValid = false
- }
- })
- if (!allValid) {
- ElMessage.error('请检查表格中的数据,部分必填项未填写或格式不正确')
- }
- return allValid
- }
- // 添加表单专用的格式化方法
- // 格式化设备显示(用于表单)
- const formatDevicesForForm = (deviceIds: number[]) => {
- if (!deviceIds || deviceIds.length === 0) return ''
- const deviceInfos = deviceIds
- .map((id) => {
- const device = deviceMap.value[id]
- return device ? `${device.deviceCode}-${device.deviceName}` : ''
- })
- .filter((info) => info !== '')
- if (deviceInfos.length === 0) return ''
- if (deviceInfos.length > 2) {
- return `${deviceInfos[0]}, ${deviceInfos[1]}...`
- }
- return deviceInfos.join(', ')
- }
- // 获取所有设备名称(用于表单的tooltip)
- const getAllDeviceNamesForForm = (deviceIds: number[]) => {
- if (!deviceIds || deviceIds.length === 0) return '无设备'
- const deviceInfos = deviceIds
- .map((id) => {
- const device = deviceMap.value[id]
- return device ? `${device.deviceCode}-${device.deviceName}` : '未知设备'
- })
- .filter((info) => info !== '未知设备')
- return deviceInfos.join(', ') || '无有效设备'
- }
- // 格式化责任人显示(用于表单)
- const formatResponsiblePersonsForForm = (responsiblePersonIds: number[]) => {
- if (!responsiblePersonIds || responsiblePersonIds.length === 0) return ''
- const personNames = responsiblePersonIds
- .map((id) => {
- const person = responsiblePersonList.value.find((p) => p.id === id)
- return person ? person.nickname : ''
- })
- .filter((name) => name !== undefined && name !== '')
- if (personNames.length === 0) return ''
- if (personNames.length > 2) {
- return `${personNames[0]}, ${personNames[1]}...`
- }
- return personNames.join(', ')
- }
- // 获取任务的工作量dropdownList数据
- const getWorkloadDropdownListForTask = (task: any) => {
- const dropdownList = []
- // 从workloadMap中获取当前任务井号的工作量数据
- const workloadItems = workloadMap.value.get(task.wellName) || []
- if (workloadItems.length > 0) {
- // 如果workloadMap中有数据,使用workloadMap的数据
- workloadItems.forEach((item) => {
- if (item.workloadUnit && item.workloadDesign) {
- // 获取工作量单位的标签
- const unitOptions = getStrDictOptions(DICT_TYPE.PMS_PROJECT_WORKLOAD_UNIT)
- const unitLabel =
- unitOptions.find((opt) => opt.value === item.workloadUnit)?.label || item.workloadUnit
- dropdownList.push({
- name: unitLabel, // 工作量单位名称
- value: item.workloadDesign // 工作量值
- })
- }
- })
- } else {
- // 【新增】如果workloadMap中没有数据,使用任务本身的工作量数据(直接从表格行中填写的数据)
- if (task.workloadUnit && task.workloadDesign) {
- const unitOptions = getStrDictOptions(DICT_TYPE.PMS_PROJECT_WORKLOAD_UNIT)
- const unitLabel =
- unitOptions.find((opt) => opt.value === task.workloadUnit)?.label || task.workloadUnit
- dropdownList.push({
- name: unitLabel,
- value: task.workloadDesign
- })
- }
- }
- return dropdownList
- }
- // 平台井工作量加号按钮禁用状态
- const getPlatformWellWorkloadAddBtnDisabled = (index) => {
- const wellDetail = currentTask.value.platformWellDetails[index]
- return !wellDetail.workloadUnit || !!wellDetail.workloadDesignError
- }
- // 格式化填报人显示(用于表单)
- const formatSubmittersForForm = (submitterIds: number[]) => {
- if (!submitterIds || submitterIds.length === 0) return ''
- const personNames = submitterIds
- .map((id) => {
- const person = submitterList.value.find((p) => p.id === id)
- return person ? person.nickname : ''
- })
- .filter((name) => name !== undefined && name !== '')
- if (personNames.length === 0) return ''
- if (personNames.length > 2) {
- return `${personNames[0]}, ${personNames[1]}...`
- }
- return personNames.join(', ')
- }
- // 获取所有责任人名称(用于表单的tooltip)
- const getAllResponsiblePersonNamesForForm = (responsiblePersonIds: number[]) => {
- if (!responsiblePersonIds || responsiblePersonIds.length === 0) return '无责任人'
- const personNames = responsiblePersonIds
- .map((id) => {
- const person = responsiblePersonList.value.find((p) => p.id === id)
- return person ? person.nickname : '未知人员'
- })
- .filter((name) => name !== '未知人员')
- return personNames.join(', ') || '无有效责任人'
- }
- // 获取所有填报人名称(用于表单的tooltip)
- const getAllSubmitterNamesForForm = (submitterIds: number[]) => {
- if (!submitterIds || submitterIds.length === 0) return '无填报人'
- const personNames = submitterIds
- .map((id) => {
- const person = submitterList.value.find((p) => p.id === id)
- return person ? person.nickname : '未知人员'
- })
- .filter((name) => name !== '未知人员')
- return personNames.join(', ') || '无有效填报人'
- }
- /** 提交表单 */
- const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
- // 处理平台井工作量数据
- const processPlatformWellWorkloadData = (platformWells: any[]) => {
- if (!platformWells || !platformWells.length) return
- platformWells.forEach((well: any) => {
- if (well.wellName && well.extProperty?.[0]?.dropdownList) {
- processWorkloadDataForWell(well.wellName, well.extProperty[0].dropdownList)
- }
- })
- }
- // 处理单个井的工作量数据
- const processWorkloadDataForWell = (wellName: string, dropdownList: any[]) => {
- if (!wellName || !dropdownList || !dropdownList.length) return
- // 转换dropdownList格式为workloadMap需要的格式
- const workloadData = dropdownList.map((item) => ({
- workloadUnit: getWorkloadUnitValueByName(item.name), // 通过name获取对应的value
- workloadDesign: item.value
- }))
- // 存储到workloadMap
- workloadMap.value.set(wellName, workloadData)
- // 如果这个井在platformWellDetails中,更新其工作量单位和工作量设计
- if (currentTask.value.platformWellDetails) {
- const detailIndex = currentTask.value.platformWellDetails.findIndex(
- (detail: any) => detail.wellName === wellName
- )
- if (detailIndex !== -1 && workloadData.length > 0) {
- // 使用第一个工作量项作为平台井表格中显示的值
- currentTask.value.platformWellDetails[detailIndex].workloadUnit = workloadData[0].workloadUnit
- currentTask.value.platformWellDetails[detailIndex].workloadDesign =
- workloadData[0].workloadDesign
- }
- }
- // 如果是主任务井,也更新当前任务的工作量数据
- if (wellName === currentTask.value.wellName && workloadData.length > 0) {
- currentTask.value.workloadUnit = workloadData[0].workloadUnit
- currentTask.value.workloadDesign = workloadData[0].workloadDesign
- }
- }
- // 通过工作量单位名称获取对应的值
- const getWorkloadUnitValueByName = (name: string): string => {
- const options = getStrDictOptions(DICT_TYPE.PMS_PROJECT_WORKLOAD_UNIT)
- const option = options.find((opt) => opt.label === name)
- return option ? option.value : ''
- }
- const submitForm = async () => {
- // 施工区域的数据字典类型
- currentTask.value.dictType = currentDictLabel.value
- // 先校验设计工作量
- if (currentTask.value.platformWell !== '1' && !validateWorkloadDesign()) {
- ElMessage.error('请完善设计工作量信息')
- return
- }
- // 在同步任务前,确保平台井关联井的工作量数据正确设置
- if (currentTask.value.platformWell === '1') {
- currentTask.value.platformWellDetails.forEach((detail) => {
- // 如果该关联井在workloadMap中没有数据,但表格行中有工作量数据,则设置到workloadMap中
- if (
- detail.wellName &&
- !workloadMap.value.has(detail.wellName) &&
- detail.workloadUnit &&
- detail.workloadDesign
- ) {
- workloadMap.value.set(detail.wellName, [
- {
- workloadUnit: detail.workloadUnit,
- workloadDesign: detail.workloadDesign
- }
- ])
- }
- })
- }
- // 先同步当前任务表单数据到表格
- if (!syncCurrentTaskToTable()) {
- return
- }
- // 校验表单
- await formRef.value.validate()
- // 校验所有行数据
- if (!validateAllRows()) {
- return
- }
- const getFileType = (filename: string) => {
- const ext = filename.split('.').pop()?.toLowerCase()
- if (['jpg', 'jpeg', 'png', 'gif', 'bmp'].includes(ext || '')) {
- return 'image'
- } else if (['pdf'].includes(ext || '')) {
- return 'pdf'
- } else if (['doc', 'docx'].includes(ext || '')) {
- return 'word'
- } else if (['xls', 'xlsx'].includes(ext || '')) {
- return 'excel'
- } else {
- return 'other'
- }
- }
- const formatFileSize = (bytes: number) => {
- if (bytes === 0) return '0 Bytes'
- const k = 1024
- const sizes = ['Bytes', 'KB', 'MB', 'GB']
- const i = Math.floor(Math.log(bytes) / Math.log(k))
- return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
- }
- function formatterAttachments(attachments: any[], type: string, taskId: number) {
- return attachments.flatMap((item) => {
- if (item.response.data.files) {
- return item.response.data.files.map((file) => ({
- category: 'DAILY_REPORT',
- bizId: taskId,
- filename: file.name || '未知文件',
- fileType: getFileType(file.name),
- filePath: file.filePath,
- fileSize: formatFileSize(file.size || 0),
- remark: '',
- type
- }))
- } else return item.response.data
- })
- }
- // 处理动态属性数据
- const processedTableData = tableData.value.map((task) => {
- // 获取当前任务的工作量数据并转换为dropdownList格式
- const workloadDropdownList = getWorkloadDropdownListForTask(task)
- // 为每个任务构建extProperty数组
- const extProperties = dynamicAttrs.value.map((attr) => {
- return {
- name: attr.name,
- sort: attr.sort,
- unit: attr.unit,
- actualValue: task[attr.identifier] || '', // 从任务中获取用户填写的值
- dataType: attr.dataType,
- maxValue: attr.maxValue,
- minValue: attr.minValue,
- required: attr.required,
- accessMode: attr.accessMode,
- identifier: attr.identifier,
- defaultValue: attr.defaultValue,
- // 添加dropdownList到任务对象中
- dropdownList: workloadDropdownList
- }
- })
- // 返回处理后的任务数据,包含extProperty字段
- return {
- ...task,
- dictType: task.dictType || currentDictLabel.value, // 确保每个任务都有dictType
- extProperty: extProperties,
- attachments: formatterAttachments(constructionFiles.value, 'CONSTRUCTION_DESIGN', task.id)
- .concat(formatterAttachments(geologicalFiles.value, 'GEOLOGICAL_DESIGN', task.id))
- .concat(formatterAttachments(completionFiles.value, 'COMPLETION_REPORT', task.id))
- }
- })
- // 提交请求
- formLoading.value = true
- try {
- tableData.value.forEach((item) => {
- item.projectId = formData.value.id
- })
- const data = {
- taskList: processedTableData
- }
- if (formType.value === 'create') {
- await IotProjectTaskApi.createIotProjectTask(data)
- message.success(t('common.createSuccess'))
- } else {
- await IotProjectTaskApi.updateIotProjectTask(data)
- message.success(t('common.updateSuccess'))
- }
- // 发送操作成功的事件
- emit('success')
- close()
- } finally {
- formLoading.value = false
- }
- }
- // 判断是否为主要的平台井详情(不能删除)
- const isMainPlatformWellDetail = (index: number) => {
- if (
- !currentTask.value.platformWellDetails ||
- currentTask.value.platformWellDetails.length === 0
- ) {
- return false
- }
- const detail = currentTask.value.platformWellDetails[index]
- // 主记录的条件:是第一条记录且有关联的任务ID,或者是自动从非平台井转换过来的主记录
- return (
- index === 0 &&
- (detail.taskId === currentTask.value.id ||
- (detail.wellName === currentTask.value.wellName &&
- detail.workloadDesign === currentTask.value.workloadDesign))
- )
- }
- // 处理平台井开关变化
- const handlePlatformWellChange = (value) => {
- if (value === '1') {
- // 切换到平台井模式前,备份当前井号的工作量数据
- if (currentTask.value.wellName) {
- const currentWorkload = workloadMap.value.get(currentTask.value.wellName)
- if (currentWorkload) {
- workloadBackup.value.set(currentTask.value.wellName, [...currentWorkload])
- }
- }
- // 检查是否是从非平台井切换过来,且当前任务有井号信息
- const hasWellName = currentTask.value.wellName && currentTask.value.wellName.trim() !== ''
- const hasWorkloadDesign = currentTask.value.workloadDesign
- if (hasWellName && hasWorkloadDesign) {
- // 从非平台井切换到平台井,自动添加一条记录
- const mainDetail = {
- taskId: currentTask.value.id, // 关联当前任务ID
- wellName: currentTask.value.wellName,
- workloadUnit: currentTask.value.workloadUnit, // 同步工作量单位
- workloadDesign: currentTask.value.workloadDesign,
- workloadDesignError: ''
- }
- // 如果workloadMap中有主井数据,同步到平台井表格
- if (workloadMap.value.has(currentTask.value.wellName)) {
- const workloadData = workloadMap.value.get(currentTask.value.wellName)
- if (workloadData && workloadData.length > 0) {
- mainDetail.workloadUnit = workloadData[0].workloadUnit
- mainDetail.workloadDesign = workloadData[0].workloadDesign
- }
- }
- // 清空现有详情,添加主记录
- currentTask.value.platformWellDetails = [mainDetail]
- } else {
- // 恢复之前保存的数据或初始化
- if (platformWellDetailsBackup.value.length > 0) {
- currentTask.value.platformWellDetails = [...platformWellDetailsBackup.value]
- sortPlatformWellDetails()
- } else {
- addPlatformWellDetail()
- }
- }
- // 更新备份数据
- platformWellDetailsBackup.value = [...currentTask.value.platformWellDetails]
- } else {
- // 如果有平台井详情,将第一个详情的数据设置回主任务
- if (currentTask.value.platformWellDetails.length > 0) {
- const mainDetail = currentTask.value.platformWellDetails[0]
- currentTask.value.wellName = mainDetail.wellName || ''
- currentTask.value.workloadDesign = mainDetail.workloadDesign || ''
- // 恢复工作量数据
- if (mainDetail.wellName && workloadBackup.value.has(mainDetail.wellName)) {
- const backupWorkload = workloadBackup.value.get(mainDetail.wellName)
- if (backupWorkload && backupWorkload.length > 0) {
- workloadMap.value.set(mainDetail.wellName, [...backupWorkload])
- // 恢复表单中的工作量单位(取第一项)
- currentTask.value.workloadUnit = backupWorkload[0].workloadUnit
- currentTask.value.workloadDesign = backupWorkload[0].workloadDesign
- }
- }
- }
- // 切换到非平台井模式,保存当前数据到备份
- platformWellDetailsBackup.value = [...currentTask.value.platformWellDetails]
- // 切换到非平台井模式,清空详情列表
- currentTask.value.platformWellDetails = []
- }
- }
- // 校验工作量对话框中的设计工作量
- const validateWorkloadDialogDesign = (index) => {
- const workloadItem = workloadList.value[index]
- workloadItem.workloadDesignError = ''
- const value = workloadItem.workloadDesign
- if (value === '' || value === null || value === undefined) {
- workloadItem.workloadDesignError = '设计工作量不能为空'
- return false
- }
- const numValue = Number(value)
- if (isNaN(numValue) || numValue < 0) {
- workloadItem.workloadDesignError = '请填写大于0的数字'
- return false
- }
- return true
- }
- // 获取表单中已选的工作量单位(来自workloadMap)
- const getFormSelectedWorkloadUnits = () => {
- // 兼容普通井/平台井的井号获取逻辑(与工作量弹窗逻辑一致)
- let currentWellName = ''
- if (currentTask.value.platformWell === '1') {
- // 平台井:取主井号(优先当前任务wellName,其次取平台井详情第一个)
- currentWellName =
- currentTask.value.wellName ||
- (currentTask.value.platformWellDetails.length > 0
- ? currentTask.value.platformWellDetails[0].wellName
- : '')
- } else {
- // 普通井:直接取当前任务井号
- currentWellName = currentTask.value.wellName
- }
- // 从Map中获取当前井号的工作量列表,提取已选单位
- const workloadList = workloadMap.value.get(currentWellName) || []
- return workloadList.map((item) => item.workloadUnit).filter((unit) => unit && unit.trim() !== '') // 过滤空值
- }
- // 添加平台井详情行
- const addPlatformWellDetail = () => {
- const newDetail = {
- taskId: '',
- wellName: '',
- workloadUnit: '', // 新增工作量单位字段
- workloadDesign: '',
- workloadDesignError: '' // 新增错误信息字段
- }
- // 将新记录添加到数组末尾,而不是开头
- currentTask.value.platformWellDetails.push(newDetail)
- }
- // 删除平台井详情行
- const removePlatformWellDetail = (index: number) => {
- // 获取被删除的井号,清理Map
- const removedDetail = currentTask.value.platformWellDetails[index]
- if (removedDetail.wellName && workloadMap.value.has(removedDetail.wellName)) {
- workloadMap.value.delete(removedDetail.wellName)
- }
- currentTask.value.platformWellDetails.splice(index, 1)
- // 删除后重新排序
- sortPlatformWellDetails()
- }
- // 平台井详情排序方法
- const sortPlatformWellDetails = () => {
- if (
- !currentTask.value.platformWellDetails ||
- currentTask.value.platformWellDetails.length === 0
- ) {
- return
- }
- currentTask.value.platformWellDetails.sort((a, b) => {
- // 主记录(关联当前任务ID或从非平台井转换过来的记录)排在最前面
- const aIsMain = a.taskId === currentTask.value.id
- const bIsMain = b.taskId === currentTask.value.id
- if (aIsMain && !bIsMain) return -1
- if (!aIsMain && bIsMain) return 1
- // 其他记录保持原有顺序
- return 0
- })
- }
- /** 重置表单 */
- const resetForm = () => {
- formData.value = {
- id: undefined,
- contractId: undefined,
- contractName: undefined,
- contractCode: undefined,
- workloadTotal: undefined,
- workloadFinish: undefined,
- workloadUnit: undefined,
- startTime: undefined,
- endTime: undefined,
- location: undefined,
- technique: undefined,
- payment: undefined,
- remark: undefined,
- manufactureName: undefined,
- manufacturerId: undefined,
- userName: undefined,
- userId: undefined
- }
- formRef.value?.resetFields()
- }
- // 加载工作区域选项的方法
- const loadWorkAreaOptions = async (deptId: number) => {
- // 如果正在加载,直接返回
- if (loadingWorkAreaOptions.value) return
- loadingWorkAreaOptions.value = true
- try {
- // 先尝试通过 getDictLabel 获取字典标签
- const dictLabel = await getDictLabel(DICT_TYPE.PMS_PROJECT_WORK_AREA, deptId)
- console.log('当前专业公司的施工区域数据字典类型:' + dictLabel)
- // 将 dictLabel 存储到 currentDictLabel
- currentDictLabel.value = dictLabel || '' // 如果没有获取到,设为空字符串
- if (dictLabel) {
- // 如果获取到标签,再获取完整的字典选项
- const dictOptions = getStrDictOptions(dictLabel)
- console.log('当前专业公司的施工区域数据字典集合长度:' + dictOptions.length)
- workAreaOptions.value = dictOptions.map((option) => ({
- value: option.label, // 使用标签作为显示值
- id: option.value // 保留原始值
- }))
- } else {
- // 如果获取不到标签,清空选项
- workAreaOptions.value = []
- }
- } catch (error) {
- console.error('获取工作区域选项失败:', error)
- workAreaOptions.value = []
- } finally {
- loadingWorkAreaOptions.value = false
- }
- }
- // 当没有查询字符串时返回所有选项
- const querySearch = (queryString: string, cb: any) => {
- // 如果没有查询字符串,返回所有选项
- if (!queryString) {
- cb(workAreaOptions.value)
- return
- }
- // 有查询字符串时进行筛选
- const results = workAreaOptions.value.filter((option) =>
- option.value.toLowerCase().includes(queryString.toLowerCase())
- )
- // 调用 callback 返回建议列表的数据
- cb(results)
- }
- // 添加处理施工区域获取焦点的方法
- const handleWorkAreaFocus = async () => {
- // 如果已经有选项数据,直接显示下拉框
- if (workAreaOptions.value.length > 0) {
- // 使用Element Plus提供的方法触发下拉框
- try {
- // 直接调用el-autocomplete的focus方法
- if (workAreaAutocomplete.value && typeof workAreaAutocomplete.value.focus === 'function') {
- workAreaAutocomplete.value.focus()
- }
- } catch (error) {
- console.error('触发下拉框显示失败:', error)
- }
- return
- }
- // 如果没有选项数据,尝试加载
- if (formData.value.deptId && !loadingWorkAreaOptions.value) {
- await loadWorkAreaOptions(formData.value.deptId)
- // 加载完成后尝试显示下拉框
- if (workAreaOptions.value.length > 0) {
- try {
- if (workAreaAutocomplete.value && typeof workAreaAutocomplete.value.focus === 'function') {
- workAreaAutocomplete.value.focus()
- }
- } catch (error) {
- console.error('触发下拉框显示失败:', error)
- }
- }
- }
- }
- // 添加选择处理方法
- const handleSelect = (item: any) => {
- // 这里可以根据需要处理选择后的逻辑
- console.log('选择了:', item.value)
- }
- // 加载施工工艺选项的方法
- const loadTechnologyOptions = async (deptId: number) => {
- if (loadingTechnologyOptions.value) return
- loadingTechnologyOptions.value = true
- try {
- // 先尝试通过 getDictLabel 获取字典标签
- const dictLabel = await getDictLabel(DICT_TYPE.PMS_PROJECT_TECHNOLOGY, deptId)
- console.log('当前专业公司的施工工艺数据字典类型:' + dictLabel)
- // 将 dictLabel 存储到 currentTechnologyDictLabel
- currentTechnologyDictLabel.value = dictLabel || '' // 如果没有获取到,设为空字符串
- if (dictLabel) {
- // 如果获取到标签,再获取完整的字典选项
- const dictOptions = getStrDictOptions(dictLabel)
- console.log('当前专业公司的施工工艺数据字典集合长度:' + dictOptions.length)
- technologyOptions.value = dictOptions.map((option) => ({
- value: option.value,
- label: option.label
- }))
- } else {
- // 如果获取不到标签,清空选项
- technologyOptions.value = []
- }
- } catch (error) {
- console.error('获取施工工艺选项失败:', error)
- technologyOptions.value = []
- } finally {
- loadingTechnologyOptions.value = false
- }
- }
- // 工作量加号按钮禁用状态(计算属性)
- const getWorkloadAddBtnDisabled = computed(() => {
- // 禁用条件:无工作量单位 || 平台井模式 || 设计工作量校验失败
- return (
- !currentTask.value.workloadUnit ||
- currentTask.value.platformWell === '1' ||
- !!workloadDesignError.value
- )
- })
- // 监听平台井状态变化,清空错误信息
- watch(
- () => currentTask.value.platformWell,
- () => {
- workloadDesignError.value = ''
- }
- )
- // 监听工作量单位变化,同步更新到 workloadMap
- watch(
- () => currentTask.value.workloadUnit,
- (newWorkloadUnit, oldWorkloadUnit) => {
- if (!newWorkloadUnit || newWorkloadUnit === oldWorkloadUnit) return
- // 获取当前井号(兼容普通井/平台井)
- let currentWellName = ''
- if (currentTask.value.platformWell === '1') {
- currentWellName =
- currentTask.value.wellName ||
- (currentTask.value.platformWellDetails.length > 0
- ? currentTask.value.platformWellDetails[0].wellName
- : '')
- } else {
- currentWellName = currentTask.value.wellName
- }
- if (!currentWellName) return
- // 如果workloadMap中存在当前井号的工作量数据,更新第一项的workloadUnit
- if (workloadMap.value.has(currentWellName)) {
- const workloadList = workloadMap.value.get(currentWellName)
- if (workloadList && workloadList.length > 0) {
- // 更新第一项的workloadUnit
- workloadList[0].workloadUnit = newWorkloadUnit
- // 重新设置到Map中(虽然引用相同,但为了确保响应性)
- workloadMap.value.set(currentWellName, [...workloadList])
- } else {
- // 如果列表为空但有设计工作量,创建新项
- if (currentTask.value.workloadDesign) {
- workloadMap.value.set(currentWellName, [
- {
- workloadUnit: newWorkloadUnit,
- workloadDesign: currentTask.value.workloadDesign
- }
- ])
- }
- }
- } else if (currentTask.value.workloadDesign) {
- // 如果Map中不存在但有设计工作量,创建新条目
- workloadMap.value.set(currentWellName, [
- {
- workloadUnit: newWorkloadUnit,
- workloadDesign: currentTask.value.workloadDesign
- }
- ])
- }
- },
- { deep: true }
- )
- // 校验设计工作量
- const validateWorkloadDesign = () => {
- workloadDesignError.value = ''
- if (currentTask.value.platformWell === '1') {
- return true
- }
- const value = currentTask.value.workloadDesign
- if (value === '' || value === null || value === undefined) {
- workloadDesignError.value = '设计工作量不能为空'
- return false
- }
- const numValue = Number(value)
- if (isNaN(numValue) || numValue < 0) {
- workloadDesignError.value = '请填写大于0的数字'
- return false
- }
- return true
- }
- // 监听设计工作量变化
- watch(
- () => currentTask.value.workloadDesign,
- () => {
- if (workloadDesignError.value) {
- validateWorkloadDesign()
- }
- }
- )
- // 监听当前任务的变化,设置默认展开的keys
- watch(
- () => currentTask.value.deptIds,
- (newVal, oldVal) => {
- if (newVal && newVal.length > 0) {
- defaultExpandedKeys.value = [...newVal]
- }
- // 【新增】施工队伍变化时,重新查询设备并更新状态
- const params = {
- deptIds: newVal
- }
- /* IotDeviceApi.getDevicesByDepts(params).then(data => {
- // 更新 hasDevicesAvailable 状态
- hasDevicesAvailable.value = data && data.length > 0;
- // 更新设备列表和映射表
- if (hasDevicesAvailable.value) {
- const newDeviceMap = {...deviceMap.value};
- data.forEach(device => {
- newDeviceMap[device.id] = device;
- });
- deviceMap.value = newDeviceMap;
- }
- }).catch(error => {
- console.error('施工队伍变化时查询设备失败:', error);
- hasDevicesAvailable.value = false;
- }); */
- if (!newVal || newVal.length === 0) {
- // 清空施工队伍时,同时清空相关人员和设备
- currentTask.value.responsiblePerson = []
- currentTask.value.submitter = []
- currentTask.value.deviceIds = []
- // 重置设备可用状态
- hasDevicesAvailable.value = true
- // 清除相关字段的验证状态
- nextTick(() => {
- taskFormRef.value?.validateField('responsiblePerson')
- taskFormRef.value?.validateField('submitter')
- taskFormRef.value?.validateField('deviceIds')
- })
- } else if (newVal !== oldVal) {
- // 施工队伍发生变化时,重置设备可用状态(因为不同队伍可能有不同的设备)
- // hasDevicesAvailable.value = true;
- }
- },
- { immediate: true, deep: true }
- )
- // 监听部门列表加载完成
- watch(
- () => deptList.value,
- (newVal) => {
- if (
- newVal &&
- newVal.length > 0 &&
- currentTask.value.deptIds &&
- currentTask.value.deptIds.length > 0
- ) {
- // defaultExpandedKeys.value = [...currentTask.value.deptIds];
- // 过滤掉非叶子节点的ID,只保留叶子节点
- const leafNodeIds = currentTask.value.deptIds.filter((id) => {
- const node = findDeptNodeById(newVal, id)
- return node && node.type === '3'
- })
- if (leafNodeIds.length > 0) {
- defaultExpandedKeys.value = [...leafNodeIds]
- }
- }
- },
- { immediate: true, deep: true }
- )
- // 根据ID在部门树中查找节点
- const findDeptNodeById = (tree: any[], id: number): any => {
- for (const node of tree) {
- if (node.id === id) {
- return node
- }
- if (node.children && node.children.length > 0) {
- const found = findDeptNodeById(node.children, id)
- if (found) return found
- }
- }
- return null
- }
- // 监听项目列表变化,确保列表加载完成后才执行自动选择
- watch(projectList, (newVal) => {
- if (newVal && newVal.length > 0) {
- // 如果是编辑模式,使用任务数据中的合同ID
- if (id && tableData.value.length > 0 && tableData.value[0].projectId) {
- autoSelectContract(tableData.value[0].projectId.toString())
- }
- // 如果是新增模式且有传递的projectId,使用传递的projectId
- else if (!id && projectId.value) {
- console.log('watch-新增模式且有传递的projectId' + projectId.value + ' projectId not found')
- autoSelectContract(projectId.value)
- }
- }
- })
- // 处理树形下拉框可见性变化
- const handleTreeVisibleChange = (visible: boolean) => {
- if (visible && currentTask.value.deptIds && currentTask.value.deptIds.length > 0) {
- // 当下拉框显示且当前任务有已选部门时,设置默认展开的keys
- defaultExpandedKeys.value = [...currentTask.value.deptIds]
- // 使用nextTick确保DOM更新后再执行展开操作
- nextTick(() => {
- if (treeSelectRef.value) {
- // 尝试访问内部树实例并展开节点
- const treeInstance = treeSelectRef.value.treeRef
- if (treeInstance && treeInstance.setExpandedKeys) {
- treeInstance.setExpandedKeys(defaultExpandedKeys.value)
- }
- }
- })
- }
- }
- onMounted(async () => {
- // 查询当前登录人所属公司下的所有部门
- deptList.value = handleTree(await DeptApi.companyLevelChildrenDepts())
- let deptId = useUserStore().getUser.deptId
- projectList.value = await IotProjectInfoApi.getIotProjectInfoUser(deptId)
- // 初始化时过滤当前任务中的部门ID,移除非叶子节点
- if (currentTask.value.deptIds && currentTask.value.deptIds.length > 0) {
- const validDeptIds = currentTask.value.deptIds.filter((id) => {
- const node = findDeptNodeById(deptList.value, id)
- return node && node.type === '3'
- })
- if (validDeptIds.length !== currentTask.value.deptIds.length) {
- currentTask.value.deptIds = validDeptIds
- }
- }
- // 查询当前任务已经选中的设备信息
- open()
- })
- </script>
- <style scoped>
- .edit-input {
- margin-right: 10px;
- }
- .error-message {
- margin-top: 5px;
- font-size: 12px;
- color: #f56c6c;
- }
- .action-cell {
- display: flex;
- gap: 8px;
- }
- /* 1. 穿梭框父容器:居中 + 内边距 */
- .transfer-container {
- padding: 0; /* 上下内边距,避免紧贴对话框边缘 */
- text-align: center;
- }
- /* 2. 穿梭框组件:控制宽度,避免过窄或过宽 */
- .transfer-component {
- width: 100%; /* 占对话框90%宽度,兼顾美观和内容显示 */
- min-width: 600px;
- }
- /* 3. 直接调整 el-transfer 左右窗口的宽度 */
- :deep(.el-transfer-panel) {
- width: 40% !important; /* 强制设置左右面板宽度,确保两侧面板对等 */
- }
- /* 3. 深度选择器:修改el-transfer选项样式(解决内容省略问题) */
- :deep(.el-transfer-panel__item) {
- /* white-space: nowrap; 文本不换行,保证一行显示 */
- /* overflow: hidden; 超出部分隐藏 */
- /* text-overflow: ellipsis; 超出显示省略号 */
- /* max-width: 100%; 确保文本不超出选项容器宽度 */
- /* padding: 6px 6px; 适当增加内边距,优化点击体验 */
- }
- :deep(.el-transfer-panel__item) {
- display: flex !important;
- height: 32px !important;
- padding: 0 8px !important;
- margin: 0 !important;
- overflow: hidden;
- line-height: 32px !important;
- text-overflow: ellipsis;
- white-space: nowrap;
- align-items: center !important;
- }
- /* 4. 选项文本:确保继承父容器宽度,省略号正常生效 */
- .transfer-option-text {
- display: inline-block;
- max-width: 100%;
- }
- /* 设备名称显示区域样式 */
- .device-names {
- max-width: 200px; /* 根据实际列宽调整 */
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- :deep(.el-transfer-panel__list) {
- width: 100% !important; /* 使面板内部内容宽度占满 */
- }
- /* 责任人名称显示区域样式 */
- .responsible-names {
- max-width: 200px; /* 根据实际列宽调整 */
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- /* 添加部门名称的样式 */
- .dept-names {
- display: inline-block;
- max-width: 200px; /* 根据实际列宽调整 */
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- vertical-align: bottom;
- }
- /* 部门选择器样式优化 */
- :deep(.department-tree-select .el-select__tags) {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- flex-wrap: nowrap;
- }
- :deep(.department-tree-select .el-select__tags .el-tag) {
- display: inline-block;
- max-width: 120px;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- :deep(.department-tree-select .el-select__tags .el-tag + .el-tag) {
- margin-left: 6px;
- }
- :deep(.department-tree-select .el-select__tags-text) {
- display: inline-block;
- max-width: 100px;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- /* 当有多个标签被折叠时显示的 "+N" 标签样式 */
- :deep(.department-tree-select .el-select__collapse-tags) {
- display: inline-block;
- white-space: nowrap;
- }
- .task-edit-form {
- padding: 20px;
- margin-bottom: 20px;
- background-color: #fafafa;
- border: 1px solid #ebeef5;
- border-radius: 4px;
- }
- /* 按钮文字样式 - 红色字体 */
- :deep(.workload-add-btn .btn-text) {
- font-size: 18px; /* 更大的字号 */
- font-weight: 900; /* 更粗的字体 */
- line-height: 1;
- color: #f00 !important;
- }
- /* 设计工作量加号按钮 - 启用状态(深蓝色) */
- :deep(.workload-add-btn .el-icon) {
- color: #f00 !important; /* Element Plus 主色调深蓝色,可替换为 #003366 等自定义深蓝色 */
- }
- /* 按钮禁用状态 */
- :deep(.workload-add-btn:disabled .btn-text) {
- color: #c0c4cc !important;
- }
- /* 调整按钮整体样式,确保icon居中 */
- :deep(.workload-add-btn) {
- display: flex;
- width: 100%;
- height: 100%;
- min-width: auto;
- padding: 0 8px;
- align-items: center;
- justify-content: center;
- }
- /* 调整输入框append部分的宽度 */
- :deep(.workload-input-with-button .el-input-group__append) {
- width: 45px; /* 稍微增加宽度以容纳文字 */
- padding: 0;
- }
- /* 确保按钮在禁用状态下有正确的样式 */
- :deep(.workload-add-btn:disabled) {
- cursor: not-allowed;
- background-color: #f5f7fa;
- border-color: #e4e7ed;
- }
- /* 设计工作量错误输入框样式 */
- :deep(.error-input .el-input__inner) {
- background-color: #fef0f0 !important;
- border-color: #f56c6c !important;
- box-shadow: 0 0 0 1px rgb(245 108 108 / 40%) !important;
- }
- :deep(.error-input .el-input__inner:hover) {
- background-color: #fef0f0 !important;
- border-color: #f56c6c !important;
- }
- :deep(.error-input .el-input__inner:focus) {
- background-color: #fef0f0 !important;
- border-color: #f56c6c !important;
- box-shadow: 0 0 0 1px rgb(245 108 108 / 20%) !important;
- }
- /* 设计工作量tooltip样式 */
- :deep(.workload-design-tooltip) {
- max-width: 300px;
- padding: 8px 12px;
- font-size: 12px;
- color: #f56c6c !important;
- background: #fef0f0 !important;
- border: 1px solid #fbc4c4 !important;
- }
- /* 隐藏 Tooltip 箭头 */
- :deep(.workload-design-tooltip .el-tooltip__arrow),
- :deep(.workload-design-tooltip .el-tooltip__arrow::before) {
- display: none !important;
- width: 0 !important;
- height: 0 !important;
- }
- </style>
|