Commit 829e7f3a by 李伟康

feat(customer): 新增策略任务确认功能并优化客户机会组件

- 在customerApi中新增confirmSopTask接口用于策略任务确认
- 重构CustomerOpportunities组件的数据初始化逻辑,修复切换标签时状态重置问题
- 添加tableRef方法统一访问表格引用,避免直接操作$refs可能的空指针异常
- 优化loading显示,在请求完成后确保隐藏loading状态
- 在CustomerPopup组件中新增全部任务合并推送按钮及功能
- 完善CustomerPopup组件中的错误处理机制
- 修复Table组件中时间格式化时可能出现的空值问题
- 为TaskItem组件添加任务确认事件处理功能
- 调整HomeFrame样式以解决transform属性导致的布局问题
1 parent 34db4cd5
......@@ -145,5 +145,15 @@ module.exports = {
projectName: 'pad',
...data
})
}
},
/**
* 策略任务确认
*/
confirmSopTask(data) {
return http.post({
method: 'dj.pad.api.last.week.sop.task.confirm',
projectName: 'pad',
...data
})
},
}
......@@ -23,10 +23,13 @@
<view class="sub-title flex">
<view :class="['sprite-icon', subIcon]"></view>
{{ subTitle }}
<template v-if="options.type == 'task'">
<view class="btn flex" @click="confirmAllTask">全部任务合并推送</view>
</template>
</view>
<scroll-view class="content" scroll-y>
<template v-for="(item, index) in taskList">
<task-item :key="index" :item="item" :num="index" :type="options.type" />
<task-item :key="index" :item="item" :num="index" :type="options.type" @confirmTask="confirmTask" />
</template>
<view class="p-b"></view>
</scroll-view>
......@@ -41,7 +44,9 @@ export default {
inject: ['userInfo'],
data() {
return {
options: {},
options: {
data: {}
},
customerObject: [
{ title: '客户姓名', key: 'customerName' },
{ title: '手机号码', key: 'customerPhone' },
......@@ -83,17 +88,19 @@ export default {
mounted() { },
methods: {
open(options) {
uni.showLoading({
mask: true,
title: '加载中...'
})
this.options = options
this.$refs.popup.open()
this.getData(options)
},
close() {
this.$refs.popup.close()
},
async getData(options) {
try {
uni.showLoading({
mask: true,
title: '加载中...'
})
let { shopMerchantId: merchantId } = this.userInfo,
targetApi = {
task: 'getTodaySopTaskDetailList',
......@@ -103,8 +110,17 @@ export default {
data = await uni.$api.customerApi[targetApi]({ merchantId, customerInstanceId })
uni.hideLoading()
this.taskList = data
this.$refs.popup.open()
} catch (error) {
uni.hideLoading()
}
},
confirmTask(options) {
console.log(options)
},
confirmAllTask() {
console.log('全部任务合并推送')
}
}
}
</script>
......@@ -196,6 +212,18 @@ export default {
margin-right: 18rpx;
}
.btn {
margin-left: auto;
background-color: #2C66F7;
color: #FFFFFF;
padding: 0 32rpx;
border-radius: 16rpx;
height: 64rpx;
line-height: 64rpx;
color: #2C66F7;
font-size: 28rpx;
}
}
.content {
......
......@@ -102,7 +102,7 @@ export default {
},
methods: {
lastExecuteTime(time) {
return dayjs(time).format('MM-DD HH:mm')
return time ? dayjs(time).format('MM-DD HH:mm') : ''
},
getAvatar(name) {
return name.charAt(0)
......@@ -131,7 +131,7 @@ export default {
}[status]
},
orderHandleTime(time) {
return dayjs(time).format('YYYY-MM-DD')
return time ? dayjs(time).format('YYYY-MM-DD') : ''
},
showTagMore(tags, index) {
let query = uni.createSelectorQuery(),
......
......@@ -11,8 +11,8 @@
</view>
<view class="btn-box flex">
<template v-if="item.taskStatus == 0">
<view class="btn primary-btn">立即推送</view>
<view class="btn">暂不推送</view>
<view class="btn primary-btn" @click="confirmTask(1)">立即推送</view>
<view class="btn" @click="confirmTask()">暂不推送</view>
</template>
<template v-else>
<view :class="['status flex', { success: item.taskStatus == 1 }]">{{ taskStatus(item.taskStatus) }}</view>
......@@ -37,7 +37,7 @@ export default {
computed: {},
mounted() { },
methods: {
messageType(type){
messageType(type) {
return {
1: '文本',
2: '图片',
......@@ -45,12 +45,18 @@ export default {
4: '网页链接',
}[type]
},
taskStatus(status){
taskStatus(status) {
return {
1: '已推送',
2: '暂不推送',
}[status]
}
},
confirmTask(confirmStatus = 0) {
this.$emit('confirmTask', {
confirmStatus,
item: this.item
})
},
}
}
</script>
......
......@@ -51,23 +51,34 @@ export default {
if (val) {
this.getTodaySopTaskCustomerPage()
this.getLastWeekSopTaskCustomerPage(false)
} else this.initRequestParams()
} else {
this.tabs = this.$options.data.call(this).tabs
this.tabIndex = 0
this.initRequestParams()
}
},
immediate: true,
deep: true
}
},
computed: {
},
mounted() {
},
methods: {
tableRef() {
return this.$refs.table || null
},
initRequestParams() {
this.pageNum = 1
this.pageSize = 10
this.tableData = []
this.$refs.table.loadComplete = false
this.$refs.table.noMore = false
if (this.tableRef()) {
this.tableRef().loadComplete = false
this.tableRef().noMore = false
}
uni.hideLoading()
},
/**
* 切换标签
......@@ -89,38 +100,38 @@ export default {
this.pageNum += 1
if (tabIndex == 0) this.getTodaySopTaskCustomerPage()
else this.getLastWeekSopTaskCustomerPage()
} else this.$refs.table.noMore = true
} else this.tableRef().noMore = true
},
async getTodaySopTaskCustomerPage() {
try {
uni.showLoading({ title: '加载中' })
uni.showLoading({ title: '加载中...', mask: true })
let { shopMerchantId: merchantId } = this.userInfo,
{ pageNum, pageSize, tableData } = this,
{ list, total } = await uni.$api.customerApi.getTodaySopTaskCustomerPage({ merchantId, pageNum, pageSize })
uni.hideLoading()
this.tableData = [...tableData, ...list]
this.$refs.table.loadComplete = true
this.tableRef().loadComplete = true
this.total = total
if (total) this.$set(this.tabs, 0, `待执行推送客户(${total})`)
uni.hideLoading()
} catch (error) {
this.$refs.table.loadComplete = true
this.tableRef() && (this.tableRef().loadComplete = true)
}
},
async getLastWeekSopTaskCustomerPage(assignment = true) {
try {
if (assignment) uni.showLoading({ title: '加载中' })
if (assignment) uni.showLoading({ title: '加载中...', mask: true })
let { shopMerchantId: merchantId } = this.userInfo,
{ pageNum, pageSize, tableData } = this,
{ list, total } = await uni.$api.customerApi.getLastWeekSopTaskCustomerPage({ merchantId, pageNum, pageSize })
if (assignment) {
this.tableData = [...tableData, ...list]
this.$refs.table.loadComplete = true
this.tableRef().loadComplete = true
this.total = total
uni.hideLoading()
}
if (total) this.$set(this.tabs, 1, `近7日已推送客户(${total})`)
} catch (error) {
this.$refs.table.loadComplete = true
this.tableRef() && (this.tableRef().loadComplete = true)
}
}
}
......
......@@ -1312,6 +1312,7 @@ export default {
}
.customer-opportunities-box{
padding: 0;
transform: none;
}
.app-content-box {
width: 100%;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!