fix: bug#11013

This commit is contained in:
xieyonghong 2023-03-28 13:34:16 +08:00
parent 0ea4214ee3
commit f11f5e1729
2 changed files with 125 additions and 111 deletions

View File

@ -1,132 +1,146 @@
<!-- 绑定设备 --> <!-- 绑定设备 -->
<template> <template>
<j-modal :maskClosable="false" width="1100px" :visible="true" title="选择设备" okText="确定" cancelText="取消" @ok="handleOk" <j-modal :maskClosable='false' width='1100px' :visible='true' title='选择设备' okText='确定' cancelText='取消' @ok='handleOk'
@cancel="handleCancel" :confirmLoading="btnLoading"> @cancel='handleCancel' :confirmLoading='btnLoading'>
<div style="margin-top: 10px"> <div style='margin-top: 10px'>
<pro-search :columns="columns" target="iot-card-bind-device" @search="handleSearch" type="simple" /> <pro-search :columns='columns' target='iot-card-bind-device' @search='handleSearch' type='simple' />
<j-pro-table ref="bindDeviceRef" :columns="columns" :request="queryUnbounded" model="TABLE" :defaultParams="{ <j-pro-table
sorts: [{ name: 'createTime', order: 'desc' }], ref='bindDeviceRef'
}" :rowSelection="{ :columns='columns'
type: 'radio', :request='queryUnbounded'
selectedRowKeys: _selectedRowKeys, model='TABLE'
onSelect: onSelectChange, :defaultParams="{
}" @cancelSelect="cancelSelect" :params="params"> pageSize: 10,
<template #registryTime="slotProps"> sorts: [{ name: 'createTime', order: 'desc' }],
{{ }"
slotProps.registryTime :pagination="{
? moment(slotProps.registryTime).format( showSizeChanger: true,
'YYYY-MM-DD HH:mm:ss', pageSizeOptions: ['10', '20', '50', '100'],
) }"
: '' :rowSelection="{
}} type: 'radio',
</template> selectedRowKeys: _selectedRowKeys,
<template #state="slotProps"> onSelect: onSelectChange,
<j-badge :text="slotProps.state.text" :status="statusMap.get(slotProps.state.value)" /> }"
</template> @cancelSelect='cancelSelect'
</j-pro-table> :params='params'
</div> >
</j-modal> <template #registryTime='slotProps'>
{{
slotProps.registryTime
? moment(slotProps.registryTime).format(
'YYYY-MM-DD HH:mm:ss'
)
: ''
}}
</template>
<template #state='slotProps'>
<j-badge :text='slotProps.state.text' :status='statusMap.get(slotProps.state.value)' />
</template>
</j-pro-table>
</div>
</j-modal>
</template> </template>
<script setup lang="ts"> <script setup lang='ts'>
import { queryUnbounded, bind } from '@/api/iot-card/cardManagement'; import { queryUnbounded, bind } from '@/api/iot-card/cardManagement'
import moment from 'moment'; import moment from 'moment'
import { message } from 'jetlinks-ui-components'; import { message } from 'jetlinks-ui-components'
const emit = defineEmits(['change']); const emit = defineEmits(['change'])
const props = defineProps({ const props = defineProps({
cardId: { cardId: {
type: String, type: String
}, }
}); })
const bindDeviceRef = ref<Record<string, any>>({}); const bindDeviceRef = ref<Record<string, any>>({})
const params = ref<Record<string, any>>({}); const params = ref<Record<string, any>>({})
const _selectedRowKeys = ref<string[]>([]); const _selectedRowKeys = ref<string[]>([])
const btnLoading = ref<boolean>(false); const btnLoading = ref<boolean>(false)
const statusMap = new Map(); const statusMap = new Map()
statusMap.set('online', 'processing'); statusMap.set('online', 'processing')
statusMap.set('offline', 'error'); statusMap.set('offline', 'error')
statusMap.set('notActive', 'warning'); statusMap.set('notActive', 'warning')
const columns = [ const columns = [
{ {
title: 'ID', title: 'ID',
dataIndex: 'id', dataIndex: 'id',
key: 'id', key: 'id',
ellipsis: true, ellipsis: true,
fixed: 'left', fixed: 'left',
search: { search: {
type: 'string', type: 'string'
}, }
}, },
{ {
title: '设备名称', title: '设备名称',
dataIndex: 'name', dataIndex: 'name',
key: 'name', key: 'name',
ellipsis: true, ellipsis: true,
search: { search: {
type: 'string', type: 'string'
}, }
}, },
{ {
title: '注册时间', title: '注册时间',
dataIndex: 'registryTime', dataIndex: 'registryTime',
key: 'registryTime', key: 'registryTime',
scopedSlots: true, scopedSlots: true,
search: { search: {
type: 'date', type: 'date'
}, }
// sorter: true, // sorter: true,
}, },
{ {
title: '状态', title: '状态',
dataIndex: 'state', dataIndex: 'state',
key: 'state', key: 'state',
scopedSlots: true, scopedSlots: true,
search: { search: {
type: 'select', type: 'select',
options: [ options: [
{ label: '禁用', value: 'notActive' }, { label: '禁用', value: 'notActive' },
{ label: '离线', value: 'offline' }, { label: '离线', value: 'offline' },
{ label: '在线', value: 'online' }, { label: '在线', value: 'online' }
], ]
}, }
// filterMultiple: false, // filterMultiple: false,
}, }
]; ]
const handleSearch = (e: any) => { const handleSearch = (e: any) => {
params.value = e; params.value = e
}; }
const onSelectChange = (record: any) => { const onSelectChange = (record: any) => {
_selectedRowKeys.value = [record.id]; _selectedRowKeys.value = [record.id]
}; }
const cancelSelect = () => { const cancelSelect = () => {
_selectedRowKeys.value = []; _selectedRowKeys.value = []
}; }
const handleOk = () => { const handleOk = () => {
btnLoading.value = true; btnLoading.value = true
bind(props.cardId, _selectedRowKeys.value[0]) bind(props.cardId, _selectedRowKeys.value[0])
.then((resp: any) => { .then((resp: any) => {
if (resp.status === 200) { if (resp.status === 200) {
message.success('操作成功') message.success('操作成功')
emit('change', true); emit('change', true)
} }
}) })
.finally(() => { .finally(() => {
btnLoading.value = false; btnLoading.value = false
}); })
}; }
const handleCancel = () => { const handleCancel = () => {
emit('change', false); emit('change', false)
}; }
</script> </script>
<style scoped lang="less"></style> <style scoped lang='less'></style>

View File

@ -3700,8 +3700,8 @@ jetlinks-store@^0.0.3:
jetlinks-ui-components@^1.0.5: jetlinks-ui-components@^1.0.5:
version "1.0.5" version "1.0.5"
resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#531a7cd5cc4069dc299f0efcc92411a4eee369e7" resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#031a300df4df31a353d738cacee8b4ff630ae2d0"
integrity sha512-7VHsz5lVG9PlFkHoJvEown4QARuVuasR+jDa9NNQ+pJSHAtHAeiIO1bpVTQKfE5WCyhCKPnN8yIerJLLzmQ1fA== integrity sha512-SfucQ7LzlE13VdyZsDhrhzwF9Le/NOke5F6UY3bNN1OJiRD/bZMJecGQxWBQGv567lKcV60SOPCMT8ExiZxUgw==
dependencies: dependencies:
"@vueuse/core" "^9.12.0" "@vueuse/core" "^9.12.0"
ant-design-vue "^3.2.15" ant-design-vue "^3.2.15"