clueDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <template>
  2. <view class="clueDetail_wrap">
  3. <view class="telPhone">
  4. <view class="left">
  5. <view class="phone">电话:
  6. <show-real-text :real="clueDetail.telephone" :type='params.type'
  7. v-if="clueDetail.telephone"></show-real-text>
  8. <template v-if="clueDetail.telAddr">
  9. ({{clueDetail.telAddr}})
  10. </template>
  11. </view>
  12. <view class="copy_btn" v-if="params.type != '1'" @click="handleCopy(clueDetail)">复制</view>
  13. </view>
  14. <view class="right">
  15. 运营人 : {{ clueDetail.clueOperationName }}
  16. </view>
  17. </view>
  18. <view class="clueDetail_top_info">
  19. <view class="top_info_item">
  20. <view class="top">
  21. {{defaultText(clueDetail.clueOwnerName)}}
  22. </view>
  23. <view class="bottom">
  24. 线索所属人
  25. </view>
  26. </view>
  27. <view class="top_info_item">
  28. <view class="top">
  29. {{defaultText(clueDetail.appName)}}
  30. </view>
  31. <view class="bottom">
  32. 流量来源
  33. </view>
  34. </view>
  35. <view class="top_info_item">
  36. <view class="top">
  37. {{defaultText(clueDetail.clueType)}}
  38. </view>
  39. <view class="bottom">
  40. 线索类型
  41. </view>
  42. </view>
  43. <view class="top_info_item">
  44. <view class="top">
  45. {{defaultText(clueDetail.createTime)}}
  46. </view>
  47. <view class="bottom">
  48. 线索创建时间
  49. </view>
  50. </view>
  51. <view class="top_info_item">
  52. <view class="top">
  53. {{defaultText(clueDetail.clueDataSource)}}
  54. </view>
  55. <view class="bottom">
  56. 线索渠道
  57. </view>
  58. </view>
  59. <view class="top_info_item">
  60. <view class="top">
  61. {{crmFollowStatusFormat(clueDetail.handleState)}}
  62. </view>
  63. <view class="bottom">
  64. 跟进状态
  65. </view>
  66. </view>
  67. </view>
  68. <view class="clue_state_wrap">
  69. <view class="clue_state_top_wrap">
  70. <view class="top_left">线索阶段</view>
  71. <view class="top_right" @click="handleIsInvalid">
  72. <template v-if="clueDetail.clueState === '6'">已标记无效</template>
  73. <template v-else>标记无效</template>
  74. </view>
  75. </view>
  76. <view class="steps_wrap">
  77. <u-steps :current="currentSteps" dot>
  78. <u-steps-item :title="item.dictLabel" @click.native="handleClickStepsItem(item)"
  79. v-for="(item,index) in crmCluePhaseDict" :key="index"></u-steps-item>
  80. </u-steps>
  81. </view>
  82. </view>
  83. <view class="clue_tag_wrap">
  84. <view class="clue_tag_add_btn" @click="handleAddClueTag">
  85. + 添加标签
  86. </view>
  87. <u-tag :text="tag.name" plain plainFill :closable="true" @close="hanldeTagClose(tag)" borderColor="#fff"
  88. v-for="(tag) in clueDetail.clueTags" :key="tag.id" style="margin-left: 10px;margin-bottom: 10px;"
  89. :bgColor="tag.color" color="#fff"></u-tag>
  90. </view>
  91. <yui-tabs :tabs="tabs" v-model="activeIndex" :lineWidth="'120rpx'" :isLazyRender="false" color="#108cff"
  92. titleActiveColor="#108cff" :swipeable="true" :swiper="false" :ellipsis="false" :scroll-threshold="3">
  93. <template #clueInfo>
  94. <clueInfo :clueId="clueDetail.id" v-if="clueDetail.id" :clueDetailVo="clueDetail" :params="params" ref="clueInfoRef" type="1">
  95. </clueInfo>
  96. </template>
  97. <template #advertising>
  98. <advertising :clueId="clueDetail.id" v-if="clueDetail.id" ref="advertisingRef"></advertising>
  99. </template>
  100. <template #followRecord>
  101. <followRecord :clueId="clueDetail.id" v-if="clueDetail.id" ref="followRecordRef" type="1">
  102. </followRecord>
  103. </template>
  104. <template #callRecord>
  105. <callRecord :clueId="clueDetail.id" :clueDetail="clueDetail" v-if="clueDetail.id" ref="callRecordRef">
  106. </callRecord>
  107. </template>
  108. <template #orderFollow>
  109. <followRecord :clueId="clueDetail.id" v-if="clueDetail.id" ref="followRecordRef" type="3">
  110. </followRecord>
  111. </template>
  112. </yui-tabs>
  113. <u-tabbar class="clueDetail_tabber" :fixed="true" inactiveColor="#ffffff" :placeholder="true"
  114. :safeAreaInsetBottom="true">
  115. <u-tabbar-item text="拨打电话" icon="../../static/clueDetail/icon-phone.png"
  116. @click="handleCallPhone"></u-tabbar-item>
  117. <!-- <u-tabbar-item text="转移线索" icon="../../static/clueDetail/icon-clue.png"
  118. @click="handleDistribution"></u-tabbar-item> -->
  119. <u-tabbar-item text="发单" icon="../../static/clueDetail/icon-order.png"
  120. @click="handleClueSend"></u-tabbar-item>
  121. <u-tabbar-item text="写新跟进" icon="../../static/caseDetail/icon-follow.png"
  122. @click="handleAddFollow"></u-tabbar-item>
  123. <u-tabbar-item text="上传录音" icon="../../static/caseDetail/icon-record.png"
  124. @click="handleUploadRecord"></u-tabbar-item>
  125. </u-tabbar>
  126. <distribution-modal :clueDetail="clueDetail" ref="distribution"
  127. @handleSuccess="distributionSuccess"></distribution-modal>
  128. <group-select class="clueTagsSelect" :list="clueTagGroupVoList" scrollHeight="720rpx" groupName="groupName"
  129. groupChild="clueTagDataList" label-key="name" value-key="id" placeholder="请选择线索标签" v-model="checkTags"
  130. multiple clearable ref="clueTag" @confirm="handleClueTagConfirm"></group-select>
  131. </view>
  132. </template>
  133. <script>
  134. import {
  135. cloneDeep
  136. } from "lodash";
  137. import {
  138. selectDictLabel
  139. } from "@/utils/util";
  140. import clueInfo from "../tabs/clueInfo/index";
  141. import advertising from "../tabs/advertising/index";
  142. import followRecord from "../tabs/followRecord/index";
  143. import callRecord from "../tabs/callRecord/index";
  144. export default {
  145. components: {
  146. clueInfo,
  147. advertising,
  148. followRecord,
  149. callRecord,
  150. },
  151. props: {
  152. clueId: {
  153. type: String,
  154. required: true
  155. },
  156. params: {
  157. type: Object,
  158. required: true
  159. },
  160. },
  161. computed: {
  162. currentSteps() {
  163. const index = this.crmCluePhaseDict.findIndex(v => v.dictValue === this.clueDetail.clueState);
  164. return index;
  165. },
  166. },
  167. data() {
  168. return {
  169. showModal: false,
  170. clueDetail: {},
  171. checkTags: [],
  172. clueTagGroupVoList: [],
  173. crmHandelStatusDict: [],
  174. crmCluePhaseDict: [],
  175. tabs: [{
  176. label: '基础信息',
  177. slot: 'clueInfo'
  178. }, {
  179. label: '广告信息',
  180. slot: 'advertising'
  181. }, {
  182. label: '跟进记录',
  183. slot: 'followRecord'
  184. },
  185. {
  186. label: '通话记录',
  187. slot: 'callRecord'
  188. },
  189. {
  190. label: '后端跟进',
  191. slot: 'orderFollow'
  192. }
  193. ],
  194. activeIndex: 0,
  195. }
  196. },
  197. methods: {
  198. distributionSuccess() {
  199. this.handleInit();
  200. },
  201. async hanldeTagClose(tag) {
  202. const {
  203. cfId: id,
  204. clueTags
  205. } = this.clueDetail;
  206. const copyClueTags = cloneDeep(clueTags);
  207. if (id == null) {
  208. this.$message.error("修改异常");
  209. return;
  210. }
  211. const index = copyClueTags.findIndex(v => v.id === tag.id);
  212. if (index !== -1) {
  213. copyClueTags.splice(index, 1);
  214. const allTags = copyClueTags.map(v => v.id).join(",");
  215. await uni.$u.api.updateClueFixedFieldsAllTags({
  216. id,
  217. allTags
  218. });
  219. this.clueDetail.clueTags = copyClueTags;
  220. this.checkTags = this.clueDetail.clueTags.map(v => v.id);
  221. }
  222. },
  223. handleDistribution() {
  224. this.$refs.distribution.show();
  225. },
  226. confirm() {
  227. },
  228. async handleClueTagConfirm() {
  229. const allTags = this.checkTags.join(",");
  230. await uni.$u.api.updateClueFixedFieldsAllTags({
  231. id: this.clueDetail.cfId,
  232. allTags
  233. });
  234. this.getDetail();
  235. },
  236. handleAddClueTag() {
  237. this.$refs.clueTag.showModal();
  238. },
  239. handleIsInvalid() {
  240. const invalidDict = {
  241. dictValue: '6'
  242. };
  243. this.handleClickStepsItem(invalidDict);
  244. },
  245. async handleClickStepsItem(item) {
  246. const {
  247. cfId: id,
  248. clueState
  249. } = this.clueDetail;
  250. if (clueState === '6') {
  251. if (clueState === item.dictValue) {
  252. item.dictValue = '1';
  253. } else {
  254. uni.$u.toast("当前标记无效,请先取消");
  255. return;
  256. }
  257. }
  258. if (clueState === item.dictValue) {
  259. return;
  260. }
  261. if (id == null) {
  262. this.$message.error("修改异常");
  263. return;
  264. }
  265. uni.$u.api.updateClueFixedFieldsClueState({
  266. id,
  267. clueState: item.dictValue
  268. }).then(() => {
  269. this.$set(this.clueDetail, "clueState", item.dictValue);
  270. });
  271. },
  272. defaultText(text) {
  273. return text ? text : "-";
  274. },
  275. crmFollowStatusFormat(v) {
  276. return selectDictLabel(this.crmHandelStatusDict, v);
  277. },
  278. handleCopy(item) {
  279. uni.setClipboardData({
  280. data: item.telephone,
  281. success: function() {
  282. uni.$u.toast("复制成功");
  283. }
  284. });
  285. },
  286. // 添加联系人
  287. handleCallPhone() {
  288. uni.makePhoneCall({
  289. phoneNumber: this.clueDetail.telephone,
  290. success: () => {
  291. this.$store.commit("call/SET_FORM", {
  292. clueId: this.clueId,
  293. type: '3',
  294. callee: this.clueDetail.telephone
  295. })
  296. }
  297. });
  298. },
  299. // 发单
  300. async handleClueSend() {
  301. const {
  302. data: count
  303. } = await uni.$u.api.getClueSendFormCountByClueId({
  304. clueId: this.clueId
  305. });
  306. if (count > 0) {
  307. uni.showModal({
  308. title: '该线索已发单是否再次发单?',
  309. success: (res)=> {
  310. if (res.confirm) {
  311. this.toOrderForm()
  312. }
  313. }
  314. });
  315. } else {
  316. this.toOrderForm()
  317. }
  318. },
  319. toOrderForm() {
  320. const {
  321. id,
  322. ownLatestDynamicTime,
  323. createTime,
  324. clueOwnerId
  325. } = this.clueDetail;
  326. if (this.$store.state.user.userInfo.userId === clueOwnerId) {
  327. uni.navigateTo({
  328. url: `/pages/orderForm/index?clueId=${this.clueId}`
  329. })
  330. } else {
  331. // 确定用于判断的目标时间(ownLatestDynamicTime,为null则用createTime)
  332. const date = ownLatestDynamicTime || createTime
  333. const twoDaysLater = new Date(date)
  334. twoDaysLater.setDate(twoDaysLater.getDate() + 2) // 日期加2天
  335. // 是否大于当前时间 小于可以发单
  336. let isOrderForm = false
  337. if (twoDaysLater) {
  338. isOrderForm = twoDaysLater.getTime() <= new Date().getTime()
  339. }
  340. if (isOrderForm) {
  341. uni.navigateTo({
  342. url: `/pages/orderForm/index?clueId=${this.clueId}`
  343. })
  344. } else {
  345. uni.$u.toast('非所属人需两天内无跟进记录才可发单')
  346. }
  347. }
  348. },
  349. // 添加跟进记录
  350. handleAddFollow() {
  351. uni.navigateTo({
  352. url: `/pages/addFollow/index?clueId=${this.clueId}`
  353. })
  354. },
  355. handleUploadRecord() {
  356. uni.navigateTo({
  357. url: `/pages/uploadRecord/index?clueId=${this.clueId}`
  358. })
  359. },
  360. // 初始化详情页
  361. async handleInit() {
  362. this.$getDicts('crm_follow_status').then((res => {
  363. this.crmHandelStatusDict = res;
  364. }))
  365. this.$getDicts('crm_clue_phase').then((res => {
  366. this.crmCluePhaseDict = res.filter(v => v.dictValue !== '6');
  367. }))
  368. uni.$u.api.getClueTagGroupVoList({
  369. tagGroupApplication: '1'
  370. }).then(({
  371. data
  372. }) => {
  373. this.clueTagGroupVoList = data;
  374. });
  375. this.getDetail();
  376. },
  377. getDetail() {
  378. uni.$u.api.getClueMainInfoVoById({
  379. id: this.clueId
  380. }).then(res => {
  381. this.clueDetail = res.data;
  382. this.checkTags = this.clueDetail.clueTags.map(v => v.id);
  383. });
  384. },
  385. // 标签点击事件
  386. tabClick(index, item) {
  387. // // 根据索引调用对应组件的getData方法
  388. // const componentRefs = [
  389. // this.$refs.clueInfoRef,
  390. // this.$refs.advertisingRef,
  391. // this.$refs.followRecordRef,
  392. // this.$refs.callRecordRef
  393. // ];
  394. // const currentComponent = componentRefs[index];
  395. // if (currentComponent && typeof currentComponent.getData === 'function') {
  396. // currentComponent.getData();
  397. // }
  398. },
  399. // 标签切换事件
  400. tabChange(index, item) {
  401. // console.log("tabChange", index, item);
  402. },
  403. },
  404. created() {
  405. this.handleInit();
  406. },
  407. }
  408. </script>
  409. <style lang="scss" scoped>
  410. .clueTagsSelect {
  411. height: 0;
  412. overflow: hidden;
  413. }
  414. .clue_tag_wrap {
  415. display: flex;
  416. align-items: center;
  417. background-color: #fff;
  418. padding: 0 10px;
  419. margin: 20px 0;
  420. flex-wrap: wrap;
  421. min-height: 50px;
  422. .clue_tag_add_btn {
  423. font-size: 14px;
  424. color: #108cff;
  425. }
  426. }
  427. .clue_state_wrap {
  428. background-color: #fff;
  429. padding: 10px;
  430. margin-bottom: 20px;
  431. .clue_state_top_wrap {
  432. display: flex;
  433. justify-content: space-between;
  434. margin-bottom: 10px;
  435. .top_left {
  436. font-size: 16px;
  437. }
  438. .top_right {
  439. font-size: 14px;
  440. color: #4fa5fe;
  441. }
  442. }
  443. .steps_wrap {}
  444. }
  445. .clueDetail_tabber {
  446. ::v-deep .u-tabbar__content {
  447. background: #108cff;
  448. border-top-right-radius: 10px;
  449. border-top-left-radius: 10px;
  450. }
  451. }
  452. .clueDetail_wrap {
  453. .telPhone {
  454. display: flex;
  455. background: #fff;
  456. padding: 20px;
  457. justify-content: space-between;
  458. .left {
  459. display: flex;
  460. }
  461. .copy_btn {
  462. color: #4fa5fe;
  463. margin-left: 10px;
  464. }
  465. }
  466. .clueDetail_top_info {
  467. display: flex;
  468. flex-wrap: wrap;
  469. background-color: #ffffff;
  470. padding-top: 20px;
  471. margin: 18px 0;
  472. .top_info_item {
  473. width: 33.33%;
  474. text-align: center;
  475. margin-bottom: 20px;
  476. .top {
  477. font-size: 15px;
  478. color: #202020;
  479. margin-bottom: 5px;
  480. font-weight: bold;
  481. }
  482. .bottom {
  483. font-size: 15px;
  484. color: #c0c0c7;
  485. }
  486. }
  487. }
  488. }
  489. </style>