修改bug
parent
a42d078825
commit
51ad8e799f
|
|
@ -911,3 +911,18 @@ export function markWarningLogs(id, mode: ErrorMessageMode = 'modal') {
|
|||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @description:更新基础数据统计
|
||||
*/
|
||||
export function citydataEdit(data, mode: ErrorMessageMode = 'modal') {
|
||||
return defHttp.put(
|
||||
{
|
||||
url: `/api/citydata-statistics-edit`,
|
||||
data,
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ export function getTreeData(
|
|||
idName = 'id',
|
||||
childrenName = 'children',
|
||||
key = 'key',
|
||||
condition = 0,
|
||||
isNull = true,
|
||||
) {
|
||||
let arr = []
|
||||
|
|
@ -117,7 +118,7 @@ export function getTreeData(
|
|||
for (let i = 0; i < data.length; i++) {
|
||||
if (data[i][pidName] == pid) {
|
||||
data[i][key] = data[i][idName]
|
||||
data[i]['disabled'] = data[i].is_end == 1 ? false : true
|
||||
data[i]['disabled'] = data[i].is_end == condition ? false : true
|
||||
data[i][childrenName] = getTreeData(
|
||||
data,
|
||||
data[i][idName],
|
||||
|
|
@ -125,6 +126,7 @@ export function getTreeData(
|
|||
idName,
|
||||
childrenName,
|
||||
key,
|
||||
condition,
|
||||
isNull,
|
||||
)
|
||||
if (isNull && data[i][childrenName].length == 0) delete data[i][childrenName]
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@
|
|||
}).then((AMap) => {
|
||||
AMapObj = AMap
|
||||
map.value = new AMap.Map('mapcontainer', {
|
||||
center: [104.739928, 29.484215], //中心点坐标
|
||||
zoom: 5, //级别
|
||||
center: [105.29, 29.34], //中心点坐标
|
||||
zoom: 12, //级别
|
||||
})
|
||||
// 添加点击事件
|
||||
map.value.on('click', onMapClick)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
<template>
|
||||
<BasicDrawer
|
||||
v-bind="$attrs"
|
||||
@register="registerDrawer"
|
||||
showFooter
|
||||
title="编辑统计"
|
||||
width="500px"
|
||||
@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>
|
||||
</BasicForm>
|
||||
</BasicDrawer>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref, unref } from 'vue'
|
||||
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 { citydataEdit } from '/@/api/sys/user'
|
||||
const emits = defineEmits(['success', 'register'])
|
||||
const isUpdate = ref(false)
|
||||
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
|
||||
labelWidth: 20,
|
||||
baseColProps: { span: 24 },
|
||||
schemas: searchFormSchema1,
|
||||
showActionButtonGroup: false,
|
||||
})
|
||||
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
||||
resetFields()
|
||||
setDrawerProps({ confirmLoading: false })
|
||||
isUpdate.value = data?.isUpdate
|
||||
if (unref(isUpdate)) {
|
||||
setFieldsValue({
|
||||
...data,
|
||||
})
|
||||
}
|
||||
})
|
||||
const handleSubmit = async () => {
|
||||
try {
|
||||
const { data } = await validate()
|
||||
const params = {}
|
||||
data.forEach((e) => {
|
||||
params[e.slug] = e.value
|
||||
})
|
||||
await citydataEdit(params)
|
||||
closeDrawer()
|
||||
emits('success')
|
||||
} finally {
|
||||
setDrawerProps({ confirmLoading: false })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
@ -133,3 +133,11 @@ export const accountFormSchema: FormSchema[] = [
|
|||
component: 'InputTextArea',
|
||||
},
|
||||
]
|
||||
export const searchFormSchema1: FormSchema[] = [
|
||||
{
|
||||
field: 'data',
|
||||
label: '',
|
||||
component: 'Input',
|
||||
slot: 'data',
|
||||
},
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<template>
|
||||
<PageWrapper>
|
||||
<a-card title="全市数据统计" class="px-16px">
|
||||
<!-- <template #extra>
|
||||
<a-button size="small">编辑</a-button>
|
||||
</template> -->
|
||||
<template #extra>
|
||||
<a-button size="small" @click="handleCensus">编辑</a-button>
|
||||
</template>
|
||||
<a-card-grid
|
||||
class="!md:w-1/3 !xl:w-1/7 !w-full"
|
||||
v-for="(item, index) in CityDate"
|
||||
|
|
@ -40,6 +40,8 @@
|
|||
</BasicTable>
|
||||
</div>
|
||||
<DeviceDrawer @register="registerDrawer" @success="handleSuccess" />
|
||||
<!-- 统计编辑 -->
|
||||
<CensusDrawer @register="registerDrawer1" @success="handleSuccess1" />
|
||||
</PageWrapper>
|
||||
</template>
|
||||
|
||||
|
|
@ -49,6 +51,7 @@
|
|||
import { Card } from 'ant-design-vue'
|
||||
import CountItem from './components/CountItem.vue'
|
||||
import DeviceDrawer from './DeviceDrawer.vue'
|
||||
import CensusDrawer from './CensusDrawer.vue'
|
||||
import { getCitydataStatistics } from '/@/api/sys/other'
|
||||
import { getTownAgriculturalBasic, deleteGriculturalBasic } from '/@/api/sys/user'
|
||||
import { columns, searchFormSchema } from './city.data'
|
||||
|
|
@ -64,10 +67,13 @@
|
|||
BasicTable,
|
||||
TableAction,
|
||||
DeviceDrawer,
|
||||
CensusDrawer,
|
||||
},
|
||||
setup() {
|
||||
const CityDate = ref([])
|
||||
const [registerDrawer, { openDrawer }] = useDrawer()
|
||||
// 统计
|
||||
const [registerDrawer1, { openDrawer: openDrawer1 }] = useDrawer()
|
||||
const [registerTable, { reload }] = useTable({
|
||||
api: async (e) => {
|
||||
const { data, meta } = await getTownAgriculturalBasic({ type: 2, ...e })
|
||||
|
|
@ -106,9 +112,23 @@
|
|||
message.success('操作成功')
|
||||
reload()
|
||||
}
|
||||
onMounted(async () => {
|
||||
// 统计
|
||||
const handleCensus = () => {
|
||||
openDrawer1(true, {
|
||||
isUpdate: true,
|
||||
data: JSON.parse(JSON.stringify(CityDate.value)),
|
||||
})
|
||||
}
|
||||
const handleSuccess1 = () => {
|
||||
message.success('操作成功')
|
||||
getData()
|
||||
}
|
||||
const getData = async () => {
|
||||
let res = await getCitydataStatistics()
|
||||
CityDate.value = res
|
||||
}
|
||||
onMounted(async () => {
|
||||
getData()
|
||||
})
|
||||
return {
|
||||
CityDate,
|
||||
|
|
@ -118,6 +138,9 @@
|
|||
handleDelete,
|
||||
registerDrawer,
|
||||
handleSuccess,
|
||||
handleCensus,
|
||||
registerDrawer1,
|
||||
handleSuccess1,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@
|
|||
if (unref(treeData).length === 0) {
|
||||
const res = await getcrops({ type: 'all', crop_type: 1 })
|
||||
cropslist.value = res.data
|
||||
treeData.value = getTreeData(res.data, 0, 'parent_id', 'id', 'children', 'key')
|
||||
treeData.value = getTreeData(res.data, 0, 'parent_id', 'id', 'children', 'key', 1)
|
||||
}
|
||||
isUpdate.value = data?.isUpdate
|
||||
if (unref(isUpdate)) {
|
||||
|
|
@ -91,13 +91,13 @@
|
|||
const res = await getCropYieldsInfo(data.id)
|
||||
await setFieldsValue({
|
||||
id: data.id,
|
||||
quarter: data.quarter.toString(),
|
||||
time_year: dayjs(data.time_year.toString()),
|
||||
base_id: data.base_id,
|
||||
yield: data.yield,
|
||||
output: data.output,
|
||||
crop_id: data.crop_id,
|
||||
cultivated: data.cultivated,
|
||||
quarter: res.quarter.toString(),
|
||||
time_year: dayjs(res.time_year.toString()),
|
||||
base_id: res.base_id,
|
||||
yield: res.yield,
|
||||
output: res.output,
|
||||
crop_id: res.crop_id,
|
||||
cultivated: res.cultivated,
|
||||
extends: formatDataByObject(my_extends, res.extends),
|
||||
})
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { BasicColumn } from '/@/components/Table'
|
||||
import { FormSchema } from '/@/components/Table'
|
||||
import { getTownAgriculturalBasic } from '/@/api/sys/user'
|
||||
import { getTownAgriculturalBasic, getcrops } from '/@/api/sys/user'
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: '基地名称',
|
||||
|
|
@ -51,7 +51,7 @@ export const searchFormSchema: FormSchema[] = [
|
|||
picker: 'year',
|
||||
mode: 'year',
|
||||
},
|
||||
colProps: { span: 8 },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{
|
||||
field: 'quarter',
|
||||
|
|
@ -65,22 +65,22 @@ export const searchFormSchema: FormSchema[] = [
|
|||
{ label: '第四季度', value: '4' },
|
||||
],
|
||||
},
|
||||
colProps: { span: 8 },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{
|
||||
field: 'crop',
|
||||
label: '农作物',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: async () => {
|
||||
const { data } = await getcrops({ type: 'all', crop_type: 1 })
|
||||
return data.filter((e) => e.is_end == 1)
|
||||
},
|
||||
labelField: 'name',
|
||||
valueField: 'id',
|
||||
},
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
// {
|
||||
// field: 'crop',
|
||||
// label: '农作物',
|
||||
// component: 'ApiSelect',
|
||||
// componentProps: {
|
||||
// api: async () => {
|
||||
// const res = await getcrops({ type: 'all', crop_type: 2 })
|
||||
// return res.filter((e) => e.is_end == 1)
|
||||
// },
|
||||
// labelField: 'name',
|
||||
// valueField: 'id',
|
||||
// },
|
||||
// colProps: { span: 6 },
|
||||
// },
|
||||
]
|
||||
|
||||
export const accountFormSchema: FormSchema[] = [
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@
|
|||
if (unref(treeData).length === 0) {
|
||||
const res = await getcrops({ type: 'all', crop_type: 2 })
|
||||
cropslist.value = res.data
|
||||
treeData.value = getTreeData(res.data, 0, 'parent_id', 'id', 'children', 'key')
|
||||
treeData.value = getTreeData(res.data, 0, 'parent_id', 'id', 'children', 'key', 1)
|
||||
}
|
||||
isUpdate.value = data?.isUpdate
|
||||
if (unref(isUpdate)) {
|
||||
|
|
@ -94,13 +94,13 @@
|
|||
const res = await getCropYieldsInfo(data.id)
|
||||
await setFieldsValue({
|
||||
id: data.id,
|
||||
quarter: data.quarter.toString(),
|
||||
time_year: dayjs(data.time_year.toString()),
|
||||
base_id: data.base_id,
|
||||
yield: data.yield,
|
||||
output: data.output,
|
||||
crop_id: data.crop_id,
|
||||
cultivated: data.cultivated,
|
||||
quarter: res.quarter.toString(),
|
||||
time_year: dayjs(res.time_year.toString()),
|
||||
base_id: res.base_id,
|
||||
yield: res.yield,
|
||||
output: res.output,
|
||||
crop_id: res.crop_id,
|
||||
cultivated: res.cultivated,
|
||||
extends: formatDataByObject(my_extends, res.extends),
|
||||
})
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { BasicColumn } from '/@/components/Table'
|
||||
import { FormSchema } from '/@/components/Table'
|
||||
import { getTownAgriculturalBasic } from '/@/api/sys/user'
|
||||
import { getTownAgriculturalBasic, getcrops } from '/@/api/sys/user'
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: '基地名称',
|
||||
|
|
@ -51,7 +51,7 @@ export const searchFormSchema: FormSchema[] = [
|
|||
picker: 'year',
|
||||
mode: 'year',
|
||||
},
|
||||
colProps: { span: 8 },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{
|
||||
field: 'quarter',
|
||||
|
|
@ -65,22 +65,22 @@ export const searchFormSchema: FormSchema[] = [
|
|||
{ label: '第四季度', value: '4' },
|
||||
],
|
||||
},
|
||||
colProps: { span: 8 },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{
|
||||
field: 'crop',
|
||||
label: '农作物',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: async () => {
|
||||
const { data } = await getcrops({ type: 'all', crop_type: 2 })
|
||||
return data.filter((e) => e.is_end == 1)
|
||||
},
|
||||
labelField: 'name',
|
||||
valueField: 'id',
|
||||
},
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
// {
|
||||
// field: 'crop',
|
||||
// label: '农作物',
|
||||
// component: 'ApiSelect',
|
||||
// componentProps: {
|
||||
// api: async () => {
|
||||
// const res = await getcrops({ type: 'all', crop_type: 2 })
|
||||
// return res.filter((e) => e.is_end == 1)
|
||||
// },
|
||||
// labelField: 'name',
|
||||
// valueField: 'id',
|
||||
// },
|
||||
// colProps: { span: 6 },
|
||||
// },
|
||||
]
|
||||
|
||||
export const accountFormSchema: FormSchema[] = [
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@
|
|||
setDrawerProps({ confirmLoading: false })
|
||||
if (unref(treeData).length === 0) {
|
||||
const res = await getcrops({ type: 'all', crop_type: 1 })
|
||||
treeData.value = getTreeData(res.data, 0, 'parent_id', 'id', 'children', 'key')
|
||||
treeData.value = getTreeData(res.data, 0, 'parent_id', 'id', 'children', 'key', 0)
|
||||
}
|
||||
isUpdate.value = data?.isUpdate
|
||||
if (unref(isUpdate)) {
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@
|
|||
setDrawerProps({ confirmLoading: false })
|
||||
if (unref(treeData).length === 0) {
|
||||
const res = await getcrops({ type: 'all', crop_type: 2 })
|
||||
treeData.value = getTreeData(res.data, 0, 'parent_id', 'id', 'children', 'key')
|
||||
treeData.value = getTreeData(res.data, 0, 'parent_id', 'id', 'children', 'key', 0)
|
||||
}
|
||||
isUpdate.value = data?.isUpdate
|
||||
if (unref(isUpdate)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue