/* * @Author: code4eat awesomedema@gmail.com * @Date: 2023-03-03 11:30:33 * @LastEditors: code4eat awesomedema@gmail.com * @LastEditTime: 2024-10-15 15:32:31 * @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 KCIMPagecontainer from '@/components/KCIMPageContainer'; import { KCIMTable } from '@/components/KCIMTable'; import { formatMoneyNumber } from '@/utils/format'; import { createFromIconfontCN } from '@ant-design/icons'; import FormItem from 'antd/es/form/FormItem'; import { ActionType, ProFormDateTimePicker, ProFormInstance, ProFormText } from '@ant-design/pro-components'; import { ModalForm, ProFormDependency, ProFormDigit, ProFormRadio, ProFormSelect, ProFormSwitch } from '@ant-design/pro-form' import { ProColumns } from '@ant-design/pro-table'; import { Input, message, Popconfirm, Form } from 'antd'; import { useEffect, useRef, useState } from 'react'; import 'moment/locale/zh-cn'; import locale from 'antd/es/date-picker/locale/zh_CN'; import { addData, delData, editData, getSpaceCostTableData, importDataPost } from './service'; import './style.less'; import KCIMUpload from '@/components/KCIMUpload'; import { downloadTemplateReq, renameChildListToChildren } from '@/utils/tooljs'; const IconFont = createFromIconfontCN({ scriptUrl: '', }); export default function SpaceCostManagement() { const [tableDataFilterParams, set_tableDataFilterParams] = useState(); const [tableDataSearchKeywords, set_tableDataSearchKeywords] = useState(''); const tableRef = useRef(); const formRef = useRef(); const [stopStat, set_stopStat] = useState(0); const columns: ProColumns[] = [ { title: '空间名称', dataIndex: 'name', }, { title: '空间编码', dataIndex: 'code', }, { title: '建置成本(元)', dataIndex: 'cost', align:'right', }, { title: '建置容积(㎡)', dataIndex: 'volume', align:'right', }, { title: '折旧年限', dataIndex: 'depreciationYear', renderText(num) { return formatMoneyNumber(num) }, }, { title: '每年折旧', align:'right', dataIndex: 'costPerYear', renderText(num) { return formatMoneyNumber(num) }, }, { title: '每分钟成本', align:'right', dataIndex: 'costPerMinute', }, { title: '停用', dataIndex: 'status', renderText(num) { return num ? '是' : '否' }, }, { title: '操作', key: 'option', width: 120, valueType: 'option', render: (_: any, record: any) => { return record.type == 0 ?[ , delTableData(record)} > 删除 , , ]:[ , delTableData(record)} > 删除 ] }, }, ] const getTableData = async (params: any) => { let resp = await getSpaceCostTableData({ ...params,stop:stopStat }); if (resp) { const data = renameChildListToChildren(resp, 'childList'); return { data: data, success: true, } } 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" | "ADDCHILD") => { const result = { ...formVal } if (type == 'ADD'||type == 'ADDCHILD') { const resp = await addData(result); if (resp) { tableRef.current?.reload(); message.success('操作成功!'); } } if (type == 'EDIT') { const resp = await editData({ ...result }); if (resp) { tableRef.current?.reload(); message.success('操作成功!'); } } return true; } const UpDataActBtn = ({ record, type }: { record: any, type: 'EDIT' | 'ADD' | 'ADDCHILD' }) => { return ( 编辑 : {type == 'ADD' ? '新增' : '添加'} } onFinish={(val) => { return updateTable(type == 'EDIT' ? { ...record, ...val } :type == 'ADDCHILD'?{...val,parentCode:record.code}:{ ...val,parentCode:0 }, type); }} modalProps={{ destroyOnClose: true }} colProps={{ span: 24 }} grid > { ({ type }) => { return type == 1 && ( <> *停用:}>
{/* style={{position:'relative',left:-10}} */} { ({ status }) => { // console.log({report}); return ( status ? : null ) } }
) } }
) } const tableDataSearchHandle = (paramName: string) => { set_tableDataFilterParams({ ...tableDataFilterParams, [`${paramName}`]: tableDataSearchKeywords }) } const downloadTemplate = async () => { await downloadTemplateReq('/costAccount/setting/exportSpaceCost'); }; const importData = () => { return ( 导入 } submitter={{ render: (props, defaultDoms) => { const needBtn = defaultDoms.filter((b) => { return b.key != 'rest'; }); return [ // , ...needBtn, ]; }, }} onFinish={async (values) => { const { importFile: { fileList }, } = values; let formData = new FormData(); formData.append('file', fileList[0].originFileObj); const resp = await importDataPost(formData); if (resp) { tableRef.current?.reload(); return true; } }} > downloadTemplate()} /> ); }; useEffect(() => { }, []) 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 }); }} />
{ set_stopStat(bool ? 1 : 0); tableRef.current?.reload(); } }} /> 显示停用项目 {importData()}
getTableData(params)} />
) }