index.jsx 3.12 KB
Newer Older
wuhao's avatar
wuhao committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
import React, { useEffect, useReducer, useRef } from "react";
import {
  Button,
  Drawer,
  Steps,
  Form,
  Popconfirm,
  Switch,
  Tabs,
  Tooltip,
  Row,
  Col,
  message,
  Card,
} from "antd";
import AutoTable from "@/components/AutoTable";
import getPrem from "@/utils/getPrem"; //权限判断fn
import InitForm from "@/components/InitForm";
import { useRequest, useModel } from "umi";
import { useInterval } from "ahooks";
import moment from "moment";
import Coltext from "@/components/Coltext";
const topleft = {
    collectionSitName: "采集站点",
    workingProcedureName: "工序名称",
  },
  middleright = {
    jobOrderNo: "派工单编号",
    scheduledProductionNum: "排产数量",
    materieCode: "物料编号",
    qualifiedNum: "合格数量",
    productionOrderNo: "生产订单编号",
    noQualifiedNum: "不合格数量",
    f1: "当前SN号/批次号",
    f2: "上线数量",
    current: "当前工序",
    status: "当前状态",
  };

const initState = {
  topleftData: {},
  time: moment().format("YYYY-MM-DD HH:mm:ss"),
  snorbatch: "",
  middlerightData: {},
  timepage: moment().format("YYYY-MM-DD HH:mm:ss"),
};
function reducer(state, action) {
  let { type } = action,
    newState = {};
  switch (type) {
    case "changeTopleft":
      newState = {
        ...state,
        topleftData: { ...action.topleftData },
      };
      break;
    case "changeTopright":
      newState = {
        ...state,
        topRightData: { ...action.topRightData },
      };
      break;
    case "changeTime":
      newState = {
        ...state,
        time: action.time,
      };
      break;
    case "close":
      newState = {
        topleftData: {},
        user: "",
        time: moment().format("YYYY-MM-DD HH:mm:ss"),
        snorbatch: "",
        middlerightData: {},
      };
      break;
  }

  return newState;
}
const Gatherprocess = (props) => {
  const {
    initialState: { currentUser },
    setInitialState,
  } = useModel("@@initialState");
  const [state, dispatch] = useReducer(reducer, initState),
    { topleftData, time, snorbatch, middlerightData, timepage } = state;
  useInterval(() => {
    dispatch({
      type: "changeTime",
      time: moment().add(1, "seconds").format("YYYY-MM-DD HH:mm:ss"),
    });
  }, 1000);
  return (
    <Card title={props.route.name}>
      <div className="spread">
        <div style={{ flex: 1, marginRight: 15 }}>
          <Row gutter={[16, 10]}>
            {Object.keys(topleft).map((item) => {
              return (
                <Coltext
                  label={topleft[item]}
                  value={topleftData[item]}
                  key={item}
                  col={{ span: 20 }}
                />
              );
            })}
            <Col>
              <Button type="primary">选择</Button>
            </Col>
          </Row>
        </div>
        <div style={{ flex: 1, textAlign: "right" }}>
          <div style={{ marginBottom: 6 }}>当前时间:{time}</div>
          <div>当前采集人:{currentUser.userName}</div>
        </div>
      </div>
      <div className="spread"></div>
      <div></div>
    </Card>
  );
};

export default Gatherprocess;