浏览代码

fix: 加药显示异常问题修复

ZhaoJun 1 年之前
父节点
当前提交
65639db645

+ 23 - 15
src/pages/TaskManage/Detail/TaskOrder/TaskOrder.tsx

@@ -24,7 +24,7 @@ import { PhotoProvider, PhotoView } from 'react-photo-view';
 
 interface IPropsType {
   userList: IUserType[];
-  dispatch: (args: { type: string; payload: object }) => {};
+  dispatch: (args: { type: string; payload: object }) => void;
 }
 
 interface IOrderInfo {
@@ -120,12 +120,15 @@ const TaskOrder: React.FC<IPropsType> = (props) => {
         return;
       }
       const tempDetail: IOrderInfo = {
-        CreateTime: dayjs(temp.CreateTime).format('YYYY-MM-DD HH:mm'),
-        PlanTime: dayjs(temp.PlanTime).format('YYYY-MM-DD HH:mm'),
-        RepairTime:
-          (temp.RepairTime &&
-            dayjs(temp.RepairTime).format('YYYY-MM-DD HH:mm')) ||
-          '-',
+        CreateTime: temp.CreateTime
+          ? dayjs(temp.CreateTime).format('YYYY-MM-DD HH:mm')
+          : '-',
+        PlanTime: temp.PlanTime
+          ? dayjs(temp.PlanTime).format('YYYY-MM-DD HH:mm')
+          : '-',
+        RepairTime: temp.RepairTime
+          ? dayjs(temp.RepairTime).format('YYYY-MM-DD HH:mm')
+          : '-',
         Reason: temp.Reason,
         Repairman: userList.find((item) => item.ID === temp.Repairman) || '-',
         DispatchMan:
@@ -195,12 +198,15 @@ const TaskOrder: React.FC<IPropsType> = (props) => {
     formatResult: (result) => {
       const temp = {
         ...result,
-        CreateTime: dayjs(result?.start_time?.Time).format('YYYY-MM-DD HH:mm'),
-        PlanTime: dayjs(result.plan_end_time.Time).format('YYYY-MM-DD HH:mm'),
-        RepairTime:
-          (result?.actual_end_time?.Valid &&
-            dayjs(result.actual_end_time.Time).format('YYYY-MM-DD HH:mm')) ||
-          '-',
+        CreateTime: result?.start_time?.Valid
+          ? dayjs(result?.start_time?.Time).format('YYYY-MM-DD HH:mm')
+          : '-',
+        PlanTime: result?.plan_end_time?.Valid
+          ? dayjs(result.plan_end_time.Time).format('YYYY-MM-DD HH:mm')
+          : '-',
+        RepairTime: result?.actual_end_time?.Valid
+          ? dayjs(result.actual_end_time.Time).format('YYYY-MM-DD HH:mm')
+          : '-',
         Reason: result.note,
         Repairman: '-',
         DispatchMan:
@@ -220,7 +226,7 @@ const TaskOrder: React.FC<IPropsType> = (props) => {
   });
 
   // 获取工单流程信息
-  const { run: getOrderFlow } = useRequest(getWorkOrderFlow, {
+  useRequest(getWorkOrderFlow, {
     // manual: true,
     defaultParams: [{ work_type: order_type, work_id: order_id }],
     formatResult(res: IStepInfo[]) {
@@ -382,7 +388,9 @@ const TaskOrder: React.FC<IPropsType> = (props) => {
               <Row>
                 <Col className={styles.fontS28}>加药详情:</Col>
                 <Col className={styles.fontS28} span={18}>
-                  {`药剂名称:${additionalInfo?.name} 加药量:${additionalInfo?.dosage}升 浓度:${additionalInfo?.concentration}`}
+                  {`药剂名称:${additionalInfo?.name || '-'} 加药量:${
+                    additionalInfo?.dosage || '-'
+                  }升 浓度:${additionalInfo?.concentration || '-'}`}
                 </Col>
               </Row>
             </div>

+ 26 - 3
src/pages/TaskManage/Detail/WorkOrderList/WorkOrderList.js

@@ -3,6 +3,7 @@ import PageTitle from '@/components/PageTitle';
 import {
   getCraftRecordList,
   getMaintainRecordList,
+  getReagentOrderList,
   getRepairRecordList,
   getUserWorkOrderList,
 } from '@/services/TaskManage';
@@ -86,6 +87,23 @@ const WorkOrderList = (props) => {
     setWorkOrderList(tempNode);
   };
 
+  const formatCreateTime = (order) => {
+    if (order_type === 1 || order_type === 6 || order_type === 7) {
+      if (order?.start_time) {
+        return dayjs(order.start_time).format('YYYY-MM-DD HH:mm');
+      }
+    } else if (order_type === 2 || order_type === 3) {
+      if (order?.CreateTime) {
+        return dayjs(order.CreateTime).format('YYYY-MM-DD HH:mm');
+      }
+    } else if (order_type === 5) {
+      if (order?.start_time?.Valid) {
+        return dayjs(order.start_time.Time).format('YYYY-MM-DD HH:mm');
+      }
+    }
+    return '-';
+  };
+
   const { run: getWorkOrderList } = useRequest(
     (status) => {
       if (userID !== null) {
@@ -98,13 +116,12 @@ const WorkOrderList = (props) => {
       } else {
         switch (order_type) {
           case 1:
-          case 4:
-          case 5:
           case 6:
           case 7:
             return getCraftRecordList({
               project_id,
               status: status || 0,
+              work_type: order_type,
             });
           case 2:
             return getRepairRecordList({
@@ -113,6 +130,10 @@ const WorkOrderList = (props) => {
             });
           case 3:
             return getMaintainRecordList({ project_id, status: status || 0 });
+          case 4:
+            return;
+          case 5:
+            return getReagentOrderList({ project_id, status: status || 0 });
         }
       }
     },
@@ -142,13 +163,15 @@ const WorkOrderList = (props) => {
             const temp = result.data.list.map((item) => {
               return {
                 ...item,
-                CreateTime: dayjs(item.start_time).format('YYYY-MM-DD HH:mm'),
+                CreateTime: formatCreateTime(item),
                 Repairman: userList.find((user) => {
                   let temp = -1;
                   if (order_type === 2) {
                     temp = item.Repairman;
                   } else if (order_type === 3) {
                     temp = item.MaintenancePerson;
+                  } else if (order_type === 5) {
+                    temp = '-';
                   } else {
                     temp = item.checker_id;
                   }

+ 52 - 2
src/pages/TaskManage/Popup/WorkOrderModal.js

@@ -1,8 +1,10 @@
 import {
   getCraftRecordList,
   getMaintainRecordList,
+  getReagentOrderDetail,
   getRepairRecordList,
   getWorkOrderFlow,
+  queryReagentDetail,
 } from '@/services/TaskManage';
 import { CloseOutlined } from '@ant-design/icons';
 import { connect, useLocation, useParams, useRequest } from '@umijs/max';
@@ -149,8 +151,39 @@ const WorkOrderModal = (props) => {
       }
     },
   });
+  const { run: getDosingOrder } = useRequest(getReagentOrderDetail, {
+    manual: true,
+    formatResult: (result) => {
+      const temp = {
+        ...result,
+        CreateTime: result?.start_time?.Valid
+          ? dayjs(result?.start_time?.Time).format('YYYY-MM-DD HH:mm')
+          : '-',
+        PlanTime: result?.plan_end_time?.Valid
+          ? dayjs(result.plan_end_time.Time).format('YYYY-MM-DD HH:mm')
+          : '-',
+        RepairTime: result?.actual_end_time?.Valid
+          ? dayjs(result.actual_end_time.Time).format('YYYY-MM-DD HH:mm')
+          : '-',
+        Reason: result.note,
+        Repairman: '-',
+        DispatchMan:
+          userList.find((user) => user.ID === result.operator_id) || '-',
+        OrderStatus:
+          OrderStatus.find((status) => status.value === result.status) || '-',
+      };
+      setOrderInfo(temp);
+      queryReagentDetail({ id: temp.id })
+        .then((res) => {
+          if (res) {
+            setAdditionalInfo(res);
+          }
+        })
+        .catch((err) => console.log(err));
+    },
+  });
 
-  const { run: getOrderFlow } = useRequest(getWorkOrderFlow, {
+  useRequest(getWorkOrderFlow, {
     defaultParams: [{ work_type: order_type, work_id: order_id }],
     formatResult(res) {
       if (res && res?.length) {
@@ -189,7 +222,6 @@ const WorkOrderModal = (props) => {
     switch (order_type) {
       case 1:
       case 4:
-      case 5:
       case 6:
         getCraftDetail({ project_id: projectID, work_id: order_id });
         break;
@@ -199,6 +231,9 @@ const WorkOrderModal = (props) => {
       case 3:
         getMaintainDetail({ project_id: projectID, id: order_id });
         break;
+      case 5:
+        getDosingOrder(order_id);
+        break;
       default:
         break;
     }
@@ -301,6 +336,21 @@ const WorkOrderModal = (props) => {
             </div>
           </div>
         )}
+        {order_type === 5 && (
+          <div>
+            <SubTitle title="加药详情" titleFontSize={24} />
+            <div style={{ padding: '15px' }}>
+              <Row>
+                <Col className={styles.fontS24}>加药详情:</Col>
+                <Col className={styles.fontS24} span={18}>
+                  {`药剂名称:${additionalInfo?.name || '-'} 加药量:${
+                    additionalInfo?.dosage || '-'
+                  }升 浓度:${additionalInfo?.concentration || '-'}`}
+                </Col>
+              </Row>
+            </div>
+          </div>
+        )}
         {stepInfo.length > 0 && (
           <div>
             <SubTitle title="工单流程" titleFontSize={24} />