index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  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 || Number(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. }
  231. else if(!item.count){
  232. this.editOrAdd = 'add'
  233. this.isShowChart = false
  234. this.$refs.inquiryDialog.showDialog()
  235. }
  236. },
  237. // 询价取消
  238. handleInquiryCancel() {
  239. this.$refs.inquiryDialog.closeDialog()
  240. },
  241. // 卡片根节点点击:若刚因点蒙层关闭弹窗则不跳转,否则通知父组件跳转详情
  242. handlePostRootClick() {
  243. if (Date.now() - this.closedFollowPopupAt < 400) return
  244. this.$emit('to-detail', this.item)
  245. },
  246. onFollowPopupClose() {
  247. this.followPopupVisible = false
  248. this.closedFollowPopupAt = Date.now()
  249. },
  250. // 点击最新跟进记录,打开详情弹窗
  251. handleShowFollowDetail(item) {
  252. this.currentFollowClue = item
  253. this.followPopupVisible = true
  254. this.followList = []
  255. this.followListError = ''
  256. },
  257. // 弹窗打开时加载该线索的跟进列表
  258. async loadFollowList() {
  259. if (!this.currentFollowClue || !this.currentFollowClue.id) return
  260. this.followLoading = true
  261. this.followListError = ''
  262. try {
  263. const res = await uni.$u.api.getClueFollowListByClueId({ clueId: this.currentFollowClue.id })
  264. this.followList = (res.data || res) || []
  265. } catch (e) {
  266. console.error('获取跟进记录失败', e)
  267. this.followListError = '加载失败'
  268. this.followList = []
  269. } finally {
  270. this.followLoading = false
  271. }
  272. },
  273. // 增加跟进:跳转添加跟进页
  274. handleAddFollow(item) {
  275. const id = (item && item.id) || (this.currentFollowClue && this.currentFollowClue.id)
  276. if (!id) return
  277. uni.navigateTo({
  278. url: `/pages/addFollow/index?clueId=${id}`
  279. })
  280. this.followPopupVisible = false
  281. },
  282. // 弹窗内点击「增加跟进」
  283. handleAddFollowFromPopup() {
  284. this.handleAddFollow(this.currentFollowClue)
  285. },
  286. },
  287. }
  288. </script>
  289. <style lang="scss" scoped>
  290. .post_item {
  291. background: #fff;
  292. border-radius: 20px;
  293. padding: 20px;
  294. margin-bottom: 20px;
  295. position: relative;
  296. .post_top {
  297. display: flex;
  298. justify-content: space-between;
  299. margin-bottom: 10px;
  300. .top_left {
  301. font-size: 18px;
  302. display: flex;
  303. .price{
  304. display: flex;
  305. align-items: center;
  306. gap: 8rpx;
  307. .more{
  308. font-size: 20rpx;
  309. border: 1px solid #3c9cff;
  310. border-radius:10rpx;
  311. padding: 3rpx 8rpx;
  312. color: #3c9cff;
  313. }
  314. }
  315. }
  316. .top_right {
  317. color: #87bf66;
  318. }
  319. }
  320. .post_info {
  321. font-size: 14px;
  322. display: grid;
  323. grid-template-columns: 1fr 1fr;
  324. gap: 10rpx;
  325. .telPhone {
  326. display: flex;
  327. grid-column: 1 / -1;
  328. .copy_btn {
  329. color: #4fa5fe;
  330. margin-left: 10px;
  331. }
  332. }
  333. .info {
  334. display: flex;
  335. // margin-bottom: 10px;
  336. overflow: hidden;
  337. > view {
  338. white-space: nowrap;
  339. overflow: hidden;
  340. text-overflow: ellipsis;
  341. flex: 1;
  342. }
  343. .createTime {
  344. margin-right: 10px;
  345. }
  346. .copy_btn {
  347. display: flex;
  348. flex-wrap: wrap;
  349. }
  350. }
  351. .latest_follow_row {
  352. align-items: flex-start;
  353. flex-wrap: wrap;
  354. grid-column: 1 / -1;
  355. .label {
  356. flex: 0 0 90px;
  357. }
  358. .latest_follow_content {
  359. flex: 1;
  360. min-width: 0;
  361. display: flex;
  362. gap: 4px;
  363. flex-direction: column;
  364. }
  365. .latest_follow_text {
  366. font-size: 13px;
  367. word-break: break-all;
  368. }
  369. .latest_follow_time {
  370. font-size: 12px;
  371. }
  372. .latest_follow_add {
  373. flex-shrink: 0;
  374. color: #4fa5fe;
  375. font-size: 14px;
  376. margin-left: 8px;
  377. }
  378. }
  379. }
  380. .clue_state_wrap {
  381. font-size: 14px;
  382. background: #f8f9fb;
  383. padding: 10px;
  384. color: #9b9aa2;
  385. overflow: hidden;
  386. .state_wrap {
  387. display: flex;
  388. margin-bottom: 10px;
  389. }
  390. .label {
  391. flex: 0 0 66px;
  392. }
  393. .clueTag {
  394. display: flex;
  395. }
  396. }
  397. .sendOrder_wrap {
  398. display: flex;
  399. justify-content: space-between;
  400. gap: 20rpx;
  401. .sendOrder {
  402. width: 50%;
  403. height: 40px;
  404. background-color: rgb(36, 98, 234);
  405. color: #fff;
  406. border-radius: 20rpx;
  407. display: flex;
  408. justify-content: center;
  409. align-items: center;
  410. gap: 20rpx;
  411. font-size: 28rpx;
  412. font-weight: 700;
  413. font-family: "uicon";
  414. margin-top: 10rpx;
  415. .sendOrder_img {
  416. width: 20px;
  417. height: 20px;
  418. }
  419. }
  420. .inquiry {
  421. right: 140rpx;
  422. color: #2563eb;
  423. border: 1px solid #2563eb;
  424. background-color: #fff;
  425. }
  426. }
  427. }
  428. .follow_popup {
  429. padding: 24rpx 30rpx 40rpx;
  430. max-height: 70vh;
  431. display: flex;
  432. flex-direction: column;
  433. .follow_popup_title {
  434. font-size: 34rpx;
  435. font-weight: 600;
  436. margin-bottom: 24rpx;
  437. text-align: center;
  438. }
  439. .follow_popup_list {
  440. flex: 1;
  441. max-height: 50vh;
  442. margin-bottom: 24rpx;
  443. }
  444. .follow_item {
  445. padding: 20rpx 0;
  446. border-bottom: 1rpx solid #eee;
  447. &:last-child {
  448. border-bottom: none;
  449. }
  450. .follow_top {
  451. display: flex;
  452. justify-content: space-between;
  453. align-items: center;
  454. margin-bottom: 12rpx;
  455. font-size: 24rpx;
  456. .person_name {
  457. color: #333;
  458. font-weight: 500;
  459. }
  460. .follow_time {
  461. color: #999;
  462. }
  463. }
  464. .follow_content {
  465. font-size: 26rpx;
  466. color: #666;
  467. line-height: 1.5;
  468. word-break: break-all;
  469. }
  470. }
  471. .follow_popup_empty,
  472. .follow_popup_loading {
  473. text-align: center;
  474. color: #999;
  475. font-size: 28rpx;
  476. padding: 60rpx 0;
  477. }
  478. .follow_popup_footer {
  479. padding-top: 20rpx;
  480. }
  481. }
  482. </style>