城镇数据
parent
8ba4477d76
commit
d22d28b49f
|
|
@ -10,7 +10,7 @@ interface VisualizationState {
|
||||||
export const useVisualizationStore = defineStore({
|
export const useVisualizationStore = defineStore({
|
||||||
id: 'app-visualization',
|
id: 'app-visualization',
|
||||||
state: (): VisualizationState => ({
|
state: (): VisualizationState => ({
|
||||||
year: Number(localStorage.getItem(YEAR_KEY)) || new Date().getFullYear(),
|
year: Number(localStorage.getItem(YEAR_KEY)) || new Date().getFullYear() - 1,
|
||||||
addressId: null,
|
addressId: null,
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
|
|
|
||||||
|
|
@ -4,25 +4,97 @@
|
||||||
@register="registerDrawer"
|
@register="registerDrawer"
|
||||||
showFooter
|
showFooter
|
||||||
title="编辑统计"
|
title="编辑统计"
|
||||||
width="500px"
|
width="600px"
|
||||||
@ok="handleSubmit"
|
@ok="handleSubmit"
|
||||||
>
|
>
|
||||||
<BasicForm @register="registerForm">
|
<BasicForm @register="registerForm">
|
||||||
<template #data="{ model, field }">
|
<template #data="{ model, field }">
|
||||||
<FormItem
|
<template v-for="(item, index) in model[field]" :key="index">
|
||||||
:labelCol="{ span: 8 }"
|
<FormItem
|
||||||
:label="item.name"
|
v-if="!item.isMore"
|
||||||
v-for="(item, index) in model[field]"
|
:labelCol="{ span: 8 }"
|
||||||
:key="index"
|
:label="item.name"
|
||||||
:name="['data', index, 'value']"
|
:name="['data', index, 'value']"
|
||||||
:rules="{
|
:rules="{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入',
|
message: '请输入',
|
||||||
trigger: 'change',
|
trigger: 'change',
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<Input v-model:value="item.value" :suffix="item.unit" placeholder="请输入"></Input>
|
<Input v-model:value="item.value" :suffix="item.unit" placeholder="请输入" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
<template v-else>
|
||||||
|
<div v-for="(item1, i) in item.value" :key="i">
|
||||||
|
<Row>
|
||||||
|
<Col :span="15">
|
||||||
|
<FormItem
|
||||||
|
:labelCol="{ span: 13 }"
|
||||||
|
:label="i == 0 ? item.name : ` `"
|
||||||
|
:name="['data', i, 'value']"
|
||||||
|
:rules="{
|
||||||
|
required: false,
|
||||||
|
message: '请输入',
|
||||||
|
trigger: 'change',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<Input v-model:value="item1.year" placeholder="请输入" />
|
||||||
|
</FormItem>
|
||||||
|
</Col>
|
||||||
|
<Col :span="9">
|
||||||
|
<FormItem
|
||||||
|
:labelCol="{ span: 2 }"
|
||||||
|
:name="['data', i, 'value']"
|
||||||
|
:label="` `"
|
||||||
|
:rules="{
|
||||||
|
required: false,
|
||||||
|
message: '请输入',
|
||||||
|
trigger: 'change',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
class="!w-8/10 !mr-10px"
|
||||||
|
v-model:value="item1.value"
|
||||||
|
placeholder="请输入"
|
||||||
|
/>
|
||||||
|
<PlusCircleOutlined
|
||||||
|
v-if="i === 0"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="addDomain(item)"
|
||||||
|
/>
|
||||||
|
<MinusCircleOutlined
|
||||||
|
v-else
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="removeDomain(item, i)"
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
</Col>
|
||||||
|
<!-- <FormItem
|
||||||
|
:labelCol="{ span: 8 }"
|
||||||
|
:label="item.name"
|
||||||
|
:name="['data', index, 'value']"
|
||||||
|
:rules="{
|
||||||
|
required: true,
|
||||||
|
message: '请输入',
|
||||||
|
trigger: 'change',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<Input v-model:value="item1.year" placeholder="请输入" />
|
||||||
|
</FormItem>
|
||||||
|
<FormItem
|
||||||
|
:labelCol="{ span: 8 }"
|
||||||
|
:name="['data', index, 'value']"
|
||||||
|
:rules="{
|
||||||
|
required: true,
|
||||||
|
message: '请输入',
|
||||||
|
trigger: 'change',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<Input v-model:value="item1.value" placeholder="请输入" />
|
||||||
|
</FormItem> -->
|
||||||
|
</Row>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</BasicForm>
|
</BasicForm>
|
||||||
</BasicDrawer>
|
</BasicDrawer>
|
||||||
|
|
@ -32,8 +104,11 @@
|
||||||
import { BasicForm, useForm } from '/@/components/Form/index'
|
import { BasicForm, useForm } from '/@/components/Form/index'
|
||||||
import { searchFormSchema1 } from './city.data'
|
import { searchFormSchema1 } from './city.data'
|
||||||
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'
|
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 { 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 emits = defineEmits(['success', 'register'])
|
||||||
const isUpdate = ref(false)
|
const isUpdate = ref(false)
|
||||||
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
|
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
|
||||||
|
|
@ -42,19 +117,61 @@
|
||||||
schemas: searchFormSchema1,
|
schemas: searchFormSchema1,
|
||||||
showActionButtonGroup: false,
|
showActionButtonGroup: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
||||||
resetFields()
|
resetFields()
|
||||||
setDrawerProps({ confirmLoading: false })
|
setDrawerProps({ confirmLoading: false })
|
||||||
isUpdate.value = data?.isUpdate
|
isUpdate.value = data?.isUpdate
|
||||||
|
|
||||||
if (unref(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({
|
setFieldsValue({
|
||||||
...data,
|
data: tempData,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await validate()
|
const { data } = await validate()
|
||||||
|
console.log(data)
|
||||||
|
|
||||||
|
return
|
||||||
const params = {}
|
const params = {}
|
||||||
data.forEach((e) => {
|
data.forEach((e) => {
|
||||||
params[e.slug] = e.value
|
params[e.slug] = e.value
|
||||||
|
|
@ -66,4 +183,15 @@
|
||||||
setDrawerProps({ confirmLoading: false })
|
setDrawerProps({ confirmLoading: false })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const addDomain = (item) => {
|
||||||
|
item.value.push({
|
||||||
|
value: '',
|
||||||
|
year: '',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const removeDomain = (item, index) => {
|
||||||
|
item.value.splice(index, 1)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
<a-button size="small" @click="handleCensus">编辑</a-button>
|
<a-button size="small" @click="handleCensus">编辑</a-button>
|
||||||
</template>
|
</template>
|
||||||
<a-card-grid
|
<a-card-grid
|
||||||
|
v-show="filterCityData.findIndex((e) => e === item.slug) < 0"
|
||||||
class="!md:w-1/3 !xl:w-1/7 !w-full !py-24px !px-10px"
|
class="!md:w-1/3 !xl:w-1/7 !w-full !py-24px !px-10px"
|
||||||
v-for="(item, index) in CityDate"
|
v-for="(item, index) in CityDate"
|
||||||
:key="index"
|
:key="index"
|
||||||
|
|
@ -71,6 +72,13 @@
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const CityDate = ref([])
|
const CityDate = ref([])
|
||||||
|
const filterCityData = [
|
||||||
|
'city_data_chart_nongye',
|
||||||
|
'city_data_chart_yuye',
|
||||||
|
'city_data_chart_xumuye',
|
||||||
|
'city_data_chart_lingye',
|
||||||
|
'city_data_chart_activity',
|
||||||
|
]
|
||||||
const [registerDrawer, { openDrawer }] = useDrawer()
|
const [registerDrawer, { openDrawer }] = useDrawer()
|
||||||
// 统计
|
// 统计
|
||||||
const [registerDrawer1, { openDrawer: openDrawer1 }] = useDrawer()
|
const [registerDrawer1, { openDrawer: openDrawer1 }] = useDrawer()
|
||||||
|
|
@ -141,6 +149,7 @@
|
||||||
handleCensus,
|
handleCensus,
|
||||||
registerDrawer1,
|
registerDrawer1,
|
||||||
handleSuccess1,
|
handleSuccess1,
|
||||||
|
filterCityData,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue