diff --git a/src/api/sys/user.ts b/src/api/sys/user.ts index 7fd664de..b57c4f87 100644 --- a/src/api/sys/user.ts +++ b/src/api/sys/user.ts @@ -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, + }, + ) +} diff --git a/src/utils/index.ts b/src/utils/index.ts index 41f2974c..b9d57c50 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -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] diff --git a/src/views/base/base-data/map.vue b/src/views/base/base-data/map.vue index 96927378..9c14d26a 100644 --- a/src/views/base/base-data/map.vue +++ b/src/views/base/base-data/map.vue @@ -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) diff --git a/src/views/base/city-data/CensusDrawer.vue b/src/views/base/city-data/CensusDrawer.vue new file mode 100644 index 00000000..0b536400 --- /dev/null +++ b/src/views/base/city-data/CensusDrawer.vue @@ -0,0 +1,69 @@ + + diff --git a/src/views/base/city-data/city.data.ts b/src/views/base/city-data/city.data.ts index c9ec6920..c2acd92b 100644 --- a/src/views/base/city-data/city.data.ts +++ b/src/views/base/city-data/city.data.ts @@ -133,3 +133,11 @@ export const accountFormSchema: FormSchema[] = [ component: 'InputTextArea', }, ] +export const searchFormSchema1: FormSchema[] = [ + { + field: 'data', + label: '', + component: 'Input', + slot: 'data', + }, +] diff --git a/src/views/base/city-data/index.vue b/src/views/base/city-data/index.vue index c1e94eba..62b50f73 100644 --- a/src/views/base/city-data/index.vue +++ b/src/views/base/city-data/index.vue @@ -1,9 +1,9 @@ @@ -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, } }, }) diff --git a/src/views/base/crop-yields/base-yields/BaseDrawer.vue b/src/views/base/crop-yields/base-yields/BaseDrawer.vue index f168cb56..c5d0c8fe 100644 --- a/src/views/base/crop-yields/base-yields/BaseDrawer.vue +++ b/src/views/base/crop-yields/base-yields/BaseDrawer.vue @@ -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 { diff --git a/src/views/base/crop-yields/base-yields/base.data.ts b/src/views/base/crop-yields/base-yields/base.data.ts index c10bdecb..e20d24f4 100644 --- a/src/views/base/crop-yields/base-yields/base.data.ts +++ b/src/views/base/crop-yields/base-yields/base.data.ts @@ -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[] = [ diff --git a/src/views/base/crop-yields/town-yields/TownDrawer.vue b/src/views/base/crop-yields/town-yields/TownDrawer.vue index 9bd4a438..d0400538 100644 --- a/src/views/base/crop-yields/town-yields/TownDrawer.vue +++ b/src/views/base/crop-yields/town-yields/TownDrawer.vue @@ -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 { diff --git a/src/views/base/crop-yields/town-yields/town.data.ts b/src/views/base/crop-yields/town-yields/town.data.ts index c10bdecb..3b652fe3 100644 --- a/src/views/base/crop-yields/town-yields/town.data.ts +++ b/src/views/base/crop-yields/town-yields/town.data.ts @@ -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[] = [ diff --git a/src/views/base/crops/base-crops/BaseDrawer.vue b/src/views/base/crops/base-crops/BaseDrawer.vue index 1b81449e..f8ee9eaa 100644 --- a/src/views/base/crops/base-crops/BaseDrawer.vue +++ b/src/views/base/crops/base-crops/BaseDrawer.vue @@ -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)) { diff --git a/src/views/base/crops/town-crops/TownDrawer.vue b/src/views/base/crops/town-crops/TownDrawer.vue index ecc3436f..91f0f3c2 100644 --- a/src/views/base/crops/town-crops/TownDrawer.vue +++ b/src/views/base/crops/town-crops/TownDrawer.vue @@ -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)) {