|
|
@@ -4,11 +4,60 @@
|
|
|
呈现通过网关方式接入到IoT的设备(传感器)。子设备的状态表示子设备接入网关的状态,由网关上报到IoT平台进行状态的刷新;如果网关不能正常上报子设备的状态信息到IoT平台,则展示的子设备状态不会刷新。
|
|
|
</div>
|
|
|
<a-row justify="space-between" style="margin: 20px 0;" >
|
|
|
- <a-col></a-col>
|
|
|
+ <a-col>
|
|
|
+ <a-space>
|
|
|
+ <a-select style="width: 170px;" v-model:value="state.queryParams.deviceStatus" >
|
|
|
+ <a-select-option
|
|
|
+ v-for="item in deviceStatusList"
|
|
|
+ :key="item.key"
|
|
|
+ :value="item.key"
|
|
|
+ >{{item.name}}</a-select-option>
|
|
|
+ </a-select>
|
|
|
+
|
|
|
+ <a-select style="width: 120px;" v-model:value="state.queryParams.searchKey" >
|
|
|
+ <a-select-option
|
|
|
+ v-for="item in DeviceContriller.searchKeyList"
|
|
|
+ :key="item.key"
|
|
|
+ :value="item.key"
|
|
|
+ >{{item.name}}</a-select-option>
|
|
|
+ </a-select>
|
|
|
+
|
|
|
+ <a-input-search
|
|
|
+ v-model:value="state.queryParams.searchValue"
|
|
|
+ enter-button
|
|
|
+ @search="getSubDevicePage"
|
|
|
+ />
|
|
|
+ </a-space>
|
|
|
+ </a-col>
|
|
|
<a-col>
|
|
|
<a-button type="primary" @click="state.visible = true">添加子设备</a-button>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
+
|
|
|
+ <a-table
|
|
|
+ :columns="columns"
|
|
|
+ :dataSource="state.dataSource"
|
|
|
+ :pagination="state.queryParams"
|
|
|
+ >
|
|
|
+ <template #bodyCell="{ column, record }">
|
|
|
+ <template v-if="column.key === 'deviceStatus'">
|
|
|
+ <a-tag :color="DeviceContriller.deviceStatusMap.get(record.deviceStatus)?.color" >{{ DeviceContriller.deviceStatusMap.get(record.deviceStatus)?.name }}</a-tag>
|
|
|
+ </template>
|
|
|
+ <template v-if="column.key === 'action'">
|
|
|
+ <a-space>
|
|
|
+ <a>详情</a>
|
|
|
+ <a-popconfirm
|
|
|
+ title="确实要删除吗?"
|
|
|
+ ok-text="确定"
|
|
|
+ cancel-text="取消"
|
|
|
+ @confirm="delSubDevice(record.id)"
|
|
|
+ >
|
|
|
+ <a>删除</a>
|
|
|
+ </a-popconfirm>
|
|
|
+ </a-space>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </a-table>
|
|
|
</a-card>
|
|
|
|
|
|
<modal-pro
|
|
|
@@ -21,12 +70,12 @@
|
|
|
<form-proo
|
|
|
ref="formPro"
|
|
|
validate
|
|
|
- :columnsProps="colums"
|
|
|
+ :columnsProps="columns"
|
|
|
/>
|
|
|
</modal-pro>
|
|
|
</template>
|
|
|
<script lang='ts' setup >
|
|
|
-import { DeviceContriller } from '@/controller'
|
|
|
+import { DeviceContriller, ModelCmdController, ModelController } from '@/controller'
|
|
|
import { onMounted, reactive, ref } from 'vue'
|
|
|
import { useRoute } from 'vue-router'
|
|
|
import { Form } from 'ant-design-vue'
|
|
|
@@ -40,46 +89,80 @@ const formPro = ref('')
|
|
|
|
|
|
const deviceId = route.query.id as string
|
|
|
|
|
|
-const colums: ColumnsProps[] = [
|
|
|
+const columns: ColumnsProps[] = [
|
|
|
+ {
|
|
|
+ title: '所属产品',
|
|
|
+ dataIndex: 'modelLabel',
|
|
|
+ formProps: {
|
|
|
+ rules: true,
|
|
|
+ type: 'select',
|
|
|
+ value: '',
|
|
|
+ label: '所属产品',
|
|
|
+ key: 'modelId',
|
|
|
+ request: async () => {
|
|
|
+ const { data } = await ModelController.list()
|
|
|
+ return data.map(item => {
|
|
|
+ return {
|
|
|
+ name: item.modelLabel,
|
|
|
+ value: item.id,
|
|
|
+ key: item.id
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
{
|
|
|
title: '状态',
|
|
|
- dataIndex: 'deviceStatus'
|
|
|
+ dataIndex: 'deviceStatus',
|
|
|
+ key: 'deviceStatus'
|
|
|
},
|
|
|
{
|
|
|
title: '设备名称',
|
|
|
- dataIndex: 'deviceLabel'
|
|
|
+ dataIndex: 'deviceLabel',
|
|
|
+ formProps: {
|
|
|
+ rules: false,
|
|
|
+ type: 'input',
|
|
|
+ value: '',
|
|
|
+ label: '设备名称',
|
|
|
+ key: 'deviceLabel'
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
title: '设备标识码',
|
|
|
- dataIndex: 'deviceLabel',
|
|
|
+ dataIndex: 'deviceCode',
|
|
|
formProps: {
|
|
|
rules: true,
|
|
|
type: 'input',
|
|
|
value: null,
|
|
|
label: '设备标识码',
|
|
|
- key: 'deviceLabel'
|
|
|
+ key: 'deviceCode'
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
- title: '设备名称',
|
|
|
- dataIndex: 'deviceLabel'
|
|
|
+ title: '设备ID',
|
|
|
+ dataIndex: 'deviceId'
|
|
|
},
|
|
|
{
|
|
|
- title: '设备名称',
|
|
|
- dataIndex: 'deviceLabel'
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: 'action',
|
|
|
+ key: 'action'
|
|
|
}
|
|
|
]
|
|
|
|
|
|
+const deviceStatusList = [...DeviceContriller.deviceStatus, { name: '所有状态', key: '' }]
|
|
|
+
|
|
|
const state = reactive({
|
|
|
loading: false,
|
|
|
visible: false,
|
|
|
dataSource: [],
|
|
|
queryParams: {
|
|
|
+ // id: deviceId,
|
|
|
page: 1,
|
|
|
pageSize: 10,
|
|
|
total: 0,
|
|
|
deviceStatus: '',
|
|
|
- searchValue: ''
|
|
|
+ searchValue: '',
|
|
|
+ searchKey: 'deviceId'
|
|
|
}
|
|
|
})
|
|
|
|
|
|
@@ -90,20 +173,16 @@ const subDeviceState = reactive({
|
|
|
deviceCode: ''
|
|
|
})
|
|
|
|
|
|
-const { resetFields, validate, validateInfos } = useForm(subDeviceState, reactive({
|
|
|
- gatewayId: [{ required: true, message: '请选择网关' }],
|
|
|
- deviceCode: [{ required: true, message: '请填写设备标识码' }],
|
|
|
- modelId: [{ required: true, message: '请选择所属产品' }]
|
|
|
-}))
|
|
|
-
|
|
|
-const ok = () => {
|
|
|
- formPro.value.onSubmit()
|
|
|
- // validate().then(async () => {
|
|
|
- // await DeviceContriller.postSub(subDeviceState)
|
|
|
- // getSubDevicePage()
|
|
|
- // })
|
|
|
+const ok = async () => {
|
|
|
+ const submitState = await formPro.value.onSubmit()
|
|
|
+ console.log('submitState:', submitState)
|
|
|
+ DeviceContriller.postSub({ ...submitState, gatewayId: deviceId })
|
|
|
+ state.visible = false
|
|
|
}
|
|
|
|
|
|
+const delSubDevice = async (id: string) => {
|
|
|
+ // const {} = await DeviceContriller
|
|
|
+}
|
|
|
const getSubDevicePage = async () => {
|
|
|
state.loading = true
|
|
|
const { data, sum } = await DeviceContriller.pageSub(deviceId, state.queryParams)
|