pagereceivecenter.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <script>
  2. // import orderCard from "./compounts/orderCard.vue";
  3. export default {
  4. components: {
  5. // orderCard,
  6. },
  7. data() {
  8. return {
  9. orderList: [],
  10. page: {
  11. pageSize: 10,
  12. pageNum: 1,
  13. total: 0
  14. },
  15. tagModalVisible: false,
  16. tagList: [],
  17. currentTags: [],
  18. currentOrder: {},
  19. followUpModelShow: false,
  20. followUpNotes: '',
  21. countdown: 300,
  22. countdownIntervals: null
  23. }
  24. },
  25. onLoad() {
  26. //初始调用
  27. this.getOrderList();
  28. this.countdownInterval()
  29. // uni.navigateTo({
  30. // url: `/pages/orderDetailNew/index?orderId=5464&item=测试发单&type=undefined&clueId=1973381744953516033`,
  31. // })
  32. },
  33. onUnload() {
  34. clearInterval(this.countdownInterval);
  35. },
  36. watch: {
  37. countdown: {
  38. handler(newVal, oldVal) {
  39. if (newVal <= 0) {
  40. this.orderList.forEach(order => {
  41. if(order.status == 1){
  42. this.handleBtnClick('isBusy',order)
  43. }
  44. })
  45. }
  46. },
  47. immediate: true
  48. }
  49. },
  50. methods: {
  51. countdownInterval(){
  52. this.countdownInterval = setInterval(() => {
  53. this.countdown--
  54. }, 1000);
  55. },
  56. //获取列表数据
  57. async getOrderList() {
  58. try {
  59. const result = await uni.$u.api.selectClueOrderFormList({
  60. pageSize: this.page.pageSize,
  61. pageNum: this.page.pageNum,
  62. });
  63. console.log('接单列表', result);
  64. // 把数组按照status的大小排序,从小到大
  65. result.rows.sort((a, b) => {
  66. return a.status - b.status;
  67. })
  68. this.orderList.push(...result.rows);
  69. this.page.total = result.total;
  70. } catch (error) {
  71. console.error('接单列表接口调用失败:', error);
  72. // 添加用户友好的错误提示
  73. uni.$u.toast('获取订单列表失败,请稍后重试');
  74. }
  75. },
  76. // 处理按钮点击事件
  77. handleBtnClick(btnType, order) {
  78. if (btnType == 'acceptOrder') {
  79. //去接单
  80. console.log('去接单', order)
  81. //打开模态窗二次确认,确认后跳转接单form
  82. uni.showModal({
  83. title: '确认接单',
  84. content: `是否确认接单订单:${order.item}?`,
  85. success: async (res) => {
  86. if (res.confirm) {
  87. await uni.$u.api.oderForm({
  88. status: "2",
  89. id: order.id,
  90. });
  91. uni.navigateTo({
  92. url: `/pages/orderDetailNew/index?orderId=${order.id}&item=${order.item}&type=${this.type}&clueId=${order.clueId}`,
  93. })
  94. } else if (res.cancel) {
  95. // 用户点击了取消,不执行任何操作
  96. uni.$u.toast('已取消接单');
  97. }
  98. }
  99. })
  100. } else if (btnType == 'isBusy') {
  101. //在忙
  102. console.log('在忙', order)
  103. //当前订单移动到末尾
  104. this.orderList.push(this.orderList.splice(this.orderList.indexOf(order), 1)[0]);
  105. } else if (btnType == 'willFollow') {
  106. //待跟进
  107. console.log('待跟进', order)
  108. //打开模态窗
  109. this.followUpModelShow = true;
  110. this.currentOrder = order
  111. } else if (btnType == 'tag') {
  112. //打标签
  113. console.log('打标签', order)
  114. //打开模态窗
  115. this.tagModalVisible = true;
  116. this.getAllTags();
  117. this.currentTags = order.tags.map(tag => tag.id);
  118. this.currentOrder = order
  119. } else if (btnType == 'share') {
  120. //一键分享
  121. console.log('一键分享', order)
  122. } else if (btnType == 'oneFollow') {
  123. //待跟进
  124. console.log('待跟进', order)
  125. this.followUpModelShow = true;
  126. this.currentOrder = order
  127. }
  128. },
  129. // 跳转订单详情
  130. toOrderDetail(order) {
  131. //点卡片看详情
  132. // if (order.status == '1' || order.status == '2') {
  133. uni.navigateTo({
  134. url: `/pages/orderDetailNew/index?orderId=${order.id}&item=${order.item}&type=${this.type}&clueId=${order.clueId}`,
  135. })
  136. // } else {
  137. // uni.$u.toast('当前订单无法查看详情');
  138. // return;
  139. // }
  140. },
  141. //滑动加载
  142. scrolltolower() {
  143. console.log('到底了');
  144. // if (this.orderList.length >= this.page.total) {
  145. // return uni.$u.toast('没有更多了');
  146. // }
  147. this.page.pageNum++;
  148. this.getOrderList();
  149. },
  150. //获取全部标签
  151. async getAllTags() {
  152. const res = await uni.$u.api.getClueTagGroupVoList({ tagGroupApplication: '2' })
  153. console.log('全部标签', res.data[0].clueTagDataList)
  154. this.tagList = res.data[0].clueTagDataList;
  155. },
  156. cancelTag() {
  157. this.tagModalVisible = false;
  158. },
  159. async confirmTag() {
  160. console.log('确认打标签', this.currentTags)
  161. // 这里可以添加打标签的逻辑
  162. const allTags = this.currentTags.map(tag => tag).join(',');
  163. console.log('allTags', allTags)
  164. await uni.$u.api.updateTags({
  165. id: this.currentOrder.id,
  166. allTags: allTags,
  167. })
  168. this.tagModalVisible = false;
  169. uni.$u.toast('标签更新成功');
  170. //更新当前订单的标签
  171. this.currentOrder.tags = this.tagList.filter(tag => this.currentTags.includes(tag.id));
  172. },
  173. // 确认跟进细节按钮点击事件
  174. async confirmFollowUp() {
  175. console.log('确认跟进细节:', this.followUpNotes);
  176. this.followUpModelShow = false;
  177. // 可以在这里添加提交跟进细节的逻辑
  178. // 未收的时候,提交一个跟进记录 待跟进_内容
  179. const res = await uni.$u.api.addOrderFollow({
  180. orderId: this.currentOrder.id,
  181. content: `待跟进_${this.followUpNotes}`,
  182. })
  183. if (res.code == 200) {
  184. uni.$u.toast('提交待跟进记录成功');
  185. }
  186. },
  187. }
  188. }
  189. </script>
  190. <template>
  191. <view class="container">
  192. <u-navbar title="接单中心" :autoBack="true" :placeholder="true" v-hideNav></u-navbar>
  193. <view class="scrollViewContainer">
  194. <scroll-view class="scrollView" scroll-y @scrolltolower="scrolltolower">
  195. <transition-group name="order-move" tag="div">
  196. <!-- <orderCard v-for="item in orderList" :key="item.receiptId + item.id" :order="item"
  197. @handleBtnClick="handleBtnClick">
  198. </orderCard> -->
  199. <view class="orderCard" v-for="item in orderList" :key="item.receiptId + item.id"
  200. @click.stop="toOrderDetail(item)">
  201. <view class="bandAndPrice">
  202. <view class="bandName">{{ item.itemBrand || '暂无品牌' }}</view>
  203. <view class="price">¥{{ item.priceRange || '?' }}</view>
  204. </view>
  205. <view class="mainLind">
  206. <!-- <view class="mainLindImg">
  207. <image :src="'/static/acceptOrder/orderCardPic.jpg'" v-if="item.src" />
  208. </view> -->
  209. <view class="itemName">{{ item.item || '暂无项目' }}</view>
  210. <view class="mainLindInfo">
  211. <view>发单人:{{ item.createNickName || '未知' }}</view>
  212. <view>机构:{{ item.orgName || '暂无机构' }}</view>
  213. <view>电话:{{ item.phone || '暂无电话' }}</view>
  214. <view>接单人:{{ item.identificationName || '暂无所属人' }}</view>
  215. <view>运营人:{{ item.clueOperationName || '暂无运营人' }}</view>
  216. <view>发单日期:{{ item.sendDate || '暂无时间' }}</view>
  217. </view>
  218. </view>
  219. <view class="tags">
  220. <view class="tag" v-for="(tag, index) in item.tags" :key="index"
  221. :style="{ backgroundColor: tag.color, opacity: 0.8 }">
  222. {{ tag.name }}</view>
  223. </view>
  224. <view class="Btns">
  225. <view class="btnGroup"
  226. v-if="item && (item.status == '1')">
  227. <view class="card-button" @click.stop="handleBtnClick('acceptOrder', item)">立即接单</view>
  228. <view class=" card-button isBusy" @click.stop="handleBtnClick('isBusy', item)">在忙({{countdown}}s)</view>
  229. </view>
  230. <view class="btnGroup"
  231. v-if="item && (item.status == '2')">
  232. <view class="card-button willFollow" @click.stop="handleBtnClick('willFollow', item)">
  233. 待跟进
  234. </view>
  235. <view class="card-button isBusy" @click.stop="handleBtnClick('tag', item)">打标签</view>
  236. </view>
  237. <view class="btnGroup"
  238. v-if="item && (item.status == '3')">
  239. <view class="card-button share" @click.stop="handleBtnClick('share', item)">一键分享</view>
  240. </view>
  241. <view class="btnGroup"
  242. v-if="item && (item.status == '4')">
  243. <view class="card-button oneFollow" @click.stop="handleBtnClick('oneFollow', item)">待跟进
  244. </view>
  245. </view>
  246. </view>
  247. </view>
  248. </transition-group>
  249. <view class="hasMore">
  250. <!-- {{ orderList.length >= page.total ? '没有更多了~' : '向下滑动加载更多~' }} -->
  251. </view>
  252. </scroll-view>
  253. </view>
  254. <!-- 打标签模态窗 -->
  255. <u-modal :show="tagModalVisible" title="选择标签" @confirm="confirmTag" @cancel="cancelTag">
  256. <view class="slot-content">
  257. <u-checkbox-group v-model="currentTags" placement="column">
  258. <u-checkbox :customStyle="{ marginBottom: '8px' }" v-for="(item, index) in tagList" :key="item.id"
  259. :label="item.name" :name="item.id">
  260. </u-checkbox>
  261. </u-checkbox-group>
  262. </view>
  263. </u-modal>
  264. <u-modal :show="followUpModelShow" :title="'填写跟进细节'" :showConfirmButton="false">
  265. <view class="modal-content">
  266. <u--textarea v-model="followUpNotes" placeholder="请输入情况" confirm-type="done"
  267. style="width: 400rpx; margin-bottom: 30rpx;"></u--textarea>
  268. <u-button type="primary" size="large" @click="confirmFollowUp">确认</u-button>
  269. </view>
  270. </u-modal>
  271. </view>
  272. </template>
  273. <style scoped lang="scss">
  274. .hasMore {
  275. text-align: center;
  276. padding: 20rpx 0;
  277. font-size: 24rpx;
  278. color: #999;
  279. }
  280. .scrollViewContainer {
  281. height: calc(100vh - 44px);
  282. }
  283. .scrollView {
  284. height: 100%;
  285. }
  286. /* 订单移动动画 */
  287. .order-move-enter-active,
  288. .order-move-leave-active {
  289. transition: all 0.5s ease;
  290. }
  291. .order-move-enter-from,
  292. .order-move-leave-to {
  293. opacity: 0;
  294. transform: translateY(30px);
  295. }
  296. .order-move-move {
  297. transition: transform 0.5s ease;
  298. }
  299. /* 订单卡片主容器 */
  300. .orderCard {
  301. box-sizing: border-box;
  302. width: 95%;
  303. background-color: #fff;
  304. margin: 20rpx auto;
  305. border-radius: 20rpx;
  306. padding: 20rpx;
  307. }
  308. /* 品牌和价格区域 */
  309. .orderCard .bandAndPrice {
  310. display: flex;
  311. justify-content: space-between;
  312. align-items: center;
  313. }
  314. /* 品牌名称 */
  315. .orderCard .bandAndPrice .bandName {
  316. font-size: 20rpx;
  317. font-weight: 700;
  318. border: 2px solid #2563EB;
  319. padding: 6rpx 12rpx;
  320. border-radius: 15rpx;
  321. background-color: #EFF6FF;
  322. color: #2563EB;
  323. }
  324. /* 价格 */
  325. .orderCard .bandAndPrice .price {
  326. font-size: 30rpx;
  327. font-weight: 700;
  328. }
  329. /* 主要内容行 */
  330. .orderCard .mainLind {
  331. margin-top: 10rpx;
  332. display: flex;
  333. justify-content: space-between;
  334. align-items: center;
  335. gap: 20rpx;
  336. flex-direction: column;
  337. }
  338. /* 主要内容行图片容器 */
  339. .orderCard .mainLind .mainLindImg image {
  340. width: 150rpx;
  341. height: 150rpx;
  342. border-radius: 20rpx;
  343. }
  344. /* 主要内容行信息容器 */
  345. .orderCard .mainLind .mainLindInfo {
  346. display: grid;
  347. grid-template-columns: 1fr 1fr;
  348. flex-direction: column;
  349. gap: 10rpx;
  350. font-size: 24rpx;
  351. color: #6b7280;
  352. }
  353. /* 商品名称 */
  354. .orderCard .mainLind .itemName {
  355. font-size: 30rpx;
  356. font-weight: 700;
  357. color: #374751;
  358. width: 100%;
  359. text-align: left;
  360. }
  361. /* 标签区域 */
  362. .orderCard .tags {
  363. display: flex;
  364. gap: 10rpx;
  365. }
  366. /* 单个标签 */
  367. .orderCard .tags .tag {
  368. font-size: 20rpx;
  369. font-weight: 700;
  370. padding: 6rpx 12rpx;
  371. border-radius: 15rpx;
  372. background-color: #EFF6FF;
  373. color: #fff;
  374. }
  375. /* 按钮区域 */
  376. .orderCard .Btns {
  377. margin-top: 10rpx;
  378. }
  379. /* 按钮组 */
  380. .orderCard .Btns .btnGroup {
  381. display: flex;
  382. justify-content: space-between;
  383. align-items: center;
  384. gap: 20rpx;
  385. }
  386. /* 卡片按钮基础样式 */
  387. .orderCard .Btns .btnGroup .card-button {
  388. font-size: 24rpx;
  389. font-weight: 700;
  390. border: 2rpx solid #2563EB;
  391. padding: 6rpx 12rpx;
  392. border-radius: 15rpx;
  393. background-color: #2563EB;
  394. color: #fff;
  395. width: 45%;
  396. text-align: center;
  397. cursor: pointer;
  398. height: 60rpx;
  399. line-height: 60rpx;
  400. }
  401. /* 忙碌状态按钮 */
  402. .orderCard .Btns .btnGroup .card-button.isBusy {
  403. background-color: #fff;
  404. color: #6B7280;
  405. border-color: #6B7280;
  406. }
  407. /* 待跟进状态按钮 */
  408. .orderCard .Btns .btnGroup .card-button.willFollow {
  409. background-color: #EFF6FF;
  410. color: #2563EB;
  411. }
  412. /* 分享按钮 */
  413. .orderCard .Btns .btnGroup .card-button.share {
  414. width: 100%;
  415. }
  416. /* 单独跟进按钮 */
  417. .orderCard .Btns .btnGroup .card-button.oneFollow {
  418. width: 100%;
  419. background-color: #EFF6FF;
  420. color: #2563EB;
  421. }
  422. </style>