import {
|
mapGetters
|
} from 'vuex'
|
|
import { moneyFormat } from '@/utils'
|
|
export default {
|
data () {
|
return {}
|
},
|
props: {
|
/** 是公海 默认是客户 */
|
isSeas: {
|
type: Boolean,
|
default: false
|
}
|
},
|
|
computed: {
|
...mapGetters(['crm']),
|
// 能否查看详情
|
canShowDetail () {
|
// if (this.detailData.length === 0) {
|
// return false
|
// }
|
// return this.crm && this.crm[this.crmType] && this.crm[this.crmType].read
|
return true
|
}
|
},
|
|
watch: {
|
id: function () {
|
if (this.canShowDetail) {
|
this.getDetial()
|
}
|
}
|
},
|
|
mounted () {
|
if (this.canShowDetail) {
|
this.getDetial()
|
}
|
},
|
|
methods: {
|
/** 顶部头 操作 */
|
detailHeadHandle (data) {
|
console.log(data)
|
if (data.type === 'edit') {
|
this.isCreate = true
|
} else if (data.type === 'delete') {
|
this.hideView()
|
} else if (data.type === 'discard') {
|
this.getDetial()
|
}
|
this.$emit('handle', data)
|
},
|
moneyFormat (money) {
|
return moneyFormat(money)
|
},
|
//* * tab标签点击 */
|
handleClick (tab, event) {},
|
// 滚动条滚动
|
onScroll (e) {
|
console.log('onscrll事件')
|
let scrollItems = document.querySelectorAll('.scroll-item')
|
console.log(scrollItems)
|
for (let i = scrollItems.length - 1; i >= 0; i--) {
|
// 判断滚动条滚动距离是否大于当前滚动项可滚动距离
|
let judge = e.target.scrollTop >= scrollItems[i].offsetTop - scrollItems[0].offsetTop
|
// console.log(e.target.scrollTop, scrollItems[i].offsetTop, scrollItems[0].offsetTop)
|
if (judge) {
|
this.tabCurrentName = this.tabnames[i].name
|
|
break
|
}
|
}
|
},
|
jump (index, info) {
|
console.log(index, info, this.tabCurrentName)
|
let target = document.querySelector('.t-loading-content')
|
let scrollItems = document.querySelectorAll('.scroll-item')
|
// 判断滚动条是否滚动到底部
|
if (target.scrollHeight <= target.scrollTop + target.clientHeight) {
|
this.tabCurrentName = this.tabnames[index.index].name
|
}
|
let totalY = scrollItems[index.index].offsetTop - scrollItems[0].offsetTop // 锚点元素距离其offsetParent(这里是body)顶部的距离(待滚动的距离)
|
let distance = document.querySelector('.t-loading-content').scrollTop // 滚动条距离滚动区域顶部的距离
|
// let distance = document.body.scrollTop || document.documentElement.scrollTop || window.pageYOffset // 滚动条距离滚动区域顶部的距离(滚动区域为窗口)
|
// 滚动动画实现, 使用setTimeout的递归实现平滑滚动,将距离细分为50小段,10ms滚动一次
|
// 计算每一小段的距离
|
let step = totalY / 50
|
if (totalY > distance) {
|
smoothDown(document.querySelector('.t-loading-content'))
|
} else {
|
let newTotal = distance - totalY
|
step = newTotal / 50
|
smoothUp(document.querySelector('.t-loading-content'))
|
}
|
|
// 参数element为滚动区域
|
function smoothDown (element) {
|
if (distance < totalY) {
|
distance += step
|
element.scrollTop = distance
|
setTimeout(smoothDown.bind(this, element), 10)
|
} else {
|
element.scrollTop = totalY
|
}
|
}
|
|
// 参数element为滚动区域
|
function smoothUp (element) {
|
if (distance > totalY) {
|
distance -= step
|
element.scrollTop = distance
|
setTimeout(smoothUp.bind(this, element), 10)
|
} else {
|
element.scrollTop = totalY
|
}
|
}
|
}
|
},
|
|
deactivated: function () { }
|
|
}
|