|
@@ -2,7 +2,7 @@
|
|
|
* @Author: code4eat awesomedema@gmail.com
|
|
* @Author: code4eat awesomedema@gmail.com
|
|
|
* @Date: 2023-03-03 11:30:33
|
|
* @Date: 2023-03-03 11:30:33
|
|
|
* @LastEditors: code4eat awesomedema@gmail.com
|
|
* @LastEditors: code4eat awesomedema@gmail.com
|
|
|
- * @LastEditTime: 2023-09-27 14:46:46
|
|
|
|
|
|
|
+ * @LastEditTime: 2023-09-27 17:52:05
|
|
|
* @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/index.tsx
|
|
* @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/index.tsx
|
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
*/
|
|
*/
|
|
@@ -14,7 +14,7 @@
|
|
|
|
|
|
|
|
import { createFromIconfontCN } from '@ant-design/icons';
|
|
import { createFromIconfontCN } from '@ant-design/icons';
|
|
|
|
|
|
|
|
-import { ActionType, DrawerForm, EditableFormInstance, EditableProTable, ProFormSelect } from '@ant-design/pro-components';
|
|
|
|
|
|
|
+import { ActionType, DrawerForm, EditableFormInstance, EditableProTable, ProFormInstance, ProFormSelect } from '@ant-design/pro-components';
|
|
|
import { ModalForm, ProFormDigit, ProFormText, ProFormTextArea } from '@ant-design/pro-form'
|
|
import { ModalForm, ProFormDigit, ProFormText, ProFormTextArea } from '@ant-design/pro-form'
|
|
|
import { ProColumns } from '@ant-design/pro-table';
|
|
import { ProColumns } from '@ant-design/pro-table';
|
|
|
import { Input, message, Popconfirm } from 'antd';
|
|
import { Input, message, Popconfirm } from 'antd';
|
|
@@ -124,29 +124,29 @@ export default function FenyeTemplate() {
|
|
|
|
|
|
|
|
const updateTable = async (formVal: any, type: 'EDIT' | "ADD") => {
|
|
const updateTable = async (formVal: any, type: 'EDIT' | "ADD") => {
|
|
|
|
|
|
|
|
- const content = formVal.table.map((a:any)=>({
|
|
|
|
|
-
|
|
|
|
|
|
|
+ const content = formVal.table.map((a: any) => ({
|
|
|
|
|
+
|
|
|
}))
|
|
}))
|
|
|
|
|
|
|
|
if (type == 'ADD') {
|
|
if (type == 'ADD') {
|
|
|
const result = {
|
|
const result = {
|
|
|
- name:formVal.name,
|
|
|
|
|
- content:JSON.stringify(formVal.table),
|
|
|
|
|
- remark:formVal.remark
|
|
|
|
|
|
|
+ name: formVal.name,
|
|
|
|
|
+ content: JSON.stringify(formVal.table),
|
|
|
|
|
+ remark: formVal.remark
|
|
|
}
|
|
}
|
|
|
const resp = await addData({ ...result });
|
|
const resp = await addData({ ...result });
|
|
|
if (resp) {
|
|
if (resp) {
|
|
|
tableRef.current?.reload();
|
|
tableRef.current?.reload();
|
|
|
message.success('操作成功!');
|
|
message.success('操作成功!');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
if (type == 'EDIT') {
|
|
if (type == 'EDIT') {
|
|
|
const result = {
|
|
const result = {
|
|
|
- id:formVal.id,
|
|
|
|
|
- name:formVal.name,
|
|
|
|
|
- content:JSON.stringify(formVal.table),
|
|
|
|
|
- remark:formVal.remark
|
|
|
|
|
|
|
+ id: formVal.id,
|
|
|
|
|
+ name: formVal.name,
|
|
|
|
|
+ content: JSON.stringify(formVal.table),
|
|
|
|
|
+ remark: formVal.remark
|
|
|
}
|
|
}
|
|
|
const resp = await editData({ ...result });
|
|
const resp = await editData({ ...result });
|
|
|
if (resp) {
|
|
if (resp) {
|
|
@@ -161,107 +161,118 @@ export default function FenyeTemplate() {
|
|
|
const UpDataActBtn = ({ record, type }: { record: any, type: 'EDIT' | 'ADD' }) => {
|
|
const UpDataActBtn = ({ record, type }: { record: any, type: 'EDIT' | 'ADD' }) => {
|
|
|
|
|
|
|
|
const editableFormRef = useRef<EditableFormInstance>();
|
|
const editableFormRef = useRef<EditableFormInstance>();
|
|
|
|
|
+ const formRef = useRef<ProFormInstance<any>>();
|
|
|
|
|
+ const editorFormRef = useRef<EditableFormInstance<any>>();
|
|
|
|
|
+
|
|
|
|
|
|
|
|
- const editableColumns:ProColumns[] = [
|
|
|
|
|
|
|
+ const editableColumns: ProColumns[] = [
|
|
|
{
|
|
{
|
|
|
- title:'标题',
|
|
|
|
|
|
|
+ title: '标题',
|
|
|
dataIndex: 'title',
|
|
dataIndex: 'title',
|
|
|
- editable:()=>true
|
|
|
|
|
|
|
+ editable: () => true
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- title:'类型',
|
|
|
|
|
- dataIndex: 'filedType',
|
|
|
|
|
- editable:()=>false
|
|
|
|
|
|
|
+ title: '类型',
|
|
|
|
|
+ dataIndex: 'filedType',
|
|
|
|
|
+ editable: () => false
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- title:'是否必填',
|
|
|
|
|
|
|
+ title: '是否必填',
|
|
|
dataIndex: 'required',
|
|
dataIndex: 'required',
|
|
|
request: async () => [
|
|
request: async () => [
|
|
|
{
|
|
{
|
|
|
- value: 1,
|
|
|
|
|
- label: '是',
|
|
|
|
|
|
|
+ value: 1,
|
|
|
|
|
+ label: '是',
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- value: 0,
|
|
|
|
|
- label: '否',
|
|
|
|
|
|
|
+ value: 0,
|
|
|
|
|
+ label: '否',
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
fieldProps: (_, { rowIndex }) => {
|
|
fieldProps: (_, { rowIndex }) => {
|
|
|
return {
|
|
return {
|
|
|
- onSelect: () => {
|
|
|
|
|
- // 每次选中重置参数
|
|
|
|
|
- editableFormRef.current?.setRowData?.(rowIndex, { fraction: [] });
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ onSelect: () => {
|
|
|
|
|
+ // 每次选中重置参数
|
|
|
|
|
+ editableFormRef.current?.setRowData?.(rowIndex, { fraction: [] });
|
|
|
|
|
+ },
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
renderText(text) {
|
|
renderText(text) {
|
|
|
- return text?'是':'否'
|
|
|
|
|
|
|
+ return text ? '是' : '否'
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- title:'是否展示信息',
|
|
|
|
|
|
|
+ title: '是否展示信息',
|
|
|
dataIndex: 'showFiled',
|
|
dataIndex: 'showFiled',
|
|
|
request: async () => [
|
|
request: async () => [
|
|
|
{
|
|
{
|
|
|
- value: 1,
|
|
|
|
|
- label: '是',
|
|
|
|
|
|
|
+ value: 1,
|
|
|
|
|
+ label: '是',
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- value: 0,
|
|
|
|
|
- label: '否',
|
|
|
|
|
|
|
+ value: 0,
|
|
|
|
|
+ label: '否',
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
fieldProps: (_, { rowIndex }) => {
|
|
fieldProps: (_, { rowIndex }) => {
|
|
|
return {
|
|
return {
|
|
|
- onSelect: () => {
|
|
|
|
|
- // 每次选中重置参数
|
|
|
|
|
- editableFormRef.current?.setRowData?.(rowIndex, { fraction: [] });
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ onSelect: () => {
|
|
|
|
|
+ // 每次选中重置参数
|
|
|
|
|
+ editableFormRef.current?.setRowData?.(rowIndex, { fraction: [] });
|
|
|
|
|
+ },
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
renderText(text) {
|
|
renderText(text) {
|
|
|
- return text?'是':'否'
|
|
|
|
|
|
|
+ return text ? '是' : '否'
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
title: '操作',
|
|
title: '操作',
|
|
|
valueType: 'option',
|
|
valueType: 'option',
|
|
|
render: (text, record, _, action) => [
|
|
render: (text, record, _, action) => [
|
|
|
- <a
|
|
|
|
|
- key="editable"
|
|
|
|
|
- onClick={() => {
|
|
|
|
|
- action?.startEditable?.(record.tempId);
|
|
|
|
|
- }}
|
|
|
|
|
- >
|
|
|
|
|
- 编辑
|
|
|
|
|
- </a>,
|
|
|
|
|
- <a
|
|
|
|
|
- key="delete"
|
|
|
|
|
- onClick={() => {
|
|
|
|
|
- //setDataSource(dataSource.filter((item) => item.id !== record.id));
|
|
|
|
|
- }}
|
|
|
|
|
- >
|
|
|
|
|
- 删除
|
|
|
|
|
- </a>,
|
|
|
|
|
|
|
+ <a
|
|
|
|
|
+ key="editable"
|
|
|
|
|
+ onClick={() => {
|
|
|
|
|
+ action?.startEditable?.(record.tempId);
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ 编辑
|
|
|
|
|
+ </a>,
|
|
|
|
|
+ <a
|
|
|
|
|
+ key="delete"
|
|
|
|
|
+ onClick={() => {
|
|
|
|
|
+ const tableDataSource = formRef.current?.getFieldValue(
|
|
|
|
|
+ 'table',
|
|
|
|
|
+ ) as any[];
|
|
|
|
|
+ formRef.current?.setFieldsValue({
|
|
|
|
|
+ table: tableDataSource.filter((item) => item.tempId !== record.tempId),
|
|
|
|
|
+ });
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ 删除
|
|
|
|
|
+ </a>,
|
|
|
],
|
|
],
|
|
|
- },
|
|
|
|
|
|
|
+ },
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
- let defaultTableData = JSON.parse(record.content?record.content:'[]');
|
|
|
|
|
- defaultTableData = defaultTableData.map((a:any)=>({...a,tempId:Math.random()}))
|
|
|
|
|
|
|
+ let defaultTableData = JSON.parse(record.content ? record.content : '[]');
|
|
|
|
|
+ defaultTableData = defaultTableData.map((a: any) => ({ ...a, tempId: (Math.random() * 1000000).toFixed(0) }));
|
|
|
|
|
+
|
|
|
|
|
+ const [tempData, setTempData] = useState<any[]>(defaultTableData);
|
|
|
// console.log({defaultTableData});
|
|
// console.log({defaultTableData});
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<DrawerForm
|
|
<DrawerForm
|
|
|
title={`${type == 'EDIT' ? '编辑' : '新增'}模板数据`}
|
|
title={`${type == 'EDIT' ? '编辑' : '新增'}模板数据`}
|
|
|
width={800}
|
|
width={800}
|
|
|
- initialValues={type == 'EDIT' ? { ...record,table:defaultTableData,filedType:'Text'} : {filedType:'Text'}}
|
|
|
|
|
|
|
+ initialValues={type == 'EDIT' ? { ...record, table: defaultTableData, filedType: 'Text' } : { filedType: 'Text' }}
|
|
|
trigger={
|
|
trigger={
|
|
|
type == 'EDIT' ? <a key="edit" >编辑</a> : <span className='add'>新增</span>
|
|
type == 'EDIT' ? <a key="edit" >编辑</a> : <span className='add'>新增</span>
|
|
|
}
|
|
}
|
|
|
onFinish={(val) => {
|
|
onFinish={(val) => {
|
|
|
return updateTable(type == 'EDIT' ? { ...record, ...val } : { ...val }, type);
|
|
return updateTable(type == 'EDIT' ? { ...record, ...val } : { ...val }, type);
|
|
|
}}
|
|
}}
|
|
|
|
|
+ formRef={formRef}
|
|
|
drawerProps={{ destroyOnClose: true }}
|
|
drawerProps={{ destroyOnClose: true }}
|
|
|
colProps={{ span: 24 }}
|
|
colProps={{ span: 24 }}
|
|
|
grid
|
|
grid
|
|
@@ -279,13 +290,19 @@ export default function FenyeTemplate() {
|
|
|
placeholder="请输入"
|
|
placeholder="请输入"
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
|
- <EditableProTable
|
|
|
|
|
|
|
+ <EditableProTable
|
|
|
name='table'
|
|
name='table'
|
|
|
rowKey={'tempId'}
|
|
rowKey={'tempId'}
|
|
|
- tableStyle={{padding:0}}
|
|
|
|
|
|
|
+ editableFormRef={editorFormRef}
|
|
|
|
|
+ tableStyle={{ padding: 0 }}
|
|
|
columns={editableColumns}
|
|
columns={editableColumns}
|
|
|
|
|
+ controlled
|
|
|
|
|
+ editable={{
|
|
|
|
|
+
|
|
|
|
|
+ }}
|
|
|
recordCreatorProps={{
|
|
recordCreatorProps={{
|
|
|
- record: () => ({ tempId: (Math.random() * 1000000).toFixed(0),filedType:'Text' }),
|
|
|
|
|
|
|
+ record: () => ({ tempId: (Math.random() * 1000000).toFixed(0), filedType: 'Text' }),
|
|
|
|
|
+
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
</DrawerForm>
|
|
</DrawerForm>
|