detail.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <view v-if="!refreshPage && !$isEmpty(detailData)" class="uni-app">
  3. <view class="status-bar" />
  4. <wk-nav-bar
  5. :command-list="commandList"
  6. :refresh-prev="refreshPrevPage"
  7. title="客户详情"
  8. theme="white"
  9. class="nav-bar"
  10. @command="handleCommand" />
  11. <scroll-view
  12. :scroll-y="true"
  13. class="main-container scroll-view-hook"
  14. @scrolltolower="handleScrollTolower">
  15. <view class="header-top">
  16. <view class="bg linear-gradient" />
  17. <view class="card">
  18. <view class="title-cell">
  19. <image :src="$static('images/crm/gray_customer.png')" class="type-icon" />
  20. <view class="title-text">
  21. <text class="text">
  22. {{ detailData.customerName || '' }}
  23. </text>
  24. <text v-if="detailData.status === 2" class="wk wk-lock" />
  25. </view>
  26. <view :class="detailData.dealStatus === 1 ? 'success' : 'info'" class="title-status">
  27. <text>{{ detailData.dealStatus === 1 ? '已成交' : '未成交' }}</text>
  28. </view>
  29. </view>
  30. <view class="main-info">
  31. <view class="info-item">
  32. 负责人:{{ detailData.ownerUserName || '&#45;&#45;' }}
  33. </view>
  34. <view class="info-item">
  35. 联系方式:{{ detailData.mobile || '&#45;&#45;' }}
  36. </view>
  37. </view>
  38. <image
  39. v-if="detailData.mobile"
  40. :src="$static('images/icon/call_up.png')"
  41. class="call-up"
  42. @click="ringUp(detailData.mobile)" />
  43. <view class="main-info">
  44. <flow-progress
  45. v-if="detailData"
  46. :type="comType"
  47. :detail-id="id"
  48. :detail-data="detailData" />
  49. </view>
  50. </view>
  51. </view>
  52. <view ref="wkTabs" class="wk-tabs">
  53. <view
  54. v-for="(tab, index) in tabs"
  55. :key="index"
  56. :class="{active: activeTab === tab.value}"
  57. class="wk-tab-item"
  58. @click="handleToggleTabs(tab.value)">
  59. {{ tab.label }}
  60. </view>
  61. </view>
  62. <wk-keep-alive v-if="id" v-model="activeTab">
  63. <wk-keep-alive-item>
  64. <detail-activity-list
  65. ref="activity"
  66. :detail-id="id"
  67. :type="comType"
  68. activity-title="客户" />
  69. </wk-keep-alive-item>
  70. <wk-keep-alive-item>
  71. <detail-base-info :detail-id="id" :type="comType" class="detail-container" />
  72. </wk-keep-alive-item>
  73. <wk-keep-alive-item>
  74. <detail-about
  75. :detail-id="id"
  76. :detail-data="detailData"
  77. :batch-id="detailData.batchId"
  78. class="detail-about-container" />
  79. </wk-keep-alive-item>
  80. </wk-keep-alive>
  81. </scroll-view>
  82. <uni-popup ref="popup" type="dialog">
  83. <uni-popup-dialog
  84. :content="dialogMsg"
  85. type="warning"
  86. @confirm="handleDialogConfirm" />
  87. </uni-popup>
  88. </view>
  89. </template>
  90. <script>
  91. import {
  92. QueryById,
  93. Transfer,
  94. Lock,
  95. UpdateCustomerByIds,
  96. DeleteByIds,
  97. SetDealStatus
  98. } from 'API/crm/customer'
  99. import {
  100. QueryById as MainUser
  101. } from 'API/crm/concat'
  102. import {
  103. PoolNameList
  104. } from 'API/crm/pool'
  105. import DetailBaseInfo from '../components/detailSection/baseInfo'
  106. import DetailActivityList from '../components/detailSection/activityList'
  107. import DetailAbout from './components/tabsAbout'
  108. import FlowProgress from '../components/customFlow/flowProgress.vue'
  109. import detailMixins from '../mixins/detail.js'
  110. export default {
  111. name: 'CustomerDetail',
  112. components: {
  113. DetailBaseInfo,
  114. DetailActivityList,
  115. DetailAbout,
  116. FlowProgress
  117. },
  118. mixins: [detailMixins],
  119. data() {
  120. return {
  121. comType: 'crm_customer',
  122. mainUserInfo: {},
  123. commandList: [
  124. {
  125. label: '转移',
  126. imgIcon: 'transfer',
  127. auth: 'crm.customer.transfer',
  128. value: 'transfer'
  129. },
  130. {
  131. label: '锁定',
  132. imgIcon: 'lock',
  133. auth: 'crm.customer.lock',
  134. value: 'lock'
  135. },
  136. {
  137. label: '放入公海',
  138. imgIcon: 'putinpool',
  139. auth: 'crm.customer.putinpool',
  140. value: 'putinpool'
  141. },
  142. {
  143. label: '更改成交状态',
  144. imgIcon: 'dealStatus',
  145. auth: 'crm.customer.dealStatus',
  146. value: 'dealStatus'
  147. },
  148. {
  149. label: '编辑',
  150. imgIcon: 'update',
  151. auth: 'crm.customer.update',
  152. value: 'update'
  153. },
  154. {
  155. label: '删除',
  156. imgIcon: 'delete',
  157. auth: 'crm.customer.delete',
  158. value: 'delete'
  159. },
  160. ]
  161. }
  162. },
  163. methods: {
  164. getDetail() {
  165. QueryById({
  166. customerId: this.id
  167. }).then(res => {
  168. console.log('detail: ', res)
  169. this.detailData = res
  170. this.commandList[1].label = res.status === 2 ? '解锁' : '锁定'
  171. this.commandList[1].imgIcon = res.status === 2 ? 'unlock' : 'lock'
  172. this.getMainUser()
  173. }).catch(() => {
  174. this.goBack()
  175. })
  176. },
  177. /**
  178. * 获取首要联系人详情
  179. */
  180. getMainUser() {
  181. if (!this.detailData.contactsId) return
  182. MainUser({
  183. contactsId: this.detailData.contactsId
  184. }).then(res => {
  185. if (!res.hasOwnProperty('dataAuth')) {
  186. this.mainUserInfo = res
  187. }
  188. }).catch()
  189. },
  190. handleCommand(command) {
  191. this.commandValue = command.value
  192. switch (command.value) {
  193. case 'transfer':
  194. this.handleToChangeOwnerUser()
  195. break
  196. case 'lock':
  197. this.dialogMsg = `您确定要${command.label}该客户吗?`
  198. this.$refs.popup.open()
  199. break
  200. case 'putinpool':
  201. this.handleToChoosePool()
  202. break
  203. case 'dealStatus':
  204. this.dialogMsg = `您确定要将该客户更改为${this.detailData.dealStatus === 0 ? '已成交' : '未成交'}吗?`
  205. this.$refs.popup.open()
  206. break
  207. case 'update':
  208. this.handleEdit()
  209. break
  210. case 'delete':
  211. this.dialogMsg = '您确定要删除该客户吗?'
  212. this.$refs.popup.open()
  213. break
  214. }
  215. },
  216. handleDialogConfirm(next) {
  217. switch (this.commandValue) {
  218. case 'lock':
  219. this.lockCustomer()
  220. break
  221. case 'dealStatus':
  222. this.changeDealStatus()
  223. break
  224. case 'delete':
  225. this.deleteCustomer()
  226. break
  227. }
  228. next()
  229. },
  230. handleToChoosePool() {
  231. const bridge = getApp().globalData.selectedValBridge
  232. const that = this
  233. bridge.options = {
  234. guid: this.guid,
  235. title: '选择公海',
  236. defaultVal: [],
  237. maxlength: 1,
  238. request: PoolNameList,
  239. config: {
  240. labelField: 'poolName',
  241. valueField: 'poolId',
  242. checkFn: ({ data }) => {
  243. if (data.length === 0) {
  244. this.$toast('请选择要放入的公海')
  245. return false
  246. }
  247. return true
  248. }
  249. }
  250. }
  251. uni.$on('selected-options', this.selectedPool)
  252. this.$Router.navigateTo('/pages_common/selectList/options')
  253. },
  254. selectedPool(data) {
  255. if (this.guid === data.guid) {
  256. if (data.data.length > 0) {
  257. this.$nextTick(function() {
  258. this.seasCustomer(data.data[0])
  259. })
  260. }
  261. }
  262. uni.$off('selected-options')
  263. },
  264. /**
  265. * 转移
  266. * @param {Object} user
  267. */
  268. handleTransfer(user) {
  269. let params = {
  270. ids: [this.id],
  271. ownerUserId: user.userId,
  272. transferType: 1,
  273. changeType: []
  274. }
  275. Transfer(params).then(() => {
  276. this.$toast('转移成功')
  277. this.$refreshAndToPrev(this)
  278. }).catch()
  279. },
  280. toContactsDetail() {
  281. if (!this.mainUserInfo.contactsId) return
  282. this.$Router.navigateTo({
  283. url: '/pages_crm/contacts/detail',
  284. query: {
  285. id: this.mainUserInfo.contactsId
  286. }
  287. })
  288. },
  289. /**
  290. * 锁定/解锁
  291. */
  292. lockCustomer() {
  293. let params = {
  294. ids: this.id,
  295. status: this.detailData.status === 1 ? 2 : 1
  296. };
  297. Lock(params).then(() => {
  298. this.$toast(this.detailData.status === 1 ? '锁定成功' : '解锁成功')
  299. this.getDetail()
  300. }).catch()
  301. },
  302. /**
  303. * 更改成交状态
  304. */
  305. changeDealStatus() {
  306. SetDealStatus({
  307. ids: this.id,
  308. dealStatus: this.detailData.dealStatus === 0 ? 1 : 0
  309. }).then(() => {
  310. this.$toast('修改成功')
  311. this.getDetail()
  312. }).catch()
  313. },
  314. /**
  315. * 放入公海
  316. */
  317. seasCustomer(data) {
  318. UpdateCustomerByIds({
  319. ids: [this.id],
  320. poolId: data.poolId
  321. }).then(() => {
  322. this.$toast('放入公海成功')
  323. this.$refreshAndToPrev(this)
  324. })
  325. },
  326. /**
  327. * 删除
  328. */
  329. deleteCustomer() {
  330. DeleteByIds([this.id]).then(() => {
  331. this.$toast('删除成功')
  332. this.$refreshAndToPrev(this)
  333. })
  334. },
  335. }
  336. }
  337. </script>
  338. <style scoped lang="scss">
  339. @import "../style/detail.scss";
  340. .header-top {
  341. .card {
  342. .title-status {
  343. &.success {
  344. color: #FFFFFF;
  345. background-color: #FF8700;
  346. }
  347. &.info {
  348. color: #BBBBBB;
  349. background-color: #EEEEEE;
  350. }
  351. }
  352. .main-info {
  353. margin-bottom: 25rpx;
  354. }
  355. .call-up {
  356. position: absolute;
  357. right: 20rpx;
  358. top: 105rpx;
  359. width: 116rpx;
  360. height: 116rpx;
  361. }
  362. }
  363. }
  364. </style>