fix: bug#10609-1
This commit is contained in:
parent
e9d5c8e9c3
commit
b4734056d8
|
@ -0,0 +1,26 @@
|
||||||
|
|
||||||
|
import { defineStore } from "pinia";
|
||||||
|
|
||||||
|
type DepartmentStateType = {
|
||||||
|
productId: string;
|
||||||
|
optType: string | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useDepartmentStore = defineStore({
|
||||||
|
id: 'department',
|
||||||
|
state: (): DepartmentStateType => ({
|
||||||
|
productId: '',
|
||||||
|
// 设备资产分配弹窗操作类型:
|
||||||
|
// 1. optType === 'handle': 手动点击资产分配按钮;
|
||||||
|
// 2. optType === ': 产品资产分配后, 自动弹出设备资产分配
|
||||||
|
optType: ''
|
||||||
|
}),
|
||||||
|
actions: {
|
||||||
|
setProductId(value: string) {
|
||||||
|
this.productId = value
|
||||||
|
},
|
||||||
|
setType(value: string | undefined) {
|
||||||
|
this.optType = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
|
@ -143,6 +143,9 @@ import {
|
||||||
} from '@/api/system/department';
|
} from '@/api/system/department';
|
||||||
import { message } from 'jetlinks-ui-components';
|
import { message } from 'jetlinks-ui-components';
|
||||||
import { dictType } from '../typing';
|
import { dictType } from '../typing';
|
||||||
|
import { useDepartmentStore } from '@/store/department';
|
||||||
|
|
||||||
|
const departmentStore = useDepartmentStore();
|
||||||
|
|
||||||
const emits = defineEmits(['confirm', 'update:visible']);
|
const emits = defineEmits(['confirm', 'update:visible']);
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
|
@ -154,6 +157,9 @@ const props = defineProps<{
|
||||||
}>();
|
}>();
|
||||||
// 弹窗相关
|
// 弹窗相关
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
// 资产咨询次数, 产品分配后自动进入的设备资产, 第一次需要带上产品id查询
|
||||||
|
const queryCount = ref(0);
|
||||||
|
|
||||||
const confirm = () => {
|
const confirm = () => {
|
||||||
if (table.selectedRows.length < 1) {
|
if (table.selectedRows.length < 1) {
|
||||||
return message.warning('请先勾选数据');
|
return message.warning('请先勾选数据');
|
||||||
|
@ -167,6 +173,11 @@ const confirm = () => {
|
||||||
permission: item.selectPermissions,
|
permission: item.selectPermissions,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
if (params.length === 1) {
|
||||||
|
// 只选择一个产品资产分配时, 分配之后, 进入设备资产分配需查出对应产品下的设备
|
||||||
|
departmentStore.setProductId(params[0].assetIdList[0]);
|
||||||
|
}
|
||||||
|
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
bindDeviceOrProductList_api(props.assetType, params)
|
bindDeviceOrProductList_api(props.assetType, params)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -398,6 +409,7 @@ const table: any = {
|
||||||
}),
|
}),
|
||||||
// 整理参数并获取数据
|
// 整理参数并获取数据
|
||||||
requestFun: async (oParams: any) => {
|
requestFun: async (oParams: any) => {
|
||||||
|
queryCount.value += 1;
|
||||||
if (props.parentId) {
|
if (props.parentId) {
|
||||||
const terms = [
|
const terms = [
|
||||||
{
|
{
|
||||||
|
@ -415,9 +427,24 @@ const table: any = {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
column: 'productId$product-info',
|
||||||
|
type: 'and',
|
||||||
|
value: `id is ${departmentStore.productId}`,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (
|
||||||
|
props.assetType !== 'device' ||
|
||||||
|
!departmentStore.productId ||
|
||||||
|
queryCount.value > 1 ||
|
||||||
|
departmentStore.optType === 'handle'
|
||||||
|
) {
|
||||||
|
// 非设备|产品id不存在|有其他查询操作(queryCount+1)|设备页面手动点击资产分配, 均删除产品带入的id
|
||||||
|
terms[0].terms.pop();
|
||||||
|
}
|
||||||
if (oParams.terms && oParams.terms.length > 0)
|
if (oParams.terms && oParams.terms.length > 0)
|
||||||
terms.unshift({ terms: oParams.terms });
|
terms.unshift({ terms: oParams.terms });
|
||||||
const params = {
|
const params = {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<PermissionButton
|
<PermissionButton
|
||||||
:hasPermission="`${permission}:assert`"
|
:hasPermission="`${permission}:assert`"
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="table.clickAdd"
|
@click="table.clickAdd('handle')"
|
||||||
>
|
>
|
||||||
<AIcon type="PlusOutlined" />资产分配
|
<AIcon type="PlusOutlined" />资产分配
|
||||||
</PermissionButton>
|
</PermissionButton>
|
||||||
|
@ -211,6 +211,9 @@ import { intersection } from 'lodash-es';
|
||||||
|
|
||||||
import type { dictType, optionsType } from '../typing';
|
import type { dictType, optionsType } from '../typing';
|
||||||
import { message } from 'jetlinks-ui-components';
|
import { message } from 'jetlinks-ui-components';
|
||||||
|
import { useDepartmentStore } from '@/store/department';
|
||||||
|
|
||||||
|
const departmentStore = useDepartmentStore();
|
||||||
|
|
||||||
const permission = 'system/Department';
|
const permission = 'system/Department';
|
||||||
|
|
||||||
|
@ -248,7 +251,7 @@ const columns = [
|
||||||
rename: 'productId$product-info',
|
rename: 'productId$product-info',
|
||||||
type: 'select',
|
type: 'select',
|
||||||
handleValue(value: string) {
|
handleValue(value: string) {
|
||||||
return `id is ${value}`
|
return `id is ${value}`;
|
||||||
},
|
},
|
||||||
options: () =>
|
options: () =>
|
||||||
new Promise((resolve) => {
|
new Promise((resolve) => {
|
||||||
|
@ -291,9 +294,9 @@ const columns = [
|
||||||
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' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
scopedSlots: true,
|
scopedSlots: true,
|
||||||
|
@ -465,7 +468,9 @@ const table = {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
clickAdd: () => {
|
clickAdd: (type?: string) => {
|
||||||
|
// 设备资产分配弹窗操作类型: type = 'handle': 手动点击资产分配按钮, !type产品资产分配后, 自动弹出设备资产分配
|
||||||
|
departmentStore.setType(type)
|
||||||
dialogs.addShow = true;
|
dialogs.addShow = true;
|
||||||
},
|
},
|
||||||
clickEdit: (row?: any) => {
|
clickEdit: (row?: any) => {
|
||||||
|
|
Loading…
Reference in New Issue