service.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <view>
  3. <common-tabs :list="list" :current="current" @change="change" />
  4. <view class="p-top8">
  5. <template v-if="listData.length > 0">
  6. <view class="mx3 my2 p3 bg-color-white box p-relative" v-for="(item, index) in listData" :key="index"
  7. @tap="handleDetail(item)" @longpress="showMask(item.id, $event)">
  8. <common-mask :item="item" :maskId="maskId" @hide="maskId = 0" @del="handleDel(item.id)" />
  9. <view class="d-flex j-between border-bottom pb-2 a-center">
  10. <view class="text-color-b f-size-26">{{ item.sbName }}</view>
  11. <view class="f-size-24 state-orange">{{
  12. statusMap[item.status]
  13. }}</view>
  14. </view>
  15. <view class="mt-2 d-flex j-between">
  16. <view class="text-color-3 f-size-32 f-weight-bold">{{
  17. item.actualUser
  18. }}-{{
  19. item.sbCph
  20. }}</view>
  21. </view>
  22. <view class="f-size-26 text-color-6 f-weight-4 mt-2">{{
  23. item.applyTime
  24. }}</view>
  25. <view class="d-flex j-end edit-box">
  26. <view class="text-color-3 f-size-32 edit" v-if="
  27. item.status ===
  28. $DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED">
  29. <view @click.stop="handleDealEdit(item)">接收</view>
  30. </view>
  31. <!-- 仅维修中(状态2)可转派,与后端 transfer 接口状态校验保持一致;审核中(状态4)等状态不显示 -->
  32. <view class="text-color-3 f-size-32 edit" v-if="
  33. item.status ===
  34. $DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING &&
  35. !item.fourRepairUser && item.repairUserId
  36. ">
  37. <view @click.stop="handleDispatching(item)">转派</view>
  38. </view>
  39. <view class="text-color-3 f-size-32 edit" v-if="
  40. [
  41. $DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING,
  42. $DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REBACK,
  43. ].includes(item.status)
  44. ">
  45. <view @click.stop="handleEdit(item)">完成</view>
  46. </view>
  47. <view class="text-color-3 f-size-32 edit" v-if="
  48. item.status ===
  49. $DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.WAIT_SUBMIT ||
  50. item.status ===
  51. $DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REBACK
  52. ">
  53. <view @click.stop="handleExamine(item)">提交审核</view>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="py3">
  58. <u-loadmore :status="status" />
  59. </view>
  60. </template>
  61. <template v-else>
  62. <view class="empty">
  63. <u-empty text="暂无数据" mode="list"></u-empty>
  64. </view>
  65. </template>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. export default {
  71. data() {
  72. return {
  73. list: [
  74. ],
  75. current: 0,
  76. // 加载更多
  77. status: 'loadmore',
  78. page: 1,
  79. limit: 10,
  80. sbId: '',
  81. type: 0,
  82. filter: -1,
  83. loadMore: true,
  84. listData: [],
  85. statusMap: {},
  86. sourceMap: {},
  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(options) {
  105. this.sbId = options.sbId
  106. this.filter = options.filter
  107. this.statusMap = this.$DictCache.getLabelByValueMapByType(
  108. this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS
  109. );
  110. this.sourceMap = this.$DictCache.getLabelByValueMapByType(
  111. this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE
  112. );
  113. this.list = [{ label: '全部', value: '' }].concat(
  114. this.$DictCache.getChildrenList(this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
  115. );
  116. },
  117. onShow() {
  118. this.page = 1;
  119. this.loadMore = true;
  120. this.listData = [];
  121. this.initData();
  122. },
  123. onHide() {
  124. this.maskId = 0
  125. },
  126. methods: {
  127. showMask(id, e) {
  128. this.maskId = id
  129. // #ifdef H5
  130. e.preventDefault()
  131. // #endif
  132. },
  133. // 提交审批验收
  134. handleExamine(item) {
  135. var that = this;
  136. uni.showModal({
  137. title: '提示',
  138. content: '确认提交审核?',
  139. success: function (res) {
  140. if (res.confirm) {
  141. that.$Http
  142. .examine({
  143. id: item.id
  144. })
  145. .then((res) => {
  146. uni.showToast({
  147. title: '已提交,请等待审核'
  148. });
  149. that.initData();
  150. });
  151. }
  152. }
  153. });
  154. },
  155. handleDel(id) {
  156. const that = this;
  157. const params = [];
  158. params.push(id);
  159. uni.showModal({
  160. title: '提示',
  161. content: '您确认删除吗?',
  162. success: (res) => {
  163. if (res.confirm) {
  164. this.$Http.deleteRepairForms(params).then((res) => {
  165. uni.showToast({ title: '删除成功' });
  166. this.page = 1;
  167. this.loadMore = true;
  168. this.listData = [];
  169. this.initData();
  170. });
  171. } else if (res.cancel) {
  172. }
  173. }
  174. });
  175. },
  176. handleDealEdit(item) {
  177. const that = this;
  178. uni.showModal({
  179. title: '提示',
  180. content: '确认接收该维修任务?',
  181. success: function (res) {
  182. if (res.confirm) {
  183. that.$Http.repairFormDeal(item).then((res) => {
  184. that.page = 1;
  185. that.loadMore = true;
  186. that.listData = [];
  187. that.initData();
  188. });
  189. }
  190. }
  191. });
  192. },
  193. handleDispatching(item) {
  194. uni.navigateTo({
  195. url: '/pages/repair-detail/transfer?id=' + item.id
  196. });
  197. },
  198. handleEdit(item) {
  199. uni.navigateTo({
  200. url: '/pages/service-add/service-add?id=' + item.id
  201. });
  202. },
  203. // tab
  204. change(index) {
  205. this.current = index;
  206. // type 做相应改变
  207. this.type = index;
  208. this.page = 1;
  209. this.loadMore = true;
  210. this.listData = [];
  211. this.initData();
  212. },
  213. // 跳转详情
  214. handleDetail(item) {
  215. // if (index == 0) {
  216. // uni.navigateTo({
  217. // url: '../service-add/service-add'
  218. // });
  219. // } else {
  220. // uni.navigateTo({
  221. // url: '../service-detail/service-detail'
  222. // });
  223. // }
  224. if (this.maskId != 0) return this.maskId = 0
  225. uni.navigateTo({
  226. url: '/pages/service-detail/service-detail?id=' + item.id
  227. });
  228. },
  229. initData() {
  230. const that = this;
  231. that.status = 'loading';
  232. this.$Http
  233. .getRepairApplicationFormPage({
  234. pageNum: this.page,
  235. pageSize: this.limit,
  236. sbId: this.sbId,
  237. searchType: 2,
  238. filter: this.filter,
  239. status: this.type,
  240. dataScope: {
  241. sortBy: 'asc, desc',
  242. sortName: 'status, apply_time'
  243. }
  244. })
  245. .then((res) => {
  246. const data = res.data.rows;
  247. console.log(res);
  248. if (data && data.length > 0 && data.length < that.limit) {
  249. that.status = 'nomore';
  250. that.loadMore = false;
  251. } else if (data.length === that.limit) {
  252. that.status = 'loadmore';
  253. } else {
  254. that.status = 'nomore';
  255. }
  256. that.listData = [...that.listData, ...data];
  257. });
  258. }
  259. }
  260. };
  261. </script>
  262. <style lang="scss">
  263. page {
  264. background-color: #f4f4f4;
  265. }
  266. .box {
  267. padding-right: 0;
  268. border-radius: 20rpx;
  269. }
  270. .edit-box {
  271. padding: 0 30rpx;
  272. margin-top: 40rpx;
  273. .edit {
  274. padding: 8rpx 40rpx;
  275. border: 1px solid #ddd;
  276. border-radius: 20rpx;
  277. font-size: 26rpx;
  278. color: #666;
  279. margin-left: 30rpx;
  280. }
  281. }
  282. </style>