Browse Source

feat: 同步任务及工单展示

ZhaoJun 1 năm trước cách đây
mục cha
commit
d3b3c0fd16

+ 49 - 11
src/pages/TaskManage/Detail/TaskDetail/TaskDetail.tsx

@@ -126,13 +126,10 @@ function TaskDetail(props: IPropsType) {
                 <div className={styles.leftInfo}>
                   <Row style={{ marginBottom: '15px' }}>
                     <Col className={styles.fontS24} span={12}>
-                      {/*// @ts-ignore*/}
-                      工单类型:
-                      {record.RecordType === 1
-                        ? '工艺'
-                        : record.RecordType === 2
-                        ? '维修'
-                        : '保养'}
+                      <>
+                        工单类型:
+                        {record.RecordType?.label?.replace('工单', '')}
+                      </>
                     </Col>
                     <Col className={styles.fontS24} span={12}>
                       时间:{record.CreateTime || '-'}
@@ -164,7 +161,11 @@ function TaskDetail(props: IPropsType) {
                       return;
                     }
                     // @ts-ignore
-                    goTaskOrder(record.Id, record.RecordType?.value);
+                    goTaskOrder(
+                      record.Id,
+                      record.RecordType?.value,
+                      tempMandate?.MandateClass.value,
+                    );
                   }}
                 >
                   查看工单
@@ -186,7 +187,6 @@ function TaskDetail(props: IPropsType) {
           tempMandate.img = base64ToImageUrl(image.event_bg);
         }
       }
