PhotoRecord.uvue 13 KB

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