/* * @Author: code4eat awesomedema@gmail.com * @Date: 2023-03-03 11:30:33 * @LastEditors: code4eat awesomedema@gmail.com * @LastEditTime: 2023-05-24 17:16:20 * @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 */ import BMSPagecontainer from '@/components/BMSPageContainer'; import { BMSTable } from '@/components/BMSTable'; import { getComputeDate } from '@/pages/Home/service'; import { getDataByKeyFromDic, getPubDicData } from '@/services/getDic'; import { createFromIconfontCN } from '@ant-design/icons'; import { ActionType, ProFormRadio } from '@ant-design/pro-components'; import { ModalForm, ProFormCascader, ProFormDigit, ProFormSelect, ProFormText, ProFormTextArea } from '@ant-design/pro-form' import { ProColumns } from '@ant-design/pro-table'; import { Input, message, Popconfirm } from 'antd'; import { useEffect, useRef, useState } from 'react' import { addData, delData, editData, gainData, getIndicProjectTableData } from './service'; import './style.less'; const IconFont = createFromIconfontCN({ scriptUrl: '//at.alicdn.com/t/c/font_1927152_4nm5kxbv4m3.js', }); export default function BilingProjectMana() { const [tableDataFilterParams, set_tableDataFilterParams] = useState(); const [tableDataSearchKeywords, set_tableDataSearchKeywords] = useState(''); const tableRef = useRef(); const columns:ProColumns[] = [ { title: '项目代码', dataIndex: 'indicatorCode', }, { title: '项目名称', dataIndex: 'indicatorName', }, { title: '类型', dataIndex: 'indicatorTypeName', }, { title: '定义', dataIndex: 'indicatorDefinition', }, { title: '点值', dataIndex: 'orderPointValue', }, { title: 'SQL', dataIndex: 'sql', width:400, ellipsis:true }, { title: '操作', key: 'option', width: 120, valueType: 'option', render: (_: any, record: any) => { return [ , delTableData(record)} > 删除 ] }, }, ] const getTableData = async (params: any) => { const resp = await getIndicProjectTableData(params); if (resp) { return { data: resp.list, success: true, total: resp.totalCount, pageSize: resp.pageSize, totalPage: resp.totalPage, } } return [] } const delTableData = async (record: any) => { const resp = await delData(record.id); if (resp) { message.success('操作成功!'); tableRef.current?.reload(); // message.success('操作成功!'); } } const updateTable = async (formVal: any, type: 'EDIT' | "ADD") => { const result = { indicatorName: formVal.indicatorName, indicatorType: formVal.indicatorType, indicatorDefinition: formVal.indicatorDefinition, orderPointValue: formVal.orderPointValue, //executePointValue: formVal.executePointValue, sql: formVal.sql } if (type == 'ADD') { const resp = await addData({...result}); if (resp) { tableRef.current?.reload(); message.success('操作成功!'); } } if (type == 'EDIT') { const resp = await editData({id:formVal.id,...result}); if (resp) { tableRef.current?.reload(); message.success('操作成功!'); } } return true; } const [dicData, set_dicData] = useState([]); const getDirecData = async (key?: string) => { const data = await getPubDicData(); if (data) { set_dicData(data); } } const UpDataActBtn = ({ record, type }: { record: any, type: 'EDIT' | 'ADD' }) => { return ( 编辑 : 新增 } onFinish={(val) => { return updateTable(type == 'EDIT' ? { ...record, ...val,orderPointValue:val.orderPointValue?val.orderPointValue:undefined } : { ...val }, type); }} modalProps={{ destroyOnClose: true }} colProps={{ span: 24 }} grid > ) } const tableDataSearchHandle = (paramName: string) => { set_tableDataFilterParams({ ...tableDataFilterParams, [`${paramName}`]: tableDataSearchKeywords }) } //获取按钮点击后获取数据 const getDataBySQL = async () => { const resp = await getComputeDate(); if (resp) { const respStat = await gainData({ compute_date: resp }); if (respStat) { tableRef.current?.reload(); } } } useEffect(() => { getDirecData(); }, []) return (
检索: tableDataSearchHandle('name')} /> } onChange={(e) => { set_tableDataSearchKeywords(e.target.value); if (e.target.value.length == 0) { set_tableDataFilterParams({ ...tableDataFilterParams, name: '' }); } }} onPressEnter={(e) => { set_tableDataFilterParams({ ...tableDataFilterParams, name: (e.target as HTMLInputElement).value }); }} />
{/* getDataBySQL()}>获取 */}
getTableData(params)} />
) }