Merge branch 'kpi-statis'
This commit is contained in:
@@ -59,3 +59,8 @@ export function accountCostEdit(params?: any) {
|
||||
export function accountCostDetail(params?: any) {
|
||||
return request.get({ url: '/finance.account_cost/detail', params })
|
||||
}
|
||||
|
||||
// 账户消耗删除
|
||||
export function accountCostDelete(params?: any) {
|
||||
return request.post({ url: '/finance.account_cost/delete', params })
|
||||
}
|
||||
|
||||
@@ -18,6 +18,22 @@
|
||||
:disabled="mode === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="自媒体渠道" prop="media_channel_code">
|
||||
<el-select
|
||||
v-model="formData.media_channel_code"
|
||||
placeholder="请选择自媒体渠道"
|
||||
class="w-full"
|
||||
filterable
|
||||
:disabled="mode === 'edit'"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in mediaChannelOptions"
|
||||
:key="item.code"
|
||||
:label="item.name"
|
||||
:value="item.code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="账户消耗" prop="amount">
|
||||
<el-input-number
|
||||
v-model="formData.amount"
|
||||
@@ -48,6 +64,16 @@ import type { FormInstance } from 'element-plus'
|
||||
import { accountCostAdd, accountCostDetail, accountCostEdit } from '@/api/finance'
|
||||
import Popup from '@/components/popup/index.vue'
|
||||
|
||||
interface MediaChannelOption {
|
||||
code: string
|
||||
name: string
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
mediaChannelOptions: MediaChannelOption[]
|
||||
defaultMediaChannelCode: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits(['success', 'close'])
|
||||
const formRef = shallowRef<FormInstance>()
|
||||
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
||||
@@ -58,6 +84,7 @@ const popupTitle = computed(() => (mode.value === 'edit' ? '编辑账户消耗'
|
||||
const formData = reactive({
|
||||
id: '',
|
||||
cost_date: '',
|
||||
media_channel_code: '',
|
||||
amount: 0,
|
||||
remark: '',
|
||||
})
|
||||
@@ -70,6 +97,13 @@ const formRules = {
|
||||
trigger: ['change'],
|
||||
},
|
||||
],
|
||||
media_channel_code: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择自媒体渠道',
|
||||
trigger: ['change'],
|
||||
},
|
||||
],
|
||||
amount: [
|
||||
{
|
||||
required: true,
|
||||
@@ -82,6 +116,7 @@ const formRules = {
|
||||
const resetForm = () => {
|
||||
formData.id = ''
|
||||
formData.cost_date = ''
|
||||
formData.media_channel_code = props.defaultMediaChannelCode || ''
|
||||
formData.amount = 0
|
||||
formData.remark = ''
|
||||
}
|
||||
@@ -106,6 +141,7 @@ const open = (type: 'add' | 'edit' = 'add') => {
|
||||
const setFormData = (data: Record<string, any>) => {
|
||||
formData.id = data.id ?? ''
|
||||
formData.cost_date = data.cost_date ?? ''
|
||||
formData.media_channel_code = data.media_channel_code ?? ''
|
||||
formData.amount = Number(data.amount ?? 0)
|
||||
formData.remark = data.remark ?? ''
|
||||
}
|
||||
|
||||
@@ -21,6 +21,22 @@
|
||||
v-model:endTime="queryParams.end_date"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="自媒体渠道">
|
||||
<el-select
|
||||
v-model="queryParams.media_channel_code"
|
||||
placeholder="筛选全部渠道"
|
||||
clearable
|
||||
filterable
|
||||
class="w-[220px]"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in mediaChannelOptions"
|
||||
:key="item.code"
|
||||
:label="item.name"
|
||||
:value="item.code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item class="w-[280px]" label="备注/维护人">
|
||||
<el-input
|
||||
v-model="queryParams.remark"
|
||||
@@ -48,6 +64,7 @@
|
||||
|
||||
<el-table class="mt-4" size="large" v-loading="pager.loading" :data="pager.lists">
|
||||
<el-table-column label="日期" prop="cost_date" min-width="120" />
|
||||
<el-table-column label="自媒体渠道" prop="media_channel_name" min-width="120" />
|
||||
<el-table-column label="账户消耗" min-width="120">
|
||||
<template #default="{ row }">¥{{ row.amount }}</template>
|
||||
</el-table-column>
|
||||
@@ -55,7 +72,7 @@
|
||||
<el-table-column label="创建人" prop="creator_name" min-width="100" />
|
||||
<el-table-column label="最后修改人" prop="updater_name" min-width="100" />
|
||||
<el-table-column label="更新时间" prop="update_time" min-width="180" />
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<el-table-column label="操作" width="160" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-perms="['finance.account_cost/edit']"
|
||||
@@ -65,6 +82,14 @@
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['finance.account_cost/delete']"
|
||||
type="danger"
|
||||
link
|
||||
@click="handleDelete(row.id)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -74,22 +99,36 @@
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" />
|
||||
<edit-popup
|
||||
v-if="showEdit"
|
||||
ref="editRef"
|
||||
:media-channel-options="mediaChannelOptions"
|
||||
:default-media-channel-code="defaultMediaChannelCode"
|
||||
@success="getLists"
|
||||
@close="showEdit = false"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="accountCostList">
|
||||
import { accountCostLists } from '@/api/finance'
|
||||
import { accountCostDelete, accountCostLists } from '@/api/finance'
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
import feedback from '@/utils/feedback'
|
||||
|
||||
import EditPopup from './edit.vue'
|
||||
|
||||
interface MediaChannelOption {
|
||||
code: string
|
||||
name: string
|
||||
}
|
||||
|
||||
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
||||
const showEdit = ref(false)
|
||||
|
||||
const queryParams = reactive({
|
||||
start_date: '',
|
||||
end_date: '',
|
||||
media_channel_code: '',
|
||||
remark: '',
|
||||
})
|
||||
|
||||
@@ -98,6 +137,18 @@ const { pager, getLists, resetPage } = usePaging({
|
||||
params: queryParams,
|
||||
})
|
||||
|
||||
const mediaChannelOptions = computed<MediaChannelOption[]>(() => {
|
||||
const options = pager.extend.media_channel_options
|
||||
if (!Array.isArray(options)) return []
|
||||
|
||||
return options.map((item: Record<string, any>) => ({
|
||||
code: String(item.code || ''),
|
||||
name: String(item.name || ''),
|
||||
}))
|
||||
})
|
||||
|
||||
const defaultMediaChannelCode = computed(() => String(pager.extend.default_media_channel_code || ''))
|
||||
|
||||
const handleAdd = async () => {
|
||||
showEdit.value = true
|
||||
await nextTick()
|
||||
@@ -111,9 +162,16 @@ const handleEdit = async (row: any) => {
|
||||
editRef.value?.getDetail(row)
|
||||
}
|
||||
|
||||
const handleDelete = async (id: number) => {
|
||||
await feedback.confirm('确定要删除这条账户消耗记录吗?')
|
||||
await accountCostDelete({ id })
|
||||
getLists()
|
||||
}
|
||||
|
||||
const handleReset = () => {
|
||||
queryParams.start_date = ''
|
||||
queryParams.end_date = ''
|
||||
queryParams.media_channel_code = ''
|
||||
queryParams.remark = ''
|
||||
resetPage()
|
||||
}
|
||||
|
||||
@@ -43,6 +43,24 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="自媒体渠道">
|
||||
<el-select
|
||||
v-model="queryParams.media_channel_code"
|
||||
placeholder="全部渠道"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 220px"
|
||||
@change="handleMediaChannelChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in mediaChannelOptions"
|
||||
:key="item.code"
|
||||
:label="item.name"
|
||||
:value="item.code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="时间范围">
|
||||
<el-radio-group v-model="queryParams.time_type" @change="handleTimeTypeChange">
|
||||
<el-radio-button label="today">今天</el-radio-button>
|
||||
@@ -208,6 +226,11 @@ interface OptionItem {
|
||||
name: string
|
||||
}
|
||||
|
||||
interface MediaChannelOption {
|
||||
code: string
|
||||
name: string
|
||||
}
|
||||
|
||||
interface MetricCard {
|
||||
key: string
|
||||
label: string
|
||||
@@ -227,6 +250,7 @@ const deptTreeOptions = ref<any[]>([])
|
||||
const deptOptions = ref<OptionItem[]>([])
|
||||
const assistantOptions = ref<OptionItem[]>([])
|
||||
const doctorOptions = ref<OptionItem[]>([])
|
||||
const mediaChannelOptions = ref<MediaChannelOption[]>([])
|
||||
const filtersLoaded = ref(false)
|
||||
const overview = reactive<Record<string, any>>({
|
||||
dimension: 'dept',
|
||||
@@ -250,6 +274,7 @@ const queryParams = reactive({
|
||||
dept_id: undefined as number | undefined,
|
||||
assistant_id: undefined as number | undefined,
|
||||
doctor_id: undefined as number | undefined,
|
||||
media_channel_code: '',
|
||||
time_type: 'today',
|
||||
start_date: '',
|
||||
end_date: ''
|
||||
@@ -367,8 +392,8 @@ const fanPieHasData = computed(() => overview.charts.fan_share.length > 0)
|
||||
|
||||
const rankingChartData = computed(() => {
|
||||
const ranking = overview.charts?.ranking || {}
|
||||
const names = Array.isArray(ranking.names) ? ranking.names : []
|
||||
const normalize = (values: unknown[]) => names.map((_, index) => Number(values?.[index] ?? 0))
|
||||
const names: unknown[] = Array.isArray(ranking.names) ? ranking.names : []
|
||||
const normalize = (values: unknown[]) => names.map((_: unknown, index: number) => Number(values?.[index] ?? 0))
|
||||
|
||||
return {
|
||||
names,
|
||||
@@ -505,6 +530,7 @@ const applyFilterOptions = (filters?: Record<string, any>) => {
|
||||
const departments = Array.isArray(filters.departments) ? filters.departments : []
|
||||
const assistants = Array.isArray(filters.assistants) ? filters.assistants : []
|
||||
const doctors = Array.isArray(filters.doctors) ? filters.doctors : []
|
||||
const mediaChannels = Array.isArray(filters.media_channels) ? filters.media_channels : []
|
||||
|
||||
deptTreeOptions.value = departments
|
||||
deptOptions.value = flattenDepts(departments)
|
||||
@@ -516,6 +542,10 @@ const applyFilterOptions = (filters?: Record<string, any>) => {
|
||||
id: Number(item.id),
|
||||
name: item.name,
|
||||
}))
|
||||
mediaChannelOptions.value = mediaChannels.map((item: any) => ({
|
||||
code: String(item.code || ''),
|
||||
name: String(item.name || ''),
|
||||
}))
|
||||
}
|
||||
|
||||
const fetchOverview = async () => {
|
||||
@@ -540,6 +570,11 @@ const handleEntityChange = () => {
|
||||
fetchOverview()
|
||||
}
|
||||
|
||||
const handleMediaChannelChange = () => {
|
||||
pager.page = 1
|
||||
fetchOverview()
|
||||
}
|
||||
|
||||
const handleTimeTypeChange = () => {
|
||||
if (queryParams.time_type !== 'custom') {
|
||||
dateRange.value = []
|
||||
@@ -565,6 +600,7 @@ const handleReset = () => {
|
||||
queryParams.dept_id = undefined
|
||||
queryParams.assistant_id = undefined
|
||||
queryParams.doctor_id = undefined
|
||||
queryParams.media_channel_code = ''
|
||||
queryParams.time_type = 'today'
|
||||
dateRange.value = []
|
||||
pager.page = 1
|
||||
|
||||
Reference in New Issue
Block a user