215 lines
6.8 KiB
Vue
215 lines
6.8 KiB
Vue
<template>
|
|
<div>
|
|
<template v-if="statusType && statusNo">
|
|
<!-- placement="topLeft"-->
|
|
<a-tooltip
|
|
overlay-class-name="status-tooltip"
|
|
:title="currentTitle"
|
|
arrow-point-at-center
|
|
:mouse-enter-delay="0.1"
|
|
@visibleChange="visibleChange">
|
|
<img :src="status" @click="s"/>
|
|
</a-tooltip>
|
|
</template>
|
|
<template v-else>
|
|
<img :src="status" @click="s"/>
|
|
</template>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import zero from '../../assets/imgs/zero.png'
|
|
import finished from '../../assets/imgs/finished.png'
|
|
import half from '../../assets/imgs/half.png'
|
|
import error from '../../assets/imgs/error.png'
|
|
// 获得当前行数据的方法,默认写的是 普通项目获得数据的方法,其他模块需要以传参的方式修改相应的方法
|
|
import { queryCommonProjectById } from '../../api/incomePaymentsApi'
|
|
import { ProjectTypeEnums } from '@/enums/commonEnums'
|
|
|
|
export default {
|
|
name: 'StatusSlot',
|
|
data() {
|
|
return {
|
|
currentTitle: ' ', // 气泡中显示的文字,必须有内容,否则dom选择时不会解析
|
|
hasInfo: false // 是否有详情信息可以显示,即是否通过接口请求过数据
|
|
}
|
|
},
|
|
props: {
|
|
/*
|
|
* 表格行对象
|
|
* */
|
|
statuObj: {
|
|
type: Object,
|
|
required: false
|
|
},
|
|
/*
|
|
* false 代表是打包 和需要发票
|
|
* true 代表其他三个
|
|
* */
|
|
statusType: {
|
|
type: Boolean,
|
|
required: false,
|
|
default: false
|
|
},
|
|
/*
|
|
* 具体的状态值
|
|
* */
|
|
statusNo: {
|
|
type: Number,
|
|
required: false
|
|
},
|
|
// 当前需要转换key的属性, 悬浮显示实际具体内容信息时需要
|
|
// paymentRecord 来款 confirm-确认收入 mail -- 邮寄 bill--开票; pack--打包
|
|
statusKey: {
|
|
type: String,
|
|
required: false,
|
|
default: 'paymentRecord'
|
|
},
|
|
// 获得tooltip详情信息的方法
|
|
getInfoFunc: {
|
|
type: Function,
|
|
required: false,
|
|
default: queryCommonProjectById
|
|
},
|
|
// 打包的字段 如果打包,其他的字段全部置灰 如果为空,不做判断
|
|
packField: {
|
|
type: String,
|
|
required: false,
|
|
default: 'pack'
|
|
}
|
|
},
|
|
computed: {
|
|
// eslint-disable-next-line vue/return-in-computed-property
|
|
status() {
|
|
// 非打包项目,其他项目如果被打包,就除了打包列全部置灰
|
|
// 如果有打包字段 && 当前列不是打包列 && 当前行是打包为"是" && 当前项目不是打包项目
|
|
if (this.packField && this.statusKey !== 'pack' && this.statuObj[this.packField] === 1 && this.statuObj.projectType !== ProjectTypeEnums.PACK_PRO.value) {
|
|
return zero
|
|
}
|
|
if (this.statuObj.amountReceivable === '0.00' || this.statuObj.receivableAmount === '0.00') {
|
|
if (this.statusType) {
|
|
// 待确收金额为0 未到账 未邮寄 未开票的状态
|
|
return zero
|
|
} else {
|
|
// 待确收金额为0 打包 与需要开票的状态 打包与需要开票 只有√和×的状态
|
|
if (this.statusNo === 0) {
|
|
return error
|
|
} else if (this.statusNo === 1 || this.statusNo === 2) {
|
|
// 打包只有 0和 1 需要发票 有 0(不需要发票) 1(普通发票) 2(增值税发票)
|
|
return finished
|
|
}
|
|
}
|
|
|
|
} else {
|
|
// 待确收金额不为0 都正常判断
|
|
if (this.statusNo === 0) {
|
|
// 开票或邮寄时,不需要发票
|
|
if ((this.statusKey === 'bill' || this.statusKey === 'mail') && this.statuObj.needInvoice === 0) {
|
|
return zero
|
|
} else {
|
|
return error
|
|
}
|
|
} else if (this.statusNo === 1) {
|
|
return finished
|
|
} else if (this.statusNo === 2) {
|
|
// 如果不是打包和需要发票
|
|
if (this.statusType) {
|
|
return half
|
|
} else {
|
|
return finished
|
|
}
|
|
} else if(this.statusNo === 4) {
|
|
// 确认收入莫名其妙的出现了 4, 所以修改成 全部确认的样式
|
|
return finished
|
|
}
|
|
}
|
|
},
|
|
// 操作返回数据的key值,此处是根据业务逻辑处理的
|
|
opeStatusKey() {
|
|
let result = this.statusKey
|
|
if (this.statusKey === 'mail' || this.statusKey === 'bill') {
|
|
result = 'mailBill'
|
|
}
|
|
return result
|
|
}
|
|
},
|
|
created() {
|
|
|
|
},
|
|
methods: {
|
|
s() {
|
|
console.log(this.statuObj)
|
|
},
|
|
visibleChange(visible) {
|
|
// 到账、开票、邮寄 的时候,请求接口获得相应的数据
|
|
// 判断条件 tooltip显示、 有不同的统计状态,统计状态值不为0 没有请求过详情数据
|
|
if (visible && this.statusType && this.statusNo && !this.hasInfo) {
|
|
let idKey = this.statusKey === 'confirm' && 'projectId' || 'id'
|
|
this.getInfoFunc({ [idKey]: this.statuObj.id }).then(res => {
|
|
if (res.success) {
|
|
let arr = []
|
|
if(this.statusKey === 'confirm') {
|
|
// 确认收入单独的实现逻辑
|
|
arr = res.result || []
|
|
} else {
|
|
arr = res.result[this.opeStatusKey] || []
|
|
}
|
|
let result = []
|
|
arr.map(tt => {
|
|
result.push(this.showTemplate(tt))
|
|
})
|
|
// 对tooltip中的文字进行替换
|
|
this.currentTitle = result.join('\n')
|
|
this.hasInfo = true
|
|
|
|
}
|
|
})
|
|
}
|
|
},
|
|
/**
|
|
* 显示的模板数据,即根据返回值怎么处理数据
|
|
* 判断是否存在一句话里所有变量为null,存在就不显示那句话了
|
|
* @param item -传入的item的值
|
|
* @return 返回一个模板字符串用于后续显示,可按照需求进行更改
|
|
*/
|
|
showTemplate(item) {
|
|
let result = ''
|
|
console.log(item)
|
|
// 来款
|
|
if (this.statusKey === 'paymentRecord') {
|
|
if (item.paymentDate || item.amountReceived) {
|
|
result = `${ item.paymentDate }到账${ item.amountReceived }元`
|
|
}
|
|
} else if (this.statusKey === 'bill') {
|
|
if (item.billDate || item.billNo) {
|
|
result = `${ item.billDate }新增发票,发票单号:${ item.billNo }`
|
|
}
|
|
} else if (this.statusKey === 'mail') {
|
|
if (item.sendDate || item.postNo) {
|
|
result = `${ item.sendDate }新增邮寄信息,邮寄单号:${ item.postNo }`
|
|
}
|
|
} else if (this.statusKey === 'confirm') {
|
|
if (item.paymentDate || item.amountReceived) {
|
|
result = `${ item.paymentDate }确认收入${ item.amountReceived }元`
|
|
}
|
|
}
|
|
return result
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
|
|
</style>
|
|
<style>
|
|
/* 自定义tooltip下样式问题*/
|
|
.status-tooltip .ant-tooltip-inner {
|
|
white-space: pre-wrap !important;
|
|
}
|
|
|
|
.ant-tooltip {
|
|
max-width: 16rem;
|
|
}
|
|
</style>
|