index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <view v-if="!['待接单', '已完工'].includes(content.where.status)" style="background-color: #fff;">
  3. <up-tabs lineColor="#3874F6" :current="current" :scrollable="false" :list="tabList" @click="tabClick" />
  4. </view>
  5. <My_listbox ref="listBox" :empty="!list.length" @getlist="getList">
  6. <view style="height: 18rpx;" />
  7. <navigator class="item" v-for="item in list" :key="item.sa_workorderid" url="#" @click="toDetail(item)"
  8. hover-class="navigator-hover">
  9. <view class="head">
  10. <view style="display: flex;">
  11. <view class="tag" :style="{
  12. 'color': { '待接单': '#3874F6', '待开始': '#3874F6', '待服务': '#F56C6C', '进行中': '#67C23A', '提交': '#171919', '已完工': '#171919' }[item.status] || '#999999',
  13. 'background': {
  14. '待接单': '#E6F0FF',
  15. '待开始': '#E6F0FF',
  16. '待服务': '#FFECEF',
  17. '进行中': '#F0F9EB',
  18. '提交': '#F7F7F7',
  19. '已完工': '#F7F7F7' // 与提交共用浅灰背景
  20. }[item.status] || '#F5F5F5',
  21. marginRight: '20rpx',
  22. }">
  23. {{ item.status }}
  24. </view>
  25. <view class="tag" :style="{
  26. 'background': { '安装': '#E8F8D5', '维修': '#FFE2E5', '清洁': '#E2EBFF', '清洗': '#E2EBFF' }[item.type] || '#F0F0F0',
  27. 'color': { '安装': '#4B8E00', '维修': '#B00016', '清洁': '#2A5AD9', '清洗': '#2A5AD9' }[item.type] || '#333333'
  28. }">
  29. {{ item.type }}
  30. </view>
  31. </view>
  32. <view class="time">
  33. {{ item.createdate }}
  34. </view>
  35. </view>
  36. <view class="address">
  37. 产品:{{ item.itemname }}
  38. </view>
  39. <view class="address">
  40. 型号:{{ item.model }}
  41. </view>
  42. <view class="address">
  43. 备注:{{ item.remarks || '--' }}
  44. </view>
  45. <view class="address">
  46. 地址:{{ item.address }}
  47. </view>
  48. <view class="user">
  49. 现场联系人:{{ item.scenecontact + ' ' + item.scenecontactphonenumber }}
  50. </view>
  51. <view v-if="content.where.status != '已完工'" class="but-box" @click.stop>
  52. <view class="but-box-item">
  53. <My-button :customStyle="{
  54. 'background-color': '#FFFFFF',
  55. 'color': '#3874F6',
  56. height: '70rpx',
  57. }" frontIcon="icon-bodadianhua1" text="电话" :phonenumber="item.scenecontactphonenumber" />
  58. </view>
  59. <view v-if="content.where.status == '待接单'" class="but-box-item" @click="openModel(item)">
  60. <My-button :customStyle="{
  61. height: '70rpx',
  62. }" frontIcon="icon-jiedan" text="接单" />
  63. </view>
  64. <view v-if="content.where.status == '提交'" class="but-box-item">
  65. <My-button @onClick="completion(item)" :customStyle="{
  66. height: '70rpx',
  67. }" text="确认完工" />
  68. </view>
  69. <navigator v-if="content.where.status != '待接单' && content.where.status != '提交'"
  70. :url="'/pages/workOrder/detail?id=' + item.sa_workorderid" class="but-box-item">
  71. <My-button :customStyle="{
  72. height: '70rpx',
  73. }" frontIcon="icon-jiedan" text="报工" />
  74. </navigator>
  75. </view>
  76. </navigator>
  77. </My_listbox>
  78. <up-modal negativeTop="100" :show="takeOrderShow" title="是否确认接单?" showCancelButton @confirm="takeOrders"
  79. @cancel="takeOrderShow = false" ref="uModal" :asyncClose="true"></up-modal>
  80. </template>
  81. <script setup>
  82. import { ref, reactive, getCurrentInstance } from 'vue';
  83. const { $Http } = getCurrentInstance().proxy;
  84. import { onLoad, onShow } from '@dcloudio/uni-app';
  85. // 完成工单
  86. function completion(item) {
  87. uni.showModal({
  88. title: '提示',
  89. confirmText: '确认完工',
  90. content: '请确认工单内容,完工后不可修改!',
  91. success: ({ confirm }) => {
  92. if (confirm) {
  93. $Http.basic({
  94. id: 20230209144903,
  95. "content": {
  96. "sa_workorderid": item.sa_workorderid
  97. }
  98. }).then(res => {
  99. console.log("提交结果", res)
  100. uni.showToast({
  101. title: res.code == 1 ? '完工成功' : res.msg,
  102. icon: 'none'
  103. });
  104. if (res.code == 1) getList(true);
  105. })
  106. }
  107. },
  108. })
  109. }
  110. function toDetail(item) {
  111. if (item.status == '待开始') {
  112. uni.navigateTo({
  113. url: '/pages/workOrder/changeMsg?id=' + item.sa_workorderid,
  114. })
  115. } else {
  116. uni.navigateTo({
  117. url: '/pages/workOrder/detail?id=' + item.sa_workorderid,
  118. })
  119. }
  120. }
  121. const listBox = ref(null);
  122. const content = reactive({
  123. "nocache": true,
  124. loading: false,
  125. isadmin: 0,
  126. "pageNumber": 1,
  127. "pageSize": 20,
  128. "where": {
  129. "status": '',
  130. "condition": ""
  131. }
  132. });
  133. const list = ref([])
  134. function tabClick(e) {
  135. content.where.status = e.value || e.name;
  136. getList(true);
  137. listBox.value.backToTop()
  138. }
  139. onLoad((options) => {
  140. switch (options.type) {
  141. case '待接单':
  142. uni.setNavigationBarTitle({
  143. title: '待接工单'
  144. });
  145. content.where.status = options.type;
  146. break;
  147. case '进行中':
  148. uni.setNavigationBarTitle({
  149. title: '进行中工单'
  150. });
  151. content.where.status = '进行中';
  152. break;
  153. case '已完工':
  154. uni.setNavigationBarTitle({
  155. title: '已完工工单'
  156. });
  157. content.where.status = '已完工';
  158. break;
  159. }
  160. getList();
  161. getBadge();
  162. });
  163. onShow(() => {
  164. if (content.pageNumber != 1) {
  165. $Http.updateList(content, getList)
  166. getBadge();
  167. }
  168. })
  169. function getList(init = false) {
  170. if (content.loading) return;
  171. if (init) content.pageNumber = 1;
  172. content.loading = true;
  173. $Http.basic({
  174. "id": "20230208140203",
  175. content
  176. }).then(res => {
  177. console.log("获取列表", res)
  178. content.loading = false;
  179. listBox.value.refreshToComplete();
  180. listBox.value.setHeight();
  181. if (res.code == 1) {
  182. list.value = reactive(res.firstPage ? res.data : list.value.concat(res.data));
  183. content.pageTotal = res.pageTotal;
  184. content.pageNumber = res.pageNumber;
  185. } else {
  186. if (res.msg) uni.showToast({
  187. title: res.msg,
  188. icon: 'none'
  189. });
  190. }
  191. })
  192. }
  193. let tabList = ref([
  194. {
  195. name: '待开始',
  196. },
  197. {
  198. name: '进行中',
  199. },
  200. {
  201. name: '已提交',
  202. value: '提交'
  203. }
  204. ]),
  205. current = ref(1);
  206. function getBadge() {
  207. return
  208. if (!['待接单', '已完工'].includes(content.where.status)) Promise.all(
  209. tabList.value.map(v =>
  210. $Http.basic({
  211. "id": "20230208140203", "content":
  212. { "pageNumber": 1, "pageSize": 0, "nocache": true, "where": { "status": v.value || v.name } }
  213. })
  214. )
  215. ).then(res => {
  216. let changeCurrent = false;
  217. res.forEach((v, index) => {
  218. let value = v.code !== 0 ? v.total : 0
  219. tabList.value[index].badge = {
  220. value
  221. }
  222. if (tabList.value[index].name == '进行中' && value == 0) changeCurrent = true;
  223. })
  224. if (changeCurrent) {
  225. let index = tabList.value.findIndex(v => v.badge.value > 0);
  226. current.value = index == -1 ? 0 : index;
  227. content.where.status = tabList.value[current.value].value || tabList.value[current.value].name;
  228. getList(true);
  229. }
  230. })
  231. }
  232. let takeOrderShow = ref(false);
  233. let takeItem = null;
  234. function openModel(item) {
  235. takeItem = item;
  236. takeOrderShow.value = true;
  237. }
  238. function takeOrders() {
  239. $Http.basic({
  240. id: 20230210101103,
  241. "content": {
  242. "sa_workorderid": takeItem.sa_workorderid
  243. }
  244. }).then(res => {
  245. console.log("接单结果", res)
  246. if (res.code == 1) {
  247. takeOrderShow.value = false;
  248. uni.navigateTo({
  249. url: '/pages/workOrder/detail?id=' + takeItem.sa_workorderid,
  250. success: (result) => {
  251. uni.showToast({
  252. title: '接单成功',
  253. icon: 'none'
  254. });
  255. },
  256. })
  257. $Http.updateList(content, getList)
  258. } else {
  259. if (res.msg) uni.showToast({
  260. title: res.msg,
  261. icon: 'none'
  262. });
  263. }
  264. })
  265. }
  266. </script>
  267. <style lang="scss" scoped>
  268. .item {
  269. width: 690rpx;
  270. background: #FFFFFF;
  271. box-shadow: 0rpx 4rpx 16rpx 2rpx rgba(150, 157, 165, 0.16);
  272. margin: 0 auto 20rpx;
  273. padding: 20rpx 40rpx;
  274. box-sizing: border-box;
  275. border-radius: 16rpx;
  276. .head {
  277. display: flex;
  278. align-items: center;
  279. justify-content: space-between;
  280. .tag {
  281. font-family: PingFang SC, PingFang SC;
  282. font-size: 24rpx;
  283. padding: 8rpx 20rpx;
  284. border-radius: 8rpx;
  285. }
  286. .time {
  287. font-family: Microsoft YaHei, Microsoft YaHei;
  288. font-size: 24rpx;
  289. color: #999999;
  290. }
  291. }
  292. .address {
  293. line-height: 38rpx;
  294. font-family: Microsoft YaHei, Microsoft YaHei;
  295. font-size: 28rpx;
  296. color: #333333;
  297. margin-top: 20rpx;
  298. }
  299. .user {
  300. line-height: 32rpx;
  301. font-family: Microsoft YaHei, Microsoft YaHei;
  302. font-size: 24rpx;
  303. color: #999999;
  304. margin-top: 20rpx;
  305. }
  306. .but-box {
  307. display: flex;
  308. align-items: center;
  309. justify-content: space-around;
  310. margin-top: 20rpx;
  311. .but-box-item {
  312. width: 40%;
  313. }
  314. }
  315. }
  316. </style>