fix: bug#10839

This commit is contained in:
xieyonghong 2023-03-27 19:44:05 +08:00
parent fb1478a181
commit de51d8a0eb
1 changed files with 237 additions and 235 deletions

View File

@ -1,38 +1,38 @@
<template>
<pro-search
:columns="columns"
type="simple"
@search="handleSearch"
class="scene-search"
target="scene-trigger-device-product"
:columns='columns'
type='simple'
@search='handleSearch'
class='scene-search'
target='scene-trigger-device-product'
/>
<j-divider style="margin: 0" />
<j-divider style='margin: 0' />
<j-pro-table
ref="actionRef"
model="CARD"
:columns="columns"
:params="params"
:request="productQuery"
:gridColumn="2"
:bodyStyle="{
ref='actionRef'
model='CARD'
:columns='columns'
:params='params'
:request='productQuery'
:gridColumn='2'
:bodyStyle='{
paddingRight: 0,
paddingLeft: 0,
}"
}'
>
<template #card="slotProps">
<template #card='slotProps'>
<CardBox
:value="slotProps"
:active="rowKey === slotProps.id"
:status="String(slotProps.state)"
:value='slotProps'
:active='rowKey === slotProps.id'
:status='String(slotProps.state)'
:statusText="slotProps.state === 1 ? '正常' : '禁用'"
:statusNames="{ '1': 'processing', '0': 'error' }"
@click="handleClick(slotProps)"
@click='handleClick(slotProps)'
>
<template #img>
<slot name="img">
<slot name='img'>
<img
:width="88"
:height="88"
:width='88'
:height='88'
:src="
slotProps.photoUrl ||
getImage('/device-product.png')
@ -41,20 +41,20 @@
</slot>
</template>
<template #content>
<div style="width: calc(100% - 100px)">
<div style='width: calc(100% - 100px)'>
<Ellipsis>
<span style="font-size: 16px; font-weight: 600">
<span style='font-size: 16px; font-weight: 600'>
{{ slotProps.name }}
</span>
</Ellipsis>
</div>
<j-row>
<j-col :span="12">
<div class="card-item-content-text">设备类型</div>
<j-col :span='12'>
<div class='card-item-content-text'>设备类型</div>
<Ellipsis>{{ slotProps.deviceType?.text }}</Ellipsis>
</j-col>
<j-col :span="12">
<div class="card-item-content-text">接入方式</div>
<j-col :span='12'>
<div class='card-item-content-text'>接入方式</div>
<Ellipsis>{{ slotProps?.accessName || '未接入' }}</Ellipsis>
</j-col>
</j-row>
@ -68,12 +68,12 @@
import {
getProviders,
queryGatewayList,
queryProductList,
} from '@/api/device/product';
import { queryTree } from '@/api/device/category';
import { getTreeData_api } from '@/api/system/department';
import { isNoCommunity } from '@/utils/utils';
import { getImage } from '@/utils/comm';
queryProductList
} from '@/api/device/product'
import { queryTree } from '@/api/device/category'
import { getTreeData_api } from '@/api/system/department'
import { isNoCommunity } from '@/utils/utils'
import { getImage } from '@/utils/comm'
import { accessConfigTypeFilter } from '@/utils/setting'
type Emit = {
@ -82,20 +82,20 @@ type Emit = {
(e: 'change', data: string): void;
};
const actionRef = ref();
const params = ref({});
const actionRef = ref()
const params = ref({})
const props = defineProps({
rowKey: {
type: String,
default: '',
default: ''
},
detail: {
type: Object,
default: () => ({}),
},
});
default: () => ({})
}
})
const emit = defineEmits<Emit>();
const emit = defineEmits<Emit>()
const columns = [
{
@ -105,8 +105,8 @@ const columns = [
ellipsis: true,
fixed: 'left',
search: {
type: 'string',
},
type: 'string'
}
},
{
title: '名称',
@ -115,8 +115,8 @@ const columns = [
ellipsis: true,
search: {
type: 'string',
first: true,
},
first: true
}
},
{
title: '网关类型',
@ -130,8 +130,8 @@ const columns = [
getProviders().then((resp: any) => {
const data = resp.result || []
return accessConfigTypeFilter(data)
}),
},
})
}
},
{
title: '接入方式',
@ -144,10 +144,10 @@ const columns = [
queryGatewayList().then((resp: any) =>
resp.result.map((item: any) => ({
label: item.name,
value: item.id,
})),
),
},
value: item.id
}))
)
}
},
{
title: '设备类型',
@ -158,9 +158,9 @@ const columns = [
options: [
{ label: '直连设备', value: 'device' },
{ label: '网关子设备', value: 'childrenDevice' },
{ label: '网关设备', value: 'gateway' },
],
},
{ label: '网关设备', value: 'gateway' }
]
}
},
{
title: '状态',
@ -170,15 +170,15 @@ const columns = [
type: 'select',
options: [
{ label: '禁用', value: 0 },
{ label: '正常', value: 1 },
],
},
{ label: '正常', value: 1 }
]
}
},
{
title: '说明',
dataIndex: 'describe',
ellipsis: true,
width: 300,
width: 300
},
{
dataIndex: 'classifiedId',
@ -196,10 +196,10 @@ const columns = [
componentProps: {
fieldNames: {
label: 'name',
value: 'id',
},
},
},
value: 'id'
}
}
}
},
{
dataIndex: 'id$dim-assets',
@ -207,11 +207,12 @@ const columns = [
hideInTable: true,
search: {
type: 'treeSelect',
options: getTreeData_api({ paging: false }).then((resp: any) => {
options: () => new Promise((resolve) => {
getTreeData_api({ paging: false }).then((resp: any) => {
const formatValue = (list: any[]) => {
return list.map((item: any) => {
if (item.children) {
item.children = formatValue(item.children);
item.children = formatValue(item.children)
}
return {
...item,
@ -220,42 +221,43 @@ const columns = [
targets: [
{
type: 'org',
id: item.id,
},
],
}),
};
});
};
return formatValue(resp.result);
}),
},
},
];
id: item.id
}
]
})
}
})
}
resolve(formatValue(resp.result) || [])
})
})
}
}
]
const handleSearch = (p: any) => {
params.value = p;
};
params.value = p
}
const productQuery = (p: any) => {
const sorts: any = [];
const sorts: any = []
if (props.rowKey) {
sorts.push({
name: 'id',
value: props.rowKey,
});
value: props.rowKey
})
}
sorts.push({ name: 'createTime', order: 'desc' })
p.sorts = sorts
return queryProductList(p)
}
sorts.push({ name: 'createTime', order: 'desc' });
p.sorts = sorts;
return queryProductList(p);
};
const handleClick = (detail: any) => {
emit('update:rowKey', detail.id);
emit('update:detail', detail);
emit('change', detail);
};
emit('update:rowKey', detail.id)
emit('update:detail', detail)
emit('change', detail)
}
</script>
<style scoped lang='less'>