From d22d28b49f7442047777c6e672eee1d4b21ba425 Mon Sep 17 00:00:00 2001 From: ihzero Date: Wed, 8 Feb 2023 17:51:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=8E=E9=95=87=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/visualization.ts | 2 +- src/views/base/city-data/CensusDrawer.vue | 162 +++++++++++++++++++--- src/views/base/city-data/index.vue | 9 ++ 3 files changed, 155 insertions(+), 18 deletions(-) diff --git a/src/store/modules/visualization.ts b/src/store/modules/visualization.ts index 05d89588..200e9b15 100644 --- a/src/store/modules/visualization.ts +++ b/src/store/modules/visualization.ts @@ -10,7 +10,7 @@ interface VisualizationState { export const useVisualizationStore = defineStore({ id: 'app-visualization', state: (): VisualizationState => ({ - year: Number(localStorage.getItem(YEAR_KEY)) || new Date().getFullYear(), + year: Number(localStorage.getItem(YEAR_KEY)) || new Date().getFullYear() - 1, addressId: null, }), getters: { diff --git a/src/views/base/city-data/CensusDrawer.vue b/src/views/base/city-data/CensusDrawer.vue index 0b536400..c371b221 100644 --- a/src/views/base/city-data/CensusDrawer.vue +++ b/src/views/base/city-data/CensusDrawer.vue @@ -4,25 +4,97 @@ @register="registerDrawer" showFooter title="编辑统计" - width="500px" + width="600px" @ok="handleSubmit" > @@ -32,8 +104,11 @@ import { BasicForm, useForm } from '/@/components/Form/index' import { searchFormSchema1 } from './city.data' import { BasicDrawer, useDrawerInner } from '/@/components/Drawer' - import { Input, FormItem } from 'ant-design-vue' + import { Input, FormItem, Row, Col } from 'ant-design-vue' import { citydataEdit } from '/@/api/sys/user' + import { concat } from 'lodash-es' + import { isObject } from '/@/utils/is' + import { MinusCircleOutlined, PlusCircleOutlined } from '@ant-design/icons-vue' const emits = defineEmits(['success', 'register']) const isUpdate = ref(false) const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({ @@ -42,19 +117,61 @@ schemas: searchFormSchema1, showActionButtonGroup: false, }) + const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { resetFields() setDrawerProps({ confirmLoading: false }) isUpdate.value = data?.isUpdate + if (unref(isUpdate)) { + const tempData = data.data.reduce((pre, cur) => { + const obj = { + name: cur.name, + slug: cur.slug, + unit: cur.unit, + } + if (isObject(cur.value)) { + // cur.value[2023] = '' + const temp = [] + // if(Object.keys(cur.value).length === 1)) + if (Object.keys(cur.value).length === 0) { + temp.push({ + value: '', + year: '', + }) + } + + for (const key in cur.value) { + temp.push({ + value: cur.value[key], + year: key, + }) + } + return concat(pre, { + ...obj, + isMore: true, + value: temp, + }) + } + return concat(pre, { + ...obj, + isMore: false, + value: cur.value, + }) + }, []) + console.log(tempData) + setFieldsValue({ - ...data, + data: tempData, }) } }) const handleSubmit = async () => { try { const { data } = await validate() + console.log(data) + + return const params = {} data.forEach((e) => { params[e.slug] = e.value @@ -66,4 +183,15 @@ setDrawerProps({ confirmLoading: false }) } } + + const addDomain = (item) => { + item.value.push({ + value: '', + year: '', + }) + } + + const removeDomain = (item, index) => { + item.value.splice(index, 1) + } diff --git a/src/views/base/city-data/index.vue b/src/views/base/city-data/index.vue index 7534543c..1abb05e8 100644 --- a/src/views/base/city-data/index.vue +++ b/src/views/base/city-data/index.vue @@ -5,6 +5,7 @@ 编辑