PhotoRecord.uvue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  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. // #ifdef APP-ANDROID
  120. getListByOrder('app_task_photo', 'pdid', pid, ' order by sxid desc', null).then((res : UTSJSONObject) => {
  121. let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
  122. if (dataList != null && dataList.length > 0) {
  123. let index = 1
  124. dataList.forEach(item => {
  125. if (item != null) {
  126. const imgnameStr = item?.['imgname'] as string ?? ''
  127. const photourlStr = item?.['photourl'] as string ?? ''
  128. const exampleurlStr = item?.['exampleurl'] as string ?? ''
  129. const imgnameArr = imgnameStr.indexOf(",") > -1 ? imgnameStr.split(",") : (imgnameStr != '' ? [imgnameStr] : [])
  130. const photourlArr = photourlStr.indexOf(",") > -1 ? photourlStr.split(",") : (photourlStr != '' ? [photourlStr] : [])
  131. const exampleurlArr = exampleurlStr.indexOf(",") > -1 ? exampleurlStr.split(",") : (exampleurlStr != '' ? [exampleurlStr] : [])
  132. item['imgname'] = imgnameArr
  133. item['photourlSpl'] = photourlArr
  134. item['exampleurlSpl'] = exampleurlArr
  135. item['senum'] = index
  136. let record = JSON.parse<TaskPhoto>(item.toJSONString());
  137. if (record != null) {
  138. initRecords.push(record)
  139. // 为每个图片初始化closeTags值为true,表示默认显示
  140. if (record.imgname != null && record.imgname.length > 0) {
  141. for (let i = 0; i < record.imgname.length; i++) {
  142. closeTags.value.push(true);
  143. }
  144. }
  145. index++
  146. }
  147. }
  148. });
  149. maxcount = index-1;
  150. }
  151. if (initRecords.length > 0) {
  152. if (index > 0) {
  153. current.value = index
  154. } else {
  155. current.value = initRecords[0].senum
  156. }
  157. records.value = initRecords.filter(item => item['senum'] == current.value)
  158. console.log(records)
  159. }
  160. });
  161. // #endif
  162. }
  163. onLoad((options) => {
  164. photoitem = options?.photoitem ?? ""
  165. pid = options?.pdid ?? "1"
  166. senum = options?.senum ?? "1"
  167. // 加载初始数据
  168. refreshRecords(parseInt(senum));
  169. });
  170. const tabsClick = (obj : number) => {
  171. current.value = obj
  172. records.value = initRecords.filter(item => item['senum'] == current.value)
  173. }
  174. const closeTag = (index : number) => {
  175. let record = records.value[0]
  176. uni.showModal({
  177. title: '系统提示',
  178. content: '确认是否删除图片',
  179. cancelText: '取消',
  180. confirmText: '确定',
  181. success: function (res) {
  182. if (res.confirm) {
  183. closeTags.value[index] = false
  184. let imgname = record.imgname.filter((img, i) => i != index)
  185. let urlpdt = record.photourlSpl.filter((url, i) => i != index)
  186. let updatedData = ''
  187. if (imgname.length != urlpdt.length) {
  188. uni.showToast({
  189. title: '图片数据不正确',
  190. icon: 'error',
  191. duration: 2000
  192. });
  193. return;
  194. }
  195. if (imgname.length == 0 && urlpdt.length == 0) {
  196. updatedData = "imgname='',photourl=''"
  197. } else if (imgname.length == 1 && urlpdt.length == 1) {
  198. updatedData = "imgname='" + imgname[0] + "',photourl='" + urlpdt[0] + "'"
  199. } else {
  200. updatedData = "imgname='" + imgname.join(",") + "',photourl='" + urlpdt.join(",") + "'"
  201. }
  202. updateData('app_task_photo', updatedData, 'sxid', record.sxid.toString()).then((res : UTSJSONObject) => {
  203. let dataRes = res?.['data'] as boolean ?? false
  204. if (dataRes) {
  205. uni.showToast({
  206. title: "删除成功!",
  207. });
  208. // 刷新页面数据
  209. refreshRecords(record.senum);
  210. }
  211. });
  212. }
  213. }
  214. })
  215. }
  216. const preview = (imageUrl : string) => {
  217. uni.previewImage({
  218. urls: [imageUrl], // 需要预览的图片链接列表
  219. current: 0, // 当前显示图片的索引
  220. indicator: 'number', // 图片指示器样式
  221. loop: false // 是否可循环预览
  222. });
  223. }
  224. const cancel = (id : number) => {
  225. uni.navigateTo({
  226. url: `/pages/work/download/TaskCamera?id=${id}&num=${current.value}`
  227. })
  228. }
  229. defineExpose({
  230. backPressOptions
  231. })
  232. </script>
  233. <style scoped>
  234. .container {
  235. padding: 24rpx;
  236. background-color: #f0f4f8;
  237. flex: 1;
  238. display: flex;
  239. flex-direction: column;
  240. font-family: "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
  241. /* #ifndef APP-ANDROID */
  242. min-height: 100vh;
  243. /* #endif */
  244. }
  245. .banner {
  246. background: linear-gradient(135deg, #6dd5ed, #2193b0);
  247. border-radius: 24rpx;
  248. padding: 40rpx 30rpx;
  249. margin-bottom: 40rpx;
  250. box-shadow: 0 8rpx 16rpx rgba(33, 147, 176, 0.3);
  251. }
  252. .banner-title {
  253. color: white;
  254. font-size: 36rpx;
  255. font-weight: bold;
  256. text-align: center;
  257. }
  258. /* 卡片整体 */
  259. .record-card {
  260. background: #ffffff;
  261. border-radius: 20rpx;
  262. padding: 24rpx 32rpx;
  263. box-shadow: 0 8rpx 15rpx rgba(0, 43, 92, 0.1);
  264. display: flex;
  265. flex-direction: column;
  266. margin-bottom: 15rpx;
  267. margin-top: 10rpx;
  268. }
  269. /* 卡片整体 */
  270. .record-card2 {
  271. background: #ffffff;
  272. border-radius: 20rpx;
  273. padding: 24rpx 32rpx;
  274. display: flex;
  275. flex-direction: column;
  276. margin-bottom: 20rpx;
  277. margin-top: 20rpx;
  278. }
  279. /* 头部:科室 和 状态 */
  280. .header-row {
  281. display: flex;
  282. flex-direction: row;
  283. justify-content: space-between;
  284. align-items: center;
  285. }
  286. .department {
  287. font-size: 32rpx;
  288. font-weight: 700;
  289. color: #004a99;
  290. }
  291. .status {
  292. font-size: 28rpx;
  293. color: #1890ff;
  294. padding: 6rpx 18rpx;
  295. border-radius: 16rpx;
  296. background-color: #e6f7ff;
  297. }
  298. .status-cancelled {
  299. color: #ff4d4f;
  300. background-color: #fff1f0;
  301. }
  302. /* 信息行 */
  303. .info-row {
  304. display: flex;
  305. flex-direction: row;
  306. font-size: 28rpx;
  307. color: #33475b;
  308. align-items: center;
  309. }
  310. .label {
  311. color: #102a43;
  312. min-width: 100rpx;
  313. width: 180rpx;
  314. line-height: 1.5;
  315. }
  316. .value {
  317. flex: 1;
  318. word-break: break-all;
  319. word-wrap: break-word;
  320. }
  321. .fee {
  322. color: #fa541c;
  323. font-weight: 700;
  324. }
  325. /* 取消按钮 */
  326. .cancel-btn {
  327. align-self: flex-end;
  328. background-color: #ff4d4f;
  329. color: #fff;
  330. border: none;
  331. border-radius: 32rpx;
  332. padding: 5rpx 30rpx;
  333. font-size: 28rpx;
  334. font-weight: 700;
  335. margin-top: 20rpx;
  336. }
  337. .cancel-btn:hover {
  338. background-color: #d9363e;
  339. }
  340. .cancel-btn:active {
  341. background-color: #a93232;
  342. }
  343. .swiper {
  344. height: 300rpx;
  345. margin: 20rpx 0;
  346. }
  347. .swiper-box {
  348. height: 500rpx;
  349. }
  350. .swiper-item {
  351. /* #ifndef APP-NVUE */
  352. display: flex;
  353. /* #endif */
  354. flex-direction: column;
  355. justify-content: center;
  356. align-items: center;
  357. color: #fff;
  358. height: 500rpx;
  359. line-height: 300rpx;
  360. }
  361. .my-page {
  362. display: flex;
  363. flex-direction: column;
  364. box-sizing: border-box;
  365. background-color: #fff;
  366. /* #ifndef APP-ANDROID */
  367. min-height: 100%;
  368. /* #endif */
  369. height: 100%;
  370. }
  371. .flex-row {
  372. flex-direction: row;
  373. flex-wrap: nowrap;
  374. width: auto;
  375. min-width: 100%;
  376. /* 确保容器宽度至少为屏幕宽度 */
  377. }
  378. .demo-view-label {
  379. text-align: center;
  380. color: #102a43;
  381. line-height: 1.5;
  382. margin-top: 5rpx;
  383. }
  384. .tag-circle {
  385. width: 60rpx;
  386. height: 60rpx;
  387. margin: 0 10rpx;
  388. display: flex;
  389. justify-content: center;
  390. align-items: center;
  391. flex-shrink: 0;
  392. }
  393. .circle {
  394. height: 50rpx;
  395. width: 50rpx;
  396. background-color: #004a99;
  397. text-align: center;
  398. color: #fff;
  399. line-height: 50rpx;
  400. border-radius: 50rpx;
  401. }
  402. .checked-tag {
  403. height: 60rpx;
  404. width: 60rpx;
  405. line-height: 60rpx;
  406. border: 2rpx solid #ffffff;
  407. box-shadow: 0 0 0 2rpx #007aff;
  408. position: relative;
  409. z-index: 10;
  410. }
  411. .bg-green {
  412. background-color: seagreen;
  413. }
  414. .bg-yellow {
  415. background-color: yellow;
  416. }
  417. .bg-black {
  418. background-color: #102a43;
  419. }
  420. .bg-red {
  421. background-color: red;
  422. }
  423. .btn-panel {
  424. position: relative;
  425. width: 100%;
  426. height: 90rpx;
  427. overflow: visible;
  428. }
  429. .btn {
  430. position: absolute;
  431. height: 70rpx;
  432. line-height: 70rpx;
  433. padding: 0 20rpx;
  434. top: 50%;
  435. transform: translateY(-50%);
  436. background-color: #00aaff;
  437. color: #fff;
  438. border: 0 none;
  439. border-radius: 25rpx;
  440. }
  441. .btn-first {
  442. left: 15rpx;
  443. }
  444. .btn-second {
  445. right: 15rpx;
  446. }
  447. /* 安卓兼容的滚动容器样式 */
  448. .tag-scroll-container {
  449. width: 100%;
  450. overflow-x: auto;
  451. overflow-y: hidden;
  452. -webkit-overflow-scrolling: touch;
  453. box-sizing: border-box;
  454. padding: 10rpx 15rpx;
  455. white-space: nowrap;
  456. display: flex;
  457. flex-direction: row;
  458. }
  459. .tag-scroll-container::-webkit-scrollbar-thumb {
  460. background-color: rgba(0, 0, 0, 0.2) !important;
  461. border-radius: 3rpx !important;
  462. }
  463. .img-banner {
  464. height: 50rpx;
  465. width: 100%;
  466. background-color: #004a99;
  467. text-align: center;
  468. color: #fff;
  469. line-height: 50rpx;
  470. border-radius: 10rpx;
  471. margin-left: 2rpx;
  472. font-size: 12px;
  473. padding: 0 10rpx;
  474. }
  475. .tag-banner {
  476. flex-direction: column;
  477. flex-wrap: wrap;
  478. margin: 4px 0;
  479. font-size: 12px;
  480. }
  481. .mg-top {
  482. margin-top: 20rpx;
  483. }
  484. </style>