【招生小程序】 新增# 电销:总结模板

master
kaeery 2025-02-28 20:46:15 +08:00
parent 46ba82e344
commit 4528f8f7e2
4 changed files with 158 additions and 55 deletions

17
src/api/summary.ts 100644
View File

@ -0,0 +1,17 @@
import request from '@/utils/request'
// 获取模板
export function apiSummary(params: any) {
return request.get({ url: '/template/defaultTemplate', data: params })
}
// 新增模板
export function apiAddSummary(params: any) {
return request.post({ url: '/summary/template/add', data: params })
}
// 模板详情
export function apiSummaryDetail(params: any) {
return request.get({ url: '/summary/template/detail', data: params })
}
// 编辑模板
export function apiEditSummary(params: any) {
return request.post({ url: '/summary/template/edit', data: params })
}

View File

@ -1,5 +1,9 @@
<template>
<view>
<template v-if="loading && modelValue.length == 0">
<u-loading-icon text="加载中" textSize="18"></u-loading-icon>
</template>
<template v-else-if="!loading && modelValue.length > 0">
<view class="form">
<view
class="px-[32rpx] flex flex-col gap-[24rpx]"
@ -23,16 +27,19 @@
</view>
</view>
</view>
<view class="px-[60rpx] mt-[48rpx]" v-if="readonly == ''">
<u-button class="btn" color="#0E66FB" shape="circle" @click="handleConfirm">
确认
</u-button>
</template>
<template v-else-if="!loading && modelValue.length == 0">
<view class="flex flex-col items-center text-gray4">
<image :src="emptyImg" />
<text>暂无模板可填写</text>
</view>
</template>
</view>
</template>
<script setup lang="ts">
import { PropType } from 'vue'
import emptyImg from '@/static/images/error.png'
export interface ISummary {
formTitle: string
@ -44,15 +51,11 @@ defineProps({
type: Array as PropType<ISummary[]>,
default: () => []
},
readonly: {
type: String,
default: ''
loading: {
type: Boolean,
default: false
}
})
const emit = defineEmits(['handleConfirm'])
const handleConfirm = () => {
emit('handleConfirm')
}
</script>
<style scoped lang="scss">
.form {
@ -66,9 +69,4 @@ const handleConfirm = () => {
}
}
}
:deep(.btn) {
button {
@apply h-[88rpx];
}
}
</style>

View File

@ -1,30 +1,117 @@
<template>
<TContainer>
<view class="pb-[24rpx]">
<w-date-more :curDate="curDate" type="telesale" />
<date-strip v-model="value" @change="handleDateChange" height="160rpx" />
<w-summary-form v-model="templateItems" @handle-confirm="handleConfirm" />
<w-date-more :curDate="addTime" type="telesale" />
<date-strip
v-model="templateInfo.dateValue"
@change="handleDateChange"
height="160rpx"
/>
<w-summary-form
v-model="templateInfo.templateFormList"
:loading="loading"
@handle-confirm="handleConfirm"
/>
<view
class="px-[60rpx] mt-[48rpx]"
v-if="templateInfo.templateFormList?.length > 0 && isToday"
>
<u-button class="btn" color="#0E66FB" shape="circle" @click="handleConfirm">
确认
</u-button>
</view>
</view>
</TContainer>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { computed, ref } from 'vue'
import dateStrip from '@/components/date-strip/index.vue'
import { apiAddSummary, apiEditSummary, apiSummary, apiSummaryDetail } from '@/api/summary'
import cache from '@/utils/cache'
import { ROLEINDEX } from '@/enums/cacheEnums'
import { useUserStore } from '@/stores/user'
import { storeToRefs } from 'pinia'
import { formatDate, toast } from '@/utils/util'
import dayjs from 'dayjs'
import { onMounted } from 'vue'
const curDate = ref(new Date().getTime())
const templateItems = ref([
{ formType: 1, formTitle: '今日打电话数量(包括不接、挂、空)', value: '' },
{ formType: 1, formTitle: '今日打出多少条有效数据(可以加微信)', value: '' },
{ formType: 1, formTitle: '家长主动加我们微信数据', value: '' },
{ formType: 2, formTitle: '有遇到什么问题', value: '' }
])
const handleConfirm = () => {
console.log(templateItems.value)
}
const value = ref(new Date().getTime())
const userStore = useUserStore()
const { userInfo } = storeToRefs(userStore)
const roles = computed(() => userInfo.value.roles)
const loading = ref(false)
const templateInfo = ref({
id: '',
dateValue: new Date().getTime(),
templateFormList: [],
isFill: 0
})
const addTime = ref(new Date().getTime())
const date = computed(
() =>
(format = 'YYYY-MM-DD') =>
formatDate(templateInfo.value.dateValue, format)
)
const isToday = computed(() => {
const today = new Date()
const selectedDate = new Date(templateInfo.value.dateValue)
return (
today.getFullYear() === selectedDate.getFullYear() &&
today.getMonth() === selectedDate.getMonth() &&
today.getDate() === selectedDate.getDate()
)
})
const handleDateChange = item => {
console.log(item)
templateInfo.value.dateValue = dayjs(item.key).valueOf()
isToday.value ? fetchSummaryTemplate() : fetchSummaryDetail()
}
// ()
const handleConfirm = async () => {
try {
const { templateFormList, isFill, id } = templateInfo.value
const params = {
id,
templateFormList: templateFormList,
addTime: date.value('YYYY-MM-DD HH:mm:ss')
}
const flag = isToday.value && isFill
const api = flag ? apiEditSummary : apiAddSummary
const msg = flag ? '编辑' : '提交'
await api(params)
toast(`${msg}成功`)
fetchSummaryTemplate()
} catch (error) {}
}
//
const fetchSummaryTemplate = async () => {
loading.value = true
try {
const roleIndex = cache.get(ROLEINDEX)
const curRole = roles.value[roleIndex]
const { id: postId } = curRole
const result = await apiSummary({ postId })
templateInfo.value.templateFormList = result.templateFormList ?? []
templateInfo.value.isFill = result.isFill
templateInfo.value.id = result.id
} catch (error) {}
loading.value = false
}
const fetchSummaryDetail = async () => {
try {
const params = {
date: date.value('YYYY-MM-DD')
}
const result = await apiSummaryDetail(params)
templateInfo.value.templateFormList = result.templateContentList ?? []
templateInfo.value.isFill = result.isFill ?? 0
} catch (error) {}
}
fetchSummaryTemplate()
</script>
<style scoped lang="scss"></style>
<style scoped lang="scss">
:deep(.btn) {
button {
@apply h-[88rpx];
}
}
</style>

View File

@ -28,6 +28,7 @@ module.exports = {
gray: '#EFEFEF',
gray2: '#7C7E82',
gray3: '#F8F8F8',
gray4: '#999',
lightblack: '#3D3D3D',
border: '#F1F1F1',
border2: '#F3F3F3',