fix: bug#10609-1

This commit is contained in:
JiangQiming 2023-03-23 15:36:31 +08:00
parent e9d5c8e9c3
commit b4734056d8
3 changed files with 64 additions and 6 deletions

26
src/store/department.ts Normal file
View File

@ -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
}
}
})

View File

@ -143,6 +143,9 @@ import {
} from '@/api/system/department';
import { message } from 'jetlinks-ui-components';
import { dictType } from '../typing';
import { useDepartmentStore } from '@/store/department';
const departmentStore = useDepartmentStore();
const emits = defineEmits(['confirm', 'update:visible']);
const props = defineProps<{
@ -154,6 +157,9 @@ const props = defineProps<{
}>();
//
const loading = ref(false);
// , , id
const queryCount = ref(0);
const confirm = () => {
if (table.selectedRows.length < 1) {
return message.warning('请先勾选数据');
@ -167,6 +173,11 @@ const confirm = () => {
permission: item.selectPermissions,
}));
if (params.length === 1) {
// , ,
departmentStore.setProductId(params[0].assetIdList[0]);
}
loading.value = true;
bindDeviceOrProductList_api(props.assetType, params)
.then(() => {
@ -398,6 +409,7 @@ const table: any = {
}),
//
requestFun: async (oParams: any) => {
queryCount.value += 1;
if (props.parentId) {
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)
terms.unshift({ terms: oParams.terms });
const params = {

View File

@ -22,7 +22,7 @@
<PermissionButton
:hasPermission="`${permission}:assert`"
type="primary"
@click="table.clickAdd"
@click="table.clickAdd('handle')"
>
<AIcon type="PlusOutlined" />资产分配
</PermissionButton>
@ -211,6 +211,9 @@ import { intersection } from 'lodash-es';
import type { dictType, optionsType } from '../typing';
import { message } from 'jetlinks-ui-components';
import { useDepartmentStore } from '@/store/department';
const departmentStore = useDepartmentStore();
const permission = 'system/Department';
@ -248,7 +251,7 @@ const columns = [
rename: 'productId$product-info',
type: 'select',
handleValue(value: string) {
return `id is ${value}`
return `id is ${value}`;
},
options: () =>
new Promise((resolve) => {
@ -291,9 +294,9 @@ const columns = [
search: {
type: 'select',
options: [
{ label: '禁用', value: 'notActive' },
{ label: '离线', value: 'offline' },
{ label: '在线', value: 'online' },
{ label: '禁用', value: 'notActive' },
{ label: '离线', value: 'offline' },
{ label: '在线', value: 'online' },
],
},
scopedSlots: true,
@ -465,7 +468,9 @@ const table = {
};
}
},
clickAdd: () => {
clickAdd: (type?: string) => {
// : type = 'handle': , !type,
departmentStore.setType(type)
dialogs.addShow = true;
},
clickEdit: (row?: any) => {