【招生小程序】 新增# 电销:总结模板
parent
46ba82e344
commit
4528f8f7e2
|
@ -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 })
|
||||||
|
}
|
|
@ -1,5 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<view>
|
<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="form">
|
||||||
<view
|
<view
|
||||||
class="px-[32rpx] flex flex-col gap-[24rpx]"
|
class="px-[32rpx] flex flex-col gap-[24rpx]"
|
||||||
|
@ -23,16 +27,19 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="px-[60rpx] mt-[48rpx]" v-if="readonly == ''">
|
</template>
|
||||||
<u-button class="btn" color="#0E66FB" shape="circle" @click="handleConfirm">
|
<template v-else-if="!loading && modelValue.length == 0">
|
||||||
确认
|
<view class="flex flex-col items-center text-gray4">
|
||||||
</u-button>
|
<image :src="emptyImg" />
|
||||||
|
<text>暂无模板可填写</text>
|
||||||
</view>
|
</view>
|
||||||
|
</template>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { PropType } from 'vue'
|
import { PropType } from 'vue'
|
||||||
|
import emptyImg from '@/static/images/error.png'
|
||||||
|
|
||||||
export interface ISummary {
|
export interface ISummary {
|
||||||
formTitle: string
|
formTitle: string
|
||||||
|
@ -44,15 +51,11 @@ defineProps({
|
||||||
type: Array as PropType<ISummary[]>,
|
type: Array as PropType<ISummary[]>,
|
||||||
default: () => []
|
default: () => []
|
||||||
},
|
},
|
||||||
readonly: {
|
loading: {
|
||||||
type: String,
|
type: Boolean,
|
||||||
default: ''
|
default: false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['handleConfirm'])
|
|
||||||
const handleConfirm = () => {
|
|
||||||
emit('handleConfirm')
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.form {
|
.form {
|
||||||
|
@ -66,9 +69,4 @@ const handleConfirm = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
:deep(.btn) {
|
|
||||||
button {
|
|
||||||
@apply h-[88rpx];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,30 +1,117 @@
|
||||||
<template>
|
<template>
|
||||||
<TContainer>
|
<TContainer>
|
||||||
<view class="pb-[24rpx]">
|
<view class="pb-[24rpx]">
|
||||||
<w-date-more :curDate="curDate" type="telesale" />
|
<w-date-more :curDate="addTime" type="telesale" />
|
||||||
<date-strip v-model="value" @change="handleDateChange" height="160rpx" />
|
<date-strip
|
||||||
<w-summary-form v-model="templateItems" @handle-confirm="handleConfirm" />
|
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>
|
</view>
|
||||||
</TContainer>
|
</TContainer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import dateStrip from '@/components/date-strip/index.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 userStore = useUserStore()
|
||||||
const templateItems = ref([
|
const { userInfo } = storeToRefs(userStore)
|
||||||
{ formType: 1, formTitle: '今日打电话数量(包括不接、挂、空)', value: '' },
|
const roles = computed(() => userInfo.value.roles)
|
||||||
{ formType: 1, formTitle: '今日打出多少条有效数据(可以加微信)', value: '' },
|
const loading = ref(false)
|
||||||
{ formType: 1, formTitle: '家长主动加我们微信数据', value: '' },
|
const templateInfo = ref({
|
||||||
{ formType: 2, formTitle: '有遇到什么问题', value: '' }
|
id: '',
|
||||||
])
|
dateValue: new Date().getTime(),
|
||||||
const handleConfirm = () => {
|
templateFormList: [],
|
||||||
console.log(templateItems.value)
|
isFill: 0
|
||||||
}
|
})
|
||||||
const value = ref(new Date().getTime())
|
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 => {
|
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>
|
</script>
|
||||||
<style scoped lang="scss"></style>
|
<style scoped lang="scss">
|
||||||
|
:deep(.btn) {
|
||||||
|
button {
|
||||||
|
@apply h-[88rpx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
@ -28,6 +28,7 @@ module.exports = {
|
||||||
gray: '#EFEFEF',
|
gray: '#EFEFEF',
|
||||||
gray2: '#7C7E82',
|
gray2: '#7C7E82',
|
||||||
gray3: '#F8F8F8',
|
gray3: '#F8F8F8',
|
||||||
|
gray4: '#999',
|
||||||
lightblack: '#3D3D3D',
|
lightblack: '#3D3D3D',
|
||||||
border: '#F1F1F1',
|
border: '#F1F1F1',
|
||||||
border2: '#F3F3F3',
|
border2: '#F3F3F3',
|
||||||
|
|
Loading…
Reference in New Issue