pagereceivecenter.vue 14 KB

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