Parcourir la source

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

ZhaoJun il y a 1 an
Parent
commit
fd0770e531

+ 36 - 6
src/components/DDComponents/DepartmentField/index.js

@@ -5,7 +5,7 @@ import { connect } from 'dva';
 // import { queryDDdepList } from '@/services/boom';
 
 function DepartmentField(props) {
-  const { value = [], onChange, defaultValue, depUserTree } = props;
+  const { value = [], onChange, defaultValue, depTrees } = props;
   // const [treeData, setTreeData] = useState([]);
 
   // const genTreeNode = dep => {
@@ -74,9 +74,36 @@ function DepartmentField(props) {
     }
   }, [defaultValue]);
 
-  const onChangeValue = newValue => {
-    const depName = findDepName(depUserTree, newValue);
-    onChange(depName);
+  const findDepID = (list, Name) => {
+    let result = '';
+    const dep = list.find(item => item.Name === Name);
+    if (dep) {
+      result = dep.ID;
+    } else {
+      for (let index = 0; index < list.length; index++) {
+        const element = list[index];
+        if (element?.children && element?.children.length) {
+          result = findDepID(element.children, Name);
+          if (result) {
+            break;
+          }
+        }
+      }
+    }
+    return result;
+  };
+
+  const defaultID = useMemo(() => {
+    if (defaultValue !== undefined) {
+      return findDepID(depUserTree, defaultValue[0]);
+    } else {
+      return null;
+    }
+  }, [defaultValue]);
+
+  const onChangeValue = (newValue, label) => {
+    // const depName = findDepName(depTrees, newValue);
+    onChange(label);
   };
 
   return (
@@ -91,10 +118,13 @@ function DepartmentField(props) {
       }}
       style={{ width: '100%' }}
       placeholder="请选择部门"
-      treeData={depUserTree}
+      treeData={depTrees}
+      filterTreeNode={(input, option) => {
+        return option.title.toLowerCase().includes(input.toLowerCase());
+      }}
       onChange={onChangeValue}
     />
   );
 }
 
-export default connect(({ user }) => ({ depUserTree: user.depUserTree }))(DepartmentField);
+export default connect(({ user }) => ({ depTrees: user.depTrees }))(DepartmentField);

+ 17 - 1
src/models/user.js

@@ -38,6 +38,17 @@ function getDepUserTree(data) {
   return data;
 }
 
