Ver código fonte

Merge branch 'develop' of http://120.55.44.4:10080/xujunjie/gt_client_pad into develop

Renxy 1 ano atrás
pai
commit
adfb788e72

+ 35 - 16
src/pages/Center/MyTask/Detail/TaskDetail.js

@@ -136,22 +136,41 @@ function TaskDetail(props) {
                   </Row>
                 </div>
                 <Divider type="vertical" style={{ height: '0.4rem' }} />
-                <div
-                  className={styles.rightButton}
-                  style={{ color: '#5697e4' }}
-                  onClick={() => {
-                    if (typeof record.RecordType === 'number') {
-                      return;
-                    }
-                    // @ts-ignore
-                    goTaskOrder(
-                      record.Id,
-                      record.RecordType?.value,
-                      tempMandate?.MandateClass.value,
-                    );
-                  }}
-                >
-                  查看工单
+                <div className={styles.rightButtonContainer}>
+                  <div
+                    className={styles.rightButton}
+                    style={{ color: '#5697e4' }}
+                    onClick={() => {
+                      if (typeof record.RecordType === 'number') {
+                        return;
+                      }
+                      // @ts-ignore
+                      goTaskOrder(
+                        record.Id,
+                        record.RecordType?.value,
+                        tempMandate?.MandateClass.value,
+                      );
+                    }}
+                  >
+                    查看工单
+                  </div>
+                  {/* <div
+                    className={styles.rightButton}
+                    style={{ color: '#5697e4' }}
+                    onClick={() => {
+                      if (typeof record.RecordType === 'number') {
+                        return;
+                      }
+                      // @ts-ignore
+                      goTaskOrder(
+                        record.Id,
+                        record.RecordType?.value,
+                        tempMandate?.MandateClass.value,
+                      );
+                    }}
+                  >
+                    关闭工单
+                  </div> */}
                 </div>
               </div>
             );

+ 8 - 4
src/pages/Center/MyTask/Detail/taskDetail.less

@@ -63,14 +63,18 @@
           width: 80%;
         }
 
+        .rightButtonContainer {
+          width: 20%;
+          display: flex;
+          flex-direction: column;
+          justify-content: space-between;
+          align-items: center;
+        }
+
         .rightButton {
-          flex: auto;
           color: #5697e4;
           font-size: 0.24rem;
           text-align: center;
-          display: flex;
-          justify-content: center;
-          align-items: center;
         }
       }
     }

+ 27 - 12
src/pages/Center/MyTask/List/TaskList.js

@@ -196,18 +196,33 @@ const MyTaskList = (props) => {
                 </Row>
               </div>
               <Divider type="vertical" style={{ height: '0.4rem' }} />
-              <div
-                className={styles.rightButton}
-                style={{ color: '#5697e4' }}
-                onClick={() => {
-                  goMyWorkOrder(
-                    order.Id,
-                    order.RecordType?.value,
-                    item.MandateClass,
-                  );
-                }}
-              >
-                查看工单
+              <div className={styles.rightButtonContainer}>
+                <div
+                  className={styles.rightButton}
+                  style={{ color: '#5697e4' }}
+                  onClick={() => {
+                    goMyWorkOrder(
+                      order.Id,
+                      order.RecordType?.value,
+                      item.MandateClass,
+                    );
+                  }}
+                >
+                  查看工单
+                </div>
+                {/* <div
+                  className={styles.rightButton}
+                  style={{ color: '#5697e4' }}
+                  onClick={() => {
+                    goMyWorkOrder(
+                      order.Id,
+                      order.RecordType?.value,
+                      item.MandateClass,
+                    );
+                  }}
+                >
+                  关闭工单
+                </div> */}
               </div>
             </div>
           );

+ 8 - 4
src/pages/Center/MyTask/List/taskList.less

@@ -42,14 +42,18 @@
         width: 80%;
       }
 
+      .rightButtonContainer {
+        width: 20%;
+        display: flex;
+        flex-direction: column;
+        justify-content: space-between;
+        align-items: center;
+      }
+
       .rightButton {
-        flex: auto;
         color: #5697e4;
         font-size: 0.24rem;
         text-align: center;
-        display: flex;
-        justify-content: center;
-        align-items: center;
       }
     }
   }

+ 113 - 37
src/pages/TaskManage/Detail/TaskDetail/TaskDetail.tsx

@@ -16,11 +16,26 @@ import {
   OrderStatus,
   OrderType,
 } from '@/pages/TaskManage/constent';
