浏览代码

冲突解决

1178232204@qq.com 3 年之前
父节点
当前提交
669ab8c7c6

+ 4 - 0
src/components/DrugManager/Drug-context.js

@@ -0,0 +1,4 @@
+import { createContext } from 'react';
+const DrugContext = createContext(null);
+
+export default DrugContext;

+ 120 - 0
src/components/DrugManager/addDrug.js

@@ -0,0 +1,120 @@
+import React, {
+   useContext
+} from 'react';
+import { Form, Input, Button,  message, Space } from 'antd';
+import apiObj from '@api/index';
+import { getCookie,setCookie } from '@utils/index';
+import DrugContext from './Drug-context';
+const { post, api } = apiObj;
+
+function AddDrug(props) {
+  
+  const [form] = Form.useForm();
+  const { type, formData} = useContext(DrugContext);
+  const initialValues = formData;
+
+  const onFinish = values => {
+    let params = values
+    if (type == 3) {
+	  params.id=initialValues.id
+      upDrugById(params)
+    } else {
+      addDrug(params)
+    }
+
+  };
+  function addDrug(param) {
+    const hisId = getCookie("hospitalId");
+	const params ={
+		hospitalId:hisId,
+		...param
+	}
+	post(api.addDrug, params).then((res) => {
+      if (res.data.code === 200) {
+        props.DrugChange()
+        message.success(res.data.message);
+      } else {
+        message.error(res.data.message);
+      }
+    })
+  }
+  function upDrugById(param) {
+	  const hisId = getCookie("hospitalId");
+	  const params ={
+	  	hospitalId:hisId,
+	  	...param
+	  }
+    post(api.upDrugById, params).then((res) => {
+      if (res.data.code === 200) {
+        props.DrugChange()
+        message.success(res.data.message);
+      } else {
+        message.error(res.data.message);
+      }
+    })
+  }
+  function cancel() {
+  	props.cancel()
+  }
+  
+  function onValuesChange() {
+  	props.isChange(form.isFieldsTouched())
+  }
+
+  return (
+    <>
+      <Form
+        labelCol={{ span: 6 }}
+        wrapperCol={{ span: 16 }}
+        form={form}
+        name="register"
+        onFinish={onFinish}
+        initialValues={initialValues}
+		onValuesChange={onValuesChange}
+      >
+
+        <Form.Item
+          name="name"
+          label="医院药品名称"
+          rules={[
+            {
+              required: true,
+              message: '请输入医院药品名称',
+            },
+          ]}
+        >
+          {type == 3 ?
+		    <Input  autoComplete='off'/>
+            :
+            <Input placeholder="请输入" autoComplete='off'/>
+          }
+
+        </Form.Item>
+		<Form.Item
+		  name="approvalNum"
+		  label="国药准字"
+		>
+		  {type == 3 ?
+		    <Input  autoComplete='off'/>
+		    :
+		    <Input placeholder="请输入" autoComplete='off'/>
+		  }
+		
+		</Form.Item>
+          <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
+            <Space size="middle">
+              <Button htmlType="button" onClick={e => cancel()}>
+                取消
+            </Button>
+              <Button type="primary" htmlType="submit">
+                保存
+            </Button>
+            </Space>
+          </Form.Item>
+
+      </Form>
+    </>
+  );
+}
+
+export default AddDrug;

+ 400 - 358
src/components/DrugManager/index.js

@@ -1,376 +1,418 @@
 import React, { useState, useEffect } from 'react';
-import { Empty, ConfigProvider, Spin, Form, Input, Button, Table, Select, Space, Modal, message, Row, Col } from 'antd';
+import { Form, Input, Button, Table, Select, Space, Modal, message, Row, Col, Upload } from 'antd';
 import { PlusOutlined } from '@ant-design/icons';
-import AddTerm from '../DiagManager/addDiag'
-import { useSelector } from 'react-redux';
+import AddDrug from './addDrug'
+import MatchDrug from './MatchDrug.js'
 import '@common/common.less';
 import apiObj from '@api/index';
