/* * @Author: code4eat awesomedema@gmail.com * @Date: 2023-03-03 11:30:33 * @LastEditors: code4eat awesomedema@gmail.com * @LastEditTime: 2023-11-08 16:42:54 * @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, getDrugTableData, importDataPost } from './service'; import './style.less'; import KCIMUpload from '@/components/KCIMUpload'; import { downloadTemplateReq } from '@/utils/tooljs'; const IconFont = createFromIconfontCN({ scriptUrl: '', }); export default function MaterialCostManagement() { 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: 'code', }, { title: '项目名称', dataIndex: 'name', }, { title: '项目类型', dataIndex: 'type', renderText(num) { return num == 1?'不计价材料':'高值材料' }, }, { title: '单价', dataIndex: 'price', renderText(num) { return formatMoneyNumber(num) }, }, { title: '成本', dataIndex: 'cost', renderText(num) { return formatMoneyNumber(num) }, }, { title: '停用', dataIndex: 'status', renderText(stat) { return stat ? '是' : '否' }, }, { title: '操作', key: 'option', width: 120, valueType: 'option', render: (_: any, record: any) => { return [ , delTableData(record)} > 删除 ] }, }, ] const getTableData = async (params: any) => { const resp = await getDrugTableData({...params,stop:stopStat}); 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 = { ...formVal } if (type == 'ADD') { 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' }) => { return ( 编辑 : 新增 } onFinish={(val) => { return updateTable(type == 'EDIT' ? { ...record, ...val } : { ...val }, type); }} modalProps={{ destroyOnClose: true }} colProps={{ span: 24 }} grid > *停用:}>
{/* 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/exportMaterial'); }; 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)} />
) }