|
|
@@ -1,6 +1,6 @@
|
|
|
-import {PageContainer} from '@ant-design/pro-layout';
|
|
|
-import {Badge, Button, message, Space, Tooltip, Upload} from 'antd';
|
|
|
-import type {ProductItem} from '@/pages/device/Product/typings';
|
|
|
+import { PageContainer } from '@ant-design/pro-layout';
|
|
|
+import { Badge, Button, message, Space, Tooltip, Upload } from 'antd';
|
|
|
+import type { ProductItem } from '@/pages/device/Product/typings';
|
|
|
import {
|
|
|
DeleteOutlined,
|
|
|
DownloadOutlined,
|
|
|
@@ -10,18 +10,18 @@ import {
|
|
|
StopOutlined,
|
|
|
} from '@ant-design/icons';
|
|
|
import Service from '@/pages/device/Product/service';
|
|
|
-import {observer} from '@formily/react';
|
|
|
-import {model} from '@formily/reactive';
|
|
|
-import {useHistory} from 'umi';
|
|
|
-import {useIntl} from '@@/plugin-locale/localeExports';
|
|
|
-import type {ActionType, ProColumns} from '@jetlinks/pro-table';
|
|
|
-import {useEffect, useRef, useState} from 'react';
|
|
|
+import { observer } from '@formily/react';
|
|
|
+import { model } from '@formily/reactive';
|
|
|
+import { useHistory } from 'umi';
|
|
|
+import { useIntl } from '@@/plugin-locale/localeExports';
|
|
|
+import type { ActionType, ProColumns } from '@jetlinks/pro-table';
|
|
|
+import { useEffect, useRef, useState } from 'react';
|
|
|
import Save from '@/pages/device/Product/Save';
|
|
|
import SearchComponent from '@/components/SearchComponent';
|
|
|
-import {getMenuPathByParams, MENUS_CODE} from '@/utils/menu';
|
|
|
-import {AIcon, PermissionButton, ProTableCard} from '@/components';
|
|
|
+import { getMenuPathByParams, MENUS_CODE } from '@/utils/menu';
|
|
|
+import { AIcon, PermissionButton, ProTableCard } from '@/components';
|
|
|
import ProductCard from '@/components/ProTableCard/CardItems/product';
|
|
|
-import {downloadObject} from '@/utils/util';
|
|
|
+import { downloadObject } from '@/utils/util';
|
|
|
|
|
|
export const service = new Service('device-product');
|
|
|
export const statusMap = {
|
|
|
@@ -151,19 +151,18 @@ const Product = observer(() => {
|
|
|
defaultMessage: '下载',
|
|
|
}),
|
|
|
}}
|
|
|
+ onClick={async () => {
|
|
|
+ downloadObject(
|
|
|
+ record,
|
|
|
+ intl.formatMessage({
|
|
|
+ id: 'pages.device.product',
|
|
|
+ defaultMessage: '产品',
|
|
|
+ }),
|
|
|
+ );
|
|
|
+ message.success('操作成功');
|
|
|
+ }}
|
|
|
>
|
|
|
- <DownloadOutlined
|
|
|
- onClick={async () => {
|
|
|
- downloadObject(
|
|
|
- record,
|
|
|
- intl.formatMessage({
|
|
|
- id: 'pages.device.product',
|
|
|
- defaultMessage: '产品',
|
|
|
- }),
|
|
|
- );
|
|
|
- message.success('操作成功');
|
|
|
- }}
|
|
|
- />
|
|
|
+ <DownloadOutlined />
|
|
|
</PermissionButton>,
|
|
|
<PermissionButton
|
|
|
popConfirm={{
|
|
|
@@ -199,12 +198,9 @@ const Product = observer(() => {
|
|
|
defaultMessage: '是否删除?',
|
|
|
}),
|
|
|
onConfirm: async () => {
|
|
|
- if (record.state === 0) {
|
|
|
- await deleteItem(record.id);
|
|
|
- } else {
|
|
|
- message.error('已发布的产品不能进行删除操作');
|
|
|
- }
|
|
|
+ await deleteItem(record.id);
|
|
|
},
|
|
|
+ disabled: record.state === 1,
|
|
|
}}
|
|
|
tooltip={{
|
|
|
title: intl.formatMessage({
|
|
|
@@ -295,7 +291,7 @@ const Product = observer(() => {
|
|
|
id: 'pages.system.description',
|
|
|
defaultMessage: '说明',
|
|
|
}),
|
|
|
- hideInSearch: true,
|
|
|
+ // hideInSearch: true,
|
|
|
},
|
|
|
{
|
|
|
title: intl.formatMessage({
|
|
|
@@ -380,13 +376,14 @@ const Product = observer(() => {
|
|
|
data.state = 0;
|
|
|
if (Array.isArray(data)) {
|
|
|
message.error('请上传json格式文件');
|
|
|
- return;
|
|
|
+ return false;
|
|
|
}
|
|
|
const res = await service.update(data);
|
|
|
if (res.status === 200) {
|
|
|
message.success('操作成功');
|
|
|
actionRef.current?.reload();
|
|
|
}
|
|
|
+ return true;
|
|
|
} catch {
|
|
|
message.error('请上传json格式文件');
|
|
|
}
|
|
|
@@ -438,19 +435,18 @@ const Product = observer(() => {
|
|
|
type={'link'}
|
|
|
key={'download'}
|
|
|
style={{ padding: 0 }}
|
|
|
+ onClick={async () => {
|
|
|
+ downloadObject(
|
|
|
+ record,
|
|
|
+ intl.formatMessage({
|
|
|
+ id: 'pages.device.product',
|
|
|
+ defaultMessage: '产品',
|
|
|
+ }),
|
|
|
+ );
|
|
|
+ message.success('操作成功');
|
|
|
+ }}
|
|
|
>
|
|
|
- <DownloadOutlined
|
|
|
- onClick={async () => {
|
|
|
- downloadObject(
|
|
|
- record,
|
|
|
- intl.formatMessage({
|
|
|
- id: 'pages.device.product',
|
|
|
- defaultMessage: '产品',
|
|
|
- }),
|
|
|
- );
|
|
|
- message.success('操作成功');
|
|
|
- }}
|
|
|
- />
|
|
|
+ <DownloadOutlined />
|
|
|
{intl.formatMessage({
|
|
|
id: 'pages.data.option.download',
|
|
|
defaultMessage: '下载',
|
|
|
@@ -499,12 +495,9 @@ const Product = observer(() => {
|
|
|
defaultMessage: '是否删除?',
|
|
|
}),
|
|
|
onConfirm: async () => {
|
|
|
- if (record.state === 0) {
|
|
|
- await deleteItem(record.id);
|
|
|
- } else {
|
|
|
- message.error('已发布的产品不能进行删除操作');
|
|
|
- }
|
|
|
+ await deleteItem(record.id);
|
|
|
},
|
|
|
+ disabled: record.state === 1,
|
|
|
}}
|
|
|
>
|
|
|
<DeleteOutlined />
|