import { NAlert, NButton, NForm, NFormItemGi, NGrid, NInput, useMessage } from 'naive-ui' import { defineComponent, reactive, ref, shallowRef } from 'vue' import { getVipPriceSettings, setVipPriceSettings } from '../../api' import styles from './index.module.less' export default defineComponent({ name: 'member-fee', setup() { const forms = reactive({ id: 0, originalPrice: 0, salePrice: 0 }) as any const beforeData: any = shallowRef({}) // 储存原始数据 const formsRef = ref() const btnLoading = ref(false) const message = useMessage() const getList = async () => { try { const { data } = await getVipPriceSettings({ page: 1, rows: 999, cardTypes: ['VIP'] }) const rows = data.rows[0] forms.id = rows.id forms.originalPrice = rows.originalPrice forms.salePrice = rows.salePrice console.log(forms) // beforeData.value = { ...forms } } catch {} } // // 数组进行对比 // const dataCompare = (beforeData: any, afterData: any) => { // const changeDate: any = [] // for (let key in beforeData) { // if (beforeData[key] != afterData[key]) { // changeDate.push({ // id: key, // paramValue: afterData[key] // }) // } // } // return changeDate || [] // } const onSubmit = async () => { formsRef.value.validate(async (errors: any) => { if (errors) return try { const res = await setVipPriceSettings({ ...forms }) } catch (e) { console.log(e) } message.success('保存成功') }) } getList() return () => ( <> {{ suffix: () => '元' }} {{ suffix: () => '元' }} 保存设置 ) } })