snapshotSelectDialog.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <!-- components/snapshotSelectDialog.vue - 选择随手拍弹窗 -->
  2. <template>
  3. <uni-popup ref="popup" type="center">
  4. <view class="select-dialog">
  5. <view class="header">选择随手拍</view>
  6. <view class="search">
  7. <uni-forms :modelValue="where" label-width="70px">
  8. <uni-forms-item label="上报人">
  9. <uni-easyinput v-model="where.reporterName" placeholder="请输入" clearable />
  10. </uni-forms-item>
  11. <uni-forms-item label="上报时间">
  12. <uni-datetime-picker v-model="where.createTime" type="datetime" return-type="string" />
  13. </uni-forms-item>
  14. <view class="search-buttons">
  15. <button type="primary" size="mini" @click="handleSearch">查询</button>
  16. <button size="mini" @click="handleReset">重置</button>
  17. </view>
  18. </uni-forms>
  19. </view>
  20. <scroll-view scroll-y class="list">
  21. <view v-for="item in list" :key="item.id" class="list-item" :class="{ active: selectedId === item.id }" @click="selectItem(item)">
  22. <text class="desc">{{ item.description }}</text>
  23. <text class="info">{{ item.location }} | {{ item.reporterName }} | {{ item.createTime }}</text>
  24. </view>
  25. <view v-if="list.length === 0 && !loading" class="empty">暂无数据</view>
  26. </scroll-view>
  27. <uni-pagination :current="page" :total="total" :page-size="limit" @change="onPageChange" show-icon />
  28. <view class="footer">
  29. <button @click="close">取消</button>
  30. <button type="primary" :disabled="!selectedItem" @click="handleConfirm">确定</button>
  31. </view>
  32. </view>
  33. </uni-popup>
  34. </template>
  35. <script>
  36. import { getList } from '@/api/snapshot/index.js';
  37. export default {
  38. emits: ['confirm'],
  39. data() {
  40. return {
  41. list: [],
  42. total: 0,
  43. page: 1,
  44. limit: 10,
  45. loading: false,
  46. where: { reporterName: '', createTime: '' },
  47. selectedItem: null,
  48. selectedId: null
  49. };
  50. },
  51. methods: {
  52. open() {
  53. this.selectedItem = null;
  54. this.selectedId = null;
  55. this.page = 1;
  56. this.where = { reporterName: '', createTime: '' };
  57. this.loadData();
  58. this.$refs.popup.open();
  59. },
  60. close() {
  61. this.$refs.popup.close();
  62. },
  63. async loadData() {
  64. this.loading = true;
  65. try {
  66. const res = await getList({ ...this.where, handleResult: 0, pageNum: this.page, size: this.limit });
  67. this.list = res.rows || [];
  68. this.total = res.total || 0;
  69. } finally {
  70. this.loading = false;
  71. }
  72. },
  73. selectItem(item) {
  74. this.selectedId = item.id;
  75. this.selectedItem = item;
  76. },
  77. handleConfirm() {
  78. if (!this.selectedItem) return;
  79. this.$emit('confirm', {
  80. sourceType: 4,
  81. sourceId: this.selectedItem.id,
  82. sourceName: '随手拍',
  83. foundUserName: this.selectedItem.reporterName,
  84. foundUserId: this.selectedItem.reporterId,
  85. foundTime: this.selectedItem.createTime,
  86. description: this.selectedItem.location + this.selectedItem.description,
  87. reportAttachments: this.selectedItem.attachment
  88. });
  89. this.close();
  90. },
  91. handleSearch() {
  92. this.page = 1;
  93. this.loadData();
  94. },
  95. handleReset() {
  96. this.where = { reporterName: '', createTime: '' };
  97. this.handleSearch();
  98. },
  99. onPageChange(e) {
  100. this.page = e.current;
  101. this.loadData();
  102. }
  103. }
  104. };
  105. </script>
  106. <style lang="scss" scoped>
  107. .select-dialog {
  108. width: 600rpx;
  109. max-width: 90vw;
  110. background: #fff;
  111. border-radius: 16rpx;
  112. display: flex;
  113. flex-direction: column;
  114. max-height: 80vh;
  115. .header {
  116. padding: 30rpx;
  117. font-size: 36rpx;
  118. font-weight: bold;
  119. text-align: center;
  120. border-bottom: 1px solid #eee;
  121. }
  122. .search {
  123. padding: 20rpx;
  124. border-bottom: 1px solid #eee;
  125. .search-buttons {
  126. display: flex;
  127. gap: 20rpx;
  128. margin-top: 20rpx;
  129. }
  130. }
  131. .list {
  132. flex: 1;
  133. padding: 20rpx;
  134. .list-item {
  135. padding: 20rpx;
  136. border-bottom: 1px solid #f0f0f0;
  137. &.active { background: #e6f7ff; }
  138. .desc { font-weight: bold; display: block; }
  139. .info { font-size: 24rpx; color: #666; margin-top: 10rpx; display: block; }
  140. }
  141. .empty { text-align: center; padding: 40rpx; color: #999; }
  142. }
  143. .footer {
  144. padding: 20rpx;
  145. display: flex;
  146. gap: 20rpx;
  147. border-top: 1px solid #eee;
  148. button { flex: 1; margin: 0; }
  149. }
  150. }
  151. </style>