+import DrugContext from './Drug-context';
 
 const { post, api } = apiObj;
 const { Option } = Select;
 //获取列表
 function DrugManager() {
-	const { drugNum } = useSelector((state) => {
-		return state.userInfo;
-	});
-	useEffect(() => {
-		setSize(15)
-		setCurrent(1)
-		form.resetFields();
-		getDrugeryPage();
-	}, [drugNum]);
-	const [DrugList, setDrugList] = useState([]);//当前页列表数据
-	const [Drugid, setDrugid] = useState([]);//当前操作行id
-	const [title, setTitle] = useState("");//新增/修改的弹窗标题
-	const [visible, setVisible] = useState(false);//新增修改 弹窗
-	const [delvisible, setDelvisible] = useState(false);//删除 弹窗
-	const [loading, setloading] = useState(true);//是否显示加载中
-	const [flag, setFlag] = useState(false);//新增1或修改3
-	const [formData, setFormData] = useState({});//当前行数据
-	const [size, setSize] = useState(15);//每页显示条数
-	const [total, setTotal] = useState(0);
-	const [current, setCurrent] = useState(1);//当前页
-	const [params, setParams] = useState({
-		pages: 1,
-		current: 1,
-		size: 15
-	});
-	const [form] = Form.useForm();
+  useEffect(() => {
+    getDrugPage();
+  }, []);
+  const [DrugList, setDrugList] = useState([]);//当前页列表数据
+  const [Drugid, setDrugid] = useState([]);//当前列表id
+  const [title, setTitle] = useState("");//数据总量
+  const [visible, setVisible] = useState(false);//新增修改 弹窗
+  const [msvisible, setMsvisible] = useState(false);//删除 弹窗
+  const [visible1, setvisible1] = useState(false);//导入 弹窗
+  const [visible2, setvisible2] = useState(false);//匹配 弹窗
+  const [unsaved, setUnsaved] = useState(false);//修改未保存弹窗
+  const [revise, setRevise] = useState(false);//是否修改 新增修改内容
+  const [type, setType] = useState("");
+  const [formData, setFormData] = useState(null);//当前行数据
+  const [size, setSize] = useState(15);//每页显示条数
+  const [total, setTotal] = useState(0);
+  const [current, setCurrent] = useState(1);//当前页
+  const [uploadStatus, setUploadStatus] = useState(0);//导入状态,0初始,1成功,2格式错误,3导入数据错误
+  const [uploadTip, setUploadTip] = useState("");		//导入状态提示语
+  const [saveParams, setSaveParams] = useState({});		//匹配药品选中
+  const [params, setParams] = useState({
+    pages: 1,
+    current: 1,
+    size: 15
+  });
+  const [form] = Form.useForm();
+  const tipMap = {
+    0: '提示:EXCEL导入,模板样式及数据请在【朗通云平台-CDSS数据维护-医学术语关联维护】中导出获取。',
+    2: "模板格式错误,模板样式及数据请在【朗通云平台-CDSS数据维护-医学术语关联维护】中导出获取",
+    3: '模板导入失败,失败原因已在Excel中标识并自动下载,请检查后重新导入',
+  };
 
-	let data = {
-		pages: 1,
-		current: 1,
-		size: 15
-	}
-	//新增/修改 弹窗flag=1新增,3修改
-	const showModal = (name, flag1, Drugrow) => {
-		setVisible(true);
-		setTitle(name);
-		setFlag(flag1)
-		if (flag1 === 1) {
-			setFormData({
-				status: 1,
-				hisName: '',
-				uniqueName: '',
-				form: ''
-			})
-		} else if (flag1 === 3) {
-			console.log(33, Drugrow)
-			setFormData(Drugrow)
-		}
-	}
-	//表格数据
-	function getDrugeryPage(param) {  //type(必填): 类型:1-化验、3-辅检、4-诊断、5-药品、6-手术和操作
-		const hide = message.loading('加载中...', 0);
-		const hospitalId = localStorage.getItem('hospitalId')
-		setloading(true)
-		post(api.getTermPage, { ...(param || params), type: 5, hospitalId: hospitalId }).then((res) => {
-			hide()
-			if (res.data.code === 200) {
-				const data = res.data.data;
-				setDrugList(data.records);
-				setTotal(data.total)
-				setloading(false)
-			}
-		})
-	}
-	function showDelModal(id) {
-		setDelvisible(true);
-		setDrugid(id);
-	}
-	//删除
-	function delDrugeryById() {
-		post(api.deleteRecord, { id: Drugid }).then((res) => {
-			setDelvisible(false);
-			if (res.data.code === 200) {
-				//刷新列表
-				const totalPage = Math.ceil((total - 1) / size);
-				//将当前页码与删除数据之后的总页数进行比较,避免当前页码不存在
-				const pagenum =
-					params.current > totalPage ? totalPage : params.current;
-				//避免pagenum变为0
-				params.current = pagenum < 1 ? 1 : pagenum;
-				setParams(params)
-				getDrugeryPage();
-				setDrugid("");
-				message.success("删除成功");
-			} else {
-				message.warning(res.data.msg || '操作失败');
-			}
-		}).catch(() => {
-			setDelvisible(false);
-			message.error("接口出错");
-		});
-	}
-	//每页显示条数切换
-	function onSizeChange(current, pageSize) {
-		params.current = current
-		params.size = pageSize
-		setSize(pageSize)
-		setCurrent(current)
-		setParams(params)
-	}
-	//翻页
-	function changePage(page, pageSize) {
-		params.current = page
-		params.size = pageSize
-		setCurrent(page)
-		setParams(params)
-		getDrugeryPage()
-	}
-	//筛选查询
-	const onFinish = (value) => {
-		params.current = 1
-		const param = {
-			...params,
-			...value
-		}
-		console.log(param)
-		setCurrent(1)
-		setParams(param)
-		getDrugeryPage(param);
-	};
-	//重置
-	const onReset = () => {
-		setSize(15)
-		setCurrent(1)
-		setParams(data)
-		form.resetFields();
-		getDrugeryPage(data);
-	};
+  let data = {
+    pages: 1,
+    current: 1,
+    size: size
+  }
+  //新增 弹窗
+  const showModal = (name, type, flag, Drugrow) => {
+    setVisible(type);
+    setTitle(name);
+    setType(flag)
+    if (flag == 1) {
+      setFormData({
+        status: '1'
+      })
+    }
+    if (flag == 3) {
+      setFormData(Drugrow)
+      getDrugPage()
+    }
+  }
+  //表格数据
+  function getDrugPage(param) {
+    post(api.getDrugPage, param || params).then((res) => {
+      if (res.data.code === 200) {
+        const data = res.data.data;
+        setDrugList(data.records);
+        setTotal(data.total)
+      }
+    })
+  }
 
-	//删除 提示框取消或关闭
-	function handleCancel() {
-		setDelvisible(false);
-	}
+  //删除
+  function delDrugById() {
+    post(api.delDrugById, { ids: Drugid }).then((res) => {
+      setMsvisible(false);
+      if (res.data.code === 200) {
+        getDrugPage();
+        setDrugid([])
+        message.success("操作成功");
+      } else {
+        message.warning(res.data.msg || '操作失败');
+      }
+    }).catch(() => {
+      setMsvisible(false);
+      message.error("接口出错");
+    });
+  }
+  //每页显示条数切换
+  function onSizeChange(current, pageSize) {
+    params.current = current
+    params.size = pageSize
+    setSize(pageSize)
+    setCurrent(current)
+    setParams(params)
+    getDrugPage()
+  }
+  //翻页
+  function changePage(page, pageSize) {
+    params.current = page
+    params.size = pageSize
+    setCurrent(page)
+    setParams(params)
+    getDrugPage()
+  }
+  const onFinish = (value) => {
+    const param = {
+      ...data,
+      ...value
+    }
+    setCurrent(1)
+    setParams(param)
+    getDrugPage(param);
+  };
+  //重置
+  const onReset = () => {
+    setCurrent(1)
+    setParams(data)
+    form.resetFields();
+    getDrugPage(data);
+  };
+  //打开导入弹窗
+  const ImportBox = () => {
+    setvisible1(true)
+  }
+  //导入弹窗取消或关闭
+  function handleCancel1() {
+    setvisible1(false);
+    setUploadStatus(0);
+  }
+  //打开匹配弹窗
+  function match(row) {
+    setvisible2(true)
+    setFormData(row)
+  }
+  //导入弹窗取消或关闭
+  function handleCancel2() {
+    setvisible2(false);
+  }
+  const messageBox = () => {
+    if (!Drugid.length) {
+      message.warning("请先选择要删除的记录~", 1);
+      return;
+    }
+    setMsvisible(true)
+  }
+  //删除 提示框取消或关闭
+  function handleCancel() {
+    setMsvisible(false);
+  }
 
-	//新增修改 取消或关闭
-	function cancel() {
-		setVisible(false)
-		setFormData([])
-	}
+  //新增修改 取消或关闭
+  function cancel() {
+    if (revise) {
+      setUnsaved(true)
+    } else {
+      setVisible(false)
+      setFormData(null)
+    }
+  }
 
-	function saveMatching(saveParams) {
-		post(api.saveOrUpdateRecord, saveParams).then((res) => {
-			if (res.data.code === 200) {
-				message.success("匹配成功");
-				setVisible(false);
-				setFormData([])
-				getDrugeryPage();
-			} else {
-				message.warning(res.data.message || "匹配失败,请重试");
-			}
-		}).catch((error) => {
-			message.warning(error.message || "接口出错,请重试",);
-		})
-	}
-	const renderEmpty = () => (
-		<Empty
-			imageStyle={{
-				height: 0,
-			}}
-			description={<span></span>}
-		>
-		</Empty>
-	)
+  function isChange(a) {
+    setRevise(a)
+  }
 
-	const columns = [
-		{ title: '序号', dataIndex: 'index', render: (text, record, index) => (current - 1) * params.size + index + 1 },
-		{ title: '操作时间', dataIndex: 'gmtModified', },
-		{ title: '医院药品名称', dataIndex: 'hisName', },
-		{ title: '标准药品名称', dataIndex: 'uniqueName', },
-		{ title: '药品剂型', dataIndex: 'form', },
-		{
-			title: '标准术语状态', dataIndex: 'status', render: (text, record) => {
-				return record.status === 1 ? '启用' : record.status === 0 ? '禁用' : '';
-			}
-		},
-		{
-			title: '剂型术语状态', dataIndex: 'formStatus', render: (text, record) => {
-				return record.formStatus === 1 ? '启用' : record.formStatus === 0 ? '禁用' : '';
-			}
-		},
-		{
-			title: '是否匹配', dataIndex: 'isMatch', render: (text, record) => {
-				return record.isMatch === 1 ? '已匹配' : '未匹配';
-			}
-		},
-		{
-			title: '操作', dataIndex: 'key', render: (text, record) => (
-				<Space size="middle">
-					<a onClick={e => showModal('修改药品信息', 3, record)}>修改</a>
-					<a style={{ color: "#FF4D4D" }} onClick={() => showDelModal(record.id)}>删除</a>
-				</Space>
-			)
-		}
-	]
-	return (
-		<div className="wrapper">
-			<div className="filter-box">
-				<Form
-					form={form}
-					name="normal_login"
-					onFinish={onFinish}
-				>
-					<Row gutter={24}>
-						<Col span={5} key={0}>
-							<Form.Item label="医院药品名称" name="hisName">
-								<Input placeholder="请输入" autoComplete='off' allowClear maxLength='30' />
-							</Form.Item>
-						</Col>
-						<Col span={5} key={1}>
-							<Form.Item label="标准药品名称" name="uniqueName">
-								<Input placeholder="请输入" autoComplete='off' allowClear maxLength='30' />
-							</Form.Item>
-						</Col>
-						<Col span={5} key={2}>
-							<Form.Item label="药品剂型" name="form">
-								<Input placeholder="请输入" autoComplete='off' allowClear maxLength='30' />
-							</Form.Item>
-						</Col>
-						<Col span={5} key={3}>
-							<Form.Item id="groupTypeval" label="是否匹配" name="isMatch">
-								<Select
-									showSearch
-									optionFilterProp="children"
-									// onSearch={onSearch}
-									// onFocus={onFocus}
-									placeholder="全部"
-								>
-									<Option value={''} key={-1}>全部</Option>
-									<Option value={0} key={0}>未匹配</Option>
-									<Option value={1} key={1}>已匹配</Option>
-								</Select>
-							</Form.Item>
-						</Col>
-						<Col span={5} key={4}>
-							<Form.Item label="标准术语状态" name="status">
-								<Select
-									showSearch
-									optionFilterProp="children"
-									placeholder="全部"
-								>
-									<Option value={''} key={-1}>全部</Option>
-									<Option value={0} key={0}>禁用</Option>
-									<Option value={1} key={1}>启用</Option>
-								</Select>
-							</Form.Item>
-						</Col>
-						<Col span={5} key={5}>
-							<Form.Item label="剂型术语状态" name="formStatus">
-								<Select
-									showSearch
-									optionFilterProp="children"
-									placeholder="全部"
-								>
-									<Option value={''} key={-1}>全部</Option>
-									<Option value={0} key={0}>禁用</Option>
-									<Option value={1} key={1}>启用</Option>
-								</Select>
-							</Form.Item>
-						</Col>
-						<Col span={5} key={6}>
-							<Form.Item>
-								<Button type="primary" htmlType="submit">
-									查询
-								</Button>
-								<Button onClick={onReset}>
-									重置
-								</Button>
-							</Form.Item>
-						</Col>
-					</Row>
-				</Form>
-			</div>
+  function addCancel() {
+    setRevise(false)
+    setVisible(false)
+    setUnsaved(false)
+    setFormData(null)
+  }
 
-			<Table
-				rowSelection={{ type: 'checkbox', ...rowSelection, }}
-				columns={columns}
-				dataSource={DrugList}
-				rowKey={record => record.id}
-				pagination={{
-					current: current,
-					pageSize: size,
-					size: 'small',
-					showSizeChanger: true,
-					pageSizeOptions: ['15', '30', '60', '120'],
-					showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
-					onShowSizeChange: (current, pageSize) => onSizeChange(current, pageSize), // 改变每页数量时更新显示
-					onChange: (page, pageSize) => changePage(page, pageSize),//点击页码事件
-					total: total,
-					showQuickJumper: true,
-				}} />
-			{visible && formData ?
-				<Modal
-					title={title}
-					okText='确定'
-					cancelText='关闭'
-					width={'45%'}
-					visible={visible}
-					onCancel={cancel}
-					footer={null}
-					forceRender={true}
-					maskClosable={false}
-				>
-					<DrugContext.Provider value={{ type, formData }}>
-						<AddDrug DrugChange={DrugChange} cancel={cancel} isChange={isChange} />
-					</DrugContext.Provider>
-					<Modal
-						maskClosable={false}
-						title="提示"
-						okText='确定'
-						cancelText='关闭'
-						width={400}
-						visible={unsaved}
-						onOk={addCancel}
-						onCancel={unsavedCancel}
-					>
-						<p>当前数据未保存 是否确认关闭?</p>
-					</Modal>
-				</Modal>
-				: ''}
-			<Modal
-				maskClosable={false}
-				title="提示"
-				okText='确定'
-				cancelText='关闭'
-				width={400}
-				visible={msvisible}
-				onOk={delDrugById}
-				onCancel={handleCancel}
-			>
-				<p>药品信息删除后将无法恢复,确认删除这{Drugid.length}条信息。</p>
-			</Modal>
-			<Modal
-				maskClosable={false}
-				destroyOnClose={true}
-				title="提示"
-				width={400}
-				visible={visible1}
-				onCancel={handleCancel1}
-				footer={<Button key="back" onClick={handleCancel1}>关闭</Button>}
-			>
-				<div style={{ marginBottom: 10 + 'px' }}>
-					<span>药品信息导入:</span>
-					<Upload {...props}><Button type="primary" >导入目录</Button></Upload>
-				</div>
-				{uploadStatus === 1 ? (<span style={{ color: '#00AF71' }}>{uploadTip}</span>) : (<span style={{ color: '#E3505B' }}>{tipMap[uploadStatus]}</span>)}
-			</Modal>
-			<Modal
-				maskClosable={false}
-				destroyOnClose={true}
-				title="提示"
-				okText='保存'
-				cancelText='关闭'
-				width={800}
-				visible={visible2}
-				onCancel={handleCancel2}
-				onOk={saveMatching}
-			>
-				<MatchDrug row={formData} onChange={matchChange}></MatchDrug>
-			</Modal>
-		</div>
-	)
+  function unsavedCancel() {
+    setUnsaved(false)
+  }
+
+  //新增修改 保存
+  function DrugChange() {
+    setRevise(false)
+    setVisible(false)
+    getDrugPage();
+  }
+  function saveMatching() {
+    post(api.matchingDrug, saveParams).then((res) => {
+      setvisible2(false);
+      if (res.data.code === 200) {
+        message.success("匹配成功");
+        getDrugPage();
+      } else {
+        message.warning(res.data.message || "匹配失败,请重试");
+      }
+    }).catch((error) => {
+      message.warning(error.message || "接口出错,请重试",);
+    })
+  }
+  const rowSelection = {
+    onChange: (selectedRowKeys, selectedRows) => {
+      console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
+      setDrugid(selectedRowKeys)
+    }
+  };
+  //导入模板
+  const props = {
+    name: 'file',
+    accept: ".xls",
+    showUploadList: false,
+    action: api.importDrug,
+    headers: {
+      authorization: 'authorization-text',
+    },
+    onChange(info) {
+      const { response, status } = info.file;
+      if (status === 'done') {
+        if (response.code === 200) {
+          getDrugPage();		//刷新列表
+          //setvisible1(false);			//关闭导入弹窗
+          //message.success(`${info.file.name} 导入成功`);
+          setUploadStatus(1);
+          setUploadTip(response.data);
+        } else {
+          //message.error(`${info.file.name} 导入失败.`);
+          setUploadStatus(2);
+        }
+      } else if (status === 'error') {
+        setUploadStatus(3);
+      }
+    },
+  };
+  function matchChange(data) {
+    setSaveParams(data);
+  }
+  const columns = [
+    { title: '序号', dataIndex: 'index', render: (text, record, index) => (current - 1) * params.size + index + 1 },
+    { title: '医院药品名称', dataIndex: 'name', },
+    { title: '国药准字', dataIndex: 'approvalNum', },
+    { title: '药品剂型', dataIndex: 'dosageForm', },
+    { title: '标准药品名称', dataIndex: 'standard', },
+    { title: '是否匹配', dataIndex: 'isMapping', },
+    {
+      title: '操作', dataIndex: 'key', render: (text, record) => (
+        <Space size="middle">
+          <a onClick={e => showModal('修改字典', true, 3, record)}>修改</a>
+          <a onClick={e => match(record)}>匹配</a>
+        </Space>
+      )
+    }
+  ]
+  return (
+    <div className="wrapper">
+      <div className="filter-box">
+        <Form
+          form={form}
+          name="normal_login"
+          onFinish={onFinish}
+          initialValues={{ isMapping: '' }}
+        >
+          <Row gutter={24}>
+            <Col span={5} key={0}>
+              <Form.Item label="医院药品名称" name="name">
+                <Input placeholder="请输入" autoComplete='off' allowClear />
+              </Form.Item>
+            </Col>
+            <Col span={5} key={1}>
+              <Form.Item label="国药准字" name="approvalNum">
+                <Input placeholder="请输入" autoComplete='off' allowClear />
+              </Form.Item>
+            </Col>
+            <Col span={5} key={2}>
+              <Form.Item label="药品剂型" name="dosageForm">
+                <Input placeholder="请选择" autoComplete='off' allowClear />
+              </Form.Item>
+            </Col>
+            <Col span={5} key={3}>
+              <Form.Item label="标准药品名称" name="standard">
+                <Input placeholder="请输入" autoComplete='off' allowClear />
+              </Form.Item>
+            </Col>
+            <Col span={4} key={4}>
+              <Form.Item id="groupTypeval" label="是否匹配" name="isMapping">
+                <Select
+                  showSearch
+                  optionFilterProp="children"
+                  // onSearch={onSearch}
+                  // onFocus={onFocus}
+                  placeholder="全部"
+                >
+                  <Option value={''} key={-1}>全部</Option>
+                  <Option value={0} key={0}>未匹配</Option>
+                  <Option value={1} key={1}>已匹配</Option>
+                </Select>
+              </Form.Item>
+            </Col>
+            <Col span={5} key={5}>
+              <Form.Item>
+                <Button type="primary" htmlType="submit">
+                  查询
+                </Button>
+                <Button onClick={onReset}>
+                  重置
+                </Button>
+              </Form.Item>
+            </Col>
+          </Row>
+        </Form>
+      </div>
+
+      <div className="table">
+        <div className="table-header">
+          <h2 className="table-title">药品信息维护</h2>
+          <Row gutter={12}>
+            <Col key={0}>
+              <Button type="primary" icon={<PlusOutlined />} onClick={e => showModal('新增', true, 1)}>新增</Button>
+            </Col>
+            <Col key={1}>
+              <Button onClick={e => messageBox()} type="primary" danger>删除</Button>
+            </Col>
+            <Col key={2}>
+              <Button type="primary" onClick={e => ImportBox()}>导入</Button>
+            </Col>
+          </Row>
+        </div>
+
+        <Table
+          rowSelection={{ type: 'checkbox', ...rowSelection, }}
+          columns={columns}
+          dataSource={DrugList}
+          rowKey={record => record.id}
+          pagination={{
+            current: current,
+            pageSize: size,
+            size: 'small',
+            showSizeChanger: true,
+            pageSizeOptions: ['15', '30', '60', '120'],
+            showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
+            onShowSizeChange: (current, pageSize) => onSizeChange(current, pageSize), // 改变每页数量时更新显示
+            onChange: (page, pageSize) => changePage(page, pageSize),//点击页码事件
+            total: total,
+            showQuickJumper:true,
+          }} />
+      </div>
+      {visible && formData ?
+        <Modal
+          title={title}
+          okText='确定'
+          cancelText='关闭'
+          width={'45%'}
+          visible={visible}
+          onCancel={cancel}
+          footer={null}
+          forceRender={true}
+          maskClosable={false}
+        >
+          <DrugContext.Provider value={{ type, formData }}>
+            <AddDrug DrugChange={DrugChange} cancel={cancel} isChange={isChange} />
+          </DrugContext.Provider>
+          <Modal
+            maskClosable={false}
+            title="提示"
+            okText='确定'
+            cancelText='关闭'
+            width={400}
+            visible={unsaved}
+            onOk={addCancel}
+            onCancel={unsavedCancel}
+          >
+            <p>当前数据未保存 是否确认关闭?</p>
+          </Modal>
+        </Modal>
+        : ''}
+      <Modal
+        maskClosable={false}
+        title="提示"
+        okText='确定'
+        cancelText='关闭'
+        width={400}
+        visible={msvisible}
+        onOk={delDrugById}
+        onCancel={handleCancel}
+      >
+        <p>药品信息删除后将无法恢复,确认删除这{Drugid.length}条信息。</p>
+      </Modal>
+      <Modal
+        maskClosable={false}
+        destroyOnClose={true}
+        title="提示"
+        width={400}
+        visible={visible1}
+        onCancel={handleCancel1}
+        footer={<Button key="back" onClick={handleCancel1}>关闭</Button>}
+      >
+        <div style={{ marginBottom: 10 + 'px' }}>
+          <span>药品信息导入:</span>
+          <Upload {...props}><Button type="primary" >导入目录</Button></Upload>
+        </div>
+        {uploadStatus === 1 ? (<span style={{ color: '#00AF71' }}>{uploadTip}</span>) : (<span style={{ color: '#E3505B' }}>{tipMap[uploadStatus]}</span>)}
+      </Modal>
+      <Modal
+        maskClosable={false}
+        destroyOnClose={true}
+        title="提示"
+        okText='保存'
+        cancelText='关闭'
+        width={800}
+        visible={visible2}
+        onCancel={handleCancel2}
+        onOk={saveMatching}
+      >
+        <MatchDrug row={formData} onChange={matchChange}></MatchDrug>
+      </Modal>
+    </div>
+  )
 }
 
 export default DrugManager;

