IotProjectTaskForm.vue 119 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635
  1. <template>
  2. <div class="project-task-page">
  3. <ContentWrap class="page-header">
  4. <div class="page-header__main">
  5. <div class="page-header__icon">
  6. <Icon :icon="formType === 'create' ? 'ep:document-add' : 'ep:edit-pen'" />
  7. </div>
  8. <div>
  9. <h2 class="page-header__title">
  10. {{ formType === 'create' ? '新增项目任务' : '编辑项目任务' }}
  11. </h2>
  12. <p class="page-header__subtitle">{{ t('iotprojecttask.iotproject820427-0') }}</p>
  13. </div>
  14. </div>
  15. <el-button size="default" @click="close">
  16. <Icon icon="ep:arrow-left" class="mr-5px" />{{ t('iotprojecttask.iotproject820427-1') }}</el-button>
  17. </ContentWrap>
  18. <ContentWrap v-loading="formLoading" class="project-summary-section">
  19. <div class="section-heading">
  20. <div class="section-heading__title">{{ t('iotprojecttask.iotproject820427-2') }}</div>
  21. <span class="section-heading__hint">{{ t('iotprojecttask.iotproject820427-3') }}</span>
  22. </div>
  23. <el-form
  24. ref="formRef"
  25. :model="formData"
  26. :rules="formRules"
  27. label-width="100px"
  28. size="default"
  29. class="project-summary-form">
  30. <el-row :gutter="24">
  31. <el-col :span="12">
  32. <el-form-item :label="t('iotprojecttask.iotproject820427-4')" prop="contractName">
  33. <el-select
  34. v-model="formData.contractId"
  35. :placeholder="t('iotprojecttask.iotproject820427-5')"
  36. @change="getProjectInfo"
  37. disabled>
  38. <el-option
  39. v-for="item in projectList"
  40. :key="item.id"
  41. :label="item.contractName"
  42. :value="item.id"
  43. clearable />
  44. </el-select>
  45. </el-form-item>
  46. </el-col>
  47. <el-col :span="12">
  48. <el-form-item :label="t('iotprojecttask.iotproject820427-6')" prop="contractCode">
  49. <el-input v-model="formData.contractCode" :placeholder="t('iotprojecttask.iotproject820427-7')" disabled />
  50. </el-form-item>
  51. </el-col>
  52. </el-row>
  53. <el-row :gutter="24">
  54. <el-col :span="12">
  55. <el-form-item :label="t('iotprojecttask.iotproject820427-8')" prop="manufacturerId">
  56. <el-select
  57. clearable
  58. @clear="zzClear"
  59. v-model="formData.manufacturerId"
  60. :placeholder="t('deviceForm.mfgHolder')"
  61. disabled>
  62. <el-option :label="formData.manufactureName" :value="formData.manufacturerId" />
  63. </el-select>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="12">
  67. <el-form-item :label="t('project.payment')" prop="payment">
  68. <el-select v-model="formData.payment" :placeholder="t('iotprojecttask.iotproject820427-5')" disabled>
  69. <el-option
  70. v-for="dict in getStrDictOptions(DICT_TYPE.PMS_PROJECT_SETTLEMENT)"
  71. :key="dict.id"
  72. :label="dict.label"
  73. :value="dict.value" />
  74. </el-select>
  75. </el-form-item>
  76. </el-col>
  77. </el-row>
  78. <el-row :gutter="24">
  79. <el-col :span="12">
  80. <el-form-item :label="t('iotprojecttask.iotproject820427-9')" prop="startTime">
  81. <el-date-picker
  82. v-model="formData.startTime"
  83. type="date"
  84. value-format="x"
  85. :placeholder="t('iotprojecttask.iotproject820427-10')"
  86. disabled />
  87. </el-form-item>
  88. </el-col>
  89. <el-col :span="12">
  90. <el-form-item :label="t('iotprojecttask.iotproject820427-11')" prop="endTime">
  91. <el-date-picker
  92. v-model="formData.endTime"
  93. type="date"
  94. value-format="x"
  95. :placeholder="t('iotprojecttask.iotproject820427-12')"
  96. disabled />
  97. </el-form-item>
  98. </el-col>
  99. </el-row>
  100. <el-row :gutter="24">
  101. <el-col :span="12"
  102. ><el-form-item :label="t('iotprojecttask.iotproject820427-13')" prop="projectDeptId">
  103. <el-select
  104. v-model="formData.projectDeptId"
  105. :options="deptOptions"
  106. filterable
  107. :placeholder="t('iotprojecttask.iotproject820427-14')"
  108. clearable
  109. disabled /> </el-form-item
  110. ></el-col>
  111. <el-col :span="12"
  112. ><el-form-item :label="t('iotprojecttask.iotproject820427-15')" prop="remark">
  113. <el-input
  114. v-model="formData.remark"
  115. :placeholder="t('iotprojecttask.iotproject820427-16')"
  116. type="textarea"
  117. disabled />
  118. </el-form-item>
  119. </el-col>
  120. </el-row>
  121. </el-form>
  122. </ContentWrap>
  123. <ContentWrap v-if="false">
  124. <div class="content">
  125. <div class="toolbar">
  126. <div class="actions">
  127. <!-- 操作按钮已移动到表单区域 -->
  128. </div>
  129. </div>
  130. <div class="table-container">
  131. <el-table
  132. :data="tableData"
  133. empty-text="暂无数据"
  134. highlight-current-row
  135. @current-change="handleRowClick">
  136. <el-table-column prop="wellName" :label="t('iotprojecttask.iotproject820427-17')" />
  137. <el-table-column prop="wellType" :label="t('iotprojecttask.iotproject820427-18')">
  138. <template #default="{ row }">
  139. {{ getWellTypeLabel(row.wellType) }}
  140. </template>
  141. </el-table-column>
  142. <el-table-column prop="wellCategory" :label="t('iotprojecttask.iotproject820427-19')">
  143. <template #default="{ row }">
  144. {{ getWellCategoryLabel(row.wellCategory) }}
  145. </template>
  146. </el-table-column>
  147. <el-table-column prop="location" :label="t('iotprojecttask.iotproject820427-20')" />
  148. <el-table-column :label="t('project.technology')">
  149. <template #default="{ row }">
  150. {{ getTechniqueLabel(row.technique) }}
  151. </template>
  152. </el-table-column>
  153. <el-table-column prop="workloadDesign" :label="t('iotprojecttask.iotproject820427-21')" />
  154. <el-table-column :label="t('project.unit')">
  155. <template #default="{ row }">
  156. {{ getWorkloadUnitLabel(row.workloadUnit) }}
  157. </template>
  158. </el-table-column>
  159. <el-table-column prop="deptIds" :label="t('iotprojecttask.iotproject820427-22')">
  160. <template #default="{ row }">
  161. <el-tooltip
  162. effect="dark"
  163. :content="getAllDeptNames(row.deptIds)"
  164. placement="top"
  165. :disabled="!row.deptIds || row.deptIds.length <= 1">
  166. <span class="dept-names">
  167. {{ getDeptNames(row.deptIds) }}
  168. </span>
  169. </el-tooltip>
  170. </template>
  171. </el-table-column>
  172. <el-table-column prop="deviceIds" :label="t('iotprojecttask.iotproject820427-23')">
  173. <template #default="{ row }">
  174. <el-tooltip
  175. :content="getAllDeviceNames(row.deviceIds)"
  176. placement="top"
  177. :disabled="row.deviceIds && row.deviceIds.length <= 1">
  178. <span class="device-names">
  179. {{ getDeviceNames(row.deviceIds) }}
  180. </span>
  181. </el-tooltip>
  182. </template>
  183. </el-table-column>
  184. <el-table-column prop="responsiblePerson" :label="t('iotprojecttask.iotproject820427-24')">
  185. <template #default="{ row }">
  186. <el-tooltip
  187. :content="getAllResponsiblePersonNames(row.responsiblePerson)"
  188. placement="top"
  189. :disabled="!row.responsiblePerson || row.responsiblePerson.length <= 1">
  190. <span class="responsible-names">
  191. {{ getResponsiblePersonNames(row.responsiblePerson) }}
  192. </span>
  193. </el-tooltip>
  194. </template>
  195. </el-table-column>
  196. <el-table-column prop="remark" :label="t('iotprojecttask.iotproject820427-15')" />
  197. </el-table>
  198. </div>
  199. </div>
  200. </ContentWrap>
  201. <!-- 新增任务详情编辑表单 -->
  202. <ContentWrap class="task-detail-section">
  203. <div class="section-heading">
  204. <div class="section-heading__title">{{ t('iotprojecttask.iotproject820427-25') }}</div>
  205. <span class="section-heading__hint">{{ t('iotprojecttask.iotproject820427-26') }}</span>
  206. </div>
  207. <el-form
  208. ref="taskFormRef"
  209. :model="currentTask"
  210. :rules="taskFormRules"
  211. label-width="108px"
  212. size="default"
  213. class="task-edit-form">
  214. <el-row :gutter="24">
  215. <el-col :span="8">
  216. <el-form-item :label="t('iotprojecttask.iotproject820427-17')" prop="wellName">
  217. <el-input
  218. v-model="currentTask.wellName"
  219. :placeholder="t('iotprojecttask.iotproject820427-27')"
  220. :disabled="currentTask.platformWell === '1'" />
  221. </el-form-item>
  222. </el-col>
  223. <el-col :span="8">
  224. <el-form-item :label="t('project.workArea')" prop="location">
  225. <el-autocomplete
  226. ref="workAreaAutocomplete"
  227. v-model="currentTask.location"
  228. :fetch-suggestions="querySearch"
  229. :trigger-on-focus="true"
  230. :placeholder="t('iotprojecttask.iotproject820427-28')"
  231. @focus="handleWorkAreaFocus"
  232. @select="handleSelect"
  233. :disabled="!workAreaOptions.length"
  234. popper-class="work-area-autocomplete">
  235. <template #prefix>
  236. <el-icon v-if="loadingWorkAreaOptions" class="is-loading">
  237. <Loading />
  238. </el-icon>
  239. </template>
  240. </el-autocomplete>
  241. <div v-if="!workAreaOptions.length" class="el-form-item__error">{{ t('iotprojecttask.iotproject820427-29') }}</div>
  242. </el-form-item>
  243. </el-col>
  244. <el-col :span="8">
  245. <el-form-item :label="t('project.technology')" prop="technique">
  246. <el-select
  247. v-model="currentTask.technique"
  248. :placeholder="t('iotprojecttask.iotproject820427-30')"
  249. clearable
  250. :loading="loadingTechnologyOptions">
  251. <el-option
  252. v-for="dict in technologyOptions"
  253. :key="dict.value"
  254. :label="dict.label"
  255. :value="dict.value" />
  256. </el-select>
  257. <div
  258. v-if="!technologyOptions.length && !loadingTechnologyOptions"
  259. class="el-form-item__error">{{ t('iotprojecttask.iotproject820427-31') }}</div>
  260. </el-form-item>
  261. </el-col>
  262. </el-row>
  263. <el-row :gutter="24">
  264. <el-col :span="8">
  265. <el-form-item :label="t('iotprojecttask.iotproject820427-21')" prop="workloadDesign">
  266. <el-tooltip
  267. :disabled="!workloadDesignError"
  268. :content="workloadDesignError"
  269. placement="top"
  270. effect="light"
  271. popper-class="workload-design-tooltip"
  272. :show-after="0">
  273. <el-input
  274. v-model="currentTask.workloadDesign"
  275. :placeholder="t('iotprojecttask.iotproject820427-32')"
  276. :disabled="currentTask.platformWell === '1'"
  277. class="workload-input-with-button"
  278. :class="{ 'error-input': workloadDesignError }"
  279. @blur="validateWorkloadDesign">
  280. <template #append>
  281. <el-tooltip :content="t('iotprojecttask.iotproject820427-33')" placement="top">
  282. <el-button
  283. class="workload-add-btn"
  284. @click="openWorkloadDialog"
  285. :disabled="getWorkloadAddBtnDisabled">
  286. <span class="btn-text">+</span>
  287. </el-button>
  288. </el-tooltip>
  289. </template>
  290. </el-input>
  291. </el-tooltip>
  292. </el-form-item>
  293. </el-col>
  294. <el-col :span="8">
  295. <el-form-item :label="t('project.unit')" prop="workloadUnit">
  296. <el-select
  297. v-model="currentTask.workloadUnit"
  298. :placeholder="t('iotprojecttask.iotproject820427-34')"
  299. clearable
  300. :disabled="currentTask.platformWell === '1'">
  301. <el-option
  302. v-for="dict in getStrDictOptions(DICT_TYPE.PMS_PROJECT_WORKLOAD_UNIT)"
  303. :key="dict.value"
  304. :label="dict.label"
  305. :value="dict.value"
  306. :disabled="
  307. getFormSelectedWorkloadUnits().includes(dict.value) &&
  308. dict.value !== currentTask.workloadUnit
  309. " />
  310. </el-select>
  311. </el-form-item>
  312. </el-col>
  313. <el-col :span="8">
  314. <el-form-item :label="t('iotprojecttask.iotproject820427-22')" prop="deptIds">
  315. <el-tree-select
  316. multiple
  317. :multiple-limit="formData.deptId === 157 ? 1 : 0"
  318. v-model="currentTask.deptIds"
  319. :data="deptList"
  320. :props="treeSelectProps"
  321. :default-expanded-keys="defaultExpandedKeys"
  322. check-strictly
  323. node-key="id"
  324. filterable
  325. :placeholder="t('iotprojecttask.iotproject820427-35')"
  326. clearable
  327. @visible-change="handleTreeVisibleChange"
  328. collapse-tags
  329. collapse-tags-tooltip
  330. :max-collapse-tags="1"
  331. class="department-tree-select single-line-tree-select" />
  332. </el-form-item>
  333. </el-col>
  334. </el-row>
  335. <el-row :gutter="24" class="resource-row">
  336. <el-col :span="isSpecialDept ? 8 : 12">
  337. <el-form-item :label="t('iotprojecttask.iotproject820427-23')" prop="deviceIds" class="resource-select-item">
  338. <el-button @click="openDeviceDialogForForm" type="primary" plain size="default">{{ t('iotprojecttask.iotproject820427-36') }}</el-button>
  339. <!--
  340. <span v-if="currentTask.deviceIds && currentTask.deviceIds.length > 0" style="margin-left: 10px;">
  341. 已选 {{ currentTask.deviceIds.length }} 台设备
  342. </span> -->
  343. <el-tooltip
  344. v-if="currentTask.deviceIds && currentTask.deviceIds.length > 0"
  345. :content="getAllDeviceNamesForForm(currentTask.deviceIds)"
  346. placement="top">
  347. <span class="selection-summary">
  348. {{ formatDevicesForForm(currentTask.deviceIds) }}
  349. </span>
  350. </el-tooltip>
  351. <span v-else class="selection-summary selection-summary--empty">{{ t('iotprojecttask.iotproject820427-37') }}</span>
  352. </el-form-item>
  353. </el-col>
  354. <el-col :span="isSpecialDept ? 8 : 12">
  355. <el-form-item
  356. ::label="t('iotprojecttask.iotproject820427-38')"
  357. prop="responsiblePerson"
  358. class="resource-select-item">
  359. <el-button
  360. @click="openResponsiblePersonDialogForForm"
  361. type="primary"
  362. plain
  363. size="default">
  364. 选择{{ isSpecialDept ? '带班干部' : '责任人' }}
  365. </el-button>
  366. <el-tooltip
  367. v-if="currentTask.responsiblePerson && currentTask.responsiblePerson.length > 0"
  368. :content="getAllResponsiblePersonNamesForForm(currentTask.responsiblePerson)"
  369. placement="top">
  370. <span class="selection-summary">
  371. {{ formatResponsiblePersonsForForm(currentTask.responsiblePerson) }}
  372. </span>
  373. </el-tooltip>
  374. <span v-else class="selection-summary selection-summary--empty">
  375. 暂未选择{{ isSpecialDept ? '带班干部' : '责任人' }}
  376. </span>
  377. </el-form-item>
  378. </el-col>
  379. <el-col :span="8" v-if="isSpecialDept">
  380. <el-form-item :label="t('iotprojecttask.iotproject820427-39')" prop="submitter" class="resource-select-item">
  381. <el-button @click="openSubmitterDialogForForm" type="primary" plain size="default">{{ t('iotprojecttask.iotproject820427-40') }}</el-button>
  382. <el-tooltip
  383. v-if="currentTask.submitter && currentTask.submitter.length > 0"
  384. :content="getAllSubmitterNamesForForm(currentTask.submitter)"
  385. placement="top">
  386. <span class="selection-summary">
  387. {{ formatSubmittersForForm(currentTask.submitter) }}
  388. </span>
  389. </el-tooltip>
  390. <span v-else class="selection-summary selection-summary--empty">{{ t('iotprojecttask.iotproject820427-41') }}</span>
  391. </el-form-item>
  392. </el-col>
  393. </el-row>
  394. <el-row :gutter="24">
  395. <el-col :span="8" v-if="isSpecialDept && showPlatformWellSwitch">
  396. <el-form-item :label="t('iotprojecttask.iotproject820427-42')" prop="platformWell">
  397. <el-switch
  398. v-model="currentTask.platformWell"
  399. active-value="1"
  400. inactive-value="0"
  401. @change="handlePlatformWellChange" />
  402. </el-form-item>
  403. </el-col>
  404. </el-row>
  405. <!-- 动态属性部分 -->
  406. <el-row v-if="dynamicAttrs.length > 0" :gutter="24">
  407. <el-col
  408. v-for="attr in dynamicAttrs"
  409. :key="attr.id"
  410. :span="attr.dataType === 'textarea' ? 24 : 8">
  411. <el-form-item
  412. :label="attr.name + (attr.unit ? `(${attr.unit})` : '')"
  413. :prop="attr.identifier"
  414. :rules="getDynamicAttrRules(attr)">
  415. <!-- 文本类型 -->
  416. <el-input
  417. v-if="attr.dataType === 'text'"
  418. v-model="currentTask[attr.identifier]"
  419. ::placeholder="t('iotprojecttask.iotproject820427-43')" />
  420. <!-- 文本域类型 -->
  421. <el-input
  422. v-else-if="attr.dataType === 'textarea'"
  423. v-model="currentTask[attr.identifier]"
  424. ::placeholder="t('iotprojecttask.iotproject820427-43')"
  425. type="textarea"
  426. :rows="3" />
  427. <!-- 数字类型 -->
  428. <el-input
  429. v-else-if="attr.dataType === 'double'"
  430. v-model="currentTask[attr.identifier]"
  431. ::placeholder="t('iotprojecttask.iotproject820427-43')"
  432. type="number"
  433. :min="attr.minValue || undefined"
  434. :max="attr.maxValue || undefined" />
  435. <!-- 日期类型 -->
  436. <el-date-picker
  437. v-else-if="attr.dataType === 'date'"
  438. v-model="currentTask[attr.identifier]"
  439. type="date"
  440. value-format="x"
  441. ::placeholder="t('iotprojecttask.iotproject820427-44')"
  442. style="width: 100%" />
  443. <!-- 默认文本输入 -->
  444. <el-input
  445. v-else
  446. v-model="currentTask[attr.identifier]"
  447. ::placeholder="t('iotprojecttask.iotproject820427-43')" />
  448. </el-form-item>
  449. </el-col>
  450. </el-row>
  451. <el-row :gutter="24">
  452. <el-col :span="24">
  453. <el-form-item :label="t('iotprojecttask.iotproject820427-15')" prop="remark">
  454. <el-input
  455. v-model="currentTask.remark"
  456. :placeholder="t('iotprojecttask.iotproject820427-16')"
  457. type="textarea"
  458. :rows="3" />
  459. </el-form-item>
  460. </el-col>
  461. </el-row>
  462. <el-form-item class="task-reset-action">
  463. <el-button v-if="isNewTask" size="default" @click="resetTaskForm">
  464. <Icon icon="ep:refresh" class="mr-5px" />{{ t('iotprojecttask.iotproject820427-45') }}</el-button>
  465. </el-form-item>
  466. </el-form>
  467. </ContentWrap>
  468. <ContentWrap v-if="companyName === 'ry'" class="attachment-section">
  469. <div class="section-heading">
  470. <div class="section-heading__title">{{ t('iotprojecttask.iotproject820427-46') }}</div>
  471. <span class="section-heading__hint">{{ t('iotprojecttask.iotproject820427-47') }}</span>
  472. </div>
  473. <div class="attachment-content">
  474. <el-form-item size="default" :label="t('iotprojecttask.iotproject820427-48')">
  475. <el-upload
  476. v-model:file-list="constructionFiles"
  477. :action="uploadUrl"
  478. multiple
  479. :headers="{ 'tenant-id': 1, 'device-id': 'undefined' }"
  480. name="files"
  481. class="w-50%"
  482. @preview="handlePreview">
  483. <el-button type="primary">{{ t('iotprojecttask.iotproject820427-49') }}</el-button>
  484. <template #tip>
  485. <div class="el-upload__tip">文件大小不能超过50MB </div>
  486. </template>
  487. </el-upload>
  488. </el-form-item>
  489. <el-form-item size="default" :label="t('iotprojecttask.iotproject820427-50')">
  490. <el-upload
  491. v-model:file-list="geologicalFiles"
  492. :action="uploadUrl"
  493. multiple
  494. :headers="{ 'tenant-id': 1, 'device-id': 'undefined' }"
  495. name="files"
  496. class="w-50%"
  497. @preview="handlePreview">
  498. <el-button type="primary">{{ t('iotprojecttask.iotproject820427-51') }}</el-button>
  499. <template #tip>
  500. <div class="el-upload__tip">文件大小不能超过50MB </div>
  501. </template>
  502. </el-upload>
  503. </el-form-item>
  504. <el-form-item size="default" :label="t('iotprojecttask.iotproject820427-52')">
  505. <el-upload
  506. v-model:file-list="completionFiles"
  507. :action="uploadUrl"
  508. multiple
  509. :headers="{ 'tenant-id': 1, 'device-id': 'undefined' }"
  510. name="files"
  511. class="w-50%"
  512. @preview="handlePreview">
  513. <el-button :disabled="tableData[0].status !== 'wg'" type="primary"
  514. >{{ t('iotprojecttask.iotproject820427-53') }}</el-button
  515. >
  516. <template #tip>
  517. <div class="el-upload__tip">文件大小不能超过50MB </div>
  518. </template>
  519. </el-upload>
  520. </el-form-item>
  521. </div>
  522. </ContentWrap>
  523. <ContentWrap v-if="currentTask.platformWell === '1'" class="platform-well-section">
  524. <div class="section-heading">
  525. <div class="section-heading__title">{{ t('iotprojecttask.iotproject820427-42') }}</div>
  526. <span class="section-heading__hint">{{ t('iotprojecttask.iotproject820427-54') }}</span>
  527. </div>
  528. <el-table :data="currentTask.platformWellDetails" style="width: 100%">
  529. <el-table-column prop="wellName" :label="t('iotprojecttask.iotproject820427-17')">
  530. <template #default="{ $index }">
  531. <el-input
  532. v-model="currentTask.platformWellDetails[$index].wellName"
  533. :placeholder="t('iotprojecttask.iotproject820427-27')" />
  534. </template>
  535. </el-table-column>
  536. <el-table-column :label="t('iotprojecttask.iotproject820427-55')" width="150">
  537. <template #default="{ $index }">
  538. <el-select
  539. v-model="currentTask.platformWellDetails[$index].workloadUnit"
  540. :placeholder="t('iotprojecttask.iotproject820427-34')"
  541. clearable
  542. :disabled="
  543. getPlatformWellWorkloadUnits($index).includes(
  544. currentTask.platformWellDetails[$index].workloadUnit
  545. ) &&
  546. currentTask.platformWellDetails[$index].workloadUnit !== currentTask.workloadUnit
  547. ">
  548. <el-option
  549. v-for="dict in getStrDictOptions(DICT_TYPE.PMS_PROJECT_WORKLOAD_UNIT)"
  550. :key="dict.value"
  551. :label="dict.label"
  552. :value="dict.value"
  553. :disabled="
  554. getPlatformWellWorkloadUnits($index).includes(dict.value) &&
  555. dict.value !== currentTask.platformWellDetails[$index].workloadUnit
  556. " />
  557. </el-select>
  558. </template>
  559. </el-table-column>
  560. <el-table-column prop="workloadDesign" :label="t('iotprojecttask.iotproject820427-21')">
  561. <template #default="{ $index }">
  562. <el-tooltip
  563. :disabled="!currentTask.platformWellDetails[$index].workloadDesignError"
  564. :content="currentTask.platformWellDetails[$index].workloadDesignError"
  565. placement="top"
  566. effect="light"
  567. popper-class="workload-design-tooltip"
  568. :show-after="0">
  569. <el-input
  570. v-model="currentTask.platformWellDetails[$index].workloadDesign"
  571. :placeholder="t('iotprojecttask.iotproject820427-32')"
  572. class="workload-input-with-button"
  573. :class="{
  574. 'error-input': currentTask.platformWellDetails[$index].workloadDesignError
  575. }"
  576. @blur="validatePlatformWellWorkloadDesign($index)">
  577. <template #append>
  578. <el-tooltip :content="t('iotprojecttask.iotproject820427-33')" placement="top">
  579. <el-button
  580. class="workload-add-btn"
  581. @click="openPlatformWellWorkloadDialog($index)"
  582. :disabled="getPlatformWellWorkloadAddBtnDisabled($index)">
  583. <span class="btn-text">+</span>
  584. </el-button>
  585. </el-tooltip>
  586. </template>
  587. </el-input>
  588. </el-tooltip>
  589. </template>
  590. </el-table-column>
  591. <el-table-column :label="t('iotprojecttask.iotproject820427-56')" width="100">
  592. <template #default="{ $index }">
  593. <el-button
  594. type="danger"
  595. size="default"
  596. @click="removePlatformWellDetail($index)"
  597. :disabled="isMainPlatformWellDetail($index)">{{ t('iotprojecttask.iotproject820427-57') }}</el-button>
  598. </template>
  599. </el-table-column>
  600. </el-table>
  601. <el-button type="primary" plain size="default" @click="addPlatformWellDetail">
  602. <Icon icon="ep:plus" class="mr-5px" />{{ t('iotprojecttask.iotproject820427-58') }}</el-button>
  603. </ContentWrap>
  604. <div class="form-actions">
  605. <el-button size="default" type="primary" :loading="formLoading" @click="submitForm">
  606. <Icon icon="ep:check" class="mr-5px" />{{ t('iotprojecttask.iotproject820427-59') }}</el-button>
  607. <el-button size="default" @click="close">{{ t('iotprojecttask.iotproject820427-60') }}</el-button>
  608. </div>
  609. <!-- 设备选择对话框 -->
  610. <el-dialog
  611. v-model="deviceDialogVisible"
  612. :title="t('iotprojecttask.iotproject820427-61')"
  613. width="min(960px, calc(100vw - 32px))"
  614. :before-close="handleDeviceDialogClose"
  615. class="device-select-dialog">
  616. <div class="transfer-container">
  617. <el-transfer
  618. v-model="selectedDeviceIds"
  619. :data="filteredDeviceList"
  620. :titles="['可选设备', '已选设备']"
  621. :props="{ key: 'id', label: 'deviceCode' }"
  622. filterable
  623. :filter-method="filterDeviceMethod"
  624. class="transfer-component"
  625. @change="handleTransferChange">
  626. <template #default="{ option }">
  627. <el-tooltip
  628. effect="dark"
  629. placement="top"
  630. :content="`${option.deviceCode || ''} - ${option.deviceName || ''}`"
  631. :disabled="!option.deviceCode && !option.deviceName"
  632. transition="fade-in-linear">
  633. <span class="transfer-option-text">
  634. {{ option.deviceCode }} - {{ option.deviceName }}
  635. </span>
  636. </el-tooltip>
  637. </template>
  638. </el-transfer>
  639. </div>
  640. <template #footer>
  641. <span class="dialog-footer">
  642. <el-button size="default" @click="handleDeviceDialogClose">{{ t('iotprojecttask.iotproject820427-60') }}</el-button>
  643. <el-button size="default" type="primary" @click="confirmDeviceSelection">{{ t('iotprojecttask.iotproject820427-62') }}</el-button>
  644. </span>
  645. </template>
  646. </el-dialog>
  647. <!-- 责任人选择对话框 -->
  648. <el-dialog
  649. v-model="responsiblePersonDialogVisible"
  650. :title="t('iotprojecttask.iotproject820427-63')"
  651. width="min(960px, calc(100vw - 32px))"
  652. :before-close="handleResponsiblePersonDialogClose"
  653. class="responsible-person-select-dialog">
  654. <div class="transfer-container">
  655. <el-transfer
  656. v-model="selectedResponsiblePersonIds"
  657. :data="responsiblePersonList"
  658. :titles="['可选人员', '已选人员']"
  659. :props="{ key: 'id', label: 'nickname' }"
  660. filterable
  661. class="transfer-component">
  662. <template #default="{ option }">
  663. <el-tooltip
  664. effect="dark"
  665. placement="top"
  666. ::content="t('iotprojecttask.iotproject820427-64')">
  667. <span class="transfer-option-text">
  668. {{ option.nickname }} - {{ option.deptName || '未分配部门' }}
  669. </span>
  670. </el-tooltip>
  671. </template>
  672. </el-transfer>
  673. </div>
  674. <template #footer>
  675. <span class="dialog-footer">
  676. <el-button size="default" @click="handleResponsiblePersonDialogClose">{{ t('iotprojecttask.iotproject820427-60') }}</el-button>
  677. <el-button size="default" type="primary" @click="confirmResponsiblePersonSelection">{{ t('iotprojecttask.iotproject820427-62') }}</el-button>
  678. </span>
  679. </template>
  680. </el-dialog>
  681. <!-- 填报人选择对话框 -->
  682. <el-dialog
  683. v-model="submitterDialogVisible"
  684. :title="t('iotprojecttask.iotproject820427-40')"
  685. width="min(960px, calc(100vw - 32px))"
  686. :before-close="handleSubmitterDialogClose"
  687. class="responsible-person-select-dialog">
  688. <div class="transfer-container">
  689. <el-transfer
  690. v-model="selectedSubmitterIds"
  691. :data="submitterList"
  692. :titles="['可选人员', '已选人员']"
  693. :props="{ key: 'id', label: 'nickname' }"
  694. filterable
  695. class="transfer-component">
  696. <template #default="{ option }">
  697. <el-tooltip
  698. effect="dark"
  699. placement="top"
  700. ::content="t('iotprojecttask.iotproject820427-64')">
  701. <span class="transfer-option-text">
  702. {{ option.nickname }} - {{ option.deptName || '未分配部门' }}
  703. </span>
  704. </el-tooltip>
  705. </template>
  706. </el-transfer>
  707. </div>
  708. <template #footer>
  709. <span class="dialog-footer">
  710. <el-button size="default" @click="handleSubmitterDialogClose">{{ t('iotprojecttask.iotproject820427-60') }}</el-button>
  711. <el-button size="default" type="primary" @click="confirmSubmitterSelection">{{ t('iotprojecttask.iotproject820427-62') }}</el-button>
  712. </span>
  713. </template>
  714. </el-dialog>
  715. <!-- 工作量维护对话框 -->
  716. <el-dialog
  717. v-model="workloadDialogVisible"
  718. :title="t('iotprojecttask.iotproject820427-21')"
  719. width="min(680px, calc(100vw - 32px))"
  720. class="workload-dialog">
  721. <el-table :data="workloadList" style="width: 100%">
  722. <el-table-column prop="workloadUnit" :label="t('iotprojecttask.iotproject820427-55')" width="200">
  723. <template #default="{ $index }">
  724. <el-select
  725. v-model="workloadList[$index].workloadUnit"
  726. :placeholder="t('iotprojecttask.iotproject820427-34')"
  727. :disabled="$index === 0 && hasInitialWorkload">
  728. <el-option
  729. v-for="dict in getStrDictOptions(DICT_TYPE.PMS_PROJECT_WORKLOAD_UNIT)"
  730. :key="dict.value"
  731. :label="dict.label"
  732. :value="dict.value"
  733. :disabled="getSelectedWorkloadUnits($index).includes(dict.value)" />
  734. </el-select>
  735. </template>
  736. </el-table-column>
  737. <el-table-column prop="workloadDesign" :label="t('iotprojecttask.iotproject820427-65')">
  738. <template #default="{ $index }">
  739. <el-tooltip
  740. :disabled="!workloadList[$index].workloadDesignError"
  741. :content="workloadList[$index].workloadDesignError"
  742. placement="top"
  743. effect="light"
  744. popper-class="workload-design-tooltip"
  745. :show-after="0">
  746. <el-input
  747. v-model="workloadList[$index].workloadDesign"
  748. :placeholder="t('iotprojecttask.iotproject820427-66')"
  749. :disabled="$index === 0 && hasInitialWorkload"
  750. :class="{ 'error-input': workloadList[$index].workloadDesignError }"
  751. @blur="validateWorkloadDialogDesign($index)" />
  752. </el-tooltip>
  753. </template>
  754. </el-table-column>
  755. <el-table-column :label="t('iotprojecttask.iotproject820427-56')" width="80">
  756. <template #default="{ $index }">
  757. <el-button
  758. type="danger"
  759. size="default"
  760. @click="removeWorkloadItem($index)"
  761. :disabled="$index === 0 && hasInitialWorkload">{{ t('iotprojecttask.iotproject820427-57') }}</el-button>
  762. </template>
  763. </el-table-column>
  764. </el-table>
  765. <el-button type="primary" plain size="default" @click="addWorkloadItem">
  766. <Icon icon="ep:plus" class="mr-5px" />{{ t('iotprojecttask.iotproject820427-58') }}</el-button>
  767. <template #footer>
  768. <span class="dialog-footer">
  769. <el-button size="default" @click="workloadDialogVisible = false">{{ t('iotprojecttask.iotproject820427-60') }}</el-button>
  770. <el-button size="default" type="primary" @click="confirmWorkloadSelection">{{ t('iotprojecttask.iotproject820427-62') }}</el-button>
  771. </span>
  772. </template>
  773. </el-dialog>
  774. </div>
  775. </template>
  776. <script setup lang="ts">
  777. // 导入部分保持不变,与原始代码相同
  778. import { IotProjectInfoApi, IotProjectInfoVO } from '@/api/pms/iotprojectinfo'
  779. import { handleTree } from '@/utils/tree'
  780. import * as DeptApi from '@/api/system/dept'
  781. import { ref, reactive, computed, onMounted, watch } from 'vue'
  782. import { useUserStore } from '@/store/modules/user'
  783. import { IotProjectTaskApi, IotProjectTaskVO } from '@/api/pms/iotprojecttask'
  784. import { ElMessage } from 'element-plus'
  785. import { useTagsViewStore } from '@/store/modules/tagsView'
  786. import { IotDeviceApi, IotDeviceVO } from '@/api/pms/device'
  787. import * as UserApi from '@/api/system/user'
  788. import { IotProjectTaskAttrsApi } from '@/api/pms/iotprojecttaskattrs'
  789. import { DICT_TYPE, getStrDictOptions, getDictLabel } from '@/utils/dict'
  790. import { IotOpeationFillApi } from '@/api/pms/iotopeationfill'
  791. import { Base64 } from 'js-base64'
  792. import { useRoute } from 'vue-router'
  793. // import { Plus } from '@element-plus/icons-vue'
  794. const { query, params, name } = useRoute() // 查询参数
  795. console.log('idaaaaaaaaaaaaaaaa', useRoute().query.deptId)
  796. const id = params.id
  797. let deptId = ref(params.deptId)
  798. const uploadUrl = import.meta.env.VITE_BASE_URL + '/admin-api/rq/file/upload'
  799. const constructionFiles = ref<any>([])
  800. const geologicalFiles = ref<any>([])
  801. const completionFiles = ref<any>([])
  802. // 修改projectId获取逻辑:优先使用params.projectId,其次使用query.projectId
  803. const projectId = ref<string>('')
  804. // 获取projectId的逻辑
  805. if (params.projectId) {
  806. projectId.value = Array.isArray(params.projectId) ? params.projectId[0] : params.projectId
  807. } else if (query.projectId) {
  808. projectId.value = Array.isArray(query.projectId as any)
  809. ? query.projectId[0]
  810. : (query.projectId as string)
  811. }
  812. function handlePreview(file: any) {
  813. if (!file.response) {
  814. message.error('附件路径不存在')
  815. return
  816. }
  817. try {
  818. const filePath = file.response.data.filePath ?? file.response.data.files[0].filePath
  819. const encodedPath = encodeURIComponent(Base64.encode(filePath))
  820. window.open(`http://doc.deepoil.cc:8012/onlinePreview?url=${encodedPath}`)
  821. } catch (error) {
  822. console.error('预览附件失败:', error)
  823. message.error('预览附件失败')
  824. }
  825. }
  826. const deptLoading = ref(false)
  827. const deptOptions = ref<any[]>([])
  828. const user = useUserStore().getUser
  829. const userdeptId = user.deptId
  830. async function loadDept(deptId?: number) {
  831. deptLoading.value = true
  832. try {
  833. const res = await DeptApi.specifiedSimpleDepts(deptId ?? userdeptId)
  834. deptOptions.value = res
  835. .map((item: any) => ({
  836. label: item.name,
  837. value: item.id,
  838. raw: item
  839. }))
  840. .filter((item) => item.raw.type === '2')
  841. } catch (error) {
  842. } finally {
  843. deptLoading.value = false
  844. }
  845. }
  846. onMounted(() => {
  847. loadDept()
  848. })
  849. // 施工队伍 选择树 响应式变量
  850. const defaultExpandedKeys = ref<number[]>([]) // 默认展开的部门节点keys
  851. const treeSelectRef = ref() // 树选择组件的引用
  852. const { delView } = useTagsViewStore() // 视图操作
  853. const { currentRoute, push } = useRouter()
  854. const { t } = useI18n() // 国际化
  855. const message = useMessage() // 消息弹窗
  856. const deptList = ref<Tree[]>([]) // 树形结构
  857. const deviceList = ref<IotDeviceVO[]>([]) // 设备列表
  858. // 设备映射表(ID->设备对象)
  859. const deviceMap = ref<Record<number, IotDeviceVO>>({})
  860. const dialogVisible = ref(true) // 弹窗的是否展示
  861. const dialogTitle = ref('') // 弹窗的标题
  862. const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
  863. const taskList = ref<IotProjectTaskVO[]>([]) // 列表的数据
  864. const projectList = ref<IotProjectInfoVO[]>([])
  865. const formType = ref('') // 表单的类型:create - 新增;update - 修改
  866. const loading = ref(true) // 列表的加载中
  867. // 设备选择相关变量
  868. const deviceDialogVisible = ref(false)
  869. const filteredDeviceList = ref<IotDeviceVO[]>([]) // 过滤后的设备列表
  870. const selectedDeviceIds = ref<number[]>([]) // 选中的设备ID
  871. // 责任人相关变量
  872. const responsiblePersonDialogVisible = ref(false)
  873. const responsiblePersonList = ref([]) // 所有责任人列表
  874. const selectedResponsiblePersonIds = ref([]) // 选中的责任人ID
  875. const currentEditingRowForResponsible = ref(null) // 当前正在编辑责任人的行
  876. const submitterDialogVisible = ref(false)
  877. const submitterList = ref([]) // 所有填报人列表
  878. const selectedSubmitterIds = ref([]) // 选中的日报填报人ID
  879. // 动态属性相关变量
  880. const dynamicAttrs = ref<any[]>([]) // 存储动态属性列表
  881. // 跟踪是否已从任务数据中获取动态属性
  882. const hasDynamicAttrsFromTask = ref(false)
  883. // 添加 workAreaOptions 引用和加载状态
  884. const workAreaOptions = ref<any[]>([])
  885. const loadingWorkAreaOptions = ref(false)
  886. const workAreaAutocomplete = ref() // 添加对el-autocomplete的引用
  887. // currentDictLabel 响应式变量
  888. const currentDictLabel = ref('') // 存储当前项目对应的施工区域字典类型
  889. // 当前正在操作的平台井索引
  890. const currentPlatformWellIndex = ref(-1)
  891. // 施工工艺相关变量
  892. const technologyOptions = ref<any[]>([])
  893. const loadingTechnologyOptions = ref(false)
  894. const currentTechnologyDictLabel = ref('') // 存储当前项目对应的施工工艺字典类型
  895. // 添加一个变量来保存平台井详情数据
  896. const platformWellDetailsBackup = ref([])
  897. // 存储井号到工作量列表的映射(key: wellName, value: Array<{workloadUnit, workloadDesign}>)
  898. const workloadMap = ref(new Map())
  899. // 工作量数据备份
  900. const workloadBackup = ref<Map<string, any[]>>(new Map())
  901. // 工作量维护相关变量
  902. const workloadDialogVisible = ref(false)
  903. const workloadList = ref<any[]>([])
  904. const hasInitialWorkload = ref(false)
  905. // 跟踪设备列表是否为空
  906. const hasDevicesAvailable = ref(false) // 默认假设有设备,等接口返回后更新
  907. // 设计工作量错误信息
  908. const workloadDesignError = ref('')
  909. /** 项目信息 表单 */
  910. defineOptions({ name: 'IotProjectTaskInfo' })
  911. const formData = ref({
  912. id: undefined,
  913. contractId: undefined,
  914. contractName: undefined,
  915. contractCode: undefined,
  916. workloadTotal: undefined,
  917. workloadFinish: undefined,
  918. workloadUnit: undefined,
  919. startTime: undefined,
  920. endTime: undefined,
  921. location: undefined,
  922. technique: undefined,
  923. payment: undefined,
  924. remark: undefined,
  925. manufactureName: undefined,
  926. manufacturerId: undefined,
  927. userName: undefined,
  928. userId: undefined,
  929. deptId: undefined, // 新增项目部门ID字段
  930. projectDeptId: undefined // 新增项目部门ID字段
  931. })
  932. const close = () => {
  933. delView(unref(currentRoute))
  934. push({ name: 'IotProjectTask', params: {} })
  935. }
  936. // 添加计算属性来判断是否为特定部门
  937. const isSpecialDept = computed(() => {
  938. return formData.value.deptId === 163
  939. })
  940. // 仅隐藏平台井切换入口,保留既有平台井数据的查看和编辑能力
  941. const showPlatformWellSwitch = false
  942. // 定义新的树选择器配置,添加禁用逻辑
  943. const treeSelectProps = {
  944. children: 'children',
  945. label: 'name',
  946. disabled: (data: any) => {
  947. // 只有叶子节点(type = 3)可以选择,非叶子节点禁用
  948. return data.type !== '3'
  949. }
  950. }
  951. const getProjectInfo = async (contractId: number) => {
  952. const project = projectList.value.find((item) => item.id === contractId)
  953. if (project) {
  954. formData.value.contractName = project.contractName
  955. formData.value.contractCode = project.contractCode
  956. formData.value.payment = project.payment
  957. formData.value.workloadTotal = project.workloadTotal
  958. formData.value.startTime = project.startTime
  959. formData.value.endTime = project.endTime
  960. formData.value.remark = project.remark
  961. formData.value.manufactureName = project.manufactureName
  962. formData.value.manufacturerId = project.manufacturerId
  963. formData.value.id = project.id
  964. formData.value.deptId = project.deptId // 保存项目部门ID
  965. formData.value.projectDeptId = project.projectDeptId // 保存项目部门ID
  966. // 获取施工区域数据字典集合
  967. await loadWorkAreaOptions(formData.value.deptId)
  968. // 获取施工工艺数据字典集合
  969. await loadTechnologyOptions(formData.value.deptId)
  970. // 获取动态属性
  971. await fetchDynamicAttrs()
  972. }
  973. }
  974. const queryParams = reactive({
  975. projectId: undefined,
  976. id: undefined
  977. })
  978. const formRules = reactive({
  979. contractId: [{ required: true, message: '合同名称不能为空', trigger: 'blur' }],
  980. manufacturerId: [{ required: true, message: '客户不能为空', trigger: 'blur' }],
  981. payment: [{ required: true, message: '结算方式不能为空', trigger: 'blur' }],
  982. // workloadTotal: [{ required: true, message: '工作量总数不能为空', trigger: 'blur' }],
  983. startTime: [{ required: true, message: '开始时间不能为空', trigger: 'blur' }],
  984. endTime: [{ required: true, message: '结束时间不能为空', trigger: 'blur' }]
  985. })
  986. const formRef = ref() // 表单 Ref
  987. const zzClear = () => {
  988. formData.value.manufacturerId = undefined
  989. formData.value.manufactureName = undefined
  990. }
  991. // 根据部门ID获取部门名称
  992. const getDeptNames = (deptIds) => {
  993. if (!deptIds || deptIds.length === 0) return ''
  994. const names = []
  995. const findDept = (list, id) => {
  996. for (const item of list) {
  997. if (item.id === id) {
  998. names.push(item.name)
  999. return true
  1000. }
  1001. if (item.children && findDept(item.children, id)) {
  1002. return true
  1003. }
  1004. }
  1005. return false
  1006. }
  1007. deptIds.forEach((id) => findDept(deptList.value, id))
  1008. if (names.length > 1) {
  1009. return `${names[0]}...`
  1010. }
  1011. return names.join(', ')
  1012. }
  1013. const getAllDeptNames = (deptIds) => {
  1014. if (!deptIds || deptIds.length === 0) return '无施工队伍'
  1015. const names = []
  1016. const findDept = (list, id) => {
  1017. for (const item of list) {
  1018. if (item.id === id) {
  1019. names.push(item.name)
  1020. return true
  1021. }
  1022. if (item.children && findDept(item.children, id)) {
  1023. return true
  1024. }
  1025. }
  1026. return false
  1027. }
  1028. deptIds.forEach((id) => findDept(deptList.value, id))
  1029. return names.join(', ') || '无有效施工队伍'
  1030. }
  1031. const getDeviceNames = (deviceIds: number[]) => {
  1032. if (!deviceIds || deviceIds.length === 0) return ''
  1033. // 获取所有有效设备名称
  1034. const deviceNames = deviceIds
  1035. .map((id) => deviceMap.value[id]?.deviceCode)
  1036. .filter((name) => name !== undefined && name !== '')
  1037. if (deviceNames.length === 0) return ''
  1038. // 如果设备数量超过2个,显示前两个加省略号
  1039. if (deviceNames.length > 2) {
  1040. return `${deviceNames[0]}, ${deviceNames[1]}...`
  1041. }
  1042. // 设备数量不超过2个,正常显示所有
  1043. return deviceNames.join(', ')
  1044. }
  1045. const initDynamicAttrsToCurrentTask = () => {
  1046. dynamicAttrs.value.forEach((attr) => {
  1047. if (!currentTask.value.hasOwnProperty(attr.identifier)) {
  1048. // 如果是从任务数据中获取的属性,并且有实际值,使用实际值
  1049. if (
  1050. hasDynamicAttrsFromTask.value &&
  1051. attr.actualValue !== undefined &&
  1052. attr.actualValue !== null &&
  1053. attr.actualValue !== ''
  1054. ) {
  1055. currentTask.value[attr.identifier] = attr.actualValue
  1056. } else {
  1057. // 否则使用默认值
  1058. currentTask.value[attr.identifier] = attr.defaultValue || ''
  1059. }
  1060. }
  1061. })
  1062. }
  1063. // 当前编辑的任务
  1064. const currentTask = ref({
  1065. id: undefined,
  1066. wellName: '',
  1067. wellType: '',
  1068. wellCategory: '',
  1069. location: '',
  1070. dictType: '',
  1071. technique: '',
  1072. workloadDesign: '',
  1073. workloadUnit: '',
  1074. deptIds: [],
  1075. deviceIds: [],
  1076. responsiblePerson: [],
  1077. submitter: [],
  1078. remark: '',
  1079. projectId: '',
  1080. platformWell: '0', // 新增平台井字段,默认非平台井
  1081. platformWellDetails: [] // 新增平台井详情列表
  1082. })
  1083. const isNewTask = ref(false) // 是否是新任务
  1084. const taskFormRef = ref() // 任务表单ref
  1085. const currentEditingIndex = ref(-1) // 当前编辑的行索引
  1086. // 任务表单验证规则
  1087. const taskFormRules = computed(() => {
  1088. const rules = {
  1089. wellName: [
  1090. { required: currentTask.value.platformWell !== '1', message: '井号不能为空', trigger: 'blur' }
  1091. ],
  1092. wellType: [{ required: true, message: '井型不能为空', trigger: 'change' }],
  1093. location: [{ required: true, message: '施工地点不能为空', trigger: 'blur' }],
  1094. technique: [{ required: true, message: '施工工艺不能为空', trigger: 'change' }],
  1095. workloadDesign: [
  1096. {
  1097. required: currentTask.value.platformWell !== '1',
  1098. message: '设计工作量不能为空',
  1099. trigger: 'blur'
  1100. },
  1101. {
  1102. validator: (rule, value, callback) => {
  1103. if (currentTask.value.platformWell === '1') {
  1104. callback()
  1105. return
  1106. }
  1107. if (value === '' || value === null || value === undefined) {
  1108. callback(new Error('设计工作量不能为空'))
  1109. return
  1110. }
  1111. const numValue = Number(value)
  1112. if (isNaN(numValue) || numValue < 0) {
  1113. callback(new Error('请填写大于0的数字'))
  1114. } else {
  1115. callback()
  1116. }
  1117. },
  1118. trigger: 'blur'
  1119. }
  1120. ],
  1121. workloadUnit: [
  1122. {
  1123. required: currentTask.value.platformWell !== '1',
  1124. message: '工作量单位不能为空',
  1125. trigger: 'change'
  1126. }
  1127. ],
  1128. deptIds: [{ required: true, message: '施工队伍不能为空', trigger: 'change' }],
  1129. deviceIds: [
  1130. { required: hasDevicesAvailable.value, message: '施工设备不能为空', trigger: 'change' }
  1131. ],
  1132. responsiblePerson: [
  1133. {
  1134. required: true,
  1135. message: isSpecialDept.value ? '带班干部不能为空' : '责任人不能为空',
  1136. trigger: 'change',
  1137. validator: (rule, value, callback) => {
  1138. if (!value || value.length === 0) {
  1139. callback(new Error(isSpecialDept.value ? '带班干部不能为空' : '责任人不能为空'))
  1140. } else {
  1141. callback()
  1142. }
  1143. }
  1144. }
  1145. ],
  1146. submitter: [
  1147. {
  1148. required: isSpecialDept.value,
  1149. message: '填报人不能为空',
  1150. trigger: 'change',
  1151. validator: (rule, value, callback) => {
  1152. if (isSpecialDept.value && (!value || value.length === 0)) {
  1153. callback(new Error('填报人不能为空'))
  1154. } else {
  1155. callback()
  1156. }
  1157. }
  1158. }
  1159. ]
  1160. }
  1161. return rules
  1162. })
  1163. // 动态属性验证规则
  1164. const getDynamicAttrRules = (attr) => {
  1165. const rules = []
  1166. if (attr.required === 1) {
  1167. rules.push({ required: true, message: `${attr.name}不能为空`, trigger: 'blur' })
  1168. }
  1169. // 数字类型验证
  1170. if (attr.dataType === 'double') {
  1171. rules.push({
  1172. validator: (rule, value, callback) => {
  1173. if (value === '' || value === null || value === undefined) {
  1174. callback()
  1175. return
  1176. }
  1177. const numValue = Number(value)
  1178. if (isNaN(numValue)) {
  1179. callback(new Error(`${attr.name}必须是数字`))
  1180. } else if (attr.minValue !== null && numValue < Number(attr.minValue)) {
  1181. // callback(new Error(`${attr.name}不能小于${attr.minValue}`));
  1182. } else if (attr.maxValue !== null && numValue > Number(attr.maxValue)) {
  1183. // callback(new Error(`${attr.name}不能大于${attr.maxValue}`));
  1184. } else {
  1185. callback()
  1186. }
  1187. },
  1188. trigger: 'blur'
  1189. })
  1190. }
  1191. return rules
  1192. }
  1193. const tableData = ref([])
  1194. // 打开责任人选择对话框(用于表单)
  1195. const openResponsiblePersonDialogForForm = async () => {
  1196. if (!currentTask.value.deptIds || currentTask.value.deptIds.length === 0) {
  1197. ElMessage.warning('请先选择施工队伍')
  1198. return
  1199. }
  1200. selectedResponsiblePersonIds.value = [...(currentTask.value.responsiblePerson || [])]
  1201. try {
  1202. const params = {
  1203. deptIds: currentTask.value.deptIds, // 使用当前项目所属部门的deptId
  1204. deptId: deptId.value
  1205. }
  1206. const response = await UserApi.selectedDeptsEmployee(params)
  1207. responsiblePersonList.value = response
  1208. responsiblePersonDialogVisible.value = true
  1209. } catch (error) {
  1210. ElMessage.error('获取责任人列表失败')
  1211. console.error('获取责任人列表失败:', error)
  1212. }
  1213. }
  1214. // 打开工单人选择对话框(用于表单)
  1215. const openSubmitterDialogForForm = async () => {
  1216. if (!currentTask.value.deptIds || currentTask.value.deptIds.length === 0) {
  1217. ElMessage.warning('请先选择施工队伍')
  1218. return
  1219. }
  1220. selectedSubmitterIds.value = [...(currentTask.value.submitter || [])]
  1221. try {
  1222. const params = {
  1223. deptIds: currentTask.value.deptIds // 使用当前项目所属部门的deptId
  1224. }
  1225. const response = await UserApi.selectedDeptsEmployee(params)
  1226. submitterList.value = response
  1227. submitterDialogVisible.value = true
  1228. } catch (error) {
  1229. ElMessage.error('获取填报人列表失败')
  1230. console.error('获取填报人列表失败:', error)
  1231. }
  1232. }
  1233. // 获取动态属性
  1234. const fetchDynamicAttrs = async () => {
  1235. // 如果已经通过任务数据获取了动态属性,则不再调用接口
  1236. if (hasDynamicAttrsFromTask.value) {
  1237. return
  1238. }
  1239. if (!formData.value.deptId) {
  1240. console.warn('部门ID为空,无法获取动态属性')
  1241. return
  1242. }
  1243. try {
  1244. const queryParams = {
  1245. deptId: formData.value.deptId
  1246. }
  1247. const response = await IotProjectTaskAttrsApi.getIotProjectTaskAttrsList(queryParams)
  1248. dynamicAttrs.value = response || []
  1249. // 初始化动态属性到当前任务
  1250. initDynamicAttrsToCurrentTask()
  1251. } catch (error) {
  1252. console.error('获取动态属性失败:', error)
  1253. ElMessage.error('获取动态属性失败')
  1254. }
  1255. }
  1256. // 打开设备选择对话框(用于表单)
  1257. const openDeviceDialogForForm = async () => {
  1258. if (!currentTask.value.deptIds || currentTask.value.deptIds.length === 0) {
  1259. ElMessage.warning('请先选择施工队伍')
  1260. return
  1261. }
  1262. selectedDeviceIds.value = [...(currentTask.value.deviceIds || [])]
  1263. console.log('sssssssssssssssssss', params)
  1264. try {
  1265. const params = {
  1266. deptIds: currentTask.value.deptIds,
  1267. deptId: deptId.value
  1268. }
  1269. const data = await IotDeviceApi.getDevicesByDepts(params)
  1270. // 更新 hasDevicesAvailable 状态
  1271. hasDevicesAvailable.value = data && data.length > 0
  1272. // 更新设备映射表
  1273. const newDeviceMap = { ...deviceMap.value }
  1274. data.forEach((device) => {
  1275. newDeviceMap[device.id] = device
  1276. })
  1277. deviceMap.value = newDeviceMap
  1278. filteredDeviceList.value = data
  1279. deviceDialogVisible.value = true
  1280. // 如果没有设备可用,显示提示信息
  1281. if (!hasDevicesAvailable.value) {
  1282. ElMessage.info('当前施工队伍下没有可用设备,设备字段为非必填项')
  1283. }
  1284. } catch (error) {
  1285. ElMessage.error('获取设备列表失败')
  1286. console.error('获取设备列表失败:', error)
  1287. // 如果获取失败,也设为非必填,避免用户无法提交
  1288. hasDevicesAvailable.value = false
  1289. }
  1290. }
  1291. // 打开工作量维护对话框
  1292. const openWorkloadDialog = () => {
  1293. currentPlatformWellIndex.value = -1 // 设置为-1表示普通井模式
  1294. // 前置校验:设计工作量不合法则直接返回
  1295. if (!validateWorkloadDesign()) {
  1296. ElMessage.error(workloadDesignError.value)
  1297. return
  1298. }
  1299. // 重置列表
  1300. workloadList.value = []
  1301. hasInitialWorkload.value = false
  1302. // 获取当前操作的井号(兼容普通井/平台井)
  1303. let currentWellName = ''
  1304. if (currentTask.value.platformWell === '1') {
  1305. // 平台井:取主井号(优先当前任务wellName,其次取平台井详情第一个)
  1306. currentWellName =
  1307. currentTask.value.wellName ||
  1308. (currentTask.value.platformWellDetails.length > 0
  1309. ? currentTask.value.platformWellDetails[0].wellName
  1310. : '')
  1311. } else {
  1312. // 普通井:直接取当前任务井号
  1313. currentWellName = currentTask.value.wellName
  1314. }
  1315. if (!currentWellName) {
  1316. ElMessage.warning('请先填写井号')
  1317. return
  1318. }
  1319. // 从Map中回显当前井号的工作量数据
  1320. if (workloadMap.value.has(currentWellName)) {
  1321. // 深拷贝避免原数据被修改
  1322. workloadList.value = JSON.parse(JSON.stringify(workloadMap.value.get(currentWellName)))
  1323. hasInitialWorkload.value = workloadList.value.length > 0
  1324. } else {
  1325. // 无历史数据时,沿用原有逻辑(取表单已有值初始化首行)
  1326. if (currentTask.value.workloadUnit && currentTask.value.workloadDesign) {
  1327. workloadList.value.push({
  1328. workloadUnit: currentTask.value.workloadUnit,
  1329. workloadDesign: currentTask.value.workloadDesign
  1330. })
  1331. hasInitialWorkload.value = true
  1332. }
  1333. }
  1334. workloadDialogVisible.value = true
  1335. }
  1336. // 添加工作量项
  1337. const addWorkloadItem = () => {
  1338. workloadList.value.push({
  1339. workloadUnit: '',
  1340. workloadDesign: ''
  1341. })
  1342. }
  1343. // 删除工作量项
  1344. const removeWorkloadItem = (index: number) => {
  1345. workloadList.value.splice(index, 1)
  1346. }
  1347. // 确认工作量选择
  1348. const confirmWorkloadSelection = () => {
  1349. // 验证工作量对话框中的所有数据
  1350. let allValid = true
  1351. workloadList.value.forEach((item, index) => {
  1352. if (!validateWorkloadDialogDesign(index)) {
  1353. allValid = false
  1354. }
  1355. })
  1356. if (!allValid) {
  1357. ElMessage.error('请完善所有工作量信息')
  1358. return
  1359. }
  1360. // 验证工作量单位唯一性
  1361. const unitList = workloadList.value.map((item) => item.workloadUnit).filter(Boolean)
  1362. const uniqueUnits = new Set(unitList)
  1363. if (unitList.length !== uniqueUnits.size) {
  1364. ElMessage.error('工作量单位不能重复,请选择不同的单位')
  1365. return
  1366. }
  1367. // 获取当前井号并存储到Map
  1368. let currentWellName = ''
  1369. if (currentPlatformWellIndex.value >= 0) {
  1370. // 平台井模式
  1371. const wellDetail = currentTask.value.platformWellDetails[currentPlatformWellIndex.value]
  1372. currentWellName = wellDetail.wellName
  1373. // 同步更新平台井表格中的工作量单位
  1374. if (workloadList.value.length > 0) {
  1375. const firstItem = workloadList.value[0]
  1376. if (wellDetail.workloadUnit !== firstItem.workloadUnit) {
  1377. wellDetail.workloadUnit = firstItem.workloadUnit
  1378. }
  1379. wellDetail.workloadDesign = firstItem.workloadDesign
  1380. }
  1381. } else {
  1382. // 普通井模式
  1383. currentWellName = currentTask.value.wellName
  1384. // 同步更新表单中的工作量单位
  1385. if (workloadList.value.length > 0) {
  1386. const firstItem = workloadList.value[0]
  1387. if (currentTask.value.workloadUnit !== firstItem.workloadUnit) {
  1388. currentTask.value.workloadUnit = firstItem.workloadUnit
  1389. }
  1390. currentTask.value.workloadDesign = firstItem.workloadDesign
  1391. }
  1392. }
  1393. // 存储到Map
  1394. if (currentWellName) {
  1395. workloadMap.value.set(currentWellName, JSON.parse(JSON.stringify(workloadList.value)))
  1396. }
  1397. workloadDialogVisible.value = false
  1398. currentPlatformWellIndex.value = -1 // 重置索引
  1399. ElMessage.success('工作量信息已更新')
  1400. }
  1401. // 处理穿梭框变化
  1402. const handleTransferChange = (value, direction, movedKeys) => {
  1403. // 可以添加额外的处理逻辑
  1404. }
  1405. // 确认设备选择(用于表单)
  1406. const confirmDeviceSelection = () => {
  1407. currentTask.value.deviceIds = [...selectedDeviceIds.value]
  1408. // 强制更新视图
  1409. currentTask.value = { ...currentTask.value }
  1410. deviceDialogVisible.value = false
  1411. }
  1412. // 确认责任人选择(用于表单)
  1413. const confirmResponsiblePersonSelection = () => {
  1414. currentTask.value.responsiblePerson = [...selectedResponsiblePersonIds.value]
  1415. responsiblePersonDialogVisible.value = false
  1416. // 立即触发责任人字段验证
  1417. nextTick(() => {
  1418. taskFormRef.value.validateField('responsiblePerson')
  1419. })
  1420. }
  1421. // 确认填报人选择(用于表单)
  1422. const confirmSubmitterSelection = () => {
  1423. currentTask.value.submitter = [...selectedSubmitterIds.value]
  1424. submitterDialogVisible.value = false
  1425. // 立即触发填报人字段验证
  1426. nextTick(() => {
  1427. taskFormRef.value.validateField('submitter')
  1428. })
  1429. }
  1430. // 关闭设备选择对话框
  1431. const handleDeviceDialogClose = () => {
  1432. deviceDialogVisible.value = false
  1433. }
  1434. // 关闭责任人选择对话框
  1435. const handleResponsiblePersonDialogClose = () => {
  1436. responsiblePersonDialogVisible.value = false
  1437. }
  1438. // 关闭填报人选择对话框
  1439. const handleSubmitterDialogClose = () => {
  1440. submitterDialogVisible.value = false
  1441. }
  1442. // 获取井型标签的方法
  1443. const getWellTypeLabel = (value) => {
  1444. const options = getStrDictOptions(DICT_TYPE.PMS_PROJECT_WELL_TYPE)
  1445. const option = options.find((opt) => opt.value === value)
  1446. return option ? option.label : value
  1447. }
  1448. // 获取井别标签的方法
  1449. const getWellCategoryLabel = (value) => {
  1450. const options = getStrDictOptions(DICT_TYPE.PMS_PROJECT_WELL_CATEGORY)
  1451. const option = options.find((opt) => opt.value === value)
  1452. return option ? option.label : value
  1453. }
  1454. // 获取施工工艺标签的方法
  1455. const getTechniqueLabel = (value) => {
  1456. const options = getStrDictOptions(DICT_TYPE.PMS_PROJECT_TECHNOLOGY)
  1457. const option = options.find((opt) => opt.value === value)
  1458. return option ? option.label : value
  1459. }
  1460. // 获取 工作量单位 标签的方法
  1461. const getWorkloadUnitLabel = (value) => {
  1462. const options = getStrDictOptions(DICT_TYPE.PMS_PROJECT_WORKLOAD_UNIT)
  1463. const option = options.find((opt) => opt.value === value)
  1464. return option ? option.label : value
  1465. }
  1466. // 打开平台井工作量对话框
  1467. const openPlatformWellWorkloadDialog = (index) => {
  1468. currentPlatformWellIndex.value = index
  1469. const wellDetail = currentTask.value.platformWellDetails[index]
  1470. // 前置校验
  1471. if (!validatePlatformWellWorkloadDesign(index)) {
  1472. ElMessage.error(wellDetail.workloadDesignError)
  1473. return
  1474. }
  1475. // 重置列表
  1476. workloadList.value = []
  1477. hasInitialWorkload.value = false
  1478. if (!wellDetail.wellName) {
  1479. ElMessage.warning('请先填写井号')
  1480. return
  1481. }
  1482. // 从Map中回显工作量数据
  1483. if (workloadMap.value.has(wellDetail.wellName)) {
  1484. workloadList.value = JSON.parse(JSON.stringify(workloadMap.value.get(wellDetail.wellName)))
  1485. hasInitialWorkload.value = workloadList.value.length > 0
  1486. } else {
  1487. // 无历史数据时,使用当前行的值初始化
  1488. if (wellDetail.workloadUnit && wellDetail.workloadDesign) {
  1489. workloadList.value.push({
  1490. workloadUnit: wellDetail.workloadUnit,
  1491. workloadDesign: wellDetail.workloadDesign
  1492. })
  1493. hasInitialWorkload.value = true
  1494. }
  1495. }
  1496. workloadDialogVisible.value = true
  1497. }
  1498. // 校验平台井设计工作量
  1499. const validatePlatformWellWorkloadDesign = (index) => {
  1500. const wellDetail = currentTask.value.platformWellDetails[index]
  1501. wellDetail.workloadDesignError = ''
  1502. const value = wellDetail.workloadDesign
  1503. if (value === '' || value === null || value === undefined) {
  1504. wellDetail.workloadDesignError = '设计工作量不能为空'
  1505. return false
  1506. }
  1507. const numValue = Number(value)
  1508. if (isNaN(numValue) || numValue < 0) {
  1509. wellDetail.workloadDesignError = '请填写大于0的数字'
  1510. return false
  1511. }
  1512. return true
  1513. }
  1514. /** 同步当前任务表单数据到表格数据 */
  1515. const syncCurrentTaskToTable = () => {
  1516. // 平台井模式特殊处理
  1517. if (currentTask.value.platformWell === '1') {
  1518. if (currentTask.value.platformWellDetails.length === 0) {
  1519. ElMessage.warning('请先添加平台井详情')
  1520. return false
  1521. }
  1522. // 验证平台井详情数据
  1523. const invalidDetails = currentTask.value.platformWellDetails.some(
  1524. (detail) => !detail.wellName || !detail.wellName.trim() || !detail.workloadDesign
  1525. )
  1526. if (invalidDetails) {
  1527. ElMessage.error('请完善平台井的井号和设计工作量信息')
  1528. return false
  1529. }
  1530. // 平台井模式:为每个平台井详情生成任务对象
  1531. const platformTasks = []
  1532. // 查找当前编辑的主任务对应的平台井详情
  1533. let mainTaskDetailIndex = -1
  1534. // 如果有当前任务ID,查找对应的平台井详情
  1535. if (currentTask.value.id) {
  1536. mainTaskDetailIndex = currentTask.value.platformWellDetails.findIndex(
  1537. (detail) => detail.taskId === currentTask.value.id
  1538. )
  1539. }
  1540. // 如果没有找到对应的详情,使用第一个详情作为主任务
  1541. if (mainTaskDetailIndex === -1 && currentTask.value.platformWellDetails.length > 0) {
  1542. mainTaskDetailIndex = 0
  1543. }
  1544. // 处理每个平台井详情
  1545. currentTask.value.platformWellDetails.forEach((detail, index) => {
  1546. // 获取当前井号的工作量数据
  1547. const workloadData = workloadMap.value.get(detail.wellName) || []
  1548. if (index === mainTaskDetailIndex) {
  1549. // 主任务:使用当前任务对象
  1550. currentTask.value.wellName = detail.wellName
  1551. currentTask.value.workloadDesign = detail.workloadDesign
  1552. currentTask.value.workloadUnit = detail.workloadUnit
  1553. // platformWell 保持为 '1' - 主平台井任务
  1554. currentTask.value.platformWell = '1'
  1555. platformTasks.push({ ...currentTask.value })
  1556. } else {
  1557. // 子任务:创建新的任务对象
  1558. const newTask = {
  1559. ...currentTask.value, // 拷贝所有属性
  1560. id: detail.taskId || undefined, // 已有任务使用taskId,新增任务为undefined
  1561. wellName: detail.wellName,
  1562. workloadDesign: detail.workloadDesign,
  1563. workloadUnit: detail.workloadUnit,
  1564. platformWell: detail.taskId ? '2' : '2' // 子任务platformWell设为2
  1565. }
  1566. // 移除不需要的属性
  1567. delete newTask.platformWellDetails
  1568. platformTasks.push(newTask)
  1569. }
  1570. })
  1571. // 设置项目ID
  1572. platformTasks.forEach((task) => {
  1573. task.projectId = formData.value.id
  1574. })
  1575. if (isNewTask.value) {
  1576. // 新增任务 - 为所有任务生成ID
  1577. let maxId =
  1578. tableData.value.length > 0 ? Math.max(...tableData.value.map((item) => item.id)) : 0
  1579. platformTasks.forEach((task) => {
  1580. maxId += 1
  1581. task.id = maxId
  1582. tableData.value.unshift({ ...task })
  1583. })
  1584. isNewTask.value = false
  1585. } else {
  1586. // 更新现有任务 - 比较复杂,需要先删除原有任务再添加新任务
  1587. // 这里简化处理:删除当前任务相关的所有平台井任务,然后重新添加
  1588. const currentTaskId = currentTask.value.id
  1589. tableData.value = tableData.value.filter((item) => item.id !== currentTaskId)
  1590. platformTasks.forEach((task) => {
  1591. tableData.value.unshift({ ...task })
  1592. })
  1593. }
  1594. return true
  1595. } else {
  1596. // 非平台井模式,验证原有字段
  1597. if (!currentTask.value.wellName) {
  1598. ElMessage.warning('请先填写任务详情')
  1599. return false
  1600. }
  1601. // 设置项目ID
  1602. currentTask.value.projectId = formData.value.id
  1603. if (isNewTask.value) {
  1604. // 新增任务 - 生成唯一ID并添加到表格
  1605. const newId =
  1606. tableData.value.length > 0 ? Math.max(...tableData.value.map((item) => item.id)) + 1 : 1
  1607. currentTask.value.id = newId
  1608. tableData.value.unshift({ ...currentTask.value })
  1609. isNewTask.value = false
  1610. } else {
  1611. // 更新现有任务
  1612. const index = tableData.value.findIndex((item) => item.id === currentTask.value.id)
  1613. if (index !== -1) {
  1614. tableData.value.splice(index, 1, { ...currentTask.value })
  1615. } else {
  1616. // 如果没有找到,添加到表格(可能是意外情况)
  1617. tableData.value.unshift({ ...currentTask.value })
  1618. }
  1619. }
  1620. return true
  1621. }
  1622. }
  1623. // 重置任务表单
  1624. const resetTaskForm = () => {
  1625. // 记录旧井号,用于清理Map
  1626. const oldWellName = currentTask.value.wellName
  1627. currentTask.value = {
  1628. id: undefined,
  1629. wellName: '',
  1630. wellType: '',
  1631. wellCategory: '',
  1632. location: '',
  1633. technique: '',
  1634. workloadDesign: '',
  1635. workloadUnit: '',
  1636. deptIds: [],
  1637. deviceIds: [],
  1638. responsiblePerson: [],
  1639. remark: '',
  1640. projectId: formData.value.id,
  1641. platformWell: '0', // 重置平台井状态
  1642. platformWellDetails: [], // 清空平台井详情
  1643. // 如果是特殊部门,初始化填报人字段
  1644. ...(isSpecialDept.value ? { submitter: [] } : {})
  1645. }
  1646. // 清理当前井号对应的Map数据
  1647. if (oldWellName) {
  1648. if (workloadMap.value.has(oldWellName)) {
  1649. workloadMap.value.delete(oldWellName)
  1650. }
  1651. if (workloadBackup.value.has(oldWellName)) {
  1652. workloadBackup.value.delete(oldWellName)
  1653. }
  1654. }
  1655. // 重新初始化动态属性
  1656. initDynamicAttrsToCurrentTask()
  1657. isNewTask.value = false
  1658. taskFormRef.value?.resetFields()
  1659. // 清除表单验证状态
  1660. nextTick(() => {
  1661. taskFormRef.value?.clearValidate()
  1662. })
  1663. }
  1664. // 获取已选的工作量单位(排除当前行) ==========
  1665. const getSelectedWorkloadUnits = (currentIndex) => {
  1666. if (!workloadList.value || workloadList.value.length === 0) {
  1667. return []
  1668. }
  1669. // 过滤当前行 + 空值,收集已选的单位
  1670. return workloadList.value
  1671. .filter((_, index) => index !== currentIndex)
  1672. .map((item) => item.workloadUnit)
  1673. .filter((unit) => unit && unit.trim() !== '')
  1674. }
  1675. // 处理行点击事件
  1676. const handleRowClick = (row, index) => {
  1677. if (row) {
  1678. currentTask.value = { ...row }
  1679. currentEditingIndex.value = index // 保存当前编辑的行索引
  1680. isNewTask.value = false
  1681. }
  1682. }
  1683. // 设备过滤方法
  1684. const filterDeviceMethod = (query: string, item: IotDeviceVO) => {
  1685. if (!query) return true
  1686. const searchText = query.toLowerCase()
  1687. const deviceCode = (item.deviceCode || '').toLowerCase()
  1688. const deviceName = (item.deviceName || '').toLowerCase()
  1689. // 同时匹配设备编码和设备名称
  1690. return deviceCode.includes(searchText) || deviceName.includes(searchText)
  1691. }
  1692. // 根据责任人ID获取责任人名称
  1693. const getResponsiblePersonNames = (responsiblePersonIds: number[]) => {
  1694. if (!responsiblePersonIds || responsiblePersonIds.length === 0) return ''
  1695. // 获取所有有效责任人名称
  1696. const personNames = responsiblePersonIds
  1697. .map((id) => {
  1698. const person = responsiblePersonList.value.find((p) => p.id === id)
  1699. return person ? person.nickname : ''
  1700. })
  1701. .filter((name) => name !== undefined && name !== '')
  1702. if (personNames.length === 0) return ''
  1703. // 如果责任人数量超过2个,显示前两个加省略号
  1704. if (personNames.length > 2) {
  1705. return `${personNames[0]}, ${personNames[1]}...`
  1706. }
  1707. // 责任人数量不超过2个,正常显示所有
  1708. return personNames.join(', ')
  1709. }
  1710. // 获取所有责任人名称(用于tooltip提示)
  1711. const getAllResponsiblePersonNames = (responsiblePersonIds: number[]) => {
  1712. if (!responsiblePersonIds || responsiblePersonIds.length === 0) return '无责任人'
  1713. const personNames = responsiblePersonIds
  1714. .map((id) => {
  1715. const person = responsiblePersonList.value.find((p) => p.id === id)
  1716. return person ? person.nickname : '未知人员'
  1717. })
  1718. .filter((name) => name !== '未知人员')
  1719. return personNames.join(', ') || '无有效责任人'
  1720. }
  1721. // 获取所有设备名称(用于tooltip提示)
  1722. const getAllDeviceNames = (deviceIds: number[]) => {
  1723. if (!deviceIds || deviceIds.length === 0) return '无设备'
  1724. const deviceNames = deviceIds
  1725. .map((id) => deviceMap.value[id]?.deviceCode || '未知设备')
  1726. .filter((name) => name !== '未知设备')
  1727. return deviceNames.join(', ') || '无有效设备'
  1728. }
  1729. const companyName = ref('')
  1730. /** 打开弹窗 */
  1731. const open = async () => {
  1732. resetForm()
  1733. resetTaskForm()
  1734. hasDynamicAttrsFromTask.value = false // 重置标志
  1735. // 修改时,设置数据
  1736. if (id) {
  1737. formType.value = 'update'
  1738. formLoading.value = true
  1739. try {
  1740. queryParams.id = id
  1741. const data = await IotProjectTaskApi.getIotProjectTaskPage(queryParams)
  1742. tableData.value = data.list
  1743. const company = await IotOpeationFillApi.getOrgName(tableData.value[0].deptId)
  1744. companyName.value = company
  1745. // 收集所有设备ID
  1746. const allDeviceIds = new Set<number>()
  1747. // 收集所有责任人ID
  1748. const allResponsiblePersonIds = new Set<number>()
  1749. // 收集所有填报人ID
  1750. const allSubmitterIds = new Set<number>()
  1751. data.list.forEach((item) => {
  1752. if (item.deviceIds?.length) {
  1753. item.deviceIds.forEach((id) => allDeviceIds.add(id))
  1754. }
  1755. if (item.responsiblePerson?.length) {
  1756. item.responsiblePerson.forEach((id) => allResponsiblePersonIds.add(id))
  1757. }
  1758. if (item.submitter?.length) {
  1759. item.submitter.forEach((id) => allSubmitterIds.add(id))
  1760. }
  1761. })
  1762. // 批量获取设备信息
  1763. if (allDeviceIds.size > 0) {
  1764. const deviceIdsArray = Array.from(allDeviceIds)
  1765. const devices = await IotDeviceApi.getDevicesByDepts({
  1766. deviceIds: deviceIdsArray
  1767. })
  1768. // 更新设备列表和映射表
  1769. deviceList.value = devices
  1770. deviceMap.value = {}
  1771. devices.forEach((device) => {
  1772. deviceMap.value[device.id] = device
  1773. })
  1774. }
  1775. // 批量获取责任人信息
  1776. if (allResponsiblePersonIds.size > 0) {
  1777. const personIdsArray = Array.from(allResponsiblePersonIds)
  1778. const params = {
  1779. userIds: personIdsArray
  1780. }
  1781. const persons = await UserApi.companyDeptsEmployee(params)
  1782. // 更新责任人列表
  1783. responsiblePersonList.value = persons
  1784. }
  1785. // 批量获取填报人信息
  1786. if (allSubmitterIds.size > 0) {
  1787. const personIdsArray = Array.from(allSubmitterIds)
  1788. const params = {
  1789. userIds: personIdsArray
  1790. }
  1791. const persons = await UserApi.companyDeptsEmployee(params)
  1792. // 更新责任人列表
  1793. submitterList.value = persons
  1794. }
  1795. if (tableData.value && tableData.value.length > 0) {
  1796. // 使用深拷贝,避免修改表单时直接影响表格数据
  1797. currentTask.value = JSON.parse(JSON.stringify(tableData.value[0]))
  1798. isNewTask.value = false
  1799. // 如果当前任务有施工队伍,立即查询设备并更新 hasDevicesAvailable
  1800. if (currentTask.value.deptIds && currentTask.value.deptIds.length > 0) {
  1801. try {
  1802. const params = {
  1803. deptIds: currentTask.value.deptIds,
  1804. deptId: deptId.value
  1805. }
  1806. const deviceData = await IotDeviceApi.getDevicesByDepts(params)
  1807. // 更新 hasDevicesAvailable 状态
  1808. hasDevicesAvailable.value = deviceData && deviceData.length > 0
  1809. // 更新设备列表和映射表(如果有设备)
  1810. if (hasDevicesAvailable.value) {
  1811. deviceList.value = deviceData
  1812. deviceMap.value = {}
  1813. deviceData.forEach((device) => {
  1814. deviceMap.value[device.id] = device
  1815. })
  1816. }
  1817. } catch (error) {
  1818. console.error('初始化查询设备失败:', error)
  1819. hasDevicesAvailable.value = false
  1820. }
  1821. } else {
  1822. // 如果没有施工队伍,默认没有设备可用
  1823. hasDevicesAvailable.value = false
  1824. }
  1825. // 处理平台井数据
  1826. // 将数字类型的 platformWell 转换为字符串类型
  1827. currentTask.value.platformWell = currentTask.value.platformWell?.toString() || '0'
  1828. // 如果 platformWell 为 1,处理 platformWells 数据
  1829. if (currentTask.value.platformWell === '1' && currentTask.value.platformWells) {
  1830. // 将 platformWells 映射到 platformWellDetails
  1831. currentTask.value.platformWellDetails = currentTask.value.platformWells.map(
  1832. (item: any) => ({
  1833. taskId: item.id,
  1834. wellName: item.wellName,
  1835. workloadUnit: item.workloadUnit || '', // 确保有workloadUnit字段
  1836. workloadDesign: item.workloadDesign || '',
  1837. workloadDesignError: '' // 新增错误信息字段
  1838. })
  1839. )
  1840. // 使用专门的排序方法
  1841. sortPlatformWellDetails()
  1842. // 初始化备份数据
  1843. platformWellDetailsBackup.value = [...currentTask.value.platformWellDetails]
  1844. // 处理每个平台井的工作量数据
  1845. processPlatformWellWorkloadData(currentTask.value.platformWells)
  1846. } else {
  1847. // 非平台井模式,确保 platformWellDetails 是数组
  1848. currentTask.value.platformWellDetails = currentTask.value.platformWellDetails || []
  1849. platformWellDetailsBackup.value = []
  1850. // 处理非平台井的工作量数据
  1851. if (currentTask.value.extProperty?.[0]?.dropdownList) {
  1852. processWorkloadDataForWell(
  1853. currentTask.value.wellName,
  1854. currentTask.value.extProperty[0].dropdownList
  1855. )
  1856. }
  1857. }
  1858. // 检查任务数据中是否有extProperty
  1859. if (tableData.value[0].extProperty && tableData.value[0].extProperty.length > 0) {
  1860. // 使用任务数据中的extProperty作为动态属性
  1861. dynamicAttrs.value = tableData.value[0].extProperty
  1862. hasDynamicAttrsFromTask.value = true
  1863. // 将extProperty中的值设置到当前任务
  1864. tableData.value[0].extProperty.forEach((attr) => {
  1865. if (attr.identifier) {
  1866. // 优先使用actualValue,如果没有则使用defaultValue
  1867. currentTask.value[attr.identifier] =
  1868. attr.actualValue !== undefined &&
  1869. attr.actualValue !== null &&
  1870. attr.actualValue !== ''
  1871. ? attr.actualValue
  1872. : attr.defaultValue || ''
  1873. }
  1874. })
  1875. }
  1876. const attachments = tableData.value[0].attachments || []
  1877. constructionFiles.value = attachments
  1878. .filter((item) => item.type === 'CONSTRUCTION_DESIGN')
  1879. .map((item) => ({
  1880. name: item.filename,
  1881. percentage: 100,
  1882. response: { data: item },
  1883. status: 'success',
  1884. uid: item.createTime
  1885. }))
  1886. geologicalFiles.value = attachments
  1887. .filter((item) => item.type === 'GEOLOGICAL_DESIGN')
  1888. .map((item) => ({
  1889. name: item.filename,
  1890. percentage: 100,
  1891. response: { data: item },
  1892. status: 'success',
  1893. uid: item.createTime
  1894. }))
  1895. completionFiles.value = attachments
  1896. .filter((item) => item.type === 'COMPLETION_DESIGN')
  1897. .map((item) => ({
  1898. name: item.filename,
  1899. percentage: 100,
  1900. response: { data: item },
  1901. status: 'success',
  1902. uid: item.createTime
  1903. }))
  1904. }
  1905. } finally {
  1906. formLoading.value = false
  1907. }
  1908. } else {
  1909. formType.value = 'create'
  1910. // 初始化备份数据
  1911. platformWellDetailsBackup.value = []
  1912. }
  1913. // 如果有projectId参数,自动选中对应的合同
  1914. if (projectId.value) {
  1915. autoSelectContract(projectId.value)
  1916. }
  1917. }
  1918. defineExpose({ open }) // 提供 open 方法,用于打开弹窗
  1919. // 获取平台井已选的工作量单位(排除当前行)
  1920. const getPlatformWellWorkloadUnits = (currentIndex) => {
  1921. if (
  1922. !currentTask.value.platformWellDetails ||
  1923. currentTask.value.platformWellDetails.length === 0
  1924. ) {
  1925. return []
  1926. }
  1927. // 获取当前井号的井名
  1928. const currentWellName = currentTask.value.platformWellDetails[currentIndex]?.wellName
  1929. if (!currentWellName) {
  1930. return []
  1931. }
  1932. // 从workloadMap中获取当前井号的工作量列表
  1933. const currentWellWorkloadList = workloadMap.value.get(currentWellName) || []
  1934. return currentWellWorkloadList
  1935. .filter((_, index) => index !== 0)
  1936. .map((item) => item.workloadUnit)
  1937. .filter((unit) => unit && unit.trim() !== '')
  1938. }
  1939. /** 自动选择合同 */
  1940. const autoSelectContract = async (projectId: string) => {
  1941. console.log('项目id:' + projectId)
  1942. // 查找匹配的合同
  1943. const project = projectList.value.find((item) => item.id === Number(projectId))
  1944. if (project) {
  1945. // 设置选中值
  1946. formData.value.contractId = project.id
  1947. // 触发合同信息加载
  1948. getProjectInfo(project.id)
  1949. } else {
  1950. ElMessage.warning('未找到指定的合同信息')
  1951. }
  1952. }
  1953. /** 校验所有行数据 */
  1954. const validateAllRows = (): boolean => {
  1955. // 判断任务列表是否为空
  1956. if (!tableData.value || tableData.value.length === 0) {
  1957. ElMessage.error('没有任务数据,无法保存')
  1958. return false
  1959. }
  1960. let allValid = true
  1961. tableData.value.forEach((row) => {
  1962. if (!row.wellName || row.wellName.trim() === '') {
  1963. allValid = false
  1964. }
  1965. // 对于平台井模式下的后续任务,platformWell为0,但wellName和workloadDesign仍需验证
  1966. if (!row.workloadDesign) {
  1967. allValid = false
  1968. }
  1969. if (!row.location || row.location.trim() === '') {
  1970. allValid = false
  1971. }
  1972. if (!row.technique || row.technique.trim() === '') {
  1973. allValid = false
  1974. }
  1975. if (!row.deptIds || row.deptIds.length === 0) {
  1976. allValid = false
  1977. }
  1978. // 修改:只有当有设备可用时才验证设备字段
  1979. if (hasDevicesAvailable.value && (!row.deviceIds || row.deviceIds.length === 0)) {
  1980. allValid = false
  1981. }
  1982. if (!row.responsiblePerson || row.responsiblePerson.length === 0) {
  1983. allValid = false
  1984. }
  1985. // 如果是特殊部门,验证填报人
  1986. if (isSpecialDept.value && (!row.submitter || row.submitter.length === 0)) {
  1987. allValid = false
  1988. }
  1989. })
  1990. if (!allValid) {
  1991. ElMessage.error('请检查表格中的数据,部分必填项未填写或格式不正确')
  1992. }
  1993. return allValid
  1994. }
  1995. // 添加表单专用的格式化方法
  1996. // 格式化设备显示(用于表单)
  1997. const formatDevicesForForm = (deviceIds: number[]) => {
  1998. if (!deviceIds || deviceIds.length === 0) return ''
  1999. const deviceInfos = deviceIds
  2000. .map((id) => {
  2001. const device = deviceMap.value[id]
  2002. return device ? `${device.deviceCode}-${device.deviceName}` : ''
  2003. })
  2004. .filter((info) => info !== '')
  2005. if (deviceInfos.length === 0) return ''
  2006. return deviceInfos.join(', ')
  2007. }
  2008. // 获取所有设备名称(用于表单的tooltip)
  2009. const getAllDeviceNamesForForm = (deviceIds: number[]) => {
  2010. if (!deviceIds || deviceIds.length === 0) return '无设备'
  2011. const deviceInfos = deviceIds
  2012. .map((id) => {
  2013. const device = deviceMap.value[id]
  2014. return device ? `${device.deviceCode}-${device.deviceName}` : '未知设备'
  2015. })
  2016. .filter((info) => info !== '未知设备')
  2017. return deviceInfos.join(', ') || '无有效设备'
  2018. }
  2019. // 格式化责任人显示(用于表单)
  2020. const formatResponsiblePersonsForForm = (responsiblePersonIds: number[]) => {
  2021. if (!responsiblePersonIds || responsiblePersonIds.length === 0) return ''
  2022. const personNames = responsiblePersonIds
  2023. .map((id) => {
  2024. const person = responsiblePersonList.value.find((p) => p.id === id)
  2025. return person ? person.nickname : ''
  2026. })
  2027. .filter((name) => name !== undefined && name !== '')
  2028. if (personNames.length === 0) return ''
  2029. return personNames.join(', ')
  2030. }
  2031. // 获取任务的工作量dropdownList数据
  2032. const getWorkloadDropdownListForTask = (task: any) => {
  2033. const dropdownList = []
  2034. // 从workloadMap中获取当前任务井号的工作量数据
  2035. const workloadItems = workloadMap.value.get(task.wellName) || []
  2036. if (workloadItems.length > 0) {
  2037. // 如果workloadMap中有数据,使用workloadMap的数据
  2038. workloadItems.forEach((item) => {
  2039. if (item.workloadUnit && item.workloadDesign) {
  2040. // 获取工作量单位的标签
  2041. const unitOptions = getStrDictOptions(DICT_TYPE.PMS_PROJECT_WORKLOAD_UNIT)
  2042. const unitLabel =
  2043. unitOptions.find((opt) => opt.value === item.workloadUnit)?.label || item.workloadUnit
  2044. dropdownList.push({
  2045. name: unitLabel, // 工作量单位名称
  2046. value: item.workloadDesign // 工作量值
  2047. })
  2048. }
  2049. })
  2050. } else {
  2051. // 【新增】如果workloadMap中没有数据,使用任务本身的工作量数据(直接从表格行中填写的数据)
  2052. if (task.workloadUnit && task.workloadDesign) {
  2053. const unitOptions = getStrDictOptions(DICT_TYPE.PMS_PROJECT_WORKLOAD_UNIT)
  2054. const unitLabel =
  2055. unitOptions.find((opt) => opt.value === task.workloadUnit)?.label || task.workloadUnit
  2056. dropdownList.push({
  2057. name: unitLabel,
  2058. value: task.workloadDesign
  2059. })
  2060. }
  2061. }
  2062. return dropdownList
  2063. }
  2064. // 平台井工作量加号按钮禁用状态
  2065. const getPlatformWellWorkloadAddBtnDisabled = (index) => {
  2066. const wellDetail = currentTask.value.platformWellDetails[index]
  2067. return !wellDetail.workloadUnit || !!wellDetail.workloadDesignError
  2068. }
  2069. // 格式化填报人显示(用于表单)
  2070. const formatSubmittersForForm = (submitterIds: number[]) => {
  2071. if (!submitterIds || submitterIds.length === 0) return ''
  2072. const personNames = submitterIds
  2073. .map((id) => {
  2074. const person = submitterList.value.find((p) => p.id === id)
  2075. return person ? person.nickname : ''
  2076. })
  2077. .filter((name) => name !== undefined && name !== '')
  2078. if (personNames.length === 0) return ''
  2079. return personNames.join(', ')
  2080. }
  2081. // 获取所有责任人名称(用于表单的tooltip)
  2082. const getAllResponsiblePersonNamesForForm = (responsiblePersonIds: number[]) => {
  2083. if (!responsiblePersonIds || responsiblePersonIds.length === 0) return '无责任人'
  2084. const personNames = responsiblePersonIds
  2085. .map((id) => {
  2086. const person = responsiblePersonList.value.find((p) => p.id === id)
  2087. return person ? person.nickname : '未知人员'
  2088. })
  2089. .filter((name) => name !== '未知人员')
  2090. return personNames.join(', ') || '无有效责任人'
  2091. }
  2092. // 获取所有填报人名称(用于表单的tooltip)
  2093. const getAllSubmitterNamesForForm = (submitterIds: number[]) => {
  2094. if (!submitterIds || submitterIds.length === 0) return '无填报人'
  2095. const personNames = submitterIds
  2096. .map((id) => {
  2097. const person = submitterList.value.find((p) => p.id === id)
  2098. return person ? person.nickname : '未知人员'
  2099. })
  2100. .filter((name) => name !== '未知人员')
  2101. return personNames.join(', ') || '无有效填报人'
  2102. }
  2103. /** 提交表单 */
  2104. const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
  2105. // 处理平台井工作量数据
  2106. const processPlatformWellWorkloadData = (platformWells: any[]) => {
  2107. if (!platformWells || !platformWells.length) return
  2108. platformWells.forEach((well: any) => {
  2109. if (well.wellName && well.extProperty?.[0]?.dropdownList) {
  2110. processWorkloadDataForWell(well.wellName, well.extProperty[0].dropdownList)
  2111. }
  2112. })
  2113. }
  2114. // 处理单个井的工作量数据
  2115. const processWorkloadDataForWell = (wellName: string, dropdownList: any[]) => {
  2116. if (!wellName || !dropdownList || !dropdownList.length) return
  2117. // 转换dropdownList格式为workloadMap需要的格式
  2118. const workloadData = dropdownList.map((item) => ({
  2119. workloadUnit: getWorkloadUnitValueByName(item.name), // 通过name获取对应的value
  2120. workloadDesign: item.value
  2121. }))
  2122. // 存储到workloadMap
  2123. workloadMap.value.set(wellName, workloadData)
  2124. // 如果这个井在platformWellDetails中,更新其工作量单位和工作量设计
  2125. if (currentTask.value.platformWellDetails) {
  2126. const detailIndex = currentTask.value.platformWellDetails.findIndex(
  2127. (detail: any) => detail.wellName === wellName
  2128. )
  2129. if (detailIndex !== -1 && workloadData.length > 0) {
  2130. // 使用第一个工作量项作为平台井表格中显示的值
  2131. currentTask.value.platformWellDetails[detailIndex].workloadUnit = workloadData[0].workloadUnit
  2132. currentTask.value.platformWellDetails[detailIndex].workloadDesign =
  2133. workloadData[0].workloadDesign
  2134. }
  2135. }
  2136. // 如果是主任务井,也更新当前任务的工作量数据
  2137. if (wellName === currentTask.value.wellName && workloadData.length > 0) {
  2138. currentTask.value.workloadUnit = workloadData[0].workloadUnit
  2139. currentTask.value.workloadDesign = workloadData[0].workloadDesign
  2140. }
  2141. }
  2142. // 通过工作量单位名称获取对应的值
  2143. const getWorkloadUnitValueByName = (name: string): string => {
  2144. const options = getStrDictOptions(DICT_TYPE.PMS_PROJECT_WORKLOAD_UNIT)
  2145. const option = options.find((opt) => opt.label === name)
  2146. return option ? option.value : ''
  2147. }
  2148. const submitForm = async () => {
  2149. // 施工区域的数据字典类型
  2150. currentTask.value.dictType = currentDictLabel.value
  2151. // 先校验设计工作量
  2152. if (currentTask.value.platformWell !== '1' && !validateWorkloadDesign()) {
  2153. ElMessage.error('请完善设计工作量信息')
  2154. return
  2155. }
  2156. // 在同步任务前,确保平台井关联井的工作量数据正确设置
  2157. if (currentTask.value.platformWell === '1') {
  2158. currentTask.value.platformWellDetails.forEach((detail) => {
  2159. // 如果该关联井在workloadMap中没有数据,但表格行中有工作量数据,则设置到workloadMap中
  2160. if (
  2161. detail.wellName &&
  2162. !workloadMap.value.has(detail.wellName) &&
  2163. detail.workloadUnit &&
  2164. detail.workloadDesign
  2165. ) {
  2166. workloadMap.value.set(detail.wellName, [
  2167. {
  2168. workloadUnit: detail.workloadUnit,
  2169. workloadDesign: detail.workloadDesign
  2170. }
  2171. ])
  2172. }
  2173. })
  2174. }
  2175. // 先同步当前任务表单数据到表格
  2176. if (!syncCurrentTaskToTable()) {
  2177. return
  2178. }
  2179. // 校验表单
  2180. await formRef.value.validate()
  2181. // 校验所有行数据
  2182. if (!validateAllRows()) {
  2183. return
  2184. }
  2185. const getFileType = (filename: string) => {
  2186. const ext = filename.split('.').pop()?.toLowerCase()
  2187. if (['jpg', 'jpeg', 'png', 'gif', 'bmp'].includes(ext || '')) {
  2188. return 'image'
  2189. } else if (['pdf'].includes(ext || '')) {
  2190. return 'pdf'
  2191. } else if (['doc', 'docx'].includes(ext || '')) {
  2192. return 'word'
  2193. } else if (['xls', 'xlsx'].includes(ext || '')) {
  2194. return 'excel'
  2195. } else {
  2196. return 'other'
  2197. }
  2198. }
  2199. const formatFileSize = (bytes: number) => {
  2200. if (bytes === 0) return '0 Bytes'
  2201. const k = 1024
  2202. const sizes = ['Bytes', 'KB', 'MB', 'GB']
  2203. const i = Math.floor(Math.log(bytes) / Math.log(k))
  2204. return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
  2205. }
  2206. function formatterAttachments(attachments: any[], type: string, taskId: number) {
  2207. return attachments.flatMap((item) => {
  2208. if (item.response.data.files) {
  2209. return item.response.data.files.map((file) => ({
  2210. category: 'DAILY_REPORT',
  2211. bizId: taskId,
  2212. filename: file.name || '未知文件',
  2213. fileType: getFileType(file.name),
  2214. filePath: file.filePath,
  2215. fileSize: formatFileSize(file.size || 0),
  2216. remark: '',
  2217. type
  2218. }))
  2219. } else return item.response.data
  2220. })
  2221. }
  2222. // 处理动态属性数据
  2223. const processedTableData = tableData.value.map((task) => {
  2224. // 获取当前任务的工作量数据并转换为dropdownList格式
  2225. const workloadDropdownList = getWorkloadDropdownListForTask(task)
  2226. // 为每个任务构建extProperty数组
  2227. const extProperties = dynamicAttrs.value.map((attr) => {
  2228. return {
  2229. name: attr.name,
  2230. sort: attr.sort,
  2231. unit: attr.unit,
  2232. actualValue: task[attr.identifier] || '', // 从任务中获取用户填写的值
  2233. dataType: attr.dataType,
  2234. maxValue: attr.maxValue,
  2235. minValue: attr.minValue,
  2236. required: attr.required,
  2237. accessMode: attr.accessMode,
  2238. identifier: attr.identifier,
  2239. defaultValue: attr.defaultValue,
  2240. // 添加dropdownList到任务对象中
  2241. dropdownList: workloadDropdownList
  2242. }
  2243. })
  2244. // 返回处理后的任务数据,包含extProperty字段
  2245. return {
  2246. ...task,
  2247. dictType: task.dictType || currentDictLabel.value, // 确保每个任务都有dictType
  2248. extProperty: extProperties,
  2249. attachments: formatterAttachments(constructionFiles.value, 'CONSTRUCTION_DESIGN', task.id)
  2250. .concat(formatterAttachments(geologicalFiles.value, 'GEOLOGICAL_DESIGN', task.id))
  2251. .concat(formatterAttachments(completionFiles.value, 'COMPLETION_REPORT', task.id))
  2252. }
  2253. })
  2254. // 提交请求
  2255. formLoading.value = true
  2256. try {
  2257. tableData.value.forEach((item) => {
  2258. item.projectId = formData.value.id
  2259. })
  2260. const data = {
  2261. taskList: processedTableData
  2262. }
  2263. if (formType.value === 'create') {
  2264. await IotProjectTaskApi.createIotProjectTask(data)
  2265. message.success(t('common.createSuccess'))
  2266. } else {
  2267. await IotProjectTaskApi.updateIotProjectTask(data)
  2268. message.success(t('common.updateSuccess'))
  2269. }
  2270. // 发送操作成功的事件
  2271. emit('success')
  2272. close()
  2273. } finally {
  2274. formLoading.value = false
  2275. }
  2276. }
  2277. // 判断是否为主要的平台井详情(不能删除)
  2278. const isMainPlatformWellDetail = (index: number) => {
  2279. if (
  2280. !currentTask.value.platformWellDetails ||
  2281. currentTask.value.platformWellDetails.length === 0
  2282. ) {
  2283. return false
  2284. }
  2285. const detail = currentTask.value.platformWellDetails[index]
  2286. // 主记录的条件:是第一条记录且有关联的任务ID,或者是自动从非平台井转换过来的主记录
  2287. return (
  2288. index === 0 &&
  2289. (detail.taskId === currentTask.value.id ||
  2290. (detail.wellName === currentTask.value.wellName &&
  2291. detail.workloadDesign === currentTask.value.workloadDesign))
  2292. )
  2293. }
  2294. // 处理平台井开关变化
  2295. const handlePlatformWellChange = (value) => {
  2296. if (value === '1') {
  2297. // 切换到平台井模式前,备份当前井号的工作量数据
  2298. if (currentTask.value.wellName) {
  2299. const currentWorkload = workloadMap.value.get(currentTask.value.wellName)
  2300. if (currentWorkload) {
  2301. workloadBackup.value.set(currentTask.value.wellName, [...currentWorkload])
  2302. }
  2303. }
  2304. // 检查是否是从非平台井切换过来,且当前任务有井号信息
  2305. const hasWellName = currentTask.value.wellName && currentTask.value.wellName.trim() !== ''
  2306. const hasWorkloadDesign = currentTask.value.workloadDesign
  2307. if (hasWellName && hasWorkloadDesign) {
  2308. // 从非平台井切换到平台井,自动添加一条记录
  2309. const mainDetail = {
  2310. taskId: currentTask.value.id, // 关联当前任务ID
  2311. wellName: currentTask.value.wellName,
  2312. workloadUnit: currentTask.value.workloadUnit, // 同步工作量单位
  2313. workloadDesign: currentTask.value.workloadDesign,
  2314. workloadDesignError: ''
  2315. }
  2316. // 如果workloadMap中有主井数据,同步到平台井表格
  2317. if (workloadMap.value.has(currentTask.value.wellName)) {
  2318. const workloadData = workloadMap.value.get(currentTask.value.wellName)
  2319. if (workloadData && workloadData.length > 0) {
  2320. mainDetail.workloadUnit = workloadData[0].workloadUnit
  2321. mainDetail.workloadDesign = workloadData[0].workloadDesign
  2322. }
  2323. }
  2324. // 清空现有详情,添加主记录
  2325. currentTask.value.platformWellDetails = [mainDetail]
  2326. } else {
  2327. // 恢复之前保存的数据或初始化
  2328. if (platformWellDetailsBackup.value.length > 0) {
  2329. currentTask.value.platformWellDetails = [...platformWellDetailsBackup.value]
  2330. sortPlatformWellDetails()
  2331. } else {
  2332. addPlatformWellDetail()
  2333. }
  2334. }
  2335. // 更新备份数据
  2336. platformWellDetailsBackup.value = [...currentTask.value.platformWellDetails]
  2337. } else {
  2338. // 如果有平台井详情,将第一个详情的数据设置回主任务
  2339. if (currentTask.value.platformWellDetails.length > 0) {
  2340. const mainDetail = currentTask.value.platformWellDetails[0]
  2341. currentTask.value.wellName = mainDetail.wellName || ''
  2342. currentTask.value.workloadDesign = mainDetail.workloadDesign || ''
  2343. // 恢复工作量数据
  2344. if (mainDetail.wellName && workloadBackup.value.has(mainDetail.wellName)) {
  2345. const backupWorkload = workloadBackup.value.get(mainDetail.wellName)
  2346. if (backupWorkload && backupWorkload.length > 0) {
  2347. workloadMap.value.set(mainDetail.wellName, [...backupWorkload])
  2348. // 恢复表单中的工作量单位(取第一项)
  2349. currentTask.value.workloadUnit = backupWorkload[0].workloadUnit
  2350. currentTask.value.workloadDesign = backupWorkload[0].workloadDesign
  2351. }
  2352. }
  2353. }
  2354. // 切换到非平台井模式,保存当前数据到备份
  2355. platformWellDetailsBackup.value = [...currentTask.value.platformWellDetails]
  2356. // 切换到非平台井模式,清空详情列表
  2357. currentTask.value.platformWellDetails = []
  2358. }
  2359. }
  2360. // 校验工作量对话框中的设计工作量
  2361. const validateWorkloadDialogDesign = (index) => {
  2362. const workloadItem = workloadList.value[index]
  2363. workloadItem.workloadDesignError = ''
  2364. const value = workloadItem.workloadDesign
  2365. if (value === '' || value === null || value === undefined) {
  2366. workloadItem.workloadDesignError = '设计工作量不能为空'
  2367. return false
  2368. }
  2369. const numValue = Number(value)
  2370. if (isNaN(numValue) || numValue < 0) {
  2371. workloadItem.workloadDesignError = '请填写大于0的数字'
  2372. return false
  2373. }
  2374. return true
  2375. }
  2376. // 获取表单中已选的工作量单位(来自workloadMap)
  2377. const getFormSelectedWorkloadUnits = () => {
  2378. // 兼容普通井/平台井的井号获取逻辑(与工作量弹窗逻辑一致)
  2379. let currentWellName = ''
  2380. if (currentTask.value.platformWell === '1') {
  2381. // 平台井:取主井号(优先当前任务wellName,其次取平台井详情第一个)
  2382. currentWellName =
  2383. currentTask.value.wellName ||
  2384. (currentTask.value.platformWellDetails.length > 0
  2385. ? currentTask.value.platformWellDetails[0].wellName
  2386. : '')
  2387. } else {
  2388. // 普通井:直接取当前任务井号
  2389. currentWellName = currentTask.value.wellName
  2390. }
  2391. // 从Map中获取当前井号的工作量列表,提取已选单位
  2392. const workloadList = workloadMap.value.get(currentWellName) || []
  2393. return workloadList.map((item) => item.workloadUnit).filter((unit) => unit && unit.trim() !== '') // 过滤空值
  2394. }
  2395. // 添加平台井详情行
  2396. const addPlatformWellDetail = () => {
  2397. const newDetail = {
  2398. taskId: '',
  2399. wellName: '',
  2400. workloadUnit: '', // 新增工作量单位字段
  2401. workloadDesign: '',
  2402. workloadDesignError: '' // 新增错误信息字段
  2403. }
  2404. // 将新记录添加到数组末尾,而不是开头
  2405. currentTask.value.platformWellDetails.push(newDetail)
  2406. }
  2407. // 删除平台井详情行
  2408. const removePlatformWellDetail = (index: number) => {
  2409. // 获取被删除的井号,清理Map
  2410. const removedDetail = currentTask.value.platformWellDetails[index]
  2411. if (removedDetail.wellName && workloadMap.value.has(removedDetail.wellName)) {
  2412. workloadMap.value.delete(removedDetail.wellName)
  2413. }
  2414. currentTask.value.platformWellDetails.splice(index, 1)
  2415. // 删除后重新排序
  2416. sortPlatformWellDetails()
  2417. }
  2418. // 平台井详情排序方法
  2419. const sortPlatformWellDetails = () => {
  2420. if (
  2421. !currentTask.value.platformWellDetails ||
  2422. currentTask.value.platformWellDetails.length === 0
  2423. ) {
  2424. return
  2425. }
  2426. currentTask.value.platformWellDetails.sort((a, b) => {
  2427. // 主记录(关联当前任务ID或从非平台井转换过来的记录)排在最前面
  2428. const aIsMain = a.taskId === currentTask.value.id
  2429. const bIsMain = b.taskId === currentTask.value.id
  2430. if (aIsMain && !bIsMain) return -1
  2431. if (!aIsMain && bIsMain) return 1
  2432. // 其他记录保持原有顺序
  2433. return 0
  2434. })
  2435. }
  2436. /** 重置表单 */
  2437. const resetForm = () => {
  2438. formData.value = {
  2439. id: undefined,
  2440. contractId: undefined,
  2441. contractName: undefined,
  2442. contractCode: undefined,
  2443. workloadTotal: undefined,
  2444. workloadFinish: undefined,
  2445. workloadUnit: undefined,
  2446. startTime: undefined,
  2447. endTime: undefined,
  2448. location: undefined,
  2449. technique: undefined,
  2450. payment: undefined,
  2451. remark: undefined,
  2452. manufactureName: undefined,
  2453. manufacturerId: undefined,
  2454. userName: undefined,
  2455. userId: undefined
  2456. }
  2457. formRef.value?.resetFields()
  2458. }
  2459. // 加载工作区域选项的方法
  2460. const loadWorkAreaOptions = async (deptId: number) => {
  2461. // 如果正在加载,直接返回
  2462. if (loadingWorkAreaOptions.value) return
  2463. loadingWorkAreaOptions.value = true
  2464. try {
  2465. // 先尝试通过 getDictLabel 获取字典标签
  2466. const dictLabel = await getDictLabel(DICT_TYPE.PMS_PROJECT_WORK_AREA, deptId)
  2467. console.log('当前专业公司的施工区域数据字典类型:' + dictLabel)
  2468. // 将 dictLabel 存储到 currentDictLabel
  2469. currentDictLabel.value = dictLabel || '' // 如果没有获取到,设为空字符串
  2470. if (dictLabel) {
  2471. // 如果获取到标签,再获取完整的字典选项
  2472. const dictOptions = getStrDictOptions(dictLabel)
  2473. console.log('当前专业公司的施工区域数据字典集合长度:' + dictOptions.length)
  2474. workAreaOptions.value = dictOptions.map((option) => ({
  2475. value: option.label, // 使用标签作为显示值
  2476. id: option.value // 保留原始值
  2477. }))
  2478. } else {
  2479. // 如果获取不到标签,清空选项
  2480. workAreaOptions.value = []
  2481. }
  2482. } catch (error) {
  2483. console.error('获取工作区域选项失败:', error)
  2484. workAreaOptions.value = []
  2485. } finally {
  2486. loadingWorkAreaOptions.value = false
  2487. }
  2488. }
  2489. // 当没有查询字符串时返回所有选项
  2490. const querySearch = (queryString: string, cb: any) => {
  2491. // 如果没有查询字符串,返回所有选项
  2492. if (!queryString) {
  2493. cb(workAreaOptions.value)
  2494. return
  2495. }
  2496. // 有查询字符串时进行筛选
  2497. const results = workAreaOptions.value.filter((option) =>
  2498. option.value.toLowerCase().includes(queryString.toLowerCase())
  2499. )
  2500. // 调用 callback 返回建议列表的数据
  2501. cb(results)
  2502. }
  2503. // 添加处理施工区域获取焦点的方法
  2504. const handleWorkAreaFocus = async () => {
  2505. // 如果已经有选项数据,直接显示下拉框
  2506. if (workAreaOptions.value.length > 0) {
  2507. // 使用Element Plus提供的方法触发下拉框
  2508. try {
  2509. // 直接调用el-autocomplete的focus方法
  2510. if (workAreaAutocomplete.value && typeof workAreaAutocomplete.value.focus === 'function') {
  2511. workAreaAutocomplete.value.focus()
  2512. }
  2513. } catch (error) {
  2514. console.error('触发下拉框显示失败:', error)
  2515. }
  2516. return
  2517. }
  2518. // 如果没有选项数据,尝试加载
  2519. if (formData.value.deptId && !loadingWorkAreaOptions.value) {
  2520. await loadWorkAreaOptions(formData.value.deptId)
  2521. // 加载完成后尝试显示下拉框
  2522. if (workAreaOptions.value.length > 0) {
  2523. try {
  2524. if (workAreaAutocomplete.value && typeof workAreaAutocomplete.value.focus === 'function') {
  2525. workAreaAutocomplete.value.focus()
  2526. }
  2527. } catch (error) {
  2528. console.error('触发下拉框显示失败:', error)
  2529. }
  2530. }
  2531. }
  2532. }
  2533. // 添加选择处理方法
  2534. const handleSelect = (item: any) => {
  2535. // 这里可以根据需要处理选择后的逻辑
  2536. console.log('选择了:', item.value)
  2537. }
  2538. // 加载施工工艺选项的方法
  2539. const loadTechnologyOptions = async (deptId: number) => {
  2540. if (loadingTechnologyOptions.value) return
  2541. loadingTechnologyOptions.value = true
  2542. try {
  2543. // 先尝试通过 getDictLabel 获取字典标签
  2544. const dictLabel = await getDictLabel(DICT_TYPE.PMS_PROJECT_TECHNOLOGY, deptId)
  2545. console.log('当前专业公司的施工工艺数据字典类型:' + dictLabel)
  2546. // 将 dictLabel 存储到 currentTechnologyDictLabel
  2547. currentTechnologyDictLabel.value = dictLabel || '' // 如果没有获取到,设为空字符串
  2548. if (dictLabel) {
  2549. // 如果获取到标签,再获取完整的字典选项
  2550. const dictOptions = getStrDictOptions(dictLabel)
  2551. console.log('当前专业公司的施工工艺数据字典集合长度:' + dictOptions.length)
  2552. technologyOptions.value = dictOptions.map((option) => ({
  2553. value: option.value,
  2554. label: option.label
  2555. }))
  2556. } else {
  2557. // 如果获取不到标签,清空选项
  2558. technologyOptions.value = []
  2559. }
  2560. } catch (error) {
  2561. console.error('获取施工工艺选项失败:', error)
  2562. technologyOptions.value = []
  2563. } finally {
  2564. loadingTechnologyOptions.value = false
  2565. }
  2566. }
  2567. // 工作量加号按钮禁用状态(计算属性)
  2568. const getWorkloadAddBtnDisabled = computed(() => {
  2569. // 禁用条件:无工作量单位 || 平台井模式 || 设计工作量校验失败
  2570. return (
  2571. !currentTask.value.workloadUnit ||
  2572. currentTask.value.platformWell === '1' ||
  2573. !!workloadDesignError.value
  2574. )
  2575. })
  2576. // 监听平台井状态变化,清空错误信息
  2577. watch(
  2578. () => currentTask.value.platformWell,
  2579. () => {
  2580. workloadDesignError.value = ''
  2581. }
  2582. )
  2583. // 监听工作量单位变化,同步更新到 workloadMap
  2584. watch(
  2585. () => currentTask.value.workloadUnit,
  2586. (newWorkloadUnit, oldWorkloadUnit) => {
  2587. if (!newWorkloadUnit || newWorkloadUnit === oldWorkloadUnit) return
  2588. // 获取当前井号(兼容普通井/平台井)
  2589. let currentWellName = ''
  2590. if (currentTask.value.platformWell === '1') {
  2591. currentWellName =
  2592. currentTask.value.wellName ||
  2593. (currentTask.value.platformWellDetails.length > 0
  2594. ? currentTask.value.platformWellDetails[0].wellName
  2595. : '')
  2596. } else {
  2597. currentWellName = currentTask.value.wellName
  2598. }
  2599. if (!currentWellName) return
  2600. // 如果workloadMap中存在当前井号的工作量数据,更新第一项的workloadUnit
  2601. if (workloadMap.value.has(currentWellName)) {
  2602. const workloadList = workloadMap.value.get(currentWellName)
  2603. if (workloadList && workloadList.length > 0) {
  2604. // 更新第一项的workloadUnit
  2605. workloadList[0].workloadUnit = newWorkloadUnit
  2606. // 重新设置到Map中(虽然引用相同,但为了确保响应性)
  2607. workloadMap.value.set(currentWellName, [...workloadList])
  2608. } else {
  2609. // 如果列表为空但有设计工作量,创建新项
  2610. if (currentTask.value.workloadDesign) {
  2611. workloadMap.value.set(currentWellName, [
  2612. {
  2613. workloadUnit: newWorkloadUnit,
  2614. workloadDesign: currentTask.value.workloadDesign
  2615. }
  2616. ])
  2617. }
  2618. }
  2619. } else if (currentTask.value.workloadDesign) {
  2620. // 如果Map中不存在但有设计工作量,创建新条目
  2621. workloadMap.value.set(currentWellName, [
  2622. {
  2623. workloadUnit: newWorkloadUnit,
  2624. workloadDesign: currentTask.value.workloadDesign
  2625. }
  2626. ])
  2627. }
  2628. },
  2629. { deep: true }
  2630. )
  2631. // 校验设计工作量
  2632. const validateWorkloadDesign = () => {
  2633. workloadDesignError.value = ''
  2634. if (currentTask.value.platformWell === '1') {
  2635. return true
  2636. }
  2637. const value = currentTask.value.workloadDesign
  2638. if (value === '' || value === null || value === undefined) {
  2639. workloadDesignError.value = '设计工作量不能为空'
  2640. return false
  2641. }
  2642. const numValue = Number(value)
  2643. if (isNaN(numValue) || numValue < 0) {
  2644. workloadDesignError.value = '请填写大于0的数字'
  2645. return false
  2646. }
  2647. return true
  2648. }
  2649. // 监听设计工作量变化
  2650. watch(
  2651. () => currentTask.value.workloadDesign,
  2652. () => {
  2653. if (workloadDesignError.value) {
  2654. validateWorkloadDesign()
  2655. }
  2656. }
  2657. )
  2658. // 监听当前任务的变化,设置默认展开的keys
  2659. watch(
  2660. () => currentTask.value.deptIds,
  2661. (newVal, oldVal) => {
  2662. if (newVal && newVal.length > 0) {
  2663. defaultExpandedKeys.value = [...newVal]
  2664. }
  2665. // 【新增】施工队伍变化时,重新查询设备并更新状态
  2666. const params = {
  2667. deptIds: newVal
  2668. }
  2669. /* IotDeviceApi.getDevicesByDepts(params).then(data => {
  2670. // 更新 hasDevicesAvailable 状态
  2671. hasDevicesAvailable.value = data && data.length > 0;
  2672. // 更新设备列表和映射表
  2673. if (hasDevicesAvailable.value) {
  2674. const newDeviceMap = {...deviceMap.value};
  2675. data.forEach(device => {
  2676. newDeviceMap[device.id] = device;
  2677. });
  2678. deviceMap.value = newDeviceMap;
  2679. }
  2680. }).catch(error => {
  2681. console.error('施工队伍变化时查询设备失败:', error);
  2682. hasDevicesAvailable.value = false;
  2683. }); */
  2684. if (!newVal || newVal.length === 0) {
  2685. // 清空施工队伍时,同时清空相关人员和设备
  2686. currentTask.value.responsiblePerson = []
  2687. currentTask.value.submitter = []
  2688. currentTask.value.deviceIds = []
  2689. // 重置设备可用状态
  2690. hasDevicesAvailable.value = true
  2691. // 清除相关字段的验证状态
  2692. nextTick(() => {
  2693. taskFormRef.value?.validateField('responsiblePerson')
  2694. taskFormRef.value?.validateField('submitter')
  2695. taskFormRef.value?.validateField('deviceIds')
  2696. })
  2697. } else if (newVal !== oldVal) {
  2698. // 施工队伍发生变化时,重置设备可用状态(因为不同队伍可能有不同的设备)
  2699. // hasDevicesAvailable.value = true;
  2700. }
  2701. },
  2702. { immediate: true, deep: true }
  2703. )
  2704. // 监听部门列表加载完成
  2705. watch(
  2706. () => deptList.value,
  2707. (newVal) => {
  2708. if (
  2709. newVal &&
  2710. newVal.length > 0 &&
  2711. currentTask.value.deptIds &&
  2712. currentTask.value.deptIds.length > 0
  2713. ) {
  2714. // defaultExpandedKeys.value = [...currentTask.value.deptIds];
  2715. // 过滤掉非叶子节点的ID,只保留叶子节点
  2716. const leafNodeIds = currentTask.value.deptIds.filter((id) => {
  2717. const node = findDeptNodeById(newVal, id)
  2718. return node && node.type === '3'
  2719. })
  2720. if (leafNodeIds.length > 0) {
  2721. defaultExpandedKeys.value = [...leafNodeIds]
  2722. }
  2723. }
  2724. },
  2725. { immediate: true, deep: true }
  2726. )
  2727. // 根据ID在部门树中查找节点
  2728. const findDeptNodeById = (tree: any[], id: number): any => {
  2729. for (const node of tree) {
  2730. if (node.id === id) {
  2731. return node
  2732. }
  2733. if (node.children && node.children.length > 0) {
  2734. const found = findDeptNodeById(node.children, id)
  2735. if (found) return found
  2736. }
  2737. }
  2738. return null
  2739. }
  2740. // 监听项目列表变化,确保列表加载完成后才执行自动选择
  2741. watch(projectList, (newVal) => {
  2742. if (newVal && newVal.length > 0) {
  2743. // 如果是编辑模式,使用任务数据中的合同ID
  2744. if (id && tableData.value.length > 0 && tableData.value[0].projectId) {
  2745. autoSelectContract(tableData.value[0].projectId.toString())
  2746. }
  2747. // 如果是新增模式且有传递的projectId,使用传递的projectId
  2748. else if (!id && projectId.value) {
  2749. console.log('watch-新增模式且有传递的projectId' + projectId.value + ' projectId not found')
  2750. autoSelectContract(projectId.value)
  2751. }
  2752. }
  2753. })
  2754. // 处理树形下拉框可见性变化
  2755. const handleTreeVisibleChange = (visible: boolean) => {
  2756. if (visible && currentTask.value.deptIds && currentTask.value.deptIds.length > 0) {
  2757. // 当下拉框显示且当前任务有已选部门时,设置默认展开的keys
  2758. defaultExpandedKeys.value = [...currentTask.value.deptIds]
  2759. // 使用nextTick确保DOM更新后再执行展开操作
  2760. nextTick(() => {
  2761. if (treeSelectRef.value) {
  2762. // 尝试访问内部树实例并展开节点
  2763. const treeInstance = treeSelectRef.value.treeRef
  2764. if (treeInstance && treeInstance.setExpandedKeys) {
  2765. treeInstance.setExpandedKeys(defaultExpandedKeys.value)
  2766. }
  2767. }
  2768. })
  2769. }
  2770. }
  2771. onMounted(async () => {
  2772. // 查询当前登录人所属公司下的所有部门
  2773. deptList.value = handleTree(await DeptApi.companyLevelChildrenDepts())
  2774. let deptId = useUserStore().getUser.deptId
  2775. projectList.value = await IotProjectInfoApi.getIotProjectInfoUser(deptId)
  2776. // 初始化时过滤当前任务中的部门ID,移除非叶子节点
  2777. if (currentTask.value.deptIds && currentTask.value.deptIds.length > 0) {
  2778. const validDeptIds = currentTask.value.deptIds.filter((id) => {
  2779. const node = findDeptNodeById(deptList.value, id)
  2780. return node && node.type === '3'
  2781. })
  2782. if (validDeptIds.length !== currentTask.value.deptIds.length) {
  2783. currentTask.value.deptIds = validDeptIds
  2784. }
  2785. }
  2786. // 查询当前任务已经选中的设备信息
  2787. open()
  2788. })
  2789. </script>
  2790. <style scoped>
  2791. @media (width <= 1200px) {
  2792. .task-edit-form :deep(.el-col-8) {
  2793. flex: 0 0 50%;
  2794. max-width: 50%;
  2795. }
  2796. .project-task-page .attachment-content {
  2797. grid-template-columns: minmax(0, 1fr);
  2798. gap: 0;
  2799. }
  2800. }
  2801. @media (width <= 768px) {
  2802. .project-task-page .page-header :deep(.el-card__body) {
  2803. align-items: flex-start;
  2804. }
  2805. .project-task-page .page-header__subtitle,
  2806. .project-task-page .section-heading__hint {
  2807. display: none;
  2808. }
  2809. .project-task-page .project-summary-form,
  2810. .project-task-page .task-edit-form {
  2811. padding-right: 12px;
  2812. padding-left: 12px;
  2813. }
  2814. .project-summary-form :deep(.el-col-12),
  2815. .task-edit-form :deep(.el-col-8),
  2816. .task-edit-form :deep(.el-col-12) {
  2817. flex: 0 0 100%;
  2818. max-width: 100%;
  2819. }
  2820. .project-task-page .transfer-component {
  2821. display: block;
  2822. }
  2823. .transfer-component :deep(.el-transfer-panel) {
  2824. width: 100% !important;
  2825. }
  2826. .transfer-component :deep(.el-transfer__buttons) {
  2827. display: flex;
  2828. justify-content: center;
  2829. padding: 12px 0;
  2830. }
  2831. }
  2832. .project-task-page {
  2833. display: flex;
  2834. flex-direction: column;
  2835. gap: 12px;
  2836. min-height: calc(
  2837. 100vh - 20px - var(--top-tool-height) - var(--tags-view-height) - var(--app-footer-height)
  2838. );
  2839. }
  2840. .page-header,
  2841. .project-summary-section,
  2842. .task-detail-section,
  2843. .attachment-section,
  2844. .platform-well-section {
  2845. margin-bottom: 0;
  2846. overflow: hidden;
  2847. border-radius: 8px;
  2848. }
  2849. .page-header :deep(.el-card__body) {
  2850. display: flex;
  2851. align-items: center;
  2852. justify-content: space-between;
  2853. min-height: 64px;
  2854. padding: 12px 16px;
  2855. }
  2856. .page-header__main {
  2857. display: flex;
  2858. align-items: center;
  2859. min-width: 0;
  2860. }
  2861. .page-header__icon {
  2862. display: inline-flex;
  2863. flex: 0 0 auto;
  2864. align-items: center;
  2865. justify-content: center;
  2866. width: 38px;
  2867. height: 38px;
  2868. margin-right: 12px;
  2869. color: var(--el-color-primary);
  2870. background: var(--el-color-primary-light-9);
  2871. border: 1px solid var(--el-color-primary-light-7);
  2872. border-radius: 6px;
  2873. }
  2874. .page-header__title {
  2875. margin: 0;
  2876. font-size: 16px;
  2877. font-weight: 600;
  2878. line-height: 24px;
  2879. letter-spacing: 0;
  2880. color: var(--el-text-color-primary);
  2881. }
  2882. .page-header__subtitle {
  2883. margin: 2px 0 0;
  2884. font-size: 12px;
  2885. line-height: 18px;
  2886. color: var(--el-text-color-secondary);
  2887. }
  2888. .project-summary-section :deep(.el-card__body),
  2889. .task-detail-section :deep(.el-card__body),
  2890. .attachment-section :deep(.el-card__body),
  2891. .platform-well-section :deep(.el-card__body) {
  2892. padding: 0;
  2893. }
  2894. .section-heading {
  2895. display: flex;
  2896. align-items: center;
  2897. justify-content: space-between;
  2898. height: 42px;
  2899. padding: 0 16px;
  2900. background: var(--el-fill-color-extra-light);
  2901. border-bottom: 1px solid var(--el-border-color-lighter);
  2902. }
  2903. .section-heading__title {
  2904. position: relative;
  2905. padding-left: 13px;
  2906. font-size: 15px;
  2907. font-weight: 600;
  2908. line-height: 22px;
  2909. color: var(--el-text-color-primary);
  2910. }
  2911. .section-heading__title::before {
  2912. position: absolute;
  2913. top: 50%;
  2914. left: 0;
  2915. width: 4px;
  2916. height: 17px;
  2917. background: var(--el-color-primary);
  2918. border-radius: 2px;
  2919. content: '';
  2920. transform: translateY(-50%);
  2921. }
  2922. .section-heading__hint {
  2923. font-size: 12px;
  2924. color: var(--el-text-color-secondary);
  2925. }
  2926. .project-summary-form,
  2927. .task-edit-form {
  2928. padding: 18px 18px 2px;
  2929. }
  2930. .project-summary-form :deep(.el-select),
  2931. .project-summary-form :deep(.el-date-editor),
  2932. .task-edit-form :deep(.el-select),
  2933. .task-edit-form :deep(.el-tree-select),
  2934. .task-edit-form :deep(.el-date-editor),
  2935. .task-edit-form :deep(.el-autocomplete) {
  2936. width: 100%;
  2937. }
  2938. .project-summary-form :deep(.el-form-item),
  2939. .task-edit-form :deep(.el-form-item) {
  2940. margin-bottom: 24px;
  2941. }
  2942. .project-summary-form :deep(.el-form-item__label),
  2943. .task-edit-form :deep(.el-form-item__label) {
  2944. white-space: nowrap;
  2945. }
  2946. .resource-select-item :deep(.el-form-item__content) {
  2947. display: flex;
  2948. flex-wrap: nowrap;
  2949. align-items: flex-start;
  2950. gap: 10px;
  2951. min-width: 0;
  2952. }
  2953. .selection-summary {
  2954. display: block;
  2955. height: 32px;
  2956. min-width: 0;
  2957. padding: 0 10px;
  2958. overflow: hidden;
  2959. line-height: 30px;
  2960. color: var(--el-text-color-regular);
  2961. text-overflow: ellipsis;
  2962. white-space: nowrap;
  2963. border: 1px solid var(--el-border-color);
  2964. border-radius: 4px;
  2965. flex: 1;
  2966. }
  2967. .selection-summary--empty {
  2968. color: var(--el-text-color-placeholder);
  2969. }
  2970. .task-reset-action :deep(.el-form-item__content) {
  2971. justify-content: flex-end;
  2972. }
  2973. .attachment-content {
  2974. display: grid;
  2975. grid-template-columns: repeat(3, minmax(0, 1fr));
  2976. gap: 20px;
  2977. padding: 18px 20px 0;
  2978. }
  2979. .attachment-content :deep(.el-upload),
  2980. .attachment-content :deep(.el-upload-list) {
  2981. width: 100%;
  2982. }
  2983. .attachment-content :deep(.el-form-item) {
  2984. margin-bottom: 18px;
  2985. }
  2986. .platform-well-section :deep(.el-table) {
  2987. width: calc(100% - 40px) !important;
  2988. margin: 16px 20px 12px;
  2989. }
  2990. .platform-well-section > :deep(.el-button),
  2991. .workload-dialog :deep(.el-dialog__body > .el-button) {
  2992. margin: 0 20px 16px;
  2993. }
  2994. .form-actions {
  2995. position: sticky;
  2996. bottom: 0;
  2997. z-index: 10;
  2998. display: flex;
  2999. width: 100%;
  3000. min-height: 58px;
  3001. padding: 10px 16px;
  3002. margin-top: auto;
  3003. background: var(--el-bg-color);
  3004. border-top: 1px solid var(--el-border-color-lighter);
  3005. box-shadow: 0 -4px 12px rgb(0 0 0 / 4%);
  3006. box-sizing: border-box;
  3007. flex-shrink: 0;
  3008. flex-direction: row-reverse;
  3009. gap: 10px;
  3010. align-items: center;
  3011. }
  3012. .form-actions :deep(.el-button) {
  3013. margin-left: 0;
  3014. }
  3015. .device-select-dialog :deep(.el-dialog__header),
  3016. .responsible-person-select-dialog :deep(.el-dialog__header),
  3017. .workload-dialog :deep(.el-dialog__header) {
  3018. padding: 16px 20px;
  3019. margin-right: 0;
  3020. border-bottom: 1px solid var(--el-border-color-lighter);
  3021. }
  3022. .device-select-dialog :deep(.el-dialog__body),
  3023. .responsible-person-select-dialog :deep(.el-dialog__body),
  3024. .workload-dialog :deep(.el-dialog__body) {
  3025. padding: 18px 20px;
  3026. }
  3027. .device-select-dialog :deep(.el-dialog__footer),
  3028. .responsible-person-select-dialog :deep(.el-dialog__footer),
  3029. .workload-dialog :deep(.el-dialog__footer) {
  3030. padding: 12px 20px;
  3031. border-top: 1px solid var(--el-border-color-lighter);
  3032. }
  3033. .edit-input {
  3034. margin-right: 10px;
  3035. }
  3036. .error-message {
  3037. margin-top: 5px;
  3038. font-size: 12px;
  3039. color: #f56c6c;
  3040. }
  3041. .action-cell {
  3042. display: flex;
  3043. gap: 8px;
  3044. }
  3045. .transfer-container {
  3046. width: 100%;
  3047. }
  3048. .transfer-component {
  3049. display: flex;
  3050. align-items: center;
  3051. width: 100%;
  3052. min-width: 0;
  3053. }
  3054. :deep(.el-transfer-panel) {
  3055. flex: 1;
  3056. width: auto !important;
  3057. }
  3058. .transfer-component :deep(.el-transfer__buttons) {
  3059. flex: 0 0 auto;
  3060. padding: 0 16px;
  3061. }
  3062. :deep(.el-transfer-panel__item) {
  3063. display: flex !important;
  3064. height: 32px !important;
  3065. padding: 0 8px !important;
  3066. margin: 0 !important;
  3067. overflow: hidden;
  3068. line-height: 32px !important;
  3069. text-overflow: ellipsis;
  3070. white-space: nowrap;
  3071. align-items: center !important;
  3072. }
  3073. /* 4. 选项文本:确保继承父容器宽度,省略号正常生效 */
  3074. .transfer-option-text {
  3075. display: inline-block;
  3076. max-width: 100%;
  3077. overflow: hidden;
  3078. text-overflow: ellipsis;
  3079. white-space: nowrap;
  3080. }
  3081. /* 设备名称显示区域样式 */
  3082. .device-names {
  3083. max-width: 200px; /* 根据实际列宽调整 */
  3084. overflow: hidden;
  3085. text-overflow: ellipsis;
  3086. white-space: nowrap;
  3087. }
  3088. :deep(.el-transfer-panel__list) {
  3089. width: 100% !important;
  3090. }
  3091. /* 责任人名称显示区域样式 */
  3092. .responsible-names {
  3093. max-width: 200px; /* 根据实际列宽调整 */
  3094. overflow: hidden;
  3095. text-overflow: ellipsis;
  3096. white-space: nowrap;
  3097. }
  3098. /* 添加部门名称的样式 */
  3099. .dept-names {
  3100. display: inline-block;
  3101. max-width: 200px; /* 根据实际列宽调整 */
  3102. overflow: hidden;
  3103. text-overflow: ellipsis;
  3104. white-space: nowrap;
  3105. vertical-align: bottom;
  3106. }
  3107. /* 部门选择器样式优化 */
  3108. :deep(.department-tree-select .el-select__tags) {
  3109. overflow: hidden;
  3110. text-overflow: ellipsis;
  3111. white-space: nowrap;
  3112. flex-wrap: nowrap;
  3113. }
  3114. :deep(.department-tree-select .el-select__tags .el-tag) {
  3115. display: inline-block;
  3116. max-width: 120px;
  3117. overflow: hidden;
  3118. text-overflow: ellipsis;
  3119. }
  3120. :deep(.department-tree-select .el-select__tags .el-tag + .el-tag) {
  3121. margin-left: 6px;
  3122. }
  3123. :deep(.department-tree-select .el-select__tags-text) {
  3124. display: inline-block;
  3125. max-width: 100px;
  3126. overflow: hidden;
  3127. text-overflow: ellipsis;
  3128. }
  3129. /* 当有多个标签被折叠时显示的 "+N" 标签样式 */
  3130. :deep(.department-tree-select .el-select__collapse-tags) {
  3131. display: inline-block;
  3132. white-space: nowrap;
  3133. }
  3134. /* 按钮文字样式 - 红色字体 */
  3135. :deep(.workload-add-btn .btn-text) {
  3136. font-size: 18px; /* 更大的字号 */
  3137. font-weight: 900; /* 更粗的字体 */
  3138. line-height: 1;
  3139. color: #f00 !important;
  3140. }
  3141. /* 设计工作量加号按钮 - 启用状态(深蓝色) */
  3142. :deep(.workload-add-btn .el-icon) {
  3143. color: #f00 !important; /* Element Plus 主色调深蓝色,可替换为 #003366 等自定义深蓝色 */
  3144. }
  3145. /* 按钮禁用状态 */
  3146. :deep(.workload-add-btn:disabled .btn-text) {
  3147. color: #c0c4cc !important;
  3148. }
  3149. /* 调整按钮整体样式,确保icon居中 */
  3150. :deep(.workload-add-btn) {
  3151. display: flex;
  3152. width: 40px;
  3153. height: 100%;
  3154. max-width: 40px;
  3155. min-width: 40px;
  3156. padding: 0;
  3157. box-sizing: border-box;
  3158. align-items: center;
  3159. justify-content: center;
  3160. }
  3161. /* 调整输入框append部分的宽度 */
  3162. :deep(.workload-input-with-button .el-input-group__append) {
  3163. width: 40px;
  3164. max-width: 40px;
  3165. min-width: 40px;
  3166. padding: 0;
  3167. box-sizing: border-box;
  3168. }
  3169. :deep(.workload-add-btn:focus-visible) {
  3170. outline-offset: -2px;
  3171. }
  3172. /* 确保按钮在禁用状态下有正确的样式 */
  3173. :deep(.workload-add-btn:disabled) {
  3174. cursor: not-allowed;
  3175. background-color: #f5f7fa;
  3176. border-color: #e4e7ed;
  3177. }
  3178. /* 设计工作量错误输入框样式 */
  3179. :deep(.error-input .el-input__inner) {
  3180. background-color: #fef0f0 !important;
  3181. border-color: #f56c6c !important;
  3182. box-shadow: 0 0 0 1px rgb(245 108 108 / 40%) !important;
  3183. }
  3184. :deep(.error-input .el-input__inner:hover) {
  3185. background-color: #fef0f0 !important;
  3186. border-color: #f56c6c !important;
  3187. }
  3188. :deep(.error-input .el-input__inner:focus) {
  3189. background-color: #fef0f0 !important;
  3190. border-color: #f56c6c !important;
  3191. box-shadow: 0 0 0 1px rgb(245 108 108 / 20%) !important;
  3192. }
  3193. /* 设计工作量tooltip样式 */
  3194. :deep(.workload-design-tooltip) {
  3195. max-width: 300px;
  3196. padding: 8px 12px;
  3197. font-size: 12px;
  3198. color: #f56c6c !important;
  3199. background: #fef0f0 !important;
  3200. border: 1px solid #fbc4c4 !important;
  3201. }
  3202. /* 隐藏 Tooltip 箭头 */
  3203. :deep(.workload-design-tooltip .el-tooltip__arrow),
  3204. :deep(.workload-design-tooltip .el-tooltip__arrow::before) {
  3205. display: none !important;
  3206. width: 0 !important;
  3207. height: 0 !important;
  3208. }
  3209. </style>