repair.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <view>
  3. <my-add-button @handleClick="handleClick" />
  4. <!-- 关键词搜索栏:与设备台账(equipment.vue)一致,后端 selectPageList keyword 已覆盖报修内容/报修人/维修人(含二三四维修人)等字段 -->
  5. <div class="bg-color-white py2">
  6. <u-search placeholder="设备名称/编号/单号/报修内容/报修人/维修人" clearabled v-model="keyword" @search="search" @custom="search" @clear="search"></u-search>
  7. </div>
  8. <!-- <view class="border-bottom">
  9. <u-tabs class="p-fixed left0 right0 zIndex" :list="list" :is-scroll="false" :current="current" @change="change"></u-tabs>
  10. </view> -->
  11. <view class="">
  12. <template v-if="listData.length > 0">
  13. <view
  14. class="mx3 my2 p3 bg-color-white box p-relative"
  15. v-for="(item, index) in listData"
  16. :key="index"
  17. @tap="handleDetail(item.id)"
  18. @longpress="showMask(item.id,$event)"
  19. >
  20. <common-mask :item="item" :maskId="maskId" @hide="maskId = 0" @del="handleDel(item.id)" />
  21. <view class="d-flex j-between border-bottom pb-2 a-center">
  22. <view class="text-color-b f-size-26">{{ item.sbName }} ({{ item.sbNo }})</view>
  23. <my-badge
  24. :text="$BaseTool.Object.getField(statusMap, item.status)"
  25. :status="
  26. $DictCache.COLOR.REPAIR_APPLICATION_FORM_STATUS[item.status]
  27. "
  28. />
  29. </view>
  30. <view class="mt-2 d-flex j-between">
  31. <view class="text-color-3 f-size-32 f-weight-bold">{{
  32. item.actualUser
  33. }}-{{
  34. item.sbCph
  35. }}</view>
  36. </view>
  37. <view class="f-size-26 text-color-6 f-weight-4 mt-2">{{
  38. item.applyTime
  39. }}</view>
  40. <!-- <view class="d-flex j-end edit-box">
  41. <view v-if="item.status === $DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ACCEPTANCE" class="text-color-3 f-size-32 edit">
  42. <view @click.stop="handleApprove(item)">通过</view>
  43. </view>
  44. <view v-if="item.status === $DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ACCEPTANCE" class="text-color-3 f-size-32 edit">
  45. <view @click.stop="handleReturn(item)">驳回</view>
  46. </view>
  47. </view>-->
  48. </view>
  49. <view class="py3">
  50. <u-loadmore :status="status" />
  51. </view>
  52. </template>
  53. <template v-else>
  54. <view class="empty">
  55. <u-empty text="暂无数据" mode="list"></u-empty>
  56. </view>
  57. </template>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. export default {
  63. data() {
  64. return {
  65. list: [
  66. {
  67. name: '全部'
  68. },
  69. {
  70. name: '待接单'
  71. },
  72. {
  73. name: '进行中'
  74. },
  75. {
  76. name: '待验收'
  77. },
  78. {
  79. name: '待支付'
  80. }
  81. ],
  82. current: 0,
  83. // 加载更多
  84. status: 'loadmore',
  85. keyword: '',
  86. page: 1,
  87. limit: 10,
  88. type: '',
  89. loadMore: true,
  90. listData: [],
  91. statusMap: {},
  92. maskId: 0
  93. };
  94. },
  95. onPullDownRefresh() {
  96. // 请求结束取消刷新
  97. this.page = 1;
  98. this.loadMore = true;
  99. this.listData = [];
  100. this.initData();
  101. uni.stopPullDownRefresh();
  102. },
  103. onReachBottom() {
  104. if (this.loadMore) {
  105. this.page++;
  106. this.initData();
  107. }
  108. },
  109. onLoad() {
  110. this.statusMap = this.$DictCache.getLabelByValueMapByType(
  111. this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS
  112. );
  113. },
  114. onShow() {
  115. this.page = 1;
  116. this.loadMore = true;
  117. this.listData = [];
  118. this.initData();
  119. },
  120. onHide() {
  121. this.maskId = 0
  122. },
  123. methods: {
  124. showMask(id, e) {
  125. this.maskId = id
  126. // #ifdef H5
  127. e.preventDefault()
  128. // #endif
  129. },
  130. handleDel(id) {
  131. const that = this
  132. const params = []
  133. params.push(id)
  134. uni.showModal({
  135. title: '提示',
  136. content: '您确认删除吗?',
  137. success: (res) => {
  138. if (res.confirm) {
  139. this.$Http.deleteRepairApplicationForms(params).then(res => {
  140. uni.showToast({ title: '删除成功' })
  141. this.page = 1;
  142. this.loadMore = true;
  143. this.listData = [];
  144. this.initData();
  145. })
  146. } else if (res.cancel) { }
  147. }
  148. });
  149. },
  150. handleReturn(item) {
  151. const that = this;
  152. uni.showModal({
  153. title: '提示',
  154. content: '确认驳回?',
  155. success: function (res) {
  156. if (res.confirm) {
  157. uni.navigateTo({
  158. url: '/pages/repair/repair-return?id=' + item.id
  159. });
  160. }
  161. }
  162. });
  163. },
  164. // 通过
  165. handleApprove(item) {
  166. const that = this;
  167. uni.showModal({
  168. title: '提示',
  169. content: '确认通过?',
  170. success: function (res) {
  171. if (res.confirm) {
  172. that.$Http.approve(item).then((res) => {
  173. // console.log(res);
  174. that.initData();
  175. });
  176. }
  177. }
  178. });
  179. },
  180. handleClick() {
  181. uni.navigateTo({
  182. url: '/pages/repair-add/repair-add'
  183. });
  184. },
  185. // tab
  186. change(index) {
  187. this.current = index;
  188. this.type = index;
  189. this.page = 1;
  190. this.loadMore = true;
  191. this.listData = [];
  192. this.initData();
  193. },
  194. // 跳转详情
  195. handleDetail(id) {
  196. if (this.maskId != 0) return this.maskId = 0
  197. uni.navigateTo({
  198. url: '/pages/repair-detail/repair-detail?detailId=' + id
  199. });
  200. },
  201. // 点击搜索:重置分页后按关键词查询
  202. search() {
  203. this.page = 1;
  204. this.loadMore = true;
  205. this.listData = [];
  206. this.initData();
  207. },
  208. // 关键词搜索默认时间起点:近三个月,避免大表多列 LIKE 全表扫描,保证查询性能(后端按 apply_time 过滤)
  209. getSearchStartTime() {
  210. const d = new Date();
  211. d.setMonth(d.getMonth() - 3);
  212. return this.$BaseTool.Date.formatter(d, this.$BaseTool.Date.PICKER_NORM_DATETIME_PATTERN);
  213. },
  214. // 初始化
  215. initData() {
  216. const that = this;
  217. that.status = 'loading';
  218. const kw = (this.keyword || '').trim();
  219. this.$Http
  220. .getRepairApplicationFormPage({
  221. pageNum: this.page,
  222. pageSize: this.limit,
  223. keyword: kw,
  224. // 仅在关键词搜索时默认限定近三个月,普通列表加载行为保持不变
  225. searchStartTime: kw ? this.getSearchStartTime() : null,
  226. // status: that.$DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED,
  227. dataScope: {
  228. sortBy: 'asc, desc',
  229. sortName: 'status, apply_time'
  230. }
  231. })
  232. .then((res) => {
  233. const data = res.data.rows;
  234. if (data && data.length > 0 && data.length < that.limit) {
  235. that.status = 'nomore';
  236. that.loadMore = false;
  237. } else if (data.length == that.limit) {
  238. that.status = 'loadmore';
  239. } else {
  240. that.status = 'nomore';
  241. }
  242. that.listData = [...that.listData, ...data];
  243. });
  244. }
  245. }
  246. };
  247. </script>
  248. <style lang="less">
  249. page {
  250. background-color: #f4f4f4;
  251. }
  252. .box {
  253. border-radius: 20rpx;
  254. padding-right: 0;
  255. }
  256. .edit-box {
  257. padding: 0 30rpx;
  258. margin-top: 40rpx;
  259. .edit {
  260. padding: 8rpx 40rpx;
  261. border: 1px solid #ddd;
  262. border-radius: 20rpx;
  263. font-size: 26rpx;
  264. color: #666;
  265. margin-left: 30rpx;
  266. }
  267. }
  268. </style>