xujunjie 2 سال پیش
والد
کامیت
903bbded0e

+ 4 - 0
config/router.config.js

@@ -74,6 +74,10 @@ export default [
           },
         ],
       },
+      {
+        path: '/dd-login',
+        component: './DDLogin/index',
+      },
       {
         path: '/mobiletest/chart',
         component: './Mobile/DataMeter/Chart',

+ 4 - 2
package.json

@@ -51,6 +51,7 @@
     "caniuse-lite": "^1.0.30001165",
     "classnames": "^2.2.6",
     "compression-webpack-plugin": "6.0.0",
+    "dingtalk-jsapi": "^2.15.4",
     "dva": "^2.4.1",
     "enquire-js": "^0.2.1",
     "exceljs": "^4.3.0",
@@ -74,6 +75,7 @@
     "omit.js": "^1.0.0",
     "path-to-regexp": "^3.0.0",
     "prop-types": "^15.6.2",
+    "qrcode.react": "^3.1.0",
     "qs": "^6.6.0",
     "range-parser": "1.2.0",
     "rc-animate": "^2.6.0",
@@ -136,10 +138,10 @@
     "tslint": "^5.12.1",
     "tslint-config-prettier": "^1.17.0",
     "tslint-react": "^3.6.0",
+    "typescript": "^4.4.4",
     "umi": "^2.4.4",
     "umi-plugin-ga": "^1.1.3",
-    "umi-plugin-react": "^1.4.2",
-    "typescript": "^4.4.4"
+    "umi-plugin-react": "^1.4.2"
   },
   "optionalDependencies": {
     "puppeteer": "^1.12.1"

+ 16 - 0
src/components/DDComponents/DDCode/index.js

@@ -0,0 +1,16 @@
+import QRCode from 'qrcode.react';
+import { connect } from 'dva';
+import React, { useEffect, useState } from 'react';
+
+function DDCode(props) {
+  return (
+    <div>
+      钉钉扫码授权
+      <QRCode size={128} value={'http://192.168.20.80:8000/bom/#/bom/dd-login'} />
+    </div>
+  );
+}
+
+export default connect(({ loading }) => ({
+  loading,
+}))(DDCode);

+ 54 - 0
src/pages/DDLogin/index.js

@@ -0,0 +1,54 @@
+import React, { useEffect, useState } from 'react';
+import * as dd from 'dingtalk-jsapi';
+import { message } from 'antd';
+import { LoadingOutlined, CheckOutlined } from '@ant-design/icons';
+
+function DDLogin() {
+  const [info, setInfo] = useState('');
+  useEffect(() => {
+    if (dd.env.platform != 'notInDingTalk') {
+      dd.ready(function() {
+        dd.runtime.permission.requestAuthCode({
+          corpId: 'ding0cdce2d5dbf986d9', // 企业id
+          onSuccess: function(info) {
+            setTimeout(() => {
+              setInfo(JSON.stringify(info));
+            }, 1000);
+            // 通过该免登授权码可以获取用户身份
+          },
+          onFail: error => {
+            setInfo(JSON.stringify(error));
+          },
+        });
+      });
+    }
+  }, []);
+
+  return (
+    <div
+      style={{
+        width: '100vw',
+        fontSize: 24,
+        paddingTop: 50,
+        display: 'flex',
+        justifyContent: 'center',
+        alignItems: 'center',
+        flexDirection: 'column',
+      }}
+    >
+      {info ? (
+        <>
+          <CheckOutlined style={{ fontSize: 40, color: '#52c41a' }} />
+          <div>授权成功</div>
+        </>
+      ) : (
+        <>
+          <LoadingOutlined style={{ fontSize: 40, color: '#1890ff' }} />
+          <div>授权中...</div>
+        </>
+      )}
+    </div>
+  );
+}
+
+export default DDLogin;

+ 1 - 1
src/pages/PurchaseAdmin/PurchaseList/Detail/AuditFlow.js

@@ -137,7 +137,7 @@ function AuditFlow(props) {
           processCode,
           deptId,
           userId,
-          formComponentValues,
+          formComponentValues,  
         });
         setFlow(flow);
       } catch (error) {}

