This commit is contained in:
weipengfei 2023-08-14 15:54:23 +08:00
commit 1f583a4e74

View File

@ -15,21 +15,61 @@
<el-form-item label="金额" prop="moeny">
<el-input v-model="formData.money" clearable placeholder="请输入金额" />
</el-form-item>
<el-form-item label="一阶天数">
<el-input
v-model="formData.stage_day_one"
clearable
placeholder="请输入天数"
type="number"
>
<template #append></template>
</el-input>
</el-form-item>
<el-form-item label="一阶比例">
<el-input
v-model="formData.proportion_one"
clearable
placeholder="请输入比例"
type="number"
>
<template #append>%</template>
</el-input>
</el-form-item>
<el-form-item label="二阶天数">
<el-input
v-model="formData.stage_day_two"
clearable
placeholder="请输入天数"
type="number"
>
<template #append></template>
</el-input>
</el-form-item>
<el-form-item label="二阶比例">
<el-input
v-model="formData.mediumint_two"
clearable
placeholder="请输入比例"
type="number"
>
<template #append>%</template>
</el-input>
</el-form-item>
<el-form-item label="任务类型" prop="type">
<el-select v-model="formData.type" clearable placeholder="请输入任务类型" >
<el-option
v-for="item in datalist"
:key="item.label"
:value="item.id"
:label="item.name"
/>
</el-select>
<el-select v-model="formData.type" clearable placeholder="请输入任务类型">
<el-option
v-for="item in datalist"
:key="item.label"
:value="item.id"
:label="item.name"
/>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-radio-group v-model="formData.status">
<el-radio :label="1">显示</el-radio>
<el-radio :label="0">隐藏</el-radio>
</el-radio-group>
<el-radio-group v-model="formData.status">
<el-radio :label="1">显示</el-radio>
<el-radio :label="0">隐藏</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="任务描述" prop="content">
<el-input v-model="formData.content" clearable placeholder="请输入任务描述" />
@ -45,7 +85,7 @@ import Popup from '@/components/popup/index.vue'
import { apiTaskTemplateAdd, apiTaskTemplateEdit, apiTaskTemplateDetail } from '@/api/task_template'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
import { dictDataLists } from "@/api/setting/dict";
import { dictDataLists } from '@/api/setting/dict'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
@ -56,7 +96,7 @@ const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
const datalist=ref([])
const datalist = ref([])
//
const popupTitle = computed(() => {
@ -65,43 +105,55 @@ const popupTitle = computed(() => {
//
const formData = reactive({
id: '',
title: '',
admin_id: '',
money: '',
type: '',
status: '',
content: '',
stage_day_one: 0,
proportion_one: 0,
stage_day_two: 9999,
mediumint_two: 0
})
//
dictDataLists({ type_id: 10 }).then((res) => {
datalist.value = res.lists;
});
datalist.value = res.lists
})
//
const formRules = reactive<any>({
title: [{
required: true,
message: '请输入主题',
trigger: ['blur']
}],
admin_id: [{
required: true,
message: '请输入创建人',
trigger: ['blur']
}],
type: [{
required: true,
message: '请输入任务类型',
trigger: ['blur']
}],
status: [{
required: true,
message: '请选择状态',
trigger: ['blur']
}]
title: [
{
required: true,
message: '请输入主题',
trigger: ['blur']
}
],
admin_id: [
{
required: true,
message: '请输入创建人',
trigger: ['blur']
}
],
type: [
{
required: true,
message: '请输入任务类型',
trigger: ['blur']
}
],
status: [
{
required: true,
message: '请选择状态',
trigger: ['blur']
}
]
})
//
const setFormData = async (data: Record<any, any>) => {
for (const key in formData) {
@ -110,8 +162,6 @@ const setFormData = async (data: Record<any, any>) => {
formData[key] = data[key]
}
}
}
const getDetail = async (row: Record<string, any>) => {
@ -121,14 +171,11 @@ const getDetail = async (row: Record<string, any>) => {
setFormData(data)
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
mode.value == 'edit'
? await apiTaskTemplateEdit(data)
: await apiTaskTemplateAdd(data)
const data = { ...formData }
mode.value == 'edit' ? await apiTaskTemplateEdit(data) : await apiTaskTemplateAdd(data)
popupRef.value?.close()
emit('success')
}
@ -144,8 +191,6 @@ const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,