|
@@ -2,7 +2,7 @@
|
|
|
import type { ActionType, ProColumns } from '@jetlinks/pro-table';
|
|
import type { ActionType, ProColumns } from '@jetlinks/pro-table';
|
|
|
import ProTable from '@jetlinks/pro-table';
|
|
import ProTable from '@jetlinks/pro-table';
|
|
|
import { useIntl } from '@@/plugin-locale/localeExports';
|
|
import { useIntl } from '@@/plugin-locale/localeExports';
|
|
|
-import { Button, message, Popconfirm, Tooltip } from 'antd';
|
|
|
|
|
|
|
+import { Button, message, Popconfirm, Space, Tooltip } from 'antd';
|
|
|
import { useRef, useState } from 'react';
|
|
import { useRef, useState } from 'react';
|
|
|
import { useParams } from 'umi';
|
|
import { useParams } from 'umi';
|
|
|
import { observer } from '@formily/react';
|
|
import { observer } from '@formily/react';
|
|
@@ -39,23 +39,27 @@ export default observer(() => {
|
|
|
* 解除资产绑定
|
|
* 解除资产绑定
|
|
|
*/
|
|
*/
|
|
|
const handleUnBind = () => {
|
|
const handleUnBind = () => {
|
|
|
- service
|
|
|
|
|
- .unBind('deviceCategory', [
|
|
|
|
|
- {
|
|
|
|
|
- targetType: 'org',
|
|
|
|
|
- targetId: param.id,
|
|
|
|
|
- assetType: 'deviceCategory',
|
|
|
|
|
- assetIdList: Models.unBindKeys,
|
|
|
|
|
- },
|
|
|
|
|
- ])
|
|
|
|
|
- .subscribe({
|
|
|
|
|
- next: () => message.success('操作成功'),
|
|
|
|
|
- error: () => message.error('操作失败'),
|
|
|
|
|
- complete: () => {
|
|
|
|
|
- Models.unBindKeys = [];
|
|
|
|
|
- actionRef.current?.reload();
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ if (Models.unBindKeys.length) {
|
|
|
|
|
+ service
|
|
|
|
|
+ .unBind('deviceCategory', [
|
|
|
|
|
+ {
|
|
|
|
|
+ targetType: 'org',
|
|
|
|
|
+ targetId: param.id,
|
|
|
|
|
+ assetType: 'deviceCategory',
|
|
|
|
|
+ assetIdList: Models.unBindKeys,
|
|
|
|
|
+ },
|
|
|
|
|
+ ])
|
|
|
|
|
+ .subscribe({
|
|
|
|
|
+ next: () => message.success('操作成功'),
|
|
|
|
|
+ error: () => message.error('操作失败'),
|
|
|
|
|
+ complete: () => {
|
|
|
|
|
+ Models.unBindKeys = [];
|
|
|
|
|
+ actionRef.current?.reload();
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ message.warning('请勾选需要解绑的数据');
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const singleUnBind = (key: string) => {
|
|
const singleUnBind = (key: string) => {
|
|
@@ -196,13 +200,39 @@ export default observer(() => {
|
|
|
selectedRowKeys: Models.unBindKeys,
|
|
selectedRowKeys: Models.unBindKeys,
|
|
|
onSelect: (record, selected, selectedRows) => {
|
|
onSelect: (record, selected, selectedRows) => {
|
|
|
const keys = getTableKeys(selected ? selectedRows : [record]);
|
|
const keys = getTableKeys(selected ? selectedRows : [record]);
|
|
|
|
|
+ console.log(record, selected, selectedRows);
|
|
|
if (selected) {
|
|
if (selected) {
|
|
|
- Models.unBindKeys = keys;
|
|
|
|
|
|
|
+ const _map = new Map();
|
|
|
|
|
+ keys.forEach((k) => {
|
|
|
|
|
+ _map.set(k, k);
|
|
|
|
|
+ });
|
|
|
|
|
+ Models.unBindKeys = [..._map.values()];
|
|
|
} else {
|
|
} else {
|
|
|
// 去除重复的key
|
|
// 去除重复的key
|
|
|
Models.unBindKeys = difference(Models.unBindKeys, keys);
|
|
Models.unBindKeys = difference(Models.unBindKeys, keys);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ onSelectAll: (selected, selectedRows) => {
|
|
|
|
|
+ if (selected) {
|
|
|
|
|
+ Models.unBindKeys = selectedRows.map((item) => item.id);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Models.unBindKeys = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ }}
|
|
|
|
|
+ tableAlertOptionRender={() => {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Space size={16}>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ type={'link'}
|
|
|
|
|
+ onClick={() => {
|
|
|
|
|
+ Models.unBindKeys = [];
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ 取消选择
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </Space>
|
|
|
|
|
+ );
|
|
|
}}
|
|
}}
|
|
|
toolBarRender={() => [
|
|
toolBarRender={() => [
|
|
|
<Button
|
|
<Button
|