+ 124 - 0
src/components/SurgeryManager/addSurg.js

@@ -0,0 +1,124 @@
+import React, { useContext} from 'react';
+import { Form, Input, Button, message, Space } from 'antd';
+import apiObj from '@api/index';
+import { getCookie,setCookie } from '@utils/index';
+import SurgContext from './surg-context';
+const { post, api } = apiObj;
+
+function AddSurg(props) {
+  const [form] = Form.useForm();
+  const { type, formData} = useContext(SurgContext);
+  const initialValues = formData;
+
+  const onFinish = values => {
+	  values.status ? values.status=1:values.status=0
+    let params = values
+    if (type == 3) {
+	  params.id=initialValues.id
+      upSurgById(params)
+    } else {
+      addSurg(params)
+    }
+
+  };
+  function addSurg(param) {
+    const hisId = getCookie("hospitalId");
+	const params ={
+		hospitalId:hisId,
+		...param
+	}
+	post(api.addOperation, params).then((res) => {
+      if (res.data.code === 200) {
+        props.SurgChange()
+        message.success(res.data.message);
+      } else {
+        message.error(res.data.message);
+      }
+    })
+  }
+  function upSurgById(param) {
+	  const hisId = getCookie("hospitalId");
+	  const params ={
+	  	hospitalId:hisId,
+	  	...param
+	  }
+    post(api.upOperationById, params).then((res) => {
+      if (res.data.code === 200) {
+        props.SurgChange()
+        message.success(res.data.message);
+      } else {
+        message.error(res.data.message);
+      }
+    })
+  }
+  function cancel() {
+  	props.cancel()
+  }
+  
+  function onValuesChange() {
+  	props.isChange(form.isFieldsTouched())
+  }
+
+  return (
+    <>
+      <Form
+        labelCol={{ span: 7 }}
+        wrapperCol={{ span: 16 }}
+        form={form}
+        name="register"
+        onFinish={onFinish}
+        initialValues={initialValues}
+		onValuesChange={onValuesChange}
+      >
+
+        <Form.Item
+          name="name"
+          label="医院手术/操作名称"
+          rules={[
+            {
+              required: true,
+              message: '请输入医院手术/操作名称',
+            },
+          ]}
+        >
+          {type == 3 ?
+		    <Input  autoComplete='off'/>
+            :
+            <Input placeholder="请输入" autoComplete='off'/>
+          }
+
+        </Form.Item>
+		<Form.Item
+		  name="code"
+		  label="手术和操作代码"
+		  rules={[
+		    {
+		      required: true,
+		      message: '请输入手术和操作代码',
+		    },
+		  ]}
+		>
+		  {type == 3 ?
+		    <Input  autoComplete='off'/>
+		    :
+		    <Input placeholder="请输入" autoComplete='off'/>
+		  }
+		
+		</Form.Item>
+          <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
+            <Space size="middle">
+              <Button htmlType="button" onClick={e => cancel()}>
+                取消
+            </Button>
+              <Button type="primary" htmlType="submit">
+                保存
+            </Button>
+            </Space>
+          </Form.Item>
+
+      </Form>
+    </>
+  );
+}
+
+export default AddSurg;

