|
@@ -8,13 +8,13 @@ import { guid } from '@/utils/utils';
|
|
|
import { PlusOutlined } from '@ant-design/icons';
|
|
import { PlusOutlined } from '@ant-design/icons';
|
|
|
import type { ActionType, ProColumns } from '@ant-design/pro-table';
|
|
import type { ActionType, ProColumns } from '@ant-design/pro-table';
|
|
|
import { Button, message, Space, Typography } from 'antd';
|
|
import { Button, message, Space, Typography } from 'antd';
|
|
|
-import React, { useRef } from 'react';
|
|
|
|
|
|
|
+import React, { useEffect, useRef, useState } from 'react';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 区域管理
|
|
* 区域管理
|
|
|
* 后端接口(CollectRegionController):
|
|
* 后端接口(CollectRegionController):
|
|
|
- * - GET /region/list 区域列表(可选 status 过滤)
|
|
|
|
|
- * - POST /region/add 新增区域(name 必填)
|
|
|
|
|
|
|
+ * - GET /region/list 区域列表(可选 platform/status 过滤)
|
|
|
|
|
+ * - POST /region/add 新增区域(platform, name 必填)
|
|
|
* - POST /region/edit 编辑区域(id 必填)
|
|
* - POST /region/edit 编辑区域(id 必填)
|
|
|
* - POST /region/set_status 设置区域状态
|
|
* - POST /region/set_status 设置区域状态
|
|
|
*/
|
|
*/
|
|
@@ -22,6 +22,20 @@ const RegionManage: React.FC = () => {
|
|
|
const actionRef = useRef<ActionType>();
|
|
const actionRef = useRef<ActionType>();
|
|
|
const proTableFormRef = useRef<any>();
|
|
const proTableFormRef = useRef<any>();
|
|
|
const modiyFormModalRef = useRef<any>();
|
|
const modiyFormModalRef = useRef<any>();
|
|
|
|
|
+ const [platformOptions, setPlatformOptions] = useState<
|
|
|
|
|
+ { label: string; value: number }[]
|
|
|
|
|
+ >([]);
|
|
|
|
|
+ const [selectedPlatform, setSelectedPlatform] = useState<
|
|
|
|
|
+ number | undefined
|
|
|
|
|
+ >();
|
|
|
|
|
+
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ API.CollectPlatform.selectOptions().then((res: any) => {
|
|
|
|
|
+ if (res?.code === 'success') {
|
|
|
|
|
+ setPlatformOptions(res.data || []);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }, []);
|
|
|
|
|
|
|
|
const modiyManage = (type: 'create' | 'update', data: any = {}) => {
|
|
const modiyManage = (type: 'create' | 'update', data: any = {}) => {
|
|
|
const { hide } = Modal.show({
|
|
const { hide } = Modal.show({
|
|
@@ -32,6 +46,14 @@ const RegionManage: React.FC = () => {
|
|
|
type={type}
|
|
type={type}
|
|
|
formOptions={{ labelCol: 8, labelAlign: 'right' }}
|
|
formOptions={{ labelCol: 8, labelAlign: 'right' }}
|
|
|
formList={[
|
|
formList={[
|
|
|
|
|
+ {
|
|
|
|
|
+ label: '所属平台',
|
|
|
|
|
+ isRequired: true,
|
|
|
|
|
+ value: 'platform',
|
|
|
|
|
+ type: 'select',
|
|
|
|
|
+ options: platformOptions,
|
|
|
|
|
+ disabled: type === 'update',
|
|
|
|
|
+ },
|
|
|
{
|
|
{
|
|
|
label: '区域名称',
|
|
label: '区域名称',
|
|
|
isRequired: true,
|
|
isRequired: true,
|
|
@@ -41,6 +63,7 @@ const RegionManage: React.FC = () => {
|
|
|
]}
|
|
]}
|
|
|
ref={modiyFormModalRef}
|
|
ref={modiyFormModalRef}
|
|
|
getDetail={() => ({
|
|
getDetail={() => ({
|
|
|
|
|
+ platform: data?.platform ?? selectedPlatform,
|
|
|
name: data?.name,
|
|
name: data?.name,
|
|
|
})}
|
|
})}
|
|
|
/>
|
|
/>
|
|
@@ -56,6 +79,7 @@ const RegionManage: React.FC = () => {
|
|
|
}
|
|
}
|
|
|
const values = formInstance.getData();
|
|
const values = formInstance.getData();
|
|
|
const payload = {
|
|
const payload = {
|
|
|
|
|
+ platform: Number(values.platform),
|
|
|
name: String(values.name).trim(),
|
|
name: String(values.name).trim(),
|
|
|
};
|
|
};
|
|
|
const response =
|
|
const response =
|
|
@@ -83,6 +107,24 @@ const RegionManage: React.FC = () => {
|
|
|
hideInSearch: true,
|
|
hideInSearch: true,
|
|
|
width: 80,
|
|
width: 80,
|
|
|
},
|
|
},
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '所属平台',
|
|
|
|
|
+ dataIndex: 'platform',
|
|
|
|
|
+ key: 'platform',
|
|
|
|
|
+ valueType: 'select',
|
|
|
|
|
+ fieldProps: {
|
|
|
|
|
+ options: platformOptions,
|
|
|
|
|
+ allowClear: true,
|
|
|
|
|
+ onChange: (val: number | undefined) => {
|
|
|
|
|
+ setSelectedPlatform(val);
|
|
|
|
|
+ actionRef.current?.reload();
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ renderText: (_, record: any) => {
|
|
|
|
|
+ const opt = platformOptions.find((o) => o.value === record?.platform);
|
|
|
|
|
+ return opt?.label ?? record?.platform ?? '-';
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
{
|
|
{
|
|
|
title: '区域名称',
|
|
title: '区域名称',
|
|
|
dataIndex: 'name',
|
|
dataIndex: 'name',
|
|
@@ -159,7 +201,9 @@ const RegionManage: React.FC = () => {
|
|
|
actionRef={actionRef}
|
|
actionRef={actionRef}
|
|
|
formRef={proTableFormRef}
|
|
formRef={proTableFormRef}
|
|
|
request={async (params) => {
|
|
request={async (params) => {
|
|
|
- const res = await API.CollectRegion.list(params);
|
|
|
|
|
|
|
+ const res = await API.CollectRegion.list({
|
|
|
|
|
+ platform: params.platform ?? selectedPlatform,
|
|
|
|
|
+ });
|
|
|
return {
|
|
return {
|
|
|
data: res.data || [],
|
|
data: res.data || [],
|
|
|
total: res.data?.length || 0,
|
|
total: res.data?.length || 0,
|
|
@@ -168,7 +212,6 @@ const RegionManage: React.FC = () => {
|
|
|
}}
|
|
}}
|
|
|
editable={{ type: 'multiple' }}
|
|
editable={{ type: 'multiple' }}
|
|
|
scroll={{ x: '120%' }}
|
|
scroll={{ x: '120%' }}
|
|
|
- noSearch
|
|
|
|
|
toolbar={{
|
|
toolbar={{
|
|
|
actions: [
|
|
actions: [
|
|
|
<Button
|
|
<Button
|