FillDailyReportForm.vue 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662
  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">{{ dailyReportData.wellName || dailyReportData.taskName || '-' }}</span>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="table-row">
  42. <div class="table-cell">
  43. <div class="cell-content">
  44. <span class="cell-label">施工队伍:</span>
  45. <span class="cell-value">{{ dailyReportData.deptName || '-' }}</span>
  46. </div>
  47. </div>
  48. <div class="table-cell">
  49. <div class="cell-content">
  50. <span class="cell-label">施工地点:</span>
  51. <span class="cell-value">{{ dailyReportData.location || '-' }}</span>
  52. </div>
  53. </div>
  54. <div class="table-cell">
  55. <div class="cell-content">
  56. <span class="cell-label">工艺:</span>
  57. <span class="cell-value">{{ dailyReportData.techniqueNames || '-' }}</span>
  58. </div>
  59. </div>
  60. </div>
  61. <div class="table-row">
  62. <div class="table-cell">
  63. <div class="cell-content">
  64. <span class="cell-label">搬迁日期:</span>
  65. <span class="cell-value">{{ formatDate(dailyReportData.dpDate) || '-' }}</span>
  66. </div>
  67. </div>
  68. <div class="table-cell">
  69. <div class="cell-content">
  70. <span class="cell-label">开工日期:</span>
  71. <span class="cell-value">{{ formatDate(dailyReportData.sgDate) || '-' }}</span>
  72. </div>
  73. </div>
  74. <div class="table-cell">
  75. <div class="cell-content">
  76. <span class="cell-label">完工日期:</span>
  77. <span class="cell-value">{{ formatDate(dailyReportData.wgDate) || '-' }}</span>
  78. </div>
  79. </div>
  80. </div>
  81. <div class="table-row">
  82. <div class="table-cell">
  83. <div class="cell-content">
  84. <span class="cell-label">施工周期D:</span>
  85. <span class="cell-value">{{ constructionPeriod || 0 }}</span>
  86. </div>
  87. </div>
  88. <div class="table-cell">
  89. <div class="cell-content">
  90. <span class="cell-label">停待时间D:</span>
  91. <span class="cell-value">{{ dailyReportData.faultDowntime || 0 }}</span>
  92. </div>
  93. </div>
  94. <div class="table-cell">
  95. <div class="cell-content">
  96. <span class="cell-label">带班干部:</span>
  97. <span class="cell-value">{{ dailyReportData.responsiblePersonNames || '-' }}</span>
  98. </div>
  99. </div>
  100. </div>
  101. <!-- 第五行:设备配置(单独一行) -->
  102. <div class="table-row">
  103. <div class="table-cell full-width">
  104. <div class="cell-content">
  105. <span class="cell-label">设备配置:</span>
  106. <span class="cell-value indent-multiline">{{ dailyReportData.deviceNames || '-' }}</span>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. </ContentWrap>
  112. <!-- 第三部分:日报填报表单 -->
  113. <ContentWrap class="section-padding">
  114. <el-form
  115. ref="formRef"
  116. :model="formData"
  117. :rules="isReadonlyMode ? {} : formRules"
  118. v-loading="formLoading"
  119. style="margin-top: 1em"
  120. label-width="200px"
  121. :disabled="isReadonlyMode"
  122. >
  123. <!-- 第一行:时间节点、施工状态 -->
  124. <el-row :gutter="30">
  125. <el-col :span="12">
  126. <el-form-item label="时间节点" prop="timeRange">
  127. <el-time-picker
  128. is-range
  129. v-model="formData.timeRange"
  130. range-separator="至"
  131. start-placeholder="开始时间"
  132. end-placeholder="结束时间"
  133. placeholder="选择时间范围"
  134. style="width: 100%"
  135. :readonly="isReadonlyMode"
  136. :disabled="isReadonlyMode"
  137. />
  138. </el-form-item>
  139. </el-col>
  140. <el-col :span="12">
  141. <el-form-item label="施工状态" prop="rdStatus">
  142. <el-select v-model="formData.rdStatus" placeholder="请选择施工状态"
  143. style="width: 100%" :disabled="isReadonlyMode">
  144. <el-option
  145. v-for="dict in rdStatusOptions"
  146. :key="dict.value"
  147. :label="dict.label"
  148. :value="dict.value"
  149. />
  150. </el-select>
  151. </el-form-item>
  152. </el-col>
  153. </el-row>
  154. <!-- 施工设备字段 -->
  155. <el-row>
  156. <el-col :span="24">
  157. <el-form-item label="施工设备" prop="deviceIds">
  158. <!-- 编辑模式:显示选择按钮 -->
  159. <template v-if="isEditMode">
  160. <el-button
  161. @click="openDeviceDialog"
  162. type="primary"
  163. size="small"
  164. :disabled="formLoading"
  165. >
  166. 选择设备
  167. </el-button>
  168. <el-tooltip
  169. v-if="formData.deviceIds && formData.deviceIds.length > 0"
  170. :content="getAllDeviceNamesForDisplay"
  171. placement="top"
  172. >
  173. <span class="device-display-container">
  174. {{ formatDevicesForDisplay }}
  175. </span>
  176. </el-tooltip>
  177. <span v-else class="no-device">
  178. 未选择设备
  179. </span>
  180. </template>
  181. <!-- 只读模式:只显示设备信息 -->
  182. <template v-else>
  183. <el-tooltip
  184. v-if="formData.deviceIds && formData.deviceIds.length > 0"
  185. :content="getAllDeviceNamesForDisplay"
  186. placement="top"
  187. >
  188. <span class="device-display-container">
  189. {{ formatDevicesForDisplay }}
  190. </span>
  191. </el-tooltip>
  192. <span v-else class="no-device">-</span>
  193. </template>
  194. </el-form-item>
  195. </el-col>
  196. </el-row>
  197. <!-- 未施工设备 -->
  198. <el-row>
  199. <el-col :span="24">
  200. <el-form-item label="未施工设备" prop="unSelectedDeviceNames">
  201. <el-input
  202. v-model="unSelectedDeviceNames"
  203. type="textarea"
  204. :rows="2"
  205. placeholder="未施工的设备将显示在这里"
  206. :readonly="true"
  207. class="unselected-device"
  208. />
  209. </el-form-item>
  210. </el-col>
  211. </el-row>
  212. <!-- 第二行:施工工艺 -->
  213. <el-row>
  214. <el-col :span="24">
  215. <el-form-item label="施工工艺" prop="techniqueIds">
  216. <el-select v-model="formData.techniqueIds" placeholder="请选择施工工艺"
  217. style="width: 100%" multiple :disabled="isReadonlyMode">
  218. <el-option
  219. v-for="dict in techniqueOptions"
  220. :key="dict.value"
  221. :label="dict.label"
  222. :value="dict.value"
  223. />
  224. </el-select>
  225. </el-form-item>
  226. </el-col>
  227. </el-row>
  228. <!-- 动态属性区域:施工工艺与当日生产动态之间 -->
  229. <el-row v-if="dynamicAttrs.length > 0" :gutter="30">
  230. <el-col
  231. v-for="attr in dynamicAttrs"
  232. :key="attr.id"
  233. :span="attr.dataType === 'textarea' ? 24 : 12"
  234. >
  235. <el-form-item
  236. :label="attr.name + (attr.unit ? `(${attr.unit})` : '')"
  237. :prop="'dynamicFields.' + attr.identifier"
  238. :rules="isReadonlyMode ? [] : getDynamicAttrRules(attr)"
  239. >
  240. <!-- 文本类型 -->
  241. <el-input
  242. v-if="attr.dataType === 'text'"
  243. v-model="formData.dynamicFields[attr.identifier]"
  244. :placeholder="`请输入${attr.name}`"
  245. :readonly="isReadonlyMode"
  246. />
  247. <!-- 文本域类型 -->
  248. <el-input
  249. v-else-if="attr.dataType === 'textarea'"
  250. v-model="formData.dynamicFields[attr.identifier]"
  251. :placeholder="`请输入${attr.name}`"
  252. type="textarea"
  253. :rows="3"
  254. :readonly="isReadonlyMode"
  255. />
  256. <!-- 数字类型 -->
  257. <el-input
  258. v-else-if="attr.dataType === 'double'"
  259. v-model="formData.dynamicFields[attr.identifier]"
  260. :placeholder="`请输入${attr.name}`"
  261. type="number"
  262. :min="attr.minValue || undefined"
  263. :max="attr.maxValue || undefined"
  264. :readonly="isReadonlyMode"
  265. />
  266. <!-- 日期类型 -->
  267. <el-date-picker
  268. v-else-if="attr.dataType === 'date'"
  269. v-model="formData.dynamicFields[attr.identifier]"
  270. type="date"
  271. value-format="x"
  272. :placeholder="`选择${attr.name}`"
  273. style="width: 100%"
  274. :readonly="isReadonlyMode"
  275. />
  276. <!-- 默认文本输入 -->
  277. <el-input
  278. v-else
  279. v-model="formData.dynamicFields[attr.identifier]"
  280. :placeholder="`请输入${attr.name}`"
  281. :readonly="isReadonlyMode"
  282. />
  283. </el-form-item>
  284. </el-col>
  285. </el-row>
  286. <!-- 第三行:当日生产动态 -->
  287. <el-row>
  288. <el-col :span="24">
  289. <el-form-item label="当日生产动态" prop="productionStatus">
  290. <el-input
  291. v-model="formData.productionStatus"
  292. type="textarea"
  293. :rows="3"
  294. placeholder="请输入当日生产动态"
  295. :readonly="isReadonlyMode"
  296. />
  297. </el-form-item>
  298. </el-col>
  299. </el-row>
  300. <!-- 第四行:下步工作计划 -->
  301. <el-row>
  302. <el-col :span="24">
  303. <el-form-item label="下步工作计划" prop="nextPlan">
  304. <el-input
  305. v-model="formData.nextPlan"
  306. type="textarea"
  307. :rows="3"
  308. placeholder="请输入下步工作计划"
  309. :readonly="isReadonlyMode"
  310. />
  311. </el-form-item>
  312. </el-col>
  313. </el-row>
  314. <!-- 第五行:外租设备 -->
  315. <el-row>
  316. <el-col :span="24">
  317. <el-form-item label="外租设备" prop="externalRental">
  318. <el-input
  319. v-model="formData.externalRental"
  320. type="textarea"
  321. :rows="3"
  322. placeholder="请输入外租设备信息"
  323. :readonly="isReadonlyMode"
  324. />
  325. </el-form-item>
  326. </el-col>
  327. </el-row>
  328. <!-- 故障情况 -->
  329. <el-row>
  330. <el-col :span="24">
  331. <el-form-item label="故障情况" prop="malfunction">
  332. <el-input
  333. v-model="formData.malfunction"
  334. type="textarea"
  335. :rows="3"
  336. placeholder="请输入故障情况"
  337. :readonly="isReadonlyMode"
  338. />
  339. </el-form-item>
  340. </el-col>
  341. </el-row>
  342. <!-- 故障误工H -->
  343. <el-row>
  344. <el-col :span="24">
  345. <el-form-item label="故障误工H" prop="faultDowntime">
  346. <el-input
  347. v-model="formData.faultDowntime"
  348. type="number"
  349. :rows="3"
  350. placeholder="请输入故障误工H"
  351. :readonly="isReadonlyMode"
  352. />
  353. </el-form-item>
  354. </el-col>
  355. </el-row>
  356. <!-- 第六行:上传附件 -->
  357. <el-row>
  358. <el-col :span="24">
  359. <el-form-item label="附件">
  360. <!-- 文件上传组件 -->
  361. <FileUpload
  362. v-if="!isReadonlyMode"
  363. ref="fileUploadRef"
  364. :device-id="deviceId"
  365. :show-folder-button="false"
  366. @upload-success="handleUploadSuccess"
  367. />
  368. <!-- 已上传附件列表显示 -->
  369. <div v-if="formData.attachments && formData.attachments.length > 0" class="attachment-container">
  370. <div class="attachment-list">
  371. <div
  372. v-for="(attachment, index) in formData.attachments"
  373. :key="attachment.id || index"
  374. class="attachment-item"
  375. >
  376. <!-- 为附件名称添加点击事件,传递整个附件对象 -->
  377. <a class="attachment-name" @click="inContent(attachment)">
  378. {{ attachment.filename }}
  379. </a>
  380. <el-button
  381. v-if="!isReadonlyMode"
  382. type="danger"
  383. link
  384. size="small"
  385. @click="removeAttachment(index)"
  386. >
  387. 删除
  388. </el-button>
  389. </div>
  390. </div>
  391. </div>
  392. <!-- 审批模式下只显示附件列表 -->
  393. <div v-else-if="isApprovalMode && (!formData.attachments || formData.attachments.length === 0)" class="no-attachment">
  394. 无附件
  395. </div>
  396. </el-form-item>
  397. </el-col>
  398. </el-row>
  399. </el-form>
  400. </ContentWrap>
  401. <!-- 第四部分:审批意见 - 只在审批模式下显示 -->
  402. <ContentWrap class="section-padding" v-if="isApprovalMode">
  403. <el-form
  404. ref="approvalFormRef"
  405. :model="approvalForm"
  406. style="margin-top: 1em"
  407. label-width="200px"
  408. >
  409. <el-row>
  410. <el-col :span="24">
  411. <el-form-item label="审批意见" prop="opinion">
  412. <el-input
  413. v-model="approvalForm.opinion"
  414. type="textarea"
  415. :rows="4"
  416. placeholder="请输入审批意见"
  417. maxlength="500"
  418. show-word-limit
  419. />
  420. </el-form-item>
  421. </el-col>
  422. </el-row>
  423. </el-form>
  424. </ContentWrap>
  425. <!-- 操作按钮 -->
  426. <ContentWrap class="section-padding" v-if="isEditMode">
  427. <el-form>
  428. <el-form-item style="float: right">
  429. <el-button @click="submitForm" type="primary" :disabled="formLoading">
  430. {{ t('common.save') }}
  431. </el-button>
  432. <el-button @click="close">{{ t('common.cancel') }}</el-button>
  433. </el-form-item>
  434. </el-form>
  435. </ContentWrap>
  436. <!-- 审批模式下的操作按钮 -->
  437. <ContentWrap class="section-padding" v-if="isApprovalMode">
  438. <el-form>
  439. <el-form-item style="float: right">
  440. <el-button @click="handleApprove('pass')" type="success">
  441. 审批通过
  442. </el-button>
  443. <el-button @click="handleApprove('reject')" type="danger">
  444. 审批驳回
  445. </el-button>
  446. <el-button @click="close">{{ t('common.close') }}</el-button>
  447. </el-form-item>
  448. </el-form>
  449. </ContentWrap>
  450. <!-- 详情模式下的操作按钮 - 只有关闭按钮 -->
  451. <ContentWrap class="section-padding" v-if="isDetailMode">
  452. <el-form>
  453. <el-form-item style="float: right">
  454. <el-button @click="close">{{ t('common.close') }}</el-button>
  455. </el-form-item>
  456. </el-form>
  457. </ContentWrap>
  458. </ContentWrap>
  459. <!-- 设备选择对话框 -->
  460. <el-dialog
  461. v-model="deviceDialogVisible"
  462. title="选择施工设备"
  463. width="1000px"
  464. :before-close="handleDeviceDialogClose"
  465. class="device-select-dialog"
  466. >
  467. <div class="transfer-container">
  468. <el-transfer
  469. v-model="selectedDeviceIds"
  470. :data="filteredDeviceList"
  471. :titles="['可选设备', '已选设备']"
  472. :props="{ key: 'id', label: 'deviceCode' }"
  473. filterable
  474. class="transfer-component"
  475. @change="handleTransferChange"
  476. >
  477. <template #default="{ option }">
  478. <el-tooltip
  479. effect="dark"
  480. placement="top"
  481. :content="`${option.deviceCode || ''} - ${option.deviceName || ''}`"
  482. :disabled="!option.deviceCode && !option.deviceName"
  483. transition="fade-in-linear"
  484. >
  485. <span class="transfer-option-text">
  486. {{ option.deviceCode }} - {{ option.deviceName }}
  487. </span>
  488. </el-tooltip>
  489. </template>
  490. </el-transfer>
  491. </div>
  492. <template #footer>
  493. <span class="dialog-footer">
  494. <el-button @click="handleDeviceDialogClose">取消</el-button>
  495. <el-button type="primary" @click="confirmDeviceSelection">确定</el-button>
  496. </span>
  497. </template>
  498. </el-dialog>
  499. </template>
  500. <script setup lang="ts">
  501. import { ref, reactive, computed, onMounted, nextTick, watch } from 'vue'
  502. import { useI18n } from '@/hooks/web/useI18n'
  503. import { useMessage } from '@/hooks/web/useMessage'
  504. import { useTagsViewStore } from '@/store/modules/tagsView'
  505. import { useRouter, useRoute } from 'vue-router'
  506. import {DICT_TYPE, getDictLabel, getStrDictOptions} from '@/utils/dict'
  507. import { IotRdDailyReportApi } from '@/api/pms/iotrddailyreport'
  508. import { IotDailyReportAttrsApi } from '@/api/pms/iotdailyreportattrs'
  509. import * as DeptApi from '@/api/system/dept'
  510. import { useUserStore } from '@/store/modules/user'
  511. import dayjs from 'dayjs'
  512. import FileUpload from "@/components/UploadFile/src/FileUpload.vue";
  513. const { t } = useI18n()
  514. const message = useMessage()
  515. const { delView } = useTagsViewStore()
  516. const { push, currentRoute } = useRouter()
  517. const { params } = useRoute()
  518. const userStore = useUserStore()
  519. /** 填报日报 表单 */
  520. defineOptions({ name: 'FillDailyReportForm' })
  521. const formLoading = ref(false)
  522. const formRef = ref()
  523. const id = params.id // 瑞都日报id
  524. // 日报数据
  525. const dailyReportData = ref<any>({})
  526. // 添加模式判断计算属性
  527. const isApprovalMode = computed(() => params.mode === 'approval')
  528. const isDetailMode = computed(() => params.mode === 'detail')
  529. const isEditMode = computed(() => params.mode === 'fill' || !params.mode) // 默认为编辑模式
  530. // 只读模式判断:审批模式或详情模式都为只读
  531. const isReadonlyMode = computed(() => isApprovalMode.value || isDetailMode.value)
  532. // 页面标题计算
  533. const pageTitle = computed(() => {
  534. if (isApprovalMode.value) {
  535. return dailyReportData.value.wellName && dailyReportData.value.constructionStartDate
  536. ? `${dailyReportData.value.wellName} - ${formatDate(dailyReportData.value.constructionStartDate)} 日报审批`
  537. : '日报审批'
  538. } else if (isDetailMode.value) {
  539. return dailyReportData.value.wellName && dailyReportData.value.constructionStartDate
  540. ? `${dailyReportData.value.wellName} - ${formatDate(dailyReportData.value.constructionStartDate)} 日报详情`
  541. : '日报详情'
  542. } else {
  543. return dailyReportData.value.wellName && dailyReportData.value.constructionStartDate
  544. ? `${dailyReportData.value.wellName} - ${formatDate(dailyReportData.value.constructionStartDate)} 生产日报`
  545. : '日报填报'
  546. }
  547. })
  548. // 模式提示信息
  549. const modeNotice = computed(() => {
  550. if (isApprovalMode.value) {
  551. return '审批模式:所有字段均为只读'
  552. } else if (isDetailMode.value) {
  553. return '详情模式:所有字段均为只读'
  554. }
  555. return ''
  556. })
  557. // 动态属性相关变量
  558. const dynamicAttrs = ref<any[]>([]) // 存储动态属性列表
  559. // 添加设备选择相关变量
  560. const deviceDialogVisible = ref(false)
  561. const filteredDeviceList = ref<any[]>([])
  562. const selectedDeviceIds = ref<number[]>([])
  563. const deviceMap = ref<Record<number, any>>({})
  564. // 添加审批表单相关变量
  565. const approvalFormRef = ref()
  566. const approvalForm = reactive({
  567. opinion: '' // 审批意见
  568. })
  569. // 审批表单验证规则(可选,根据需求添加)
  570. const approvalFormRules = reactive({
  571. opinion: [
  572. { required: false, message: '请输入审批意见', trigger: 'blur' },
  573. { min: 0, max: 500, message: '审批意见长度不能超过500个字符', trigger: 'blur' }
  574. ]
  575. })
  576. // 添加文件上传组件的引用
  577. const fileUploadRef = ref()
  578. // 表单数据
  579. const formData = ref({
  580. id: undefined,
  581. deptId: undefined,
  582. companyId: undefined,
  583. deptName: undefined,
  584. constructionStartDate: undefined,
  585. contractName: undefined,
  586. projectDepartment: '',
  587. costCenterId: undefined,
  588. costCenter: '',
  589. // 新增日报填报字段
  590. timeRange: [ // 设置默认时间范围 8:00 - 8:00
  591. dayjs().hour(8).minute(0).second(0).toDate(),
  592. dayjs().hour(8).minute(0).second(0).toDate()
  593. ],
  594. startTime: undefined, // 开始时间
  595. endTime: undefined, // 结束时间
  596. rdStatus: '', // 施工状态
  597. deviceIds: [] as number[], // 设备ID数组
  598. techniqueIds: [], // 施工工艺
  599. productionStatus: '', // 当日生产动态
  600. nextPlan: '', // 下步工作计划
  601. externalRental: '', // 外租设备
  602. malfunction: '', // 故障情况
  603. faultDowntime: '', // 故障误工
  604. // 添加动态字段对象
  605. dynamicFields: {} as Record<string, any>,
  606. // 附件列表
  607. attachments: [] as any[]
  608. })
  609. // 添加上传成功处理函数
  610. const handleUploadSuccess = (result: any) => {
  611. console.log('上传成功:', result)
  612. try {
  613. // 检查响应是否成功
  614. if (!result.response) {
  615. message.error('上传响应数据异常')
  616. return
  617. }
  618. if (result.response.code !== 0) {
  619. message.error(result.response.msg || '文件上传失败')
  620. return
  621. }
  622. const responseData = result.response.data
  623. if (!responseData) {
  624. message.error('上传数据为空')
  625. return
  626. }
  627. // 处理返回的文件列表
  628. if (responseData.files && Array.isArray(responseData.files) && responseData.files.length > 0) {
  629. responseData.files.forEach((file: any) => {
  630. if (!file.filePath) {
  631. console.warn('文件缺少 filePath:', file)
  632. return
  633. }
  634. // 根据后端返回的数据结构构建附件对象
  635. const attachment = {
  636. id: undefined,
  637. category: 'daily_report',
  638. bizId: formData.value.id,
  639. type: 'attachment',
  640. filename: file.name || '未知文件',
  641. fileType: getFileType(file.name),
  642. filePath: file.filePath, //使用正确的 filePath
  643. fileSize: formatFileSize(file.size || 0),
  644. remark: ''
  645. }
  646. // 添加到附件列表
  647. if (!formData.value.attachments) {
  648. formData.value.attachments = []
  649. }
  650. formData.value.attachments.push(attachment)
  651. })
  652. message.success(`成功上传 ${responseData.files.length} 个文件`)
  653. } else {
  654. console.warn('上传成功但没有返回文件信息')
  655. message.warning('上传成功但未获取到文件信息')
  656. }
  657. } catch (error) {
  658. console.error('处理上传结果时发生错误:', error)
  659. message.error('处理上传结果失败')
  660. }
  661. }
  662. // 删除附件
  663. const removeAttachment = (index: number) => {
  664. if (formData.value.attachments && formData.value.attachments.length > index) {
  665. formData.value.attachments.splice(index, 1)
  666. }
  667. }
  668. // 计算属性:未施工设备名称
  669. const unSelectedDeviceNames = computed(() => {
  670. const selectedDevices = dailyReportData.value.selectedDevices || []
  671. const selectedDeviceIds = formData.value.deviceIds || []
  672. if (selectedDevices.length === 0) {
  673. return '无可用设备'
  674. }
  675. // 筛选出未选择的设备
  676. const unselectedDevices = selectedDevices.filter((device: any) =>
  677. !selectedDeviceIds.includes(device.id)
  678. )
  679. if (unselectedDevices.length === 0) {
  680. return '所有设备都已施工'
  681. }
  682. // 提取设备名称并用逗号分隔
  683. const deviceNames = unselectedDevices
  684. .map((device: any) => device.deviceName || device.deviceCode || '未知设备')
  685. .filter((name: string) => name !== '未知设备')
  686. return deviceNames.join(', ') || '无未选择设备'
  687. })
  688. // 附件名称点击事件
  689. const inContent = async (attachment) => {
  690. if (!attachment || !attachment.filePath) {
  691. message.error('附件路径不存在')
  692. return
  693. }
  694. try {
  695. // 直接使用 attachment.filePath
  696. const filePath = attachment.filePath
  697. // 确保 filePath 是编码后的格式
  698. const encodedPath = encodeURIComponent(Base64.encode(filePath))
  699. // 打开预览窗口
  700. window.open(`http://doc.deepoil.cc:8012/onlinePreview?url=${encodedPath}`)
  701. } catch (error) {
  702. console.error('预览附件失败:', error)
  703. message.error('预览附件失败')
  704. }
  705. }
  706. // 获取文件类型辅助函数
  707. const getFileType = (filename: string) => {
  708. const ext = filename.split('.').pop()?.toLowerCase()
  709. if (['jpg', 'jpeg', 'png', 'gif', 'bmp'].includes(ext || '')) {
  710. return 'image'
  711. } else if (['pdf'].includes(ext || '')) {
  712. return 'pdf'
  713. } else if (['doc', 'docx'].includes(ext || '')) {
  714. return 'word'
  715. } else if (['xls', 'xlsx'].includes(ext || '')) {
  716. return 'excel'
  717. } else {
  718. return 'other'
  719. }
  720. }
  721. // 格式化文件大小辅助函数
  722. const formatFileSize = (bytes: number) => {
  723. if (bytes === 0) return '0 Bytes'
  724. const k = 1024
  725. const sizes = ['Bytes', 'KB', 'MB', 'GB']
  726. const i = Math.floor(Math.log(bytes) / Math.log(k))
  727. return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
  728. }
  729. // 计算属性:格式化设备显示
  730. const formatDevicesForDisplay = computed(() => {
  731. const deviceIds = formData.value.deviceIds
  732. if (!deviceIds || deviceIds.length === 0) {
  733. return '无设备'
  734. }
  735. const deviceNames = deviceIds
  736. .map(id => deviceMap.value[id]?.deviceName)
  737. .filter(name => name !== undefined && name !== '')
  738. if (deviceNames.length === 0) return '无设备'
  739. // 如果设备数量超过2个,显示前两个加省略号
  740. /* if (deviceNames.length > 2) {
  741. return `${deviceNames[0]}, ${deviceNames[1]}...`
  742. } */
  743. return deviceNames.join(', ')
  744. })
  745. // 计算属性:获取所有设备名称(用于tooltip)
  746. const getAllDeviceNamesForDisplay = computed(() => {
  747. const deviceIds = formData.value.deviceIds
  748. if (!deviceIds || deviceIds.length === 0) {
  749. return '无设备'
  750. }
  751. const deviceNames = deviceIds
  752. .map(id => deviceMap.value[id]?.deviceCode || '未知设备')
  753. .filter(name => name !== '未知设备')
  754. return deviceNames.join(', ') || '无有效设备'
  755. })
  756. // 打开设备选择对话框
  757. const openDeviceDialog = async () => {
  758. if (!dailyReportData.value.deptId) {
  759. message.error('请先加载项目信息')
  760. return
  761. }
  762. try {
  763. formLoading.value = true
  764. selectedDeviceIds.value = [...(formData.value.deviceIds || [])]
  765. // 直接从日报数据的 selectedDevices 中获取设备列表
  766. const selectedDevices = dailyReportData.value.selectedDevices || []
  767. // 更新设备映射表
  768. const newDeviceMap = { ...deviceMap.value }
  769. selectedDevices.forEach((device: any) => {
  770. if (device.id) {
  771. newDeviceMap[device.id] = device
  772. }
  773. })
  774. deviceMap.value = newDeviceMap
  775. filteredDeviceList.value = selectedDevices
  776. deviceDialogVisible.value = true
  777. } catch (error) {
  778. console.error('获取设备列表失败:', error)
  779. message.error('获取设备列表失败')
  780. } finally {
  781. formLoading.value = false
  782. }
  783. }
  784. // 处理穿梭框变化
  785. const handleTransferChange = (value: number[], direction: string, movedKeys: number[]) => {
  786. // 可以添加额外的处理逻辑
  787. }
  788. // 确认设备选择
  789. const confirmDeviceSelection = () => {
  790. formData.value.deviceIds = [...selectedDeviceIds.value]
  791. deviceDialogVisible.value = false
  792. message.success(`已选择 ${selectedDeviceIds.value.length} 台设备`)
  793. }
  794. // 关闭设备选择对话框
  795. const handleDeviceDialogClose = () => {
  796. deviceDialogVisible.value = false
  797. }
  798. // 初始化设备数据
  799. const initDeviceData = (reportData: any) => {
  800. // 初始化设备ID
  801. if (reportData.deviceIds && Array.isArray(reportData.deviceIds)) {
  802. formData.value.deviceIds = [...reportData.deviceIds]
  803. } else {
  804. formData.value.deviceIds = []
  805. }
  806. // 初始化设备映射表(用于显示设备名称)
  807. if (reportData.selectedDevices && Array.isArray(reportData.selectedDevices)) {
  808. const newDeviceMap = { ...deviceMap.value }
  809. reportData.selectedDevices.forEach((device: any) => {
  810. if (device.id) {
  811. newDeviceMap[device.id] = device
  812. }
  813. })
  814. deviceMap.value = newDeviceMap
  815. }
  816. }
  817. // 表单验证规则
  818. const formRules = reactive({
  819. timeRange: [{ required: true, message: '时间节点不能为空', trigger: 'change' }],
  820. rdStatus: [{ required: true, message: '施工状态不能为空', trigger: 'change' }],
  821. techniqueIds: [{ required: true, message: '施工工艺不能为空', trigger: 'change' }],
  822. productionStatus: [{ required: true, message: '当日生产动态不能为空', trigger: 'blur' }]
  823. })
  824. const queryParams = reactive({
  825. deptId: undefined,
  826. techniqueIds: [],
  827. })
  828. // 下拉选项
  829. const rdStatusOptions = getStrDictOptions(DICT_TYPE.PMS_PROJECT_RD_STATUS) // 施工状态
  830. const techniqueOptions = getStrDictOptions(DICT_TYPE.PMS_PROJECT_RD_TECHNOLOGY) // 瑞都施工工艺
  831. // 计算属性:日报标题
  832. const dailyReportTitle = computed(() => {
  833. if (!dailyReportData.value.wellName || !dailyReportData.value.constructionStartDate) {
  834. return '日报填报'
  835. }
  836. const dateStr = formatDate(dailyReportData.value.constructionStartDate)
  837. return `${dailyReportData.value.wellName} - ${dateStr} 生产日报`
  838. })
  839. // 日报审批:日报标题
  840. const dailyReportApprovalTitle = computed(() => {
  841. if (!dailyReportData.value.wellName || !dailyReportData.value.constructionStartDate) {
  842. return '日报审批'
  843. }
  844. const dateStr = formatDate(dailyReportData.value.constructionStartDate)
  845. return `${dailyReportData.value.wellName} - ${dateStr} 日报审批`
  846. })
  847. // 计算属性:施工周期
  848. const constructionPeriod = computed(() => {
  849. const start = dailyReportData.value.constructionStartDate
  850. const end = dailyReportData.value.constructionEndDate
  851. if (!start || !end) return 0
  852. const startDate = dayjs(start)
  853. const endDate = dayjs(end)
  854. return endDate.diff(startDate, 'day')
  855. })
  856. // 日期格式化函数
  857. const formatDate = (timestamp: number) => {
  858. if (!timestamp) return ''
  859. return dayjs(timestamp).format('YYYY-MM-DD')
  860. }
  861. const close = () => {
  862. delView(unref(currentRoute))
  863. push({ name: 'FillDailyReport', params: {} })
  864. }
  865. /** 提交表单 */
  866. const emit = defineEmits(['success'])
  867. const submitForm = async () => {
  868. // 验证表单
  869. try {
  870. await formRef.value.validate()
  871. } catch (error) {
  872. return
  873. }
  874. // 处理时间范围数据
  875. if (formData.value.timeRange && formData.value.timeRange.length === 2) {
  876. // 将时间范围转换为 LocalTime 格式的字符串
  877. const startDate = dayjs(formData.value.timeRange[0])
  878. const endDate = dayjs(formData.value.timeRange[1])
  879. // 格式化为 HH:mm:ss 字符串,后端会自动转换为 LocalTime
  880. formData.value.startTime = startDate.format('HH:mm:ss')
  881. formData.value.endTime = endDate.format('HH:mm:ss')
  882. }
  883. // 构建动态属性 extProperty 数组
  884. const extProperties = dynamicAttrs.value.map(attr => {
  885. return {
  886. name: attr.name,
  887. sort: attr.sort,
  888. unit: attr.unit,
  889. actualValue: formData.value.dynamicFields[attr.identifier] || '', // 从 dynamicFields 中获取用户填写的值
  890. dataType: attr.dataType,
  891. maxValue: attr.maxValue,
  892. minValue: attr.minValue,
  893. required: attr.required,
  894. accessMode: attr.accessMode,
  895. identifier: attr.identifier,
  896. defaultValue: attr.defaultValue
  897. }
  898. })
  899. // 准备提交数据,包含动态字段
  900. const submitData = {
  901. ...formData.value,
  902. // 将动态字段组装成 extProperty 数组
  903. extProperty: extProperties,
  904. deviceIds: formData.value.deviceIds, // 设备ID集合
  905. }
  906. // 提交请求
  907. formLoading.value = true
  908. try {
  909. // 调用更新接口
  910. await IotRdDailyReportApi.updateIotRdDailyReport(submitData)
  911. message.success(t('common.updateSuccess'))
  912. close()
  913. // 发送操作成功的事件
  914. emit('success')
  915. } catch (error) {
  916. console.error('提交失败:', error)
  917. } finally {
  918. formLoading.value = false
  919. }
  920. }
  921. /** 重置表单 */
  922. const resetForm = () => {
  923. formRef.value?.resetFields()
  924. }
  925. // 初始化动态属性
  926. const initDynamicAttrs = (reportData: any) => {
  927. if (reportData.dailyReportAttrs && reportData.dailyReportAttrs.length > 0) {
  928. dynamicAttrs.value = reportData.dailyReportAttrs
  929. // 初始化动态字段的值
  930. const initialDynamicFields: Record<string, any> = {}
  931. // 优先从 extProperty 中获取实际值(编辑时)
  932. if (reportData.extProperty && reportData.extProperty.length > 0) {
  933. reportData.extProperty.forEach((extProp: any) => {
  934. if (extProp.identifier) {
  935. initialDynamicFields[extProp.identifier] = extProp.actualValue || ''
  936. }
  937. })
  938. }
  939. reportData.dailyReportAttrs.forEach((attr: any) => {
  940. if (!initialDynamicFields.hasOwnProperty(attr.identifier)) {
  941. // 优先使用实际值,如果没有则使用默认值
  942. const value = (attr.extProperty && attr.extProperty.actualValue !== undefined &&
  943. attr.extProperty.actualValue !== null && attr.extProperty.actualValue !== '')
  944. ? attr.extProperty.actualValue
  945. : (attr.defaultValue || (attr.extProperty?.defaultValue || ''))
  946. initialDynamicFields[attr.identifier] = value
  947. }
  948. })
  949. formData.value.dynamicFields = initialDynamicFields
  950. }
  951. }
  952. // 获取动态字段的验证规则
  953. const getDynamicAttrRules = (attr: any) => {
  954. const rules = []
  955. if (attr.required === 1) {
  956. rules.push({
  957. required: true,
  958. message: `${attr.name}不能为空`,
  959. trigger: 'blur'
  960. })
  961. }
  962. // 数字类型验证
  963. if (attr.dataType === 'double') {
  964. rules.push({
  965. validator: (rule: any, value: any, callback: any) => {
  966. if (value === '' || value === null || value === undefined) {
  967. callback()
  968. return
  969. }
  970. const numValue = Number(value)
  971. if (isNaN(numValue)) {
  972. callback(new Error(`${attr.name}必须是数字`))
  973. } else if (attr.minValue && numValue < Number(attr.minValue)) {
  974. callback(new Error(`${attr.name}不能小于${attr.minValue}`))
  975. } else if (attr.maxValue && numValue > Number(attr.maxValue)) {
  976. callback(new Error(`${attr.name}不能大于${attr.maxValue}`))
  977. } else {
  978. callback()
  979. }
  980. },
  981. trigger: 'blur'
  982. })
  983. }
  984. return rules
  985. }
  986. // 更新动态属性(处理交集、新增和删除)
  987. const updateDynamicAttrs = async (newAttrs: any[], newTechniqueIds: string[], oldTechniqueIds?: string[]) => {
  988. const oldAttrs = [...dynamicAttrs.value]
  989. const oldDynamicFields = { ...formData.value.dynamicFields }
  990. // 计算需要保留的字段(交集)
  991. const commonAttrs = oldAttrs.filter(oldAttr =>
  992. newAttrs.some(newAttr => newAttr.identifier === oldAttr.identifier)
  993. )
  994. // 计算需要新增的字段
  995. const addedAttrs = newAttrs.filter(newAttr =>
  996. !oldAttrs.some(oldAttr => oldAttr.identifier === newAttr.identifier)
  997. )
  998. // 计算需要删除的字段
  999. const removedAttrs = oldAttrs.filter(oldAttr =>
  1000. !newAttrs.some(newAttr => newAttr.identifier === oldAttr.identifier)
  1001. )
  1002. // 构建新的动态属性数组
  1003. const updatedAttrs = [...commonAttrs, ...addedAttrs]
  1004. // 构建新的动态字段对象
  1005. const updatedDynamicFields = { ...oldDynamicFields }
  1006. // 移除已删除的字段
  1007. removedAttrs.forEach(attr => {
  1008. delete updatedDynamicFields[attr.identifier]
  1009. })
  1010. // 初始化新增字段的值
  1011. addedAttrs.forEach(attr => {
  1012. if (!updatedDynamicFields[attr.identifier]) {
  1013. // 如果有默认值使用默认值,否则为空
  1014. updatedDynamicFields[attr.identifier] = attr.defaultValue ||
  1015. (attr.extProperty?.defaultValue || '')
  1016. }
  1017. })
  1018. // 更新响应式数据
  1019. dynamicAttrs.value = updatedAttrs
  1020. formData.value.dynamicFields = updatedDynamicFields
  1021. }
  1022. // 加载动态属性
  1023. const loadDynamicAttrs = async (newTechniqueIds: string[], oldTechniqueIds?: string[]) => {
  1024. try {
  1025. formLoading.value = true
  1026. const queryParams = {
  1027. techniqueIds: newTechniqueIds.join(',')
  1028. }
  1029. const response = await IotDailyReportAttrsApi.dailyReportAttrs(queryParams)
  1030. const newAttrs = response || []
  1031. // 处理动态属性更新
  1032. await updateDynamicAttrs(newAttrs, newTechniqueIds, oldTechniqueIds)
  1033. } catch (error) {
  1034. console.error('加载动态属性失败:', error)
  1035. message.error('加载动态属性失败')
  1036. } finally {
  1037. formLoading.value = false
  1038. }
  1039. }
  1040. // 监听施工工艺变化
  1041. watch(() => formData.value.techniqueIds, async (newTechniqueIds, oldTechniqueIds) => {
  1042. if (newTechniqueIds && newTechniqueIds.length > 0) {
  1043. await loadDynamicAttrs(newTechniqueIds, oldTechniqueIds)
  1044. } else {
  1045. dynamicAttrs.value = []
  1046. formData.value.dynamicFields = {}
  1047. }
  1048. }, { deep: true })
  1049. // 初始化表单数据
  1050. const initFormData = (reportData: any) => {
  1051. // 处理附件数据格式转换
  1052. const formattedAttachments = (reportData.attachments || []).map((attachment: any) => ({
  1053. id: attachment.id,
  1054. category: attachment.category?.toLowerCase() || 'daily_report',
  1055. bizId: attachment.bizId,
  1056. type: attachment.type?.toLowerCase() || 'attachment',
  1057. filename: attachment.filename,
  1058. fileType: attachment.fileType, // 使用辅助函数获取文件类型
  1059. filePath: attachment.filePath,
  1060. fileSize: attachment.fileSize,
  1061. remark: attachment.remark || ''
  1062. }))
  1063. formData.value = {
  1064. ...formData.value,
  1065. id: reportData.id,
  1066. deptId: reportData.deptId,
  1067. rdStatus: reportData.rdStatus || '',
  1068. techniqueIds: reportData.techniqueIds ? reportData.techniqueIds.map((id: number) => id.toString()) : [],
  1069. productionStatus: reportData.productionStatus || '',
  1070. nextPlan: reportData.nextPlan || '',
  1071. externalRental: reportData.externalRental || '',
  1072. malfunction: reportData.malfunction || '',
  1073. faultDowntime: reportData.faultDowntime || '',
  1074. startTime: reportData.startTime || undefined,
  1075. endTime: reportData.endTime || undefined,
  1076. companyId: reportData.companyId || '',
  1077. dynamicFields: {}, // 确保有初始值
  1078. // 初始化附件数据
  1079. attachments: formattedAttachments
  1080. }
  1081. queryParams.deptId = reportData.companyId
  1082. // 设置时间范围选择器
  1083. if (reportData.startTime && reportData.startTime[0] && reportData.endTime && reportData.endTime[0]) {
  1084. formData.value.timeRange = [
  1085. new Date(reportData.startTime[0]),
  1086. new Date(reportData.endTime[0])
  1087. ]
  1088. }
  1089. // 初始化动态属性
  1090. initDynamicAttrs(reportData)
  1091. // 初始化设备数据
  1092. initDeviceData(reportData)
  1093. }
  1094. onMounted(async () => {
  1095. formLoading.value = true
  1096. try {
  1097. // 加载当前登录人所属部门
  1098. const deptId = userStore.getUser.deptId
  1099. const dept = await DeptApi.getDept(deptId)
  1100. // 查询瑞都日报详情
  1101. if (id) {
  1102. const response = await IotRdDailyReportApi.getIotRdDailyReport(id)
  1103. dailyReportData.value = response || {}
  1104. initFormData(dailyReportData.value)
  1105. }
  1106. } catch (error) {
  1107. console.error('初始化数据失败:', error)
  1108. message.error('数据加载失败')
  1109. } finally {
  1110. formLoading.value = false
  1111. }
  1112. })
  1113. /** 审批操作 */
  1114. const handleApprove = async (action: 'pass' | 'reject') => {
  1115. // 只有在审批模式下才执行审批操作
  1116. if (!isApprovalMode.value) {
  1117. message.warning('当前不是审批模式')
  1118. return
  1119. }
  1120. try {
  1121. // 验证审批表单(如果需要)
  1122. // await approvalFormRef.value.validate()
  1123. formLoading.value = true
  1124. // 处理时间范围数据
  1125. if (formData.value.timeRange && formData.value.timeRange.length === 2) {
  1126. // 将时间范围转换为 LocalTime 格式的字符串
  1127. const startDate = dayjs(formData.value.timeRange[0])
  1128. const endDate = dayjs(formData.value.timeRange[1])
  1129. // 格式化为 HH:mm:ss 字符串,后端会自动转换为 LocalTime
  1130. formData.value.startTime = startDate.format('HH:mm:ss')
  1131. formData.value.endTime = endDate.format('HH:mm:ss')
  1132. }
  1133. // 构建审批数据,包含审批意见
  1134. const approveData = {
  1135. ...formData.value,
  1136. id: Number(id),
  1137. opinion: approvalForm.opinion,
  1138. auditStatus: action === 'pass' ? 20 : 30
  1139. }
  1140. // 这里可以调用审批API
  1141. if (action === 'pass') {
  1142. // 审批通过逻辑
  1143. await IotRdDailyReportApi.approveRdDailyReport(approveData)
  1144. message.success('审批通过')
  1145. } else {
  1146. // 审批驳回逻辑
  1147. await IotRdDailyReportApi.approveRdDailyReport(approveData)
  1148. message.success('审批驳回')
  1149. }
  1150. close()
  1151. } catch (error) {
  1152. console.error('审批操作失败:', error)
  1153. message.error('审批操作失败')
  1154. } finally {
  1155. formLoading.value = false
  1156. }
  1157. }
  1158. </script>
  1159. <style scoped>
  1160. .info-table {
  1161. border: 1px solid #e0e0e0;
  1162. border-radius: 4px;
  1163. overflow: hidden;
  1164. }
  1165. .table-row {
  1166. display: flex;
  1167. border-bottom: 1px solid #e0e0e0;
  1168. }
  1169. .table-row:last-child {
  1170. border-bottom: none;
  1171. }
  1172. .table-cell {
  1173. flex: 1;
  1174. border-right: 1px solid #e0e0e0;
  1175. padding: 12px 8px;
  1176. min-height: 44px;
  1177. display: flex;
  1178. align-items: center;
  1179. }
  1180. .table-cell:last-child {
  1181. border-right: none;
  1182. }
  1183. .table-cell.full-width {
  1184. flex: 1;
  1185. border-right: none;
  1186. }
  1187. .cell-content {
  1188. display: flex;
  1189. align-items: center;
  1190. width: 100%;
  1191. }
  1192. .cell-label {
  1193. font-weight: 500;
  1194. /* 统一字体大小为 14px(Element 表单默认) */
  1195. font-size: 14px;
  1196. color: #606266;
  1197. min-width: 80px;
  1198. margin-right: 8px;
  1199. flex-shrink: 0;
  1200. }
  1201. .cell-value {
  1202. /* 统一字体大小为 14px(Element 输入框默认) */
  1203. font-size: 14px;
  1204. color: #303133;
  1205. /* 统一行高为 1.5(Element 组件默认行高) */
  1206. line-height: 1.5;
  1207. flex: 1;
  1208. word-break: break-all;
  1209. }
  1210. /* 响应式设计 */
  1211. @media (max-width: 768px) {
  1212. .table-row {
  1213. flex-direction: column;
  1214. }
  1215. .table-cell {
  1216. border-right: none;
  1217. border-bottom: 1px solid #e0e0e0;
  1218. }
  1219. .table-cell:last-child {
  1220. border-bottom: none;
  1221. }
  1222. }
  1223. .daily-report-title {
  1224. text-align: center;
  1225. margin: 20px 0;
  1226. padding: 10px;
  1227. border-bottom: 2px solid #409eff;
  1228. }
  1229. .daily-report-title h2 {
  1230. margin: 0;
  1231. color: #303133;
  1232. font-size: 16px;
  1233. font-weight: bold;
  1234. }
  1235. /* 为第二、三部分增加左右留白 */
  1236. .section-padding {
  1237. padding-left: 0px;
  1238. padding-right: 40px;
  1239. }
  1240. .project-info-section {
  1241. margin: 20px 0;
  1242. padding: 20px;
  1243. background-color: #f8f9fa;
  1244. border-radius: 4px;
  1245. border: 1px solid #e9ecef;
  1246. }
  1247. .info-row {
  1248. padding: 12px 0;
  1249. border-bottom: 1px solid #e9ecef;
  1250. }
  1251. .info-row:last-child {
  1252. border-bottom: none;
  1253. }
  1254. .info-label {
  1255. font-weight: bold;
  1256. color: #495057;
  1257. margin-right: 8px;
  1258. }
  1259. .info-value {
  1260. color: #212529;
  1261. }
  1262. :deep(.el-textarea .el-textarea__inner) {
  1263. min-height: 80px;
  1264. }
  1265. /* 确保表单label不换行 */
  1266. :deep(.el-form-item__label) {
  1267. white-space: nowrap;
  1268. text-overflow: ellipsis;
  1269. overflow: hidden;
  1270. }
  1271. /* 甲方字段:单行显示+超出省略 */
  1272. .single-line-ellipsis {
  1273. /* 强制文本单行显示 */
  1274. white-space: nowrap;
  1275. /* 超出容器部分隐藏 */
  1276. overflow: hidden;
  1277. /* 超出部分显示省略号 */
  1278. text-overflow: ellipsis;
  1279. /* 避免文本被截断(可选,根据需求调整) */
  1280. word-break: normal;
  1281. }
  1282. /* 设备配置字段:换行缩进(与首行对齐) */
  1283. .indent-multiline {
  1284. /* 首行及换行后缩进 2em(与 label 宽度匹配,可根据需求调整) */
  1285. text-indent: 0em;
  1286. /* 允许长文本换行(覆盖原有 cell-value 的 break-all,确保中文换行正常) */
  1287. word-break: break-word;
  1288. /* 保证换行后文本正常显示(可选,清除可能的 nowrap 影响) */
  1289. white-space: normal;
  1290. }
  1291. /* 添加审批模式下的样式 */
  1292. .approval-notice {
  1293. margin-top: 10px;
  1294. }
  1295. /* 审批模式下表单字段的只读样式 */
  1296. :deep(.el-form-item.is-disabled .el-input__inner),
  1297. :deep(.el-form-item.is-disabled .el-textarea__inner) {
  1298. background-color: #f5f7fa;
  1299. border-color: #e4e7ed;
  1300. color: #c0c4cc;
  1301. cursor: not-allowed;
  1302. }
  1303. :deep(.el-form-item.is-disabled .el-select .el-input__inner) {
  1304. background-color: #f5f7fa;
  1305. border-color: #e4e7ed;
  1306. color: #c0c4cc;
  1307. cursor: not-allowed;
  1308. }
  1309. :deep(.el-form-item.is-disabled .el-date-editor .el-input__inner) {
  1310. background-color: #f5f7fa;
  1311. border-color: #e4e7ed;
  1312. color: #c0c4cc;
  1313. cursor: not-allowed;
  1314. }
  1315. /* 只读模式下表单字段的样式 */
  1316. :deep(.el-form-item.is-disabled .el-input__inner),
  1317. :deep(.el-form-item.is-disabled .el-textarea__inner),
  1318. :deep(.el-form-item.is-disabled .el-select .el-input__inner),
  1319. :deep(.el-form-item.is-disabled .el-date-editor .el-input__inner) {
  1320. background-color: #f5f7fa;
  1321. border-color: #e4e7ed;
  1322. color: #606266; /* 保持文字可读性 */
  1323. cursor: not-allowed;
  1324. }
  1325. /* 详情模式下的特殊样式 */
  1326. .detail-mode .cell-value {
  1327. color: #303133;
  1328. font-weight: normal;
  1329. }
  1330. /* 添加审批意见区域的样式 */
  1331. .approval-opinion-section {
  1332. margin-top: 20px;
  1333. border-top: 2px solid #f0f0f0;
  1334. padding-top: 20px;
  1335. }
  1336. /* 审批意见文本域样式 */
  1337. :deep(.approval-opinion .el-textarea__inner) {
  1338. min-height: 100px;
  1339. resize: vertical;
  1340. }
  1341. /* 审批意见标签样式 */
  1342. :deep(.approval-opinion .el-form-item__label) {
  1343. font-weight: bold;
  1344. color: #606266;
  1345. }
  1346. /* 附件列表样式 */
  1347. .attachment-list {
  1348. width: 100%;
  1349. margin-top: 5px;
  1350. border: 1px solid #e0e0e0;
  1351. border-radius: 4px;
  1352. padding: 10px;
  1353. background-color: #fafafa;
  1354. box-sizing: border-box;
  1355. }
  1356. .attachment-item {
  1357. display: flex;
  1358. justify-content: space-between;
  1359. align-items: center;
  1360. padding: 8px 12px;
  1361. border-bottom: 1px solid #f0f0f0;
  1362. }
  1363. .attachment-item:last-child {
  1364. border-bottom: none;
  1365. }
  1366. .attachment-name {
  1367. flex: 1;
  1368. color: #606266;
  1369. font-size: 11px;
  1370. }
  1371. .no-attachment {
  1372. color: #909399;
  1373. font-style: italic;
  1374. margin-top: 5px;
  1375. padding: 10px;
  1376. }
  1377. /* 附件名称链接样式 */
  1378. .attachment-name {
  1379. color: #409eff;
  1380. text-decoration: underline;
  1381. cursor: pointer;
  1382. }
  1383. .attachment-name:hover {
  1384. color: #66b1ff;
  1385. }
  1386. /* 只读模式下的设备显示样式 */
  1387. .device-display-readonly {
  1388. color: #606266;
  1389. font-size: 11px;
  1390. line-height: 1.5;
  1391. background-color: #f5f7fa;
  1392. padding: 8px 12px;
  1393. border-radius: 4px;
  1394. border: 1px solid #e4e7ed;
  1395. display: inline-block;
  1396. min-width: 200px;
  1397. }
  1398. .no-device {
  1399. margin-left: 10px;
  1400. color: #909399;
  1401. font-style: italic;
  1402. }
  1403. /* 设备选择对话框样式 */
  1404. .transfer-container {
  1405. text-align: center;
  1406. padding: 0px;
  1407. }
  1408. .transfer-component {
  1409. width: 100%;
  1410. min-width: 600px;
  1411. }
  1412. :deep(.el-transfer-panel) {
  1413. width: 40% !important;
  1414. }
  1415. :deep(.el-transfer-panel__item) {
  1416. display: flex !important;
  1417. align-items: center !important;
  1418. height: 32px !important;
  1419. line-height: 32px !important;
  1420. padding: 0 8px !important;
  1421. margin: 0 !important;
  1422. white-space: nowrap;
  1423. overflow: hidden;
  1424. text-overflow: ellipsis;
  1425. }
  1426. .transfer-option-text {
  1427. display: inline-block;
  1428. max-width: 100%;
  1429. }
  1430. :deep(.el-transfer-panel__list) {
  1431. width: 100% !important;
  1432. }
  1433. .device-display-container {
  1434. /* 与其他文本域保持相同的宽度和样式 */
  1435. display: inline-block;
  1436. width: 100%; /* 减去按钮宽度 */
  1437. min-height: 32px;
  1438. line-height: 32px;
  1439. padding: 0 12px;
  1440. margin-left: 0px;
  1441. border-radius: 4px;
  1442. border: 1px solid #e4e7ed;
  1443. background-color: #fff;
  1444. font-size: 11px;
  1445. /* 文本溢出处理 */
  1446. white-space: nowrap;
  1447. overflow: hidden;
  1448. text-overflow: ellipsis;
  1449. }
  1450. /* 只读模式下的设备显示样式 */
  1451. :deep(.is-disabled) .device-display-container {
  1452. background-color: #f5f7fa;
  1453. color: #606266;
  1454. cursor: not-allowed;
  1455. }
  1456. /* 附件容器样式调整 */
  1457. .attachment-container {
  1458. /* 与其他文本域保持相同的宽度和边距 */
  1459. width: 100%;
  1460. margin-top: 10px;
  1461. }
  1462. /* 未选择设备字段的只读样式 */
  1463. :deep(.unselected-device .el-textarea__inner) {
  1464. background-color: #f5f7fa;
  1465. border-color: #e4e7ed;
  1466. color: #909399;
  1467. cursor: not-allowed;
  1468. resize: none;
  1469. }
  1470. </style>