FillDailyReportForm.vue 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740
  1. <template>
  2. <ContentWrap v-loading="formLoading">
  3. <!-- 第一部分:日报标题 -->
  4. <div class="daily-report-title">
  5. <h2>{{ pageTitle }}</h2>
  6. <!-- 在审批模式下显示审批状态提示 -->
  7. <div v-if="isReadonlyMode" class="approval-notice">
  8. <el-alert :title="modeNotice" type="info" :closable="false" />
  9. </div>
  10. </div>
  11. <!-- 第二部分:项目/任务信息 -->
  12. <ContentWrap>
  13. <div class="info-table" style="margin-top: 1em">
  14. <!-- 表格行 -->
  15. <div class="table-row">
  16. <div class="table-cell">
  17. <div class="cell-content">
  18. <span class="cell-label">甲方:</span>
  19. <!-- 甲方字段:添加 single-line-ellipsis 类 + title 绑定完整内容 -->
  20. <span
  21. class="cell-value single-line-ellipsis"
  22. :title="dailyReportData.manufactureName || '-'"
  23. >
  24. {{ dailyReportData.manufactureName || '-' }}
  25. </span>
  26. </div>
  27. </div>
  28. <div class="table-cell">
  29. <div class="cell-content">
  30. <span class="cell-label">合同号:</span>
  31. <span class="cell-value">{{ dailyReportData.contractName || '-' }}</span>
  32. </div>
  33. </div>
  34. <div class="table-cell">
  35. <div class="cell-content">
  36. <span class="cell-label">井号:</span>
  37. <span class="cell-value">{{ displayWellName || dailyReportData.taskName || '-' }}</span>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="table-row">
  42. <div class="table-cell">
  43. <div class="cell-content">
  44. <span class="cell-label">施工队伍:</span>
  45. <span class="cell-value">{{ dailyReportData.deptName || '-' }}</span>
  46. </div>
  47. </div>
  48. <div class="table-cell">
  49. <div class="cell-content">
  50. <span class="cell-label">施工地点:</span>
  51. <span class="cell-value">{{ dailyReportData.location || '-' }}</span>
  52. </div>
  53. </div>
  54. <div class="table-cell">
  55. <div class="cell-content">
  56. <span class="cell-label">工艺:</span>
  57. <span class="cell-value">{{ dailyReportData.techniqueNames || '-' }}</span>
  58. </div>
  59. </div>
  60. </div>
  61. <div class="table-row">
  62. <div class="table-cell">
  63. <div class="cell-content">
  64. <span class="cell-label">搬迁日期:</span>
  65. <span class="cell-value">{{ formatDate(dailyReportData.dpDate) || '-' }}</span>
  66. </div>
  67. </div>
  68. <div class="table-cell">
  69. <div class="cell-content">
  70. <span class="cell-label">开工日期:</span>
  71. <span class="cell-value">{{ formatDate(dailyReportData.sgDate) || '-' }}</span>
  72. </div>
  73. </div>
  74. <div class="table-cell">
  75. <div class="cell-content">
  76. <span class="cell-label">完工日期:</span>
  77. <span class="cell-value">{{ formatDate(dailyReportData.wgDate) || '-' }}</span>
  78. </div>
  79. </div>
  80. </div>
  81. <div class="table-row">
  82. <div class="table-cell">
  83. <div class="cell-content">
  84. <span class="cell-label">施工周期D:</span>
  85. <span class="cell-value">{{ constructionPeriod || 0 }}</span>
  86. </div>
  87. </div>
  88. <div class="table-cell">
  89. <div class="cell-content">
  90. <span class="cell-label">停待时间D:</span>
  91. <span class="cell-value">{{ dailyReportData.faultDowntime || 0 }}</span>
  92. </div>
  93. </div>
  94. <div class="table-cell">
  95. <div class="cell-content">
  96. <span class="cell-label">带班干部:</span>
  97. <span class="cell-value">{{ dailyReportData.responsiblePersonNames || '-' }}</span>
  98. </div>
  99. </div>
  100. </div>
  101. <!-- 第五行:设备配置(单独一行) -->
  102. <div class="table-row">
  103. <div class="table-cell full-width">
  104. <div class="cell-content">
  105. <span class="cell-label">设备配置:</span>
  106. <span class="cell-value indent-multiline">{{ dailyReportData.deviceNames || '-' }}</span>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. </ContentWrap>
  112. <!-- 第三部分:日报填报表单 -->
  113. <ContentWrap class="section-padding">
  114. <el-form
  115. ref="formRef"
  116. :model="formData"
  117. :rules="isReadonlyMode ? {} : formRules"
  118. v-loading="formLoading"
  119. style="margin-top: 1em"
  120. label-width="200px"
  121. :disabled="isReadonlyMode"
  122. >
  123. <!-- 第一行:时间节点、施工状态 -->
  124. <el-row :gutter="30">
  125. <el-col :span="12">
  126. <el-form-item label="时间节点" prop="timeRange">
  127. <el-time-picker
  128. is-range
  129. v-model="formData.timeRange"
  130. range-separator="至"
  131. start-placeholder="开始时间"
  132. end-placeholder="结束时间"
  133. placeholder="选择时间范围"
  134. style="width: 100%"
  135. :readonly="isReadonlyMode"
  136. :disabled="isReadonlyMode"
  137. />
  138. </el-form-item>
  139. </el-col>
  140. <el-col :span="12">
  141. <el-form-item label="施工状态" prop="rdStatus">
  142. <el-select v-model="formData.rdStatus" placeholder="请选择施工状态"
  143. style="width: 100%" :disabled="isReadonlyMode">
  144. <el-option
  145. v-for="dict in rdStatusOptions"
  146. :key="dict.value"
  147. :label="dict.label"
  148. :value="dict.value"
  149. />
  150. </el-select>
  151. </el-form-item>
  152. </el-col>
  153. </el-row>
  154. <!-- 平台井 -->
  155. <el-row v-if="showPlatformField">
  156. <el-col :span="24">
  157. <el-form-item label="平台井" prop="platformId">
  158. <el-select
  159. v-model="formData.platformId"
  160. placeholder="请选择平台井"
  161. style="width: 100%"
  162. :disabled="isReadonlyMode"
  163. >
  164. <el-option
  165. v-for="platform in platformOptions"
  166. :key="platform.id"
  167. :label="platform.wellName"
  168. :value="platform.id"
  169. />
  170. </el-select>
  171. </el-form-item>
  172. </el-col>
  173. </el-row>
  174. <!-- 施工设备字段 -->
  175. <el-row>
  176. <el-col :span="24">
  177. <el-form-item label="施工设备" prop="deviceIds">
  178. <!-- 编辑模式:显示选择按钮 -->
  179. <template v-if="isEditMode">
  180. <el-button
  181. @click="openDeviceDialog"
  182. type="primary"
  183. size="small"
  184. :disabled="formLoading"
  185. >
  186. 选择设备
  187. </el-button>
  188. <el-tooltip
  189. v-if="formData.deviceIds && formData.deviceIds.length > 0"
  190. :content="getAllDeviceNamesForDisplay"
  191. placement="top"
  192. >
  193. <span class="device-display-container">
  194. {{ formatDevicesForDisplay }}
  195. </span>
  196. </el-tooltip>
  197. <span v-else class="no-device">
  198. 未选择设备
  199. </span>
  200. </template>
  201. <!-- 只读模式:只显示设备信息 -->
  202. <template v-else>
  203. <el-tooltip
  204. v-if="formData.deviceIds && formData.deviceIds.length > 0"
  205. :content="getAllDeviceNamesForDisplay"
  206. placement="top"
  207. >
  208. <span class="device-display-container">
  209. {{ formatDevicesForDisplay }}
  210. </span>
  211. </el-tooltip>
  212. <span v-else class="no-device">-</span>
  213. </template>
  214. </el-form-item>
  215. </el-col>
  216. </el-row>
  217. <!-- 未施工设备 -->
  218. <el-row>
  219. <el-col :span="24">
  220. <el-form-item label="未施工设备" prop="unSelectedDeviceNames">
  221. <el-input
  222. v-model="unSelectedDeviceNames"
  223. type="textarea"
  224. :rows="2"
  225. placeholder="未施工的设备将显示在这里"
  226. :readonly="true"
  227. class="unselected-device"
  228. />
  229. </el-form-item>
  230. </el-col>
  231. </el-row>
  232. <!-- 第二行:施工工艺 -->
  233. <el-row>
  234. <el-col :span="24">
  235. <el-form-item label="施工工艺" prop="techniqueIds">
  236. <el-select v-model="formData.techniqueIds" placeholder="请选择施工工艺"
  237. style="width: 100%" multiple :disabled="isReadonlyMode">
  238. <el-option
  239. v-for="dict in techniqueOptions"
  240. :key="dict.value"
  241. :label="dict.label"
  242. :value="dict.value"
  243. />
  244. </el-select>
  245. </el-form-item>
  246. </el-col>
  247. </el-row>
  248. <!-- 动态属性区域:施工工艺与当日生产动态之间 -->
  249. <el-row v-if="dynamicAttrs.length > 0" :gutter="30">
  250. <el-col
  251. v-for="attr in dynamicAttrs"
  252. :key="attr.id"
  253. :span="attr.dataType === 'textarea' ? 24 : 12"
  254. >
  255. <el-form-item
  256. :label="attr.name + (attr.unit ? `(${attr.unit})` : '')"
  257. :prop="'dynamicFields.' + attr.identifier"
  258. :rules="isReadonlyMode ? [] : getDynamicAttrRules(attr)"
  259. >
  260. <!-- 文本类型 -->
  261. <el-input
  262. v-if="attr.dataType === 'text'"
  263. v-model="formData.dynamicFields[attr.identifier]"
  264. :placeholder="`请输入${attr.name}`"
  265. :readonly="isReadonlyMode"
  266. />
  267. <!-- 文本域类型 -->
  268. <el-input
  269. v-else-if="attr.dataType === 'textarea'"
  270. v-model="formData.dynamicFields[attr.identifier]"
  271. :placeholder="`请输入${attr.name}`"
  272. type="textarea"
  273. :rows="3"
  274. :readonly="isReadonlyMode"
  275. />
  276. <!-- 数字类型 -->
  277. <el-input
  278. v-else-if="attr.dataType === 'double'"
  279. v-model="formData.dynamicFields[attr.identifier]"
  280. :placeholder="`请输入${attr.name}`"
  281. type="number"
  282. :min="attr.minValue || undefined"
  283. :max="attr.maxValue || undefined"
  284. :readonly="isReadonlyMode"
  285. />
  286. <!-- 日期类型 -->
  287. <el-date-picker
  288. v-else-if="attr.dataType === 'date'"
  289. v-model="formData.dynamicFields[attr.identifier]"
  290. type="date"
  291. value-format="x"
  292. :placeholder="`选择${attr.name}`"
  293. style="width: 100%"
  294. :readonly="isReadonlyMode"
  295. />
  296. <!-- 默认文本输入 -->
  297. <el-input
  298. v-else
  299. v-model="formData.dynamicFields[attr.identifier]"
  300. :placeholder="`请输入${attr.name}`"
  301. :readonly="isReadonlyMode"
  302. />
  303. </el-form-item>
  304. </el-col>
  305. </el-row>
  306. <el-row>
  307. <el-col :span="24">
  308. <el-form-item label="当日油耗(L)" prop="dailyFuel">
  309. <el-input
  310. v-model="formData.dailyFuel"
  311. type="text"
  312. :min="0"
  313. placeholder="自动计算当日油耗"
  314. :readonly="isReadonlyMode"
  315. @blur="formatDailyFuel"
  316. />
  317. </el-form-item>
  318. </el-col>
  319. </el-row>
  320. <!-- 第三行:当日生产动态 -->
  321. <el-row>
  322. <el-col :span="24">
  323. <el-form-item label="当日生产动态" prop="productionStatus">
  324. <el-input
  325. v-model="formData.productionStatus"
  326. type="textarea"
  327. :rows="3"
  328. placeholder="请输入当日生产动态"
  329. :readonly="isReadonlyMode"
  330. />
  331. </el-form-item>
  332. </el-col>
  333. </el-row>
  334. <!-- 第四行:下步工作计划 -->
  335. <el-row>
  336. <el-col :span="24">
  337. <el-form-item label="下步工作计划" prop="nextPlan">
  338. <el-input
  339. v-model="formData.nextPlan"
  340. type="textarea"
  341. :rows="3"
  342. placeholder="请输入下步工作计划"
  343. :readonly="isReadonlyMode"
  344. />
  345. </el-form-item>
  346. </el-col>
  347. </el-row>
  348. <!-- 第五行:外租设备 -->
  349. <el-row>
  350. <el-col :span="24">
  351. <el-form-item label="外租设备" prop="externalRental">
  352. <el-input
  353. v-model="formData.externalRental"
  354. type="textarea"
  355. :rows="3"
  356. placeholder="请输入外租设备信息"
  357. :readonly="isReadonlyMode"
  358. />
  359. </el-form-item>
  360. </el-col>
  361. </el-row>
  362. <!-- 故障情况 -->
  363. <el-row>
  364. <el-col :span="24">
  365. <el-form-item label="故障情况" prop="malfunction">
  366. <el-input
  367. v-model="formData.malfunction"
  368. type="textarea"
  369. :rows="3"
  370. placeholder="请输入故障情况"
  371. :readonly="isReadonlyMode"
  372. />
  373. </el-form-item>
  374. </el-col>
  375. </el-row>
  376. <!-- 故障误工H -->
  377. <el-row>
  378. <el-col :span="24">
  379. <el-form-item label="故障误工H" prop="faultDowntime">
  380. <el-input
  381. v-model="formData.faultDowntime"
  382. type="number"
  383. :rows="3"
  384. placeholder="请输入故障误工H"
  385. :readonly="isReadonlyMode"
  386. />
  387. </el-form-item>
  388. </el-col>
  389. </el-row>
  390. <!-- 第六行:上传附件 -->
  391. <el-row>
  392. <el-col :span="24">
  393. <el-form-item label="附件">
  394. <!-- 文件上传组件 -->
  395. <FileUpload
  396. v-if="!isReadonlyMode"
  397. ref="fileUploadRef"
  398. :device-id="deviceId"
  399. :show-folder-button="false"
  400. @upload-success="handleUploadSuccess"
  401. />
  402. <!-- 已上传附件列表显示 -->
  403. <div v-if="formData.attachments && formData.attachments.length > 0" class="attachment-container">
  404. <div class="attachment-list">
  405. <div
  406. v-for="(attachment, index) in formData.attachments"
  407. :key="attachment.id || index"
  408. class="attachment-item"
  409. >
  410. <!-- 为附件名称添加点击事件,传递整个附件对象 -->
  411. <a class="attachment-name" @click="inContent(attachment)">
  412. {{ attachment.filename }}
  413. </a>
  414. <el-button
  415. v-if="!isReadonlyMode"
  416. type="danger"
  417. link
  418. size="small"
  419. @click="removeAttachment(index)"
  420. >
  421. 删除
  422. </el-button>
  423. </div>
  424. </div>
  425. </div>
  426. <!-- 审批模式下只显示附件列表 -->
  427. <div v-else-if="isApprovalMode && (!formData.attachments || formData.attachments.length === 0)" class="no-attachment">
  428. 无附件
  429. </div>
  430. </el-form-item>
  431. </el-col>
  432. </el-row>
  433. </el-form>
  434. </ContentWrap>
  435. <!-- 油耗信息区域 - 当有油耗数据时显示 -->
  436. <ContentWrap class="fuel-consumption-section" v-if="showFuelConsumption">
  437. <h2 class="text-lg font-semibold mb-4">油耗信息</h2>
  438. <div class="fuel-consumption-table">
  439. <el-table
  440. :data="fuelConsumptionData"
  441. border
  442. style="width: 100%"
  443. class="fuel-consumption-el-table"
  444. table-layout="fixed"
  445. :key="fuelTableKey"
  446. >
  447. <!-- 车辆编码 -->
  448. <el-table-column
  449. prop="deviceCode"
  450. label="车辆编码"
  451. align="center"
  452. :show-overflow-tooltip="false"
  453. width="120"
  454. />
  455. <!-- 车辆名称 -->
  456. <el-table-column
  457. prop="deviceName"
  458. label="车辆名称"
  459. align="center"
  460. :show-overflow-tooltip="false"
  461. width="150"
  462. />
  463. <!-- 发生日期 -->
  464. <el-table-column
  465. label="发生日期"
  466. align="center"
  467. :show-overflow-tooltip="false"
  468. width="120"
  469. >
  470. <template #default="scope">
  471. {{ formatDate(scope.row.queryDate) }}
  472. </template>
  473. </el-table-column>
  474. <!-- 中航北斗油耗 -->
  475. <el-table-column
  476. label="中航北斗油耗(L)"
  477. align="center"
  478. width="140"
  479. >
  480. <template #default="scope">
  481. {{ formatNumber(scope.row.zhbdFuel, 2) }}
  482. </template>
  483. </el-table-column>
  484. <!-- 实际油耗 -->
  485. <el-table-column
  486. label="实际油耗(L)"
  487. align="center"
  488. width="140"
  489. >
  490. <template #default="scope">
  491. <!-- 编辑模式下显示输入框 -->
  492. <el-input
  493. v-if="!isReadonlyMode"
  494. v-model="scope.row.customFuel"
  495. type="text"
  496. :min="0"
  497. placeholder="请输入实际油耗"
  498. @blur="handleCustomFuelChange(scope.row)"
  499. style="width: 100%"
  500. size="small"
  501. @focus="handleFuelInputFocus(scope.row)"
  502. />
  503. <!-- 只读模式下显示数值 -->
  504. <span v-else>
  505. {{ formatNumber(scope.row.customFuel, 2) }}
  506. </span>
  507. </template>
  508. </el-table-column>
  509. </el-table>
  510. </div>
  511. </ContentWrap>
  512. <!-- 平台井工作量区域 - 只在平台井的详情或审批模式下显示 -->
  513. <ContentWrap class="platform-workload-section" v-if="(isDetailMode || isApprovalMode) && dailyReportData?.platformWell === 1">
  514. <h2 class="text-lg font-semibold mb-4">平台井工作量</h2>
  515. <div class="platform-workload-table" v-if="platformWorkloadData && platformWorkloadData.length > 0">
  516. <el-table :data="platformWorkloadData" border style="width: 100%" class="platform-workload-el-table" table-layout="fixed">
  517. <!-- 固定列 -->
  518. <el-table-column prop="wellName" label="井号" align="center" :show-overflow-tooltip="true"/>
  519. <el-table-column label="施工状态" align="center" :show-overflow-tooltip="true">
  520. <template #default="scope">
  521. {{ scope.row.rdStatusLabel || '' }}
  522. </template>
  523. </el-table-column>
  524. <el-table-column label="施工工艺" align="center" :show-overflow-tooltip="true">
  525. <template #default="scope">
  526. {{ scope.row.techniqueNames || '' }}
  527. </template>
  528. </el-table-column>
  529. <!-- 动态工作量列 -->
  530. <el-table-column
  531. v-for="workloadColumn in getWorkloadColumns()"
  532. :key="workloadColumn.key"
  533. :label="workloadColumn.label"
  534. align="center"
  535. :show-overflow-tooltip="true" >
  536. <template #default="scope">
  537. {{ getWorkloadValue(scope.row, workloadColumn.identifier) }}
  538. </template>
  539. </el-table-column>
  540. </el-table>
  541. </div>
  542. <div v-else class="text-center text-gray-500 py-4">
  543. 暂无平台井工作量数据
  544. </div>
  545. </ContentWrap>
  546. <!-- 第四部分:审批意见 - 只在审批模式下显示 -->
  547. <ContentWrap class="section-padding" v-if="isApprovalMode || isEditMode || isDetailMode">
  548. <el-form
  549. ref="approvalFormRef"
  550. :model="approvalForm"
  551. style="margin-top: 1em"
  552. label-width="200px"
  553. >
  554. <el-row>
  555. <el-col :span="24">
  556. <el-form-item label="审批意见" prop="opinion">
  557. <el-input
  558. v-model="approvalForm.opinion"
  559. type="textarea"
  560. :rows="4"
  561. placeholder="请输入审批意见"
  562. maxlength="500"
  563. show-word-limit
  564. :readonly="!isApprovalMode"
  565. :disabled="!isApprovalMode"
  566. />
  567. </el-form-item>
  568. </el-col>
  569. </el-row>
  570. </el-form>
  571. </ContentWrap>
  572. <!-- 操作按钮 -->
  573. <ContentWrap class="section-padding" v-if="isEditMode">
  574. <el-form>
  575. <el-form-item style="float: right">
  576. <el-button @click="submitForm" type="primary" :disabled="formLoading">
  577. {{ t('common.save') }}
  578. </el-button>
  579. <el-button @click="close">{{ t('common.cancel') }}</el-button>
  580. </el-form-item>
  581. </el-form>
  582. </ContentWrap>
  583. <!-- 审批模式下的操作按钮 -->
  584. <ContentWrap class="section-padding" v-if="isApprovalMode">
  585. <el-form>
  586. <el-form-item style="float: right">
  587. <el-button @click="handleApprove('pass')" type="success">
  588. 审批通过
  589. </el-button>
  590. <el-button @click="handleApprove('reject')" type="danger">
  591. 审批驳回
  592. </el-button>
  593. <el-button @click="close">{{ t('common.close') }}</el-button>
  594. </el-form-item>
  595. </el-form>
  596. </ContentWrap>
  597. <!-- 详情模式下的操作按钮 - 只有关闭按钮 -->
  598. <ContentWrap class="section-padding" v-if="isDetailMode">
  599. <el-form>
  600. <el-form-item style="float: right">
  601. <el-button @click="close">{{ t('common.close') }}</el-button>
  602. </el-form-item>
  603. </el-form>
  604. </ContentWrap>
  605. </ContentWrap>
  606. <!-- 设备选择对话框 -->
  607. <el-dialog
  608. v-model="deviceDialogVisible"
  609. title="选择施工设备"
  610. width="1000px"
  611. :before-close="handleDeviceDialogClose"
  612. class="device-select-dialog"
  613. >
  614. <div class="transfer-container">
  615. <el-transfer
  616. v-model="selectedDeviceIds"
  617. :data="filteredDeviceList"
  618. :titles="['可选设备', '已选设备']"
  619. :props="{ key: 'id', label: 'deviceCode' }"
  620. filterable
  621. class="transfer-component"
  622. @change="handleTransferChange"
  623. >
  624. <template #default="{ option }">
  625. <el-tooltip
  626. effect="dark"
  627. placement="top"
  628. :content="`${option.deviceCode || ''} - ${option.deviceName || ''}`"
  629. :disabled="!option.deviceCode && !option.deviceName"
  630. transition="fade-in-linear"
  631. >
  632. <span class="transfer-option-text">
  633. {{ option.deviceCode }} - {{ option.deviceName }}
  634. </span>
  635. </el-tooltip>
  636. </template>
  637. </el-transfer>
  638. </div>
  639. <template #footer>
  640. <span class="dialog-footer">
  641. <el-button @click="handleDeviceDialogClose">取消</el-button>
  642. <el-button type="primary" @click="confirmDeviceSelection">确定</el-button>
  643. </span>
  644. </template>
  645. </el-dialog>
  646. </template>
  647. <script setup lang="ts">
  648. import { ref, reactive, computed, onMounted, nextTick, watch } from 'vue'
  649. import { useI18n } from '@/hooks/web/useI18n'
  650. import { useMessage } from '@/hooks/web/useMessage'
  651. import { useTagsViewStore } from '@/store/modules/tagsView'
  652. import { useRouter } from 'vue-router'
  653. import {DICT_TYPE, getDictLabel, getStrDictOptions} from '@/utils/dict'
  654. import { IotRdDailyReportApi } from '@/api/pms/iotrddailyreport'
  655. import { IotDailyReportAttrsApi } from '@/api/pms/iotdailyreportattrs'
  656. import * as DeptApi from '@/api/system/dept'
  657. import { useUserStore } from '@/store/modules/user'
  658. import dayjs from 'dayjs'
  659. import FileUpload from "@/components/UploadFile/src/FileUpload.vue";
  660. const { t } = useI18n()
  661. const message = useMessage()
  662. const { delView } = useTagsViewStore()
  663. const { push, currentRoute } = useRouter()
  664. const { params } = useRoute()
  665. const userStore = useUserStore()
  666. /** 填报日报 表单 */
  667. defineOptions({ name: 'FillDailyReportForm' })
  668. const formLoading = ref(false)
  669. const formRef = ref()
  670. const id = params.id // 瑞都日报id
  671. const fuelTableKey = ref(0) // 用于强制重新渲染表格
  672. // 添加一个新的响应式变量用于输入
  673. const dailyFuelInput = ref('')
  674. // 日报数据
  675. const dailyReportData = ref<any>({})
  676. // 修改 reportFuels 的 watch,添加标志位避免自动覆盖
  677. const dailyFuelManuallyModified = ref(false)
  678. // 添加模式判断计算属性
  679. const isApprovalMode = computed(() => params.mode === 'approval')
  680. const isDetailMode = computed(() => params.mode === 'detail')
  681. const isEditMode = computed(() => params.mode === 'fill' || !params.mode) // 默认为编辑模式
  682. // 只读模式判断:审批模式或详情模式都为只读
  683. const isReadonlyMode = computed(() => isApprovalMode.value || isDetailMode.value)
  684. // 在表单数据定义附近添加
  685. const platformWellPairs = ref<any[]>([]) // 存储各平台井的工作量数据
  686. const currentPlatformId = ref<number>() // 当前选中的平台井ID
  687. // 计算属性:显示井名(统一处理主井和平台井逻辑)
  688. const displayWellName = computed(() => {
  689. // 如果是平台井模式
  690. if (dailyReportData.value.platformWell === 1) {
  691. // 确定平台井数据源:优先使用 platforms,不存在则使用 finishedPlatforms
  692. const platformSource = dailyReportData.value.platforms || dailyReportData.value.finishedPlatforms
  693. // 如果有平台井数据
  694. if (platformSource && platformSource.length > 0) {
  695. // 检查主井是否在平台井列表中
  696. const isMainWellInPlatforms = platformSource.some(
  697. (platform: any) => platform.id === dailyReportData.value.taskId
  698. )
  699. // 如果主井不在平台井列表中(说明主井已施工完成),使用第一个平台井的名称
  700. if (!isMainWellInPlatforms) {
  701. const firstPlatformWellName = platformSource[0].wellName
  702. console.log(`主井已施工完成,井号显示使用平台井名称: ${firstPlatformWellName}`)
  703. return firstPlatformWellName
  704. }
  705. }
  706. }
  707. // 其他情况使用原来的井名
  708. return dailyReportData.value.wellName
  709. })
  710. // 页面标题计算
  711. const pageTitle = computed(() => {
  712. const displayWellNameValue = displayWellName.value
  713. const constructionDate = dailyReportData.value.constructionStartDate
  714. if (isApprovalMode.value) {
  715. return displayWellNameValue && constructionDate
  716. ? `${displayWellNameValue} - ${formatDate(constructionDate)} 日报审批`
  717. : '日报审批'
  718. } else if (isDetailMode.value) {
  719. return displayWellNameValue && constructionDate
  720. ? `${displayWellNameValue} - ${formatDate(constructionDate)} 日报详情`
  721. : '日报详情'
  722. } else {
  723. return displayWellNameValue && constructionDate
  724. ? `${displayWellNameValue} - ${formatDate(constructionDate)} 生产日报`
  725. : '日报填报'
  726. }
  727. })
  728. // 处理输入框获取焦点事件
  729. const handleFuelInputFocus = (fuelItem: any) => {
  730. // 如果 customFuel 是空的,确保它显示默认值
  731. if (!fuelItem.customFuel || fuelItem.customFuel === '') {
  732. const zhbdValue = parseFloat(fuelItem.zhbdFuel);
  733. fuelItem.customFuel = !isNaN(zhbdValue) ? formatNumber(zhbdValue, 2) : '0.00';
  734. }
  735. }
  736. // 模式提示信息
  737. const modeNotice = computed(() => {
  738. if (isApprovalMode.value) {
  739. return '审批模式:所有字段均为只读'
  740. } else if (isDetailMode.value) {
  741. return '详情模式:所有字段均为只读'
  742. }
  743. return ''
  744. })
  745. // 动态属性相关变量
  746. const dynamicAttrs = ref<any[]>([]) // 存储动态属性列表
  747. // 添加设备选择相关变量
  748. const deviceDialogVisible = ref(false)
  749. const filteredDeviceList = ref<any[]>([])
  750. const selectedDeviceIds = ref<number[]>([])
  751. const deviceMap = ref<Record<number, any>>({})
  752. // 添加平台井相关响应式数据
  753. const platformOptions = ref<any[]>([]) // 平台井下拉选项
  754. const showPlatformField = ref(false) // 是否显示平台井字段
  755. // 计算属性:是否显示平台井字段
  756. const shouldShowPlatformField = computed(() => {
  757. return dailyReportData.value.platformWell === 1
  758. })
  759. // 初始化平台井数据
  760. const initPlatformData = (reportData: any) => {
  761. // 设置是否显示平台井字段
  762. showPlatformField.value = reportData.platformWell === 1
  763. // 设置平台井下拉选项 - 修改后的逻辑
  764. let platformSource = reportData.platforms
  765. // 在详情或审批模式下,如果 platforms 不存在,则使用 finishedPlatforms
  766. if ((isDetailMode.value || isApprovalMode.value) && (!platformSource || platformSource.length === 0)) {
  767. platformSource = reportData.finishedPlatforms
  768. }
  769. // 设置平台井下拉选项
  770. if (platformSource && Array.isArray(platformSource)) {
  771. platformOptions.value = platformSource
  772. // 初始化 platformWellPairs,确保包含所有平台井的完整数据
  773. if (reportData.platformWell === 1) {
  774. // 初始化 platformWellPairs,包含所有平台井的完整数据
  775. platformWellPairs.value = platformSource.map((platform: any) => {
  776. // 查找是否已有该平台井的数据
  777. const existingData = reportData.platformWellPairs?.find((p: any) => p.taskId === platform.id)
  778. // 确保 techniqueIds 是字符串数组格式
  779. let techniqueIds = []
  780. if (existingData && existingData.techniqueIds) {
  781. techniqueIds = existingData.techniqueIds.map((id: any) => id.toString())
  782. } else if (platform.techniqueIds) {
  783. techniqueIds = platform.techniqueIds.map((id: any) => id.toString())
  784. }
  785. return existingData || {
  786. taskId: platform.id,
  787. reportId: platform.reportId, // 使用接口返回的 reportId
  788. wellName: platform.wellName,
  789. rdStatus: platform.rdStatus || '', // 初始为空
  790. techniqueIds: techniqueIds, // 初始为空数组
  791. extProperty: platform.extProperty || [] // 初始为空数组
  792. }
  793. })
  794. }
  795. } else {
  796. platformOptions.value = []
  797. platformWellPairs.value = []
  798. }
  799. // 设置默认选中的平台井 - 修改后的逻辑
  800. if (platformOptions.value.length > 0) {
  801. let selectedPlatform = null
  802. // 首先尝试查找与 taskId 匹配的平台井
  803. if (reportData.taskId) {
  804. selectedPlatform = platformOptions.value.find(
  805. (platform: any) => platform.id === reportData.taskId
  806. )
  807. }
  808. // 如果没有找到匹配的平台井,选择第一个平台井
  809. if (!selectedPlatform) {
  810. selectedPlatform = platformOptions.value[0]
  811. }
  812. // 设置选中的平台井
  813. if (selectedPlatform) {
  814. formData.value.platformId = selectedPlatform.id
  815. currentPlatformId.value = selectedPlatform.id
  816. // 加载平台井的数据到表单
  817. loadPlatformData(selectedPlatform.id)
  818. // 可选:在控制台输出提示信息
  819. if (reportData.taskId && selectedPlatform.id !== reportData.taskId) {
  820. console.log(`主井已施工完成,已自动选择第一个平台井: ${selectedPlatform.wellName}`)
  821. }
  822. }
  823. }
  824. }
  825. // 添加审批表单相关变量
  826. const approvalFormRef = ref()
  827. const approvalForm = reactive({
  828. opinion: '' // 审批意见
  829. })
  830. // 审批表单验证规则(可选,根据需求添加)
  831. const approvalFormRules = reactive({
  832. opinion: [
  833. { required: false, message: '请输入审批意见', trigger: 'blur' },
  834. { min: 0, max: 500, message: '审批意见长度不能超过500个字符', trigger: 'blur' }
  835. ]
  836. })
  837. // 将时分秒数组转换为Date对象(基于constructionStartDate的日期)
  838. const parseTimeArrayToDate = (timeArray: number[], baseDate: number) => {
  839. if (!Array.isArray(timeArray) || !baseDate) {
  840. return null
  841. }
  842. const hour = timeArray[0] || 0
  843. const minute = timeArray[1] || 0
  844. const second = timeArray[2] || 0
  845. // 基于日报日期(constructionStartDate)设置时分秒
  846. return dayjs(baseDate).hour(hour).minute(minute).second(second).toDate()
  847. }
  848. // 添加文件上传组件的引用
  849. const fileUploadRef = ref()
  850. // 表单数据
  851. const formData = ref({
  852. id: undefined,
  853. deptId: undefined,
  854. taskId: undefined,
  855. platformWell: undefined,
  856. companyId: undefined,
  857. deptName: undefined,
  858. constructionStartDate: undefined,
  859. contractName: undefined,
  860. projectDepartment: '',
  861. costCenterId: undefined,
  862. costCenter: '',
  863. platformId: undefined, // 平台井ID
  864. // 日报填报字段
  865. timeRange: [
  866. // 设置默认时间范围 8:00 - 8:00
  867. dayjs().hour(8).minute(0).second(0).toDate(),
  868. dayjs().hour(8).minute(0).second(0).toDate()
  869. ],
  870. startTime: undefined, // 开始时间
  871. endTime: undefined, // 结束时间
  872. rdStatus: '', // 施工状态
  873. deviceIds: [] as number[], // 设备ID数组
  874. techniqueIds: [], // 施工工艺
  875. dailyFuel: '', // 当日油耗
  876. productionStatus: '', // 当日生产动态
  877. nextPlan: '', // 下步工作计划
  878. externalRental: '', // 外租设备
  879. malfunction: '', // 故障情况
  880. faultDowntime: '', // 故障误工
  881. // 添加动态字段对象
  882. dynamicFields: {} as Record<string, any>,
  883. // 附件列表
  884. attachments: [] as any[],
  885. reportFuels: [] as any[] // 油耗信息数组
  886. })
  887. // 添加上传成功处理函数
  888. const handleUploadSuccess = (result: any) => {
  889. console.log('上传成功:', result)
  890. try {
  891. // 检查响应是否成功
  892. if (!result.response) {
  893. message.error('上传响应数据异常')
  894. return
  895. }
  896. if (result.response.code !== 0) {
  897. message.error(result.response.msg || '文件上传失败')
  898. return
  899. }
  900. const responseData = result.response.data
  901. if (!responseData) {
  902. message.error('上传数据为空')
  903. return
  904. }
  905. // 处理返回的文件列表
  906. if (responseData.files && Array.isArray(responseData.files) && responseData.files.length > 0) {
  907. responseData.files.forEach((file: any) => {
  908. if (!file.filePath) {
  909. console.warn('文件缺少 filePath:', file)
  910. return
  911. }
  912. // 根据后端返回的数据结构构建附件对象
  913. const attachment = {
  914. id: undefined,
  915. category: 'daily_report',
  916. bizId: formData.value.id,
  917. type: 'attachment',
  918. filename: file.name || '未知文件',
  919. fileType: getFileType(file.name),
  920. filePath: file.filePath, //使用正确的 filePath
  921. fileSize: formatFileSize(file.size || 0),
  922. remark: ''
  923. }
  924. // 添加到附件列表
  925. if (!formData.value.attachments) {
  926. formData.value.attachments = []
  927. }
  928. formData.value.attachments.push(attachment)
  929. })
  930. message.success(`成功上传 ${responseData.files.length} 个文件`)
  931. } else {
  932. console.warn('上传成功但没有返回文件信息')
  933. message.warning('上传成功但未获取到文件信息')
  934. }
  935. } catch (error) {
  936. console.error('处理上传结果时发生错误:', error)
  937. message.error('处理上传结果失败')
  938. }
  939. }
  940. // 删除附件
  941. const removeAttachment = (index: number) => {
  942. if (formData.value.attachments && formData.value.attachments.length > index) {
  943. formData.value.attachments.splice(index, 1)
  944. }
  945. }
  946. // 计算属性:未施工设备名称
  947. const unSelectedDeviceNames = computed(() => {
  948. const selectedDevices = dailyReportData.value.selectedDevices || []
  949. const selectedDeviceIds = formData.value.deviceIds || []
  950. if (selectedDevices.length === 0) {
  951. return '无可用设备'
  952. }
  953. // 筛选出未选择的设备
  954. const unselectedDevices = selectedDevices.filter((device: any) =>
  955. !selectedDeviceIds.includes(device.id)
  956. )
  957. if (unselectedDevices.length === 0) {
  958. return '所有设备都已施工'
  959. }
  960. // 提取设备名称并用逗号分隔
  961. const deviceNames = unselectedDevices
  962. .map((device: any) => device.deviceName || device.deviceCode || '未知设备')
  963. .filter((name: string) => name !== '未知设备')
  964. return deviceNames.join(', ') || '无未选择设备'
  965. })
  966. // 附件名称点击事件
  967. const inContent = async (attachment) => {
  968. if (!attachment || !attachment.filePath) {
  969. message.error('附件路径不存在')
  970. return
  971. }
  972. try {
  973. // 直接使用 attachment.filePath
  974. const filePath = attachment.filePath
  975. // 确保 filePath 是编码后的格式
  976. const encodedPath = encodeURIComponent(Base64.encode(filePath))
  977. // 打开预览窗口
  978. window.open(`http://doc.deepoil.cc:8012/onlinePreview?url=${encodedPath}`)
  979. } catch (error) {
  980. console.error('预览附件失败:', error)
  981. message.error('预览附件失败')
  982. }
  983. }
  984. // 获取文件类型辅助函数
  985. const getFileType = (filename: string) => {
  986. const ext = filename.split('.').pop()?.toLowerCase()
  987. if (['jpg', 'jpeg', 'png', 'gif', 'bmp'].includes(ext || '')) {
  988. return 'image'
  989. } else if (['pdf'].includes(ext || '')) {
  990. return 'pdf'
  991. } else if (['doc', 'docx'].includes(ext || '')) {
  992. return 'word'
  993. } else if (['xls', 'xlsx'].includes(ext || '')) {
  994. return 'excel'
  995. } else {
  996. return 'other'
  997. }
  998. }
  999. // 格式化文件大小辅助函数
  1000. const formatFileSize = (bytes: number) => {
  1001. if (bytes === 0) return '0 Bytes'
  1002. const k = 1024
  1003. const sizes = ['Bytes', 'KB', 'MB', 'GB']
  1004. const i = Math.floor(Math.log(bytes) / Math.log(k))
  1005. return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
  1006. }
  1007. // 计算属性:格式化设备显示
  1008. const formatDevicesForDisplay = computed(() => {
  1009. const deviceIds = formData.value.deviceIds
  1010. if (!deviceIds || deviceIds.length === 0) {
  1011. return '无设备'
  1012. }
  1013. const deviceNames = deviceIds
  1014. .map(id => deviceMap.value[id]?.deviceName)
  1015. .filter(name => name !== undefined && name !== '')
  1016. if (deviceNames.length === 0) return '无设备'
  1017. // 如果设备数量超过2个,显示前两个加省略号
  1018. /* if (deviceNames.length > 2) {
  1019. return `${deviceNames[0]}, ${deviceNames[1]}...`
  1020. } */
  1021. return deviceNames.join(', ')
  1022. })
  1023. // 计算属性:获取所有设备名称(用于tooltip)
  1024. const getAllDeviceNamesForDisplay = computed(() => {
  1025. const deviceIds = formData.value.deviceIds
  1026. if (!deviceIds || deviceIds.length === 0) {
  1027. return '无设备'
  1028. }
  1029. const deviceNames = deviceIds
  1030. .map(id => deviceMap.value[id]?.deviceCode || '未知设备')
  1031. .filter(name => name !== '未知设备')
  1032. return deviceNames.join(', ') || '无有效设备'
  1033. })
  1034. // 打开设备选择对话框
  1035. const openDeviceDialog = async () => {
  1036. if (!dailyReportData.value.deptId) {
  1037. message.error('请先加载项目信息')
  1038. return
  1039. }
  1040. try {
  1041. formLoading.value = true
  1042. selectedDeviceIds.value = [...(formData.value.deviceIds || [])]
  1043. // 直接从日报数据的 selectedDevices 中获取设备列表
  1044. const selectedDevices = dailyReportData.value.selectedDevices || []
  1045. // 更新设备映射表
  1046. const newDeviceMap = { ...deviceMap.value }
  1047. selectedDevices.forEach((device: any) => {
  1048. if (device.id) {
  1049. newDeviceMap[device.id] = device
  1050. }
  1051. })
  1052. deviceMap.value = newDeviceMap
  1053. filteredDeviceList.value = selectedDevices
  1054. deviceDialogVisible.value = true
  1055. } catch (error) {
  1056. console.error('获取设备列表失败:', error)
  1057. message.error('获取设备列表失败')
  1058. } finally {
  1059. formLoading.value = false
  1060. }
  1061. }
  1062. // 修改格式化函数,改为失去焦点时触发
  1063. const formatDailyFuel = () => {
  1064. if (!dailyFuelInput.value || dailyFuelInput.value.trim() === '') {
  1065. formData.value.dailyFuel = ''
  1066. dailyFuelInput.value = ''
  1067. return
  1068. }
  1069. // 移除非数字字符(除了小数点)
  1070. const cleaned = dailyFuelInput.value.replace(/[^\d.]/g, '')
  1071. // 确保只有一个小数点
  1072. const parts = cleaned.split('.')
  1073. if (parts.length > 2) {
  1074. dailyFuelInput.value = parts[0] + '.' + parts.slice(1).join('')
  1075. }
  1076. const numValue = parseFloat(dailyFuelInput.value)
  1077. if (!isNaN(numValue)) {
  1078. // 限制到两位小数
  1079. formData.value.dailyFuel = formatNumber(numValue, 2)
  1080. dailyFuelInput.value = formData.value.dailyFuel
  1081. } else {
  1082. formData.value.dailyFuel = ''
  1083. dailyFuelInput.value = ''
  1084. }
  1085. }
  1086. // 处理穿梭框变化
  1087. const handleTransferChange = (value: number[], direction: string, movedKeys: number[]) => {
  1088. // 可以添加额外的处理逻辑
  1089. }
  1090. // 确认设备选择
  1091. const confirmDeviceSelection = () => {
  1092. formData.value.deviceIds = [...selectedDeviceIds.value]
  1093. deviceDialogVisible.value = false
  1094. message.success(`已选择 ${selectedDeviceIds.value.length} 台设备`)
  1095. }
  1096. // 关闭设备选择对话框
  1097. const handleDeviceDialogClose = () => {
  1098. deviceDialogVisible.value = false
  1099. }
  1100. // 初始化设备数据
  1101. const initDeviceData = (reportData: any) => {
  1102. // 初始化设备ID
  1103. if (reportData.deviceIds && Array.isArray(reportData.deviceIds)) {
  1104. formData.value.deviceIds = [...reportData.deviceIds]
  1105. } else {
  1106. formData.value.deviceIds = []
  1107. }
  1108. // 初始化设备映射表(用于显示设备名称)
  1109. if (reportData.selectedDevices && Array.isArray(reportData.selectedDevices)) {
  1110. const newDeviceMap = { ...deviceMap.value }
  1111. reportData.selectedDevices.forEach((device: any) => {
  1112. if (device.id) {
  1113. newDeviceMap[device.id] = device
  1114. }
  1115. })
  1116. deviceMap.value = newDeviceMap
  1117. }
  1118. }
  1119. // 表单验证规则
  1120. /* const formRules = reactive({
  1121. timeRange: [{ required: true, message: '时间节点不能为空', trigger: 'change' }],
  1122. rdStatus: [{ required: true, message: '施工状态不能为空', trigger: 'change' }],
  1123. techniqueIds: [{ required: true, message: '施工工艺不能为空', trigger: 'change' }],
  1124. productionStatus: [{ required: true, message: '当日生产动态不能为空', trigger: 'blur' }]
  1125. }) */
  1126. const formRules = computed(() => {
  1127. // 判断是否为虚拟项目
  1128. const isVirtualProject = dailyReportData.value.virtualProject === 'Y'
  1129. // 基础校验规则(时间节点、当日生产动态始终必填)
  1130. const rules = {
  1131. timeRange: [{ required: true, message: '时间节点不能为空', trigger: 'change' }],
  1132. productionStatus: [{ required: true, message: '当日生产动态不能为空', trigger: 'blur' }],
  1133. dailyFuel: [
  1134. {
  1135. validator: (rule: any, value: any, callback: any) => {
  1136. if (value === '' || value === null || value === undefined) {
  1137. callback()
  1138. return
  1139. }
  1140. const numValue = Number(value)
  1141. if (isNaN(numValue)) {
  1142. callback(new Error('当日油耗必须是数字'))
  1143. } else if (numValue < 0) {
  1144. callback(new Error('当日油耗不能小于0'))
  1145. } else {
  1146. callback()
  1147. }
  1148. },
  1149. trigger: 'blur'
  1150. }
  1151. ]
  1152. }
  1153. // 非虚拟项目时,添加施工状态、施工工艺的必填校验
  1154. if (!isVirtualProject) {
  1155. rules.rdStatus = [{ required: true, message: '施工状态不能为空', trigger: 'change' }]
  1156. rules.techniqueIds = [{ required: true, message: '施工工艺不能为空', trigger: 'change' }]
  1157. }
  1158. return rules
  1159. })
  1160. const queryParams = reactive({
  1161. deptId: undefined,
  1162. techniqueIds: [],
  1163. })
  1164. // 下拉选项
  1165. const rdStatusOptions = getStrDictOptions(DICT_TYPE.PMS_PROJECT_RD_STATUS) // 施工状态
  1166. const techniqueOptions = getStrDictOptions(DICT_TYPE.PMS_PROJECT_RD_TECHNOLOGY) // 瑞都施工工艺
  1167. // 计算属性:日报标题
  1168. const dailyReportTitle = computed(() => {
  1169. if (!dailyReportData.value.wellName || !dailyReportData.value.constructionStartDate) {
  1170. return '日报填报'
  1171. }
  1172. const dateStr = formatDate(dailyReportData.value.constructionStartDate)
  1173. return `${dailyReportData.value.wellName} - ${dateStr} 生产日报`
  1174. })
  1175. // 日报审批:日报标题
  1176. const dailyReportApprovalTitle = computed(() => {
  1177. if (!dailyReportData.value.wellName || !dailyReportData.value.constructionStartDate) {
  1178. return '日报审批'
  1179. }
  1180. const dateStr = formatDate(dailyReportData.value.constructionStartDate)
  1181. return `${dailyReportData.value.wellName} - ${dateStr} 日报审批`
  1182. })
  1183. // 计算属性:施工周期
  1184. const constructionPeriod = computed(() => {
  1185. const start = dailyReportData.value.constructionStartDate
  1186. const end = dailyReportData.value.constructionEndDate
  1187. if (!start || !end) return 0
  1188. const startDate = dayjs(start)
  1189. const endDate = dayjs(end)
  1190. return endDate.diff(startDate, 'day')
  1191. })
  1192. // 日期格式化函数
  1193. const formatDate = (timestamp: number) => {
  1194. if (!timestamp) return ''
  1195. return dayjs(timestamp).format('YYYY-MM-DD')
  1196. }
  1197. const close = () => {
  1198. delView(unref(currentRoute))
  1199. push({ name: 'FillDailyReport', params: {} })
  1200. }
  1201. /** 提交表单 */
  1202. const emit = defineEmits(['success'])
  1203. const submitForm = async () => {
  1204. // 验证表单
  1205. try {
  1206. await formRef.value.validate()
  1207. } catch (error) {
  1208. return
  1209. }
  1210. // 保存当前平台井的数据
  1211. if (currentPlatformId.value) {
  1212. saveCurrentPlatformData(currentPlatformId.value)
  1213. }
  1214. // 打印 platformWellPairs
  1215. console.log('platformWellPairs:', JSON.stringify(platformWellPairs.value, null, 2))
  1216. // 处理时间范围数据
  1217. if (formData.value.timeRange && formData.value.timeRange.length === 2) {
  1218. // 将时间范围转换为 LocalTime 格式的字符串
  1219. const startDate = dayjs(formData.value.timeRange[0])
  1220. const endDate = dayjs(formData.value.timeRange[1])
  1221. // 格式化为 HH:mm:ss 字符串,后端会自动转换为 LocalTime
  1222. formData.value.startTime = startDate.format('HH:mm:ss')
  1223. formData.value.endTime = endDate.format('HH:mm:ss')
  1224. }
  1225. // 构建动态属性 extProperty 数组
  1226. const extProperties = dynamicAttrs.value.map(attr => {
  1227. return {
  1228. name: attr.name,
  1229. sort: attr.sort,
  1230. unit: attr.unit,
  1231. actualValue: formData.value.dynamicFields[attr.identifier] || '', // 从 dynamicFields 中获取用户填写的值
  1232. dataType: attr.dataType,
  1233. maxValue: attr.maxValue,
  1234. minValue: attr.minValue,
  1235. required: attr.required,
  1236. accessMode: attr.accessMode,
  1237. identifier: attr.identifier,
  1238. defaultValue: attr.defaultValue
  1239. }
  1240. })
  1241. // 准备提交数据,包含动态字段
  1242. const baseSubmitData = {
  1243. ...formData.value,
  1244. // 将动态字段组装成 extProperty 数组
  1245. extProperty: extProperties,
  1246. deviceIds: formData.value.deviceIds, // 设备ID集合
  1247. // 在填报模式下也提交审批意见字段
  1248. opinion: isEditMode.value ? approvalForm.opinion : undefined,
  1249. // 将油耗数据格式化为后端需要的格式
  1250. /* reportFuels: formData.value.reportFuels.map(fuel => ({
  1251. ...fuel,
  1252. // 确保 customFuel 是数字格式
  1253. customFuel: fuel.customFuel ? parseFloat(fuel.customFuel) : null
  1254. })), */
  1255. // 确保当日油耗是数字格式
  1256. dailyFuel: formData.value.dailyFuel ? parseFloat(formData.value.dailyFuel) : 0
  1257. }
  1258. // 删除不需要复制的字段
  1259. const { id: currentId, platformId, platformWell, taskId, rdStatus, techniqueIds, extProperty, ...baseData } = baseSubmitData
  1260. const submitDatas = []
  1261. if (dailyReportData.value.platformWell === 1 && platformWellPairs.value.length > 0) {
  1262. // 平台井模式:处理所有平台井数据
  1263. platformWellPairs.value.forEach(pair => {
  1264. // 复制基础数据
  1265. const platformData = { ...baseData }
  1266. // 设置平台井特定字段
  1267. platformData.id = pair.reportId // 使用 platformWellPairs 中的 reportId
  1268. platformData.platformId = pair.taskId // 使用 platformWellPairs 中的 taskId
  1269. platformData.rdStatus = pair.rdStatus || ''
  1270. platformData.techniqueIds = pair.techniqueIds || []
  1271. platformData.extProperty = pair.extProperty || []
  1272. // 处理附件:复制并修改 bizId 为当前 pair 的 reportId
  1273. platformData.attachments = (baseData.attachments || []).map(attachment => ({
  1274. ...attachment, // 深拷贝单个附件
  1275. bizId: pair.reportId // 替换 bizId 为当前平台井的 reportId
  1276. }))
  1277. // 车辆油耗:复制并修改 reportId 为当前 pair 的 reportId
  1278. platformData.reportFuels = (baseData.reportFuels || []).map(reportFuel => ({
  1279. ...reportFuel, // 深拷贝单个油耗
  1280. reportId: pair.reportId // 替换 reportId 为当前平台井的 reportId
  1281. }))
  1282. // 重新构建 dynamicFields(如果需要)
  1283. const dynamicFields = {}
  1284. if (platformData.extProperty && platformData.extProperty.length > 0) {
  1285. platformData.extProperty.forEach(prop => {
  1286. if (prop.identifier) {
  1287. dynamicFields[prop.identifier] = prop.actualValue || ''
  1288. }
  1289. })
  1290. }
  1291. platformData.dynamicFields = dynamicFields
  1292. submitDatas.push(platformData)
  1293. })
  1294. console.log('平台井模式提交数据:', JSON.stringify(submitDatas, null, 2))
  1295. } else {
  1296. // 非平台井模式:只提交当前数据
  1297. submitDatas.push(baseSubmitData)
  1298. }
  1299. // 提交请求
  1300. formLoading.value = true
  1301. try {
  1302. // 调用更新接口
  1303. await IotRdDailyReportApi.saveBatch(submitDatas)
  1304. message.success(t('common.updateSuccess'))
  1305. close()
  1306. // 发送操作成功的事件
  1307. emit('success')
  1308. } catch (error) {
  1309. console.error('提交失败:', error)
  1310. } finally {
  1311. formLoading.value = false
  1312. }
  1313. }
  1314. /** 重置表单 */
  1315. const resetForm = () => {
  1316. formRef.value?.resetFields()
  1317. }
  1318. // 初始化动态属性
  1319. const initDynamicAttrs = (reportData: any) => {
  1320. if (reportData.dailyReportAttrs && reportData.dailyReportAttrs.length > 0) {
  1321. dynamicAttrs.value = reportData.dailyReportAttrs
  1322. // 初始化动态字段的值
  1323. const initialDynamicFields: Record<string, any> = {}
  1324. // 优先从 extProperty 中获取实际值(编辑时)
  1325. if (reportData.extProperty && reportData.extProperty.length > 0) {
  1326. reportData.extProperty.forEach((extProp: any) => {
  1327. if (extProp.identifier) {
  1328. initialDynamicFields[extProp.identifier] = extProp.actualValue || ''
  1329. }
  1330. })
  1331. }
  1332. reportData.dailyReportAttrs.forEach((attr: any) => {
  1333. if (!initialDynamicFields.hasOwnProperty(attr.identifier)) {
  1334. // 优先使用实际值,如果没有则使用默认值
  1335. const value = (attr.extProperty && attr.extProperty.actualValue !== undefined &&
  1336. attr.extProperty.actualValue !== null && attr.extProperty.actualValue !== '')
  1337. ? attr.extProperty.actualValue
  1338. : (attr.defaultValue || (attr.extProperty?.defaultValue || ''))
  1339. initialDynamicFields[attr.identifier] = value
  1340. }
  1341. })
  1342. formData.value.dynamicFields = initialDynamicFields
  1343. }
  1344. }
  1345. // 获取动态字段的验证规则
  1346. const getDynamicAttrRules = (attr: any) => {
  1347. const rules = []
  1348. if (attr.required === 1) {
  1349. rules.push({
  1350. required: true,
  1351. message: `${attr.name}不能为空`,
  1352. trigger: 'blur'
  1353. })
  1354. }
  1355. // 数字类型验证
  1356. if (attr.dataType === 'double') {
  1357. rules.push({
  1358. validator: (rule: any, value: any, callback: any) => {
  1359. if (value === '' || value === null || value === undefined) {
  1360. callback()
  1361. return
  1362. }
  1363. const numValue = Number(value)
  1364. if (isNaN(numValue)) {
  1365. callback(new Error(`${attr.name}必须是数字`))
  1366. } else if (attr.minValue && numValue < Number(attr.minValue)) {
  1367. callback(new Error(`${attr.name}不能小于${attr.minValue}`))
  1368. } else if (attr.maxValue && numValue > Number(attr.maxValue)) {
  1369. callback(new Error(`${attr.name}不能大于${attr.maxValue}`))
  1370. } else {
  1371. callback()
  1372. }
  1373. },
  1374. trigger: 'blur'
  1375. })
  1376. }
  1377. return rules
  1378. }
  1379. // 更新动态属性(处理交集、新增和删除)
  1380. const updateDynamicAttrs = async (newAttrs: any[], newTechniqueIds: string[], oldTechniqueIds?: string[]) => {
  1381. const oldAttrs = [...dynamicAttrs.value]
  1382. const oldDynamicFields = { ...formData.value.dynamicFields }
  1383. // 计算需要保留的字段(交集)
  1384. const commonAttrs = oldAttrs.filter(oldAttr =>
  1385. newAttrs.some(newAttr => newAttr.identifier === oldAttr.identifier)
  1386. )
  1387. // 计算需要新增的字段
  1388. const addedAttrs = newAttrs.filter(newAttr =>
  1389. !oldAttrs.some(oldAttr => oldAttr.identifier === newAttr.identifier)
  1390. )
  1391. // 计算需要删除的字段
  1392. const removedAttrs = oldAttrs.filter(oldAttr =>
  1393. !newAttrs.some(newAttr => newAttr.identifier === oldAttr.identifier)
  1394. )
  1395. // 构建新的动态属性数组
  1396. const updatedAttrs = [...commonAttrs, ...addedAttrs]
  1397. // 构建新的动态字段对象
  1398. const updatedDynamicFields = { ...oldDynamicFields }
  1399. // 移除已删除的字段
  1400. removedAttrs.forEach(attr => {
  1401. delete updatedDynamicFields[attr.identifier]
  1402. })
  1403. // 初始化新增字段的值
  1404. addedAttrs.forEach(attr => {
  1405. if (!updatedDynamicFields[attr.identifier]) {
  1406. // 如果有默认值使用默认值,否则为空
  1407. updatedDynamicFields[attr.identifier] = attr.defaultValue ||
  1408. (attr.extProperty?.defaultValue || '')
  1409. }
  1410. })
  1411. // 更新响应式数据
  1412. dynamicAttrs.value = updatedAttrs
  1413. formData.value.dynamicFields = updatedDynamicFields
  1414. }
  1415. // 加载动态属性
  1416. const loadDynamicAttrs = async (newTechniqueIds: string[], oldTechniqueIds?: string[]) => {
  1417. try {
  1418. formLoading.value = true
  1419. const queryParams = {
  1420. techniqueIds: newTechniqueIds.join(',')
  1421. }
  1422. const response = await IotDailyReportAttrsApi.dailyReportAttrs(queryParams)
  1423. const newAttrs = response || []
  1424. // 处理动态属性更新
  1425. await updateDynamicAttrs(newAttrs, newTechniqueIds, oldTechniqueIds)
  1426. } catch (error) {
  1427. console.error('加载动态属性失败:', error)
  1428. message.error('加载动态属性失败')
  1429. } finally {
  1430. formLoading.value = false
  1431. }
  1432. }
  1433. // 计算属性:获取平台井工作量数据(在详情/审批模式下优先使用 platforms,不存在则使用 finishedPlatforms)
  1434. const platformWorkloadData = computed(() => {
  1435. if (!dailyReportData.value) return []
  1436. // 在详情或审批模式下
  1437. if (isDetailMode.value || isApprovalMode.value) {
  1438. // 优先使用 platforms,如果不存在则使用 finishedPlatforms
  1439. return dailyReportData.value.platforms || dailyReportData.value.finishedPlatforms || []
  1440. }
  1441. // 其他模式只使用 platforms
  1442. return dailyReportData.value.platforms || []
  1443. })
  1444. // 在 watch 监听平台井选择变化的部分附近,添加施工工艺转换函数
  1445. // 添加施工工艺数值到标签的转换函数
  1446. const convertTechniqueIdsToLabels = (techniqueIds: number[]): string[] => {
  1447. if (!techniqueIds || !Array.isArray(techniqueIds)) {
  1448. return []
  1449. }
  1450. return techniqueIds.map(id => {
  1451. const dict = techniqueOptions.value.find(option => option.value === id.toString())
  1452. return dict ? dict.label : id.toString()
  1453. })
  1454. }
  1455. // 监听施工工艺变化
  1456. watch(() => formData.value.techniqueIds, async (newTechniqueIds, oldTechniqueIds) => {
  1457. if (newTechniqueIds && newTechniqueIds.length > 0) {
  1458. await loadDynamicAttrs(newTechniqueIds, oldTechniqueIds)
  1459. // 动态属性加载完成后,更新当前平台井的 extProperty
  1460. if (currentPlatformId.value) {
  1461. updateCurrentPlatformExtProperty()
  1462. }
  1463. } else {
  1464. dynamicAttrs.value = []
  1465. formData.value.dynamicFields = {}
  1466. // 清空当前平台井的 extProperty
  1467. if (currentPlatformId.value) {
  1468. updateCurrentPlatformExtProperty()
  1469. }
  1470. }
  1471. }, { deep: true })
  1472. // 监听 formData.dailyFuel 变化,同步到输入变量
  1473. watch(() => formData.value.dailyFuel, (newVal) => {
  1474. if (newVal !== null && newVal !== undefined && newVal !== '') {
  1475. // 将数字转换为字符串显示,但不干扰输入
  1476. dailyFuelInput.value = String(newVal)
  1477. } else {
  1478. dailyFuelInput.value = ''
  1479. }
  1480. dailyFuelManuallyModified.value = true
  1481. }, { immediate: true })
  1482. // 监听reportFuels的变化,自动更新当日油耗
  1483. watch(() => formData.value.reportFuels, (newFuels) => {
  1484. // 只有在编辑模式且用户没有手动修改过当日油耗时才自动计算
  1485. if (!isReadonlyMode.value) {
  1486. calculateAndUpdateDailyFuel();
  1487. }
  1488. }, { deep: true })
  1489. // 更新当前平台井的 extProperty
  1490. const updateCurrentPlatformExtProperty = () => {
  1491. if (!currentPlatformId.value) return
  1492. const index = platformWellPairs.value.findIndex(item => item.taskId === currentPlatformId.value)
  1493. if (index !== -1) {
  1494. platformWellPairs.value[index].extProperty = getCurrentExtProperties()
  1495. }
  1496. }
  1497. // 监听平台井选择变化
  1498. watch(() => formData.value.platformId, (newPlatformId, oldPlatformId) => {
  1499. if (newPlatformId && newPlatformId !== oldPlatformId) {
  1500. // 保存当前平台井的数据到 platformWellPairs
  1501. if (oldPlatformId) {
  1502. saveCurrentPlatformData(oldPlatformId)
  1503. }
  1504. // 加载新平台井的数据到表单
  1505. loadPlatformData(newPlatformId)
  1506. currentPlatformId.value = newPlatformId
  1507. }
  1508. })
  1509. // 监听动态字段变化,实时更新到 platformWellPairs
  1510. watch(() => formData.value.dynamicFields, (newFields) => {
  1511. if (currentPlatformId.value) {
  1512. updateCurrentPlatformExtProperty()
  1513. }
  1514. }, { deep: true })
  1515. // 监听施工状态变化
  1516. watch(() => formData.value.rdStatus, (newStatus) => {
  1517. if (currentPlatformId.value) {
  1518. const index = platformWellPairs.value.findIndex(item => item.taskId === currentPlatformId.value)
  1519. if (index !== -1) {
  1520. platformWellPairs.value[index].rdStatus = newStatus
  1521. }
  1522. }
  1523. })
  1524. // 保存当前平台井数据到 platformWellPairs
  1525. const saveCurrentPlatformData = (platformId: number) => {
  1526. const index = platformWellPairs.value.findIndex(item => item.taskId === platformId)
  1527. if (index !== -1) {
  1528. platformWellPairs.value[index] = {
  1529. ...platformWellPairs.value[index],
  1530. rdStatus: formData.value.rdStatus,
  1531. techniqueIds: [...formData.value.techniqueIds],
  1532. extProperty: getCurrentExtProperties()
  1533. }
  1534. } else {
  1535. // 如果找不到对应的平台井,添加新的记录
  1536. const platform = platformOptions.value.find(p => p.id === platformId)
  1537. if (platform) {
  1538. platformWellPairs.value.push({
  1539. taskId: platformId,
  1540. reportId: undefined, // 新记录没有 reportId
  1541. wellName: platform.wellName,
  1542. rdStatus: formData.value.rdStatus,
  1543. techniqueIds: [...formData.value.techniqueIds],
  1544. extProperty: getCurrentExtProperties()
  1545. })
  1546. }
  1547. }
  1548. }
  1549. // 从 platformWellPairs 加载平台井数据到表单
  1550. const loadPlatformData = (platformId: number) => {
  1551. const platformData = platformWellPairs.value.find(item => item.taskId === platformId)
  1552. if (platformData) {
  1553. // 更新表单字段
  1554. formData.value.rdStatus = platformData.rdStatus || ''
  1555. // formData.value.techniqueIds = platformData.techniqueIds ? [...platformData.techniqueIds] : []
  1556. // 将施工工艺数值转换为对应的标签
  1557. if (platformData.techniqueIds && Array.isArray(platformData.techniqueIds)) {
  1558. // 如果是数字数组,转换为字符串数组(与数据字典格式匹配)
  1559. formData.value.techniqueIds = platformData.techniqueIds.map(id => id.toString())
  1560. } else {
  1561. formData.value.techniqueIds = platformData.techniqueIds ? [...platformData.techniqueIds] : []
  1562. }
  1563. // 更新动态属性
  1564. if (platformData.extProperty && platformData.extProperty.length > 0) {
  1565. const dynamicFields: Record<string, any> = {}
  1566. platformData.extProperty.forEach((prop: any) => {
  1567. if (prop.identifier) {
  1568. dynamicFields[prop.identifier] = prop.actualValue || ''
  1569. }
  1570. })
  1571. formData.value.dynamicFields = dynamicFields
  1572. } else {
  1573. formData.value.dynamicFields = {}
  1574. }
  1575. } else {
  1576. // 如果没有找到数据,初始化默认值
  1577. formData.value.rdStatus = ''
  1578. formData.value.techniqueIds = []
  1579. formData.value.dynamicFields = {}
  1580. }
  1581. }
  1582. // 获取当前动态属性数据
  1583. const getCurrentExtProperties = () => {
  1584. return dynamicAttrs.value.map(attr => {
  1585. return {
  1586. name: attr.name,
  1587. sort: attr.sort,
  1588. unit: attr.unit,
  1589. actualValue: formData.value.dynamicFields[attr.identifier] || '',
  1590. dataType: attr.dataType,
  1591. maxValue: attr.maxValue,
  1592. minValue: attr.minValue,
  1593. required: attr.required,
  1594. accessMode: attr.accessMode,
  1595. identifier: attr.identifier,
  1596. defaultValue: attr.defaultValue
  1597. }
  1598. })
  1599. }
  1600. // 初始化表单数据
  1601. const initFormData = (reportData: any) => {
  1602. // 处理附件数据格式转换
  1603. const formattedAttachments = (reportData.attachments || []).map((attachment: any) => ({
  1604. id: attachment.id,
  1605. category: attachment.category?.toLowerCase() || 'daily_report',
  1606. bizId: attachment.bizId,
  1607. type: attachment.type?.toLowerCase() || 'attachment',
  1608. filename: attachment.filename,
  1609. fileType: attachment.fileType, // 使用辅助函数获取文件类型
  1610. filePath: attachment.filePath,
  1611. fileSize: attachment.fileSize,
  1612. remark: attachment.remark || ''
  1613. }))
  1614. // 确保 techniqueIds 是字符串数组格式
  1615. let techniqueIds = []
  1616. if (reportData.techniqueIds && Array.isArray(reportData.techniqueIds)) {
  1617. techniqueIds = reportData.techniqueIds.map((id: number) => id.toString())
  1618. }
  1619. // 计算当日油耗默认值
  1620. // const dailyFuelDefault = calculateDailyFuel(reportData)
  1621. formData.value = {
  1622. ...formData.value,
  1623. id: reportData.id,
  1624. deptId: reportData.deptId,
  1625. taskId: reportData.taskId,
  1626. platformWell: reportData.platformWell,
  1627. rdStatus: reportData.rdStatus || '',
  1628. techniqueIds: techniqueIds,
  1629. dailyFuel: reportData.dailyFuel, // 当日油耗默认值
  1630. productionStatus: reportData.productionStatus || '',
  1631. nextPlan: reportData.nextPlan || '',
  1632. externalRental: reportData.externalRental || '',
  1633. malfunction: reportData.malfunction || '',
  1634. faultDowntime: reportData.faultDowntime || '',
  1635. startTime: reportData.startTime || undefined,
  1636. endTime: reportData.endTime || undefined,
  1637. companyId: reportData.companyId || '',
  1638. dynamicFields: {}, // 确保有初始值
  1639. // 初始化附件数据
  1640. attachments: formattedAttachments
  1641. }
  1642. // 初始化审批意见数据
  1643. approvalForm.opinion = reportData.auditOpinion || reportData.opinion || ''
  1644. queryParams.deptId = reportData.companyId
  1645. // 设置时间范围选择器
  1646. if (reportData.startTime && Array.isArray(reportData.startTime) && reportData.endTime && Array.isArray(reportData.endTime)) {
  1647. // 基于日报的施工开始日期作为基准日期
  1648. const baseDate = reportData.constructionStartDate || Date.now()
  1649. const startTime = parseTimeArrayToDate(reportData.startTime, baseDate)
  1650. const endTime = parseTimeArrayToDate(reportData.endTime, baseDate)
  1651. if (startTime && endTime) {
  1652. formData.value.timeRange = [startTime, endTime]
  1653. }
  1654. }
  1655. // 初始化平台井数据
  1656. initPlatformData(reportData)
  1657. // 初始化动态属性
  1658. initDynamicAttrs(reportData)
  1659. // 初始化设备数据
  1660. initDeviceData(reportData)
  1661. // 初始化油耗数据 - 根据模式选择数据源
  1662. if (isDetailMode.value || isApprovalMode.value) {
  1663. // 详情或审批模式:优先使用 reportedFuels
  1664. let fuelSource = reportData.reportedFuels;
  1665. if (fuelSource && Array.isArray(fuelSource) && fuelSource.length > 0) {
  1666. // 处理每个油耗数据项,设置 customFuel 的默认值并确保格式正确
  1667. const processedFuels = fuelSource.map((fuel: any) => {
  1668. let customFuelValue;
  1669. // 如果 customFuel 不为空,确保它是字符串格式并已正确格式化
  1670. if (fuel.customFuel !== null && fuel.customFuel !== undefined) {
  1671. const numValue = parseFloat(fuel.customFuel);
  1672. customFuelValue = !isNaN(numValue) ? formatNumber(numValue, 2) : '0.00';
  1673. } else {
  1674. // 如果 customFuel 为空,则使用 zhbdFuel 的值
  1675. const zhbdValue = parseFloat(fuel.zhbdFuel);
  1676. customFuelValue = !isNaN(zhbdValue) ? formatNumber(zhbdValue, 2) : '0.00';
  1677. }
  1678. return {
  1679. ...fuel,
  1680. customFuel: customFuelValue
  1681. };
  1682. });
  1683. formData.value.reportFuels = processedFuels;
  1684. // 计算初始的当日油耗
  1685. calculateTotalDailyFuel();
  1686. } else {
  1687. // 如果 reportedFuels 不存在或为空,设置空数组
  1688. formData.value.reportFuels = [];
  1689. }
  1690. } else {
  1691. // 编辑模式:优先使用 reportedFuels,不存在则使用 reportFuels
  1692. let fuelSource = reportData.reportedFuels || reportData.reportFuels || [];
  1693. if (fuelSource && Array.isArray(fuelSource) && fuelSource.length > 0) {
  1694. // 处理每个油耗数据项,设置 customFuel 的默认值并确保格式正确
  1695. const processedFuels = fuelSource.map((fuel: any) => {
  1696. let customFuelValue;
  1697. // 如果 customFuel 不为空,确保它是字符串格式并已正确格式化
  1698. if (fuel.customFuel !== null && fuel.customFuel !== undefined && fuel.customFuel !== '') {
  1699. const numValue = parseFloat(fuel.customFuel);
  1700. customFuelValue = !isNaN(numValue) ? formatNumber(numValue, 2) : '0.00';
  1701. } else {
  1702. // 如果 customFuel 为空,则使用 zhbdFuel 的值
  1703. const zhbdValue = parseFloat(fuel.zhbdFuel);
  1704. customFuelValue = !isNaN(zhbdValue) ? formatNumber(zhbdValue, 2) : '0.00';
  1705. }
  1706. return {
  1707. ...fuel,
  1708. customFuel: customFuelValue
  1709. };
  1710. });
  1711. formData.value.reportFuels = processedFuels;
  1712. // 计算初始的当日油耗
  1713. calculateTotalDailyFuel();
  1714. } else {
  1715. formData.value.reportFuels = [];
  1716. }
  1717. }
  1718. }
  1719. onMounted(async () => {
  1720. formLoading.value = true
  1721. try {
  1722. // 加载当前登录人所属部门
  1723. const deptId = userStore.getUser.deptId
  1724. const dept = await DeptApi.getDept(deptId)
  1725. // 查询瑞都日报详情
  1726. if (id) {
  1727. const response = await IotRdDailyReportApi.getIotRdDailyReport(id)
  1728. dailyReportData.value = response || {}
  1729. initFormData(dailyReportData.value)
  1730. // 确保油耗数据在初始化后立即渲染
  1731. await nextTick()
  1732. // 强制更新油耗数据
  1733. if (formData.value.reportFuels && formData.value.reportFuels.length > 0) {
  1734. formData.value.reportFuels = [...formData.value.reportFuels]
  1735. }
  1736. }
  1737. } catch (error) {
  1738. console.error('初始化数据失败:', error)
  1739. message.error('数据加载失败')
  1740. } finally {
  1741. formLoading.value = false
  1742. }
  1743. })
  1744. // 详细 审批 平台井 获取工作量列配置
  1745. const getWorkloadColumns = () => {
  1746. const dataSource = platformWorkloadData.value
  1747. if (!dataSource || dataSource.length === 0) return []
  1748. const columns = [];
  1749. const addedIdentifiers = new Set();
  1750. dataSource.forEach(platform => {
  1751. if (platform.extProperty && Array.isArray(platform.extProperty)) {
  1752. platform.extProperty.forEach(extProp => {
  1753. if (!addedIdentifiers.has(extProp.identifier)) {
  1754. columns.push({
  1755. key: extProp.identifier,
  1756. identifier: extProp.identifier,
  1757. label: `${extProp.name}(${extProp.unit})`
  1758. });
  1759. addedIdentifiers.add(extProp.identifier);
  1760. }
  1761. });
  1762. }
  1763. });
  1764. return columns;
  1765. };
  1766. // 强制刷新表格
  1767. const refreshFuelTable = () => {
  1768. fuelTableKey.value += 1;
  1769. }
  1770. // 计算当日油耗的默认值
  1771. const calculateDailyFuel = (reportData: any) => {
  1772. let dailyFuelValue = 0
  1773. // 如果有接口返回的dailyFuel,优先使用
  1774. if (reportData.dailyFuel !== null && reportData.dailyFuel !== undefined) {
  1775. dailyFuelValue = Number(reportData.dailyFuel)
  1776. }
  1777. // 如果reportFuels有数据,累加zhbdFuel的值
  1778. if (reportData.reportFuels && Array.isArray(reportData.reportFuels) && reportData.reportFuels.length > 0) {
  1779. const totalZhbdFuel = reportData.reportFuels.reduce((sum: number, item: any) => {
  1780. const zhbdFuelValue = Number(item.zhbdFuel) || 0
  1781. return sum + zhbdFuelValue
  1782. }, 0)
  1783. // 只有当累计值大于0时才覆盖原有的dailyFuel值
  1784. if (totalZhbdFuel > 0) {
  1785. dailyFuelValue = totalZhbdFuel
  1786. }
  1787. }
  1788. return formatNumber(dailyFuelValue, 2)
  1789. }
  1790. // 处理当日油耗输入
  1791. const handleDailyFuelInput = () => {
  1792. // 确保保留两位小数
  1793. if (formData.value.dailyFuel !== '') {
  1794. const numValue = parseFloat(formData.value.dailyFuel)
  1795. if (!isNaN(numValue)) {
  1796. formData.value.dailyFuel = numValue.toFixed(2)
  1797. }
  1798. }
  1799. }
  1800. // 添加数字格式化函数
  1801. const formatNumber = (value: any, decimalPlaces: number = 2) => {
  1802. if (value === null || value === undefined || value === '' || value === 'NaN') {
  1803. return '0.00';
  1804. }
  1805. // 如果已经是字符串,尝试转换为数字
  1806. if (typeof value === 'string') {
  1807. // 移除可能的非数字字符
  1808. const cleaned = value.replace(/[^\d.-]/g, '');
  1809. const num = Number(cleaned);
  1810. if (isNaN(num)) {
  1811. return '0.00';
  1812. }
  1813. return num.toFixed(decimalPlaces);
  1814. }
  1815. const num = Number(value);
  1816. if (isNaN(num)) {
  1817. return '0.00';
  1818. }
  1819. return num.toFixed(decimalPlaces)
  1820. }
  1821. // 新增:计算并更新当日油耗的方法
  1822. const calculateAndUpdateDailyFuel = () => {
  1823. if (!formData.value.reportFuels || !Array.isArray(formData.value.reportFuels)) {
  1824. return;
  1825. }
  1826. // 计算所有车辆的实际油耗总和
  1827. const totalCustomFuel = formData.value.reportFuels.reduce((sum: number, item: any) => {
  1828. const customFuelValue = Number(item.customFuel) || 0;
  1829. return sum + customFuelValue;
  1830. }, 0);
  1831. // 只有当累计的实际油耗大于0时,才更新当日油耗
  1832. if (totalCustomFuel > 0 && !isReadonlyMode.value) {
  1833. formData.value.dailyFuel = formatNumber(totalCustomFuel, 2);
  1834. // 更新输入框显示
  1835. if (dailyFuelInput.value) {
  1836. dailyFuelInput.value = formData.value.dailyFuel;
  1837. }
  1838. }
  1839. }
  1840. // 添加计算属性:获取油耗数据显示数据源
  1841. const fuelConsumptionData = computed(() => {
  1842. // 所有模式都统一使用 formData.value.reportFuels 作为数据源
  1843. // 因为 formData.value.reportFuels 在 initFormData 中已经正确处理了所有情况
  1844. return formData.value.reportFuels || [];
  1845. });
  1846. // 判断是否显示油耗信息区域
  1847. const showFuelConsumption = computed(() => {
  1848. const data = fuelConsumptionData.value;
  1849. return data && Array.isArray(data) && data.length > 0;
  1850. });
  1851. // 重新计算当日油耗const formatNumber
  1852. const calculateTotalDailyFuel = () => {
  1853. if (!formData.value.reportFuels || !Array.isArray(formData.value.reportFuels)) {
  1854. return;
  1855. }
  1856. // 计算所有车辆的实际油耗总和
  1857. const totalCustomFuel = formData.value.reportFuels.reduce((sum: number, item: any) => {
  1858. const customFuelValue = Number(item.customFuel) || 0;
  1859. return sum + customFuelValue;
  1860. }, 0);
  1861. // 只有当累计的实际油耗大于0时,才自动更新当日油耗
  1862. if (totalCustomFuel > 0 && !isReadonlyMode.value) {
  1863. formData.value.dailyFuel = formatNumber(totalCustomFuel, 2);
  1864. }
  1865. };
  1866. // 处理实际油耗变化
  1867. const handleCustomFuelChange = (fuelItem: any) => {
  1868. // 获取当前输入的值
  1869. let value = fuelItem.customFuel;
  1870. // 如果输入为空,则重置为zhbdFuel的值
  1871. if (value === '' || value === null || value === undefined) {
  1872. fuelItem.customFuel = formatNumber(fuelItem.zhbdFuel, 2);
  1873. return;
  1874. }
  1875. // 移除非数字字符(除了小数点)
  1876. const cleaned = value.toString().replace(/[^\d.]/g, '');
  1877. // 确保只有一个小数点
  1878. const parts = cleaned.split('.');
  1879. let formattedValue = cleaned;
  1880. if (parts.length > 2) {
  1881. formattedValue = parts[0] + '.' + parts.slice(1).join('');
  1882. }
  1883. // 转换为数字并格式化为两位小数
  1884. const numValue = parseFloat(formattedValue);
  1885. if (!isNaN(numValue)) {
  1886. // 限制到两位小数
  1887. fuelItem.customFuel = formatNumber(numValue, 2);
  1888. } else {
  1889. // 如果转换失败,设置为0.00
  1890. fuelItem.customFuel = '0.00';
  1891. }
  1892. // 手动触发当日油耗的重新计算
  1893. calculateAndUpdateDailyFuel();
  1894. // 同步更新 formData.reportFuels 中的数据
  1895. if (formData.value.reportFuels) {
  1896. const index = formData.value.reportFuels.findIndex(
  1897. item => item.id === fuelItem.id || item.deviceId === fuelItem.deviceId
  1898. );
  1899. if (index !== -1) {
  1900. formData.value.reportFuels[index] = { ...fuelItem };
  1901. }
  1902. }
  1903. }
  1904. // 详情 审批 平台井 获取工作量值
  1905. const getWorkloadValue = (platform, identifier) => {
  1906. if (!platform.extProperty) return '';
  1907. const prop = platform.extProperty.find(item => item.identifier === identifier);
  1908. return prop ? prop.actualValue || '' : '';
  1909. };
  1910. /** 审批操作 */
  1911. const handleApprove = async (action: 'pass' | 'reject') => {
  1912. // 只有在审批模式下才执行审批操作
  1913. if (!isApprovalMode.value) {
  1914. message.warning('当前不是审批模式')
  1915. return
  1916. }
  1917. try {
  1918. // 验证审批表单(如果需要)
  1919. // await approvalFormRef.value.validate()
  1920. formLoading.value = true
  1921. // 处理时间范围数据
  1922. if (formData.value.timeRange && formData.value.timeRange.length === 2) {
  1923. // 将时间范围转换为 LocalTime 格式的字符串
  1924. const startDate = dayjs(formData.value.timeRange[0])
  1925. const endDate = dayjs(formData.value.timeRange[1])
  1926. // 格式化为 HH:mm:ss 字符串,后端会自动转换为 LocalTime
  1927. formData.value.startTime = startDate.format('HH:mm:ss')
  1928. formData.value.endTime = endDate.format('HH:mm:ss')
  1929. }
  1930. // 构建审批数据,包含审批意见
  1931. const approveData = {
  1932. ...formData.value,
  1933. id: Number(id),
  1934. opinion: approvalForm.opinion,
  1935. auditStatus: action === 'pass' ? 20 : 30
  1936. }
  1937. // 这里可以调用审批API
  1938. if (action === 'pass') {
  1939. // 审批通过逻辑
  1940. await IotRdDailyReportApi.approveRdDailyReport(approveData)
  1941. message.success('审批通过')
  1942. } else {
  1943. // 审批驳回逻辑
  1944. await IotRdDailyReportApi.approveRdDailyReport(approveData)
  1945. message.success('审批驳回')
  1946. }
  1947. close()
  1948. } catch (error) {
  1949. console.error('审批操作失败:', error)
  1950. message.error('审批操作失败')
  1951. } finally {
  1952. formLoading.value = false
  1953. }
  1954. }
  1955. </script>
  1956. <style scoped>
  1957. .info-table {
  1958. border: 1px solid #e0e0e0;
  1959. border-radius: 4px;
  1960. overflow: hidden;
  1961. }
  1962. .table-row {
  1963. display: flex;
  1964. border-bottom: 1px solid #e0e0e0;
  1965. }
  1966. .table-row:last-child {
  1967. border-bottom: none;
  1968. }
  1969. .table-cell {
  1970. flex: 1;
  1971. border-right: 1px solid #e0e0e0;
  1972. padding: 12px 8px;
  1973. min-height: 44px;
  1974. display: flex;
  1975. align-items: center;
  1976. }
  1977. .table-cell:last-child {
  1978. border-right: none;
  1979. }
  1980. .table-cell.full-width {
  1981. flex: 1;
  1982. border-right: none;
  1983. }
  1984. .cell-content {
  1985. display: flex;
  1986. align-items: center;
  1987. width: 100%;
  1988. }
  1989. .cell-label {
  1990. font-weight: 500;
  1991. /* 统一字体大小为 14px(Element 表单默认) */
  1992. font-size: 14px;
  1993. color: #606266;
  1994. min-width: 80px;
  1995. margin-right: 8px;
  1996. flex-shrink: 0;
  1997. }
  1998. .cell-value {
  1999. /* 统一字体大小为 14px(Element 输入框默认) */
  2000. font-size: 14px;
  2001. color: #303133;
  2002. /* 统一行高为 1.5(Element 组件默认行高) */
  2003. line-height: 1.5;
  2004. flex: 1;
  2005. word-break: break-all;
  2006. }
  2007. /* 响应式设计 */
  2008. @media (max-width: 768px) {
  2009. .table-row {
  2010. flex-direction: column;
  2011. }
  2012. .table-cell {
  2013. border-right: none;
  2014. border-bottom: 1px solid #e0e0e0;
  2015. }
  2016. .table-cell:last-child {
  2017. border-bottom: none;
  2018. }
  2019. }
  2020. .daily-report-title {
  2021. text-align: center;
  2022. margin: 20px 0;
  2023. padding: 10px;
  2024. border-bottom: 2px solid #409eff;
  2025. }
  2026. .daily-report-title h2 {
  2027. margin: 0;
  2028. color: #303133;
  2029. font-size: 16px;
  2030. font-weight: bold;
  2031. }
  2032. /* 为第二、三部分增加左右留白 */
  2033. .section-padding {
  2034. padding-left: 0px;
  2035. padding-right: 40px;
  2036. }
  2037. .project-info-section {
  2038. margin: 20px 0;
  2039. padding: 20px;
  2040. background-color: #f8f9fa;
  2041. border-radius: 4px;
  2042. border: 1px solid #e9ecef;
  2043. }
  2044. .info-row {
  2045. padding: 12px 0;
  2046. border-bottom: 1px solid #e9ecef;
  2047. }
  2048. .info-row:last-child {
  2049. border-bottom: none;
  2050. }
  2051. .info-label {
  2052. font-weight: bold;
  2053. color: #495057;
  2054. margin-right: 8px;
  2055. }
  2056. .info-value {
  2057. color: #212529;
  2058. }
  2059. :deep(.el-textarea .el-textarea__inner) {
  2060. min-height: 80px;
  2061. }
  2062. /* 确保表单label不换行 */
  2063. :deep(.el-form-item__label) {
  2064. white-space: nowrap;
  2065. text-overflow: ellipsis;
  2066. overflow: hidden;
  2067. }
  2068. /* 甲方字段:单行显示+超出省略 */
  2069. .single-line-ellipsis {
  2070. /* 强制文本单行显示 */
  2071. white-space: nowrap;
  2072. /* 超出容器部分隐藏 */
  2073. overflow: hidden;
  2074. /* 超出部分显示省略号 */
  2075. text-overflow: ellipsis;
  2076. /* 避免文本被截断(可选,根据需求调整) */
  2077. word-break: normal;
  2078. }
  2079. /* 设备配置字段:换行缩进(与首行对齐) */
  2080. .indent-multiline {
  2081. /* 首行及换行后缩进 2em(与 label 宽度匹配,可根据需求调整) */
  2082. text-indent: 0em;
  2083. /* 允许长文本换行(覆盖原有 cell-value 的 break-all,确保中文换行正常) */
  2084. word-break: break-word;
  2085. /* 保证换行后文本正常显示(可选,清除可能的 nowrap 影响) */
  2086. white-space: normal;
  2087. }
  2088. /* 添加审批模式下的样式 */
  2089. .approval-notice {
  2090. margin-top: 10px;
  2091. }
  2092. /* 审批模式下表单字段的只读样式 */
  2093. :deep(.el-form-item.is-disabled .el-input__inner),
  2094. :deep(.el-form-item.is-disabled .el-textarea__inner) {
  2095. background-color: #f5f7fa;
  2096. border-color: #e4e7ed;
  2097. color: #c0c4cc;
  2098. cursor: not-allowed;
  2099. }
  2100. :deep(.el-form-item.is-disabled .el-select .el-input__inner) {
  2101. background-color: #f5f7fa;
  2102. border-color: #e4e7ed;
  2103. color: #c0c4cc;
  2104. cursor: not-allowed;
  2105. }
  2106. :deep(.el-form-item.is-disabled .el-date-editor .el-input__inner) {
  2107. background-color: #f5f7fa;
  2108. border-color: #e4e7ed;
  2109. color: #c0c4cc;
  2110. cursor: not-allowed;
  2111. }
  2112. /* 只读模式下表单字段的样式 */
  2113. :deep(.el-form-item.is-disabled .el-input__inner),
  2114. :deep(.el-form-item.is-disabled .el-textarea__inner),
  2115. :deep(.el-form-item.is-disabled .el-select .el-input__inner),
  2116. :deep(.el-form-item.is-disabled .el-date-editor .el-input__inner) {
  2117. background-color: #f5f7fa;
  2118. border-color: #e4e7ed;
  2119. color: #606266; /* 保持文字可读性 */
  2120. cursor: not-allowed;
  2121. }
  2122. /* 详情模式下的特殊样式 */
  2123. .detail-mode .cell-value {
  2124. color: #303133;
  2125. font-weight: normal;
  2126. }
  2127. /* 添加审批意见区域的样式 */
  2128. .approval-opinion-section {
  2129. margin-top: 20px;
  2130. border-top: 2px solid #f0f0f0;
  2131. padding-top: 20px;
  2132. }
  2133. /* 审批意见文本域样式 */
  2134. :deep(.approval-opinion .el-textarea__inner) {
  2135. min-height: 100px;
  2136. resize: vertical;
  2137. }
  2138. /* 审批意见标签样式 */
  2139. :deep(.approval-opinion .el-form-item__label) {
  2140. font-weight: bold;
  2141. color: #606266;
  2142. }
  2143. /* 附件列表样式 */
  2144. .attachment-list {
  2145. width: 100%;
  2146. margin-top: 5px;
  2147. border: 1px solid #e0e0e0;
  2148. border-radius: 4px;
  2149. padding: 10px;
  2150. background-color: #fafafa;
  2151. box-sizing: border-box;
  2152. }
  2153. .attachment-item {
  2154. display: flex;
  2155. justify-content: space-between;
  2156. align-items: center;
  2157. padding: 8px 12px;
  2158. border-bottom: 1px solid #f0f0f0;
  2159. }
  2160. .attachment-item:last-child {
  2161. border-bottom: none;
  2162. }
  2163. .attachment-name {
  2164. flex: 1;
  2165. color: #606266;
  2166. font-size: 11px;
  2167. }
  2168. .no-attachment {
  2169. color: #909399;
  2170. font-style: italic;
  2171. margin-top: 5px;
  2172. padding: 10px;
  2173. }
  2174. /* 附件名称链接样式 */
  2175. .attachment-name {
  2176. color: #409eff;
  2177. text-decoration: underline;
  2178. cursor: pointer;
  2179. }
  2180. .attachment-name:hover {
  2181. color: #66b1ff;
  2182. }
  2183. /* 只读模式下的设备显示样式 */
  2184. .device-display-readonly {
  2185. color: #606266;
  2186. font-size: 11px;
  2187. line-height: 1.5;
  2188. background-color: #f5f7fa;
  2189. padding: 8px 12px;
  2190. border-radius: 4px;
  2191. border: 1px solid #e4e7ed;
  2192. display: inline-block;
  2193. min-width: 200px;
  2194. }
  2195. .no-device {
  2196. margin-left: 10px;
  2197. color: #909399;
  2198. font-style: italic;
  2199. }
  2200. /* 设备选择对话框样式 */
  2201. .transfer-container {
  2202. text-align: center;
  2203. padding: 0px;
  2204. }
  2205. .transfer-component {
  2206. width: 100%;
  2207. min-width: 600px;
  2208. }
  2209. :deep(.el-transfer-panel) {
  2210. width: 40% !important;
  2211. }
  2212. :deep(.el-transfer-panel__item) {
  2213. display: flex !important;
  2214. align-items: center !important;
  2215. height: 32px !important;
  2216. line-height: 32px !important;
  2217. padding: 0 8px !important;
  2218. margin: 0 !important;
  2219. white-space: nowrap;
  2220. overflow: hidden;
  2221. text-overflow: ellipsis;
  2222. }
  2223. .transfer-option-text {
  2224. display: inline-block;
  2225. max-width: 100%;
  2226. }
  2227. :deep(.el-transfer-panel__list) {
  2228. width: 100% !important;
  2229. }
  2230. .device-display-container {
  2231. /* 与其他文本域保持相同的宽度和样式 */
  2232. display: inline-block;
  2233. width: 100%; /* 减去按钮宽度 */
  2234. min-height: 32px;
  2235. line-height: 32px;
  2236. padding: 0 12px;
  2237. margin-left: 0px;
  2238. border-radius: 4px;
  2239. border: 1px solid #e4e7ed;
  2240. background-color: #fff;
  2241. font-size: 11px;
  2242. /* 文本溢出处理 */
  2243. white-space: nowrap;
  2244. overflow: hidden;
  2245. text-overflow: ellipsis;
  2246. }
  2247. /* 只读模式下的设备显示样式 */
  2248. :deep(.is-disabled) .device-display-container {
  2249. background-color: #f5f7fa;
  2250. color: #606266;
  2251. cursor: not-allowed;
  2252. }
  2253. /* 附件容器样式调整 */
  2254. .attachment-container {
  2255. /* 与其他文本域保持相同的宽度和边距 */
  2256. width: 100%;
  2257. margin-top: 10px;
  2258. }
  2259. /* 未选择设备字段的只读样式 */
  2260. :deep(.unselected-device .el-textarea__inner) {
  2261. background-color: #f5f7fa;
  2262. border-color: #e4e7ed;
  2263. color: #909399;
  2264. cursor: not-allowed;
  2265. resize: none;
  2266. }
  2267. /* 平台井工作量区域专用样式 */
  2268. .platform-workload-section {
  2269. padding-left: 0px;
  2270. padding-right: 0px; /* 去掉右侧间距 */
  2271. }
  2272. /* 表格样式优化 */
  2273. .platform-workload-el-table {
  2274. width: 100%;
  2275. }
  2276. /* 表头不换行 */
  2277. :deep(.platform-workload-el-table .el-table__header-wrapper th) {
  2278. white-space: nowrap;
  2279. text-overflow: ellipsis;
  2280. overflow: hidden;
  2281. }
  2282. /* 单元格内容不换行 */
  2283. :deep(.platform-workload-el-table .el-table__body-wrapper td) {
  2284. white-space: nowrap;
  2285. text-overflow: ellipsis;
  2286. overflow: hidden;
  2287. }
  2288. /* 强制设置表头宽度为100% */
  2289. :deep(.platform-workload-el-table .el-table__header) {
  2290. width: 100% !important;
  2291. min-width: 100% !important;
  2292. }
  2293. /* 强制设置表格主体宽度为100% */
  2294. :deep(.platform-workload-el-table .el-table__body) {
  2295. width: 100% !important;
  2296. min-width: 100% !important;
  2297. }
  2298. /* 确保表格填满容器 */
  2299. :deep(.platform-workload-el-table .el-table) {
  2300. width: 100% !important;
  2301. }
  2302. /* 表格容器填满父容器 */
  2303. .platform-workload-table {
  2304. width: 100%;
  2305. }
  2306. /* 油耗信息区域样式 */
  2307. .fuel-consumption-section {
  2308. padding-left: 0px;
  2309. padding-right: 0px;
  2310. margin-top: 20px;
  2311. }
  2312. /* 强制表格宽度为100% */
  2313. :deep(.fuel-consumption-el-table) {
  2314. width: 100% !important;
  2315. min-width: 100% !important;
  2316. }
  2317. /* 确保表格内部元素也充满宽度 */
  2318. :deep(.fuel-consumption-el-table .el-table) {
  2319. width: 100% !important;
  2320. min-width: 100% !important;
  2321. }
  2322. /* 强制设置表头宽度为100% */
  2323. :deep(.fuel-consumption-el-table .el-table__header) {
  2324. width: 100% !important;
  2325. min-width: 100% !important;
  2326. }
  2327. /* 表头不换行 */
  2328. :deep(.fuel-consumption-el-table .el-table__header-wrapper th) {
  2329. white-space: nowrap;
  2330. text-overflow: ellipsis;
  2331. overflow: hidden;
  2332. background-color: #f5f7fa;
  2333. color: #606266;
  2334. font-weight: bold;
  2335. }
  2336. /* 强制设置表格主体宽度为100% */
  2337. :deep(.fuel-consumption-el-table .el-table__body) {
  2338. width: 100% !important;
  2339. min-width: 100% !important;
  2340. }
  2341. /* 表头和表体都设置为100%宽度 */
  2342. :deep(.fuel-consumption-el-table .el-table__header-wrapper),
  2343. :deep(.fuel-consumption-el-table .el-table__body-wrapper) {
  2344. width: 100% !important;
  2345. }
  2346. /* 单元格内容居中 */
  2347. :deep(.fuel-consumption-el-table .el-table__body-wrapper td) {
  2348. text-align: center;
  2349. white-space: nowrap;
  2350. text-overflow: ellipsis;
  2351. overflow: hidden;
  2352. }
  2353. /* 实际油耗输入框样式 */
  2354. :deep(.fuel-consumption-el-table .el-input__inner) {
  2355. text-align: center;
  2356. padding: 0 5px;
  2357. height: 28px;
  2358. line-height: 28px;
  2359. }
  2360. /* 只读模式下的数值显示 */
  2361. .fuel-consumption-el-table .readonly-value {
  2362. color: #606266;
  2363. font-weight: normal;
  2364. }
  2365. /* 强制设置表格宽度为100% */
  2366. :deep(.fuel-consumption-el-table .el-table) {
  2367. width: 100% !important;
  2368. }
  2369. /* 表格容器填满父容器 */
  2370. .fuel-consumption-table {
  2371. width: 100%;
  2372. overflow-x: auto;
  2373. }
  2374. /* 响应式调整 */
  2375. @media (max-width: 768px) {
  2376. .fuel-consumption-section {
  2377. padding-left: 10px;
  2378. padding-right: 10px;
  2379. }
  2380. :deep(.fuel-consumption-el-table .el-table__header-wrapper th),
  2381. :deep(.fuel-consumption-el-table .el-table__body-wrapper td) {
  2382. padding: 8px 5px;
  2383. font-size: 12px;
  2384. }
  2385. }
  2386. /* 当日油耗输入框样式优化 */
  2387. :deep(.el-form-item .el-input-number) {
  2388. width: 100%;
  2389. }
  2390. /* 当日油耗字段在只读模式下的样式 */
  2391. :deep(.is-disabled .el-input__inner[type="number"]) {
  2392. background-color: #f5f7fa;
  2393. border-color: #e4e7ed;
  2394. color: #606266;
  2395. cursor: not-allowed;
  2396. }
  2397. </style>