-import { getDiagnosticDetail, getMandateDetail } from '@/services/TaskManage';
+import {
+  getDiagnosticDetail,
+  getMandateDetail,
+  withdrawOrderRequest,
+} from '@/services/TaskManage';
 import { useLocation } from '@@/exports';
 import { UpOutlined } from '@ant-design/icons';
 import { connect, useRequest } from '@umijs/max';
-import { Col, Collapse, CollapseProps, Divider, Row, Table } from 'antd';
+import {
+  Col,
+  Collapse,
+  CollapseProps,
+  Divider,
+  Form,
+  Input,
+  Modal,
+  Row,
+  Table,
+  message,
+} from 'antd';
 import type { ColumnsType } from 'antd/es/table';
 import dayjs from 'dayjs';
 import { useEffect, useState } from 'react';
@@ -50,6 +65,9 @@ function TaskDetail(props: IPropsType) {
     CollapseProps['items']
   >([]);
   const [mandateTable, setMandateTable] = useState<IColumn[]>([]);
+  const [withdrawReason, setWithdrawReason] = useState('');
+  const [withdrawOrderOpen, setWithdrawOrderOpen] = useState(false);
+  const [clickedOrder, setClickedOrder] = useState({});
 
   const columnDef: ColumnsType<IColumn> = [
     {
@@ -153,22 +171,41 @@ function TaskDetail(props: IPropsType) {
                   </Row>
                 </div>
                 <Divider type="vertical" style={{ height: '40px' }} />
-                <div
-                  className={styles.rightButton}
-                  style={{ color: '#5697e4' }}
-                  onClick={() => {
-                    if (typeof record.RecordType === 'number') {
-                      return;
-                    }
-                    // @ts-ignore
-                    goTaskOrder(
-                      record.Id,
-                      record.RecordType?.value,
-                      tempMandate?.MandateClass.value,
-                    );
-                  }}
-                >
-                  查看工单
+                <div className={styles.rightButtonContainer}>
+                  <div
+                    className={styles.rightButton}
+                    style={{
+                      color: '#5697e4',
+                      marginBottom: `${
+                        record.Status.value === 0 ? '0.15rem' : '0'
+                      }`,
+                    }}
+                    onClick={() => {
+                      if (typeof record.RecordType === 'number') {
+                        return;
+                      }
+                      // @ts-ignore
+                      goTaskOrder(
+                        record.Id,
+                        record.RecordType?.value,
+                        tempMandate?.MandateClass.value,
+                      );
+                    }}
+                  >
+                    查看
+                  </div>
+                  {record?.Status?.value === 0 && (
+                    <div
+                      className={styles.rightButton}
+                      style={{ color: '#5697e4' }}
+                      onClick={() => {
+                        setWithdrawOrderOpen(true);
+                        setClickedOrder(record);
+                      }}
+                    >
+                      关闭
+                    </div>
+                  )}
                 </div>
               </div>
             );
@@ -211,28 +248,30 @@ function TaskDetail(props: IPropsType) {
       const dataSource = [];
       dataSource.push({
         detail: {
-          text: mandateChild[0].Title,
+          text: `${mandateChild[0].Content}: ${mandateChild[0].Content}`,
           key: 'title',
         },
       });
-      dataSource.push(
-        ...Object.entries(JSON.parse(mandateChild[0].Payload)).map(
-          (item: any) => {
-            const [key, value] = item;
-            return {
-              detail: {
-                text:
-                  value['item_alias'] +
-                  ' 现有数值:' +
-                  value['old_value'] +
-                  ' 建议调整数值' +
-                  value['new_value'],
-                key: key,
-              },
-            };
-          },
-        ),
-      );
+      console.log(mandateChild[0]);
+
+      // dataSource.push(
+      //   ...Object.entries(JSON.parse(mandateChild[0]?.Payload)).map(
+      //     (item: any) => {
+      //       const [key, value] = item;
+      //       return {
+      //         detail: {
+      //           text:
+      //             value['item_alias'] +
+      //             ' 现有数值:' +
+      //             value['old_value'] +
+      //             ' 建议调整数值' +
+      //             value['new_value'],
+      //           key: key,
+      //         },
+      //       };
+      //     },
+      //   ),
+      // );
       setMandateTable(dataSource);
       return;
     }
@@ -261,6 +300,24 @@ function TaskDetail(props: IPropsType) {
     );
   };
 
+  const withdrawOrderConfirm = async () => {
+    if (!withdrawReason) {
+      message.warning('请输入关闭理由');
+      return;
+    }
+    const res = await withdrawOrderRequest({
+      record_id: clickedOrder.Id,
+      note: withdrawReason,
+      type: clickedOrder.RecordType.value,
+    });
+    if (res.code === 200) {
+      message.success('关闭工单成功');
+      setClickedOrder({});
+      setWithdrawOrderOpen(false);
+      refreshDetail();
+    }
+  };
+
   return (
     <PageContent closeable={false}>
       <PageTitle returnable>任务详情</PageTitle>
@@ -390,6 +447,25 @@ function TaskDetail(props: IPropsType) {
           </div>
         </div>
       </div>
+      <Modal
+        className={styles.handleModal}
+        title="关闭工单"
+        open={withdrawOrderOpen}
+        onCancel={() => {
+          setWithdrawOrderOpen(false);
+        }}
+        onOk={withdrawOrderConfirm}
+      >
+        <Form>
+          <Form.Item label="关闭原因">
+            <Input
+              onChange={(e) => {
+                setWithdrawReason(e.target.value);
+              }}
+            />
+          </Form.Item>
+        </Form>
+      </Modal>
     </PageContent>
   );
 }

+ 54 - 6
src/pages/TaskManage/Detail/TaskDetail/taskDetail.less

@@ -12,7 +12,6 @@
     margin-bottom: 0.25rem;
   }
 
-
   .detailInfo {
     padding: 0.25rem 0.15rem;
     border-bottom: 0.01rem solid rgba(0, 0, 0, 10%);
@@ -65,17 +64,12 @@
         }
 
         .rightButton {
-          flex: auto;
           color: #5697e4;
           font-size: 0.24rem;
           text-align: center;
-          display: flex;
-          justify-content: center;
-          align-items: center;
         }
       }
     }
