|
@@ -0,0 +1,320 @@
|
|
|
+/*
|
|
|
+ * @Author: code4eat awesomedema@gmail.com
|
|
|
+ * @Date: 2023-03-03 11:30:33
|
|
|
+ * @LastEditors: code4eat awesomedema@gmail.com
|
|
|
+ * @LastEditTime: 2023-03-08 17:53:25
|
|
|
+ * @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 { KCInput } from '@/components/KCInput';
|
|
|
+import KCTable from '@/components/kcTable';
|
|
|
+import { getAllHosp } from '@/service/hospList';
|
|
|
+import { ModalForm, ProFormCascader, ProFormDigit, ProFormRadio, ProFormSelect, ProFormText, ProFormTextArea, ProFormTreeSelect } from '@ant-design/pro-form'
|
|
|
+import { ProColumns } from '@ant-design/pro-table';
|
|
|
+import { message, Popconfirm } from 'antd';
|
|
|
+import React, { useState } from 'react'
|
|
|
+import { addData, delData, editData, getData, getSysLists } from './service';
|
|
|
+
|
|
|
+import './style.less';
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+export default function ParamsMana() {
|
|
|
+
|
|
|
+ const [tableDataFilterParams, set_tableDataFilterParams] = useState<any | undefined>();
|
|
|
+ const [tableDataSearchKeywords, set_tableDataSearchKeywords] = useState<string>('');
|
|
|
+ const [reload, set_reload] = useState(false);
|
|
|
+ const [currentEdit, set_currentEdit] = useState<any>(undefined);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const columns = [
|
|
|
+ {
|
|
|
+ title: '参数名称',
|
|
|
+ dataIndex: 'name',
|
|
|
+
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '参数说明',
|
|
|
+ dataIndex: 'description',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '参数值',
|
|
|
+ dataIndex: 'value',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '院区',
|
|
|
+ dataIndex: 'hospName',
|
|
|
+
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '系统',
|
|
|
+ dataIndex: 'systemName',
|
|
|
+
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '启用',
|
|
|
+ dataIndex: 'status',
|
|
|
+ render: (_: any, record: any) => {
|
|
|
+ return <span style={{ color: record == 1?'#00BF8F':'red' }}>{record == 1 ? '启用' : '禁用'}</span>
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ key: 'option',
|
|
|
+ width: 120,
|
|
|
+ valueType: 'option',
|
|
|
+ render: (_: any, record: any) => {
|
|
|
+ return [
|
|
|
+ //<a key='copy'>复制</a>,
|
|
|
+ <UpDataActBtn key={'act'} record={record} type='EDIT' />,
|
|
|
+ <Popconfirm
|
|
|
+ title="是否确认删除?"
|
|
|
+ key="del"
|
|
|
+ onConfirm={() => delTableData(record)}
|
|
|
+ >
|
|
|
+ <a>删除</a>
|
|
|
+ </Popconfirm>
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ },
|
|
|
+
|
|
|
+ ]
|
|
|
+
|
|
|
+
|
|
|
+ const getTableData = async (params: any) => {
|
|
|
+ const resp = await getData(params);
|
|
|
+ set_reload(false);
|
|
|
+ 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) {
|
|
|
+ set_reload(true);
|
|
|
+ // message.success('操作成功!');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const updateTable = async (formVal: any, type: 'EDIT' | "ADD") => {
|
|
|
+ const {systemId} = formVal;
|
|
|
+ if (type == 'ADD') {
|
|
|
+ const resp = await addData({...formVal,systemId:systemId[systemId.length -1],systemPath:systemId.join(',')});
|
|
|
+ if (resp) {
|
|
|
+ set_reload(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (type == 'EDIT') {
|
|
|
+ const resp = await editData({ ...formVal,systemId:systemId[systemId.length -1],systemPath:systemId.join(',')});
|
|
|
+ if (resp) {
|
|
|
+ set_reload(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ const UpDataActBtn = ({ record, type }: { record: any, type: 'EDIT' | 'ADD' }) => {
|
|
|
+
|
|
|
+ return (
|
|
|
+ <ModalForm
|
|
|
+ title={`${type == 'EDIT' ? '编辑' : '新增'}参数`}
|
|
|
+ width={352}
|
|
|
+ initialValues={type == 'EDIT' ? { ...record,systemId:record.systemPath?record.systemPath.split(','):[] } : {}}
|
|
|
+ trigger={
|
|
|
+ type == 'EDIT' ? <a key="edit" >编辑</a> : <span className='add'>新增</span>
|
|
|
+ }
|
|
|
+ onFinish={(val) => {
|
|
|
+ return updateTable(type == 'ADD'?val:{...record,...val}, type); //编辑时将id返回去
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <ProFormText
|
|
|
+ name="name"
|
|
|
+ label="参数名称:"
|
|
|
+ placeholder="请输入"
|
|
|
+ rules={[{ required: true, message: '参数名称不能为空!' }]}
|
|
|
+ />
|
|
|
+ <ProFormText
|
|
|
+ name="description"
|
|
|
+ label="描述:"
|
|
|
+ placeholder="请输入"
|
|
|
+ rules={[{ required: true, message: '参数描述不能为空!' }]}
|
|
|
+ />
|
|
|
+ <ProFormDigit label="参数值" name="value" rules={[{ required: true, message: '参数值不能为空!' }]} />
|
|
|
+ <ProFormSelect
|
|
|
+ name="hospId"
|
|
|
+ label="院区:"
|
|
|
+ placeholder="请选择院区"
|
|
|
+ rules={[{ required: true, message: '院区不能为空!' }]}
|
|
|
+ request={async () => {
|
|
|
+ const resp = await getAllHosp({ pageSize: 200, current: 1 });
|
|
|
+ if (resp) {
|
|
|
+ const data: any = resp.list?.map((a) => ({
|
|
|
+ label: a.hospName,
|
|
|
+ value: a.id
|
|
|
+ }));
|
|
|
+
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+ return []
|
|
|
+
|
|
|
+ }}
|
|
|
+
|
|
|
+ />
|
|
|
+ <ProFormCascader
|
|
|
+ name='systemId'
|
|
|
+ label="系统:"
|
|
|
+ rules={[{ required: true, message: '系统不能为空!' }]}
|
|
|
+ placeholder="请选择"
|
|
|
+ request={async () => {
|
|
|
+ const resp = await getSysLists();
|
|
|
+ if (resp) {
|
|
|
+ return resp
|
|
|
+ }
|
|
|
+ return []
|
|
|
+
|
|
|
+ }}
|
|
|
+ fieldProps={{
|
|
|
+ fieldNames: {
|
|
|
+ label: 'name',
|
|
|
+ value: 'code'
|
|
|
+ },
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <ProFormRadio.Group
|
|
|
+ name="status"
|
|
|
+ label="启用:"
|
|
|
+ fieldProps={{
|
|
|
+ buttonStyle: 'solid'
|
|
|
+ }}
|
|
|
+ options={[
|
|
|
+ {
|
|
|
+ label: '是',
|
|
|
+ value: 1,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '否',
|
|
|
+ value: 0,
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ rules={[{ required: true, message: '启用不能为空!' }]}
|
|
|
+ />
|
|
|
+
|
|
|
+ </ModalForm>
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ const editHandle = (record: any) => {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ const tableDataSearchHandle = (paramName: string) => {
|
|
|
+
|
|
|
+
|
|
|
+ set_tableDataFilterParams({
|
|
|
+ ...tableDataFilterParams,
|
|
|
+ [`${paramName}`]: tableDataSearchKeywords
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div className='PubDicTypeMana'>
|
|
|
+ <div className='toolBar'>
|
|
|
+ <div className='filter'>
|
|
|
+ <div className='filterItem'>
|
|
|
+ <span className='label'>适用院区:</span>
|
|
|
+ <ProFormSelect
|
|
|
+ noStyle
|
|
|
+ allowClear
|
|
|
+ placeholder="请选择"
|
|
|
+ style={{ width: 160, marginRight: 16 }}
|
|
|
+ request={async () => {
|
|
|
+ const resp = await getAllHosp({ pageSize: 200, current: 1 });
|
|
|
+ if (resp) {
|
|
|
+ const data: any = resp.list?.map((a) => ({
|
|
|
+ label: a.hospName,
|
|
|
+ value: a.id
|
|
|
+ }));
|
|
|
+
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ label: '所有院区', value: '0'
|
|
|
+ }, ...data
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ return []
|
|
|
+
|
|
|
+ }}
|
|
|
+ fieldProps={{
|
|
|
+ onChange(value, option) {
|
|
|
+ set_tableDataFilterParams({ ...tableDataFilterParams, hospId: value })
|
|
|
+ },
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div className='filterItem' style={{ marginRight: 16 }}>
|
|
|
+ <span className='label'>系统名称:</span>
|
|
|
+ <ProFormCascader
|
|
|
+ noStyle
|
|
|
+ allowClear
|
|
|
+ width={160}
|
|
|
+ placeholder="请选择"
|
|
|
+ request={async () => {
|
|
|
+ const resp = await getSysLists();
|
|
|
+ if (resp) {
|
|
|
+ return resp
|
|
|
+ }
|
|
|
+ return []
|
|
|
+
|
|
|
+ }}
|
|
|
+ fieldProps={{
|
|
|
+ fieldNames: {
|
|
|
+ label: 'name',
|
|
|
+ value: 'code'
|
|
|
+ },
|
|
|
+ onChange(value: any, option: any) {
|
|
|
+ set_tableDataFilterParams({ ...tableDataFilterParams, systemId: value ? value[0] : '' })
|
|
|
+ },
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div className='filterItem'>
|
|
|
+ <span className='label'>检索:</span>
|
|
|
+ <KCInput placeholder={'请输入参数名称'} style={{ width: 160 }} search allowClear
|
|
|
+ onChange={(e) => {
|
|
|
+ set_tableDataSearchKeywords(e.target.value);
|
|
|
+ if (e.target.value.length == 0) {
|
|
|
+ set_tableDataFilterParams({
|
|
|
+ ...tableDataFilterParams,
|
|
|
+ parameterName: ''
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ onSearch={() => tableDataSearchHandle('parameterName')}
|
|
|
+
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div className='btnGroup'>
|
|
|
+ <UpDataActBtn record type='ADD' />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div style={{ marginTop: 16 }}>
|
|
|
+ <KCTable columns={columns as ProColumns[]} reload={reload} rowKey='id' newVer params={tableDataFilterParams} request={(params) => getTableData(params)} />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+}
|