PhotoRecord.uvue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. <template>
  2. <scroll-view class="tag-scroll-container" scroll-x="true">
  3. <view class="record-card2 flex-row">
  4. <view class="tag-circle" v-for="(item, index) in initRecords" :key="index" @click="tabsClick(item.senum)"
  5. :class="{'checked-tag' : item.senum == current}">
  6. <text class="circle" :class="{
  7. 'bg-green': item.status == 3,
  8. 'bg-yellow': item.status == 2,
  9. 'bg-red': item.status == 4,
  10. 'bg-black': item.status == 1
  11. }">{{item.senum}}</text>
  12. </view>
  13. </view>
  14. </scroll-view>
  15. <!-- #ifdef APP -->
  16. <scroll-view style="flex:1">
  17. <!-- #endif -->
  18. <view class="record-card" v-for="(item, index) in records" :key="index"
  19. v-show="current == item.senum as number">
  20. <view class="header-row">
  21. <text class="label">序号:</text>
  22. <text class="value">{{ item.senum }}</text>
  23. <text class="status"
  24. :class="{'status-cancelled': item.status === 5, 'bg-red': item.status == 4}">{{ recordStatusDict[item.status.toString()] }}</text>
  25. </view>
  26. <view class="info-row">
  27. <text class="label">产品码:</text>
  28. <text class="value">{{ item.productno }}</text>
  29. </view>
  30. <view class="info-row">
  31. <text class="label">拍照点:</text>
  32. <text class="value">{{ item.part }}</text>
  33. </view>
  34. <view class="info-row">
  35. <text class="label">拍照位置:</text>
  36. <text class="value">{{ item.photoitem }}</text>
  37. </view>
  38. <view class="info-row">
  39. <text class="label">描述:</text>
  40. <text class="value">{{ item.descb }}</text>
  41. </view>
  42. <view class="info-row">
  43. <text class="label">位置编号:</text>
  44. <text class="value">{{ item.partno }}</text>
  45. </view>
  46. <view class="info-row">
  47. <text class="label">数量:</text>
  48. <text class="value">{{ item.num }}</text>
  49. </view>
  50. <button class="cancel-btn" v-if="item.status == 1 || item.status == 2" @click="cancel(item.sxid, item.num)">
  51. 拍照
  52. </button>
  53. <view class="tag-banner" style="">
  54. <view class="tag-banner" v-for="(tag,index) in item.imgname" :key="index" v-if="item.imgname.length>0">
  55. <text class="img-banner" v-if="item.imgname[index]!=''&& closeTags[index]"
  56. @click="closeTag(index)">{{tag}}</text>
  57. </view>
  58. </view>
  59. <view class="my-page">
  60. <swiper class="swiper-box my-swiper" :current="0" :indicator-dots="true" v-if="item.urlpdt.length>0">
  61. <swiper-item v-for="(url, index) in item.urlpdt" :key="index" @tap="preview(uni.env.USER_DATA_PATH+url)">
  62. <view class="swiper-item ">
  63. <image class="my-image" :src="uni.env.USER_DATA_PATH+url" mode="aspectFill" />
  64. </view>
  65. <view v-if="item.imgname.length>0">
  66. <text class="demo-view-label">{{ item.imgname?.[index] ?? ''}}</text>
  67. </view>
  68. </swiper-item>
  69. </swiper>
  70. <swiper class="swiper-box my-swiper mg-top" :current="0" :indicator-dots="true"
  71. v-if="item.urlspl.length>0">
  72. <swiper-item v-for="(url, index) in item.urlspl" :key="index" @tap="preview(url)">
  73. <view class="swiper-item ">
  74. <image class="my-image" :src="url" mode="aspectFill" />
  75. </view>
  76. </swiper-item>
  77. </swiper>
  78. <view v-if="item.urlspl">
  79. <text class="demo-view-label">样张</text>
  80. </view>
  81. </view>
  82. </view>
  83. <view class="info-row btn-panel">
  84. <button class="btn btn-first" @click="tabsClick(current-1)" v-if="current > 1">
  85. 前一项
  86. </button>
  87. <button class="btn btn-second" @click="tabsClick(current+1)" v-if="current < maxcount">
  88. 下一项
  89. </button>
  90. </view>
  91. <!-- #ifdef APP -->
  92. </scroll-view>
  93. <!-- #endif -->
  94. </template>
  95. <script setup>
  96. import {
  97. ref
  98. } from 'vue'
  99. import { getList, Record, recordStatusDict, updateData } from '@/api/work';
  100. // 存储页面参数
  101. let photoitem = "";
  102. let pid = "";
  103. let senum = "";
  104. //自定义返回行为,覆盖系统默认返回按钮
  105. const backPressOptions = reactive({
  106. from: 'backbutton'
  107. } as OnBackPressOptions)
  108. onBackPress((options : OnBackPressOptions) : boolean | null => {
  109. console.log('onBackPress', options)
  110. uni.navigateTo({
  111. url: `/pages/work/record/InfoDetail?id=${pid}`,
  112. // 修改动画方向为从左到右退回
  113. animationType: 'slide-in-left', // 使用从左到右滑出的动画效果
  114. animationDuration: 300 // 动画持续时间,单位ms
  115. })
  116. // 返回true表示拦截默认返回行为
  117. return true
  118. })
  119. //检查项目最大数量
  120. var maxcount = 5
  121. var current = ref(1)
  122. var records = ref<Record[]>([]);
  123. const closeTags = ref<boolean[]>([]);
  124. var initRecords = [] as Record[]
  125. // 定义数据刷新函数
  126. const refreshRecords = (index : number) => {
  127. // 清空现有数据
  128. initRecords = [];
  129. closeTags.value = [];
  130. // #ifdef APP-ANDROID
  131. getList('app_media_record', 'photoitem', photoitem, 'pid', pid, null).then((res : UTSJSONObject) => {
  132. let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
  133. if (dataList != null && dataList.length > 0) {
  134. dataList.forEach(item => {
  135. if (item != null) {
  136. const imgnameStr = item?.['imgname'] as string ?? ''
  137. const urlpdtStr = item?.['urlpdt'] as string ?? ''
  138. const urlsplStr = item?.['urlspl'] as string ?? ''
  139. const imgnameArr = imgnameStr.indexOf(",") > -1 ? imgnameStr.split(",") : (imgnameStr != '' ? [imgnameStr] : [])
  140. const urlpdtArr = urlpdtStr.indexOf(",") > -1 ? urlpdtStr.split(",") : (urlpdtStr != '' ? [urlpdtStr] : [])
  141. const urlsplArr = urlsplStr.indexOf(",") > -1 ? urlsplStr.split(",") : (urlsplStr != '' ? [urlsplStr] : [])
  142. item['imgname'] = imgnameArr
  143. item['urlpdt'] = urlpdtArr
  144. item['urlspl'] = urlsplArr
  145. let record = JSON.parse<Record>(item.toJSONString());
  146. if (record != null) {
  147. for (let i : Int = 0; i < record.num; i++) {
  148. closeTags.value.push(true)
  149. }
  150. initRecords.push(record)
  151. }
  152. }
  153. });
  154. }
  155. if (initRecords.length > 0) {
  156. console.log(initRecords)
  157. console.log(index)
  158. if (index > 0) {
  159. current.value = index
  160. } else {
  161. current.value = initRecords[0].senum
  162. }
  163. console.log(current.value)
  164. records.value = initRecords.filter(item => item['senum'] == current.value)
  165. console.log(records)
  166. }
  167. });
  168. // #endif
  169. }
  170. onLoad((options) => {
  171. photoitem = options?.photoitem ?? ""
  172. const num = options?.num ?? "1"
  173. pid = options?.pid ?? "1"
  174. senum = options?.senum ?? "1"
  175. maxcount = parseInt(num)
  176. // 加载初始数据
  177. refreshRecords(parseInt(senum));
  178. });
  179. // #ifdef H5
  180. initRecords = [{
  181. sxid: 1,
  182. senum: 1,
  183. photoitem: '前底-外侧',
  184. productno: 'YH0001',
  185. part: '角焊缝',
  186. descb: '角片角焊缝',
  187. date: '2025-06-05',
  188. partno: 'TD10-01',
  189. num: 2,
  190. status: '未执行',
  191. urlspl: ['/static/images/demo.png'],
  192. imgname: ['1.jpg', '2.jpg'],
  193. urlpdt: ['/static/images/demo.png', '/static/images/demo.png']
  194. },
  195. {
  196. sxid: 2,
  197. senum: 2,
  198. photoitem: '后底-外侧',
  199. productno: 'YH0002',
  200. part: '角焊缝',
  201. descb: '角片角焊缝',
  202. date: '2025-06-05',
  203. partno: 'TD10-02',
  204. num: 3,
  205. status: '未执行',
  206. urlspl: ['/static/images/demo.png'],
  207. imgname: ['1.jpg', '2.jpg', '3.jpg'],
  208. urlpdt: ['/static/images/demo.png', '/static/images/demo.png', '/static/images/demo.png']
  209. }] as Record[];
  210. records.value = initRecords.filter(item => item['senum'] == current.value)
  211. // #endif
  212. const tabsClick = (obj : number) => {
  213. current.value = obj
  214. records.value = initRecords.filter(item => item['senum'] == current.value)
  215. }
  216. const closeTag = (index : number) => {
  217. let record = records.value[0]
  218. // if(record.status==3){
  219. // uni.showToast({
  220. // title: '拍照任务已完成',
  221. // icon: 'error',
  222. // duration: 2000
  223. // });
  224. // return;
  225. // }
  226. uni.showModal({
  227. title: '系统提示',
  228. content: '确认是否删除图片',
  229. cancelText: '取消',
  230. confirmText: '确定',
  231. success: function (res) {
  232. if (res.confirm) {
  233. closeTags.value[index] = false
  234. let imgname = record.imgname.filter((img, i) => i != index)
  235. let urlpdt = record.urlpdt.filter((url, i) => i != index)
  236. let updatedData = ''
  237. if (imgname.length != urlpdt.length) {
  238. uni.showToast({
  239. title: '图片数据不正确',
  240. icon: 'error',
  241. duration: 2000
  242. });
  243. return;
  244. }
  245. console.log(urlpdt)
  246. if (imgname.length == 0 && urlpdt.length == 0) {
  247. updatedData = "imgname='',urlpdt=''"
  248. } else if (imgname.length == 1 && urlpdt.length == 1) {
  249. updatedData = "imgname='" + imgname[0] + "',urlpdt='" + urlpdt[0] + "'"
  250. } else {
  251. updatedData = "imgname='" + imgname.join(",") + "',urlpdt='" + urlpdt.join(",") + "'"
  252. }
  253. if (imgname.length == 0) {
  254. updatedData += ',status=1 '
  255. } else if (imgname.length < record.num) {
  256. updatedData += ',status=2 '
  257. } else if (imgname.length + 1 == record.num){
  258. updatedData += ',status=3 '
  259. }
  260. updateData('app_media_record', updatedData, 'sxid', record.sxid.toString()).then((res : UTSJSONObject) => {
  261. let dataRes = res?.['data'] as boolean ?? false
  262. if (dataRes) {
  263. uni.showToast({
  264. title: "删除成功!",
  265. });
  266. // 刷新页面数据
  267. refreshRecords(record.senum);
  268. }
  269. });
  270. }
  271. }
  272. })
  273. }
  274. const preview = (imageUrl : string) => {
  275. uni.previewImage({
  276. urls: [imageUrl], // 需要预览的图片链接列表
  277. current: 0, // 当前显示图片的索引
  278. indicator: 'number', // 图片指示器样式
  279. loop: false // 是否可循环预览
  280. });
  281. }
  282. const cancel = (id : number, num : number) => {
  283. uni.navigateTo({
  284. url: `/pages/work/record/Camera?id=${id}&num=${num}`
  285. })
  286. }
  287. defineExpose({
  288. backPressOptions
  289. })
  290. </script>
  291. <style scoped>
  292. .container {
  293. padding: 24rpx;
  294. background-color: #f0f4f8;
  295. flex: 1;
  296. display: flex;
  297. flex-direction: column;
  298. font-family: "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
  299. /* #ifndef APP-ANDROID */
  300. min-height: 100vh;
  301. /* #endif */
  302. }
  303. .banner {
  304. background: linear-gradient(135deg, #6dd5ed, #2193b0);
  305. border-radius: 24rpx;
  306. padding: 40rpx 30rpx;
  307. margin-bottom: 40rpx;
  308. box-shadow: 0 8rpx 16rpx rgba(33, 147, 176, 0.3);
  309. }
  310. .banner-title {
  311. color: white;
  312. font-size: 36rpx;
  313. font-weight: bold;
  314. text-align: center;
  315. }
  316. /* 卡片整体 */
  317. .record-card {
  318. background: #ffffff;
  319. border-radius: 20rpx;
  320. padding: 24rpx 32rpx;
  321. box-shadow: 0 8rpx 15rpx rgba(0, 43, 92, 0.1);
  322. display: flex;
  323. flex-direction: column;
  324. margin-bottom: 15rpx;
  325. margin-top: 10rpx;
  326. }
  327. /* 卡片整体 */
  328. .record-card2 {
  329. background: #ffffff;
  330. border-radius: 20rpx;
  331. padding: 24rpx 32rpx;
  332. display: flex;
  333. flex-direction: column;
  334. margin-bottom: 20rpx;
  335. margin-top: 20rpx;
  336. }
  337. /* 头部:科室 和 状态 */
  338. .header-row {
  339. display: flex;
  340. flex-direction: row;
  341. justify-content: space-between;
  342. align-items: center;
  343. }
  344. .department {
  345. font-size: 32rpx;
  346. font-weight: 700;
  347. color: #004a99;
  348. }
  349. .status {
  350. font-size: 28rpx;
  351. color: #1890ff;
  352. padding: 6rpx 18rpx;
  353. border-radius: 16rpx;
  354. background-color: #e6f7ff;
  355. }
  356. .status-cancelled {
  357. color: #ff4d4f;
  358. background-color: #fff1f0;
  359. }
  360. /* 信息行 */
  361. .info-row {
  362. display: flex;
  363. flex-direction: row;
  364. font-size: 28rpx;
  365. color: #33475b;
  366. align-items: center;
  367. }
  368. .label {
  369. color: #102a43;
  370. min-width: 100rpx;
  371. width: 180rpx;
  372. line-height: 1.5;
  373. }
  374. .value {
  375. flex: 1;
  376. white-space: nowrap;
  377. overflow: hidden;
  378. text-overflow: ellipsis;
  379. }
  380. .fee {
  381. color: #fa541c;
  382. font-weight: 700;
  383. }
  384. /* 取消按钮 */
  385. .cancel-btn {
  386. align-self: flex-end;
  387. background-color: #ff4d4f;
  388. color: #fff;
  389. border: none;
  390. border-radius: 32rpx;
  391. padding: 5rpx 30rpx;
  392. font-size: 28rpx;
  393. font-weight: 700;
  394. }
  395. .cancel-btn:hover {
  396. background-color: #d9363e;
  397. }
  398. .cancel-btn:active {
  399. background-color: #a93232;
  400. }
  401. .swiper {
  402. height: 300rpx;
  403. margin: 20rpx 0;
  404. }
  405. .swiper-box {
  406. height: 500rpx;
  407. }
  408. .swiper-item {
  409. /* #ifndef APP-NVUE */
  410. display: flex;
  411. /* #endif */
  412. flex-direction: column;
  413. justify-content: center;
  414. align-items: center;
  415. color: #fff;
  416. height: 500rpx;
  417. line-height: 300rpx;
  418. }
  419. .my-page {
  420. display: flex;
  421. flex-direction: column;
  422. box-sizing: border-box;
  423. background-color: #fff;
  424. /* #ifndef APP-ANDROID */
  425. min-height: 100%;
  426. /* #endif */
  427. height: 100%;
  428. }
  429. .flex-row {
  430. flex-direction: row;
  431. flex-wrap: nowrap;
  432. width: auto;
  433. min-width: 100%;
  434. /* 确保容器宽度至少为屏幕宽度 */
  435. }
  436. .demo-view-label {
  437. text-align: center;
  438. color: #102a43;
  439. line-height: 1.5;
  440. margin-top: 5rpx;
  441. }
  442. .tag-circle {
  443. width: 60rpx;
  444. height: 60rpx;
  445. margin: 0 10rpx;
  446. display: flex;
  447. justify-content: center;
  448. align-items: center;
  449. flex-shrink: 0;
  450. }
  451. .circle {
  452. height: 50rpx;
  453. width: 50rpx;
  454. background-color: #004a99;
  455. text-align: center;
  456. color: #fff;
  457. line-height: 50rpx;
  458. border-radius: 50rpx;
  459. }
  460. .checked-tag {
  461. height: 60rpx;
  462. width: 60rpx;
  463. line-height: 60rpx;
  464. border: 2rpx solid #ffffff;
  465. box-shadow: 0 0 0 2rpx #007aff;
  466. position: relative;
  467. z-index: 10;
  468. }
  469. .bg-green {
  470. background-color: seagreen;
  471. }
  472. .bg-yellow {
  473. background-color: yellow;
  474. }
  475. .bg-black {
  476. background-color: #102a43;
  477. }
  478. .bg-red {
  479. background-color: red;
  480. }
  481. .btn-panel {
  482. position: relative;
  483. width: 100%;
  484. height: 90rpx;
  485. overflow: visible;
  486. }
  487. .btn {
  488. position: absolute;
  489. height: 70rpx;
  490. line-height: 70rpx;
  491. padding: 0 20rpx;
  492. top: 50%;
  493. transform: translateY(-50%);
  494. background-color: #00aaff;
  495. color: #fff;
  496. border: 0 none;
  497. border-radius: 25rpx;
  498. }
  499. .btn-first {
  500. left: 15rpx;
  501. }
  502. .btn-second {
  503. right: 15rpx;
  504. }
  505. /* 安卓兼容的滚动容器样式 */
  506. .tag-scroll-container {
  507. width: 100%;
  508. overflow-x: auto;
  509. overflow-y: hidden;
  510. -webkit-overflow-scrolling: touch;
  511. box-sizing: border-box;
  512. padding: 10rpx 15rpx;
  513. white-space: nowrap;
  514. display: flex;
  515. flex-direction: row;
  516. }
  517. .tag-scroll-container::-webkit-scrollbar-thumb {
  518. background-color: rgba(0, 0, 0, 0.2) !important;
  519. border-radius: 3rpx !important;
  520. }
  521. .img-banner {
  522. height: 50rpx;
  523. width: 100%;
  524. background-color: #004a99;
  525. text-align: center;
  526. color: #fff;
  527. line-height: 50rpx;
  528. border-radius: 10rpx;
  529. margin-left: 2rpx;
  530. font-size: 12px;
  531. padding: 0 10rpx;
  532. }
  533. .tag-banner {
  534. flex-direction: column;
  535. flex-wrap: wrap;
  536. margin: 4px 0;
  537. font-size: 12px;
  538. }
  539. .mg-top {
  540. margin-top: 20rpx;
  541. }
  542. </style>