reEvaluate.uvue 71 KB

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