城镇数据
parent
8ba4477d76
commit
d22d28b49f
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -4,25 +4,97 @@
|
|||
@register="registerDrawer"
|
||||
showFooter
|
||||
title="编辑统计"
|
||||
width="500px"
|
||||
width="600px"
|
||||
@ok="handleSubmit"
|
||||
>
|
||||
<BasicForm @register="registerForm">
|
||||
<template #data="{ model, field }">
|
||||
<FormItem
|
||||
:labelCol="{ span: 8 }"
|
||||
:label="item.name"
|
||||
v-for="(item, index) in model[field]"
|
||||
:key="index"
|
||||
:name="['data', index, 'value']"
|
||||
:rules="{
|
||||
required: true,
|
||||
message: '请输入',
|
||||
trigger: 'change',
|
||||
}"
|
||||
>
|
||||
<Input v-model:value="item.value" :suffix="item.unit" placeholder="请输入"></Input>
|
||||
</FormItem>
|
||||
<template v-for="(item, index) in model[field]" :key="index">
|
||||
<FormItem
|
||||
v-if="!item.isMore"
|
||||
:labelCol="{ span: 8 }"
|
||||
:label="item.name"
|
||||
:name="['data', index, 'value']"
|
||||
:rules="{
|
||||
required: true,
|
||||
message: '请输入',
|
||||
trigger: 'change',
|
||||
}"
|
||||
>
|
||||
<Input v-model:value="item.value" :suffix="item.unit" placeholder="请输入" />
|
||||
</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>
|
||||
</BasicForm>
|
||||
</BasicDrawer>
|
||||
|
|
@ -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)
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<a-button size="small" @click="handleCensus">编辑</a-button>
|
||||
</template>
|
||||
<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"
|
||||
v-for="(item, index) in CityDate"
|
||||
:key="index"
|
||||
|
|
@ -71,6 +72,13 @@
|
|||
},
|
||||
setup() {
|
||||
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 [registerDrawer1, { openDrawer: openDrawer1 }] = useDrawer()
|
||||
|
|
@ -141,6 +149,7 @@
|
|||
handleCensus,
|
||||
registerDrawer1,
|
||||
handleSuccess1,
|
||||
filterCityData,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue