snapshotList.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="navTitle" @clickLeft="back" />
  4. <!-- 搜索区域 -->
  5. <view class="top-wrapper">
  6. <uni-forms :modelValue="where" label-width="100px" class="search-form">
  7. <uni-forms-item label="处理结果">
  8. <uni-data-select v-model="where.handleResult" :localdata="resultOptions" placeholder="全部"
  9. 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 :item="item" :index="idx + 1" :btnList="currentBtnList" :columns="currentColumns"
  18. :title="item.description" :status="statusMap[item.handleResult]" @goDetail="goDetail"
  19. @edit="handleEdit(item)" @handleDelete="handleDelete(item)" @handleProcess="handleProcess(item)" />
  20. </view>
  21. <view style="width: 100%; height: 40rpx"></view>
  22. <view style="margin-top: 20vh" v-if="tableList.length == 0">
  23. <u-empty iconSize="150" textSize="32" text="暂无数据" />
  24. </view>
  25. </u-list>
  26. </view>
  27. <!-- 新增/编辑/查看/处理弹窗 -->
  28. <snapshot-dialog ref="snapshotDialog" @reload="reloadList" @rectify="onRectify" @discard="onDiscard" />
  29. <!-- 废弃弹窗(仅管理模式) -->
  30. <discard-dialog v-if="mode === 'manage'" ref="discardDialogRef" @confirm="doDiscard" />
  31. <!-- 新增按钮(仅我的随手拍) -->
  32. <view v-if="mode === 'my'" class="add" @click="handleAdd">
  33. <u-icon name="plus" color="#fff"></u-icon>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import myCard from "@/components/myCard.vue";
  39. import snapshotDialog from "./snapshotDialog.vue";
  40. import discardDialog from "./discardDialog.vue";
  41. import {
  42. getList,
  43. remove,
  44. discard,
  45. handle
  46. } from "@/api/snapshot/index.js";
  47. export default {
  48. components: {
  49. myCard,
  50. snapshotDialog,
  51. discardDialog
  52. },
  53. props: {
  54. mode: {
  55. type: String,
  56. default: "my",
  57. validator: (v) => ["my", "manage"].includes(v),
  58. },
  59. },
  60. data() {
  61. return {
  62. where: {
  63. handleResult: ""
  64. },
  65. resultOptions: [{
  66. value: 0,
  67. text: "待处理"
  68. },
  69. {
  70. value: 1,
  71. text: "下发整改"
  72. },
  73. {
  74. value: 2,
  75. text: "废弃"
  76. },
  77. ],
  78. statusMap: {
  79. 0: "待处理",
  80. 1: "已整改",
  81. 2: "已废弃"
  82. },
  83. tableList: [],
  84. page: 1,
  85. size: 10,
  86. isEnd: false,
  87. userInfo: {},
  88. currentId: null,
  89. };
  90. },
  91. computed: {
  92. navTitle() {
  93. return this.mode === "my" ? "我的随手拍" : "随手拍管理";
  94. },
  95. currentColumns() {
  96. return [
  97. [{
  98. prop: "location",
  99. label: "位置",
  100. className: "perce100"
  101. }],
  102. [{
  103. prop: "problemDeptName",
  104. label: "所属部门",
  105. className: "perce100"
  106. }],
  107. [{
  108. prop: "reporterName",
  109. label: "上报人",
  110. className: "perce100"
  111. }],
  112. [{
  113. prop: "createTime",
  114. label: "上报时间",
  115. className: "perce100"
  116. }],
  117. [{
  118. prop: "handleResult",
  119. label: "处理结果",
  120. className: "perce100",
  121. formatter: (row) => this.statusMap[row.handleResult],
  122. }, ],
  123. [{
  124. label: "操作:",
  125. prop: "action",
  126. type: "action",
  127. className: "perce100",
  128. }, ]
  129. ];
  130. },
  131. currentBtnList() {
  132. if (this.mode === "my") {
  133. return [{
  134. name: "编辑",
  135. apiName: "edit",
  136. btnType: "primary",
  137. judge: [{
  138. fn: (item) => item.handleResult === 0
  139. }],
  140. },
  141. {
  142. name: "删除",
  143. apiName: "handleDelete",
  144. btnType: "danger",
  145. judge: [{
  146. fn: (item) => item.handleResult === 0
  147. }],
  148. },
  149. ];
  150. } else {
  151. return [{
  152. name: "处理",
  153. apiName: "handleProcess",
  154. btnType: "primary",
  155. judge: [{
  156. fn: (item) => item.handleResult === 0
  157. }],
  158. }, ];
  159. }
  160. },
  161. },
  162. created() {
  163. this.userInfo = uni.getStorageSync("userInfo") || {};
  164. this.getList();
  165. },
  166. methods: {
  167. back() {
  168. uni.navigateBack();
  169. },
  170. // 列表查看详情
  171. goDetail(item) {
  172. this.$refs.snapshotDialog.open("view", item);
  173. },
  174. // 新增(仅 my 模式)
  175. handleAdd() {
  176. this.$refs.snapshotDialog.open("add");
  177. },
  178. // 编辑(my 模式按钮)
  179. handleEdit(row) {
  180. this.$refs.snapshotDialog.open("edit", row);
  181. },
  182. // 删除(my 模式按钮)
  183. async handleDelete(row) {
  184. const res = await uni.showModal({
  185. title: "提示",
  186. content: "确认删除该记录吗?",
  187. });
  188. if (res[1].confirm) {
  189. await remove([row.id]);
  190. uni.showToast({
  191. title: "删除成功",
  192. icon: "success"
  193. });
  194. this.reloadList();
  195. }
  196. },
  197. // 处理(manage 模式按钮)
  198. handleProcess(row) {
  199. this.$refs.snapshotDialog.open("handle", row);
  200. },
  201. // 下发整改(manage 模式)
  202. onRectify(data) {
  203. this.currentId = data.id;
  204. this.$refs.hazardDialogRef &&
  205. this.$refs.hazardDialogRef.open("add", "", "report", {
  206. sourceType: 4,
  207. sourceId: data.id,
  208. sourceName: "随手拍",
  209. foundUserName: data.reporterName,
  210. foundUserId: data.reporterId,
  211. foundTime: data.createTime,
  212. description: data.location + data.description,
  213. reportAttachments: data.attachment,
  214. });
  215. },
  216. doRectify(opinion) {
  217. handle({
  218. id: this.currentId,
  219. handleOpinion: opinion,
  220. invHazardId: "下发整改",
  221. }).then(() => {
  222. uni.showToast({
  223. title: "下发整改成功",
  224. icon: "success"
  225. });
  226. this.reloadList();
  227. });
  228. },
  229. // 废弃(manage 模式)
  230. onDiscard(data,type) {
  231. this.$refs.discardDialogRef.open(data,type);
  232. },
  233. doDiscard({
  234. id,
  235. handleOpinion
  236. }) {
  237. discard({
  238. id,
  239. handleOpinion
  240. }).then(() => {
  241. uni.showToast({
  242. title: "废弃成功",
  243. icon: "success"
  244. });
  245. this.reloadList();
  246. });
  247. },
  248. // 通用方法
  249. reloadList() {
  250. this.page = 1;
  251. this.isEnd = false;
  252. this.getList();
  253. },
  254. handleSearch() {
  255. this.page = 1;
  256. this.isEnd = false;
  257. this.getList();
  258. },
  259. async getList() {
  260. if (this.isEnd) return;
  261. uni.showLoading({
  262. title: "加载中"
  263. });
  264. try {
  265. const baseData = {
  266. pageNum: this.page,
  267. size: this.size,
  268. handleResult: this.where.handleResult !== "" ?
  269. this.where.handleResult :
  270. undefined,
  271. };
  272. // 不同模式参数不同
  273. if (this.mode === "my") {
  274. baseData.reporterId = this.userInfo.userId;
  275. }
  276. const res = await getList(baseData);
  277. const newList = this.mode === "my" ? res.list || [] : res.list || [];
  278. if (this.page === 1) this.tableList = newList;
  279. else this.tableList.push(...newList);
  280. if (this.mode === "my") {
  281. this.isEnd = this.tableList.length >= res.count;
  282. } else {
  283. this.isEnd = newList.length < this.size;
  284. }
  285. this.page += 1;
  286. } catch (e) {
  287. console.error(e);
  288. } finally {
  289. uni.hideLoading();
  290. }
  291. },
  292. scrolltolower() {
  293. if (!this.isEnd) this.getList();
  294. },
  295. },
  296. };
  297. </script>
  298. <style lang="scss" scoped>
  299. @import "../common-style.scss";
  300. </style>