FillDailyReportForm.vue 90 KB

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