+ 393 - 332
src/components/SurgeryManager/index.js

@@ -1,351 +1,412 @@
 import React, { useState, useEffect } from 'react';
-import { useSelector } from 'react-redux';
-import { Empty, ConfigProvider, Form, Input, Button, Table, Select, Space, Modal, message, Row, Col } from 'antd';
+import { Form, Input, Button, Table, Select, Pagination, Space, Modal, message, Row, Col, Upload } from 'antd';
 import { PlusOutlined } from '@ant-design/icons';
-import AddTerm from '../DiagManager/addDiag'
+import AddSurg from './addSurg'
+import MatchSurg from './MatchSurg.js'
 import '@common/common.less';
 import apiObj from '@api/index';
+import SurgContext from './surg-context';
 
 const { post, api } = apiObj;
 const { Option } = Select;
 //获取列表
 function SurgManager() {
-	const { surgeryNum } = useSelector((state) => {
-		return state.userInfo;
-	});
-	useEffect(() => {
-		setSize(15)
-		setCurrent(1)
-		form.resetFields();
-		getSurgeryPage();
-	}, [surgeryNum]);
-	const [SurgList, setSurgList] = useState([]);//当前页列表数据
-	const [Surgid, setSurgid] = useState([]);//当前操作行id
-	const [title, setTitle] = useState("");//新增/修改的弹窗标题
-	const [visible, setVisible] = useState(false);//新增修改 弹窗
-	const [loading, setloading] = useState(true);//是否显示加载中
-	const [flag, setFlag] = useState(false);//新增1或修改3
-	const [delvisible, setDelvisible] = useState(false);//删除 弹窗
-	const [formData, setFormData] = useState({});//当前行数据
-	const [size, setSize] = useState(15);//每页显示条数
-	const [total, setTotal] = useState(0);
-	const [current, setCurrent] = useState(1);//当前页
-	const [params, setParams] = useState({
-		pages: 1,
-		current: 1,
-		size: 15
-	});
-	const [form] = Form.useForm();
+  useEffect(() => {
+    getOperationPage();
+  }, []);
+  const [SurgList, setSurgList] = useState([]);//当前页列表数据
+  const [Surgid, setSurgid] = useState([]);//当前列表id
+  const [title, setTitle] = useState("");//数据总量
+  const [visible, setVisible] = useState(false);//新增修改 弹窗
+  const [msvisible, setMsvisible] = useState(false);//删除 弹窗
+  const [visible1, setvisible1] = useState(false);//导入 弹窗
+  const [visible2, setvisible2] = useState(false);//匹配 弹窗
+  const [unsaved, setUnsaved] = useState(false);//修改未保存弹窗
+  const [revise, setRevise] = useState(false);//是否修改 新增修改内容
+  const [type, setType] = useState("");
+  const [formData, setFormData] = useState(null);//当前行数据
+  const [size, setSize] = useState(15);//每页显示条数
+  const [total, setTotal] = useState(0);
+  const [current, setCurrent] = useState(1);//当前页
+  const [uploadStatus, setUploadStatus] = useState(0);//导入状态,0初始,1成功,2格式错误,3导入数据错误
+  const [uploadTip, setUploadTip] = useState("");		//导入状态提示语
+  const [saveParams, setSaveParams] = useState({});		//匹配诊断选中
+  const [params, setParams] = useState({
+    pages: 1,
+    current: 1,
+    size: 15
+  });
+  const [form] = Form.useForm();
+  const tipMap = {
+    0: '提示:EXCEL导入,模板样式及数据请在【朗通云平台-CDSS数据维护-医学术语关联维护】中导出获取。',
+    2: "模板格式错误,模板样式及数据请在【朗通云平台-CDSS数据维护-医学术语关联维护】中导出获取",
+    3: '模板导入失败,失败原因已在Excel中标识并自动下载,请检查后重新导入',
+  };
 
-	let data = {
-		pages: 1,
-		current: 1,
-		size: 15
-	}
-	//新增/修改 弹窗flag=1新增,3修改
-	const showModal = (name, flag1, Surgrow) => {
-		setVisible(true);
-		setFlag(flag1)
-		setTitle(name); console.log(flag)
-		if (flag1 === 1) {
-			setFormData({
-				status: 1,
-				uniqueName: '',
-				hisName: ''
-			})
-		} else if (flag1 === 3) {
-			console.log(33, Surgrow)
-			setFormData(Surgrow)
-		}
-	}
-	//表格数据
-	function getSurgeryPage(param) {  //type(必填): 类型:1-化验、3-辅检、4-诊断、5-药品、6-手术和操作
-		const hospitalId = localStorage.getItem('hospitalId')
-		setloading(true)
-		const hide = message.loading('加载中...', 0);
-		post(api.getTermPage, { ...(param || params), type: 6, hospitalId: hospitalId }).then((res) => {
-			hide()
-			if (res.data.code === 200) {
-				const data = res.data.data;
-				setSurgList(data.records);
-				setTotal(data.total)
-				setloading(false)
-			}
-		})
-	}
-	function showDelModal(id) {
-		setDelvisible(true);
-		setSurgid(id);
-	}
-	//删除
-	function delSurgeryById() {
-		post(api.deleteRecord, { id: Surgid }).then((res) => {
-			setDelvisible(false);
-			if (res.data.code === 200) {
-				//刷新列表
-				const totalPage = Math.ceil((total - 1) / size);
-				//将当前页码与删除数据之后的总页数进行比较,避免当前页码不存在
-				const pagenum =
-					params.current > totalPage ? totalPage : params.current;
-				//避免pagenum变为0
-				params.current = pagenum < 1 ? 1 : pagenum;
-				setParams(params)
-				getSurgeryPage();
-				setSurgid("");
-				message.success("删除成功");
-			} else {
-				message.warning(res.data.msg || '操作失败');
-			}
-		}).catch(() => {
-			setDelvisible(false);
-			message.error("接口出错");
-		});
-	}
-	//每页显示条数切换
-	function onSizeChange(current, pageSize) {
-		params.current = current
-		params.size = pageSize
-		setSize(pageSize)
-		setCurrent(current)
-		setParams(params)
-	}
-	//翻页
-	function changePage(page, pageSize) {
-		params.current = page
-		params.size = pageSize
-		setCurrent(page)
-		setParams(params)
-		getSurgeryPage()
-	}
-	//筛选查询
-	const onFinish = (value) => {
-		params.current = 1
-		const param = {
-			...params,
-			...value
-		}
-		setCurrent(1)
-		setParams(param)
-		getSurgeryPage(param);
-	};
-	//重置
-	const onReset = () => {
-		setSize(15)
-		setCurrent(1)
-		setParams(data)
-		form.resetFields();
-		getSurgeryPage(data);
-	};
+  let data = {
+    pages: 1,
+    current: 1,
+    size: size
+  }
+  //新增 弹窗
+  const showModal = (name, type, flag, Surgrow) => {
+    setVisible(type);
+    setTitle(name);
+    setType(flag)
+    if (flag == 1) {
+      setFormData({
+        status: '1'
+      })
+    }
+    if (flag == 3) {
+      setFormData(Surgrow)
+      getOperationPage()
+    }
+  }
+  //表格数据
+  function getOperationPage(param) {
+    post(api.getOperationPage, param || params).then((res) => {
+      if (res.data.code === 200) {
+        const data = res.data.data;
+        setSurgList(data.records);
+        setTotal(data.total)
+      }
+    })
+  }
 
-	//删除 提示框取消或关闭
-	function handleCancel() {
-		setDelvisible(false);
-	}
+  //删除
+  function delOperationById() {
+    post(api.delOperationById, { ids: Surgid }).then((res) => {
+      setMsvisible(false);
+      if (res.data.code === 200) {
+        getOperationPage();
+        setSurgid([])
+        message.success("操作成功");
+      } else {
+        message.warning(res.data.msg || '操作失败');
+      }
+    }).catch(() => {
+      setMsvisible(false);
+      message.error("接口出错");
+    });
+  }
+  //每页显示条数切换
+  function onSizeChange(current, pageSize) {
+    params.current = current
+    params.size = pageSize
+    setSize(pageSize)
+    setCurrent(current)
+    setParams(params)
+    getOperationPage()
+  }
+  //翻页
+  function changePage(page, pageSize) {
+    params.current = page
+    params.size = pageSize
+    setCurrent(page)
+    setParams(params)
+    getOperationPage()
+  }
+  const onFinish = (value) => {
+    const param = {
+      ...data,
+      ...value
+    }
+    setCurrent(1)
+    setParams(param)
+    getOperationPage(param);
+  };
+  //重置
+  const onReset = () => {
+    setCurrent(1)
+    setParams(data)
+    form.resetFields();
+    getOperationPage(data);
+  };
+  //打开导入弹窗
+  const ImportBox = () => {
+    setvisible1(true)
+  }
+  //导入弹窗取消或关闭
+  function handleCancel1() {
+    setvisible1(false);
+    setUploadStatus(0);
+  }
+  //打开匹配弹窗
+  function match(row) {
+    setvisible2(true)
+    setFormData(row)
+  }
+  //导入弹窗取消或关闭
+  function handleCancel2() {
+    setvisible2(false);
+  }
+  const messageBox = () => {
+    if (!Surgid.length) {
+      message.warning("请先选择要删除的记录~", 1);
+      return;
+    }
+    setMsvisible(true)
+  }
+  //删除 提示框取消或关闭
+  function handleCancel() {
+    setMsvisible(false);
+  }
 
-	//新增修改 取消或关闭
-	function cancel() {
-		setVisible(false)
-		setFormData([])
-	}
+  //新增修改 取消或关闭
+  function cancel() {
+    if (revise) {
+      setUnsaved(true)
+    } else {
+      setVisible(false)
+      setFormData(null)
+    }
+  }
 
-	function saveMatching(saveParams) {
-		post(api.saveOrUpdateRecord, saveParams).then((res) => {
-			if (res.data.code === 200) {
-				message.success("匹配成功");
-				setVisible(false);
-				setFormData([])
-				getSurgeryPage();
-			} else {
-				message.warning(res.data.message || "匹配失败,请重试");
-			}
-		}).catch((error) => {
-			message.warning(error.message || "接口出错,请重试",);
-		})
-	}
-	const renderEmpty = () => (
-		<Empty
-			imageStyle={{
-				height: 0,
-			}}
-			description={<span></span>}
-		>
-		</Empty>
-	)
+  function isChange(a) {
+    setRevise(a)
+  }
 
-	const columns = [
-		{ title: '序号', dataIndex: 'index', render: (text, record, index) => (current - 1) * params.size + index + 1 },
-		{ title: '操作时间', dataIndex: 'gmtModified', },
-		{ title: '医院手术/操作名称', dataIndex: 'hisName', },
-		{ title: '手术/操作代码', dataIndex: 'code', },
-		{ title: '标准手术/操作名称', dataIndex: 'uniqueName', },
-		{
-			title: '标准术语状态', dataIndex: 'status', render: (text, record) => {
-				return record.status === 1 ? '启用' : record.status === 0 ? '禁用' : '';
-			}
-		},
-		{
-			title: '是否匹配', dataIndex: 'isMatch', render: (text, record) => {
-				return record.isMatch === 1 ? '已匹配' : '未匹配';
-			}
-		},
-		{
-			title: '操作', dataIndex: 'key', render: (text, record) => (
-				<Space size="middle">
-					<a onClick={e => showModal('修改手术/操作信息', 3, record)}>修改</a>
-					<a style={{ color: "#FF4D4D" }} onClick={() => showDelModal(record.id)}>删除</a>
-				</Space>
-			)
-		}
-	]
-	return (
-		<div className="wrapper">
-			<div className="filter-box">
-				<Form
-					form={form}
-					name="normal_login"
-					onFinish={onFinish}
-				>
-					<Row gutter={24}>
-						<Col span={5} key={0}>
-							<Form.Item label="医院手术/操作名称" name="hisName">
-								<Input placeholder="请输入" autoComplete='off' allowClear maxLength='30' />
-							</Form.Item>
-						</Col>
-						<Col span={5} key={1}>
-							<Form.Item label="标准手术/操作名称" name="uniqueName">
-								<Input placeholder="请输入" autoComplete='off' allowClear maxLength='30' />
-							</Form.Item>
-						</Col>
-						<Col span={5} key={2}>
-							<Form.Item id="groupTypeval" label="是否匹配" name="isMatch">
-								<Select
-									showSearch
-									optionFilterProp="children"
-									// onSearch={onSearch}
-									// onFocus={onFocus}
-									placeholder="全部"
-								>
-									<Option value={''} key={-1}>全部</Option>
-									<Option value={0} key={0}>未匹配</Option>
-									<Option value={1} key={1}>已匹配</Option>
-								</Select>
-							</Form.Item>
-						</Col>
-						<Col span={5} key={3}>
-							<Form.Item label="标准术语状态" name="status">
-								<Select
-									showSearch
-									optionFilterProp="children"
-									placeholder="全部"
-								>
-									<Option value={''} key={-1}>全部</Option>
-									<Option value={0} key={0}>禁用</Option>
-									<Option value={1} key={1}>启用</Option>
-								</Select>
-							</Form.Item>
-						</Col>
-						<Col span={4} key={4}>
-							<Form.Item>
-								<Button type="primary" htmlType="submit">
-									查询
-								</Button>
-								<Button onClick={onReset}>
-									重置
-								</Button>
-							</Form.Item>
-						</Col>
-					</Row>
-				</Form>
-			</div>
+  function addCancel() {
+    setRevise(false)
+    setVisible(false)
+    setUnsaved(false)
+    setFormData(null)
+  }
 
-			<Table
-				rowSelection={{ type: 'checkbox', ...rowSelection, }}
-				columns={columns}
-				dataSource={SurgList}
-				rowKey={record => record.id}
-				pagination={{
-					current: current,
-					pageSize: size,
-					size: 'small',
-					showSizeChanger: true,
-					pageSizeOptions: ['15', '30', '60', '120'],
-					showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
-					onShowSizeChange: (current, pageSize) => onSizeChange(current, pageSize), // 改变每页数量时更新显示
-					onChange: (page, pageSize) => changePage(page, pageSize),//点击页码事件
-					total: total,
-					showQuickJumper: true,
-				}} />
+  function unsavedCancel() {
+    setUnsaved(false)
+  }
 
-			{visible && formData ?
-				<Modal maskClosable={false}
-					title={title}
-					okText='确定'
-					cancelText='关闭'
-					width={'45%'}
-					visible={visible}
-					onCancel={cancel}
-					footer={null}
-					forceRender={true}
-				>
-					<SurgContext.Provider value={{ type, formData }}>
-						<AddSurg SurgChange={SurgChange} cancel={cancel} isChange={isChange} />
-					</SurgContext.Provider>
-					<Modal
-						title="提示"
-						okText='确定'
-						cancelText='关闭'
-						width={400}
-						visible={unsaved}
-						onOk={addCancel}
-						onCancel={unsavedCancel}
-						maskClosable={false}
-					>
-						<p>当前数据未保存 是否确认关闭?</p>
-					</Modal>
-				</Modal>
-				: ''}
-			<Modal
-				maskClosable={false}
-				title="提示"
-				okText='确定'
-				cancelText='关闭'
-				width={400}
-				visible={msvisible}
-				onOk={delOperationById}
-				onCancel={handleCancel}
-			>
-				<p>诊断信息删除后将无法恢复,确认删除这{Surgid.length}条信息。</p>
-			</Modal>
-			<Modal
-				maskClosable={false}
-				destroyOnClose={true}
-				title="提示"
-				width={400}
-				visible={visible1}
-				onCancel={handleCancel1}
-				footer={<Button key="back" onClick={handleCancel1}>关闭</Button>}
-			>
-				<div style={{ marginBottom: 10 + 'px' }}>
-					<span>手术信息导入:</span>
-					<Upload {...props}><Button type="primary" >导入目录</Button></Upload>
-				</div>
-				{uploadStatus === 1 ? (<span style={{ color: '#00AF71' }}>{uploadTip}</span>) : (<span style={{ color: '#E3505B' }}>{tipMap[uploadStatus]}</span>)}
-			</Modal>
-			<Modal
-				maskClosable={false}
-				destroyOnClose={true}
-				title="提示"
-				okText='保存'
-				cancelText='关闭'
-				width={800}
-				visible={visible2}
-				onCancel={handleCancel2}
-				onOk={saveMatching}
-			>
-				<MatchSurg row={formData} onChange={matchChange}></MatchSurg>
-			</Modal>
-		</div>
-	)
+  //新增修改 保存
+  function SurgChange() {
+    setRevise(false)
+    setVisible(false)
+    getOperationPage();
+  }
+  const rowSelection = {
+    onChange: (selectedRowKeys, selectedRows) => {
+      console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
+      setSurgid(selectedRowKeys)
+    }
+  };
+  //导入模板
+  const props = {
+    name: 'file',
+    accept: ".xls",
+    showUploadList: false,
+    action: api.importOperation,
+    headers: {
+      authorization: 'authorization-text',
+    },
+    onChange(info) {
+      const { response, status } = info.file;
+      if (status === 'done') {
+        if (response.code === 200) {
+          getOperationPage();		//刷新列表
+          //setvisible1(false);			//关闭导入弹窗
+          //message.success(`${info.file.name} 导入成功`);
+          setUploadStatus(1);
+          setUploadTip(response.data);
+        } else {
+          //message.error(`${info.file.name} 导入失败.`);
+          setUploadStatus(2);
+        }
+      } else if (status === 'error') {
+        setUploadStatus(3);
+      }
+    },
+  };
+
+  function saveMatching() {
+    post(api.matchingOperation, saveParams).then((res) => {
+      setvisible2(false);
+      if (res.data.code === 200) {
+        message.success("匹配成功");
+        getOperationPage();
+      } else {
+        message.warning(res.data.message || "匹配失败,请重试");
+      }
+    }).catch((error) => {
+      message.warning(error.message || "接口出错,请重试",);
+    })
+  }
+  function matchChange(data) {
+    setSaveParams(data);
+  }
+  const columns = [
+    { title: '序号', dataIndex: 'index', render: (text, record, index) => (current - 1) * params.size + index + 1 },
+    { title: '医院手术/操作名称', dataIndex: 'name', },
+    { title: '手术和操作代码', dataIndex: 'code', },
+    { title: '标准手术/操作名称', dataIndex: 'standard', },
+    { title: '是否匹配', dataIndex: 'isMapping', },
+    {
+      title: '操作', dataIndex: 'key', render: (text, record) => (
+        <Space size="middle">
+          <a onClick={e => showModal('修改字典', true, 3, record)}>修改</a>
+          <a onClick={e => match(record)}>匹配</a>
+        </Space>
+      )
+    }
+  ]
+  return (
+    <div className="wrapper">
+      <div className="filter-box">
+        <Form
+          form={form}
+          name="normal_login"
+          onFinish={onFinish}
+          initialValues={{ isMapping: '' }}
+        >
+          <Row gutter={24}>
+            <Col span={5} key={0}>
+              <Form.Item label="医院手术/操作名称" name="name">
+                <Input placeholder="请输入" autoComplete='off' allowClear />
+              </Form.Item>
+            </Col>
+            <Col span={5} key={1}>
+              <Form.Item label="手术和操作代码" name="code">
+                <Input placeholder="请输入" autoComplete='off' allowClear />
+              </Form.Item>
+            </Col>
+            <Col span={5} key={2}>
+              <Form.Item label="标准手术/操作名称" name="standard">
+                <Input placeholder="请输入" autoComplete='off' allowClear />
+              </Form.Item>
+            </Col>
+            <Col span={4} key={3}>
+              <Form.Item id="groupTypeval" label="是否匹配" name="isMapping">
+                <Select
+                  showSearch
+                  optionFilterProp="children"
+                  // onSearch={onSearch}
+                  // onFocus={onFocus}
+                  placeholder="全部"
+                >
+                  <Option value={''} key={-1}>全部</Option>
+                  <Option value={0} key={0}>未匹配</Option>
+                  <Option value={1} key={1}>已匹配</Option>
+                </Select>
+              </Form.Item>
+            </Col>
+            <Col span={5} key={4}>
+              <Form.Item>
+                <Button type="primary" htmlType="submit">
+                  查询
+                </Button>
+                <Button onClick={onReset}>
+                  重置
+                </Button>
+              </Form.Item>
+            </Col>
+          </Row>
+        </Form>
+      </div>
+
+      <div className="table">
+        <div className="table-header">
+          <h2 className="table-title">手术信息维护</h2>
+          <Row gutter={12}>
+            <Col key={0}>
+              <Button type="primary" icon={<PlusOutlined />} onClick={e => showModal('新增', true, 1)}>新增</Button>
+            </Col>
+            <Col key={1}>
+              <Button onClick={e => messageBox()} type="primary" danger>删除</Button>
+            </Col>
+            <Col key={2}>
+              <Button type="primary" onClick={e => ImportBox()}>导入</Button>
+            </Col>
+          </Row>
+        </div>
+
+        <Table
+          rowSelection={{ type: 'checkbox', ...rowSelection, }}
+          columns={columns}
+          dataSource={SurgList}
+          rowKey={record => record.id}
+          pagination={{
+            current: current,
+            pageSize: size,
+            size: 'small',
+            showSizeChanger: true,
+            pageSizeOptions: ['15', '30', '60', '120'],
+            showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
+            onShowSizeChange: (current, pageSize) => onSizeChange(current, pageSize), // 改变每页数量时更新显示
+            onChange: (page, pageSize) => changePage(page, pageSize),//点击页码事件
+            total: total,
+            showQuickJumper:true,
+          }} />
+      </div>
+      {visible && formData ?
+        <Modal maskClosable={false}
+          title={title}
+          okText='确定'
+          cancelText='关闭'
+          width={'45%'}
+          visible={visible}
+          onCancel={cancel}
+          footer={null}
+          forceRender={true}
+        >
+          <SurgContext.Provider value={{ type, formData }}>
+            <AddSurg SurgChange={SurgChange} cancel={cancel} isChange={isChange} />
+          </SurgContext.Provider>
+          <Modal
+            title="提示"
+            okText='确定'
+            cancelText='关闭'
+            width={400}
+            visible={unsaved}
+            onOk={addCancel}
+            onCancel={unsavedCancel}
+            maskClosable={false}
+          >
+            <p>当前数据未保存 是否确认关闭?</p>
+          </Modal>
+        </Modal>
+        : ''}
+      <Modal
+        maskClosable={false}
+        title="提示"
+        okText='确定'
+        cancelText='关闭'
+        width={400}
+        visible={msvisible}
+        onOk={delOperationById}
+        onCancel={handleCancel}
+      >
+        <p>诊断信息删除后将无法恢复,确认删除这{Surgid.length}条信息。</p>
+      </Modal>
+      <Modal
+        maskClosable={false}
+        destroyOnClose={true}
+        title="提示"
+        width={400}
+        visible={visible1}
+        onCancel={handleCancel1}
+        footer={<Button key="back" onClick={handleCancel1}>关闭</Button>}
+      >
+        <div style={{ marginBottom: 10 + 'px' }}>
+          <span>手术信息导入:</span>
+          <Upload {...props}><Button type="primary" >导入目录</Button></Upload>
+        </div>
+        {uploadStatus === 1 ? (<span style={{ color: '#00AF71' }}>{uploadTip}</span>) : (<span style={{ color: '#E3505B' }}>{tipMap[uploadStatus]}</span>)}
+      </Modal>
+      <Modal
+        maskClosable={false}
+        destroyOnClose={true}
+        title="提示"
+        okText='保存'
+        cancelText='关闭'
+        width={800}
+        visible={visible2}
+        onCancel={handleCancel2}
+        onOk={saveMatching}
+      >
+        <MatchSurg row={formData} onChange={matchChange}></MatchSurg>
+      </Modal>
+    </div>
+  )
 }
 
 export default SurgManager;

+ 4 - 0
src/components/SurgeryManager/surg-context.js

@@ -0,0 +1,4 @@
+import { createContext } from 'react';
+const SurgContext = createContext(null);
+
+export default SurgContext;