repair.vue 7.9 KB

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