index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <view v-if="!['待接单', '已完成'].includes(content.where.status)" style="background-color: #fff;">
  3. <up-tabs lineColor="#3874F6" :scrollable="false" :list="[{
  4. name: '待开始'
  5. }, {
  6. name: '进行中'
  7. }, {
  8. name: '已提交',
  9. value: '提交'
  10. }]" @click="tabClick" />
  11. </view>
  12. <My_listbox ref="listBox" :empty="!list.length" @getlist="getList">
  13. <view style="height: 18rpx;" />
  14. <navigator class="item" v-for="item in list" :key="item.sa_workorderid"
  15. :url="'/pages/workOrder/detail?id=' + item.sa_workorderid" hover-class="navigator-hover">
  16. <view class="head">
  17. <view class="tag"
  18. :style="{ 'background': { '安装': '#70B603', '维修': '#D9001B', '清洁': '#3874F6', '清洗': '#3874F6' }[item.type] || '#999999' }">
  19. {{ item.type }}
  20. </view>
  21. <view class="time">
  22. {{ item.createdate }}
  23. </view>
  24. </view>
  25. <view class="address">
  26. {{ item.address }}
  27. </view>
  28. <view class="user">
  29. {{ item.customername + ' ' + item.customerphonenumber }}
  30. </view>
  31. <view v-if="content.where.status != '已完结'" class="but-box" @click.stop>
  32. <view class="but-box-item">
  33. <My-button :customStyle="{
  34. 'background-color': '#FFFFFF',
  35. 'color': '#3874F6',
  36. height: '70rpx',
  37. }" frontIcon="icon-bodadianhua1" text="电话" :phonenumber="item.customerphonenumber" />
  38. </view>
  39. <view v-if="content.where.status == '待接单'" class="but-box-item" @click="openModel(item)">
  40. <My-button :customStyle="{
  41. height: '70rpx',
  42. }" frontIcon="icon-dianhua" text="接单" />
  43. </view>
  44. <navigator v-else :url="'/pages/workOrder/detail?id=' + item.sa_workorderid" class="but-box-item">
  45. <My-button :customStyle="{
  46. height: '70rpx',
  47. }" frontIcon="icon-dianhua" text="报工" />
  48. </navigator>
  49. </view>
  50. </navigator>
  51. </My_listbox>
  52. <up-modal negativeTop="100" :show="takeOrderShow" title="是否确认接单?" showCancelButton @confirm="takeOrders"
  53. @cancel="takeOrderShow = false" ref="uModal" :asyncClose="true"></up-modal>
  54. </template>
  55. <script setup>
  56. import { ref, reactive, getCurrentInstance } from 'vue';
  57. const { $Http } = getCurrentInstance().proxy;
  58. import { onLoad, onShow } from '@dcloudio/uni-app';
  59. const listBox = ref(null);
  60. const content = reactive({
  61. loading: false,
  62. isadmin: 0,
  63. "pageNumber": 1,
  64. "pageSize": 20,
  65. "where": {
  66. "status": '',
  67. "condition": ""
  68. }
  69. });
  70. const list = ref([])
  71. function tabClick(e) {
  72. content.where.status = e.value || e.name;
  73. getList(true);
  74. }
  75. onLoad((options) => {
  76. switch (options.type) {
  77. case '待接单':
  78. uni.setNavigationBarTitle({
  79. title: '待接工单'
  80. });
  81. content.where.status = options.type;
  82. break;
  83. case '进行中':
  84. uni.setNavigationBarTitle({
  85. title: '进行中工单'
  86. });
  87. content.where.status = '待开始';
  88. break;
  89. case '已完结':
  90. uni.setNavigationBarTitle({
  91. title: '已完结工单'
  92. });
  93. content.where.status = '已完成';
  94. break;
  95. }
  96. getList();
  97. });
  98. onShow(() => {
  99. if (content.pageNumber != 1) $Http.updateList(content, getList)
  100. })
  101. function getList(init = false) {
  102. if (content.loading) return;
  103. if (init) content.pageNumber = 1;
  104. content.loading = true;
  105. $Http.basic({
  106. "id": "20230208140203",
  107. content
  108. }).then(res => {
  109. console.log("获取列表", res)
  110. content.loading = false;
  111. listBox.value.refreshToComplete();
  112. listBox.value.setHeight();
  113. if (res.code == 1) {
  114. list.value = reactive(res.firstPage ? res.data : list.value.concat(res.data));
  115. content.pageTotal = res.pageTotal;
  116. content.pageNumber = res.pageNumber;
  117. } else {
  118. if (res.msg) uni.showToast({
  119. title: res.msg,
  120. icon: 'none'
  121. });
  122. }
  123. })
  124. }
  125. let takeOrderShow = ref(false);
  126. let takeItem = null;
  127. function openModel(item) {
  128. takeItem = item;
  129. takeOrderShow.value = true;
  130. }
  131. function takeOrders() {
  132. $Http.basic({
  133. id: 20230210101103,
  134. "content": {
  135. "sa_workorderid": takeItem.sa_workorderid
  136. }
  137. }).then(res => {
  138. console.log("接单结果", res)
  139. if (res.code == 1) {
  140. takeOrderShow.value = false;
  141. wx.navigateTo({
  142. url: '/pages/workOrder/detail?id=' + takeItem.sa_workorderid,
  143. success: (result) => {
  144. uni.showToast({
  145. title: '接单成功',
  146. icon: 'none'
  147. });
  148. },
  149. })
  150. $Http.updateList(content, getList)
  151. } else {
  152. if (res.msg) uni.showToast({
  153. title: res.msg,
  154. icon: 'none'
  155. });
  156. }
  157. })
  158. }
  159. </script>
  160. <style lang="scss" scoped>
  161. .item {
  162. width: 690rpx;
  163. background: #FFFFFF;
  164. box-shadow: 0rpx 4rpx 16rpx 2rpx rgba(150, 157, 165, 0.16);
  165. margin: 0 auto 20rpx;
  166. padding: 20rpx 40rpx;
  167. box-sizing: border-box;
  168. .head {
  169. display: flex;
  170. align-items: center;
  171. justify-content: space-between;
  172. .tag {
  173. font-family: PingFang SC, PingFang SC;
  174. font-size: 24rpx;
  175. color: #FFFFFF;
  176. padding: 8rpx 20rpx;
  177. }
  178. .time {
  179. font-family: Microsoft YaHei, Microsoft YaHei;
  180. font-size: 24rpx;
  181. color: #999999;
  182. }
  183. }
  184. .address {
  185. line-height: 38rpx;
  186. font-family: Microsoft YaHei, Microsoft YaHei;
  187. font-size: 28rpx;
  188. color: #333333;
  189. margin-top: 20rpx;
  190. }
  191. .user {
  192. line-height: 32rpx;
  193. font-family: Microsoft YaHei, Microsoft YaHei;
  194. font-size: 24rpx;
  195. color: #999999;
  196. margin-top: 20rpx;
  197. }
  198. .but-box {
  199. display: flex;
  200. align-items: center;
  201. justify-content: space-around;
  202. margin-top: 20rpx;
  203. .but-box-item {
  204. width: 40%;
  205. }
  206. }
  207. }
  208. </style>