-
       setMandateDetail(tempMandate);
       setHandledWorkOrder(tempOrder);
       if (children && children.length) {
@@ -209,7 +209,40 @@ function TaskDetail(props: IPropsType) {
       return;
     }
 
+    if (mandateDetail?.MandateClass?.value === 2) {
+      const dataSource = [];
+      dataSource.push({
+        detail: {
+          text: mandateChild[0].Title,
+          key: 'title',
+        },
+      });
+      dataSource.push(
+        ...Object.entries(JSON.parse(mandateChild[0].Content)).map(
+          (item: any) => {
+            const [key, value] = item;
+            return {
+              detail: {
+                text:
+                  value['item_alias'] +
+                  ' 现有数值:' +
+                  value['old_value'] +
+                  ' 建议调整数值' +
+                  value['new_value'],
+                key: key,
+              },
+            };
+          },
+        ),
+      );
+      setMandateTable(dataSource);
+      return;
+    }
+
     const dataSource = mandateChild.map((item, index) => {
+      if (item.MandateClass === 2) {
+      }
+
       return {
         detail: {
           text: item.Title + item.Content,
@@ -220,9 +253,14 @@ function TaskDetail(props: IPropsType) {
     setMandateTable(dataSource);
   }, [mandateChild]);
 
-  const goTaskOrder = (orderID: number, orderType: number) => {
+  const goTaskOrder = (
+    orderID: number,
+    orderType: number,
+    mandateClass: number,
+  ) => {
+    console.log(mandateDetail);
     navigate(
-      `/task-manage/list/order-detail?project_id=${project_id}&order_id=${orderID}&order_type=${orderType}`,
+      `/task-manage/list/order-detail?project_id=${project_id}&order_id=${orderID}&order_type=${orderType}&mandate_class=${mandateClass}`,
     );
   };
 

+ 27 - 4
src/pages/TaskManage/Detail/TaskOrder/TaskOrder.tsx

@@ -2,7 +2,7 @@ import PageContent from '@/components/PageContent';
 import PageTitle from '@/components/PageTitle';
 import { IUserType } from '@/pages/TaskManage/Detail/TaskList/taskList.types';
 import SubTitle from '@/pages/TaskManage/components/SubTitle';
-import { OrderStatus } from '@/pages/TaskManage/constent';
+import { OrderStatus, OrderType } from '@/pages/TaskManage/constent';
 import {
   getCraftRecordList,
   getMaintainRecordList,
@@ -45,6 +45,7 @@ const TaskOrder: React.FC<IPropsType> = (props) => {
   const project_id = Number(queryParams.get('project_id'));
   const order_id = Number(queryParams.get('order_id'));
   const order_type = Number(queryParams.get('order_type'));
+  const mandate_class = Number(queryParams.get('mandate_class'));
 
   const [orderInfo, setOrderInfo] = useState<IOrderInfo>();
 
@@ -106,6 +107,27 @@ const TaskOrder: React.FC<IPropsType> = (props) => {
     },
   });
 
+  const renderReason = (detail: any) => {
+    const title = detail.match(/^(.*?)(?=\{)/g)[0];
+    const content = JSON.parse(detail.match(/\{.*\}/g)[0]);
+    console.log(content, title);
+    console.log(Object.values(content));
+    const result = [];
+    result.push(<Row className={styles.fontS28}>{title}</Row>);
+    Object.values(content).forEach((item: any) => {
+      result.push(
+        <Row className={styles.fontS28}>
+          {item['item_alias'] +
+            ' 现有数值:' +
+            item['old_value'] +
+            ' 建议调整数值' +
+            item['new_value']}
+        </Row>,
+      );
+    });
+    return result;
+  };
+
   // 根据type请求详情
   const { run: getCraftDetail } = useRequest(getCraftRecordList, {
     manual: true,
@@ -118,7 +140,7 @@ const TaskOrder: React.FC<IPropsType> = (props) => {
           (temp.actual_end_time &&
             dayjs(temp.actual_end_time).format('YYYY-MM-DD HH:mm')) ||
           '-',
-        Reason: temp.detail,
+        Reason: mandate_class !== 2 ? temp.detail : renderReason(temp.detail),
         Repairman: userList.find((item) => item.ID === temp.checker_id) || '-',
         DispatchMan:
           userList.find((item) => item.ID === temp.operator_id) || '-',
@@ -139,6 +161,7 @@ const TaskOrder: React.FC<IPropsType> = (props) => {
     switch (order_type) {
       // 工艺
       case 1:
+      case 6:
         getCraftDetail({ project_id, work_id: order_id });
         break;
       // 维修
@@ -168,7 +191,8 @@ const TaskOrder: React.FC<IPropsType> = (props) => {
               <Col className={styles.fontS28} span={16}>
                 {/*// @ts-ignore*/}
                 工单类型:
-                {order_type === 1 ? '工艺' : order_type === 2 ? '维修' : '保养'}
+                {OrderType.find((item) => item.value === order_type)?.label ||
+                  '-'}
               </Col>
               <Col className={styles.fontS28} span={8}>
                 {/*// @ts-ignore*/}
@@ -204,7 +228,6 @@ const TaskOrder: React.FC<IPropsType> = (props) => {
               <Col className={styles.fontS28}>工单详情:</Col>
               <Col className={styles.fontS28} span={18}>
                 {orderInfo?.Reason}
-                {/*<Table />*/}
               </Col>
             </Row>
           </div>

+ 60 - 9
src/pages/TaskManage/constent.ts

@@ -84,10 +84,19 @@ export const MandateClass = [
     OrderType: 2,
   },
   {
+    label: '现场巡检',
+    MandateType: 3,
     value: 15,
-    label: '备品预警',
+  },
+  {
+    label: '备品/盘点',
     MandateType: 3,
-    OrderType: 2,
+    value: 16,
+  },
+  {
+    label: '集团任务',
+    MandateType: 4,
+    value: 17,
   },
 ];
 
@@ -104,6 +113,10 @@ export const MandateType = [
     value: 3,
     label: '生产任务',
   },
+  {
+    value: 4,
+    label: '集团任务',
+  },
 ];
 
 export const MandateStatus = [
@@ -138,6 +151,22 @@ export const OrderType = [
     value: 3,
     label: '保养工单',
   },
+  {
+    label: '巡检工单',
+    value: 4,
+  },
+  {
+    label: '加药工单',
+    value: 5,
+  },
+  {
+    label: '备品备件',
+    value: 6,
+  },
+  {
+    label: '盘点工单',
+    value: 7,
+  },
 ];
 
 export const OrderStatus = [
@@ -159,7 +188,7 @@ export const OrderStatus = [
   },
 ];
 
-export const RepairOrderStatus =[
+export const RepairOrderStatus = [
   {
     value: 0,
     label: '维修中',
@@ -172,10 +201,9 @@ export const RepairOrderStatus =[
     value: 2,
     label: '已维修',
   },
-]
-
-export const MaintainOrderStatus =[
+];
 
+export const MaintainOrderStatus = [
   {
     value: 1,
     label: '已提交',
@@ -184,9 +212,9 @@ export const MaintainOrderStatus =[
     value: 2,
     label: '已保养',
   },
-]
+];
 
-export const CraftOrderStatus =[
+export const CraftOrderStatus = [
   {
     value: 0,
     label: '进行中',
@@ -199,4 +227,27 @@ export const CraftOrderStatus =[
     value: 2,
     label: '已通过',
   },
-]
+];
+
+export const ignoreReason = [
+  {
+    label: '误报',
+    value: 0,
+  },
+  {
+    label: '不影响正常生产',
+    value: 1,
+  },
+  {
+    label: '已解决,无需处理',
+    value: 2,
+  },
+  {
+    label: '已派单',
+    value: 3,
+  },
+  {
+    label: '其他',
+    value: 4,
+  },
+];

+ 9 - 9
src/pages/TaskManage/index.tsx

@@ -5,9 +5,9 @@ import styles from '@/pages/TaskManage/index.less';
 import { getMandateList } from '@/services/TaskManage';
 import { RightOutlined } from '@ant-design/icons';
 import { useParams } from '@umijs/max';
-import { List, Spin } from "antd";
+import { List, Spin } from 'antd';
 import { BaseOptionType } from 'rc-select/es/Select';
-import React, { useEffect, useState } from 'react';
+import { useEffect, useState } from 'react';
 import { useNavigate } from 'umi';
 
 const TaskManage = () => {
@@ -20,7 +20,7 @@ const TaskManage = () => {
 
   useEffect(() => {
     const requests = [];
-    for (let i = 0; i < 3; i++) {
+    for (let i = 0; i < 4; i++) {
       requests.push(
         getMandateList({
           project_id,
@@ -30,13 +30,13 @@ const TaskManage = () => {
         }),
       );
     }
-    setLoading(true)
+    setLoading(true);
     Promise.all(requests)
       .then((resList) => {
         if (resList.filter((item) => item.code !== 200).length) {
           throw new Error('请求错误');
         }
-        const typeCount = [0, 0, 0];
+        const typeCount = [0, 0, 0, 0];
         resList.forEach((item, index) => {
           typeCount[index] = item.data.pagination?.total;
         });
@@ -44,9 +44,10 @@ const TaskManage = () => {
       })
       .catch((err) => {
         console.log(err);
-      }).finally(()=>{
-        setLoading(false)
-    });
+      })
+      .finally(() => {
+        setLoading(false);
+      });
   }, []);
 
   const goTaskList = (item: number) => {
@@ -86,7 +87,6 @@ const TaskManage = () => {
           pagination={false}
         />
       </Spin>
-
     </PageContent>
   );
 };