-
   }
 
   .workOrderCard {
@@ -90,6 +84,14 @@
       width: 80%;
     }
 
+    .rightButtonContainer {
+      width: 20%;
+      display: flex;
+      flex-direction: column;
+      justify-content: space-between;
+      align-items: center;
+    }
+
     .rightButton {
       flex: auto;
       color: #5697e4;
@@ -102,6 +104,52 @@
   }
 }
 
+.handleModal {
+  :global {
+    .ant-modal-close {
+      width: 0.36rem;
+      height: 0.36rem;
+    }
+    .ant-modal-close-x {
+      font-size: 0.36rem;
+      line-height: 0.36rem;
+    }
+    .ant-modal-title {
+      font-size: 0.28rem;
+    }
+    .ant-select-single:not(.ant-select-customize-input) .ant-select-selector {
+      height: 0.6rem;
+      padding-top: 0.15rem;
+    }
+    .ant-form-item .ant-form-item-label > label {
+      font-size: 0.28rem;
+      height: 0.6rem;
+    }
+    .ant-input {
+      font-size: 0.28rem;
+      height: 0.6rem;
+    }
+    .ant-btn {
+      font-size: 0.28rem;
+      height: 0.6rem;
+      width: 1.2rem;
+    }
+    .ant-checkbox {
+      .ant-checkbox-inner {
+        width: 0.28rem;
+        height: 0.28rem;
+      }
+      .ant-checkbox-inner:after {
+        height: 0.16rem;
+        width: 0.09rem;
+      }
+    }
+    .ant-picker {
+      height: 0.6rem;
+    }
+  }
+}
+
 .fontS28 {
   font-size: 0.28rem;
 }

+ 88 - 14
src/pages/TaskManage/Detail/TaskList/TaskList.tsx

@@ -18,10 +18,21 @@ import TopFilter from '@/pages/TaskManage/components/TopFilter';
 import { IMandateType } from '@/pages/TaskManage/index.types';
 import { useNavigate } from '@@/exports';
 import { DownOutlined } from '@ant-design/icons';
-import { Col, Collapse, CollapseProps, Divider, List, Row } from 'antd';
+import {
+  Col,
+  Collapse,
+  CollapseProps,
+  Divider,
+  Form,
+  Input,
+  List,
+  Modal,
+  Row,
+  message,
+} from 'antd';
 
 import ScrollLoading from '@/components/ScrollLoading';
-import { getMandateList } from '@/services/TaskManage';
+import { getMandateList, withdrawOrderRequest } from '@/services/TaskManage';
 import dayjs from 'dayjs';
 import { useEffect, useState } from 'react';
 import styles from './taskList.less';
