selfEvaluate.uvue 70 KB

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