index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. <template>
  2. <view class="post_item" @click.stop="handlePostRootClick">
  3. <view class="post_top">
  4. <view class="top_left">{{ item.name }}
  5. &nbsp;&nbsp;&nbsp;
  6. <view v-if="item.price" class="price">
  7. <u-icon name="rmb-circle"></u-icon>
  8. {{ item.price }}
  9. <view class="more" v-if="item.hasMoreInquiryPrice" @click.stop="handleInquiry(item)">
  10. 更多
  11. </view>
  12. </view>
  13. </view>
  14. <view class="top_right">{{ item.assignStateCode === '1' ? "已分配" : "未分配" }}</view>
  15. </view>
  16. <view class="post_info">
  17. <view class="telPhone">
  18. <view class="phone">
  19. <text>电话:</text>
  20. <show-real-text :real="item.telephone" :type='type'
  21. :style="{ color: item.repetitionOperationName ? 'red' : 'black' }"></show-real-text>
  22. <template v-if="item.telAddr">
  23. ({{ item.telAddr }})
  24. </template>
  25. <text v-if="item.repetitionOperationName">( 撞 : {{ item.repetitionOperationName }})</text>
  26. </view>
  27. <view class="copy_btn" @click.stop="handleCopy(item)" v-if="type != '1'">复制</view>
  28. </view>
  29. <view class="info" v-if="item.weixin">
  30. <text>微信:</text>
  31. <view class="phone">
  32. <text :style="{ color: item.repetitionOperWeixinName ? 'red' : 'black' }">{{ item.weixin }}</text>
  33. <text v-if="item.repetitionOperWeixinName">( 撞 : {{ item.repetitionOperWeixinName }})</text>
  34. </view>
  35. </view>
  36. <view class="info">
  37. <view class="createTime">{{ item.createTime }}</view>
  38. </view>
  39. <view class="info">
  40. <view>{{ item.appName }}</view>
  41. </view>
  42. <view class="info">
  43. <view class="owner">所属人:{{ item.clueOwnerName ? item.clueOwnerName : "-" }}</view>
  44. </view>
  45. <view class="info">
  46. <view class="operation">运营人:{{ item.clueOperationName ? item.clueOperationName : "-" }}</view>
  47. </view>
  48. <view class="info latest_follow_row" @click.stop="handleShowFollowDetail(item)">
  49. <view class="label">最新跟进记录:</view>
  50. <view class="latest_follow_content">
  51. <text class="latest_follow_text">{{ item.latestDynamicData || '暂无' }}</text>
  52. <text class="latest_follow_time" v-if="item.latestDynamicTime">{{ item.latestDynamicTime }}</text>
  53. </view>
  54. <!-- <view class="latest_follow_add" @click.stop="handleAddFollow(item)">增加</view> -->
  55. </view>
  56. </view>
  57. <view class="clue_state_wrap">
  58. <view class="clue_state">
  59. <view class="state_wrap">
  60. <view class="label">线索阶段:</view>{{ crm_clue_phase(item.clueState) }}
  61. </view>
  62. <view class="clueTag">
  63. <view class="label">线索标签:</view>
  64. <u-tag :text="tag.name" plain plainFill borderColor="#fff" size="mini"
  65. v-for="(tag) in item.clueTags" :key="tag.id" style="margin-right: 10px;" :bgColor="tag.color"
  66. color="#fff"></u-tag>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="sendOrder_wrap">
  71. <view class="sendOrder inquiry" @click.stop="handleInquiry(item)">
  72. <image src='/static/publicClue/inquiry.png' mode="aspectFit" class="sendOrder_img"></image>
  73. <view>询价</view>
  74. </view>
  75. <view class="sendOrder" @click.stop="handleSendOrder(item)">
  76. <image src='/static/publicClue/littlePlane.png' mode="aspectFit" class="sendOrder_img"></image>
  77. <view>发单</view>
  78. </view>
  79. </view>
  80. <add-inquiry-dialog ref="inquiryDialog" :clueId="clueId" :isShowChart="isShowChart" :isClue="true" :editOrAdd="editOrAdd" :editInfo="editInfo" title="询价" @cancel="handleInquiryCancel" :type="1"/>
  81. <!-- 最新跟进记录详情弹窗;关闭时记时间戳,避免蒙层点击冒泡触发详情跳转 -->
  82. <u-popup :show="followPopupVisible" mode="bottom" round="16" @close="onFollowPopupClose"
  83. :closeOnClickOverlay="true" @open="loadFollowList">
  84. <view class="follow_popup">
  85. <view class="follow_popup_title">跟进记录</view>
  86. <scroll-view scroll-y class="follow_popup_list" v-if="followList.length">
  87. <view class="follow_item" v-for="f in followList" :key="f.id">
  88. <view class="follow_top">
  89. <text class="person_name">{{ f.createNickname || f.createNickName || '-' }}</text>
  90. <text class="follow_time">{{ f.createTime }}</text>
  91. </view>
  92. <view class="follow_content">{{ f.content }}</view>
  93. </view>
  94. </scroll-view>
  95. <view class="follow_popup_empty" v-else-if="!followLoading">{{ followListError || '暂无跟进记录' }}</view>
  96. <view class="follow_popup_loading" v-else>加载中...</view>
  97. <!-- <view class="follow_popup_footer">
  98. <u-button type="primary" @click="handleAddFollowFromPopup">增加跟进</u-button>
  99. </view> -->
  100. </view>
  101. </u-popup>
  102. </view>
  103. </template>
  104. <script>
  105. import addInquiryDialog from '@/components/add-inquiry-dialog/index.vue'
  106. import {
  107. selectDictLabel
  108. } from "@/utils/util";
  109. export default {
  110. components: {
  111. addInquiryDialog
  112. },
  113. props: {
  114. item: {
  115. type: Object,
  116. required: true
  117. },
  118. dicts: {
  119. type: Object,
  120. required: true
  121. },
  122. type: {
  123. type: String | Number,
  124. required: true
  125. },
  126. },
  127. data() {
  128. return {
  129. caseStatusDicts: [],
  130. clueId: '',
  131. editOrAdd: 'add',
  132. editInfo: {},
  133. followPopupVisible: false,
  134. followList: [],
  135. followLoading: false,
  136. followListError: '',
  137. currentFollowClue: null,
  138. closedFollowPopupAt: 0,
  139. isShowChart: false
  140. }
  141. },
  142. methods: {
  143. // 字典翻译
  144. crm_clue_phase(caseStatus) {
  145. return selectDictLabel(this.dicts.caseStatusDicts, caseStatus);
  146. },
  147. handleCopy(item) {
  148. uni.setClipboardData({
  149. data: item.telephone,
  150. success: function () {
  151. uni.$u.toast("复制成功");
  152. }
  153. });
  154. },
  155. // 主页面的发单
  156. async handleSendOrder(item) {
  157. console.log(item);
  158. const {
  159. data: count
  160. } = await uni.$u.api.getClueSendFormCountByClueId({
  161. clueId: item.id
  162. });
  163. console.log(count);
  164. if (count > 0) {
  165. uni.showModal({
  166. title: '该线索已发单是否再次发单?',
  167. success: (res) => {
  168. if (res.confirm) {
  169. this.toOrderForm(item)
  170. }
  171. }
  172. });
  173. } else {
  174. this.toOrderForm(item)
  175. }
  176. },
  177. toOrderForm(item) {
  178. console.log(item);
  179. const {
  180. id,
  181. ownLatestDynamicTime,
  182. createTime,
  183. clueOwnerId
  184. } = item;
  185. if (this.$store.state.user.userInfo.userId === clueOwnerId) {
  186. uni.navigateTo({
  187. url: `/pages/orderForm/index?clueId=${id}`
  188. })
  189. } else {
  190. // 确定用于判断的目标时间(ownLatestDynamicTime,为null则用createTime)
  191. const date = ownLatestDynamicTime || createTime
  192. const twoDaysLater = new Date(date)
  193. twoDaysLater.setDate(twoDaysLater.getDate() + 2) // 日期加2天
  194. // 是否大于当前时间 小于可以发单
  195. let isOrderForm = false
  196. if (twoDaysLater) {
  197. isOrderForm = twoDaysLater.getTime() <= new Date().getTime()
  198. }
  199. if (isOrderForm) {
  200. uni.navigateTo({
  201. url: `/pages/orderForm/index?clueId=${id}`
  202. })
  203. } else {
  204. uni.$u.toast('非所属人需两天内无跟进记录才可发单')
  205. }
  206. }
  207. },
  208. // 询价
  209. async handleInquiry(item) {
  210. this.clueId = item.id
  211. if(Number(item.count) > 0 || item.count === '0'){//null:未生成询价数据 0:已生成询价数据但是没有询过价 >0:询过价人数
  212. const data = {
  213. clueId: item.id,
  214. type:1
  215. }
  216. this.editOrAdd = 'editForm'
  217. uni.$u.api.inquiryDetail(data).then(res=>{
  218. if(res.code === 200){
  219. this.$nextTick(()=>{
  220. this.editInfo = res.data
  221. if(Number(item.count) === 0){
  222. this.isShowChart = false
  223. }else{
  224. this.isShowChart = true
  225. }
  226. this.$refs.inquiryDialog.showDialog()
  227. })
  228. }
  229. })
  230. }else if(!item.count){
  231. this.editOrAdd = 'add'
  232. this.isShowChart = false
  233. this.editInfo = {
  234. dictLabel:'',
  235. model:'',
  236. code:'',
  237. imgsUrl:[],
  238. price:'',
  239. remark:'',
  240. }
  241. this.$refs.inquiryDialog.showDialog()
  242. }
  243. },
  244. // 询价取消
  245. handleInquiryCancel() {
  246. this.$refs.inquiryDialog.closeDialog()
  247. },
  248. // 卡片根节点点击:若刚因点蒙层关闭弹窗则不跳转,否则通知父组件跳转详情
  249. handlePostRootClick() {
  250. if (Date.now() - this.closedFollowPopupAt < 400) return
  251. this.$emit('to-detail', this.item)
  252. },
  253. onFollowPopupClose() {
  254. this.followPopupVisible = false
  255. this.closedFollowPopupAt = Date.now()
  256. },
  257. // 点击最新跟进记录,打开详情弹窗
  258. handleShowFollowDetail(item) {
  259. this.currentFollowClue = item
  260. this.followPopupVisible = true
  261. this.followList = []
  262. this.followListError = ''
  263. },
  264. // 弹窗打开时加载该线索的跟进列表
  265. async loadFollowList() {
  266. if (!this.currentFollowClue || !this.currentFollowClue.id) return
  267. this.followLoading = true
  268. this.followListError = ''
  269. try {
  270. const res = await uni.$u.api.getClueFollowListByClueId({ clueId: this.currentFollowClue.id })
  271. this.followList = (res.data || res) || []
  272. } catch (e) {
  273. console.error('获取跟进记录失败', e)
  274. this.followListError = '加载失败'
  275. this.followList = []
  276. } finally {
  277. this.followLoading = false
  278. }
  279. },
  280. // 增加跟进:跳转添加跟进页
  281. handleAddFollow(item) {
  282. const id = (item && item.id) || (this.currentFollowClue && this.currentFollowClue.id)
  283. if (!id) return
  284. uni.navigateTo({
  285. url: `/pages/addFollow/index?clueId=${id}`
  286. })
  287. this.followPopupVisible = false
  288. },
  289. // 弹窗内点击「增加跟进」
  290. handleAddFollowFromPopup() {
  291. this.handleAddFollow(this.currentFollowClue)
  292. },
  293. },
  294. }
  295. </script>
  296. <style lang="scss" scoped>
  297. .post_item {
  298. background: #fff;
  299. border-radius: 20px;
  300. padding: 20px;
  301. margin-bottom: 20px;
  302. position: relative;
  303. .post_top {
  304. display: flex;
  305. justify-content: space-between;
  306. margin-bottom: 10px;
  307. .top_left {
  308. font-size: 18px;
  309. display: flex;
  310. .price{
  311. display: flex;
  312. align-items: center;
  313. gap: 8rpx;
  314. .more{
  315. font-size: 20rpx;
  316. border: 1px solid #3c9cff;
  317. border-radius:10rpx;
  318. padding: 3rpx 8rpx;
  319. color: #3c9cff;
  320. }
  321. }
  322. }
  323. .top_right {
  324. color: #87bf66;
  325. }
  326. }
  327. .post_info {
  328. font-size: 14px;
  329. display: grid;
  330. grid-template-columns: 1fr 1fr;
  331. gap: 10rpx;
  332. .telPhone {
  333. display: flex;
  334. grid-column: 1 / -1;
  335. .copy_btn {
  336. color: #4fa5fe;
  337. margin-left: 10px;
  338. }
  339. }
  340. .info {
  341. display: flex;
  342. // margin-bottom: 10px;
  343. overflow: hidden;
  344. > view {
  345. white-space: nowrap;
  346. overflow: hidden;
  347. text-overflow: ellipsis;
  348. flex: 1;
  349. }
  350. .createTime {
  351. margin-right: 10px;
  352. }
  353. .copy_btn {
  354. display: flex;
  355. flex-wrap: wrap;
  356. }
  357. }
  358. .latest_follow_row {
  359. align-items: flex-start;
  360. flex-wrap: wrap;
  361. grid-column: 1 / -1;
  362. .label {
  363. flex: 0 0 90px;
  364. }
  365. .latest_follow_content {
  366. flex: 1;
  367. min-width: 0;
  368. display: flex;
  369. gap: 4px;
  370. flex-direction: column;
  371. }
  372. .latest_follow_text {
  373. font-size: 13px;
  374. word-break: break-all;
  375. }
  376. .latest_follow_time {
  377. font-size: 12px;
  378. }
  379. .latest_follow_add {
  380. flex-shrink: 0;
  381. color: #4fa5fe;
  382. font-size: 14px;
  383. margin-left: 8px;
  384. }
  385. }
  386. }
  387. .clue_state_wrap {
  388. font-size: 14px;
  389. background: #f8f9fb;
  390. padding: 10px;
  391. color: #9b9aa2;
  392. overflow: hidden;
  393. .state_wrap {
  394. display: flex;
  395. margin-bottom: 10px;
  396. }
  397. .label {
  398. flex: 0 0 66px;
  399. }
  400. .clueTag {
  401. display: flex;
  402. }
  403. }
  404. .sendOrder_wrap {
  405. display: flex;
  406. justify-content: space-between;
  407. gap: 20rpx;
  408. .sendOrder {
  409. width: 50%;
  410. height: 40px;
  411. background-color: rgb(36, 98, 234);
  412. color: #fff;
  413. border-radius: 20rpx;
  414. display: flex;
  415. justify-content: center;
  416. align-items: center;
  417. gap: 20rpx;
  418. font-size: 28rpx;
  419. font-weight: 700;
  420. font-family: "uicon";
  421. margin-top: 10rpx;
  422. .sendOrder_img {
  423. width: 20px;
  424. height: 20px;
  425. }
  426. }
  427. .inquiry {
  428. right: 140rpx;
  429. color: #2563eb;
  430. border: 1px solid #2563eb;
  431. background-color: #fff;
  432. }
  433. }
  434. }
  435. .follow_popup {
  436. padding: 24rpx 30rpx 40rpx;
  437. max-height: 70vh;
  438. display: flex;
  439. flex-direction: column;
  440. .follow_popup_title {
  441. font-size: 34rpx;
  442. font-weight: 600;
  443. margin-bottom: 24rpx;
  444. text-align: center;
  445. }
  446. .follow_popup_list {
  447. flex: 1;
  448. max-height: 50vh;
  449. margin-bottom: 24rpx;
  450. }
  451. .follow_item {
  452. padding: 20rpx 0;
  453. border-bottom: 1rpx solid #eee;
  454. &:last-child {
  455. border-bottom: none;
  456. }
  457. .follow_top {
  458. display: flex;
  459. justify-content: space-between;
  460. align-items: center;
  461. margin-bottom: 12rpx;
  462. font-size: 24rpx;
  463. .person_name {
  464. color: #333;
  465. font-weight: 500;
  466. }
  467. .follow_time {
  468. color: #999;
  469. }
  470. }
  471. .follow_content {
  472. font-size: 26rpx;
  473. color: #666;
  474. line-height: 1.5;
  475. word-break: break-all;
  476. }
  477. }
  478. .follow_popup_empty,
  479. .follow_popup_loading {
  480. text-align: center;
  481. color: #999;
  482. font-size: 28rpx;
  483. padding: 60rpx 0;
  484. }
  485. .follow_popup_footer {
  486. padding-top: 20rpx;
  487. }
  488. }
  489. </style>