Browse Source

feat: 产品详情跳转订阅列表时传递产品ID,做默认筛选值

main
刘凯 1 year ago
parent
commit
ab28acf824
  1. 2
      src/views/product/components/Subscription.vue
  2. 35
      src/views/subscription/list/data.ts
  3. 4
      src/views/subscription/list/index.vue

2
src/views/product/components/Subscription.vue

@ -47,7 +47,7 @@ const schema: DescItem[] = [
type="info" show-icon class="py-4px"
message="服务端订阅:服务端可以直接订阅产品下多种类型的消息,例如设备上报属性、设备上报消息、设备状态变化通知、设备生命周期变更等。配置服务端订阅后配合使用【消费组】,平台会将产品下所有设备中已订阅类型的消息进行转发。"
/>
<a-button type="link" size="small" my="12px" @click="$router.push('/subscription/list')">
<a-button type="link" size="small" my="12px" @click="$router.push({ name: 'SubscriptionList', state: { productId: data?.productId } })">
<LinkOutlined />
管理订阅
</a-button>

35
src/views/subscription/list/data.ts

@ -50,24 +50,27 @@ export const columns: BasicColumn[] = [
},
]
export const searchFormSchema: FormSchema[] = [
{
field: 'productId',
label: '产品名称',
component: 'ApiSelect',
componentProps: {
api: getCachedProducts,
showSearch: true,
fieldNames: {
label: 'productName',
value: 'id',
export function getSearchFormSchema(productId?: string): FormSchema[] {
return [
{
field: 'productId',
label: '产品名称',
component: 'ApiSelect',
componentProps: {
api: getCachedProducts,
showSearch: true,
fieldNames: {
label: 'productName',
value: 'id',
},
},
defaultValue: productId || undefined,
colProps: {
span: 6,
},
},
colProps: {
span: 6,
},
},
]
]
}
export function getFormSchema(isUpload: Ref<boolean>): FormSchema[] {
return [

4
src/views/subscription/list/index.vue

@ -1,6 +1,6 @@
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue'
import { columns, searchFormSchema } from './data'
import { columns, getSearchFormSchema } from './data'
import SubscriptionFormModal from './SubscriptionFormModal.vue'
import { BasicTable, TableAction, useTable } from '@/components/Table'
import { deleteSubscription, getSubscriptionList } from '@/api/subscription/list'
@ -17,7 +17,7 @@ const [register, { reload }] = useTable({
columns,
formConfig: {
labelWidth: 80,
schemas: searchFormSchema,
schemas: getSearchFormSchema(history.state.productId),
},
bordered: true,
canResize: false,

Loading…
Cancel
Save