import { QueryFlowSettingList } from '@/api/crm/flow.js' import { crmEnum } from '../enum.js' export default { data() { return { id: null, detailData: {}, routerQuery: {}, tabs: [ { label: '活动记录', value: 0 }, { label: '基本信息', value: 1 }, { label: '相关信息', value: 2 } ], activeTab: 0, commandValue: null, dialogMsg: '', guid: null, flowData: null, refreshPage: false, // 刷新页面标志 refreshPrevPage: false } }, watch: { id: { handler() { this.$nextTick(() => { if (this.id) { this.getFlowSetting() } }) }, deep: true, immediate: true } }, created() { this.guid = this.$guid() }, onLoad(options) { this.routerQuery = options this.id = options.id || null this.getDetail() }, onShow() { this.refreshNowPage() }, onBackPress(evt) { if (evt.from === 'backbutton' && this.refreshPrevPage) { this.$refreshAndToPrev(this) return true // 返回值为 true 时,表示不执行默认的返回 } return false }, methods: { goBack() { setTimeout(() => { this.$Router.navigateBack() }, 1000) }, refreshNowPage() { console.log('refresh now page: ', this.refreshPage) if (this.refreshPage) { this.$nextTick(function() { console.log('refresh') this.refreshPage = false this.refreshPrevPage = true const id = this.id // this.id = null this.$nextTick(() => { this.id = id this.getDetail() }) }) } }, /** * 查询阶段流程配置信息 */ getFlowSetting() { let type = this.comType.replace('crm_', '') if (type === 'pool') { type = 'customer' } QueryFlowSettingList({ typeId: this.id, label: crmEnum[type].type }).then(res => { this.flowData = res.data || null }).catch(() => {}) }, /** * 背景图url * @param {String} val */ bgUrl(val) { return `url(${this.$static(val)})` }, /** * 切换tab * @param {Number} val */ handleToggleTabs(val) { this.activeTab = val }, /** * 编辑 */ handleEdit() { const type = this.comType.replace('crm_', '') const query = { id: this.id, batchId: this.detailData.batchId } console.log(type) if (['receivables', 'contract', 'invoice'].includes(type)) { query.type = type } this.$Router.navigateTo({ url: `/pages_crm/${type}/create`, query }) }, handleScrollTolower() { console.log('scroll bottom') // 如果是活动记录滚动到底部,则去加载下一页数据 const el = this.$refs.activity || null if (this.activeTab === 0 && el) { this.$refs.activity.getNext() } }, /** * 去修改负责人 */ handleToChangeOwnerUser() { const bridge = getApp().globalData.selectedValBridge const that = this bridge.user = { guid: this.guid, title: '选择负责人', defaultVal: [], maxlength: 1, config: { checkFn: ({ data }) => { if (data.length === 0) { this.$toast('请选择负责人') return false } if (data[0].userId == that.detailData.ownerUserId) { this.$toast('已经是负责人啦') return false } return true } } } uni.$on('selected-user', this.selectedUser) this.$Router.navigateTo('/pages_common/selectList/user') }, selectedUser(data) { if (this.guid === data.guid) { if (data.data.length > 0) { this.$nextTick(function() { this.handleTransfer(data.data[0]) }) } } uni.$off('selected-user') }, /** * 打电话 * @param {String} tel */ ringUp(tel) { if (!tel) return uni.makePhoneCall({ phoneNumber: tel }) }, } }