selfEvaluate.uvue 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028
  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">{{ 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: '',
  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. if (value == null || value == '') {
  604. return "请选择检修类型";
  605. }
  606. } else if (fieldName == 'inspectionType') {
  607. // 验证维保类型
  608. if (value == null || (Array.isArray(value) && value.length == 0)) {
  609. return "请选择维保类型";
  610. }
  611. } else if (fieldName == 'itemCompletionFactor') {
  612. // 验证分项完成系数
  613. if (value == null || value == '') {
  614. return "分项完成系数不能为空";
  615. }
  616. // 验证数值范围
  617. let numValue: number;
  618. if (typeof value == 'string' && value != '') {
  619. numValue = parseFloat(value);
  620. } else if (typeof value == 'number') {
  621. numValue = value;
  622. } else {
  623. return "分项完成系数类型错误";
  624. }
  625. if (isNaN(numValue) || numValue < 0 || numValue > 1) {
  626. return '分项完成系数必须在0到1之间';
  627. }
  628. } else if (fieldName == 'itemCompletionFactorSum') {
  629. // 验证分项完成系数和
  630. if (value == null || value == '') {
  631. return "分项完成系数和不能为空";
  632. }
  633. // 验证数值范围
  634. let numValue: number;
  635. if (typeof value == 'string' && value != '') {
  636. numValue = parseFloat(value);
  637. } else if (typeof value == 'number') {
  638. numValue = value;
  639. } else {
  640. return "分项完成系数和类型错误";
  641. }
  642. if (isNaN(numValue) || numValue < 0 || numValue > 1) {
  643. return '分项完成系数和必须在0到1之间';
  644. }
  645. }
  646. return null;
  647. }
  648. // 验证评分规则
  649. function validateScoringRules(): any {
  650. // 获取工单总分
  651. const totalScore = getTotalScore()
  652. // 获取自评分总和
  653. const totalSelfScore = getSelfEvaluatedTotalScore()
  654. const scorePersonList = selfEvaluationForm.value.scorePersonList as UTSJSONObject[]
  655. if (scorePersonList == null || scorePersonList.length == 0) {
  656. const result = new UTSJSONObject();
  657. result.set('valid', true);
  658. result.set('message', '');
  659. return result;
  660. }
  661. // 检查每个人员的评分
  662. let hasEmptyScore = false;
  663. let leaderScore: number | null = null;
  664. for (let i = 0; i < scorePersonList.length; i++) {
  665. const person = scorePersonList[i];
  666. // 验证自评分
  667. const selfScore = person.get('selfScore');
  668. if (selfScore == null || selfScore == '' || (typeof selfScore == 'number' && isNaN(selfScore as number))) {
  669. hasEmptyScore = true;
  670. } else {
  671. const scoreStr = typeof selfScore == 'number' ? selfScore.toFixed(2) : selfScore as string;
  672. const validationError = validatePersonScore(scoreStr, 'selfScore');
  673. if (validationError != null) {
  674. const result = new UTSJSONObject();
  675. result.set('valid', false);
  676. result.set('message', `${person.get('nickName')}:${validationError}`);
  677. return result;
  678. }
  679. const score = typeof selfScore == 'number' ? selfScore : parseFloat(selfScore as string);
  680. if (person.get('isLeader') != null && person.get('isLeader') as number == 1) {
  681. leaderScore = score;
  682. }
  683. }
  684. // 验证额外工分(如果存在)
  685. const extraScore = person.get('extraScore');
  686. if (extraScore != null && extraScore != '' && !(typeof extraScore == 'number' && isNaN(extraScore as number))) {
  687. const extraScoreStr = typeof extraScore == 'number' ? extraScore.toFixed(2) : extraScore as string;
  688. const extraScoreError = validatePersonScore(extraScoreStr, 'extraScore');
  689. if (extraScoreError != null) {
  690. const result = new UTSJSONObject();
  691. result.set('valid', false);
  692. result.set('message', `${person.get('nickName')}:${extraScoreError}`);
  693. return result;
  694. }
  695. }
  696. }
  697. // 如果有人没评分,返回错误
  698. if (hasEmptyScore) {
  699. const result = new UTSJSONObject();
  700. result.set('valid', false);
  701. result.set('message', '部分人员未评分');
  702. return result;
  703. }
  704. // 检查工作负责人得分-0.5后是否小于等于0
  705. if (leaderScore != null) {
  706. const leaderScoreAfterReduction = leaderScore - 0.5
  707. if (leaderScoreAfterReduction <= 0) {
  708. const result = new UTSJSONObject();
  709. result.set('valid', false);
  710. result.set('message', `工作负责人得分减去0.5后不能小于等于0(当前:${leaderScore.toFixed(2)} - 0.5 = ${leaderScoreAfterReduction.toFixed(2)})`);
  711. return result;
  712. }
  713. }
  714. // 检查工单类型是否为维保工单且多选维保类型的情况,检查是否存在零分和非零分混合
  715. let isMultipleInspectionWithMixedScores = isMixedZeroNonZeroInspectionTypes();
  716. // 如果总分为0,则评分无上限
  717. if (totalScore == 0) {
  718. // 检查工作负责人得分-0.5后是否小于等于0
  719. if (leaderScore != null) {
  720. const leaderScoreAfterReduction = leaderScore - 0.5
  721. if (leaderScoreAfterReduction <= 0) {
  722. const result = new UTSJSONObject();
  723. result.set('valid', false);
  724. result.set('message', `工作负责人得分减去0.5后不能小于等于0(当前:${leaderScore.toFixed(2)} - 0.5 = ${leaderScoreAfterReduction.toFixed(2)})`);
  725. return result;
  726. }
  727. }
  728. const result = new UTSJSONObject();
  729. result.set('valid', true);
  730. result.set('message', '');
  731. return result;
  732. }
  733. // 检查自评分总和是否超过总分
  734. /* if (totalSelfScore > totalScore + 0.01) { // 使用0.01作为容差
  735. const result = new UTSJSONObject();
  736. result.set('valid', false);
  737. result.set('message', `检修工分总和不能超过工单总分 ${totalScore.toFixed(2)} 分(当前:${totalSelfScore.toFixed(2)} 分)`);
  738. return result;
  739. } */
  740. // 对于非零总分且非多选维保类型零分非零混合的情况,自评分总和必须小于等于总分+0.5
  741. if (totalScore > 0 && !isMultipleInspectionWithMixedScores) {
  742. // 计算理论总分(总分+0.5,因为工作负责人会额外加0.5分)
  743. const expectedTotal = totalScore + 0.5;
  744. // 总得分必须等于总分+0.5(使用容差比较)
  745. /* if (Math.abs(totalSelfScore - expectedTotal) > 0.01) {
  746. const result = new UTSJSONObject();
  747. result.set('valid', false);
  748. result.set('message', `总得分必须等于 ${expectedTotal.toFixed(2)} 分(当前:${totalSelfScore.toFixed(2)} 分)`);
  749. return result;
  750. } */
  751. if (totalSelfScore - expectedTotal > 0.01) {
  752. const result = new UTSJSONObject();
  753. result.set('valid', false);
  754. result.set('message', `总得分必须小于等于 ${expectedTotal.toFixed(2)} 分(当前:${totalSelfScore.toFixed(2)} 分)`);
  755. return result;
  756. }
  757. }
  758. // 如果是维保工单且多选维保类型且存在零分和非零分混合的情况,需要特殊处理
  759. if (isMultipleInspectionWithMixedScores) {
  760. // 在这种情况下,总分可能有最小值要求
  761. const completionFactor = selfEvaluationForm.value.itemCompletionFactor != null ? selfEvaluationForm.value.itemCompletionFactor : 1
  762. // 重新计算非零分项的总分
  763. let minScoreFromDB = 0;
  764. const selectedInspectionTypes: string[] = selfEvaluationForm.value.inspectionType != null ? selfEvaluationForm.value.inspectionType : []
  765. for (let i = 0; i < selectedInspectionTypes.length; i++) {
  766. const typeId = selectedInspectionTypes[i]
  767. for (let j = 0; j < inspectionTypeOptions.value.length; j++) {
  768. const selectedType = inspectionTypeOptions.value[j]
  769. // 使用inspectionTypeId进行匹配
  770. if (selectedType.get('inspectionTypeId').toString() == typeId) {
  771. const score = selectedType.get('score');
  772. if (score != null && typeof score == 'number' && score > 0) { // 只累加非零分
  773. minScoreFromDB += score;
  774. }
  775. }
  776. }
  777. }
  778. // 计算最低理论总分(非零项的总分 * 分项完成系数 + 0.5)
  779. const minExpectedTotal = (minScoreFromDB * completionFactor) + 0.5
  780. /* // 总得分不得低于最低理论总分
  781. if (totalSelfScore < minExpectedTotal - 0.01) { // 使用0.01作为容差
  782. const result = new UTSJSONObject();
  783. result.set('valid', false);
  784. result.set('message', `总得分不得低于 ${minExpectedTotal.toFixed(2)} 分(当前:${totalSelfScore.toFixed(2)} 分)`);
  785. return result;
  786. } */
  787. }
  788. const result = new UTSJSONObject();
  789. result.set('valid', true);
  790. result.set('message', '');
  791. return result;
  792. }
  793. // 验证整个表单
  794. function validateForm(): any {
  795. console.log('开始验证表单,工单类型:', selfEvaluationForm.value.orderType);
  796. console.log('当前检修类型值:', selfEvaluationForm.value.maintenanceType);
  797. // 首先验证必填字段,按优先级排序
  798. // 验证工单类型为1(维修工单)时的检修类型
  799. if (selfEvaluationForm.value.orderType == '1') {
  800. console.log('验证维修工单的检修类型');
  801. console.log('当前maintenanceType值:', selfEvaluationForm.value.maintenanceType, '类型:', typeof selfEvaluationForm.value.maintenanceType);
  802. let validationMessage: string | null = null;
  803. try {
  804. validationMessage = validateField('maintenanceType', selfEvaluationForm.value.maintenanceType as any);
  805. } catch (error: any) {
  806. console.error('检修类型验证过程中出现异常:', error);
  807. validationMessage = '请选择检修类型';
  808. }
  809. console.log('检修类型验证结果:', validationMessage);
  810. if (validationMessage != null) {
  811. console.log('检修类型验证失败:', validationMessage);
  812. const result = new UTSJSONObject();
  813. result.set('valid', false);
  814. result.set('message', validationMessage);
  815. return result;
  816. }
  817. }
  818. // 验证总结内容
  819. let summaryValidation: string | null = null;
  820. try {
  821. summaryValidation = validateField('workSummary', selfEvaluationForm.value.workSummary as any);
  822. } catch (error: any) {
  823. console.error('工作总结验证过程中出现异常:', error);
  824. summaryValidation = '工作总结验证失败';
  825. }
  826. if (summaryValidation != null) {
  827. const result = new UTSJSONObject();
  828. result.set('valid', false);
  829. result.set('message', summaryValidation);
  830. return result;
  831. }
  832. // 验证工单类型为2(维保工单)时的分项完成系数
  833. if (selfEvaluationForm.value.orderType == '2') {
  834. // 检查分项完成系数是否为空字符串(即用户清空了输入框)
  835. if (itemCompletionFactorStr.value == '') {
  836. const result = new UTSJSONObject();
  837. result.set('valid', false);
  838. result.set('message', '分项完成系数不能为空');
  839. return result;
  840. }
  841. let validationMessage: string | null = null;
  842. try {
  843. validationMessage = validateField('itemCompletionFactor', selfEvaluationForm.value.itemCompletionFactor as any);
  844. } catch (error: any) {
  845. validationMessage = '分项完成系数验证失败';
  846. }
  847. if (validationMessage != null) {
  848. const result = new UTSJSONObject();
  849. result.set('valid', false);
  850. result.set('message', validationMessage);
  851. return result;
  852. }
  853. // 验证分项完成系数和
  854. // 检查分项完成系数和是否为空字符串(即用户清空了输入框)
  855. if (itemCompletionFactorSumStr.value == '') {
  856. const result = new UTSJSONObject();
  857. result.set('valid', false);
  858. result.set('message', '分项完成系数和不能为空');
  859. return result;
  860. }
  861. validationMessage = null;
  862. try {
  863. validationMessage = validateField('itemCompletionFactorSum', selfEvaluationForm.value.itemCompletionFactorSum as any);
  864. } catch (error: any) {
  865. validationMessage = '分项完成系数和验证失败';
  866. }
  867. if (validationMessage != null) {
  868. const result = new UTSJSONObject();
  869. result.set('valid', false);
  870. result.set('message', validationMessage);
  871. return result;
  872. }
  873. }
  874. // 验证维保类型(仅适用于维保工单)
  875. if (selfEvaluationForm.value.orderType == '2') {
  876. let validationMessage: string | null = null;
  877. try {
  878. validationMessage = validateField('inspectionType', selfEvaluationForm.value.inspectionType as any);
  879. } catch (error: any) {
  880. console.error('维保类型验证过程中出现异常:', error);
  881. validationMessage = '维保类型验证失败';
  882. }
  883. if (validationMessage != null) {
  884. const result = new UTSJSONObject();
  885. result.set('valid', false);
  886. result.set('message', validationMessage);
  887. return result;
  888. }
  889. }
  890. // 验证评分规则
  891. let scoringValidation: UTSJSONObject;
  892. try {
  893. scoringValidation = validateScoringRules() as UTSJSONObject;
  894. } catch (error: any) {
  895. console.error('评分规则验证过程中出现异常:', error);
  896. const result = new UTSJSONObject();
  897. result.set('valid', false);
  898. result.set('message', '评分规则验证失败');
  899. return result;
  900. }
  901. if (!(scoringValidation.get('valid') as boolean)) {
  902. const result = new UTSJSONObject();
  903. result.set('valid', false);
  904. result.set('message', scoringValidation.get('message') as string);
  905. return result;
  906. }
  907. const result = new UTSJSONObject();
  908. result.set('valid', true);
  909. result.set('message', '');
  910. return result;
  911. }
  912. // 加载检修类型选项
  913. async function loadMaintenanceTypes() {
  914. try {
  915. /* uni.showLoading({
  916. title: '加载中...'
  917. }) */
  918. const response: any = await getMaintenanceTypes()
  919. const resultObj = response as UTSJSONObject
  920. const code = resultObj.get('code') as number
  921. if (code == 200) {
  922. const data = resultObj.get('rows') as UTSJSONObject[]
  923. if (data != null && Array.isArray(data)) {
  924. // 将后端返回的数据转换为页面需要的格式
  925. const options: MaintenanceTypeOption[] = []
  926. for (let i = 0; i < data.length; i++) {
  927. const item = data[i]
  928. const option: MaintenanceTypeOption = {
  929. value: (item.get('maintenanceType') as string | null) ?? '',
  930. label: `${(item.get('projectName') as string | null) ?? ''}(${(item.get('scorePerCompletion') as number | null) ?? 0}分)`
  931. }
  932. options.push(option)
  933. }
  934. maintenanceTypeOptions.value = options
  935. // 设置选中项索引
  936. const mt = selfEvaluationForm.value.maintenanceType
  937. if (mt != null && mt != '') {
  938. const index = maintenanceTypeOptions.value.findIndex(item => item.value == mt)
  939. if (index >= 0) {
  940. selectedMaintenanceTypeIndex.value = index
  941. }
  942. } else {
  943. // 如果maintenanceType为空,重置选中索引
  944. selectedMaintenanceTypeIndex.value = -1
  945. selfEvaluationForm.value.maintenanceType = null
  946. }
  947. }
  948. } else {
  949. const msg = resultObj.get('msg') as string | null
  950. console.error('加载检修类型失败:', msg ?? '未知错误')
  951. }
  952. } catch (error: any) {
  953. console.error('加载检修类型失败:', error)
  954. } finally {
  955. //uni.hideLoading()
  956. }
  957. }
  958. // 加载维保类型选项
  959. async function loadInspectionTypeOptions() {
  960. try {
  961. // 加载维保类型选项
  962. if (orderType.value == '2') {
  963. // 根据风机型号获取维保类型选项
  964. const fanType = selfEvaluationForm.value.model; // 使用风机型号
  965. if (fanType != null && fanType != '') {
  966. const response: any = await listInspectionTypesByFanType(fanType as string);
  967. const resultObj = response as UTSJSONObject;
  968. const code = resultObj.get('code') as number;
  969. if (code == 200) {
  970. const data = resultObj.get('data') as UTSJSONObject[];
  971. if (data != null && Array.isArray(data)) {
  972. inspectionTypeOptions.value = data;
  973. }
  974. } else {
  975. console.error('API返回错误码:', code);
  976. console.error('错误信息:', resultObj.get('msg'));
  977. }
  978. } else {
  979. console.warn('风机型号为空,无法加载维保类型选项');
  980. }
  981. }
  982. } catch (e: any) {
  983. console.error('获取维保类型选项失败:', e.message);
  984. //console.error('错误堆栈:', e.stack);
  985. }
  986. }
  987. // 加载工单详情
  988. async function loadOrderDetail() {
  989. try {
  990. uni.showLoading({
  991. title: '加载中...'
  992. })
  993. const response: any = await getOrderScoreDetail(orderType.value, id.value)
  994. const resultObj = response as UTSJSONObject
  995. const code = resultObj.get('code') as number
  996. if (code == 200) {
  997. const data = resultObj.get('data') as UTSJSONObject
  998. // 设置表单数据
  999. const formData: SelfEvaluationFormData = {
  1000. orderType: orderType.value,
  1001. id: (data.get('id') as number | null) ?? 0,
  1002. workOrderProjectNo: (data.get('workOrderProjectNo') as string | null) ?? '',
  1003. pcsDeviceName: (data.get('pcsDeviceName') as string | null) ?? '',
  1004. pcsStationName: (data.get('pcsStationName') as string | null) ?? '',
  1005. workSummary: orderType.value == '1' ? ((data.get('content') as string | null) ?? '') : ((data.get('realContent') as string | null) ?? ''),
  1006. extraWork: orderType.value == '1' ? ((data.get('extraWork') as string | null) ?? '') : '',
  1007. maintenanceType: (data.get('maintenanceType') as string | null) ?? '',
  1008. model: (data.get('model') as string | null), // 风机型号
  1009. inspectionType: orderType.value == '2' ?
  1010. (Array.isArray(data.get('inspectionType')) ?
  1011. data.get('inspectionType') as string[] :
  1012. (((data.get('inspectionType') as string | null)?.split(',') ?? []) as string[])) : [],
  1013. itemCompletionFactor: (data.get('itemCompletionFactor') as number | null),
  1014. itemCompletionFactorSum: (data.get('itemCompletionFactorSum') as number | null),
  1015. scorePersonList: orderType.value == '1' ?
  1016. ((data.get('repairOrderPersonList') as UTSJSONObject[] | null) ?? []) :
  1017. ((data.get('workOrderPersonList') as UTSJSONObject[] | null) ?? []),
  1018. wwryNum: (data.get('wwryNum') as number | null) ?? 0,
  1019. wlryNum: (data.get('wlryNum') as number | null) ?? 0
  1020. }
  1021. selfEvaluationForm.value = formData
  1022. // 为人员列表设置初始分数
  1023. /* const list = (formData.scorePersonList as UTSJSONObject[])
  1024. for (let i = 0; i < list.length; i++) {
  1025. const person = list[i]
  1026. if (person.get('selfScore') == null) {
  1027. person.set('selfScore', '')
  1028. }
  1029. if (person.get('extraScore') == null) {
  1030. person.set('extraScore', '')
  1031. }
  1032. if (person.get('totalScore') == null) {
  1033. person.set('totalScore', '')
  1034. }
  1035. } */
  1036. // 初始化字符串中转值,处理可能为null的情况
  1037. itemCompletionFactorStr.value = formData.itemCompletionFactor != null ? formData.itemCompletionFactor.toFixed(2) : ''
  1038. itemCompletionFactorSumStr.value = formData.itemCompletionFactorSum != null ? formData.itemCompletionFactorSum.toFixed(2) : ''
  1039. // 加载检修类型选项
  1040. if (orderType.value == '1') {
  1041. await loadMaintenanceTypes()
  1042. }
  1043. // 加载维保类型选项
  1044. if (orderType.value == '2') {
  1045. await loadInspectionTypeOptions()
  1046. }
  1047. // 计算初始分数
  1048. calculateScores()
  1049. // 设置额外工作总结状态标志
  1050. hasExtraWorkFlag.value = formData.extraWork != null && formData.extraWork.trim() != '';
  1051. // 初始化已自评总分
  1052. updateSelfEvaluatedTotalScore()
  1053. } else {
  1054. const msg = resultObj.get('msg') as string | null
  1055. uni.showToast({
  1056. title: msg ?? '加载失败',
  1057. icon: 'none'
  1058. })
  1059. }
  1060. } catch (error: any) {
  1061. console.error('加载工单详情失败:', error)
  1062. uni.showToast({
  1063. title: '加载失败',
  1064. icon: 'none'
  1065. })
  1066. } finally {
  1067. uni.hideLoading()
  1068. }
  1069. }
  1070. // 加载字典数据
  1071. async function loadDictData() {
  1072. try {
  1073. // 加载维保类型字典
  1074. if (orderType.value == '2') {
  1075. const result = await getDictDataByType('gxt_inspection_type')
  1076. const resultObj = result as UTSJSONObject
  1077. if (resultObj.get('code') == 200) {
  1078. const data = resultObj.get('data') as any[]
  1079. const dictData: SysDictData[] = []
  1080. if (data != null && data.length > 0) {
  1081. for (let i = 0; i < data.length; i++) {
  1082. const item = data[i] as UTSJSONObject
  1083. // 只提取需要的字段
  1084. const dictItem: SysDictData = {
  1085. dictValue: item.get('dictValue') as string | null,
  1086. dictLabel: item.get('dictLabel') as string | null,
  1087. dictCode: null,
  1088. dictSort: null,
  1089. dictType: null,
  1090. cssClass: null,
  1091. listClass: null,
  1092. isDefault: null,
  1093. status: null,
  1094. default: null,
  1095. createTime: null,
  1096. remark: null
  1097. }
  1098. dictData.push(dictItem)
  1099. }
  1100. }
  1101. inspectionTypeDictList.value = dictData
  1102. }
  1103. }
  1104. } catch (e: any) {
  1105. console.error('获取维保类型字典失败:', e.message)
  1106. }
  1107. }
  1108. // 检修类型选择变化
  1109. function selectMaintenanceType(index: number) {
  1110. selectedMaintenanceTypeIndex.value = index
  1111. if (index >= 0 && index < maintenanceTypeOptions.value.length) {
  1112. selfEvaluationForm.value.maintenanceType = maintenanceTypeOptions.value[index].value
  1113. }
  1114. showMaintenanceTypePicker.value = false
  1115. // 选择后立即触发验证
  1116. const validationMessage = validateField('maintenanceType', selfEvaluationForm.value.maintenanceType as any);
  1117. if (validationMessage != null) {
  1118. uni.showToast({
  1119. title: validationMessage,
  1120. icon: 'none'
  1121. });
  1122. }
  1123. }
  1124. // 根据值获取检修类型标签
  1125. function getMaintenanceTypeLabel(value: string | null): string {
  1126. if (value == null || value == '') return ''
  1127. const item = maintenanceTypeOptions.value.find(item => item.value == value)
  1128. return item != null ? item.label : value
  1129. }
  1130. // 工作总结输入处理
  1131. function onWorkSummaryInput(e: UniInputEvent) {
  1132. const value = e.detail?.value as string
  1133. selfEvaluationForm.value.workSummary = value
  1134. }
  1135. // 格式化分项完成系数输入值
  1136. function formatItemCompletionFactor() {
  1137. const tempValue = tempItemCompletionFactorInput.value;
  1138. let finalValue: number | null = null; // 明确定义类型
  1139. if (tempValue.endsWith('.')) {
  1140. // 如果以点结尾,去除点号
  1141. const processedValue = tempValue.slice(0, -1);
  1142. if (processedValue != '') {
  1143. const numValue = parseFloat(processedValue);
  1144. if (!isNaN(numValue) && isFinite(numValue)) {
  1145. if (numValue >= 0 && numValue <= 1) {
  1146. finalValue = numValue;
  1147. } else {
  1148. finalValue = numValue > 1 ? 1 : 0; // 根据数值大小决定边界值
  1149. }
  1150. } else {
  1151. finalValue = 1; // 默认值
  1152. }
  1153. } else {
  1154. // 去掉点后为空,设为null
  1155. finalValue = null;
  1156. }
  1157. } else {
  1158. // 正常数值处理
  1159. const currentValue = selfEvaluationForm.value.itemCompletionFactor;
  1160. if (currentValue != null && typeof currentValue == 'number') {
  1161. // 格式化小数位数
  1162. const currentStr = currentValue.toString();
  1163. const parts = currentStr.split('.');
  1164. if (parts.length > 1 && parts[1] != null && parts[1].length > 2) {
  1165. // 创建一个局部变量确保类型安全
  1166. const valueToFormat: number = currentValue;
  1167. finalValue = parseFloat(valueToFormat.toFixed(2));
  1168. } else {
  1169. finalValue = currentValue;
  1170. }
  1171. }
  1172. }
  1173. // 更新数值
  1174. selfEvaluationForm.value.itemCompletionFactor = finalValue;
  1175. // 同步更新临时输入值为格式化后的字符串显示
  1176. if (finalValue != null) {
  1177. tempItemCompletionFactorInput.value = finalValue.toString();
  1178. } else {
  1179. tempItemCompletionFactorInput.value = '';
  1180. }
  1181. }
  1182. function onItemCompletionFactorInput(e: UniInputEvent) {
  1183. const value = e.detail?.value as string;
  1184. // 更新临时输入值
  1185. tempItemCompletionFactorInput.value = value;
  1186. // 检查输入值是否为空
  1187. if (value == '') {
  1188. selfEvaluationForm.value.itemCompletionFactor = null;
  1189. } else {
  1190. // 检查是否为中间输入状态(如 '0.' 等以点结尾的数字)
  1191. if (value.endsWith('.')) {
  1192. // 如果是中间输入状态,不更新数值,保持原有值
  1193. return;
  1194. }
  1195. // 验证输入值是否为有效数字
  1196. const numValue = parseFloat(value);
  1197. if (!isNaN(numValue) && isFinite(numValue)) {
  1198. if( numValue >= 0 && numValue <= 1){
  1199. // 在input事件中直接使用解析后的数值
  1200. selfEvaluationForm.value.itemCompletionFactor = numValue;
  1201. } else {
  1202. // 当超出范围时,设置实际值为边界值
  1203. selfEvaluationForm.value.itemCompletionFactor = numValue > 1 ? 1 : 0;
  1204. }
  1205. // 更新可自评总分显示
  1206. //updateSelfEvaluatedTotalScore();
  1207. }
  1208. }
  1209. calculateScores();
  1210. }
  1211. // 获取分项完成系数显示值
  1212. function getItemCompletionFactorDisplayValue(): string {
  1213. // 优先返回临时输入值,确保输入过程中的显示与用户操作一致
  1214. if (tempItemCompletionFactorInput.value != null && tempItemCompletionFactorInput.value != '') {
  1215. return tempItemCompletionFactorInput.value;
  1216. }
  1217. // 否则返回格式化后的数值
  1218. const value = selfEvaluationForm.value.itemCompletionFactor;
  1219. if (value == null) {
  1220. return '';
  1221. }
  1222. if (typeof value == 'number') {
  1223. return value.toString();
  1224. }
  1225. return value as string;
  1226. }
  1227. // 格式化分项完成系数和输入值
  1228. function formatItemCompletionFactorSum() {
  1229. const tempValue = tempItemCompletionFactorSumInput.value;
  1230. let finalValue: number | null = null; // 明确定义类型
  1231. if (tempValue.endsWith('.')) {
  1232. // 如果以点结尾,去除点号
  1233. const processedValue = tempValue.slice(0, -1);
  1234. if (processedValue != '') {
  1235. const numValue = parseFloat(processedValue);
  1236. if (!isNaN(numValue) && isFinite(numValue)) {
  1237. if (numValue >= 0 && numValue <= 1) {
  1238. finalValue = numValue;
  1239. } else {
  1240. finalValue = numValue > 1 ? 1 : 0; // 根据数值大小决定边界值
  1241. }
  1242. } else {
  1243. finalValue = 1; // 默认值
  1244. }
  1245. } else {
  1246. // 去掉点后为空,设为null
  1247. finalValue = null;
  1248. }
  1249. } else {
  1250. // 正常数值处理
  1251. const currentValue = selfEvaluationForm.value.itemCompletionFactorSum;
  1252. if (currentValue != null && typeof currentValue == 'number') {
  1253. // 格式化小数位数
  1254. const currentStr = currentValue.toString();
  1255. const parts = currentStr.split('.');
  1256. if (parts.length > 1 && parts[1] != null && parts[1].length > 2) {
  1257. // 创建一个局部变量确保类型安全
  1258. const valueToFormat: number = currentValue;
  1259. finalValue = parseFloat(valueToFormat.toFixed(2));
  1260. } else {
  1261. finalValue = currentValue;
  1262. }
  1263. }
  1264. }
  1265. // 更新数值
  1266. selfEvaluationForm.value.itemCompletionFactorSum = finalValue;
  1267. // 同步更新临时输入值为格式化后的字符串显示
  1268. if (finalValue != null) {
  1269. tempItemCompletionFactorSumInput.value = finalValue.toString();
  1270. } else {
  1271. tempItemCompletionFactorSumInput.value = '';
  1272. }
  1273. }
  1274. function onItemCompletionFactorSumInput(e: UniInputEvent) {
  1275. const value = e.detail?.value as string;
  1276. // 更新临时输入值
  1277. tempItemCompletionFactorSumInput.value = value;
  1278. // 检查输入值是否为空
  1279. if (value == '') {
  1280. selfEvaluationForm.value.itemCompletionFactorSum = null;
  1281. } else {
  1282. // 检查是否为中间输入状态(如 '0.' 等以点结尾的数字)
  1283. if (value.endsWith('.')) {
  1284. // 如果是中间输入状态,不更新数值,保持原有值
  1285. return;
  1286. }
  1287. // 验证输入值是否为有效数字
  1288. const numValue = parseFloat(value);
  1289. if (!isNaN(numValue) && isFinite(numValue)) {
  1290. if( numValue >= 0 && numValue <= 1){
  1291. // 在input事件中直接使用解析后的数值
  1292. selfEvaluationForm.value.itemCompletionFactorSum = numValue;
  1293. } else {
  1294. // 当超出范围时,设置实际值为边界值
  1295. selfEvaluationForm.value.itemCompletionFactorSum = numValue > 1 ? 1 : 0;
  1296. }
  1297. }
  1298. }
  1299. }
  1300. // 获取分项完成系数和显示值
  1301. function getItemCompletionFactorSumDisplayValue(): string {
  1302. // 优先返回临时输入值,确保输入过程中的显示与用户操作一致
  1303. if (tempItemCompletionFactorSumInput.value != null && tempItemCompletionFactorSumInput.value != '') {
  1304. return tempItemCompletionFactorSumInput.value;
  1305. }
  1306. // 否则返回格式化后的数值
  1307. const value = selfEvaluationForm.value.itemCompletionFactorSum;
  1308. if (value == null) {
  1309. return '';
  1310. }
  1311. if (typeof value == 'number') {
  1312. return value.toString();
  1313. }
  1314. return value as string;
  1315. }
  1316. // 额外工作总结变化
  1317. function onExtraWorkChange() {
  1318. // 更新额外工作总结状态标志
  1319. // 使用更严格的检查,包括检查长度
  1320. let extraWorkStr = '';
  1321. if (selfEvaluationForm.value.extraWork != null) {
  1322. extraWorkStr = selfEvaluationForm.value.extraWork;
  1323. }
  1324. const trimmedStr = extraWorkStr.trim();
  1325. const newHasExtraWork = trimmedStr.length > 0;
  1326. hasExtraWorkFlag.value = newHasExtraWork;
  1327. // 如果额外工作总结为空,则清空额外工分和总分字段
  1328. if (trimmedStr.length == 0) {
  1329. // 清空所有人员的额外工分和总分
  1330. const scorePersonList = selfEvaluationForm.value.scorePersonList as UTSJSONObject[]
  1331. for (let i = 0; i < scorePersonList.length; i++) {
  1332. const person = scorePersonList[i]
  1333. person.set('extraScore', 0)
  1334. // 重新计算总分(此时额外工分为空,所以总分等于自评分)
  1335. const selfScoreVal = person.get('selfScore');
  1336. if (selfScoreVal != null) {
  1337. const selfScore = typeof selfScoreVal == 'number' ? selfScoreVal : (selfScoreVal != '' ? parseFloat(selfScoreVal as string) : 0);
  1338. if (!isNaN(selfScore)) {
  1339. person.set('totalScore', selfScore);
  1340. } else {
  1341. person.set('totalScore', 0);
  1342. }
  1343. } else {
  1344. person.set('totalScore', 0);
  1345. }
  1346. }
  1347. }
  1348. // 更新已自评总分显示
  1349. updateSelfEvaluatedTotalScore()
  1350. // 当额外工作总结变化时,可能需要重新计算总分
  1351. updateTotalScores()
  1352. }
  1353. // 额外工作总结输入处理
  1354. function onExtraWorkInput(e: UniInputEvent) {
  1355. const value = e.detail?.value;
  1356. // 确保当值为null时设置为空字符串
  1357. if (value == null) {
  1358. selfEvaluationForm.value.extraWork = '';
  1359. } else {
  1360. selfEvaluationForm.value.extraWork = value.toString();
  1361. }
  1362. // 每次输入都触发变化处理
  1363. onExtraWorkChange()
  1364. }
  1365. // 获取人员评分
  1366. function getPersonScore(person: UTSJSONObject, field: string): string {
  1367. const value = person.get(field as string)
  1368. if (value == null || value == '' || (typeof value == 'number' && isNaN(value))) {
  1369. return ''
  1370. }
  1371. // 统一处理为字符串返回给UI
  1372. if (typeof value == 'number') {
  1373. const stringValue = value.toString();
  1374. return stringValue;
  1375. //return value.toFixed(2);
  1376. }
  1377. return value as string
  1378. }
  1379. // 设置人员评分
  1380. function setPersonScore(person: UTSJSONObject, field: string, value: string) {
  1381. person.set(field as string, value)
  1382. }
  1383. // 通用评分输入处理
  1384. function onScoreInput(e: UniInputEvent, index: number, field: string) {
  1385. const value = e.detail?.value as string
  1386. if (index >= 0 && index < selfEvaluationForm.value.scorePersonList.length) {
  1387. const person = selfEvaluationForm.value.scorePersonList[index] as UTSJSONObject
  1388. if (person != null) {
  1389. // 将输入的字符串转换为数字存储
  1390. const numericValue = value == '' ? null : parseFloat(value);
  1391. person.set(field, (numericValue != null && isNaN(numericValue)) ? null : numericValue);
  1392. // 实时验证评分
  1393. if (value != '') {
  1394. const validationError = validatePersonScore(value, field)
  1395. if (validationError != null) { // 修复条件判断
  1396. // 显示验证错误(在实际应用中,这里可以显示在界面上)
  1397. console.warn(`评分验证错误: ${validationError}`)
  1398. // 可以考虑用uni.showToast显示错误信息
  1399. /* uni.showToast({
  1400. title: validationError,
  1401. icon: 'none',
  1402. duration: 2000
  1403. }) */
  1404. }
  1405. }
  1406. updateTotalScores()
  1407. updateSelfEvaluatedTotalScore()
  1408. }
  1409. }
  1410. }
  1411. // 格式化评分输入值
  1412. function formatScoreInput(index: number, field: string) {
  1413. if (index >= 0 && index < selfEvaluationForm.value.scorePersonList.length) {
  1414. const person = selfEvaluationForm.value.scorePersonList[index] as UTSJSONObject
  1415. if (person != null) {
  1416. const value = person.get(field as string);
  1417. if (typeof value == 'number') {
  1418. // 检查数值的小数位数是否超过2位
  1419. const parts = value.toString().split('.');
  1420. if (parts.length > 1) { // 确保有小数部分
  1421. const decimalPart = parts[1];
  1422. if (decimalPart != null && decimalPart.length > 2) {
  1423. // 如果小数位数超过2位,使用格式化后的值
  1424. const formattedValue = parseFloat((value as number).toFixed(2));
  1425. person.set(field as string, formattedValue);
  1426. }
  1427. }
  1428. }
  1429. }
  1430. }
  1431. }
  1432. // 分数变化
  1433. function onScoreChange() {
  1434. updateTotalScores()
  1435. updateSelfEvaluatedTotalScore() // 更新已自评总分显示
  1436. }
  1437. // 返回按钮事件
  1438. function goBack() {
  1439. uni.navigateBack()
  1440. }
  1441. // 提交自评
  1442. async function submitSelfEvaluationForm(): Promise<void> {
  1443. try {
  1444. console.log('开始提交验证');
  1445. // 使用完整的表单验证
  1446. const validation = validateForm() as UTSJSONObject;
  1447. const isValid = validation.get('valid') as boolean;
  1448. const validationMsg = validation.get('message') as string;
  1449. console.log('验证结果:', isValid, '消息:', validationMsg);
  1450. console.log('验证结果类型:', typeof isValid, '是否为false:', isValid == false);
  1451. if (!isValid) {
  1452. console.log('验证失败,显示错误:', validationMsg);
  1453. // 在iOS平台中,有时需要稍作延迟才能正确显示toast
  1454. setTimeout(() => {
  1455. uni.showToast({
  1456. title: validationMsg,
  1457. icon: 'none'
  1458. });
  1459. }, 50);
  1460. return;
  1461. }
  1462. uni.showLoading({
  1463. title: '提交中...'
  1464. })
  1465. // 创建新的UTSJSONObject来存储表单数据
  1466. const formValue = new UTSJSONObject();
  1467. // 复制基本字段
  1468. formValue.set('id', selfEvaluationForm.value.id);
  1469. formValue.set('orderType', selfEvaluationForm.value.orderType);
  1470. formValue.set('workOrderProjectNo', selfEvaluationForm.value.workOrderProjectNo);
  1471. formValue.set('pcsDeviceName', selfEvaluationForm.value.pcsDeviceName);
  1472. formValue.set('pcsStationName', selfEvaluationForm.value.pcsStationName);
  1473. formValue.set('workSummary', selfEvaluationForm.value.workSummary);
  1474. formValue.set('extraWork', selfEvaluationForm.value.extraWork);
  1475. formValue.set('maintenanceType', selfEvaluationForm.value.maintenanceType);
  1476. formValue.set('itemCompletionFactor', selfEvaluationForm.value.itemCompletionFactor);
  1477. formValue.set('itemCompletionFactorSum', selfEvaluationForm.value.itemCompletionFactorSum);
  1478. formValue.set('wwryNum', selfEvaluationForm.value.wwryNum);
  1479. formValue.set('wlryNum', selfEvaluationForm.value.wlryNum);
  1480. // 处理inspectionType字段:如果是数组则转换为字符串
  1481. if (Array.isArray(selfEvaluationForm.value.inspectionType)) {
  1482. const strValue = (selfEvaluationForm.value.inspectionType as string[]).join(',');
  1483. formValue.set('inspectionType', strValue);
  1484. } else {
  1485. formValue.set('inspectionType', selfEvaluationForm.value.inspectionType);
  1486. }
  1487. // 复制scorePersonList数组
  1488. const scorePersonListArray: UTSJSONObject[] = [];
  1489. for (let i = 0; i < selfEvaluationForm.value.scorePersonList.length; i++) {
  1490. const person = selfEvaluationForm.value.scorePersonList[i];
  1491. // 将UTSJSONObject添加到数组中
  1492. scorePersonListArray.push(person);
  1493. }
  1494. formValue.set('scorePersonList', scorePersonListArray);
  1495. const response: any = await submitSelfEvaluation(formValue);
  1496. const resultObj = response as UTSJSONObject
  1497. const code = resultObj.get('code' as string) as number
  1498. if (code == 200) {
  1499. uni.showToast({
  1500. title: '自评提交成功',
  1501. icon: 'success'
  1502. })
  1503. // 设置标记,通知上一个页面需要刷新数据
  1504. uni.setStorageSync('needRefresh', true)
  1505. // 延迟返回上一页
  1506. setTimeout(() => {
  1507. uni.navigateBack()
  1508. }, 1000)
  1509. } else {
  1510. const msg = resultObj.get('msg' as string) as string | null
  1511. uni.showToast({
  1512. title: msg ?? '提交失败',
  1513. icon: 'none'
  1514. })
  1515. }
  1516. } catch (error: any) {
  1517. console.error('提交自评失败:', error)
  1518. let msg: string | null = null
  1519. if (error instanceof Error) {
  1520. msg = error.message
  1521. } else if (error instanceof UTSJSONObject && error.get('message') != null) {
  1522. msg = error.get('message') as string
  1523. }
  1524. uni.showToast({
  1525. title: msg ?? '提交失败',
  1526. icon: 'none'
  1527. })
  1528. } finally {
  1529. uni.hideLoading()
  1530. }
  1531. }
  1532. // 页面初始化
  1533. onLoad((options: any) => {
  1534. const params = options as UTSJSONObject
  1535. id.value = (params.get('id') != null ? params.get('id') as string : '')
  1536. orderType.value = (params.get('orderType') != null ? params.get('orderType') as string : '')
  1537. console.log("id.value==",id.value)
  1538. console.log("orderType.value==",orderType.value)
  1539. // 加载字典数据
  1540. loadDictData()
  1541. // 加载工单详情
  1542. loadOrderDetail()
  1543. })
  1544. </script>
  1545. <style lang="scss">
  1546. .container {
  1547. flex: 1;
  1548. background-color: #e8f0f9;
  1549. //height: 100vh;
  1550. }
  1551. .header {
  1552. padding: 30rpx;
  1553. text-align: center;
  1554. }
  1555. .title {
  1556. font-size: 36rpx;
  1557. font-weight: bold;
  1558. color: #333;
  1559. }
  1560. .form {
  1561. padding: 0 30rpx 30rpx;
  1562. }
  1563. .info-card {
  1564. background-color: #ffffff;
  1565. border-radius: 16rpx;
  1566. padding: 30rpx;
  1567. margin-bottom: 20rpx;
  1568. }
  1569. .info-item {
  1570. flex-direction: row;
  1571. padding: 20rpx 0;
  1572. border-bottom: 1rpx solid #f0f0f0;
  1573. &:last-child {
  1574. border-bottom: none;
  1575. }
  1576. .info-label {
  1577. width: 240rpx;
  1578. font-size: 28rpx;
  1579. color: #666666;
  1580. white-space: nowrap;
  1581. }
  1582. .info-value {
  1583. flex: 1;
  1584. font-size: 28rpx;
  1585. color: #333333;
  1586. text-align: right;
  1587. }
  1588. .info-input {
  1589. flex: 1;
  1590. font-size: 28rpx;
  1591. color: #333333;
  1592. border: 1rpx solid #e0e0e0;
  1593. border-radius: 8rpx;
  1594. padding: 10rpx;
  1595. text-align: right;
  1596. }
  1597. }
  1598. .form-item {
  1599. margin-bottom: 30rpx;
  1600. display: flex;
  1601. flex-direction: column;
  1602. }
  1603. .label {
  1604. font-size: 28rpx;
  1605. color: #666;
  1606. margin-bottom: 10rpx;
  1607. font-weight: bold;
  1608. }
  1609. .value {
  1610. font-size: 28rpx;
  1611. color: #333;
  1612. }
  1613. .textarea {
  1614. width: 100%;
  1615. height: 200rpx;
  1616. border: 1rpx solid #e5e5e5;
  1617. border-radius: 8rpx;
  1618. padding: 20rpx;
  1619. font-size: 28rpx;
  1620. color: #333;
  1621. }
  1622. .picker {
  1623. width: 100%;
  1624. }
  1625. .picker-display {
  1626. flex-direction: row;
  1627. justify-content: space-between;
  1628. align-items: center;
  1629. padding: 10rpx;
  1630. border: 1rpx solid #e5e5e5;
  1631. border-radius: 8rpx;
  1632. }
  1633. .selected-value {
  1634. font-size: 28rpx;
  1635. color: #333;
  1636. }
  1637. .placeholder {
  1638. font-size: 28rpx;
  1639. color: #999;
  1640. }
  1641. .arrow {
  1642. font-size: 24rpx;
  1643. color: #999;
  1644. }
  1645. .selected-values {
  1646. display: flex;
  1647. flex-wrap: wrap;
  1648. //gap: 10rpx;
  1649. }
  1650. .selected-value-tag {
  1651. background-color: #f0f0f0;
  1652. padding: 8rpx 16rpx;
  1653. border-radius: 20rpx;
  1654. font-size: 24rpx;
  1655. color: #666;
  1656. }
  1657. .person-score-item {
  1658. margin-bottom: 30rpx;
  1659. padding: 20rpx;
  1660. background-color: #f8f9fa;
  1661. border-radius: 12rpx;
  1662. }
  1663. .person-info {
  1664. margin-bottom: 15rpx;
  1665. }
  1666. .person-name {
  1667. font-size: 28rpx;
  1668. font-weight: bold;
  1669. color: #333;
  1670. }
  1671. .score-inputs {
  1672. display: flex;
  1673. flex-direction: column;
  1674. //gap: 15rpx;
  1675. }
  1676. .score-item {
  1677. display: flex;
  1678. flex-direction: row;
  1679. align-items: center;
  1680. justify-content: space-between;
  1681. }
  1682. .score-label {
  1683. font-size: 26rpx;
  1684. color: #666;
  1685. width: 120rpx;
  1686. flex-shrink: 0;
  1687. }
  1688. .score-input {
  1689. flex: 1;
  1690. height: 60rpx;
  1691. border: 1rpx solid #e0e0e0;
  1692. border-radius: 8rpx;
  1693. padding: 0 15rpx;
  1694. font-size: 26rpx;
  1695. color: #333;
  1696. text-align: right;
  1697. }
  1698. .submit-btn {
  1699. margin-top: 40rpx;
  1700. height: 80rpx;
  1701. background-color: #165DFF;
  1702. border-radius: 10rpx;
  1703. display: flex;
  1704. align-items: center;
  1705. justify-content: center;
  1706. }
  1707. .submit-text {
  1708. font-size: 32rpx;
  1709. color: #fff;
  1710. font-weight: bold;
  1711. }
  1712. /* 自定义选择器样式 */
  1713. .picker-modal {
  1714. position: fixed;
  1715. top: 0;
  1716. left: 0;
  1717. right: 0;
  1718. bottom: 0;
  1719. z-index: 1000;
  1720. }
  1721. .modal-mask {
  1722. position: absolute;
  1723. top: 0;
  1724. left: 0;
  1725. right: 0;
  1726. bottom: 0;
  1727. background-color: rgba(0, 0, 0, 0.5);
  1728. }
  1729. .modal-content {
  1730. position: absolute;
  1731. bottom: 0;
  1732. left: 0;
  1733. right: 0;
  1734. background-color: #ffffff;
  1735. border-top-left-radius: 16rpx;
  1736. border-top-right-radius: 16rpx;
  1737. min-height: 700rpx;
  1738. }
  1739. .modal-header {
  1740. flex-direction: row;
  1741. justify-content: space-between;
  1742. align-items: center;
  1743. padding: 30rpx;
  1744. border-bottom: 1rpx solid #f0f0f0;
  1745. }
  1746. .modal-title {
  1747. font-size: 32rpx;
  1748. font-weight: bold;
  1749. color: #333333;
  1750. }
  1751. .modal-close {
  1752. font-size: 28rpx;
  1753. color: #165DFF;
  1754. }
  1755. .modal-body {
  1756. max-height: 600rpx;
  1757. }
  1758. .picker-option {
  1759. flex-direction: row;
  1760. justify-content: space-between;
  1761. align-items: center;
  1762. padding: 24rpx 30rpx;
  1763. border-bottom: 1rpx solid #f0f0f0;
  1764. }
  1765. .picker-option.selected {
  1766. background-color: #f8f9fa;
  1767. }
  1768. .option-text {
  1769. font-size: 28rpx;
  1770. color: #333333;
  1771. }
  1772. .option-check {
  1773. font-size: 28rpx;
  1774. color: #165DFF;
  1775. }
  1776. .form-picker {
  1777. flex: 1;
  1778. }
  1779. .picker-display {
  1780. flex-direction: row;
  1781. justify-content: space-between;
  1782. align-items: center;
  1783. min-height: 40rpx;
  1784. }
  1785. .selected-value {
  1786. font-size: 28rpx;
  1787. color: #333333;
  1788. }
  1789. .placeholder {
  1790. font-size: 28rpx;
  1791. color: #999999;
  1792. }
  1793. .arrow {
  1794. font-size: 24rpx;
  1795. color: #999999;
  1796. margin-left: 12rpx;
  1797. }
  1798. </style>