selfEvaluate.uvue 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020
  1. <template>
  2. <uni-navbar-lite :showLeft="true" title="工分自评">
  3. <view class="back-icon" slot="left" @click="goBack">
  4. <text class="iconfont icon-back">工分自评</text>
  5. </view>
  6. </uni-navbar-lite>
  7. <scroll-view class="container" :scroll-y="true">
  8. <view class="header">
  9. <text class="title">工分自评</text>
  10. </view>
  11. <view class="form">
  12. <!-- 工单基本信息 -->
  13. <view class="info-card">
  14. <view class="info-item">
  15. <text class="info-label">工单编码</text>
  16. <text class="info-value">{{ selfEvaluationForm.workOrderProjectNo }}</text>
  17. </view>
  18. <view class="info-item">
  19. <text class="info-label">风机编号</text>
  20. <text class="info-value">{{ selfEvaluationForm.pcsDeviceName }}</text>
  21. </view>
  22. <view class="info-item">
  23. <text class="info-label">场站</text>
  24. <text class="info-value">{{ selfEvaluationForm.pcsStationName }}</text>
  25. </view>
  26. </view>
  27. <!-- 工单类型相关字段 -->
  28. <view v-if="selfEvaluationForm.orderType == '1'" class="info-card">
  29. <view class="form-item">
  30. <text class="label">检修类型<text style="color: red;">*</text></text>
  31. <view class="form-picker" @click="showMaintenanceTypePicker = true">
  32. <view class="picker-display">
  33. <text v-if="selfEvaluationForm.maintenanceType" class="selected-value">{{ getMaintenanceTypeLabel(selfEvaluationForm.maintenanceType) }}</text>
  34. <text v-else class="placeholder">请选择检修类型</text>
  35. <text class="arrow">▼</text>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <!-- 自定义选择器弹窗 -->
  41. <view v-if="showMaintenanceTypePicker" class="picker-modal">
  42. <view class="modal-mask" @click="showMaintenanceTypePicker = false"></view>
  43. <view class="modal-content">
  44. <view class="modal-header">
  45. <text class="modal-title">检修类型</text>
  46. <text class="modal-close" @click="showMaintenanceTypePicker = false">取消</text>
  47. </view>
  48. <scroll-view class="modal-body" scroll-y="true">
  49. <view
  50. v-for="(option, index) in maintenanceTypeOptions"
  51. :key="index"
  52. class="picker-option"
  53. :class="{ 'selected': index == selectedMaintenanceTypeIndex }"
  54. @click="selectMaintenanceType(index)"
  55. >
  56. <text class="option-text">{{ option.label }}</text>
  57. <text v-if="index == selectedMaintenanceTypeIndex" class="option-check">✓</text>
  58. </view>
  59. </scroll-view>
  60. </view>
  61. </view>
  62. <view v-if="selfEvaluationForm.orderType == '2'" class="info-card">
  63. <view class="info-item">
  64. <text class="info-label">维保类型</text>
  65. <text v-for="(type, index) in selfEvaluationForm.inspectionType" :key="index">
  66. {{ getInspectionTypeLabel(type) }}&nbsp;
  67. </text>
  68. </view>
  69. <view class="info-item">
  70. <text class="info-label">分项完成系数<text style="color: red;">*</text></text>
  71. <input
  72. class="info-input"
  73. type="digit"
  74. :value="getItemCompletionFactorDisplayValue()"
  75. @input="onItemCompletionFactorInput"
  76. @blur="formatItemCompletionFactor()"
  77. placeholder="请输入分项完成系数"
  78. />
  79. </view>
  80. <view class="info-item">
  81. <text class="info-label">分项完成系数和<text style="color: red;">*</text></text>
  82. <input
  83. class="info-input"
  84. type="digit"
  85. :value="getItemCompletionFactorSumDisplayValue()"
  86. @input="onItemCompletionFactorSumInput"
  87. @blur="formatItemCompletionFactorSum()"
  88. placeholder="请输入分项完成系数和"
  89. />
  90. </view>
  91. </view>
  92. <!-- 总结内容 -->
  93. <view class="info-card">
  94. <view class="form-item">
  95. <text class="label">{{ selfEvaluationForm.orderType == '1' ? '维修总结' : '维保总结' }}<text style="color: red;">*</text></text>
  96. <textarea
  97. class="textarea"
  98. :value="selfEvaluationForm.workSummary"
  99. @input="onWorkSummaryInput"
  100. placeholder="请输入总结内容"
  101. :maxlength="200"
  102. />
  103. </view>
  104. <!-- 额外工作总结 - 仅维修工单显示 -->
  105. <view v-if="selfEvaluationForm.orderType == '1'" class="form-item">
  106. <text class="label">额外工作总结</text>
  107. <textarea
  108. class="textarea"
  109. :value="selfEvaluationForm.extraWork"
  110. @input="onExtraWorkInput"
  111. @blur="onExtraWorkChange"
  112. placeholder="请输入额外工作总结"
  113. :maxlength="200"
  114. />
  115. </view>
  116. </view>
  117. <!-- 人员信息和得分明细 -->
  118. <!-- <view class="info-card">
  119. <view class="form-item">
  120. <text class="label">外委人员数(人)</text>
  121. <text class="value">{{ selfEvaluationForm.wwryNum }}</text>
  122. </view>
  123. <view class="form-item">
  124. <text class="label">外来人员数(人)</text>
  125. <text class="value">{{ selfEvaluationForm.wlryNum }}</text>
  126. </view>
  127. </view> -->
  128. <!-- 得分明细 -->
  129. <view class="info-card">
  130. <view class="form-item">
  131. <text class="label">得分明细 ({{ isMixedZeroNonZeroInspectionTypes() ? '最少可评总分: ' : '可自评总分: ' }}{{ getSelfEvaluationTotalScore() == 0 ? '未规定' : (getSelfEvaluationTotalScore() != null ? getSelfEvaluationTotalScore().toFixed(2) : '0.00') + '分' }}, 已自评总分: {{ selfEvaluatedTotalScore != null ? selfEvaluatedTotalScore.toFixed(2) : '0.00' }}分)</text>
  132. </view>
  133. <view v-for="(person, index) in selfEvaluationForm.scorePersonList as UTSJSONObject[]" :key="index" class="person-score-item">
  134. <view class="person-info">
  135. <text class="person-name">{{ (person as UTSJSONObject).get('nickName') }}<text v-if="(person as UTSJSONObject).get('isLeader') == 1"> (工作负责人)</text></text>
  136. </view>
  137. <view class="score-inputs">
  138. <view class="score-item">
  139. <text class="score-label">检修工分<text style="color: red;">*</text></text>
  140. <input
  141. class="score-input"
  142. type="digit"
  143. :value="getPersonScore(person, 'selfScore')"
  144. @input="onScoreInput($event, index, 'selfScore')"
  145. @blur="formatScoreInput(index, 'selfScore');onScoreChange"
  146. placeholder="0.00"
  147. />
  148. </view>
  149. <!-- 额外工分 - 仅当维修工单且有额外工作总结时显示 -->
  150. <view v-if="selfEvaluationForm.orderType == '1' && hasExtraWorkFlag" class="score-item">
  151. <text class="score-label">额外工分</text>
  152. <input
  153. class="score-input"
  154. type="digit"
  155. :value="getPersonScore(person, 'extraScore')"
  156. @input="onScoreInput($event, index, 'extraScore')"
  157. @blur="formatScoreInput(index, 'extraScore');onScoreChange"
  158. placeholder="0.00"
  159. />
  160. </view>
  161. <!-- 工单得分 - 仅当维修工单且有额外工作总结时显示 -->
  162. <view v-if="selfEvaluationForm.orderType == '1' && hasExtraWorkFlag" class="score-item">
  163. <text class="score-label">工单得分</text>
  164. <input
  165. class="score-input"
  166. type="digit"
  167. :value="getPersonScore(person, 'totalScore')"
  168. readonly
  169. disabled
  170. placeholder="自动计算"
  171. style="pointer-events: none;"
  172. />
  173. </view>
  174. <!-- 额外工分和工单得分 - 仅当维保工单且维保类型包含其他/其它时显示 -->
  175. <view v-if="selfEvaluationForm.orderType == '2' && hasOtherOrQitaInspectionType()" class="score-item">
  176. <text class="score-label">额外工分</text>
  177. <input
  178. class="score-input"
  179. type="digit"
  180. :value="getPersonScore(person, 'extraScore')"
  181. @input="onScoreInput($event, index, 'extraScore')"
  182. @blur="formatScoreInput(index, 'extraScore');onScoreChange"
  183. placeholder="0.00"
  184. />
  185. </view>
  186. <view v-if="selfEvaluationForm.orderType == '2' && hasOtherOrQitaInspectionType()" class="score-item">
  187. <text class="score-label">工单得分</text>
  188. <input
  189. class="score-input"
  190. type="digit"
  191. :value="getPersonScore(person, 'totalScore')"
  192. readonly
  193. disabled
  194. placeholder="自动计算"
  195. style="pointer-events: none;"
  196. />
  197. </view>
  198. </view>
  199. </view>
  200. </view>
  201. <!-- 提交按钮 -->
  202. <view class="submit-btn" @click="submitSelfEvaluationForm">
  203. <text class="submit-text">提交自评</text>
  204. </view>
  205. </view>
  206. </scroll-view>
  207. </template>
  208. <script setup lang="uts">
  209. import { ref, onMounted, onLoad, onUnload } from 'vue'
  210. import { getOrderScoreDetail, submitSelfEvaluation, getMaintenanceTypes, listInspectionTypesByFanType } from '@/api/score/index'
  211. import { getDictDataByType } from '@/api/dict/index'
  212. import type { UserInfo } from '@/types/user'
  213. import type { SysDictData } from '@/types/dict'
  214. /* // 定义事件类型
  215. // 定义事件类型
  216. interface InputEvent {
  217. detail: any
  218. target: any
  219. } */
  220. // 页面参数
  221. const id = ref<string>('')
  222. const orderType = ref<string>('')
  223. const showMaintenanceTypePicker = ref<boolean>(false)
  224. // 添加额外工作总结状态变量
  225. const hasExtraWorkFlag = ref<boolean>(false)
  226. // 验证规则 - 使用UTS兼容的简单对象定义
  227. const validationRules: any = {
  228. workSummary: [
  229. { required: true, message: "总结不能为空", trigger: "blur" }
  230. ],
  231. maintenanceType: [
  232. { required: true, message: "请选择检修类型", trigger: "change" }
  233. ],
  234. inspectionType: [
  235. { required: true, message: "请选择维保类型", trigger: "change" }
  236. ],
  237. itemCompletionFactor: [
  238. { required: true, message: "分项完成系数不能为空", trigger: "change" }
  239. ],
  240. itemCompletionFactorSum: [
  241. { required: true, message: "分项完成系数和不能为空", trigger: "change" }
  242. ]
  243. }
  244. // 自评表单数据
  245. type SelfEvaluationFormData = {
  246. orderType: string
  247. id: number
  248. workOrderProjectNo: string
  249. pcsDeviceName: string
  250. pcsStationName: string
  251. model: string | null // 风机型号,用于获取维保类型选项
  252. workSummary: string
  253. extraWork: string
  254. maintenanceType: string | null
  255. inspectionType: string[]
  256. itemCompletionFactor: number | null
  257. itemCompletionFactorSum: number | null
  258. scorePersonList: UTSJSONObject[]
  259. wwryNum: number
  260. wlryNum: number
  261. }
  262. // 用于input绑定的字符串中转
  263. let itemCompletionFactorStr = ref<string>('')
  264. let itemCompletionFactorSumStr = ref<string>('')
  265. // 临时存储分项完成系数的原始输入值
  266. const tempItemCompletionFactorInput = ref<string>('')
  267. const tempItemCompletionFactorSumInput = ref<string>('')
  268. // 添加响应式变量来跟踪已自评总分
  269. let selfEvaluatedTotalScore = ref<number>(0)
  270. const selfEvaluationForm = ref<SelfEvaluationFormData>({
  271. orderType: '',
  272. id: 0,
  273. workOrderProjectNo: '',
  274. pcsDeviceName: '',
  275. pcsStationName: '',
  276. model: null as string | null,
  277. workSummary: '',
  278. extraWork: '',
  279. maintenanceType: null,
  280. inspectionType: [],
  281. itemCompletionFactor: null,
  282. itemCompletionFactorSum: null,
  283. scorePersonList: [],
  284. wwryNum: 0,
  285. wlryNum: 0
  286. })
  287. type MaintenanceTypeOption = {
  288. value: string
  289. label: string
  290. }
  291. // 检修类型选项
  292. const maintenanceTypeOptions = ref<MaintenanceTypeOption[]>([])
  293. const selectedMaintenanceTypeIndex = ref<number>(-1)
  294. // 维保类型选项
  295. const inspectionTypeOptions = ref<UTSJSONObject[]>([])
  296. // 维保类型字典
  297. const inspectionTypeDictList = ref<SysDictData[]>([])
  298. // 获取已自评总分
  299. function getSelfEvaluatedTotalScore(): number {
  300. const scorePersonList = selfEvaluationForm.value.scorePersonList as UTSJSONObject[]
  301. if (scorePersonList == null || scorePersonList.length == 0) {
  302. return 0
  303. }
  304. let totalSelfScore = 0
  305. for (let i = 0; i < scorePersonList.length; i++) {
  306. const person = scorePersonList[i]
  307. const selfScoreVal = person.get('selfScore')
  308. if (selfScoreVal != null) {
  309. // 统一处理分数值,无论是number还是string类型
  310. const scoreValue = typeof selfScoreVal == 'number' ? selfScoreVal : (selfScoreVal != '' ? parseFloat(selfScoreVal as string) : 0);
  311. if (!isNaN(scoreValue) && scoreValue != 0) {
  312. totalSelfScore += scoreValue;
  313. }
  314. }
  315. }
  316. return totalSelfScore
  317. }
  318. // 更新已自评总分的响应式变量
  319. function updateSelfEvaluatedTotalScore(): void {
  320. selfEvaluatedTotalScore.value = getSelfEvaluatedTotalScore()
  321. }
  322. // 更新总分
  323. function updateTotalScores(): void {
  324. const scorePersonList = selfEvaluationForm.value.scorePersonList as UTSJSONObject[]
  325. if (scorePersonList == null || scorePersonList.length == 0) return
  326. for (let i = 0; i < scorePersonList.length; i++) {
  327. const person = scorePersonList[i]
  328. const selfScoreVal = person.get('selfScore')
  329. const extraScoreVal = person.get('extraScore')
  330. // 根据工单类型和条件决定是否计算总分
  331. // 检查当前工单类型并获取对应条件
  332. const isMaintenanceOrderWithExtraWork = selfEvaluationForm.value.orderType == '1' && hasExtraWorkFlag.value;
  333. const isMaintenanceOrderType = selfEvaluationForm.value.orderType == '2';
  334. // 手动实现hasOtherOrQitaInspectionType函数的逻辑
  335. let hasOtherOrQitaType = false;
  336. if (isMaintenanceOrderType) {
  337. if (selfEvaluationForm.value.orderType != '2') {
  338. hasOtherOrQitaType = false;
  339. } else if (!Array.isArray(selfEvaluationForm.value.inspectionType)) {
  340. hasOtherOrQitaType = false;
  341. } else {
  342. for (let i = 0; i < selfEvaluationForm.value.inspectionType.length; i++) {
  343. const typeId = selfEvaluationForm.value.inspectionType[i];
  344. // 内联getInspectionTypeLabel函数的逻辑
  345. let label = '';
  346. if (typeId == '') {
  347. label = '';
  348. } else {
  349. const list = inspectionTypeDictList.value;
  350. for (let j = 0; j < list.length; j++) {
  351. const item = list[j];
  352. if (item.dictValue == typeId) {
  353. label = (item.dictLabel != null ? item.dictLabel : typeId) as string;
  354. break;
  355. }
  356. }
  357. }
  358. if (label == '其他' || label == '其它') {
  359. hasOtherOrQitaType = true;
  360. break;
  361. }
  362. }
  363. }
  364. }
  365. if (isMaintenanceOrderWithExtraWork) {
  366. // 维修工单且有额外工作总结时,总分 = 自评分 + 额外工分
  367. if (selfScoreVal != null && extraScoreVal != null) {
  368. const selfScore = typeof selfScoreVal == 'number' ? selfScoreVal : (selfScoreVal != '' ? parseFloat(selfScoreVal as string) : 0)
  369. const extraScore = typeof extraScoreVal == 'number' ? extraScoreVal : (extraScoreVal != '' ? parseFloat(extraScoreVal as string) : 0)
  370. person.set('totalScore', (selfScore + extraScore).toFixed(2))
  371. } else if (selfScoreVal != null) {
  372. // 如果只有自评分,没有额外工分
  373. const selfScore = typeof selfScoreVal == 'number' ? selfScoreVal : (selfScoreVal != '' ? parseFloat(selfScoreVal as string) : 0)
  374. person.set('totalScore', selfScore.toFixed(2))
  375. }
  376. } else if (isMaintenanceOrderType && hasOtherOrQitaType) {
  377. // 维保工单且维保类型包含其他/其它时,总分 = 自评分 + 额外工分
  378. if (selfScoreVal != null && extraScoreVal != null) {
  379. const selfScore = typeof selfScoreVal == 'number' ? selfScoreVal : (selfScoreVal != '' ? parseFloat(selfScoreVal as string) : 0)
  380. const extraScore = typeof extraScoreVal == 'number' ? extraScoreVal : (extraScoreVal != '' ? parseFloat(extraScoreVal as string) : 0)
  381. person.set('totalScore', (selfScore + extraScore).toFixed(2))
  382. } else if (selfScoreVal != null) {
  383. // 如果只有自评分,没有额外工分
  384. const selfScore = typeof selfScoreVal == 'number' ? selfScoreVal : (selfScoreVal != '' ? parseFloat(selfScoreVal as string) : 0)
  385. person.set('totalScore', selfScore.toFixed(2))
  386. }
  387. } else {
  388. // 其他情况只显示自评分
  389. if (selfScoreVal != null) {
  390. const selfScore = typeof selfScoreVal == 'number' ? selfScoreVal : (selfScoreVal != '' ? parseFloat(selfScoreVal as string) : 0)
  391. if (!isNaN(selfScore)) {
  392. person.set('totalScore', selfScore.toFixed(2))
  393. }
  394. } else {
  395. person.set('totalScore', 0)
  396. }
  397. }
  398. }
  399. // 同步分项完成系数和显示
  400. itemCompletionFactorStr.value = selfEvaluationForm.value.itemCompletionFactor != null ? selfEvaluationForm.value.itemCompletionFactor.toFixed(2) : ''
  401. itemCompletionFactorSumStr.value = selfEvaluationForm.value.itemCompletionFactorSum != null ? selfEvaluationForm.value.itemCompletionFactorSum.toFixed(2) : ''
  402. // 更新已自评总分显示
  403. updateSelfEvaluatedTotalScore()
  404. }
  405. // 计算得分 - 实际上在自评中,这是手动输入的,不需要自动计算
  406. function calculateScores(): void {
  407. // 在自评阶段,分数是手动输入的,不需要自动计算
  408. // 但我们需要根据工单类型和配置来验证总分是否符合规则
  409. updateTotalScores()
  410. // 更新已自评总分显示
  411. updateSelfEvaluatedTotalScore()
  412. }
  413. // 根据值获取维保类型标签
  414. function getInspectionTypeLabel(value: string): string {
  415. if (value == '') return ''
  416. const list = inspectionTypeDictList.value
  417. for (let i = 0; i < list.length; i++) {
  418. const item = list[i]
  419. if (item.dictValue == value) {
  420. return (item.dictLabel != null ? item.dictLabel : value) as string
  421. }
  422. }
  423. return value
  424. }
  425. // 检查维保类型是否包含'其他'或'其它'选项
  426. function hasOtherOrQitaInspectionType(): boolean {
  427. if (selfEvaluationForm.value.orderType != '2') return false
  428. if (!Array.isArray(selfEvaluationForm.value.inspectionType)) return false
  429. for (let i = 0; i < selfEvaluationForm.value.inspectionType.length; i++) {
  430. const typeId = selfEvaluationForm.value.inspectionType[i]
  431. const label = getInspectionTypeLabel(typeId)
  432. if (label == '其他' || label == '其它') {
  433. return true
  434. }
  435. }
  436. return false
  437. }
  438. // 检查维保类型是否既有零分又有非零分的情况
  439. function isMixedZeroNonZeroInspectionTypes(): boolean {
  440. if (selfEvaluationForm.value.orderType != '2') return false
  441. if (!Array.isArray(selfEvaluationForm.value.inspectionType)) return false
  442. if (selfEvaluationForm.value.inspectionType.length <= 1) return false // 单选不会出现混合情况
  443. let hasZeroScore = false;
  444. let hasNonZeroScore = false;
  445. const selectedInspectionTypes: string[] = selfEvaluationForm.value.inspectionType;
  446. for (let i = 0; i < selectedInspectionTypes.length; i++) {
  447. const typeId = selectedInspectionTypes[i];
  448. for (let j = 0; j < inspectionTypeOptions.value.length; j++) {
  449. const selectedType = inspectionTypeOptions.value[j];
  450. // 使用inspectionTypeId进行匹配
  451. if (selectedType.get('inspectionTypeId').toString() == typeId) {
  452. // 从标签中提取分数
  453. const score = selectedType.get('score');
  454. if (score != null && typeof score == 'number') {
  455. if (score == 0) {
  456. hasZeroScore = true;
  457. } else if (score > 0) {
  458. hasNonZeroScore = true;
  459. }
  460. }
  461. }
  462. }
  463. }
  464. // 如果既有零分又有非零分,则返回true
  465. return hasZeroScore && hasNonZeroScore;
  466. }
  467. // 获取工单总分
  468. function getTotalScore(): number {
  469. let totalScore = 0;
  470. if (selfEvaluationForm.value.orderType == '1') {
  471. // 维修工单:根据检修类型获取总分
  472. for (let i = 0; i < maintenanceTypeOptions.value.length; i++) {
  473. const typeOption = maintenanceTypeOptions.value[i]
  474. if (typeOption.value == selfEvaluationForm.value.maintenanceType) {
  475. // 从标签中提取分数
  476. const regex = /\((\d+(\.\d+)?)分\)/
  477. const match = typeOption.label.match(regex)
  478. if (match != null && match.length > 1 && match[1] != null) {
  479. totalScore = parseFloat(match[1] as string);
  480. break;
  481. }
  482. }
  483. }
  484. } else if (selfEvaluationForm.value.orderType == '2') {
  485. // 维保工单:根据选中的维保类型和分项完成系数获取总分
  486. // 检查分项完成系数是否为null,如果是null则视为无效
  487. if (selfEvaluationForm.value.itemCompletionFactor == null) {
  488. return 0;
  489. }
  490. const completionFactor = selfEvaluationForm.value.itemCompletionFactor;
  491. // 获取选中的维保项目(现在是多选)
  492. const selectedInspectionTypes: string[] = selfEvaluationForm.value.inspectionType != null ? selfEvaluationForm.value.inspectionType : [];
  493. // 计算所有选中维保项目的总分值
  494. let totalScoreFromDB = 0; // 默认值
  495. if (Array.isArray(selectedInspectionTypes) && selectedInspectionTypes.length > 0) {
  496. for (let i = 0; i < selectedInspectionTypes.length; i++) {
  497. const typeId = selectedInspectionTypes[i];
  498. for (let j = 0; j < inspectionTypeOptions.value.length; j++) {
  499. const selectedType = inspectionTypeOptions.value[j];
  500. const inspectionTypeId = selectedType.get('inspectionTypeId');
  501. const score = selectedType.get('score');
  502. // 使用toString()方法确保类型一致进行匹配
  503. if ((inspectionTypeId as number).toString() == typeId) {
  504. if (score != null && typeof score == 'number') {
  505. totalScoreFromDB += score;
  506. }
  507. }
  508. }
  509. }
  510. }
  511. // 计算总分:总分 = 所有选中维保类型组合的总得分 * 分项完成系数
  512. totalScore = totalScoreFromDB * completionFactor;
  513. }
  514. return totalScore;
  515. }
  516. // 获取可自评总分
  517. function getSelfEvaluationTotalScore(): number {
  518. // 获取工单总分
  519. const totalScore = getTotalScore();
  520. // 如果总分为0,返回0
  521. if (totalScore == 0) {
  522. // 特殊处理:对于维保工单且多选维保类型的情况,如果存在零分和非零分的混合情况
  523. if (selfEvaluationForm.value.orderType == '2' && Array.isArray(selfEvaluationForm.value.inspectionType) && selfEvaluationForm.value.inspectionType.length > 1) {
  524. // 获取选中的维保类型
  525. const selectedInspectionTypes: string[] = selfEvaluationForm.value.inspectionType != null ? selfEvaluationForm.value.inspectionType : [];
  526. // 计算所有选中维保类型的非零分值
  527. let minScoreFromDB = 0; // 非零分值总和
  528. let hasZeroScore = false; // 是否存在零分
  529. if (Array.isArray(selectedInspectionTypes) && selectedInspectionTypes.length > 0) {
  530. for (let i = 0; i < selectedInspectionTypes.length; i++) {
  531. const typeId = selectedInspectionTypes[i];
  532. for (let j = 0; j < inspectionTypeOptions.value.length; j++) {
  533. const selectedType = inspectionTypeOptions.value[j];
  534. const inspectionTypeId = selectedType.get('inspectionTypeId');
  535. const score = selectedType.get('score');
  536. // 使用toString()方法确保类型一致进行匹配
  537. if ((inspectionTypeId as number).toString() == typeId) {
  538. if (score != null && typeof score == 'number') {
  539. if (score == 0) {
  540. hasZeroScore = true;
  541. } else if (score > 0) {
  542. minScoreFromDB += score;
  543. }
  544. }
  545. }
  546. }
  547. }
  548. }
  549. // 如果存在零分且存在非零分的情况,返回非零分的总和加上工作负责人的0.5分
  550. if (hasZeroScore && minScoreFromDB > 0) {
  551. const completionFactor = selfEvaluationForm.value.itemCompletionFactor != null ? selfEvaluationForm.value.itemCompletionFactor : 1;
  552. const result = (minScoreFromDB * completionFactor) + 0.5;
  553. return result;
  554. }
  555. }
  556. return 0;
  557. }
  558. // 检查是否存在工作负责人
  559. const scorePersonList = selfEvaluationForm.value.scorePersonList as UTSJSONObject[];
  560. for (let i = 0; i < scorePersonList.length; i++) {
  561. const person = scorePersonList[i];
  562. const isLeader = person.get('isLeader');
  563. if (isLeader != null && isLeader as number == 1) {
  564. // 如果存在工作负责人,可自评总分加0.5分
  565. const result = totalScore + 0.5;
  566. return result;
  567. }
  568. }
  569. return totalScore;
  570. }
  571. // 人员评分验证
  572. function validatePersonScore(score: string, fieldName: string): string | null {
  573. if (score == null || score == '') {
  574. if (fieldName == 'selfScore') {
  575. return '检修工分不能为空';
  576. }
  577. return null; // 额外工分可以为空
  578. }
  579. const numScore = parseFloat(score);
  580. if (isNaN(numScore)) {
  581. return `${fieldName == 'selfScore' ? '检修工分' : '额外工分'}必须为数字`;
  582. }
  583. if (numScore < 0) {
  584. return `${fieldName == 'selfScore' ? '检修工分' : '额外工分'}不能小于0`;
  585. }
  586. if (fieldName == 'selfScore' && numScore <= 0) {
  587. return '检修工分必须大于0';
  588. }
  589. return null;
  590. }
  591. // 字段验证函数
  592. function validateField(fieldName: string, value: any): string | null {
  593. console.log('验证字段:', fieldName, '值:', value, '类型:', typeof value);
  594. // 根据字段名称确定验证规则
  595. if (fieldName == 'workSummary') {
  596. // 验证工作/维保总结
  597. if (value == null || value == '') {
  598. const summaryType = selfEvaluationForm.value.orderType == '1' ? '维修' : '维保';
  599. return `${summaryType}总结不能为空`;
  600. }
  601. } else if (fieldName == 'maintenanceType') {
  602. // 验证检修类型
  603. console.log('验证检修类型,当前值:', value, '类型:', typeof value, '是否为null:', value == null, '是否为空字符串:', value == '');
  604. if (value == null || value == '') {
  605. return "请选择检修类型";
  606. }
  607. } else if (fieldName == 'inspectionType') {
  608. // 验证维保类型
  609. if (value == null || (Array.isArray(value) && value.length == 0)) {
  610. return "请选择维保类型";
  611. }
  612. } else if (fieldName == 'itemCompletionFactor') {
  613. // 验证分项完成系数
  614. if (value == null || value == '') {
  615. return "分项完成系数不能为空";
  616. }
  617. // 验证数值范围
  618. let numValue: number;
  619. if (typeof value == 'string' && value != '') {
  620. numValue = parseFloat(value);
  621. } else if (typeof value == 'number') {
  622. numValue = value;
  623. } else {
  624. return "分项完成系数类型错误";
  625. }
  626. if (isNaN(numValue) || numValue < 0 || numValue > 1) {
  627. return '分项完成系数必须在0到1之间';
  628. }
  629. } else if (fieldName == 'itemCompletionFactorSum') {
  630. // 验证分项完成系数和
  631. if (value == null || value == '') {
  632. return "分项完成系数和不能为空";
  633. }
  634. // 验证数值范围
  635. let numValue: number;
  636. if (typeof value == 'string' && value != '') {
  637. numValue = parseFloat(value);
  638. } else if (typeof value == 'number') {
  639. numValue = value;
  640. } else {
  641. return "分项完成系数和类型错误";
  642. }
  643. if (isNaN(numValue) || numValue < 0 || numValue > 1) {
  644. return '分项完成系数和必须在0到1之间';
  645. }
  646. }
  647. return null;
  648. }
  649. // 验证评分规则
  650. function validateScoringRules(): any {
  651. // 获取工单总分
  652. const totalScore = getTotalScore()
  653. // 获取自评分总和
  654. const totalSelfScore = getSelfEvaluatedTotalScore()
  655. const scorePersonList = selfEvaluationForm.value.scorePersonList as UTSJSONObject[]
  656. if (scorePersonList == null || scorePersonList.length == 0) {
  657. const result = new UTSJSONObject();
  658. result.set('valid', true);
  659. result.set('message', '');
  660. return result;
  661. }
  662. // 检查每个人员的评分
  663. let hasEmptyScore = false;
  664. let leaderScore: number | null = null;
  665. for (let i = 0; i < scorePersonList.length; i++) {
  666. const person = scorePersonList[i];
  667. // 验证自评分
  668. const selfScore = person.get('selfScore');
  669. if (selfScore == null || selfScore == '' || (typeof selfScore == 'number' && isNaN(selfScore as number))) {
  670. hasEmptyScore = true;
  671. } else {
  672. const scoreStr = typeof selfScore == 'number' ? selfScore.toFixed(2) : selfScore as string;
  673. const validationError = validatePersonScore(scoreStr, 'selfScore');
  674. if (validationError != null) {
  675. const result = new UTSJSONObject();
  676. result.set('valid', false);
  677. result.set('message', `${person.get('nickName')}:${validationError}`);
  678. return result;
  679. }
  680. const score = typeof selfScore == 'number' ? selfScore : parseFloat(selfScore as string);
  681. if (person.get('isLeader') != null && person.get('isLeader') as number == 1) {
  682. leaderScore = score;
  683. }
  684. }
  685. // 验证额外工分(如果存在)
  686. const extraScore = person.get('extraScore');
  687. if (extraScore != null && extraScore != '' && !(typeof extraScore == 'number' && isNaN(extraScore as number))) {
  688. const extraScoreStr = typeof extraScore == 'number' ? extraScore.toFixed(2) : extraScore as string;
  689. const extraScoreError = validatePersonScore(extraScoreStr, 'extraScore');
  690. if (extraScoreError != null) {
  691. const result = new UTSJSONObject();
  692. result.set('valid', false);
  693. result.set('message', `${person.get('nickName')}:${extraScoreError}`);
  694. return result;
  695. }
  696. }
  697. }
  698. // 如果有人没评分,返回错误
  699. if (hasEmptyScore) {
  700. const result = new UTSJSONObject();
  701. result.set('valid', false);
  702. result.set('message', '部分人员未评分');
  703. return result;
  704. }
  705. // 检查工作负责人得分-0.5后是否小于等于0
  706. if (leaderScore != null) {
  707. const leaderScoreAfterReduction = leaderScore - 0.5
  708. if (leaderScoreAfterReduction <= 0) {
  709. const result = new UTSJSONObject();
  710. result.set('valid', false);
  711. result.set('message', `工作负责人得分减去0.5后不能小于等于0(当前:${leaderScore.toFixed(2)} - 0.5 = ${leaderScoreAfterReduction.toFixed(2)})`);
  712. return result;
  713. }
  714. }
  715. // 检查工单类型是否为维保工单且多选维保类型的情况,检查是否存在零分和非零分混合
  716. let isMultipleInspectionWithMixedScores = isMixedZeroNonZeroInspectionTypes();
  717. // 如果总分为0,则评分无上限
  718. if (totalScore == 0) {
  719. // 检查工作负责人得分-0.5后是否小于等于0
  720. if (leaderScore != null) {
  721. const leaderScoreAfterReduction = leaderScore - 0.5
  722. if (leaderScoreAfterReduction <= 0) {
  723. const result = new UTSJSONObject();
  724. result.set('valid', false);
  725. result.set('message', `工作负责人得分减去0.5后不能小于等于0(当前:${leaderScore.toFixed(2)} - 0.5 = ${leaderScoreAfterReduction.toFixed(2)})`);
  726. return result;
  727. }
  728. }
  729. const result = new UTSJSONObject();
  730. result.set('valid', true);
  731. result.set('message', '');
  732. return result;
  733. }
  734. // 检查自评分总和是否超过总分
  735. /* if (totalSelfScore > totalScore + 0.01) { // 使用0.01作为容差
  736. const result = new UTSJSONObject();
  737. result.set('valid', false);
  738. result.set('message', `检修工分总和不能超过工单总分 ${totalScore.toFixed(2)} 分(当前:${totalSelfScore.toFixed(2)} 分)`);
  739. return result;
  740. } */
  741. // 对于非零总分且非多选维保类型零分非零混合的情况,自评分总和必须小于等于总分+0.5
  742. if (totalScore > 0 && !isMultipleInspectionWithMixedScores) {
  743. // 计算理论总分(总分+0.5,因为工作负责人会额外加0.5分)
  744. const expectedTotal = totalScore + 0.5;
  745. // 总得分必须等于总分+0.5(使用容差比较)
  746. /* if (Math.abs(totalSelfScore - expectedTotal) > 0.01) {
  747. const result = new UTSJSONObject();
  748. result.set('valid', false);
  749. result.set('message', `总得分必须等于 ${expectedTotal.toFixed(2)} 分(当前:${totalSelfScore.toFixed(2)} 分)`);
  750. return result;
  751. } */
  752. if (totalSelfScore - expectedTotal > 0.01) {
  753. const result = new UTSJSONObject();
  754. result.set('valid', false);
  755. result.set('message', `总得分必须小于等于 ${expectedTotal.toFixed(2)} 分(当前:${totalSelfScore.toFixed(2)} 分)`);
  756. return result;
  757. }
  758. }
  759. // 如果是维保工单且多选维保类型且存在零分和非零分混合的情况,需要特殊处理
  760. if (isMultipleInspectionWithMixedScores) {
  761. // 在这种情况下,总分可能有最小值要求
  762. const completionFactor = selfEvaluationForm.value.itemCompletionFactor != null ? selfEvaluationForm.value.itemCompletionFactor : 1
  763. // 重新计算非零分项的总分
  764. let minScoreFromDB = 0;
  765. const selectedInspectionTypes: string[] = selfEvaluationForm.value.inspectionType != null ? selfEvaluationForm.value.inspectionType : []
  766. for (let i = 0; i < selectedInspectionTypes.length; i++) {
  767. const typeId = selectedInspectionTypes[i]
  768. for (let j = 0; j < inspectionTypeOptions.value.length; j++) {
  769. const selectedType = inspectionTypeOptions.value[j]
  770. // 使用inspectionTypeId进行匹配
  771. if (selectedType.get('inspectionTypeId').toString() == typeId) {
  772. const score = selectedType.get('score');
  773. if (score != null && typeof score == 'number' && score > 0) { // 只累加非零分
  774. minScoreFromDB += score;
  775. }
  776. }
  777. }
  778. }
  779. // 计算最低理论总分(非零项的总分 * 分项完成系数 + 0.5)
  780. const minExpectedTotal = (minScoreFromDB * completionFactor) + 0.5
  781. /* // 总得分不得低于最低理论总分
  782. if (totalSelfScore < minExpectedTotal - 0.01) { // 使用0.01作为容差
  783. const result = new UTSJSONObject();
  784. result.set('valid', false);
  785. result.set('message', `总得分不得低于 ${minExpectedTotal.toFixed(2)} 分(当前:${totalSelfScore.toFixed(2)} 分)`);
  786. return result;
  787. } */
  788. }
  789. const result = new UTSJSONObject();
  790. result.set('valid', true);
  791. result.set('message', '');
  792. return result;
  793. }
  794. // 验证整个表单
  795. function validateForm(): any {
  796. console.log('开始验证表单,工单类型:', selfEvaluationForm.value.orderType);
  797. console.log('当前检修类型值:', selfEvaluationForm.value.maintenanceType);
  798. // 首先验证必填字段,按优先级排序
  799. // 验证工单类型为1(维修工单)时的检修类型
  800. if (selfEvaluationForm.value.orderType == '1') {
  801. console.log('验证维修工单的检修类型');
  802. console.log('当前maintenanceType值:', selfEvaluationForm.value.maintenanceType, '类型:', typeof selfEvaluationForm.value.maintenanceType);
  803. let validationMessage: string | null = null;
  804. try {
  805. validationMessage = validateField('maintenanceType', selfEvaluationForm.value.maintenanceType as any);
  806. } catch (error: any) {
  807. console.error('检修类型验证过程中出现异常:', error);
  808. validationMessage = '检修类型验证失败';
  809. }
  810. console.log('检修类型验证结果:', validationMessage);
  811. if (validationMessage != null) {
  812. console.log('检修类型验证失败:', validationMessage);
  813. const result = new UTSJSONObject();
  814. result.set('valid', false);
  815. result.set('message', validationMessage);
  816. return result;
  817. }
  818. }
  819. // 验证总结内容
  820. let summaryValidation: string | null = null;
  821. try {
  822. summaryValidation = validateField('workSummary', selfEvaluationForm.value.workSummary as any);
  823. } catch (error: any) {
  824. console.error('工作总结验证过程中出现异常:', error);
  825. summaryValidation = '工作总结验证失败';
  826. }
  827. if (summaryValidation != null) {
  828. const result = new UTSJSONObject();
  829. result.set('valid', false);
  830. result.set('message', summaryValidation);
  831. return result;
  832. }
  833. // 验证工单类型为2(维保工单)时的分项完成系数
  834. if (selfEvaluationForm.value.orderType == '2') {
  835. // 检查分项完成系数是否为空字符串(即用户清空了输入框)
  836. if (itemCompletionFactorStr.value == '') {
  837. const result = new UTSJSONObject();
  838. result.set('valid', false);
  839. result.set('message', '分项完成系数不能为空');
  840. return result;
  841. }
  842. let validationMessage: string | null = null;
  843. try {
  844. validationMessage = validateField('itemCompletionFactor', selfEvaluationForm.value.itemCompletionFactor as any);
  845. } catch (error: any) {
  846. validationMessage = '分项完成系数验证失败';
  847. }
  848. if (validationMessage != null) {
  849. const result = new UTSJSONObject();
  850. result.set('valid', false);
  851. result.set('message', validationMessage);
  852. return result;
  853. }
  854. // 验证分项完成系数和
  855. // 检查分项完成系数和是否为空字符串(即用户清空了输入框)
  856. if (itemCompletionFactorSumStr.value == '') {
  857. const result = new UTSJSONObject();
  858. result.set('valid', false);
  859. result.set('message', '分项完成系数和不能为空');
  860. return result;
  861. }
  862. validationMessage = null;
  863. try {
  864. validationMessage = validateField('itemCompletionFactorSum', selfEvaluationForm.value.itemCompletionFactorSum as any);
  865. } catch (error: any) {
  866. validationMessage = '分项完成系数和验证失败';
  867. }
  868. if (validationMessage != null) {
  869. const result = new UTSJSONObject();
  870. result.set('valid', false);
  871. result.set('message', validationMessage);
  872. return result;
  873. }
  874. }
  875. // 验证维保类型(仅适用于维保工单)
  876. if (selfEvaluationForm.value.orderType == '2') {
  877. let validationMessage: string | null = null;
  878. try {
  879. validationMessage = validateField('inspectionType', selfEvaluationForm.value.inspectionType as any);
  880. } catch (error: any) {
  881. console.error('维保类型验证过程中出现异常:', error);
  882. validationMessage = '维保类型验证失败';
  883. }
  884. if (validationMessage != null) {
  885. const result = new UTSJSONObject();
  886. result.set('valid', false);
  887. result.set('message', validationMessage);
  888. return result;
  889. }
  890. }
  891. // 验证评分规则
  892. let scoringValidation: UTSJSONObject;
  893. try {
  894. scoringValidation = validateScoringRules() as UTSJSONObject;
  895. } catch (error: any) {
  896. console.error('评分规则验证过程中出现异常:', error);
  897. const result = new UTSJSONObject();
  898. result.set('valid', false);
  899. result.set('message', '评分规则验证失败');
  900. return result;
  901. }
  902. if (!(scoringValidation.get('valid') as boolean)) {
  903. const result = new UTSJSONObject();
  904. result.set('valid', false);
  905. result.set('message', scoringValidation.get('message') as string);
  906. return result;
  907. }
  908. const result = new UTSJSONObject();
  909. result.set('valid', true);
  910. result.set('message', '');
  911. return result;
  912. }
  913. // 加载检修类型选项
  914. async function loadMaintenanceTypes() {
  915. try {
  916. /* uni.showLoading({
  917. title: '加载中...'
  918. }) */
  919. const response: any = await getMaintenanceTypes()
  920. const resultObj = response as UTSJSONObject
  921. const code = resultObj.get('code') as number
  922. if (code == 200) {
  923. const data = resultObj.get('rows') as UTSJSONObject[]
  924. if (data != null && Array.isArray(data)) {
  925. // 将后端返回的数据转换为页面需要的格式
  926. const options: MaintenanceTypeOption[] = []
  927. for (let i = 0; i < data.length; i++) {
  928. const item = data[i]
  929. const option: MaintenanceTypeOption = {
  930. value: (item.get('maintenanceType') as string | null) ?? '',
  931. label: `${(item.get('projectName') as string | null) ?? ''}(${(item.get('scorePerCompletion') as number | null) ?? 0}分)`
  932. }
  933. options.push(option)
  934. }
  935. maintenanceTypeOptions.value = options
  936. // 设置选中项索引
  937. const mt = selfEvaluationForm.value.maintenanceType
  938. if (mt != null && mt != '') {
  939. const index = maintenanceTypeOptions.value.findIndex(item => item.value == mt)
  940. if (index >= 0) {
  941. selectedMaintenanceTypeIndex.value = index
  942. }
  943. } else {
  944. // 如果maintenanceType为空,重置选中索引
  945. selectedMaintenanceTypeIndex.value = -1
  946. selfEvaluationForm.value.maintenanceType = null
  947. }
  948. }
  949. } else {
  950. const msg = resultObj.get('msg') as string | null
  951. console.error('加载检修类型失败:', msg ?? '未知错误')
  952. }
  953. } catch (error: any) {
  954. console.error('加载检修类型失败:', error)
  955. } finally {
  956. //uni.hideLoading()
  957. }
  958. }
  959. // 加载维保类型选项
  960. async function loadInspectionTypeOptions() {
  961. try {
  962. // 加载维保类型选项
  963. if (orderType.value == '2') {
  964. // 根据风机型号获取维保类型选项
  965. const fanType = selfEvaluationForm.value.model; // 使用风机型号
  966. if (fanType != null && fanType != '') {
  967. const response: any = await listInspectionTypesByFanType(fanType as string);
  968. const resultObj = response as UTSJSONObject;
  969. const code = resultObj.get('code') as number;
  970. if (code == 200) {
  971. const data = resultObj.get('data') as UTSJSONObject[];
  972. if (data != null && Array.isArray(data)) {
  973. inspectionTypeOptions.value = data;
  974. }
  975. } else {
  976. console.error('API返回错误码:', code);
  977. console.error('错误信息:', resultObj.get('msg'));
  978. }
  979. } else {
  980. console.warn('风机型号为空,无法加载维保类型选项');
  981. }
  982. }
  983. } catch (e: any) {
  984. console.error('获取维保类型选项失败:', e.message);
  985. //console.error('错误堆栈:', e.stack);
  986. }
  987. }
  988. // 加载工单详情
  989. async function loadOrderDetail() {
  990. try {
  991. uni.showLoading({
  992. title: '加载中...'
  993. })
  994. const response: any = await getOrderScoreDetail(orderType.value, id.value)
  995. const resultObj = response as UTSJSONObject
  996. const code = resultObj.get('code') as number
  997. if (code == 200) {
  998. const data = resultObj.get('data') as UTSJSONObject
  999. // 设置表单数据
  1000. const formData: SelfEvaluationFormData = {
  1001. orderType: orderType.value,
  1002. id: (data.get('id') as number | null) ?? 0,
  1003. workOrderProjectNo: (data.get('workOrderProjectNo') as string | null) ?? '',
  1004. pcsDeviceName: (data.get('pcsDeviceName') as string | null) ?? '',
  1005. pcsStationName: (data.get('pcsStationName') as string | null) ?? '',
  1006. workSummary: orderType.value == '1' ? ((data.get('content') as string | null) ?? '') : ((data.get('realContent') as string | null) ?? ''),
  1007. extraWork: orderType.value == '1' ? ((data.get('extraWork') as string | null) ?? '') : '',
  1008. maintenanceType: (data.get('maintenanceType') as string | null),
  1009. model: (data.get('model') as string | null), // 风机型号
  1010. inspectionType: orderType.value == '2' ?
  1011. (Array.isArray(data.get('inspectionType')) ?
  1012. data.get('inspectionType') as string[] :
  1013. (((data.get('inspectionType') as string | null)?.split(',') ?? []) as string[])) : [],
  1014. itemCompletionFactor: (data.get('itemCompletionFactor') as number | null),
  1015. itemCompletionFactorSum: (data.get('itemCompletionFactorSum') as number | null),
  1016. scorePersonList: orderType.value == '1' ?
  1017. ((data.get('repairOrderPersonList') as UTSJSONObject[] | null) ?? []) :
  1018. ((data.get('workOrderPersonList') as UTSJSONObject[] | null) ?? []),
  1019. wwryNum: (data.get('wwryNum') as number | null) ?? 0,
  1020. wlryNum: (data.get('wlryNum') as number | null) ?? 0
  1021. }
  1022. selfEvaluationForm.value = formData
  1023. // 为人员列表设置初始分数
  1024. /* const list = (formData.scorePersonList as UTSJSONObject[])
  1025. for (let i = 0; i < list.length; i++) {
  1026. const person = list[i]
  1027. if (person.get('selfScore') == null) {
  1028. person.set('selfScore', '')
  1029. }
  1030. if (person.get('extraScore') == null) {
  1031. person.set('extraScore', '')
  1032. }
  1033. if (person.get('totalScore') == null) {
  1034. person.set('totalScore', '')
  1035. }
  1036. } */
  1037. // 初始化字符串中转值,处理可能为null的情况
  1038. itemCompletionFactorStr.value = formData.itemCompletionFactor != null ? formData.itemCompletionFactor.toFixed(2) : ''
  1039. itemCompletionFactorSumStr.value = formData.itemCompletionFactorSum != null ? formData.itemCompletionFactorSum.toFixed(2) : ''
  1040. // 加载检修类型选项
  1041. if (orderType.value == '1') {
  1042. await loadMaintenanceTypes()
  1043. }
  1044. // 加载维保类型选项
  1045. if (orderType.value == '2') {
  1046. await loadInspectionTypeOptions()
  1047. }
  1048. // 计算初始分数
  1049. calculateScores()
  1050. // 设置额外工作总结状态标志
  1051. hasExtraWorkFlag.value = formData.extraWork != null && formData.extraWork.trim() != '';
  1052. // 初始化已自评总分
  1053. updateSelfEvaluatedTotalScore()
  1054. } else {
  1055. const msg = resultObj.get('msg') as string | null
  1056. uni.showToast({
  1057. title: msg ?? '加载失败',
  1058. icon: 'none'
  1059. })
  1060. }
  1061. } catch (error: any) {
  1062. console.error('加载工单详情失败:', error)
  1063. uni.showToast({
  1064. title: '加载失败',
  1065. icon: 'none'
  1066. })
  1067. } finally {
  1068. uni.hideLoading()
  1069. }
  1070. }
  1071. // 加载字典数据
  1072. async function loadDictData() {
  1073. try {
  1074. // 加载维保类型字典
  1075. if (orderType.value == '2') {
  1076. const result = await getDictDataByType('gxt_inspection_type')
  1077. const resultObj = result as UTSJSONObject
  1078. if (resultObj.get('code') == 200) {
  1079. const data = resultObj.get('data') as any[]
  1080. const dictData: SysDictData[] = []
  1081. if (data != null && data.length > 0) {
  1082. for (let i = 0; i < data.length; i++) {
  1083. const item = data[i] as UTSJSONObject
  1084. // 只提取需要的字段
  1085. const dictItem: SysDictData = {
  1086. dictValue: item.get('dictValue') as string | null,
  1087. dictLabel: item.get('dictLabel') as string | null,
  1088. dictCode: null,
  1089. dictSort: null,
  1090. dictType: null,
  1091. cssClass: null,
  1092. listClass: null,
  1093. isDefault: null,
  1094. status: null,
  1095. default: null,
  1096. createTime: null,
  1097. remark: null
  1098. }
  1099. dictData.push(dictItem)
  1100. }
  1101. }
  1102. inspectionTypeDictList.value = dictData
  1103. }
  1104. }
  1105. } catch (e: any) {
  1106. console.error('获取维保类型字典失败:', e.message)
  1107. }
  1108. }
  1109. // 检修类型选择变化
  1110. function selectMaintenanceType(index: number) {
  1111. selectedMaintenanceTypeIndex.value = index
  1112. if (index >= 0 && index < maintenanceTypeOptions.value.length) {
  1113. selfEvaluationForm.value.maintenanceType = maintenanceTypeOptions.value[index].value
  1114. }
  1115. showMaintenanceTypePicker.value = false
  1116. // 选择后立即触发验证
  1117. const validationMessage = validateField('maintenanceType', selfEvaluationForm.value.maintenanceType as any);
  1118. if (validationMessage != null) {
  1119. uni.showToast({
  1120. title: validationMessage,
  1121. icon: 'none'
  1122. });
  1123. }
  1124. }
  1125. // 根据值获取检修类型标签
  1126. function getMaintenanceTypeLabel(value: string | null): string {
  1127. if (value == null || value == '') return ''
  1128. const item = maintenanceTypeOptions.value.find(item => item.value == value)
  1129. return item != null ? item.label : value
  1130. }
  1131. // 工作总结输入处理
  1132. function onWorkSummaryInput(e: UniInputEvent) {
  1133. const value = e.detail?.value as string
  1134. selfEvaluationForm.value.workSummary = value
  1135. }
  1136. // 格式化分项完成系数输入值
  1137. function formatItemCompletionFactor() {
  1138. const tempValue = tempItemCompletionFactorInput.value;
  1139. let finalValue: number | null = null; // 明确定义类型
  1140. if (tempValue.endsWith('.')) {
  1141. // 如果以点结尾,去除点号
  1142. const processedValue = tempValue.slice(0, -1);
  1143. if (processedValue != '') {
  1144. const numValue = parseFloat(processedValue);
  1145. if (!isNaN(numValue) && isFinite(numValue)) {
  1146. if (numValue >= 0 && numValue <= 1) {
  1147. finalValue = numValue;
  1148. } else {
  1149. finalValue = numValue > 1 ? 1 : 0; // 根据数值大小决定边界值
  1150. }
  1151. } else {
  1152. finalValue = 1; // 默认值
  1153. }
  1154. } else {
  1155. // 去掉点后为空,设为null
  1156. finalValue = null;
  1157. }
  1158. } else {
  1159. // 正常数值处理
  1160. const currentValue = selfEvaluationForm.value.itemCompletionFactor;
  1161. if (currentValue != null && typeof currentValue == 'number') {
  1162. // 格式化小数位数
  1163. const currentStr = currentValue.toString();
  1164. const parts = currentStr.split('.');
  1165. if (parts.length > 1 && parts[1] != null && parts[1].length > 2) {
  1166. // 创建一个局部变量确保类型安全
  1167. const valueToFormat: number = currentValue;
  1168. finalValue = parseFloat(valueToFormat.toFixed(2));
  1169. } else {
  1170. finalValue = currentValue;
  1171. }
  1172. }
  1173. }
  1174. // 更新数值
  1175. selfEvaluationForm.value.itemCompletionFactor = finalValue;
  1176. // 同步更新临时输入值为格式化后的字符串显示
  1177. if (finalValue != null) {
  1178. tempItemCompletionFactorInput.value = finalValue.toString();
  1179. } else {
  1180. tempItemCompletionFactorInput.value = '';
  1181. }
  1182. }
  1183. function onItemCompletionFactorInput(e: UniInputEvent) {
  1184. const value = e.detail?.value as string;
  1185. // 更新临时输入值
  1186. tempItemCompletionFactorInput.value = value;
  1187. // 检查输入值是否为空
  1188. if (value == '') {
  1189. selfEvaluationForm.value.itemCompletionFactor = null;
  1190. } else {
  1191. // 检查是否为中间输入状态(如 '0.' 等以点结尾的数字)
  1192. if (value.endsWith('.')) {
  1193. // 如果是中间输入状态,不更新数值,保持原有值
  1194. return;
  1195. }
  1196. // 验证输入值是否为有效数字
  1197. const numValue = parseFloat(value);
  1198. if (!isNaN(numValue) && isFinite(numValue)) {
  1199. if( numValue >= 0 && numValue <= 1){
  1200. // 在input事件中直接使用解析后的数值
  1201. selfEvaluationForm.value.itemCompletionFactor = numValue;
  1202. } else {
  1203. // 当超出范围时,设置实际值为边界值
  1204. selfEvaluationForm.value.itemCompletionFactor = numValue > 1 ? 1 : 0;
  1205. }
  1206. // 更新可自评总分显示
  1207. //updateSelfEvaluatedTotalScore();
  1208. }
  1209. }
  1210. calculateScores();
  1211. }
  1212. // 获取分项完成系数显示值
  1213. function getItemCompletionFactorDisplayValue(): string {
  1214. // 优先返回临时输入值,确保输入过程中的显示与用户操作一致
  1215. if (tempItemCompletionFactorInput.value != null && tempItemCompletionFactorInput.value != '') {
  1216. return tempItemCompletionFactorInput.value;
  1217. }
  1218. // 否则返回格式化后的数值
  1219. const value = selfEvaluationForm.value.itemCompletionFactor;
  1220. if (value == null) {
  1221. return '';
  1222. }
  1223. if (typeof value == 'number') {
  1224. return value.toString();
  1225. }
  1226. return value as string;
  1227. }
  1228. // 格式化分项完成系数和输入值
  1229. function formatItemCompletionFactorSum() {
  1230. const tempValue = tempItemCompletionFactorSumInput.value;
  1231. let finalValue: number | null = null; // 明确定义类型
  1232. if (tempValue.endsWith('.')) {
  1233. // 如果以点结尾,去除点号
  1234. const processedValue = tempValue.slice(0, -1);
  1235. if (processedValue != '') {
  1236. const numValue = parseFloat(processedValue);
  1237. if (!isNaN(numValue) && isFinite(numValue)) {
  1238. if (numValue >= 0 && numValue <= 1) {
  1239. finalValue = numValue;
  1240. } else {
  1241. finalValue = numValue > 1 ? 1 : 0; // 根据数值大小决定边界值
  1242. }
  1243. } else {
  1244. finalValue = 1; // 默认值
  1245. }
  1246. } else {
  1247. // 去掉点后为空,设为null
  1248. finalValue = null;
  1249. }
  1250. } else {
  1251. // 正常数值处理
  1252. const currentValue = selfEvaluationForm.value.itemCompletionFactorSum;
  1253. if (currentValue != null && typeof currentValue == 'number') {
  1254. // 格式化小数位数
  1255. const currentStr = currentValue.toString();
  1256. const parts = currentStr.split('.');
  1257. if (parts.length > 1 && parts[1] != null && parts[1].length > 2) {
  1258. // 创建一个局部变量确保类型安全
  1259. const valueToFormat: number = currentValue;
  1260. finalValue = parseFloat(valueToFormat.toFixed(2));
  1261. } else {
  1262. finalValue = currentValue;
  1263. }
  1264. }
  1265. }
  1266. // 更新数值
  1267. selfEvaluationForm.value.itemCompletionFactorSum = finalValue;
  1268. // 同步更新临时输入值为格式化后的字符串显示
  1269. if (finalValue != null) {
  1270. tempItemCompletionFactorSumInput.value = finalValue.toString();
  1271. } else {
  1272. tempItemCompletionFactorSumInput.value = '';
  1273. }
  1274. }
  1275. function onItemCompletionFactorSumInput(e: UniInputEvent) {
  1276. const value = e.detail?.value as string;
  1277. // 更新临时输入值
  1278. tempItemCompletionFactorSumInput.value = value;
  1279. // 检查输入值是否为空
  1280. if (value == '') {
  1281. selfEvaluationForm.value.itemCompletionFactorSum = null;
  1282. } else {
  1283. // 检查是否为中间输入状态(如 '0.' 等以点结尾的数字)
  1284. if (value.endsWith('.')) {
  1285. // 如果是中间输入状态,不更新数值,保持原有值
  1286. return;
  1287. }
  1288. // 验证输入值是否为有效数字
  1289. const numValue = parseFloat(value);
  1290. if (!isNaN(numValue) && isFinite(numValue)) {
  1291. if( numValue >= 0 && numValue <= 1){
  1292. // 在input事件中直接使用解析后的数值
  1293. selfEvaluationForm.value.itemCompletionFactorSum = numValue;
  1294. } else {
  1295. // 当超出范围时,设置实际值为边界值
  1296. selfEvaluationForm.value.itemCompletionFactorSum = numValue > 1 ? 1 : 0;
  1297. }
  1298. }
  1299. }
  1300. }
  1301. // 获取分项完成系数和显示值
  1302. function getItemCompletionFactorSumDisplayValue(): string {
  1303. // 优先返回临时输入值,确保输入过程中的显示与用户操作一致
  1304. if (tempItemCompletionFactorSumInput.value != null && tempItemCompletionFactorSumInput.value != '') {
  1305. return tempItemCompletionFactorSumInput.value;
  1306. }
  1307. // 否则返回格式化后的数值
  1308. const value = selfEvaluationForm.value.itemCompletionFactorSum;
  1309. if (value == null) {
  1310. return '';
  1311. }
  1312. if (typeof value == 'number') {
  1313. return value.toString();
  1314. }
  1315. return value as string;
  1316. }
  1317. // 额外工作总结变化
  1318. function onExtraWorkChange() {
  1319. // 更新额外工作总结状态标志
  1320. // 使用更严格的检查,包括检查长度
  1321. let extraWorkStr = '';
  1322. if (selfEvaluationForm.value.extraWork != null) {
  1323. extraWorkStr = selfEvaluationForm.value.extraWork;
  1324. }
  1325. const trimmedStr = extraWorkStr.trim();
  1326. const newHasExtraWork = trimmedStr.length > 0;
  1327. hasExtraWorkFlag.value = newHasExtraWork;
  1328. // 如果额外工作总结为空,则清空额外工分和总分字段
  1329. if (trimmedStr.length == 0) {
  1330. // 清空所有人员的额外工分和总分
  1331. const scorePersonList = selfEvaluationForm.value.scorePersonList as UTSJSONObject[]
  1332. for (let i = 0; i < scorePersonList.length; i++) {
  1333. const person = scorePersonList[i]
  1334. person.set('extraScore', 0)
  1335. // 重新计算总分(此时额外工分为空,所以总分等于自评分)
  1336. const selfScoreVal = person.get('selfScore');
  1337. if (selfScoreVal != null) {
  1338. const selfScore = typeof selfScoreVal == 'number' ? selfScoreVal : (selfScoreVal != '' ? parseFloat(selfScoreVal as string) : 0);
  1339. if (!isNaN(selfScore)) {
  1340. person.set('totalScore', selfScore);
  1341. } else {
  1342. person.set('totalScore', 0);
  1343. }
  1344. } else {
  1345. person.set('totalScore', 0);
  1346. }
  1347. }
  1348. }
  1349. // 更新已自评总分显示
  1350. updateSelfEvaluatedTotalScore()
  1351. // 当额外工作总结变化时,可能需要重新计算总分
  1352. updateTotalScores()
  1353. }
  1354. // 额外工作总结输入处理
  1355. function onExtraWorkInput(e: UniInputEvent) {
  1356. const value = e.detail?.value;
  1357. // 确保当值为null时设置为空字符串
  1358. if (value == null) {
  1359. selfEvaluationForm.value.extraWork = '';
  1360. } else {
  1361. selfEvaluationForm.value.extraWork = value.toString();
  1362. }
  1363. // 每次输入都触发变化处理
  1364. onExtraWorkChange()
  1365. }
  1366. // 获取人员评分
  1367. function getPersonScore(person: UTSJSONObject, field: string): string {
  1368. const value = person.get(field as string)
  1369. if (value == null || value == '' || (typeof value == 'number' && isNaN(value))) {
  1370. return ''
  1371. }
  1372. // 统一处理为字符串返回给UI
  1373. if (typeof value == 'number') {
  1374. const stringValue = value.toString();
  1375. return stringValue;
  1376. //return value.toFixed(2);
  1377. }
  1378. return value as string
  1379. }
  1380. // 设置人员评分
  1381. function setPersonScore(person: UTSJSONObject, field: string, value: string) {
  1382. person.set(field as string, value)
  1383. }
  1384. // 通用评分输入处理
  1385. function onScoreInput(e: UniInputEvent, index: number, field: string) {
  1386. const value = e.detail?.value as string
  1387. if (index >= 0 && index < selfEvaluationForm.value.scorePersonList.length) {
  1388. const person = selfEvaluationForm.value.scorePersonList[index] as UTSJSONObject
  1389. if (person != null) {
  1390. // 将输入的字符串转换为数字存储
  1391. const numericValue = value == '' ? null : parseFloat(value);
  1392. person.set(field, (numericValue != null && isNaN(numericValue)) ? null : numericValue);
  1393. // 实时验证评分
  1394. if (value != '') {
  1395. const validationError = validatePersonScore(value, field)
  1396. if (validationError != null) { // 修复条件判断
  1397. // 显示验证错误(在实际应用中,这里可以显示在界面上)
  1398. console.warn(`评分验证错误: ${validationError}`)
  1399. // 可以考虑用uni.showToast显示错误信息
  1400. /* uni.showToast({
  1401. title: validationError,
  1402. icon: 'none',
  1403. duration: 2000
  1404. }) */
  1405. }
  1406. }
  1407. updateTotalScores()
  1408. updateSelfEvaluatedTotalScore()
  1409. }
  1410. }
  1411. }
  1412. // 格式化评分输入值
  1413. function formatScoreInput(index: number, field: string) {
  1414. if (index >= 0 && index < selfEvaluationForm.value.scorePersonList.length) {
  1415. const person = selfEvaluationForm.value.scorePersonList[index] as UTSJSONObject
  1416. if (person != null) {
  1417. const value = person.get(field as string);
  1418. if (typeof value == 'number') {
  1419. // 检查数值的小数位数是否超过2位
  1420. const parts = value.toString().split('.');
  1421. if (parts.length > 1) { // 确保有小数部分
  1422. const decimalPart = parts[1];
  1423. if (decimalPart != null && decimalPart.length > 2) {
  1424. // 如果小数位数超过2位,使用格式化后的值
  1425. const formattedValue = parseFloat((value as number).toFixed(2));
  1426. person.set(field as string, formattedValue);
  1427. }
  1428. }
  1429. }
  1430. }
  1431. }
  1432. }
  1433. // 分数变化
  1434. function onScoreChange() {
  1435. updateTotalScores()
  1436. updateSelfEvaluatedTotalScore() // 更新已自评总分显示
  1437. }
  1438. // 返回按钮事件
  1439. function goBack() {
  1440. uni.navigateBack()
  1441. }
  1442. // 提交自评
  1443. async function submitSelfEvaluationForm(): Promise<void> {
  1444. try {
  1445. console.log('开始提交验证');
  1446. // 使用完整的表单验证
  1447. const validation = validateForm() as UTSJSONObject;
  1448. const isValid = validation.get('valid') as boolean;
  1449. const validationMsg = validation.get('message') as string;
  1450. console.log('验证结果:', isValid, '消息:', validationMsg);
  1451. console.log('验证结果类型:', typeof isValid, '是否为false:', isValid == false);
  1452. if (!isValid) {
  1453. console.log('验证失败,显示错误:', validationMsg);
  1454. uni.showToast({
  1455. title: validationMsg,
  1456. icon: 'none'
  1457. });
  1458. return;
  1459. }
  1460. uni.showLoading({
  1461. title: '提交中...'
  1462. })
  1463. // 创建新的UTSJSONObject来存储表单数据
  1464. const formValue = new UTSJSONObject();
  1465. // 复制基本字段
  1466. formValue.set('id', selfEvaluationForm.value.id);
  1467. formValue.set('orderType', selfEvaluationForm.value.orderType);
  1468. formValue.set('workOrderProjectNo', selfEvaluationForm.value.workOrderProjectNo);
  1469. formValue.set('pcsDeviceName', selfEvaluationForm.value.pcsDeviceName);
  1470. formValue.set('pcsStationName', selfEvaluationForm.value.pcsStationName);
  1471. formValue.set('workSummary', selfEvaluationForm.value.workSummary);
  1472. formValue.set('extraWork', selfEvaluationForm.value.extraWork);
  1473. formValue.set('maintenanceType', selfEvaluationForm.value.maintenanceType);
  1474. formValue.set('itemCompletionFactor', selfEvaluationForm.value.itemCompletionFactor);
  1475. formValue.set('itemCompletionFactorSum', selfEvaluationForm.value.itemCompletionFactorSum);
  1476. formValue.set('wwryNum', selfEvaluationForm.value.wwryNum);
  1477. formValue.set('wlryNum', selfEvaluationForm.value.wlryNum);
  1478. // 处理inspectionType字段:如果是数组则转换为字符串
  1479. if (Array.isArray(selfEvaluationForm.value.inspectionType)) {
  1480. const strValue = (selfEvaluationForm.value.inspectionType as string[]).join(',');
  1481. formValue.set('inspectionType', strValue);
  1482. } else {
  1483. formValue.set('inspectionType', selfEvaluationForm.value.inspectionType);
  1484. }
  1485. // 复制scorePersonList数组
  1486. const scorePersonListArray: UTSJSONObject[] = [];
  1487. for (let i = 0; i < selfEvaluationForm.value.scorePersonList.length; i++) {
  1488. const person = selfEvaluationForm.value.scorePersonList[i];
  1489. // 将UTSJSONObject添加到数组中
  1490. scorePersonListArray.push(person);
  1491. }
  1492. formValue.set('scorePersonList', scorePersonListArray);
  1493. const response: any = await submitSelfEvaluation(formValue);
  1494. const resultObj = response as UTSJSONObject
  1495. const code = resultObj.get('code' as string) as number
  1496. if (code == 200) {
  1497. uni.showToast({
  1498. title: '自评提交成功',
  1499. icon: 'success'
  1500. })
  1501. // 设置标记,通知上一个页面需要刷新数据
  1502. uni.setStorageSync('needRefresh', true)
  1503. // 延迟返回上一页
  1504. setTimeout(() => {
  1505. uni.navigateBack()
  1506. }, 1000)
  1507. } else {
  1508. const msg = resultObj.get('msg' as string) as string | null
  1509. uni.showToast({
  1510. title: msg ?? '提交失败',
  1511. icon: 'none'
  1512. })
  1513. }
  1514. } catch (error: any) {
  1515. console.error('提交自评失败:', error)
  1516. uni.showToast({
  1517. title: '提交失败',
  1518. icon: 'none'
  1519. })
  1520. } finally {
  1521. uni.hideLoading()
  1522. }
  1523. }
  1524. // 页面初始化
  1525. onLoad((options: any) => {
  1526. const params = options as UTSJSONObject
  1527. id.value = (params.get('id') != null ? params.get('id') as string : '')
  1528. orderType.value = (params.get('orderType') != null ? params.get('orderType') as string : '')
  1529. console.log("id.value==",id.value)
  1530. console.log("orderType.value==",orderType.value)
  1531. // 加载字典数据
  1532. loadDictData()
  1533. // 加载工单详情
  1534. loadOrderDetail()
  1535. })
  1536. </script>
  1537. <style lang="scss">
  1538. .container {
  1539. flex: 1;
  1540. background-color: #e8f0f9;
  1541. //height: 100vh;
  1542. }
  1543. .header {
  1544. padding: 30rpx;
  1545. text-align: center;
  1546. }
  1547. .title {
  1548. font-size: 36rpx;
  1549. font-weight: bold;
  1550. color: #333;
  1551. }
  1552. .form {
  1553. padding: 0 30rpx 30rpx;
  1554. }
  1555. .info-card {
  1556. background-color: #ffffff;
  1557. border-radius: 16rpx;
  1558. padding: 30rpx;
  1559. margin-bottom: 20rpx;
  1560. }
  1561. .info-item {
  1562. flex-direction: row;
  1563. padding: 20rpx 0;
  1564. border-bottom: 1rpx solid #f0f0f0;
  1565. &:last-child {
  1566. border-bottom: none;
  1567. }
  1568. .info-label {
  1569. width: 240rpx;
  1570. font-size: 28rpx;
  1571. color: #666666;
  1572. white-space: nowrap;
  1573. }
  1574. .info-value {
  1575. flex: 1;
  1576. font-size: 28rpx;
  1577. color: #333333;
  1578. text-align: right;
  1579. }
  1580. .info-input {
  1581. flex: 1;
  1582. font-size: 28rpx;
  1583. color: #333333;
  1584. border: 1rpx solid #e0e0e0;
  1585. border-radius: 8rpx;
  1586. padding: 10rpx;
  1587. text-align: right;
  1588. }
  1589. }
  1590. .form-item {
  1591. margin-bottom: 30rpx;
  1592. display: flex;
  1593. flex-direction: column;
  1594. }
  1595. .label {
  1596. font-size: 28rpx;
  1597. color: #666;
  1598. margin-bottom: 10rpx;
  1599. font-weight: bold;
  1600. }
  1601. .value {
  1602. font-size: 28rpx;
  1603. color: #333;
  1604. }
  1605. .textarea {
  1606. width: 100%;
  1607. height: 200rpx;
  1608. border: 1rpx solid #e5e5e5;
  1609. border-radius: 8rpx;
  1610. padding: 20rpx;
  1611. font-size: 28rpx;
  1612. color: #333;
  1613. }
  1614. .picker {
  1615. width: 100%;
  1616. }
  1617. .picker-display {
  1618. flex-direction: row;
  1619. justify-content: space-between;
  1620. align-items: center;
  1621. padding: 10rpx;
  1622. border: 1rpx solid #e5e5e5;
  1623. border-radius: 8rpx;
  1624. }
  1625. .selected-value {
  1626. font-size: 28rpx;
  1627. color: #333;
  1628. }
  1629. .placeholder {
  1630. font-size: 28rpx;
  1631. color: #999;
  1632. }
  1633. .arrow {
  1634. font-size: 24rpx;
  1635. color: #999;
  1636. }
  1637. .selected-values {
  1638. display: flex;
  1639. flex-wrap: wrap;
  1640. //gap: 10rpx;
  1641. }
  1642. .selected-value-tag {
  1643. background-color: #f0f0f0;
  1644. padding: 8rpx 16rpx;
  1645. border-radius: 20rpx;
  1646. font-size: 24rpx;
  1647. color: #666;
  1648. }
  1649. .person-score-item {
  1650. margin-bottom: 30rpx;
  1651. padding: 20rpx;
  1652. background-color: #f8f9fa;
  1653. border-radius: 12rpx;
  1654. }
  1655. .person-info {
  1656. margin-bottom: 15rpx;
  1657. }
  1658. .person-name {
  1659. font-size: 28rpx;
  1660. font-weight: bold;
  1661. color: #333;
  1662. }
  1663. .score-inputs {
  1664. display: flex;
  1665. flex-direction: column;
  1666. //gap: 15rpx;
  1667. }
  1668. .score-item {
  1669. display: flex;
  1670. flex-direction: row;
  1671. align-items: center;
  1672. justify-content: space-between;
  1673. }
  1674. .score-label {
  1675. font-size: 26rpx;
  1676. color: #666;
  1677. width: 120rpx;
  1678. flex-shrink: 0;
  1679. }
  1680. .score-input {
  1681. flex: 1;
  1682. height: 60rpx;
  1683. border: 1rpx solid #e0e0e0;
  1684. border-radius: 8rpx;
  1685. padding: 0 15rpx;
  1686. font-size: 26rpx;
  1687. color: #333;
  1688. text-align: right;
  1689. }
  1690. .submit-btn {
  1691. margin-top: 40rpx;
  1692. height: 80rpx;
  1693. background-color: #165DFF;
  1694. border-radius: 10rpx;
  1695. display: flex;
  1696. align-items: center;
  1697. justify-content: center;
  1698. }
  1699. .submit-text {
  1700. font-size: 32rpx;
  1701. color: #fff;
  1702. font-weight: bold;
  1703. }
  1704. /* 自定义选择器样式 */
  1705. .picker-modal {
  1706. position: fixed;
  1707. top: 0;
  1708. left: 0;
  1709. right: 0;
  1710. bottom: 0;
  1711. z-index: 1000;
  1712. }
  1713. .modal-mask {
  1714. position: absolute;
  1715. top: 0;
  1716. left: 0;
  1717. right: 0;
  1718. bottom: 0;
  1719. background-color: rgba(0, 0, 0, 0.5);
  1720. }
  1721. .modal-content {
  1722. position: absolute;
  1723. bottom: 0;
  1724. left: 0;
  1725. right: 0;
  1726. background-color: #ffffff;
  1727. border-top-left-radius: 16rpx;
  1728. border-top-right-radius: 16rpx;
  1729. min-height: 700rpx;
  1730. }
  1731. .modal-header {
  1732. flex-direction: row;
  1733. justify-content: space-between;
  1734. align-items: center;
  1735. padding: 30rpx;
  1736. border-bottom: 1rpx solid #f0f0f0;
  1737. }
  1738. .modal-title {
  1739. font-size: 32rpx;
  1740. font-weight: bold;
  1741. color: #333333;
  1742. }
  1743. .modal-close {
  1744. font-size: 28rpx;
  1745. color: #165DFF;
  1746. }
  1747. .modal-body {
  1748. max-height: 600rpx;
  1749. }
  1750. .picker-option {
  1751. flex-direction: row;
  1752. justify-content: space-between;
  1753. align-items: center;
  1754. padding: 24rpx 30rpx;
  1755. border-bottom: 1rpx solid #f0f0f0;
  1756. }
  1757. .picker-option.selected {
  1758. background-color: #f8f9fa;
  1759. }
  1760. .option-text {
  1761. font-size: 28rpx;
  1762. color: #333333;
  1763. }
  1764. .option-check {
  1765. font-size: 28rpx;
  1766. color: #165DFF;
  1767. }
  1768. .form-picker {
  1769. flex: 1;
  1770. }
  1771. .picker-display {
  1772. flex-direction: row;
  1773. justify-content: space-between;
  1774. align-items: center;
  1775. min-height: 40rpx;
  1776. }
  1777. .selected-value {
  1778. font-size: 28rpx;
  1779. color: #333333;
  1780. }
  1781. .placeholder {
  1782. font-size: 28rpx;
  1783. color: #999999;
  1784. }
  1785. .arrow {
  1786. font-size: 24rpx;
  1787. color: #999999;
  1788. margin-left: 12rpx;
  1789. }
  1790. </style>