detail.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. import { QueryFlowSettingList } from '@/api/crm/flow.js'
  2. import { crmEnum } from '../enum.js'
  3. export default {
  4. data() {
  5. return {
  6. id: null,
  7. detailData: {},
  8. routerQuery: {},
  9. tabs: [
  10. { label: '活动记录', value: 0 },
  11. { label: '基本信息', value: 1 },
  12. { label: '相关信息', value: 2 }
  13. ],
  14. activeTab: 0,
  15. commandValue: null,
  16. dialogMsg: '',
  17. guid: null,
  18. flowData: null,
  19. refreshPage: false, // 刷新页面标志
  20. refreshPrevPage: false
  21. }
  22. },
  23. watch: {
  24. id: {
  25. handler() {
  26. this.$nextTick(() => {
  27. if (this.id) {
  28. this.getFlowSetting()
  29. }
  30. })
  31. },
  32. deep: true,
  33. immediate: true
  34. }
  35. },
  36. created() {
  37. this.guid = this.$guid()
  38. },
  39. onLoad(options) {
  40. this.routerQuery = options
  41. this.id = options.id || null
  42. this.getDetail()
  43. },
  44. onShow() {
  45. this.refreshNowPage()
  46. },
  47. onBackPress(evt) {
  48. if (evt.from === 'backbutton' && this.refreshPrevPage) {
  49. this.$refreshAndToPrev(this)
  50. return true // 返回值为 true 时,表示不执行默认的返回
  51. }
  52. return false
  53. },
  54. methods: {
  55. goBack() {
  56. setTimeout(() => {
  57. this.$Router.navigateBack()
  58. }, 1000)
  59. },
  60. refreshNowPage() {
  61. console.log('refresh now page: ', this.refreshPage)
  62. if (this.refreshPage) {
  63. this.$nextTick(function() {
  64. console.log('refresh')
  65. this.refreshPage = false
  66. this.refreshPrevPage = true
  67. const id = this.id
  68. // this.id = null
  69. this.$nextTick(() => {
  70. this.id = id
  71. this.getDetail()
  72. })
  73. })
  74. }
  75. },
  76. /**
  77. * 查询阶段流程配置信息
  78. */
  79. getFlowSetting() {
  80. let type = this.comType.replace('crm_', '')
  81. if (type === 'pool') {
  82. type = 'customer'
  83. }
  84. QueryFlowSettingList({
  85. typeId: this.id,
  86. label: crmEnum[type].type
  87. }).then(res => {
  88. this.flowData = res.data || null
  89. }).catch(() => {})
  90. },
  91. /**
  92. * 背景图url
  93. * @param {String} val
  94. */
  95. bgUrl(val) {
  96. return `url(${this.$static(val)})`
  97. },
  98. /**
  99. * 切换tab
  100. * @param {Number} val
  101. */
  102. handleToggleTabs(val) {
  103. this.activeTab = val
  104. },
  105. /**
  106. * 编辑
  107. */
  108. handleEdit() {
  109. const type = this.comType.replace('crm_', '')
  110. const query = {
  111. id: this.id,
  112. batchId: this.detailData.batchId
  113. }
  114. console.log(type)
  115. if (['receivables', 'contract', 'invoice'].includes(type)) {
  116. query.type = type
  117. }
  118. this.$Router.navigateTo({
  119. url: `/pages_crm/${type}/create`,
  120. query
  121. })
  122. },
  123. handleScrollTolower() {
  124. console.log('scroll bottom')
  125. // 如果是活动记录滚动到底部,则去加载下一页数据
  126. const el = this.$refs.activity || null
  127. if (this.activeTab === 0 && el) {
  128. this.$refs.activity.getNext()
  129. }
  130. },
  131. /**
  132. * 去修改负责人
  133. */
  134. handleToChangeOwnerUser() {
  135. const bridge = getApp().globalData.selectedValBridge
  136. const that = this
  137. bridge.user = {
  138. guid: this.guid,
  139. title: '选择负责人',
  140. defaultVal: [],
  141. maxlength: 1,
  142. config: {
  143. checkFn: ({ data }) => {
  144. if (data.length === 0) {
  145. this.$toast('请选择负责人')
  146. return false
  147. }
  148. if (data[0].userId == that.detailData.ownerUserId) {
  149. this.$toast('已经是负责人啦')
  150. return false
  151. }
  152. return true
  153. }
  154. }
  155. }
  156. uni.$on('selected-user', this.selectedUser)
  157. this.$Router.navigateTo('/pages_common/selectList/user')
  158. },
  159. selectedUser(data) {
  160. if (this.guid === data.guid) {
  161. if (data.data.length > 0) {
  162. this.$nextTick(function() {
  163. this.handleTransfer(data.data[0])
  164. })
  165. }
  166. }
  167. uni.$off('selected-user')
  168. },
  169. /**
  170. * 打电话
  171. * @param {String} tel
  172. */
  173. ringUp(tel) {
  174. if (!tel) return
  175. uni.makePhoneCall({
  176. phoneNumber: tel
  177. })
  178. },
  179. }
  180. }