@@ -50,6 +61,9 @@ const TaskList: React.FC<IPropsType> = (props) => {
     total: 0,
     pageSize: 20,
   });
+  const [withdrawOrderOpen, setWithdrawOrderOpen] = useState(false);
+  const [clickedOrder, setClickedOrder] = useState({});
+  const [withdrawReason, setWithdrawReason] = useState('');
 
   const { run: getList, loading: loadData } = useRequest(getMandateList, {
     defaultParams: [currentParams],
@@ -151,6 +165,29 @@ const TaskList: React.FC<IPropsType> = (props) => {
     );
   };
 
+  const withdrawOrder = (order: any) => {
+    setWithdrawOrderOpen(true);
+    setClickedOrder(order);
+  };
+
+  const withdrawOrderConfirm = async () => {
+    if (!withdrawReason) {
+      message.warning('请输入关闭理由');
+      return;
+    }
+    const res = await withdrawOrderRequest({
+      record_id: clickedOrder.Id,
+      note: withdrawReason,
+      type: clickedOrder.RecordType.value,
+    });
+    if (res.code === 200) {
+      message.success('关闭工单成功');
+      setClickedOrder({});
+      setWithdrawOrderOpen(false);
+      getList(currentParams);
+    }
+  };
+
   const buildTaskList = (item: IMandateType) => {
     const formatItem = {
       ...item,
@@ -207,18 +244,36 @@ const TaskList: React.FC<IPropsType> = (props) => {
                 </Row>
               </div>
               <Divider type="vertical" style={{ height: '40px' }} />
-              <div
-                className={styles.rightButton}
-                style={{ color: '#5697e4' }}
-                onClick={() => {
-                  goTaskOrder(
-                    order.Id,
-                    order.RecordType?.value,
-                    item.MandateClass,
-                  );
-                }}
-              >
-                查看工单
+              <div className={styles.rightButtonContainer}>
+                <div
+                  className={styles.rightButton}
+                  style={{
+                    color: '#5697e4',
+                    marginBottom: `${
+                      order.Status?.value === 0 ? '0.15rem' : '0'
+                    }`,
+                  }}
+                  onClick={() => {
+                    goTaskOrder(
+                      order.Id,
+                      order.RecordType?.value,
+                      item.MandateClass,
+                    );
+                  }}
+                >
+                  查看
+                </div>
+                {order.Status?.value === 0 && (
+                  <div
+                    className={styles.rightButton}
+                    style={{ color: '#5697e4' }}
+                    onClick={() => {
+                      withdrawOrder(order);
+                    }}
+                  >
+                    关闭
+                  </div>
+                )}
               </div>
             </div>
           );
@@ -307,6 +362,25 @@ const TaskList: React.FC<IPropsType> = (props) => {
           renderItem={buildTaskList}
         />
       </ScrollLoading>
+      <Modal
+        className={styles.handleModal}
+        title="关闭工单"
+        open={withdrawOrderOpen}
+        onCancel={() => {
+          setWithdrawOrderOpen(false);
+        }}
+        onOk={withdrawOrderConfirm}
+      >
+        <Form>
+          <Form.Item label="关闭原因">
+            <Input
+              onChange={(e) => {
+                setWithdrawReason(e.target.value);
+              }}
+            />
+          </Form.Item>
+        </Form>
+      </Modal>
     </PageContent>
   );
 };

+ 54 - 4
src/pages/TaskManage/Detail/TaskList/taskList.less

@@ -42,14 +42,18 @@
         width: 80%;
       }
 
+      .rightButtonContainer {
+        width: 20%;
+        display: flex;
+        flex-direction: column;
+        justify-content: space-between;
+      }
+
       .rightButton {
-        flex: auto;
+        width: 100%;
         color: #5697e4;
         font-size: 0.24rem;
         text-align: center;
-        display: flex;
-        justify-content: center;
-        align-items: center;
       }
     }
   }
@@ -66,6 +70,52 @@
   }
 }
 
