mySnapshot.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <!-- pages/snapshot/mySnapshot.vue -->
  2. <template>
  3. <view class="mainBox">
  4. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="我的随手拍" @clickLeft="back" />
  5. <!-- 搜索区域 -->
  6. <view class="top-wrapper">
  7. <uni-forms :modelValue="where" label-width="100px" class="search-form">
  8. <uni-forms-item label="处理结果">
  9. <uni-data-select v-model="where.handleResult" :localdata="resultOptions" placeholder="全部" clearable />
  10. </uni-forms-item>
  11. </uni-forms>
  12. <button class="search_btn" @click="handleSearch">搜索</button>
  13. </view>
  14. <view class="wrapper">
  15. <u-list @scrolltolower="scrolltolower" class="listContent">
  16. <view v-for="(item, idx) in tableList" :key="item.id" style="position: relative">
  17. <myCard
  18. :item="item"
  19. :index="idx + 1"
  20. :btnList="myBtnList"
  21. :columns="columns"
  22. :title="item.description"
  23. :status="statusMap[item.handleResult]"
  24. @goDetail="goDetail"
  25. @handleDelete="handleDelete"
  26. />
  27. </view>
  28. <view style="width: 100%; height: 40rpx"></view>
  29. <view style="margin-top: 20vh" v-if="tableList.length == 0">
  30. <u-empty iconSize="150" textSize="32" text="暂无数据" />
  31. </view>
  32. </u-list>
  33. </view>
  34. <!-- 新增/编辑/查看弹窗 -->
  35. <snapshot-dialog ref="snapshotDialog" @reload="reloadList" />
  36. <view class="add" @click="goDetail({}, 'add')">
  37. <u-icon name="plus" color="#fff"></u-icon>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import myCard from "@/components/myCard.vue";
  43. import snapshotDialog from './components/snapshotDialog.vue';
  44. import { getList, remove } from '@/api/snapshot/index.js';
  45. export default {
  46. components: { myCard, snapshotDialog },
  47. data() {
  48. return {
  49. where: { handleResult: '', createTime: '' },
  50. resultOptions: [
  51. { value: 0, text: '待处理' },
  52. { value: 1, text: '下发整改' },
  53. { value: 2, text: '废弃' }
  54. ],
  55. statusMap: { 0: '待处理', 1: '已整改', 2: '已废弃' },
  56. columns: [
  57. [{ prop: 'location', label: '位置', className: 'perce100' }],
  58. [{ prop: 'problemDeptName', label: '所属部门', className: 'perce100' }],
  59. [{ prop: 'createTime', label: '上报时间', className: 'perce100' }],
  60. [{ prop: 'handleResult', label: '处理结果', className: 'perce100', formatter: (row) => this.statusMap[row.handleResult] }]
  61. ],
  62. tableList: [],
  63. page: 1,
  64. size: 10,
  65. isEnd: false,
  66. userInfo: {}
  67. };
  68. },
  69. computed: {
  70. myBtnList() {
  71. return [
  72. {
  73. name: '编辑',
  74. apiName: 'edit',
  75. btnType: 'primary',
  76. judge: [{ fn: (item) => item.handleResult === 0 }]
  77. },
  78. {
  79. name: '删除',
  80. apiName: 'delete',
  81. btnType: 'danger',
  82. judge: [{ fn: (item) => item.handleResult === 0 }]
  83. }
  84. ];
  85. }
  86. },
  87. onLoad() {
  88. this.userInfo = uni.getStorageSync('userInfo') || {};
  89. this.getList();
  90. },
  91. methods: {
  92. back() { uni.navigateBack(); },
  93. goDetail(item, type) {
  94. this.$refs.snapshotDialog.open(type, item);
  95. },
  96. async handleDelete(row) {
  97. const res = await uni.showModal({ title: '提示', content: '确认删除该记录吗?' });
  98. if (res.confirm) {
  99. await remove([row.id]);
  100. uni.showToast({ title: '删除成功', icon: 'success' });
  101. this.reloadList();
  102. }
  103. },
  104. reloadList() {
  105. this.page = 1;
  106. this.isEnd = false;
  107. this.getList();
  108. },
  109. handleSearch() {
  110. this.page = 1;
  111. this.isEnd = false;
  112. this.getList();
  113. },
  114. async getList() {
  115. if (this.isEnd) return;
  116. uni.showLoading({ title: '加载中' });
  117. try {
  118. const data = {
  119. pageNum: this.page,
  120. size: this.size,
  121. reporterId: this.userInfo.userId,
  122. handleResult: this.where.handleResult !== '' ? this.where.handleResult : undefined,
  123. createTime: this.where.createTime || undefined
  124. };
  125. const res = await getList(data);
  126. const newList = res.list || [];
  127. if (this.page === 1) this.tableList = newList;
  128. else this.tableList.push(...newList);
  129. this.isEnd = this.tableList.length >= res.count;
  130. this.page += 1;
  131. } catch (e) { console.error(e); }
  132. finally { uni.hideLoading(); }
  133. },
  134. scrolltolower() {
  135. if (!this.isEnd) this.getList();
  136. }
  137. }
  138. };
  139. </script>
  140. <style lang="scss" scoped>
  141. @import './common-style.scss'; // 共用样式见下方
  142. </style>