ProcessList.uvue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. <template>
  2. <view class="record-card flex-row">
  3. <view class="tag-circle" v-for="(item, index) in initRecords" :key="index" @click="tabsClick(item.senum)"
  4. :class="{'checked-tag' : item.senum == current}">
  5. <text class="circle" :class="{
  6. 'bg-green': item.result == '合格',
  7. 'bg-red': item.result == '不合格',
  8. 'bg-black': item.result != '不合格' && item.result != '合格'
  9. }">{{item.senum}}</text>
  10. </view>
  11. </view>
  12. <!-- #ifdef APP -->
  13. <scroll-view style="flex:1">
  14. <!-- #endif -->
  15. <view v-if="initRecords.length" class="card-list">
  16. <!-- 注意:v-for 遍历 initRecords 时,item 是响应式的,但内部字段需通过计算属性转换 -->
  17. <view class="card" v-for="item in initRecords" :key="item.senum" v-show="current == item.senum">
  18. <!-- 序号:绑定计算属性 parsedMinNum(对应 item.minNum) -->
  19. <view class="info-row">
  20. <text class="label">序号</text>
  21. <view class="value">
  22. {{item.senum}}
  23. </view>
  24. </view>
  25. <view class="info-row">
  26. <text class="label">产品码</text>
  27. <view class="value">
  28. {{item.prodno}}
  29. </view>
  30. </view>
  31. <view class="info-row">
  32. <text class="label">检测项目</text>
  33. <view class="value">
  34. {{item.parametername}}
  35. </view>
  36. </view>
  37. <view class="info-row">
  38. <text class="label">分类</text>
  39. <view class="value">
  40. {{item.testapparatus}}
  41. </view>
  42. </view>
  43. <!-- 上限要求:绑定计算属性 parsedMinNum -->
  44. <view class="info-row">
  45. <text class="label">上限要求</text>
  46. <view class="value">
  47. {{item.testrequireupper}}
  48. </view>
  49. </view>
  50. <!-- 下限要求:绑定计算属性 parsedMaxNum(对应 item.maxNum) -->
  51. <view class="info-row">
  52. <text class="label">下限要求</text>
  53. <view class="value">
  54. {{item.testrequirelower}}
  55. </view>
  56. </view>
  57. <view class="divider"></view>
  58. <!-- 实测值小:绑定计算属性 parsedMeasuredValue(对应 item.measuredvalue) -->
  59. <view class="info-row">
  60. <text class="label">实测值小</text>
  61. <view class="value">
  62. <input class="surround uni-input number-input" v-model="item.measuredvaluemin" @confirm="minNumberChange"></input>
  63. </view>
  64. </view>
  65. <!-- 实测值大:绑定计算属性 parsedMeasuredMaxValue(对应 item.measuredvaluemax) -->
  66. <view class="info-row">
  67. <text class="label">实测值大</text>
  68. <view class="value">
  69. <input class="surround uni-input number-input" v-model="item.measuredvaluemax" @confirm="maxNumberChange"></input>
  70. </view>
  71. </view>
  72. <view class="info-row">
  73. <text class="label">结论</text>
  74. <view class="value">
  75. <radio-group class="radio-group-horizontal" @change="resultChange">
  76. <radio class="radio-group-horizontal-rg" value="合格" :checked="item.result == '合格'" >合格</radio>
  77. <radio class="radio-group-horizontal-rg" value="不合格" :checked="item.result == '不合格'" >不合格</radio>
  78. </radio-group>
  79. </view>
  80. </view>
  81. <view class="info-row">
  82. <text class="label">备注</text>
  83. <view class="value">
  84. <input v-model="item.memo" class="surround uni-input" @confirm="remarksChange"></input>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <!-- 空状态 -->
  90. <view v-else class="empty-card">
  91. <image src="/static/image/empty.png" class="empty-img" />
  92. <text class="empty-text">暂无检查检验记录</text>
  93. </view>
  94. <view class="info-row btn-panel">
  95. <button class="btn btn-first" @click="tabsClick(current-1)" v-if="current > 1">
  96. 前一项
  97. </button>
  98. <button class="btn btn-second" @click="tabsClick(current+1)" v-if="current < maxcount">
  99. 下一项
  100. </button>
  101. </view>
  102. <!-- #ifdef APP -->
  103. </scroll-view>
  104. <!-- #endif -->
  105. </template>
  106. <script setup>
  107. import { ref, computed } from 'vue' // 1. 引入 computed(计算属性核心)
  108. import { getListByOrder, TaskKeyProcess, recordStatusDict, updateData } from '@/api/work';
  109. import { getCurrentUserSync } from '@/utils/auth';
  110. // 存储页面参数
  111. let pdid = "";
  112. let senum = "";
  113. // 检查项目最大数量(改为 ref 响应式,避免值变化不更新)
  114. var maxcount = 5
  115. const current = ref(1)
  116. const initRecords = ref<TaskKeyProcess[]>([])
  117. var records = ref<TaskKeyProcess[]>([]);
  118. const closeTags = ref<boolean[]>([]);
  119. // 下拉框选项数组 - 定性分析选项
  120. const array = ref(['合格', '不合格']);
  121. //自定义返回行为,覆盖系统默认返回按钮
  122. const backPressOptions = reactive({
  123. from: 'backbutton'
  124. } as OnBackPressOptions)
  125. onBackPress((options : OnBackPressOptions) : boolean | null => {
  126. uni.navigateTo({
  127. url: `/pages/work/download/DownloadDetail?id=${pdid}`,
  128. // 修改动画方向为从左到右退回
  129. animationType: 'slide-in-left', // 使用从左到右滑出的动画效果
  130. animationDuration: 300 // 动画持续时间,单位ms
  131. })
  132. // 返回true表示拦截默认返回行为
  133. return true
  134. })
  135. const getParsedValue = computed(() => {
  136. return (value : string | number) => {
  137. if (typeof value === 'number') {
  138. return value;
  139. }
  140. if (typeof value === 'string') {
  141. const num = parseFloat(value);
  142. return isNaN(num) ? 0 : num;
  143. }
  144. return 0;
  145. }
  146. });
  147. // 4. 切换标签时更新 initRecords(使用响应式的 initRecords)
  148. const tabsClick = (obj : number) => {
  149. current.value = obj
  150. records.value = initRecords.value.filter(item => item['senum'] == current.value)
  151. }
  152. const refreshRecords = (index : number) => {
  153. // 清空现有数据(响应式数组需操作 .value)
  154. initRecords.value = [];
  155. closeTags.value = [];
  156. // #ifdef APP-ANDROID
  157. getListByOrder(
  158. 'app_task_keyprocess', 'pdid', pdid, ' order by sxid desc', null
  159. ).then((res : UTSJSONObject) => {
  160. const dataList = res?.['data'] as UTSJSONObject[] ?? []
  161. if (dataList.length > 0) {
  162. let index = 1
  163. dataList.forEach(item => {
  164. if (item != null) {
  165. item['senum'] = index
  166. const record = JSON.parse<TaskKeyProcess>(item.toJSONString());
  167. if (record != null) {
  168. initRecords.value.push(record)
  169. index++;
  170. }
  171. }
  172. });
  173. maxcount = index-1;
  174. }
  175. // 对initRecords按照no字段进行升序排序
  176. if (initRecords.value.length > 0) {
  177. if (index > 0) {
  178. current.value = index
  179. } else {
  180. current.value = initRecords.value[0].senum
  181. }
  182. records.value = initRecords.value.filter(item => item['senum'] == current.value)
  183. }
  184. });
  185. // #endif
  186. }
  187. const resultChange = (event : UniRadioGroupChangeEvent) => {
  188. // 获取当前选中的报告项
  189. const currentItem = initRecords.value.find(item => item.senum === current.value);
  190. if (currentItem != null) {
  191. // 更新结果值
  192. currentItem.result = event.detail.value;
  193. //更新数据库
  194. let updatedData = "result='" + currentItem.result + "', operator='" + getCurrentUserSync() + "' "
  195. updateData('app_task_keyprocess', updatedData, 'sxid', currentItem.sxid.toString()).then((res : UTSJSONObject) => {
  196. let data = res?.['data'] as boolean ?? false
  197. if (data != null && data== true) {
  198. uni.showToast({
  199. title: "保存成功!",
  200. });
  201. }
  202. });
  203. }
  204. }
  205. const minNumberChange = (event : UniInputConfirmEvent) => {
  206. // 获取当前选中的报告项
  207. const currentItem = initRecords.value.find(item => item.senum === current.value);
  208. if (currentItem != null) {
  209. // 更新结果值
  210. currentItem.measuredvaluemin = event.detail.value;
  211. // 检查measuredvalue是否为null或undefined,避免空指针异常
  212. const measuredValue = currentItem.measuredvaluemin ?? '';
  213. let updatedData = "measuredvaluemin='" + measuredValue + "', operator='" + getCurrentUserSync() + "' "
  214. //更新数据库
  215. updateData('app_task_keyprocess', updatedData, 'sxid', currentItem.sxid.toString()).then((res : UTSJSONObject) => {
  216. let data = res?.['data'] as boolean ?? false
  217. if (data != null && data== true) {
  218. uni.showToast({
  219. title: "保存成功!",
  220. });
  221. }
  222. });
  223. }
  224. }
  225. const maxNumberChange = (event : UniInputConfirmEvent) => {
  226. // 获取当前选中的报告项
  227. const currentItem = initRecords.value.find(item => item.senum === current.value);
  228. if (currentItem != null) {
  229. // 更新结果值
  230. currentItem.measuredvaluemax = event.detail.value;
  231. //更新数据库
  232. let updatedData = "measuredvaluemax='" + currentItem.measuredvaluemax + "', operator='" + getCurrentUserSync() + "' "
  233. updateData('app_task_keyprocess', updatedData, 'sxid', currentItem.sxid.toString()).then((res : UTSJSONObject) => {
  234. let data = res?.['data'] as boolean ?? false
  235. if (data != null && data== true) {
  236. uni.showToast({
  237. title: "保存成功!",
  238. });
  239. }
  240. });
  241. }
  242. }
  243. const remarksChange = (event : UniInputConfirmEvent) => {
  244. // 获取当前选中的报告项
  245. const currentItem = initRecords.value.find(item => item.senum === current.value);
  246. if (currentItem != null) {
  247. // 更新结果值
  248. currentItem.memo = event.detail.value;
  249. //更新数据库
  250. let updatedData = "memo='" + currentItem.memo + "', operator='" + getCurrentUserSync() + "' "
  251. updateData('app_task_keyprocess', updatedData, 'sxid', currentItem.sxid.toString()).then((res : UTSJSONObject) => {
  252. let data = res?.['data'] as boolean ?? false
  253. if (data != null && data== true) {
  254. uni.showToast({
  255. title: "保存成功!",
  256. });
  257. }
  258. });
  259. }
  260. }
  261. onLoad((options) => {
  262. pdid = options?.pdid ?? "1"
  263. senum = options?.senum ?? "1"
  264. // 加载初始数据(转换 senum 为数值,避免字符串类型问题)
  265. refreshRecords(getParsedValue.value(senum))
  266. });
  267. defineExpose({
  268. backPressOptions
  269. })
  270. </script>
  271. <style scoped>
  272. /* 样式部分保持不变,仅修复标签颜色冲突(tag=3时优先黄色) */
  273. .container {
  274. padding: 20px;
  275. background-color: #f5f7fa;
  276. flex: 1;
  277. box-sizing: border-box;
  278. }
  279. .banner {
  280. background: linear-gradient(135deg, #6dd5ed, #2193b0);
  281. border-radius: 12px;
  282. padding: 20px 15px;
  283. margin-bottom: 20px;
  284. box-shadow: 0 4px 8px rgba(33, 147, 176, 0.3);
  285. }
  286. .banner-title {
  287. color: white;
  288. font-size: 18px;
  289. font-weight: bold;
  290. text-align: center;
  291. }
  292. .box {
  293. width: 20px;
  294. background-color: #909193;
  295. border-radius: 7.5px;
  296. }
  297. .card-list {
  298. display: flex;
  299. flex-direction: column;
  300. }
  301. .card-list>.card {
  302. margin-bottom: 15px;
  303. }
  304. /* #ifndef APP-ANDROID */
  305. .card-list>.card:last-child {
  306. margin-bottom: 0;
  307. }
  308. /* #endif */
  309. .card {
  310. background-color: white;
  311. border-radius: 10px;
  312. padding: 15px;
  313. box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
  314. display: flex;
  315. flex-direction: column;
  316. }
  317. .card-header {
  318. display: flex;
  319. align-items: center;
  320. margin-bottom: 20rpx;
  321. }
  322. .card-icon {
  323. width: 64rpx;
  324. height: 64rpx;
  325. margin-right: 20rpx;
  326. border-radius: 12rpx;
  327. background-color: #eef5ff;
  328. padding: 10rpx;
  329. }
  330. .info-row {
  331. display: flex;
  332. flex-direction: row;
  333. font-size: 14px;
  334. color: #33475b;
  335. align-items: center;
  336. padding: 10px;
  337. }
  338. .label {
  339. font-weight: bold;
  340. color: #102a43;
  341. min-width: 75px;
  342. }
  343. .value {
  344. flex: 1;
  345. white-space: nowrap;
  346. overflow: hidden;
  347. text-overflow: ellipsis;
  348. }
  349. .divider {
  350. height: 1px;
  351. background-color: #eee;
  352. margin: 10px 0;
  353. }
  354. .card-info {
  355. font-size: 28rpx;
  356. color: #666;
  357. line-height: 1.6;
  358. display: flex;
  359. flex-direction: column;
  360. }
  361. .card-info>.card-info-item {
  362. margin-bottom: 10rpx;
  363. }
  364. /* #ifndef APP-ANDROID */
  365. .card-info>.card-info-item:last-child {
  366. margin-bottom: 0;
  367. }
  368. /* #endif */
  369. .btn-group {
  370. display: flex;
  371. justify-content: flex-end;
  372. margin-top: 20rpx;
  373. }
  374. .main-btn {
  375. font-size: 28rpx;
  376. color: white;
  377. border: none;
  378. border-radius: 100rpx;
  379. background: linear-gradient(to right, #36d1dc, #5b86e5);
  380. box-shadow: 0 6rpx 16rpx rgba(91, 134, 229, 0.3);
  381. /* #ifndef APP-ANDROID */
  382. transition: all 0.2s ease-in-out;
  383. /* #endif */
  384. }
  385. /* #ifndef APP-ANDROID */
  386. .main-btn:active {
  387. opacity: 0.9;
  388. transform: scale(0.98);
  389. }
  390. /* #endif */
  391. .empty-card {
  392. background-color: white;
  393. border-radius: 20rpx;
  394. padding: 60rpx 30rpx;
  395. box-shadow: 0 6rpx 16rpx rgba(0, 0, 0, 0.05);
  396. text-align: center;
  397. margin-top: 100rpx;
  398. }
  399. .empty-img {
  400. width: 180rpx;
  401. height: 180rpx;
  402. margin-bottom: 30rpx;
  403. opacity: 0.8;
  404. }
  405. .empty-text {
  406. font-size: 30rpx;
  407. color: #999;
  408. }
  409. .surround {
  410. border: 2rpx solid #eee;
  411. border-radius: 10rpx;
  412. min-height: 60rpx;
  413. background-color: #f5f6f7;
  414. }
  415. .selectable {
  416. /* 确保在安卓设备上文字可以正常显示为可点击状态 */
  417. user-select: text;
  418. -webkit-user-select: text;
  419. cursor: pointer;
  420. /* #ifdef APP-ANDROID */
  421. /* 安卓设备特别处理,增强可点击性 */
  422. background-color: #f8f8f8;
  423. /* #endif */
  424. }
  425. .record-card {
  426. background: #ffffff;
  427. border-radius: 20rpx;
  428. padding: 24rpx 32rpx;
  429. box-shadow: 0 8rpx 15rpx rgba(0, 43, 92, 0.1);
  430. display: flex;
  431. flex-direction: column;
  432. margin-bottom: 20rpx;
  433. margin-top: 20rpx;
  434. }
  435. /* 横向排列radio的样式 */
  436. .radio-group-horizontal {
  437. display: flex;
  438. flex-direction: row;
  439. align-items: center;
  440. }
  441. .radio-group-horizontal-rg{
  442. margin-right: 30rpx;
  443. }
  444. .flex-row {
  445. flex-direction: row;
  446. }
  447. .tag-circle {
  448. width: 60rpx;
  449. height: 60rpx;
  450. margin: 0 10rpx;
  451. display: flex;
  452. justify-content: center;
  453. align-items: center;
  454. }
  455. .circle {
  456. height: 50rpx;
  457. width: 50rpx;
  458. background-color: #004a99;
  459. text-align: center;
  460. color: #fff;
  461. line-height: 50rpx;
  462. border-radius: 50rpx;
  463. }
  464. .checked-tag {
  465. height: 60rpx;
  466. width: 60rpx;
  467. line-height: 60rpx;
  468. border: 2rpx solid #ffffff;
  469. box-shadow: 0 0 0 2rpx #007aff;
  470. position: relative;
  471. z-index: 10;
  472. }
  473. .bg-green {
  474. background-color: seagreen;
  475. }
  476. .bg-yellow {
  477. background-color: yellow;
  478. color: #333;
  479. /* 黄色标签加深色文字,避免看不清 */
  480. }
  481. .bg-black {
  482. background-color: #102a43;
  483. }
  484. .bg-red {
  485. background-color: red;
  486. }
  487. .btn-panel {
  488. position: relative;
  489. width: 100%;
  490. height: 90rpx;
  491. overflow: visible;
  492. }
  493. .btn {
  494. position: absolute;
  495. height: 70rpx;
  496. line-height: 70rpx;
  497. padding: 0 20rpx;
  498. top: 50%;
  499. transform: translateY(-50%);
  500. background-color: #00aaff;
  501. color: #fff;
  502. border: 0 none;
  503. border-radius: 25rpx;
  504. }
  505. .btn-first {
  506. left: 15rpx;
  507. }
  508. .btn-second {
  509. right: 15rpx;
  510. }
  511. .number-input {
  512. width: 50%;
  513. }
  514. </style>