repair-check.vue 7.7 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.userName
  29. }}</view>
  30. </view>
  31. <view class="f-size-26 text-color-6 f-weight-4 mt-2">{{
  32. item.applyTime
  33. }}</view>
  34. <view class="d-flex j-end edit-box">
  35. <view v-if="item.status === 4" class="text-color-3 f-size-32 edit">
  36. <view @click.stop="handleApprove(item)">通过</view>
  37. </view>
  38. <view v-if="item.status === 4" class="text-color-3 f-size-32 edit">
  39. <view @click.stop="handleReturn(item)">驳回</view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="py3">
  44. <u-loadmore :status="status" />
  45. </view>
  46. </template>
  47. <template v-else>
  48. <view class="empty">
  49. <u-empty text="暂无数据" mode="list"></u-empty>
  50. </view>
  51. </template>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. export default {
  57. data() {
  58. return {
  59. list: [
  60. {
  61. name: '全部'
  62. },
  63. {
  64. name: '待接单'
  65. },
  66. {
  67. name: '进行中'
  68. },
  69. {
  70. name: '待验收'
  71. },
  72. {
  73. name: '待支付'
  74. }
  75. ],
  76. current: 0,
  77. // 加载更多
  78. status: 'loadmore',
  79. page: 1,
  80. limit: 10,
  81. type: '',
  82. loadMore: true,
  83. listData: [],
  84. statusMap: {},
  85. maskId: 0
  86. };
  87. },
  88. onPullDownRefresh() {
  89. // 请求结束取消刷新
  90. this.page = 1;
  91. this.loadMore = true;
  92. this.listData = [];
  93. this.initData();
  94. uni.stopPullDownRefresh();
  95. },
  96. onReachBottom() {
  97. if (this.loadMore) {
  98. this.page++;
  99. this.initData();
  100. }
  101. },
  102. onLoad() {
  103. this.statusMap = this.$DictCache.getLabelByValueMapByType(
  104. this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS
  105. );
  106. },
  107. onShow() {
  108. this.page = 1;
  109. this.loadMore = true;
  110. this.listData = [];
  111. this.initData();
  112. },
  113. onHide() {
  114. this.maskId = 0
  115. },
  116. methods: {
  117. showMask(id, e) {
  118. this.maskId = id
  119. // #ifdef H5
  120. e.preventDefault()
  121. // #endif
  122. },
  123. handleDel(id) {
  124. const that = this
  125. const params = []
  126. params.push(id)
  127. uni.showModal({
  128. title: '提示',
  129. content: '您确认删除吗?',
  130. success: (res) => {
  131. if (res.confirm) {
  132. this.$Http.deleteRepairApplicationForms(params).then(res => {
  133. uni.showToast({ title: '删除成功' })
  134. this.page = 1;
  135. this.loadMore = true;
  136. this.listData = [];
  137. this.initData();
  138. })
  139. } else if (res.cancel) { }
  140. }
  141. });
  142. },
  143. handleReturn(item) {
  144. const that = this;
  145. uni.showModal({
  146. title: '提示',
  147. content: '确认驳回?',
  148. success: function (res) {
  149. if (res.confirm) {
  150. uni.navigateTo({
  151. url: '/pages/repair/repair-return?id=' + item.id
  152. });
  153. }
  154. }
  155. });
  156. },
  157. // 通过
  158. handleApprove(item) {
  159. const that = this;
  160. uni.showModal({
  161. title: '提示',
  162. content: '确认通过?',
  163. success: function (res) {
  164. if (res.confirm) {
  165. that.$Http.approve(item).then((res) => {
  166. uni.navigateTo({
  167. url: '/pages/repair-check/repair-check'
  168. });
  169. });
  170. }
  171. }
  172. });
  173. },
  174. handleClick() {
  175. uni.navigateTo({
  176. url: '/pages/repair-add/repair-add'
  177. });
  178. },
  179. // tab
  180. change(index) {
  181. this.current = index;
  182. this.type = index;
  183. this.page = 1;
  184. this.loadMore = true;
  185. this.listData = [];
  186. this.initData();
  187. },
  188. // 跳转详情
  189. handleDetail(id) {
  190. if (this.maskId != 0) return this.maskId = 0
  191. uni.navigateTo({
  192. url: '/pages/repair-check/repair-detail?detailId=' + id
  193. });
  194. },
  195. // 初始化
  196. initData() {
  197. const that = this;
  198. that.status = 'loading';
  199. this.$Http
  200. .getRepairApplicationFormPage({
  201. pageNum: this.page,
  202. pageSize: this.limit,
  203. searchType: 3,
  204. filter: 0,
  205. dataScope: {
  206. sortBy: 'desc',
  207. sortName: 'update_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>