clueDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  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-order.png"
  118. @click="handleClueSend"></u-tabbar-item>
  119. <u-tabbar-item text="写新跟进" icon="../../static/caseDetail/icon-follow.png"
  120. @click="handleAddFollow"></u-tabbar-item>
  121. <u-tabbar-item text="上传录音" icon="../../static/caseDetail/icon-record.png"
  122. @click="handleUploadRecord"></u-tabbar-item>
  123. <u-tabbar-item text="分配" icon="../../static/clueDetail/icon-clue.png" v-if="isShowDistribution()"
  124. @click="handleDistribution"></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. isShowDistribution() {
  199. return this.$store.state.user.userInfo.roles.filter(i=>i.roleKey == 'ZHUGUANG-CRM').length > 0
  200. },
  201. distributionSuccess() {
  202. this.handleInit();
  203. },
  204. async hanldeTagClose(tag) {
  205. const {
  206. cfId: id,
  207. clueTags
  208. } = this.clueDetail;
  209. const copyClueTags = cloneDeep(clueTags);
  210. if (id == null) {
  211. this.$message.error("修改异常");
  212. return;
  213. }
  214. const index = copyClueTags.findIndex(v => v.id === tag.id);
  215. if (index !== -1) {
  216. copyClueTags.splice(index, 1);
  217. const allTags = copyClueTags.map(v => v.id).join(",");
  218. await uni.$u.api.updateClueFixedFieldsAllTags({
  219. id,
  220. allTags
  221. });
  222. this.clueDetail.clueTags = copyClueTags;
  223. this.checkTags = this.clueDetail.clueTags.map(v => v.id);
  224. }
  225. },
  226. handleDistribution() {
  227. this.$refs.distribution.show();
  228. },
  229. confirm() {
  230. },
  231. async handleClueTagConfirm() {
  232. const allTags = this.checkTags.join(",");
  233. await uni.$u.api.updateClueFixedFieldsAllTags({
  234. id: this.clueDetail.cfId,
  235. allTags
  236. });
  237. this.getDetail();
  238. },
  239. handleAddClueTag() {
  240. this.$refs.clueTag.showModal();
  241. },
  242. handleIsInvalid() {
  243. const invalidDict = {
  244. dictValue: '6'
  245. };
  246. this.handleClickStepsItem(invalidDict);
  247. },
  248. async handleClickStepsItem(item) {
  249. const {
  250. cfId: id,
  251. clueState
  252. } = this.clueDetail;
  253. if (clueState === '6') {
  254. if (clueState === item.dictValue) {
  255. item.dictValue = '1';
  256. } else {
  257. uni.$u.toast("当前标记无效,请先取消");
  258. return;
  259. }
  260. }
  261. if (clueState === item.dictValue) {
  262. return;
  263. }
  264. if (id == null) {
  265. this.$message.error("修改异常");
  266. return;
  267. }
  268. uni.$u.api.updateClueFixedFieldsClueState({
  269. id,
  270. clueState: item.dictValue
  271. }).then(() => {
  272. this.$set(this.clueDetail, "clueState", item.dictValue);
  273. });
  274. },
  275. defaultText(text) {
  276. return text ? text : "-";
  277. },
  278. crmFollowStatusFormat(v) {
  279. return selectDictLabel(this.crmHandelStatusDict, v);
  280. },
  281. handleCopy(item) {
  282. uni.setClipboardData({
  283. data: item.telephone,
  284. success: function() {
  285. uni.$u.toast("复制成功");
  286. }
  287. });
  288. },
  289. // 添加联系人
  290. handleCallPhone() {
  291. uni.makePhoneCall({
  292. phoneNumber: this.clueDetail.telephone,
  293. success: () => {
  294. this.$store.commit("call/SET_FORM", {
  295. clueId: this.clueId,
  296. type: '3',
  297. callee: this.clueDetail.telephone
  298. })
  299. }
  300. });
  301. },
  302. // 发单
  303. async handleClueSend() {
  304. const {
  305. data: count
  306. } = await uni.$u.api.getClueSendFormCountByClueId({
  307. clueId: this.clueId
  308. });
  309. if (count > 0) {
  310. uni.showModal({
  311. title: '该线索已发单是否再次发单?',
  312. success: (res)=> {
  313. if (res.confirm) {
  314. this.toOrderForm()
  315. }
  316. }
  317. });
  318. } else {
  319. this.toOrderForm()
  320. }
  321. },
  322. toOrderForm() {
  323. const {
  324. id,
  325. ownLatestDynamicTime,
  326. createTime,
  327. clueOwnerId
  328. } = this.clueDetail;
  329. if (this.$store.state.user.userInfo.userId === clueOwnerId) {
  330. uni.navigateTo({
  331. url: `/pages/orderForm/index?clueId=${this.clueId}`
  332. })
  333. } else {
  334. // 确定用于判断的目标时间(ownLatestDynamicTime,为null则用createTime)
  335. const date = ownLatestDynamicTime || createTime
  336. const twoDaysLater = new Date(date)
  337. twoDaysLater.setDate(twoDaysLater.getDate() + 2) // 日期加2天
  338. // 是否大于当前时间 小于可以发单
  339. let isOrderForm = false
  340. if (twoDaysLater) {
  341. isOrderForm = twoDaysLater.getTime() <= new Date().getTime()
  342. }
  343. if (isOrderForm) {
  344. uni.navigateTo({
  345. url: `/pages/orderForm/index?clueId=${this.clueId}`
  346. })
  347. } else {
  348. uni.$u.toast('非所属人需两天内无跟进记录才可发单')
  349. }
  350. }
  351. },
  352. // 添加跟进记录
  353. handleAddFollow() {
  354. uni.navigateTo({
  355. url: `/pages/addFollow/index?clueId=${this.clueId}`
  356. })
  357. },
  358. handleUploadRecord() {
  359. uni.navigateTo({
  360. url: `/pages/uploadRecord/index?clueId=${this.clueId}`
  361. })
  362. },
  363. // 初始化详情页
  364. async handleInit() {
  365. this.$getDicts('crm_follow_status').then((res => {
  366. this.crmHandelStatusDict = res;
  367. }))
  368. this.$getDicts('crm_clue_phase').then((res => {
  369. this.crmCluePhaseDict = res.filter(v => v.dictValue !== '6');
  370. }))
  371. uni.$u.api.getClueTagGroupVoList({
  372. tagGroupApplication: '1'
  373. }).then(({
  374. data
  375. }) => {
  376. this.clueTagGroupVoList = data;
  377. });
  378. this.getDetail();
  379. },
  380. getDetail() {
  381. uni.$u.api.getClueMainInfoVoById({
  382. id: this.clueId
  383. }).then(res => {
  384. this.clueDetail = res.data;
  385. this.checkTags = this.clueDetail.clueTags.map(v => v.id);
  386. });
  387. },
  388. // 标签点击事件
  389. tabClick(index, item) {
  390. // // 根据索引调用对应组件的getData方法
  391. // const componentRefs = [
  392. // this.$refs.clueInfoRef,
  393. // this.$refs.advertisingRef,
  394. // this.$refs.followRecordRef,
  395. // this.$refs.callRecordRef
  396. // ];
  397. // const currentComponent = componentRefs[index];
  398. // if (currentComponent && typeof currentComponent.getData === 'function') {
  399. // currentComponent.getData();
  400. // }
  401. },
  402. // 标签切换事件
  403. tabChange(index, item) {
  404. // console.log("tabChange", index, item);
  405. },
  406. },
  407. created() {
  408. this.handleInit();
  409. },
  410. }
  411. </script>
  412. <style lang="scss" scoped>
  413. .clueTagsSelect {
  414. height: 0;
  415. overflow: hidden;
  416. }
  417. .clue_tag_wrap {
  418. display: flex;
  419. align-items: center;
  420. background-color: #fff;
  421. padding: 0 10px;
  422. margin: 20px 0;
  423. flex-wrap: wrap;
  424. min-height: 50px;
  425. .clue_tag_add_btn {
  426. font-size: 14px;
  427. color: #108cff;
  428. }
  429. }
  430. .clue_state_wrap {
  431. background-color: #fff;
  432. padding: 10px;
  433. margin-bottom: 20px;
  434. .clue_state_top_wrap {
  435. display: flex;
  436. justify-content: space-between;
  437. margin-bottom: 10px;
  438. .top_left {
  439. font-size: 16px;
  440. }
  441. .top_right {
  442. font-size: 14px;
  443. color: #4fa5fe;
  444. }
  445. }
  446. .steps_wrap {}
  447. }
  448. .clueDetail_tabber {
  449. ::v-deep .u-tabbar__content {
  450. background: #108cff;
  451. border-top-right-radius: 10px;
  452. border-top-left-radius: 10px;
  453. }
  454. }
  455. .clueDetail_wrap {
  456. .telPhone {
  457. display: flex;
  458. background: #fff;
  459. padding: 20px;
  460. justify-content: space-between;
  461. .left {
  462. display: flex;
  463. }
  464. .copy_btn {
  465. color: #4fa5fe;
  466. margin-left: 10px;
  467. }
  468. }
  469. .clueDetail_top_info {
  470. display: flex;
  471. flex-wrap: wrap;
  472. background-color: #ffffff;
  473. padding-top: 20px;
  474. margin: 18px 0;
  475. .top_info_item {
  476. width: 33.33%;
  477. text-align: center;
  478. margin-bottom: 20px;
  479. .top {
  480. font-size: 15px;
  481. color: #202020;
  482. margin-bottom: 5px;
  483. font-weight: bold;
  484. }
  485. .bottom {
  486. font-size: 15px;
  487. color: #c0c0c7;
  488. }
  489. }
  490. }
  491. }
  492. </style>