修改历史数据

new-map
ihzero 2023-02-03 14:33:59 +08:00
parent df275bc118
commit 295fc2c300
2 changed files with 158 additions and 103 deletions

View File

@ -15,6 +15,7 @@
<div class="px-10px"> <div class="px-10px">
<div class="flex justify-end py-4px"> <div class="flex justify-end py-4px">
<a-switch <a-switch
v-if="recommend"
checked-children="推荐开" checked-children="推荐开"
un-checked-children="推荐关" un-checked-children="推荐关"
v-model:checked="checked" v-model:checked="checked"
@ -50,6 +51,10 @@
url: { url: {
type: String, type: String,
}, },
recommend: {
type: Boolean,
default: true,
},
}, },
setup(props) { setup(props) {
let player: any | null = null let player: any | null = null

View File

@ -1,31 +1,46 @@
<template> <template>
<div> <div>
<BasicForm <BasicForm @register="registerForm" />
autoFocusFirstItem
:labelWidth="0"
:schemas="schemas"
:rowProps="{ gutter: [16, 0] }"
:showActionButtonGroup="false"
/>
<List <List
:grid="{ gutter: 16, xs: 1, sm: 2, md: 2, lg: 3, xl: 4, xxl: 5, column: 1 }" :grid="{ gutter: 16, xs: 1, sm: 2, md: 2, lg: 3, xl: 4, xxl: 5, column: 8 }"
:data-source="data" :data-source="list"
> >
<template #renderItem="{ item }"> <template #renderItem="{ item }">
<List-item> <List-item>
<LiveBroadcastItem /> <LiveBroadcastItem :recommend="false" :url="socketUrl" :item="item" />
</List-item> </List-item>
</template> </template>
</List> </List>
<div class="text-right">
<a-pagination
size="small"
v-model:current="pageCurrent"
v-model:page-size="pageSize"
:total="pageTotal"
show-less-items
showSizeChanger
:pageSizeOptions="['8']"
:show-total="(total) => `共 ${total} 条数据`"
@change="getData"
/>
</div>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue'; import { defineComponent, toRefs, reactive, onMounted, ref } from 'vue'
import { BasicForm, FormSchema } from '/@/components/Form/index'; import { BasicForm, FormSchema, useForm } from '/@/components/Form/index'
import { List } from 'ant-design-vue'; import { List, Pagination } from 'ant-design-vue'
import { ColEx } from '/@/components/Form/src/types'; import { ColEx } from '/@/components/Form/src/types'
import LiveBroadcastItem from './LiveBroadcastItem.vue'; import LiveBroadcastItem from './LiveBroadcastItem.vue'
import { formatDataByObject } from '/@/utils/index'
import { getffmpegip } from '/@/api/sys/other'
import dayjs from 'dayjs'
import {
getGriculturalDeviceBasic,
getaGriculturalDevicePoint,
getDevices,
} from '/@/api/sys/user'
const colProps: Partial<ColEx> = { const colProps: Partial<ColEx> = {
xs: 24, xs: 24,
sm: 12, sm: 12,
@ -33,105 +48,78 @@
lg: 6, lg: 6,
xl: 6, xl: 6,
xxl: 4, xxl: 4,
}; }
const schemas: FormSchema[] = [ const schemas: FormSchema[] = [
{ {
field: 'field1', field: 'base',
component: 'Select', component: 'ApiSelect',
label: '', label: '',
colProps, colProps,
componentProps: { componentProps: ({ formActionType }) => {
placeholder: '基地', return {
options: [ placeholder: '基地',
{ allowClear: false,
label: '选项2', api: getGriculturalDeviceBasic,
value: '1', params: {
key: '1', device_type: 1,
}, },
], labelField: 'name',
onChange: (e: any) => { valueField: 'id',
console.log(e); onOptionsChange: (options) => {
}, const { setFieldsValue } = formActionType
setFieldsValue({
base: options[0].value,
})
},
}
}, },
}, },
{ {
field: 'field1', field: 'point',
component: 'Select', component: 'ApiSelect',
label: '', label: '',
colProps, colProps,
componentProps: { componentProps: ({ formModel, formActionType }) => {
placeholder: '检测点', return {
options: [ placeholder: '',
{ allowClear: false,
label: '选项2', api: async (e) => {
value: '1', if (e.agricultural_basic == null) return []
key: '1', const resData = await getaGriculturalDevicePoint(e)
return formatDataByObject(resData)
}, },
], onOptionsChange: (options) => {
onChange: (e: any) => { const { setFieldsValue } = formActionType
console.log(e);
},
},
},
{
field: 'time',
component: 'RangePicker',
label: '',
colProps,
componentProps: {
placeholder: ['开始日期', '结束日期'],
},
},
{
field: 'disclosure',
component: 'RadioButtonGroup',
label: '',
colProps: colProps,
componentProps: {
options: [
{
label: '今天',
value: '1',
},
{
label: '近一周',
value: '2',
},
{
label: '近一个月',
value: '3',
},
],
},
},
];
interface DataItem { if (options.length)
title: string; setFieldsValue({
} point: options[0].value,
const data: DataItem[] = [ })
{ },
title: 'Title 1', params: {
device_type: 1,
agricultural_basic: formModel.base,
},
labelField: 'label',
valueField: 'label',
}
},
}, },
{ {
title: 'Title 2', field: '[start_time, end_time]',
label: '',
component: 'RangePicker',
required: true,
componentProps: {
format: 'YYYY-MM-DD',
placeholder: ['开始时间', '结束时间'],
disabledDate: (current) => {
return current && current > dayjs().endOf('day')
},
},
colProps,
}, },
{ ]
title: 'Title 3',
},
{
title: 'Title 4',
},
{
title: 'Title 4',
},
{
title: 'Title 4',
},
{
title: 'Title 4',
},
];
export default defineComponent({ export default defineComponent({
components: { components: {
@ -139,14 +127,76 @@
List, List,
ListItem: List.Item, ListItem: List.Item,
LiveBroadcastItem, LiveBroadcastItem,
[Pagination.name]: Pagination,
}, },
setup() { setup() {
return { const paginationParams = reactive({
pageCurrent: 1,
pageTotal: 0,
pageSize: 8,
})
const list = ref([])
const socketUrl = ref<String | null>(null)
const [registerForm, { validate, getFieldsValue }] = useForm({
schemas, schemas,
data, autoFocusFirstItem: true,
}; labelWidth: 0,
rowProps: { gutter: [16, 0] },
showActionButtonGroup: true,
submitOnChange: false,
autoSubmitOnEnter: false,
submitFunc: getData,
})
async function getData() {
if (!socketUrl.value) {
const { ip, port } = await getffmpegip()
socketUrl.value = `${ip}:${port}`
}
await validate()
const params = getFieldsValue()
const { meta, data } = await getDevices({
...params,
status: 1,
type: 1,
per_page: paginationParams.pageSize,
page: paginationParams.pageCurrent,
})
paginationParams.pageTotal = meta.total
list.value = data.reduce((acc, cur) => {
const { username, password, ip, passage } = cur.extends
cur.extends.rtsp_url = `rtsp://${username}:${password}@${ip}:9200/cam/playback?channel=${passage}&subtype=0&starttime=${dayjs(
params.start_time,
).format('YYYY_MM_DD_HH_mm_ss')}&endtime=${dayjs(params.start_time).format(
'YYYY_MM_DD_HH_mm_ss',
)}`
console.log(cur.extends.rtsp_url)
acc.push(cur)
return acc
}, [])
}
onMounted(() => {
// getData()
})
return {
list,
socketUrl,
getData,
registerForm,
...toRefs(paginationParams),
}
}, },
}); })
</script> </script>
<style scoped></style> <style scoped></style>