work-order.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <view>
  3. <!-- <view class="border-bottom">
  4. <u-tabs
  5. class="p-fixed left0 right0 zIndex"
  6. :list="list"
  7. :is-scroll="false"
  8. :current="current"
  9. @change="change"
  10. ></u-tabs>
  11. </view> -->
  12. <view>
  13. <template v-if="listData.length > 0">
  14. <view
  15. class="mx3 my2 p3 bg-color-white box p-relative"
  16. v-for="(item, index) in listData"
  17. :key="index"
  18. @tap="handleDetail(item)"
  19. @longpress="showMask(item.id, $event)"
  20. >
  21. <common-mask
  22. :item="item"
  23. :maskId="maskId"
  24. @hide="maskId = 0"
  25. @del="handleDel(item.id)"
  26. />
  27. <view class="d-flex j-between border-bottom pb-2 a-center">
  28. <view class="text-color-b f-size-26">{{
  29. item.no
  30. }}</view>
  31. <view class="f-size-24 state-orange">{{
  32. statusMap[item.status]
  33. }}</view>
  34. </view>
  35. <view class="mt-2 d-flex j-between">
  36. <view class="text-color-3 f-size-32 f-weight-bold">{{
  37. item.sbName
  38. }} ({{ item.sbNo }})</view>
  39. </view>
  40. <view class="f-size-26 text-color-6 f-weight-4 mt-2">{{
  41. item.applyTime
  42. }}</view>
  43. <view class="d-flex j-end edit-box">
  44. <view
  45. class="text-color-3 f-size-32 edit"
  46. v-if="
  47. [
  48. $DictCache.VALUE
  49. .REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED,
  50. $DictCache.VALUE
  51. .REPAIR_APPLICATION_FORM_STATUS.REBACK,
  52. ].includes(item.status)
  53. "
  54. >
  55. <view @click.stop="handleDealEdit(item)">接收</view>
  56. </view>
  57. <!-- 仅维修中(状态2)可转派,与后端 transfer 接口状态校验保持一致 -->
  58. <view
  59. class="text-color-3 f-size-32 edit"
  60. v-if="
  61. item.status ===
  62. $DictCache.VALUE
  63. .REPAIR_APPLICATION_FORM_STATUS.PROCESSING
  64. "
  65. >
  66. <view
  67. @click.stop="handleDispatching(item)"
  68. >转派</view
  69. >
  70. </view>
  71. <view
  72. class="text-color-3 f-size-32 edit"
  73. v-if="
  74. [
  75. $DictCache.VALUE
  76. .REPAIR_APPLICATION_FORM_STATUS
  77. .PROCESSING,
  78. $DictCache.VALUE
  79. .REPAIR_APPLICATION_FORM_STATUS.REBACK,
  80. ].includes(item.status)
  81. "
  82. >
  83. <view @click.stop="handleEdit(item)">维修</view>
  84. </view>
  85. </view>
  86. </view>
  87. <view class="py3">
  88. <u-loadmore :status="status" />
  89. </view>
  90. </template>
  91. <template v-else>
  92. <view class="empty">
  93. <u-empty text="暂无数据" mode="list"></u-empty>
  94. </view>
  95. </template>
  96. </view>
  97. <u-tabbar
  98. :list="tabbar"
  99. :mid-button="true"
  100. active-color="#0082ff"
  101. ></u-tabbar>
  102. </view>
  103. </template>
  104. <script>
  105. export default {
  106. data() {
  107. return {
  108. list: [
  109. {
  110. name: '全部'
  111. },
  112. {
  113. name: '待接单'
  114. },
  115. {
  116. name: '维修中'
  117. },
  118. {
  119. name: '待验收'
  120. },
  121. {
  122. name: '已完成'
  123. }
  124. ],
  125. current: 0,
  126. // 加载更多
  127. status: 'loadmore',
  128. page: 1,
  129. limit: 10,
  130. type: '',
  131. loadMore: true,
  132. listData: [],
  133. statusMap: {},
  134. sourceMap: {},
  135. maskId: 0,
  136. tabbar: [
  137. {
  138. iconPath: '/static/tabars/home.png',
  139. pagePath: '/pages/home/home',
  140. selectedIconPath: '/static/tabars/home_s.png',
  141. text: '首页'
  142. },
  143. {
  144. iconPath: '/static/tabars/tiding.png',
  145. pagePath: '/pages/tidings/tidings',
  146. selectedIconPath: '/static/tabars/tiding_s.png',
  147. text: '消息'
  148. },
  149. {
  150. iconPath: '/static/tabars/publish.png',
  151. pagePath: '/pages/middle/middle',
  152. selectedIconPath: '/static/tabars/publish.png',
  153. text: '报修',
  154. midButton: true
  155. },
  156. {
  157. iconPath: '/static/tabars/order.png',
  158. pagePath: '/pages/work-order/work-order',
  159. selectedIconPath: '/static/tabars/order_s.png',
  160. text: '工单'
  161. },
  162. {
  163. iconPath: '/static/tabars/mine.png',
  164. pagePath: '/pages/my/my',
  165. selectedIconPath: '/static/tabars/mine_s.png',
  166. text: '我的'
  167. }
  168. ]
  169. };
  170. },
  171. onPullDownRefresh() {
  172. // 请求结束取消刷新
  173. this.page = 1;
  174. this.loadMore = true;
  175. this.listData = [];
  176. this.initData();
  177. uni.stopPullDownRefresh();
  178. },
  179. onReachBottom() {
  180. if (this.loadMore) {
  181. this.page++;
  182. this.initData();
  183. }
  184. },
  185. onLoad() {
  186. this.statusMap = this.$DictCache.getLabelByValueMapByType(
  187. this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS
  188. );
  189. this.sourceMap = this.$DictCache.getLabelByValueMapByType(
  190. this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE
  191. );
  192. },
  193. onShow() {
  194. this.page = 1;
  195. this.loadMore = true;
  196. this.listData = [];
  197. this.initData();
  198. },
  199. onHide() {
  200. this.maskId = 0;
  201. },
  202. methods: {
  203. showMask(id, e) {
  204. this.maskId = id;
  205. // #ifdef H5
  206. e.preventDefault();
  207. // #endif
  208. },
  209. handleDel(id) {
  210. const that = this;
  211. const params = [];
  212. params.push(id);
  213. uni.showModal({
  214. title: '提示',
  215. content: '您确认删除吗?',
  216. success: (res) => {
  217. if (res.confirm) {
  218. this.$Http.deleteRepairForms(params).then((res) => {
  219. uni.showToast({ title: '删除成功' });
  220. this.page = 1;
  221. this.loadMore = true;
  222. this.listData = [];
  223. this.initData();
  224. });
  225. } else if (res.cancel) {
  226. }
  227. }
  228. });
  229. },
  230. handleDealEdit(item) {
  231. const that = this;
  232. uni.showModal({
  233. title: '提示',
  234. content: '确认接收该维修任务?',
  235. success: function (res) {
  236. if (res.confirm) {
  237. that.$Http.repairFormDeal(item).then((res) => {
  238. that.page = 1;
  239. that.loadMore = true;
  240. that.listData = [];
  241. that.initData();
  242. });
  243. }
  244. }
  245. });
  246. },
  247. handleDispatching(item) {
  248. uni.showModal({
  249. title: '提示',
  250. content: '确认转派?',
  251. success: function (res) {
  252. if (res.confirm) {
  253. console.log('用户点击确定');
  254. uni.navigateTo({
  255. url: '/pages/deliver-add/deliver-add?id=' + item.id
  256. });
  257. } else if (res.cancel) {
  258. console.log('用户点击取消');
  259. }
  260. }
  261. });
  262. },
  263. handleEdit(item) {
  264. uni.navigateTo({
  265. url: '/pages/service-add/service-add?id=' + item.id
  266. });
  267. },
  268. // tab
  269. change(index) {
  270. this.current = index;
  271. // type 做相应改变
  272. this.type = index;
  273. this.page = 1;
  274. this.loadMore = true;
  275. this.listData = [];
  276. this.initData();
  277. },
  278. // 跳转详情
  279. handleDetail(item) {
  280. // if (index == 0) {
  281. // uni.navigateTo({
  282. // url: '../service-add/service-add'
  283. // });
  284. // } else {
  285. // uni.navigateTo({
  286. // url: '../service-detail/service-detail'
  287. // });
  288. // }
  289. if (this.maskId != 0) return (this.maskId = 0);
  290. uni.navigateTo({
  291. url: '/pages/service-detail/service-detail?id=' + item.id
  292. });
  293. },
  294. initData() {
  295. const that = this;
  296. that.status = 'loading';
  297. this.$Http
  298. .getRepairApplicationFormPage({
  299. pageNum: this.page,
  300. pageSize: this.limit,
  301. filter: 0,
  302. searchType: 2,
  303. dataScope: {
  304. sortBy: 'desc',
  305. sortName: 'update_time'
  306. }
  307. })
  308. .then((res) => {
  309. const data = res.data.rows;
  310. console.log(res);
  311. if (data && data.length > 0 && data.length < that.limit) {
  312. that.status = 'nomore';
  313. that.loadMore = false;
  314. } else if (data.length == that.limit) {
  315. that.status = 'loadmore';
  316. } else {
  317. that.status = 'nomore';
  318. }
  319. that.listData = [...that.listData, ...data];
  320. });
  321. }
  322. }
  323. };
  324. </script>
  325. <style lang="scss">
  326. page {
  327. background-color: #f4f4f4;
  328. }
  329. .box {
  330. padding-right: 0;
  331. border-radius: 20rpx;
  332. }
  333. .edit-box {
  334. padding: 0 30rpx;
  335. margin-top: 40rpx;
  336. .edit {
  337. padding: 8rpx 40rpx;
  338. border: 1px solid #ddd;
  339. border-radius: 20rpx;
  340. font-size: 26rpx;
  341. color: #666;
  342. margin-left: 30rpx;
  343. }
  344. }
  345. </style>