+ 17 - 15
src/pages/PurchaseAdmin/PurchaseList/Detail/LuckySheet.js

@@ -116,17 +116,17 @@ class LuckySheet extends React.Component {
         //   }, 300);
         // },
       };
-      console.log(version)
-      if(version.flow_id) {
+      console.log(version);
+      if (version.flow_id) {
         option.authority = {
           sheet: true,
-          hintText: '当前处于审批节点,禁止编辑!'
-        }
-      } else if(version.audit_status != 0 || version.status == 1) {
+          hintText: '当前处于审批节点,禁止编辑!',
+        };
+      } else if (version.audit_status != 0 || version.status == 1) {
         option.authority = {
           sheet: true,
-          hintText: '当前清单不可编辑!'
-        }
+          hintText: '当前清单不可编辑!',
+        };
       }
     } else if (data && data.length > 0) {
       option.data = JSON.parse(JSON.stringify(data));
@@ -439,7 +439,7 @@ class LuckySheet extends React.Component {
   //   });
   // }
 
-  downloadExcel(checkValue) {
+  getExcelData(checkValue = null) {
     let resultList = [];
     console.log(this.luckysheet.getAllSheets());
 
@@ -447,24 +447,21 @@ class LuckySheet extends React.Component {
     currentData.forEach(sheet => {
       let data = sheet.data;
       let celldata = sheet.celldata;
-      //获取当前导出列的数组
       let colList = [];
       data[0]?.forEach((rowOneItem, colIdx) => {
-        if (rowOneItem && checkValue.indexOf(rowOneItem.v) !== -1) {
-          colList.indexOf(colIdx) == -1 ? colList.push(colIdx) : true;
+        if (rowOneItem) {
+          if (!checkValue || checkValue.indexOf(rowOneItem.v) !== -1) {
+            colList.indexOf(colIdx) == -1 ? colList.push(colIdx) : true;
+          }
         }
       });
 
-      //处理data
       const newData = [];
       data.forEach(item => {
         if (item !== null) {
           let arr = item.filter((cur, idx) => {
             return item && colList.includes(idx);
           });
-          // let len = item.length - arr.length
-          // let nullList = new Array(len).fill(null);
-          // let rowList =  arr.concat(nullList);
           newData.push(arr);
         }
       });
@@ -485,6 +482,11 @@ class LuckySheet extends React.Component {
       });
       sheet.celldata = newCellData;
     });
+
+    return currentData;
+  }
+  downloadExcel(checkValue) {
+    let currentData = this.getExcelData(checkValue);
     exportExcel(currentData, '下载');
   }
 

+ 10 - 6
src/utils/exportExcl.js

@@ -3,9 +3,8 @@ const Excel = require('exceljs');
 
 import FileSaver from 'file-saver';
 
-export default function exportExcel(luckysheet, value) {
+export function getExcelBolob(luckysheet) {
   // 参数为luckysheet.getluckysheetfile()获取的对象
-  console.log(luckysheet);
   // 1.创建工作簿,可以为工作簿添加属性
   const workbook = new Excel.Workbook();
   // 2.创建表格,第二个参数可以配置创建什么样的工作表
@@ -24,18 +23,23 @@ export default function exportExcel(luckysheet, value) {
     setBorder(borderInfo, worksheet);
     return true;
   });
-
-  // return
-  // 4.写入 buffer
   const buffer = workbook.xlsx.writeBuffer().then(data => {
     // console.log('data', data)
     const blob = new Blob([data], {
       type: 'application/vnd.ms-excel;charset=utf-8',
     });
+    return blob;
+  });
+  return buffer;
+}
+
+export default function exportExcel(luckysheet, value) {
+  // return
+  // 4.写入 buffer
+  getExcelBolob(luckysheet).then(blob => {
     console.log('导出成功!');
     FileSaver.saveAs(blob, `${value}.xlsx`);
   });
-  return buffer;
 }
 
 var setMerge = function(luckyMerge = {}, worksheet) {