123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- import React, {
- useState, useEffect, useContext
- } from 'react';
- import { Form, Col, DatePicker, Button, message, Space, Input } from 'antd';
- import apiObj from '@api/index';
- import BlockContext from './problem-context';
- import moment from "moment";
- import "moment/locale/zh-cn"
- import { getCookie } from '@utils/index'
- const { RangePicker } = DatePicker;
- const { post, api, xPost } = apiObj;
- const { TextArea } = Input;
- function EditBlock(props) {
- useEffect(() => {
- }, []);
- const [form] = Form.useForm();
- const [dates, setDates] = useState([]);
- const [limit, setLimit] = useState(false);
- const { problemDetail, type } = useContext(BlockContext);
- const initialValues = problemDetail;
- const onFinish = values => {
- if (type == 1) {
- dataCheck(values)
- } else {
- editProblem(values)
- }
- };
- function change(e) {
- const { value } = e.target;
- if (value) {
- setLimit(true)
- } else {
- setLimit(false)
- }
- }
- function editProblem(values) {
- let params = {
- id: problemDetail.id,
- description: values.description,
- }
- post(api.updateColumnResult, params).then((res) => {
- if (res.data.code === 200) {
- props.userChange()
- message.success(res.data.message);
- form.resetFields();
- } else {
- message.error(res.data.message);
- }
- })
- }
- //数据对比
- function dataCheck(values) {
- values.startDate = moment(values.time[0]).format('YYYY-MM-DD 00:00:00');
- values.endDate = moment(values.time[1]).format('YYYY-MM-DD 23:23:59');
- let params = {
- behospitalCode: values.behospitalCode,
- dateEnd: values.endDate,
- dateStart: values.startDate,
- isPlacefile:getCookie('isPlacefile')
- }
- post(api.dataCheck, params).then((res) => {
- if (res.data.code === 200) {
- props.userChange()
- message.success(res.data.message);
- form.resetFields();
- } else {
- message.error(res.data.message);
- }
- })
- }
- function disabledDate(current) {
- if (!dates || dates.length === 0) {
- return current && current >= moment().endOf('day');
- }
- const tooLate = dates[0] && current.diff(dates[0], 'days') > 29;
- const tooEarly = dates[1] && dates[1].diff(current, 'days') > 29;
- if(!limit){
- return current && current >= moment().endOf('day') || tooEarly || tooLate;
- }else{
- return current && current >= moment().endOf('day');
- }
-
- };
- function cancel() {
- props.userChange()
- }
- return (
- <>
- <Form
- labelCol={type == 3 ? { span: 16 } : { span: 4 }}
- wrapperCol={type == 3 ? { span: 12 } : { span: 16 }}
- form={form}
- name="register"
- layout={type == 3 ? 'inline' : 'horizontal'}
- onFinish={onFinish}
- initialValues={initialValues}
- className='problem'
- >
- <Col span={12} hidden={type != 3}>
- <Form.Item
- name="behospitalCode"
- label="住院序号"
- labelAlign="right"
- >
- <span>{initialValues.behospitalCode}</span>
- </Form.Item>
- </Col>
- <Col span={12} hidden={type != 3}>
- <Form.Item
- name="hosptialDatatmpCode"
- label="文书编号"
- >
- <span>{initialValues.hosptialDatatmpCode}</span>
- </Form.Item>
- </Col>
- <Col span={12} hidden={type != 3}>
- <Form.Item
- name="hosptialDatatmpName"
- label="文书标题"
- >
- <span>{initialValues.hosptialDatatmpName}</span>
- </Form.Item>
- </Col>
- <Col span={12} hidden={type != 3}>
- <Form.Item
- name="modeName"
- label="质控模块名称"
- >
- <span>{initialValues.modeName}</span>
- </Form.Item>
- </Col>
- <Col span={12} hidden={type != 3}>
- <Form.Item
- name="tableCname"
- label="表名称(中文)"
- >
- <span>{initialValues.tableCname}</span>
- </Form.Item>
- </Col>
- <Col span={12} hidden={type != 3}>
- <Form.Item
- name="tableEname"
- label="表名称(英文)"
- >
- <span>{initialValues.tableEname}</span>
- </Form.Item>
- </Col>
- <Col span={12} hidden={type != 3}>
- <Form.Item
- name="columnCname"
- label="字段名称(中文)"
- >
- <span>{initialValues.columnCname}</span>
- </Form.Item>
- </Col>
- <Col span={12} hidden={type != 3}>
- <Form.Item
- name="columnEname"
- label="字段名称(英文)"
- >
- <span>{initialValues.columnEname}</span>
- </Form.Item>
- </Col>
- <Col span={12} hidden={type != 3}>
- <Form.Item
- name="tableVal"
- label="上传字段值"
- >
- <span>{initialValues.tableVal}</span>
- </Form.Item>
- </Col>
- <Col span={12} hidden={type != 3}>
- <Form.Item
- name="type"
- label="问题类型"
- >
- <span>{initialValues.type == 1 ? "数据缺失" : initialValues.type == 2 ? "非标准值" : "正则校验失败"}</span>
- </Form.Item>
- </Col>
- <Col span={24} hidden={type != 3}>
- <Form.Item
- name="status"
- label="状态"
- >
- <span>{initialValues.isSolved == 1 ? "已解决" : "未解决"}</span>
- </Form.Item>
- </Col>
- <Col span={24} hidden={type != 3}>
- <Form.Item
- name="description"
- label="备注"
- wrapperCol={{ span: 18 }}
- rules={[{ max: 200,message:'备注不能超过200个字符' }]}
- >
- <TextArea
- autoSize={{ minRows: 5, maxRows: 5 }}
- />
- </Form.Item>
- </Col>
- <Col span={24} hidden={type == 3}>
- {type != 3 ?
- <Form.Item label="日期" name="time" rules={[{ required: true }]} labelAlign="right">
- <RangePicker
- allowClear={false}
- placeholder={['开始时间', '结束时间']}
- disabledDate={disabledDate}
- onCalendarChange={val => setDates(val)}
- />
- </Form.Item>
- : ''}
- </Col>
- <Col span={24} hidden={type == 3} style={{ marginTop: 15 }}>
- <Form.Item label="住院序号" name="behospitalCode" rules={[{ max: 30,message:'住院序号不能超过30个字符' }]}>
- <Input placeholder="请输入" autoComplete='off' onChange={change}/>
- </Form.Item>
- </Col>
- {
- type == 1 ?
- <div style={{ color: '#1690FF' }}>
- 提示:<br />
- 1、校验时间范围限制为30天,每一天数据量的校验时间约为1分钟。<br />
- 时间范围以患者入院时间为准。<br />
- 2、当输入住院序号时,校验将不受时间范围限制。<br />
- </div>
- : ''
- }
- <Form.Item wrapperCol={type == 3 ? { offset: 24, span: 16 } : { offset: 8, span: 16 }} style={{ marginTop: 15 }}>
- <Space size="middle" >
- <Button htmlType="button" onClick={e => cancel()}>
- 取消
- </Button>
- <Button type="primary" htmlType="submit">
- {type == 1 ? '确定' : '保存'}
- </Button>
- </Space>
- </Form.Item>
- </Form>
- </>
- );
- }
- export default EditBlock;
|