+.handleModal {
+  :global {
+    .ant-modal-close {
+      width: 0.36rem;
+      height: 0.36rem;
+    }
+    .ant-modal-close-x {
+      font-size: 0.36rem;
+      line-height: 0.36rem;
+    }
+    .ant-modal-title {
+      font-size: 0.28rem;
+    }
+    .ant-select-single:not(.ant-select-customize-input) .ant-select-selector {
+      height: 0.6rem;
+      padding-top: 0.15rem;
+    }
+    .ant-form-item .ant-form-item-label > label {
+      font-size: 0.28rem;
+      height: 0.6rem;
+    }
+    .ant-input {
+      font-size: 0.28rem;
+      height: 0.6rem;
+    }
+    .ant-btn {
+      font-size: 0.28rem;
+      height: 0.6rem;
+      width: 1.2rem;
+    }
+    .ant-checkbox {
+      .ant-checkbox-inner {
+        width: 0.28rem;
+        height: 0.28rem;
+      }
+      .ant-checkbox-inner:after {
+        height: 0.16rem;
+        width: 0.09rem;
+      }
+    }
+    .ant-picker {
+      height: 0.6rem;
+    }
+  }
+}
+
 .fontS28 {
   font-size: 0.28rem;
 }

+ 0 - 1
src/pages/TaskManage/Popup/index.js

@@ -68,7 +68,6 @@ const TaskModal = (props) => {
   };
   // 自动处理
   const onAutoHandleTaskConfirm = async (pw, mandate) => {
-    console.log(mandate);
     const params = {
       mandate_id: mandate.Id,
       pw,

+ 13 - 5
src/pages/TaskManage/components/MandateDetail.js

@@ -253,11 +253,19 @@ const MandateDetail = (props) => {
               </Row>
             </div>
             <Divider type="vertical" style={{ height: '0.4rem' }} />
-            <div
-              className={styles.rightButton}
-              onClick={() => openWorkOrderModal(item)}
-            >
-              查看工单
+            <div className={styles.rightButtonContainer}>
+              <div
+                className={styles.rightButton}
+                onClick={() => openWorkOrderModal(item)}
+              >
+                查看工单
+              </div>
+              {/* <div
+                className={styles.rightButton}
+                onClick={() => openWorkOrderModal(item)}
+              >
+                关闭工单
+              </div> */}
             </div>
           </div>
         );

+ 7 - 0
src/pages/TaskManage/components/MandateDetail.less

@@ -49,6 +49,13 @@
   .leftInfo > * {
     padding: 0.05rem;
   }
+
+  .rightButtonContainer {
+    width: 18%;
+    display: flex;
+    flex-direction: column;
+  }
+
   .rightButton {
     flex: auto;
     color: #5697e4;

+ 4 - 0
src/pages/TaskManage/constent.ts

@@ -186,6 +186,10 @@ export const OrderStatus = [
     value: 3,
     label: '已拒绝',
   },
+  {
+    value: 6,
+    label: '已关闭',
+  },
 ];
 
 export const RepairOrderStatus = [

+ 0 - 1
src/pages/TaskManage/index.tsx

@@ -20,7 +20,6 @@ const TaskManage = (props) => {
   const [mandateCount, setMandateCount] = useState<number[]>([0, 0, 0]);
   const [loading, setLoading] = useState(false);
   const [tab, setTab] = useState(localStorage.taskTab || '1');
-  const [UA, setUA] = useState('');
 
   useEffect(() => {
     const requests = [];

+ 31 - 0
src/services/TaskManage.js

@@ -47,6 +47,25 @@ export async function setTaskAutomation(params, mandate) {
     data: params,
   });
 
+  function convertPayloadtoParams(mandataChild) {
+    let data = [];
+    try {
+      Object.values(JSON.parse(mandataChild?.Payload)).forEach((item) => {
+        data.push({
+          item: item.item,
+          new_value: item.new_value,
+          old_value: item.old_value,
+          project_id: item.project_id,
+          mandate_id: mandataChild.MandateId,
+          source: 2, // pad端 2
+        });
+      });
+    } catch (error) {
+      return {};
+    }
+    return data;
+  }
+
   if (mandate.MandateClass === 2) {
     // res = await SetVarValues(mandate.MandateChild[0].Payload);
     const query = {
@@ -232,3 +251,15 @@ export async function getPatrolMandateRecord(params) {
   );
   return res;
 }
+
+/**
+ * 关闭工单
+ * @param {object} body
+ * @param {number} body.record_id 工单ID
+ * @param {string} body.note 关闭理由
+ * @param {number} body.type 工单类型 【1】:工艺工单,【2】:维修工单,【3】:保养工单 【4】:巡检工单 【5】:加药工单 【6】:备品备件 【7】:盘点工单
+ * @returns
+ */
+export async function withdrawOrderRequest(data) {
+  return request(`/api/v1/work_order/close`, { method: 'POST', data });
+}