增加自媒体渠道

This commit is contained in:
2026-04-23 15:43:22 +08:00
parent 366b005d78
commit 54431cbeb1
19 changed files with 737 additions and 47 deletions
@@ -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 ?? ''
}