Compare commits
No commits in common. "b10fac211bf91d4700913e9f0d3440fd082b3d22" and "4b77a4e0ee2756fccd58f1f372bbcec1c13de84e" have entirely different histories.
b10fac211b
...
4b77a4e0ee
|
|
@ -248,17 +248,17 @@ export function editPassword(id: string, data, mode: ErrorMessageMode = 'modal')
|
||||||
/**
|
/**
|
||||||
* @description:获取农作物
|
* @description:获取农作物
|
||||||
*/
|
*/
|
||||||
// export function getCrops(data, mode: ErrorMessageMode = 'modal') {
|
export function getCrops(data, mode: ErrorMessageMode = 'modal') {
|
||||||
// return defHttp.get(
|
return defHttp.get(
|
||||||
// {
|
{
|
||||||
// url: `/api/crops`,
|
url: `/api/crops`,
|
||||||
// data,
|
data,
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// errorMessageMode: mode,
|
errorMessageMode: mode,
|
||||||
// },
|
},
|
||||||
// )
|
)
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description:新增区域数据
|
* @description:新增区域数据
|
||||||
|
|
@ -357,13 +357,10 @@ export function addcrops(data, mode: ErrorMessageMode = 'modal') {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export function getCropYields(data, mode: ErrorMessageMode = 'modal') {
|
||||||
* @description:修改农作物
|
return defHttp.post(
|
||||||
*/
|
|
||||||
export function editcrops(id: string, data, mode: ErrorMessageMode = 'modal') {
|
|
||||||
return defHttp.put(
|
|
||||||
{
|
{
|
||||||
url: `/api/crops/${id}`,
|
url: `/api/crops`,
|
||||||
data,
|
data,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -371,31 +368,3 @@ export function editcrops(id: string, data, mode: ErrorMessageMode = 'modal') {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @description:删除农作物
|
|
||||||
*/
|
|
||||||
export function deleteCrops(id: string, mode: ErrorMessageMode = 'modal') {
|
|
||||||
return defHttp.delete(
|
|
||||||
{
|
|
||||||
url: `/api/crops/${id}`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
errorMessageMode: mode,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @description:稻虾价格 - 列表
|
|
||||||
*/
|
|
||||||
export function getShrimpPrices(params, mode: ErrorMessageMode = 'modal') {
|
|
||||||
return defHttp.get(
|
|
||||||
{
|
|
||||||
url: `/api/rice-shrimp-prices`,
|
|
||||||
params,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
errorMessageMode: mode,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ const main: AppRouteModule = {
|
||||||
{
|
{
|
||||||
path: 'basics-crop',
|
path: 'basics-crop',
|
||||||
name: 'BasicsCrop',
|
name: 'BasicsCrop',
|
||||||
component: () => import('/@/views/base/crops/base-crops/index.vue'),
|
component: () => import('/@/views/base/base-data/index.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: '基地农作物',
|
title: '基地农作物',
|
||||||
},
|
},
|
||||||
|
|
@ -74,7 +74,7 @@ const main: AppRouteModule = {
|
||||||
{
|
{
|
||||||
path: 'town-yield',
|
path: 'town-yield',
|
||||||
name: 'TownYield',
|
name: 'TownYield',
|
||||||
component: () => import('/@/views/base/ranking-list/index1.vue'),
|
component: () => import('/@/views/base/city-data/index.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: '城镇产量',
|
title: '城镇产量',
|
||||||
},
|
},
|
||||||
|
|
@ -82,7 +82,7 @@ const main: AppRouteModule = {
|
||||||
{
|
{
|
||||||
path: 'basics-yield',
|
path: 'basics-yield',
|
||||||
name: 'BasicsYield',
|
name: 'BasicsYield',
|
||||||
component: () => import('/@/views/base/ranking-list/index1.vue'),
|
component: () => import('/@/views/base/base-data/index.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: '基地产量',
|
title: '基地产量',
|
||||||
},
|
},
|
||||||
|
|
@ -90,17 +90,17 @@ const main: AppRouteModule = {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'estate',
|
path: 'industry',
|
||||||
name: 'estate',
|
name: 'Industry',
|
||||||
meta: {
|
meta: {
|
||||||
title: '重点产业',
|
title: '重点产业',
|
||||||
// icon: 'ion:key-outline',
|
// icon: 'ion:key-outline',
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'estate-price',
|
path: 'industry-price',
|
||||||
name: 'EstatePrice',
|
name: 'IndustryPrice',
|
||||||
component: () => import('/@/views/base/estate/shrim-price/index.vue'),
|
component: () => import('/@/views/base/city-data/index.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: '稻虾价格',
|
title: '稻虾价格',
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { BasicColumn } from '/@/components/Table'
|
import { BasicColumn } from '/@/components/Table'
|
||||||
import { FormSchema } from '/@/components/Table'
|
import { FormSchema } from '/@/components/Table'
|
||||||
import { getcrops, getTownAgriculturalBasic } from '/@/api/sys/user'
|
import { getCrops } from '/@/api/sys/user'
|
||||||
export const columns: BasicColumn[] = [
|
export const columns: BasicColumn[] = [
|
||||||
{
|
{
|
||||||
title: '基地名称',
|
title: '基地名称',
|
||||||
|
|
@ -66,7 +66,12 @@ export const accountFormSchema: FormSchema[] = [
|
||||||
required: true,
|
required: true,
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
field: 'address',
|
||||||
|
label: '基地地址',
|
||||||
|
required: true,
|
||||||
|
component: 'Input',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
field: 'person',
|
field: 'person',
|
||||||
label: '基地负责人',
|
label: '基地负责人',
|
||||||
|
|
@ -85,20 +90,6 @@ export const accountFormSchema: FormSchema[] = [
|
||||||
required: true,
|
required: true,
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
field: 'parent_id',
|
|
||||||
label: '城镇',
|
|
||||||
required: true,
|
|
||||||
component: 'ApiSelect',
|
|
||||||
componentProps: {
|
|
||||||
api: async () => {
|
|
||||||
const res = await getTownAgriculturalBasic({ type: 2 })
|
|
||||||
return res
|
|
||||||
},
|
|
||||||
labelField: 'name',
|
|
||||||
valueField: 'id',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
field: 'crops_ids',
|
field: 'crops_ids',
|
||||||
label: '基地农作物',
|
label: '基地农作物',
|
||||||
|
|
@ -106,11 +97,11 @@ export const accountFormSchema: FormSchema[] = [
|
||||||
component: 'ApiSelect',
|
component: 'ApiSelect',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
api: async () => {
|
api: async () => {
|
||||||
const res = await getcrops({ type: 'all', crop_type: 1 })
|
const res = await getCrops({ type: 'all', crop_type: 1 })
|
||||||
return res.map((e) => {
|
return res.map((e) => {
|
||||||
return {
|
return {
|
||||||
...e,
|
...e,
|
||||||
disabled: e.is_end === 0,
|
disabled: e.is_end === 1,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
@ -119,12 +110,7 @@ export const accountFormSchema: FormSchema[] = [
|
||||||
mode: 'multiple',
|
mode: 'multiple',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
field: 'address',
|
|
||||||
label: '基地地址',
|
|
||||||
required: true,
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
field: 'description',
|
field: 'description',
|
||||||
label: '基地介绍',
|
label: '基地介绍',
|
||||||
|
|
|
||||||
|
|
@ -1,216 +0,0 @@
|
||||||
<template>
|
|
||||||
<BasicDrawer
|
|
||||||
v-bind="$attrs"
|
|
||||||
@register="registerDrawer"
|
|
||||||
showFooter
|
|
||||||
:title="getTitle"
|
|
||||||
width="500px"
|
|
||||||
@ok="handleSubmit"
|
|
||||||
>
|
|
||||||
<!-- <BasicForm @register="registerForm"> </BasicForm> -->
|
|
||||||
<Form class="w-full" :label-col="{ span: 4 }" ref="formRef" :model="modelRef">
|
|
||||||
<FormItem
|
|
||||||
label="产业"
|
|
||||||
name="category_id"
|
|
||||||
:rules="{
|
|
||||||
required: true,
|
|
||||||
message: '请选择产业',
|
|
||||||
trigger: 'change',
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<Select
|
|
||||||
v-model:value="modelRef.category_id"
|
|
||||||
placeholder="请选择产业"
|
|
||||||
class="w-full"
|
|
||||||
:options="categoryDate"
|
|
||||||
:fieldNames="{ label: 'name', value: 'id' }"
|
|
||||||
></Select>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem
|
|
||||||
label="名称"
|
|
||||||
name="name"
|
|
||||||
:rules="{
|
|
||||||
required: true,
|
|
||||||
message: '请输入名称',
|
|
||||||
trigger: 'change',
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<Input v-model:value="modelRef.name" placeholder="请输入" class="w-full"></Input>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="上级">
|
|
||||||
<Select
|
|
||||||
:options="parentDate"
|
|
||||||
:fieldNames="{ label: 'name', value: 'id' }"
|
|
||||||
v-model:value="modelRef.parent_id"
|
|
||||||
placeholder="请选择"
|
|
||||||
class="w-full"
|
|
||||||
></Select>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem
|
|
||||||
label="单位"
|
|
||||||
name="unit"
|
|
||||||
:rules="{
|
|
||||||
required: true,
|
|
||||||
message: '请输入单位',
|
|
||||||
trigger: 'change',
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<Input v-model:value="modelRef.unit" placeholder="请输入" class="w-full"></Input>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem
|
|
||||||
label="排序"
|
|
||||||
name="sort"
|
|
||||||
:rules="{
|
|
||||||
required: true,
|
|
||||||
message: '请输入排序',
|
|
||||||
trigger: 'change',
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<Input v-model:value="modelRef.sort" placeholder="请输入" class="w-full"></Input>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="是否是结点" name="is_end">
|
|
||||||
<Switch v-model:checked="modelRef.is_end" placeholder="请选择"></Switch>
|
|
||||||
</FormItem>
|
|
||||||
<!-- -->
|
|
||||||
<template v-if="modelRef.is_end">
|
|
||||||
<Space
|
|
||||||
v-for="(sight, index) in modelRef.extends"
|
|
||||||
:key="index"
|
|
||||||
style="display: flex; margin-bottom: 8px"
|
|
||||||
align="baseline"
|
|
||||||
>
|
|
||||||
<FormItem
|
|
||||||
label="名称"
|
|
||||||
:name="['extends', index, 'name']"
|
|
||||||
:rules="{
|
|
||||||
required: true,
|
|
||||||
message: '请输入名称',
|
|
||||||
trigger: 'change',
|
|
||||||
}"
|
|
||||||
:label-col="{ span: 8 }"
|
|
||||||
>
|
|
||||||
<Input v-model:value="sight.name" placeholder="请输入" class="w-full"></Input>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem
|
|
||||||
label="单位"
|
|
||||||
:name="['extends', index, 'unit']"
|
|
||||||
:rules="{
|
|
||||||
required: true,
|
|
||||||
message: '请输入单位',
|
|
||||||
trigger: 'change',
|
|
||||||
}"
|
|
||||||
:label-col="{ span: 8 }"
|
|
||||||
>
|
|
||||||
<Input v-model:value="sight.unit" placeholder="请输入" class="w-full"></Input>
|
|
||||||
</FormItem>
|
|
||||||
<MinusCircleOutlined
|
|
||||||
@click="removeSight(sight)"
|
|
||||||
v-if="modelRef.extends.length > 1"
|
|
||||||
:disabled="modelRef.extends.length === 1"
|
|
||||||
/>
|
|
||||||
</Space>
|
|
||||||
<FormItem>
|
|
||||||
<div class="flex items-center justify-center w-full px-80px">
|
|
||||||
<Button type="dashed" block @click="addSight">
|
|
||||||
<PlusOutlined />
|
|
||||||
添加
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</FormItem>
|
|
||||||
</template>
|
|
||||||
</Form>
|
|
||||||
</BasicDrawer>
|
|
||||||
</template>
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { ref, computed, unref } from 'vue'
|
|
||||||
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'
|
|
||||||
import { Form, Select, FormItem, Input, Switch, Button, Space } from 'ant-design-vue'
|
|
||||||
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons-vue'
|
|
||||||
import { getCropCate, addcrops, getcrops, editcrops } from '/@/api/sys/user'
|
|
||||||
import type { FormInstance } from 'ant-design-vue'
|
|
||||||
const formRef = ref<FormInstance>()
|
|
||||||
const categoryDate = ref([])
|
|
||||||
const parentDate = ref([])
|
|
||||||
const modelRef = ref({
|
|
||||||
id: null,
|
|
||||||
category_id: undefined, //产业ID
|
|
||||||
name: '', //名称
|
|
||||||
parent_id: undefined, //上级
|
|
||||||
unit: '', //单位
|
|
||||||
is_end: false, //是否是结点
|
|
||||||
extends: [{ name: '', unit: '' }],
|
|
||||||
sort: '', //排序
|
|
||||||
})
|
|
||||||
|
|
||||||
const addSight = () => {
|
|
||||||
modelRef?.value.extends.push({
|
|
||||||
name: '',
|
|
||||||
unit: '',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const removeSight = (item: any) => {
|
|
||||||
let index = modelRef.value.extends.indexOf(item)
|
|
||||||
if (index !== -1) {
|
|
||||||
modelRef.value.extends.splice(index, 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const emits = defineEmits(['success', 'register'])
|
|
||||||
const isUpdate = ref(false)
|
|
||||||
const getTitle = computed(() => (!isUpdate.value ? '新增农作物' : '编辑农作物'))
|
|
||||||
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
|
||||||
formRef.value?.resetFields()
|
|
||||||
// 获取产业
|
|
||||||
const res = await getCropCate()
|
|
||||||
categoryDate.value = res
|
|
||||||
//获取上级数据
|
|
||||||
const resDate = await getcrops({ page: 1, per_page: 99999, crop_type: 1, type: 'all' })
|
|
||||||
parentDate.value = resDate.filter((e) => !e.is_end)
|
|
||||||
setDrawerProps({ confirmLoading: false })
|
|
||||||
isUpdate.value = data?.isUpdate
|
|
||||||
if (unref(isUpdate)) {
|
|
||||||
modelRef.value = {
|
|
||||||
category_id: data.category_id,
|
|
||||||
name: data.name,
|
|
||||||
parent_id: data.parent_id == 0 ? undefined : data.parent_id,
|
|
||||||
unit: data.unit,
|
|
||||||
is_end: data.is_end == 1 ? true : false,
|
|
||||||
extends: data.extends.length ? JSON.parse(data.extends) : [],
|
|
||||||
sort: data.sort,
|
|
||||||
id: data.id,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
modelRef.value = {
|
|
||||||
id: null,
|
|
||||||
category_id: undefined, //产业ID
|
|
||||||
name: '', //名称
|
|
||||||
parent_id: undefined, //上级
|
|
||||||
unit: '', //单位
|
|
||||||
is_end: false, //是否是结点
|
|
||||||
extends: [{ name: '', unit: '' }],
|
|
||||||
sort: '', //排序
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
|
||||||
try {
|
|
||||||
const values = await formRef.value?.validate()
|
|
||||||
const params = {
|
|
||||||
crop_type: 1,
|
|
||||||
...values,
|
|
||||||
}
|
|
||||||
setDrawerProps({ confirmLoading: true })
|
|
||||||
if (modelRef.value.id) {
|
|
||||||
// 修改
|
|
||||||
await editcrops(modelRef.value.id, params)
|
|
||||||
} else {
|
|
||||||
// 新增
|
|
||||||
await addcrops(params)
|
|
||||||
}
|
|
||||||
closeDrawer()
|
|
||||||
emits('success')
|
|
||||||
} finally {
|
|
||||||
setDrawerProps({ confirmLoading: false })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
import { BasicColumn } from '/@/components/Table'
|
|
||||||
import { FormSchema } from '/@/components/Table'
|
|
||||||
export const columns: BasicColumn[] = [
|
|
||||||
{
|
|
||||||
title: '名称',
|
|
||||||
dataIndex: 'name',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '单位',
|
|
||||||
dataIndex: 'unit',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '是否是结点',
|
|
||||||
dataIndex: 'is_end',
|
|
||||||
customRender: ({ text }) => {
|
|
||||||
return text == 1 ? '是' : '否'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
width: 180,
|
|
||||||
title: '操作',
|
|
||||||
dataIndex: 'action',
|
|
||||||
align: 'center',
|
|
||||||
fixed: undefined,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
export const searchFormSchema: FormSchema[] = []
|
|
||||||
|
|
||||||
export const accountFormSchema: FormSchema[] = []
|
|
||||||
|
|
@ -1,86 +0,0 @@
|
||||||
<template>
|
|
||||||
<div class="pt-20px">
|
|
||||||
<BasicTable @register="registerTable">
|
|
||||||
<template #toolbar>
|
|
||||||
<a-button type="primary" @click="handleCreate"> 新增农作物 </a-button>
|
|
||||||
</template>
|
|
||||||
<template #bodyCell="{ column, record }">
|
|
||||||
<template v-if="column.key === 'action'">
|
|
||||||
<div class="flex items-center justify-center">
|
|
||||||
<TableAction
|
|
||||||
:actions="[
|
|
||||||
{ label: '编辑', onClick: handleEdit.bind(null, record) },
|
|
||||||
{
|
|
||||||
label: '删除',
|
|
||||||
popConfirm: {
|
|
||||||
title: '是否确认删除',
|
|
||||||
placement: 'topRight',
|
|
||||||
confirm: handleDelete.bind(null, record),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template v-if="column.key === 'crops'">
|
|
||||||
<Button
|
|
||||||
class="mx-2px"
|
|
||||||
v-for="(item, index) in record['crops']"
|
|
||||||
:key="index"
|
|
||||||
type="link"
|
|
||||||
>{{ item.name }}</Button
|
|
||||||
>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
</BasicTable>
|
|
||||||
<TownDrawer @register="registerDrawer" @success="handleSuccess" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { BasicTable, useTable, TableAction } from '/@/components/Table'
|
|
||||||
import { deleteCrops, getcrops } from '/@/api/sys/user'
|
|
||||||
import { message } from 'ant-design-vue'
|
|
||||||
import { useDrawer } from '/@/components/Drawer'
|
|
||||||
import TownDrawer from './BaseDrawer.vue'
|
|
||||||
import { Button } from 'ant-design-vue'
|
|
||||||
import { columns, searchFormSchema } from './base.data'
|
|
||||||
const [registerDrawer, { openDrawer }] = useDrawer()
|
|
||||||
const [registerTable, { reload }] = useTable({
|
|
||||||
title: '基地农作物列表',
|
|
||||||
api: async (e) => {
|
|
||||||
const res = await getcrops({ type: 'all', ...e, crop_type: 1 })
|
|
||||||
return res
|
|
||||||
},
|
|
||||||
rowKey: 'id',
|
|
||||||
columns,
|
|
||||||
formConfig: {
|
|
||||||
labelWidth: 120,
|
|
||||||
schemas: searchFormSchema,
|
|
||||||
},
|
|
||||||
useSearchForm: false,
|
|
||||||
showTableSetting: true,
|
|
||||||
bordered: true,
|
|
||||||
showIndexColumn: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
const handleSuccess = () => {
|
|
||||||
message.success('操作成功')
|
|
||||||
reload()
|
|
||||||
}
|
|
||||||
const handleCreate = () => {
|
|
||||||
openDrawer(true, {
|
|
||||||
isUpdate: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const handleEdit = (record: Recordable) => {
|
|
||||||
openDrawer(true, {
|
|
||||||
...record,
|
|
||||||
isUpdate: true,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const handleDelete = async (record: Recordable) => {
|
|
||||||
await deleteCrops(record.id)
|
|
||||||
message.success('删除成功')
|
|
||||||
reload()
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
@ -8,209 +8,108 @@
|
||||||
@ok="handleSubmit"
|
@ok="handleSubmit"
|
||||||
>
|
>
|
||||||
<!-- <BasicForm @register="registerForm"> </BasicForm> -->
|
<!-- <BasicForm @register="registerForm"> </BasicForm> -->
|
||||||
<Form class="w-full" :label-col="{ span: 4 }" ref="formRef" :model="modelRef">
|
<Form> </Form>
|
||||||
<FormItem
|
|
||||||
label="产业"
|
|
||||||
name="category_id"
|
|
||||||
:rules="{
|
|
||||||
required: true,
|
|
||||||
message: '请选择产业',
|
|
||||||
trigger: 'change',
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<Select
|
|
||||||
v-model:value="modelRef.category_id"
|
|
||||||
placeholder="请选择产业"
|
|
||||||
class="w-full"
|
|
||||||
:options="categoryDate"
|
|
||||||
:fieldNames="{ label: 'name', value: 'id' }"
|
|
||||||
></Select>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem
|
|
||||||
label="名称"
|
|
||||||
name="name"
|
|
||||||
:rules="{
|
|
||||||
required: true,
|
|
||||||
message: '请输入名称',
|
|
||||||
trigger: 'change',
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<Input v-model:value="modelRef.name" placeholder="请输入" class="w-full"></Input>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="上级">
|
|
||||||
<Select
|
|
||||||
:options="parentDate"
|
|
||||||
:fieldNames="{ label: 'name', value: 'id' }"
|
|
||||||
v-model:value="modelRef.parent_id"
|
|
||||||
placeholder="请选择"
|
|
||||||
class="w-full"
|
|
||||||
></Select>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem
|
|
||||||
label="单位"
|
|
||||||
name="unit"
|
|
||||||
:rules="{
|
|
||||||
required: true,
|
|
||||||
message: '请输入单位',
|
|
||||||
trigger: 'change',
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<Input v-model:value="modelRef.unit" placeholder="请输入" class="w-full"></Input>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem
|
|
||||||
label="排序"
|
|
||||||
name="sort"
|
|
||||||
:rules="{
|
|
||||||
required: true,
|
|
||||||
message: '请输入排序',
|
|
||||||
trigger: 'change',
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<Input v-model:value="modelRef.sort" placeholder="请输入" class="w-full"></Input>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="是否是结点" name="is_end">
|
|
||||||
<Switch v-model:checked="modelRef.is_end" placeholder="请选择"></Switch>
|
|
||||||
</FormItem>
|
|
||||||
<!-- -->
|
|
||||||
<template v-if="modelRef.is_end">
|
|
||||||
<Space
|
|
||||||
v-for="(sight, index) in modelRef.extends"
|
|
||||||
:key="index"
|
|
||||||
style="display: flex; margin-bottom: 8px"
|
|
||||||
align="baseline"
|
|
||||||
>
|
|
||||||
<FormItem
|
|
||||||
label="名称"
|
|
||||||
:name="['extends', index, 'name']"
|
|
||||||
:rules="{
|
|
||||||
required: true,
|
|
||||||
message: '请输入名称',
|
|
||||||
trigger: 'change',
|
|
||||||
}"
|
|
||||||
:label-col="{ span: 8 }"
|
|
||||||
>
|
|
||||||
<Input v-model:value="sight.name" placeholder="请输入" class="w-full"></Input>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem
|
|
||||||
label="单位"
|
|
||||||
:name="['extends', index, 'unit']"
|
|
||||||
:rules="{
|
|
||||||
required: true,
|
|
||||||
message: '请输入单位',
|
|
||||||
trigger: 'change',
|
|
||||||
}"
|
|
||||||
:label-col="{ span: 8 }"
|
|
||||||
>
|
|
||||||
<Input v-model:value="sight.unit" placeholder="请输入" class="w-full"></Input>
|
|
||||||
</FormItem>
|
|
||||||
<MinusCircleOutlined
|
|
||||||
@click="removeSight(sight)"
|
|
||||||
v-if="modelRef.extends.length > 1"
|
|
||||||
:disabled="modelRef.extends.length === 1"
|
|
||||||
/>
|
|
||||||
</Space>
|
|
||||||
<FormItem>
|
|
||||||
<div class="flex items-center justify-center w-full px-80px">
|
|
||||||
<Button type="dashed" block @click="addSight">
|
|
||||||
<PlusOutlined />
|
|
||||||
添加
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</FormItem>
|
|
||||||
</template>
|
|
||||||
</Form>
|
|
||||||
</BasicDrawer>
|
</BasicDrawer>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, computed, unref } from 'vue'
|
import { ref, computed, unref, reactive } from 'vue'
|
||||||
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'
|
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'
|
||||||
import { Form, Select, FormItem, Input, Switch, Button, Space } from 'ant-design-vue'
|
import { Form } from 'ant-design-vue'
|
||||||
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons-vue'
|
const useForm = Form.useForm
|
||||||
import { getCropCate, addcrops, getcrops, editcrops } from '/@/api/sys/user'
|
const modelRef = reactive({
|
||||||
import type { FormInstance } from 'ant-design-vue'
|
category_id: '', //产业ID
|
||||||
const formRef = ref<FormInstance>()
|
|
||||||
const categoryDate = ref([])
|
|
||||||
const parentDate = ref([])
|
|
||||||
const modelRef = ref({
|
|
||||||
id: null,
|
|
||||||
category_id: undefined, //产业ID
|
|
||||||
name: '', //名称
|
name: '', //名称
|
||||||
parent_id: undefined, //上级
|
parent_id: '', //上级
|
||||||
unit: '', //单位
|
unit: '', //单位
|
||||||
is_end: false, //是否是结点
|
is_end: '', //是否是结点
|
||||||
extends: [{ name: '', unit: '' }],
|
extends: [],
|
||||||
sort: '', //排序
|
sort: '', //排序
|
||||||
})
|
})
|
||||||
|
const rulesRef = reactive({
|
||||||
|
category_id: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
name: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
unit: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
sort: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
const { resetFields, validate, validateInfos } = useForm(modelRef, rulesRef)
|
||||||
|
|
||||||
|
// import { BasicForm, useForm } from '/@/components/Form/index'
|
||||||
|
// import { accountFormSchema } from './town.data'
|
||||||
|
|
||||||
|
// import { addcrops, editGriculturalBasic } from '/@/api/sys/user'
|
||||||
|
|
||||||
const addSight = () => {
|
|
||||||
modelRef?.value.extends.push({
|
|
||||||
name: '',
|
|
||||||
unit: '',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const removeSight = (item: any) => {
|
|
||||||
let index = modelRef.value.extends.indexOf(item)
|
|
||||||
if (index !== -1) {
|
|
||||||
modelRef.value.extends.splice(index, 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const emits = defineEmits(['success', 'register'])
|
const emits = defineEmits(['success', 'register'])
|
||||||
const isUpdate = ref(false)
|
const isUpdate = ref(false)
|
||||||
const getTitle = computed(() => (!isUpdate.value ? '新增农作物' : '编辑农作物'))
|
const getTitle = computed(() => (!isUpdate.value ? '新增农作物' : '编辑农作物'))
|
||||||
|
// const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
|
||||||
|
// labelWidth: 90,
|
||||||
|
// baseColProps: { span: 24 },
|
||||||
|
// schemas: accountFormSchema,
|
||||||
|
// showActionButtonGroup: false,
|
||||||
|
// })
|
||||||
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
||||||
formRef.value?.resetFields()
|
// resetFields()
|
||||||
// 获取产业
|
|
||||||
const res = await getCropCate()
|
|
||||||
categoryDate.value = res
|
|
||||||
//获取上级数据
|
|
||||||
const resDate = await getcrops({ page: 1, per_page: 99999, crop_type: 2, type: 'all' })
|
|
||||||
parentDate.value = resDate.filter((e) => !e.is_end)
|
|
||||||
setDrawerProps({ confirmLoading: false })
|
setDrawerProps({ confirmLoading: false })
|
||||||
isUpdate.value = data?.isUpdate
|
isUpdate.value = data?.isUpdate
|
||||||
if (unref(isUpdate)) {
|
if (unref(isUpdate)) {
|
||||||
modelRef.value = {
|
// setFieldsValue({
|
||||||
category_id: data.category_id,
|
// ...data,
|
||||||
name: data.name,
|
// crops_ids: data.crops.map((e) => e.id),
|
||||||
parent_id: data.parent_id == 0 ? undefined : data.parent_id,
|
// })
|
||||||
unit: data.unit,
|
|
||||||
is_end: data.is_end ? true : false,
|
|
||||||
extends: data.extends.length ? JSON.parse(data.extends) : [],
|
|
||||||
sort: data.sort,
|
|
||||||
id: data.id,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
modelRef.value = {
|
|
||||||
id: null,
|
|
||||||
category_id: undefined, //产业ID
|
|
||||||
name: '', //名称
|
|
||||||
parent_id: undefined, //上级
|
|
||||||
unit: '', //单位
|
|
||||||
is_end: false, //是否是结点
|
|
||||||
extends: [{ name: '', unit: '' }],
|
|
||||||
sort: '', //排序
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
try {
|
// try {
|
||||||
const values = await formRef.value?.validate()
|
// const values = await validate()
|
||||||
const params = {
|
// values.crop_type = 2
|
||||||
crop_type: 2,
|
// values.is_end = values?.is_end ?? false
|
||||||
...values,
|
// const params = {
|
||||||
}
|
// ...values,
|
||||||
setDrawerProps({ confirmLoading: true })
|
// extends: {
|
||||||
if (modelRef.value.id) {
|
// name: '',
|
||||||
// 修改
|
// unit: '',
|
||||||
await editcrops(modelRef.value.id, params)
|
// },
|
||||||
} else {
|
// }
|
||||||
// 新增
|
// if (values.is_end) {
|
||||||
await addcrops(params)
|
// params.extends.name = values.endName
|
||||||
}
|
// params.extends.unit = values.endUnit
|
||||||
closeDrawer()
|
// } else {
|
||||||
emits('success')
|
// delete params.extends
|
||||||
} finally {
|
// }
|
||||||
setDrawerProps({ confirmLoading: false })
|
// console.log(params)
|
||||||
}
|
// setDrawerProps({ confirmLoading: true })
|
||||||
|
// if (values.id) {
|
||||||
|
// // 修改
|
||||||
|
// await editGriculturalBasic(values.id, values)
|
||||||
|
// } else {
|
||||||
|
// // 新增
|
||||||
|
// await addcrops(params)
|
||||||
|
// }
|
||||||
|
// closeDrawer()
|
||||||
|
// emits('success')
|
||||||
|
// } finally {
|
||||||
|
// setDrawerProps({ confirmLoading: false })
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { BasicTable, useTable, TableAction } from '/@/components/Table'
|
import { BasicTable, useTable, TableAction } from '/@/components/Table'
|
||||||
import { deleteCrops, getcrops } from '/@/api/sys/user'
|
import { deleteGriculturalBasic, getTownAgriculturalBasic } from '/@/api/sys/user'
|
||||||
import { message } from 'ant-design-vue'
|
import { message } from 'ant-design-vue'
|
||||||
import { useDrawer } from '/@/components/Drawer'
|
import { useDrawer } from '/@/components/Drawer'
|
||||||
import TownDrawer from './TownDrawer.vue'
|
import TownDrawer from './TownDrawer.vue'
|
||||||
|
|
@ -46,9 +46,9 @@
|
||||||
import { columns, searchFormSchema } from './town.data'
|
import { columns, searchFormSchema } from './town.data'
|
||||||
const [registerDrawer, { openDrawer }] = useDrawer()
|
const [registerDrawer, { openDrawer }] = useDrawer()
|
||||||
const [registerTable, { reload }] = useTable({
|
const [registerTable, { reload }] = useTable({
|
||||||
title: '城镇农作物列表',
|
title: '农作物列表',
|
||||||
api: async (e) => {
|
api: async (e) => {
|
||||||
const res = await getcrops({ type: 'all', ...e, crop_type: 2 })
|
const res = await getTownAgriculturalBasic({ type: 1, ...e })
|
||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
rowKey: 'id',
|
rowKey: 'id',
|
||||||
|
|
@ -79,7 +79,7 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const handleDelete = async (record: Recordable) => {
|
const handleDelete = async (record: Recordable) => {
|
||||||
await deleteCrops(record.id)
|
await deleteGriculturalBasic(record.id)
|
||||||
message.success('删除成功')
|
message.success('删除成功')
|
||||||
reload()
|
reload()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,42 @@
|
||||||
import { BasicColumn } from '/@/components/Table'
|
import { BasicColumn } from '/@/components/Table'
|
||||||
import { FormSchema } from '/@/components/Table'
|
import { FormSchema } from '/@/components/Table'
|
||||||
|
import { getCropCate, getcrops } from '/@/api/sys/user'
|
||||||
export const columns: BasicColumn[] = [
|
export const columns: BasicColumn[] = [
|
||||||
{
|
{
|
||||||
title: '名称',
|
title: '基地名称',
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '单位',
|
title: '基地负责人',
|
||||||
dataIndex: 'unit',
|
dataIndex: 'person',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '是否是结点',
|
title: '基地农作物',
|
||||||
dataIndex: 'is_end',
|
dataIndex: 'crops',
|
||||||
customRender: ({ text }) => {
|
},
|
||||||
return text == 1 ? '是' : '否'
|
{
|
||||||
},
|
title: '基地经度',
|
||||||
|
dataIndex: 'address_lat',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '基地纬度',
|
||||||
|
dataIndex: 'address_lng',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '基地地址',
|
||||||
|
dataIndex: 'address',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '基地面积',
|
||||||
|
dataIndex: 'areas',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '基地就业人数',
|
||||||
|
dataIndex: 'workforce',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '基地描述',
|
||||||
|
dataIndex: 'description',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
width: 180,
|
width: 180,
|
||||||
|
|
@ -27,4 +49,83 @@ export const columns: BasicColumn[] = [
|
||||||
|
|
||||||
export const searchFormSchema: FormSchema[] = []
|
export const searchFormSchema: FormSchema[] = []
|
||||||
|
|
||||||
export const accountFormSchema: FormSchema[] = []
|
export const accountFormSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
field: 'id',
|
||||||
|
label: '基地ID',
|
||||||
|
required: false,
|
||||||
|
dynamicDisabled: true,
|
||||||
|
component: 'Input',
|
||||||
|
ifShow: ({ values }) => {
|
||||||
|
return !!values.id
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'category_id',
|
||||||
|
label: '产业',
|
||||||
|
required: true,
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
api: getCropCate,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
label: '名称',
|
||||||
|
required: true,
|
||||||
|
component: 'Input',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'parent_id',
|
||||||
|
label: '上级',
|
||||||
|
required: false,
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
api: async () => {
|
||||||
|
const res = await getcrops({ page: 1, per_page: 99999, crop_type: 2, type: 'all' })
|
||||||
|
return res.filter((e) => !e.is_end)
|
||||||
|
},
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'unit',
|
||||||
|
label: '单位',
|
||||||
|
required: true,
|
||||||
|
component: 'Input',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'sort',
|
||||||
|
label: '排序',
|
||||||
|
required: true,
|
||||||
|
component: 'InputNumber',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'is_end',
|
||||||
|
label: '是否是结点',
|
||||||
|
required: false,
|
||||||
|
component: 'Switch',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'endName',
|
||||||
|
label: '名称',
|
||||||
|
required: true,
|
||||||
|
component: 'Input',
|
||||||
|
ifShow: ({ values }) => {
|
||||||
|
return values.is_end
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'endUnit',
|
||||||
|
label: '单位',
|
||||||
|
required: true,
|
||||||
|
component: 'Input',
|
||||||
|
ifShow: ({ values }) => {
|
||||||
|
return values.is_end
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,80 +0,0 @@
|
||||||
<template>
|
|
||||||
<BasicDrawer
|
|
||||||
v-bind="$attrs"
|
|
||||||
@register="registerDrawer"
|
|
||||||
showFooter
|
|
||||||
:title="getTitle"
|
|
||||||
width="500px"
|
|
||||||
@ok="handleSubmit"
|
|
||||||
>
|
|
||||||
<BasicForm @register="registerForm"> </BasicForm>
|
|
||||||
</BasicDrawer>
|
|
||||||
</template>
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { ref, computed, unref } from 'vue'
|
|
||||||
import { BasicForm, useForm } from '/@/components/Form/index'
|
|
||||||
import { accountFormSchema } from './shrim-price'
|
|
||||||
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'
|
|
||||||
import { defaultsDeep } from 'lodash-es'
|
|
||||||
import { createDevice, getDeviceTypes, updateDevice } from '/@/api/sys/other'
|
|
||||||
const emits = defineEmits(['success', 'register'])
|
|
||||||
const isUpdate = ref(false)
|
|
||||||
const getTitle = computed(() => (!isUpdate.value ? '新增设备' : '编辑设备'))
|
|
||||||
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
|
|
||||||
labelWidth: 120,
|
|
||||||
baseColProps: { span: 24 },
|
|
||||||
schemas: accountFormSchema,
|
|
||||||
showActionButtonGroup: false,
|
|
||||||
})
|
|
||||||
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
|
||||||
resetFields()
|
|
||||||
setDrawerProps({ confirmLoading: false })
|
|
||||||
isUpdate.value = data?.isUpdate
|
|
||||||
if (unref(isUpdate)) {
|
|
||||||
const obj = Object.assign({}, { ...data, ...data?.extends })
|
|
||||||
const deviceTypes = await getDeviceTypes()
|
|
||||||
await setFieldsValue({
|
|
||||||
...obj,
|
|
||||||
agricultural_base_id: obj.base_id,
|
|
||||||
type: formatDataByObject(deviceTypes).find((e) => e.label == obj.type)?.value,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const formatDataByObject = (obj) => {
|
|
||||||
const arr: any[] = []
|
|
||||||
Object.keys(obj).forEach((e) => {
|
|
||||||
arr.push({
|
|
||||||
label: obj[e],
|
|
||||||
value: e,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
return arr
|
|
||||||
}
|
|
||||||
const setValue = (keys: any, value: any) => {
|
|
||||||
const object = {}
|
|
||||||
var last = keys.pop()
|
|
||||||
keys.reduce((o, k) => (o[k] = o[k] || {}), object)[last] = value
|
|
||||||
return object
|
|
||||||
}
|
|
||||||
const handleSubmit = async () => {
|
|
||||||
try {
|
|
||||||
const values = await validate()
|
|
||||||
let params = {}
|
|
||||||
for (const key in values) {
|
|
||||||
params = defaultsDeep({}, params, setValue(key.split('.'), values[key]))
|
|
||||||
}
|
|
||||||
setDrawerProps({ confirmLoading: true })
|
|
||||||
if (values.id) {
|
|
||||||
// 修改
|
|
||||||
await updateDevice(values.id, params)
|
|
||||||
} else {
|
|
||||||
// 新增
|
|
||||||
await createDevice(params)
|
|
||||||
}
|
|
||||||
closeDrawer()
|
|
||||||
emits('success')
|
|
||||||
} finally {
|
|
||||||
setDrawerProps({ confirmLoading: false })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
@ -1,79 +0,0 @@
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<BasicTable @register="registerTable">
|
|
||||||
<template #toolbar>
|
|
||||||
<a-button type="primary" @click="handleCreate"> 新增设备 </a-button>
|
|
||||||
</template>
|
|
||||||
<template #bodyCell="{ column, record }">
|
|
||||||
<template v-if="column.key === 'action'">
|
|
||||||
<div class="flex items-center justify-center">
|
|
||||||
<TableAction
|
|
||||||
:actions="[
|
|
||||||
{ label: '编辑', onClick: handleEdit.bind(null, record) },
|
|
||||||
{
|
|
||||||
label: '删除',
|
|
||||||
popConfirm: {
|
|
||||||
title: '是否确认删除',
|
|
||||||
placement: 'topRight',
|
|
||||||
confirm: handleDelete.bind(null, record),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
</BasicTable>
|
|
||||||
<PriceDrawer @register="registerDrawer" @success="handleSuccess" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { BasicTable, useTable, TableAction } from '/@/components/Table'
|
|
||||||
// import { getShrimpPrices, deleteDevice } from '/@/api/sys/other'
|
|
||||||
import { getShrimpPrices } from '/@/api/sys/user'
|
|
||||||
import { message } from 'ant-design-vue'
|
|
||||||
import { useDrawer } from '/@/components/Drawer'
|
|
||||||
import PriceDrawer from './PriceDrawer.vue'
|
|
||||||
import { columns, searchFormSchema } from './shrim-price'
|
|
||||||
const [registerDrawer, { openDrawer }] = useDrawer()
|
|
||||||
const [registerTable, { reload }] = useTable({
|
|
||||||
title: '稻虾价格 - 列表',
|
|
||||||
api: getShrimpPrices,
|
|
||||||
rowKey: 'id',
|
|
||||||
columns,
|
|
||||||
formConfig: {
|
|
||||||
labelWidth: 120,
|
|
||||||
schemas: searchFormSchema,
|
|
||||||
},
|
|
||||||
useSearchForm: true,
|
|
||||||
showTableSetting: true,
|
|
||||||
bordered: true,
|
|
||||||
showIndexColumn: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
const handleSuccess = () => {
|
|
||||||
message.success('操作成功')
|
|
||||||
reload()
|
|
||||||
}
|
|
||||||
const handleCreate = () => {
|
|
||||||
openDrawer(true, {
|
|
||||||
id: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const handleEdit = (record: Recordable) => {
|
|
||||||
openDrawer(true, {
|
|
||||||
...record,
|
|
||||||
isUpdate: true,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const handleDelete = async (record: Recordable) => {
|
|
||||||
await deleteDevice(record.id)
|
|
||||||
message.success('删除成功')
|
|
||||||
reload()
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<style lang="less" scoped>
|
|
||||||
:deep(.ant-picker) {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
@ -1,184 +0,0 @@
|
||||||
import { BasicColumn } from '/@/components/Table'
|
|
||||||
import { FormSchema } from '/@/components/Table'
|
|
||||||
import { getAgriculturalBasic } from '/@/api/sys/user'
|
|
||||||
import { getDeviceTypes } from '/@/api/sys/other'
|
|
||||||
import { h } from 'vue'
|
|
||||||
import { DatePicker } from 'ant-design-vue'
|
|
||||||
function formatDataByObject(obj): any[] {
|
|
||||||
const arr: any[] = []
|
|
||||||
Object.keys(obj).forEach((e) => {
|
|
||||||
arr.push({
|
|
||||||
label: obj[e],
|
|
||||||
value: e,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
return arr
|
|
||||||
}
|
|
||||||
export const columns: BasicColumn[] = [
|
|
||||||
{
|
|
||||||
title: '年份',
|
|
||||||
dataIndex: 'year',
|
|
||||||
customRender: ({ text }) => {
|
|
||||||
return text + '年'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '季度',
|
|
||||||
dataIndex: 'quarter',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '价格',
|
|
||||||
dataIndex: 'price',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '创建人',
|
|
||||||
dataIndex: 'name',
|
|
||||||
customRender: ({ record: { created_by } }) => {
|
|
||||||
return created_by.name
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
width: 180,
|
|
||||||
title: '操作',
|
|
||||||
dataIndex: 'action',
|
|
||||||
align: 'center',
|
|
||||||
fixed: undefined,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
export const searchFormSchema: FormSchema[] = [
|
|
||||||
{
|
|
||||||
field: 'year',
|
|
||||||
label: '年份',
|
|
||||||
component: 'Input',
|
|
||||||
render: ({ model, field }) => {
|
|
||||||
return h(DatePicker, {
|
|
||||||
placeholder: '请选择年份',
|
|
||||||
picker: 'year',
|
|
||||||
mode: 'year',
|
|
||||||
onChange: (e) => {
|
|
||||||
model[field] = e['$y']
|
|
||||||
},
|
|
||||||
})
|
|
||||||
},
|
|
||||||
colProps: { span: 6 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'quarter',
|
|
||||||
label: '季度',
|
|
||||||
component: 'Select',
|
|
||||||
componentProps: {
|
|
||||||
options: [
|
|
||||||
{ label: '第一季度', value: '1' },
|
|
||||||
{ label: '第二季度', value: '2' },
|
|
||||||
{ label: '第三季度', value: '3' },
|
|
||||||
{ label: '第四季度', value: '4' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
colProps: { span: 6 },
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
export const accountFormSchema: FormSchema[] = [
|
|
||||||
{
|
|
||||||
field: 'id',
|
|
||||||
label: '设备ID',
|
|
||||||
required: false,
|
|
||||||
dynamicDisabled: true,
|
|
||||||
component: 'Input',
|
|
||||||
ifShow: ({ values }) => {
|
|
||||||
return !!values.id
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'type',
|
|
||||||
label: '设备类型',
|
|
||||||
required: true,
|
|
||||||
component: 'ApiSelect',
|
|
||||||
componentProps: {
|
|
||||||
api: async () => {
|
|
||||||
const res = await getDeviceTypes()
|
|
||||||
return formatDataByObject(res)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'agricultural_base_id',
|
|
||||||
label: '基地',
|
|
||||||
required: true,
|
|
||||||
component: 'ApiSelect',
|
|
||||||
componentProps: {
|
|
||||||
api: getAgriculturalBasic,
|
|
||||||
labelField: 'name',
|
|
||||||
valueField: 'id',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'sn',
|
|
||||||
label: '设备编号',
|
|
||||||
required: true,
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'monitoring_point',
|
|
||||||
label: '监控点',
|
|
||||||
required: true,
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'extends.ip',
|
|
||||||
label: '设备IP',
|
|
||||||
required: true,
|
|
||||||
component: 'Input',
|
|
||||||
ifShow: ({ values }) => {
|
|
||||||
return !!(values.type == 1)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'extends.port',
|
|
||||||
label: '设备端口',
|
|
||||||
required: true,
|
|
||||||
component: 'Input',
|
|
||||||
ifShow: ({ values }) => {
|
|
||||||
return !!(values.type == 1)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'extends.rtsp_url',
|
|
||||||
label: 'RTSP地址',
|
|
||||||
required: true,
|
|
||||||
component: 'Input',
|
|
||||||
ifShow: ({ values }) => {
|
|
||||||
return !!(values.type == 1)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
field: 'extends.username',
|
|
||||||
label: '设备登录名',
|
|
||||||
required: true,
|
|
||||||
component: 'Input',
|
|
||||||
ifShow: ({ values }) => {
|
|
||||||
return !!(values.type == 1)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'extends.password',
|
|
||||||
label: '设备登录密码',
|
|
||||||
required: true,
|
|
||||||
component: 'Input',
|
|
||||||
ifShow: ({ values }) => {
|
|
||||||
return !!(values.type == 1)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'extends.passage',
|
|
||||||
label: '设备播放通道',
|
|
||||||
required: true,
|
|
||||||
component: 'Input',
|
|
||||||
ifShow: ({ values }) => {
|
|
||||||
return !!(values.type == 1)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
Loading…
Reference in New Issue