snatchingOrders.vue 7.0 KB

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