+function getDepTreeData(data) {
+  data.title = `${data.Name}`;
+  data.key = data.ID;
+  data.value = data.ID;
+  if (data.children) {
+    data.children.forEach(item => {
+      getDepTreeData(item, false);
+    });
+  }
+  return data;
+}
 const getRoleList = data => {
   let roleList = [];
   (data || []).forEach(dep => {
@@ -63,6 +74,7 @@ export default {
     depRole: [],
     depUserTree: [],
     roleList: [],
+    depTrees: [],
   },
 
   effects: {
@@ -167,12 +179,16 @@ export default {
     *fetchDepV2({ payload, callback }, { call, put }) {
       const response = yield call(queryDepV2, { pageSize: 999999 });
       if (response) {
+        let temp = JSON.parse(JSON.stringify(response.data.list));
         const depUserTree = response.data.list.map(item => {
           return getDepUserTree(item);
         });
+        const depTrees = temp.map(item => {
+          return getDepTreeData(item);
+        });
         yield put({
           type: 'saveState',
-          payload: { depUserTree },
+          payload: { depUserTree, depTrees },
         });
       }
     },

+ 12 - 6
src/pages/Detail/Index.js

@@ -114,6 +114,13 @@ function Detail(props) {
     localStorage['JWT-TOKEN'] = TOKEN;
   }
 
+  const node = useMemo(() => {
+    if (version.template_node_id && flowDetail.nodes.length > 0) {
+      return flowDetail.nodes.find(item => item.Id == version.template_node_id);
+    }
+    return null;
+  }, [flowDetail, version.template_node_id]);
+
   const flow = useMemo(() => {
     let data = {
       active: 0,
@@ -270,7 +277,7 @@ function Detail(props) {
     await queryDelSheetRecord(params);
   };
 
-  const onAudit = (data) => {
+  const onAudit = data => {
     const flowNode = flow.currentNode;
     dispatch({
       type: 'detail/approve',
@@ -279,7 +286,7 @@ function Detail(props) {
         project_id: projectId,
         flow_id: flowNode.flow_id,
         node_id: flowNode.seq,
-        ...data
+        ...data,
       },
       callback: newVersion => {
         setAuditVisible(false);
@@ -442,11 +449,9 @@ function Detail(props) {
 
   //是否展示psr表上面的按钮
   const showPsrBtns = useMemo(() => {
-    let Id = version.template_node_id;
-    const node = flowDetail.nodes.find?.(item => item.Id == Id);
-    if (node?.node_type_psr >= 1 && node?.node_type_psr <= 4) return true;
+    if (node?.node_type_psr == 3 || node?.node_type_psr == 4) return true;
     return false;
-  }, [flowDetail, version]);
+  }, [node]);
 
   const getUser = newUser => {
     try {
@@ -627,6 +632,7 @@ function Detail(props) {
                   permissions={currentUser.Permission}
                   version={version}
                   templateId={templateId}
+                  node={node}
                   getUser={getUser}
                   onUpdate={onUpdate}
                   onDelSheet={onDelSheet}

+ 9 - 1
src/pages/Detail/LuckySheet.js

@@ -73,6 +73,7 @@ class LuckySheet extends React.Component {
       templateId,
       onDelSheet,
       permissions,
+      node,
     } = this.props;
     const data = currentData || this.props.data;
     const _this = this;
@@ -185,7 +186,8 @@ class LuckySheet extends React.Component {
         option.enableAddBackTop = false;
         option.showsheetbarConfig = {
           add: false,
-          sheet: false,
+          menu: false,
+          // sheet: false,
         };
         option.cellRightClickConfig = {
           copy: false, // 复制
@@ -230,6 +232,12 @@ class LuckySheet extends React.Component {
           hintText: '当前清单不可编辑!',
         };
         unableEdit(option);
+      } else if (node?.node_type_psr == 1 ||node?.node_type_psr == 2 || node?.node_type_psr == 5 ) {
+        option.authority = {
+          sheet: true,
+          hintText: '流程已完结,不可编辑!',
+        };
+        unableEdit(option);
       }
     } else if (data && data.length > 0) {
       option.data = JSON.parse(JSON.stringify(data));

+ 2 - 2
src/pages/Detail/PsrControl.js

@@ -7,7 +7,7 @@ function PsrControl(props) {
   const { sheetRef } = props;
   const [value1, setValue1] = useState(0.15);
   const [value2, setValue2] = useState(0.25);
-  const [value3, setValue3] = useState(14096800);
+  const [value3, setValue3] = useState();
   const [loading, setLoading] = useState(false);
 
   const changeProjectType = type => {
@@ -31,7 +31,7 @@ function PsrControl(props) {
     try {
       if (type == 3) {
         setting = {
-          customToleranceFn: res => Math.abs(res - value) < 1
+          customToleranceFn: res => Math.abs(res - value) < 0.001
         };
       } else {
         setting = {

+ 12 - 12
src/pages/Flow/FlowDetail.json

@@ -69,7 +69,7 @@
       "x": -578,
       "y": 6,
       "flow_id": 9,
-      "node_type_psr": 1,
+      "node_type_psr": 0,
       "count": 0,
       "role_list": ""
     },
@@ -118,7 +118,7 @@
       "x": -789,
       "y": 26,
       "flow_id": 0,
-      "node_type_psr": 0,
+      "node_type_psr": 5,
       "count": 0,
       "role_list": ""
     },
@@ -263,7 +263,7 @@
       "x": 325,
       "y": -170,
       "flow_id": 5,
-      "node_type_psr": 1,
+      "node_type_psr": 0,
       "count": 0,
       "role_list": ""
     },
@@ -287,7 +287,7 @@
       "x": 111,
       "y": 6,
       "flow_id": 8,
-      "node_type_psr": 1,
+      "node_type_psr": 0,
       "count": 0,
       "role_list": ""
     },
@@ -311,7 +311,7 @@
       "x": -63,
       "y": -435,
       "flow_id": 51,
-      "node_type_psr": 1,
+      "node_type_psr": 0,
       "count": 0,
       "role_list": ""
     },
@@ -360,7 +360,7 @@
       "y": -240,
       "zIndex": 10,
       "flow_id": 3,
-      "node_type_psr": 1,
+      "node_type_psr": 0,
       "count": 0
     },
     {
@@ -384,7 +384,7 @@
       "y": -117,
       "zIndex": 10,
       "flow_id": 4,
-      "node_type_psr": 1,
+      "node_type_psr": 0,
       "count": 0
     },
     {
@@ -407,7 +407,7 @@
       "x": 168,
       "y": -117,
       "flow_id": 4,
-      "node_type_psr": 1,
+      "node_type_psr": 0,
       "count": 0,
       "role_list": ""
     },
@@ -431,7 +431,7 @@
       "x": 168,
       "y": -240,
       "flow_id": 3,
-      "node_type_psr": 1,
+      "node_type_psr": 0,
       "count": 0,
       "role_list": ""
     },
@@ -456,7 +456,7 @@
       "y": -170,
       "zIndex": 10,
       "flow_id": 5,
-      "node_type_psr": 1,
+      "node_type_psr": 0,
       "count": 0
     },
     {
@@ -480,7 +480,7 @@
       "y": -170,
       "zIndex": 10,
       "flow_id": 7,
-      "node_type_psr": 1,
+      "node_type_psr": 0,
       "count": 0
     },
     {
@@ -528,7 +528,7 @@
       "y": -435,
       "zIndex": 10,
       "flow_id": 48,
-      "node_type_psr": 2,
+      "node_type_psr": 0,
       "count": 0
     }
   ],

+ 2 - 2
src/utils/GoalSeek.js

@@ -34,7 +34,7 @@ export default async function GoalSeek(options) {
     res = await fn(...copyParams);
     if (res > goal) {
       minGuest -= oldGuess / 2;
-      await getMin(minGuest);
+      return await getMin(minGuest);
     }
     return minGuest;
   }
@@ -45,7 +45,7 @@ export default async function GoalSeek(options) {
     res = await fn(...copyParams);
     if (res < goal) {
       maxGuest += oldGuess / 2;
-      await getMax(maxGuest);
+      return await getMax(maxGuest);
     }
     return maxGuest;
   }

+ 10 - 6
src/utils/uploadExcelByUrl.js

@@ -1,13 +1,14 @@
 import LuckyExcel from 'luckyexcel';
 import { getToken } from '@/utils/utils';
 import moment from 'moment';
-window.moment = moment
-
+window.moment = moment;
 
 const uploadExcelByUrl = (nodeType, versionId, project) => {
   const TEMPLATE_URL =
-    'https://water-service-test.oss-cn-hangzhou.aliyuncs.com/public/bom/psr1008.xlsx';
-    // 'https://gt-digitization.oss-cn-hangzhou.aliyuncs.com/public/bom/psr0913.xlsx';
+    'https://water-service-test.oss-cn-hangzhou.aliyuncs.com/public/bom/psr1010.xlsx';
+  // 'https://water-service-test.oss-cn-hangzhou.aliyuncs.com/public/bom/psr1009.xlsx';
+  // 'https://water-service-test.oss-cn-hangzhou.aliyuncs.com/public/bom/psr1008.xlsx';
+  // 'https://gt-digitization.oss-cn-hangzhou.aliyuncs.com/public/bom/psr0913.xlsx';
 
   return new Promise((resolve, reject) => {
     LuckyExcel.transformExcelToLuckyByUrl(
@@ -33,6 +34,9 @@ const uploadExcelByUrl = (nodeType, versionId, project) => {
         res.push(initPSR(excelData[1], category, project?.project_name));
 
         if (nodeType == 4) {
+          // 隐藏现金流表
+          excelData[3].hide = 1;
+          excelData[3].status = 0;
           // 处理现金流
           res.push(initActual(excelData[3], category, project));
         }
@@ -182,8 +186,8 @@ function initActual(actual, category, project) {
       }
     } else if (item.c == 12 && item.r == 5) {
       // 设置第一个月时间
-      let start_date = moment("1900-01-01 00:00:00");
-      let end_date = moment().startOf('month')
+      let start_date = moment('1900-01-01 00:00:00');
+      let end_date = moment().startOf('month');
       item.v.v = end_date.diff(start_date, 'days');
     }
   });