index.vue 12 KB

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