Skip to content

Commit

Permalink
fix: types error
Browse files Browse the repository at this point in the history
  • Loading branch information
liweijie0812 committed Aug 4, 2023
1 parent d63bd83 commit e709586
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
28 changes: 16 additions & 12 deletions src/pages/list/card/components/DialogForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,20 @@
</template>

<script setup lang="ts">
import { Data, FormRule, MessagePlugin, SubmitContext } from 'tdesign-vue-next';
import { FormRules, MessagePlugin, SubmitContext } from 'tdesign-vue-next';
import type { PropType } from 'vue';
import { ref, watch } from 'vue';
const INITIAL_DATA = {
export interface FormData {
name: string;
status: string;
description: string;
type: string;
mark: string;
amount: number;
}
const INITIAL_DATA: FormData = {
name: '',
status: '',
description: '',
Expand All @@ -58,19 +68,13 @@ const props = defineProps({
type: Boolean,
default: false,
},
data: {
type: Object,
default: () => {
return {};
},
},
data: Object as PropType<FormData>,
});
const formVisible = ref(false);
const formData = ref({});
const formData = ref({ ...INITIAL_DATA });
const textareaValue = ref('');
const onSubmit = ({ validateResult, firstError }: SubmitContext<Data>) => {
const onSubmit = ({ validateResult, firstError }: SubmitContext<FormData>) => {
if (!firstError) {
MessagePlugin.success('提交成功');
formVisible.value = false;
Expand Down Expand Up @@ -107,7 +111,7 @@ watch(
},
);
const rules: Record<string, FormRule[]> = {
const rules: FormRules<FormData> = {
name: [{ required: true, message: '请输入产品名称', type: 'error' }],
};
</script>
15 changes: 3 additions & 12 deletions src/pages/list/card/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,14 @@ import { getCardList } from '@/api/list';
import type { CardProductType } from '@/components/product-card/index.vue';
import ProductCard from '@/components/product-card/index.vue';
import type { FormData } from './components/DialogForm.vue';
import DialogForm from './components/DialogForm.vue';
interface FormData {
name: string;
status: string;
description: string;
type: number;
mark: string;
amount: number;
[key: string]: unknown;
}
const INITIAL_DATA: FormData = {
name: '',
status: '',
description: '',
type: 0,
type: '0',
mark: '',
amount: 0,
};
Expand Down Expand Up @@ -158,7 +149,7 @@ const handleManageProduct = (product: CardProductType) => {
name: product.name,
status: product?.isSetup ? '1' : '0',
description: product.description,
type: product.type,
type: product.type.toString(),
mark: '',
amount: 0,
};
Expand Down

0 comments on commit e709586

Please sign in to comment.