lanyunfei před 7 měsíci
rodič
revize
c148c5f7b9
4 změnil soubory, kde provedl 35 přidání a 4 odebrání
  1. 11 1
      dist/ExcelUtil.js
  2. 6 1
      dist/FileUtil.js
  3. 10 1
      src/ExcelUtil.ts
  4. 8 1
      src/FileUtil.ts

+ 11 - 1
dist/ExcelUtil.js

@@ -40,6 +40,7 @@ var ExcelUtil = /** @class */ (function () {
      * @param sheetname
      */
     ExcelUtil.getExcelInfo = function (excelPath) {
+        var _a;
         var workbook = xlsx.readFile(excelPath, { cellStyles: true, bookFiles: true });
         var sheetname = workbook.SheetNames[0];
         var worksheet = workbook.Sheets[sheetname];
@@ -122,7 +123,16 @@ var ExcelUtil = /** @class */ (function () {
                 if (ret.keys.findIndex(function (v) { return v == name_1; }) != -1) {
                     Config_1.Config.checkState(Config_1.RetCode.COL_NAME_REPEAT, "".concat(StringUtil_1.default.getCheckString(address, ret), " \n\u540C\u4E00\u4E2A\u8868\u4E2D\u53D1\u73B0\u5217\u540D\u91CD\u590D\uFF01").concat(name_1));
                 }
-                ret.keys.push({ name: name_1, outputclient: outputclient, outputserver: outputserver, type: type, isUniq: isUniq, isArray: isArray, canZeroStr: canZeroStr });
+                ret.keys.push({
+                    name: name_1,
+                    outputclient: outputclient,
+                    outputserver: outputserver,
+                    type: type,
+                    isUniq: isUniq,
+                    isArray: isArray,
+                    canZeroStr: canZeroStr,
+                    des: (_a = worksheet[col + 2]) === null || _a === void 0 ? void 0 : _a.v
+                });
                 delete worksheet[address]; // 删除表头信息
             }
         };

+ 6 - 1
dist/FileUtil.js

@@ -128,7 +128,12 @@ var FileUtil = /** @class */ (function () {
     FileUtil.saveTsAlone = function (outPutData) {
         var text = '/* eslint-disable */\r\n';
         var jsobj = outPutData.jsobj;
-        text += "export let ".concat(outPutData.sheetname, "=\r\n{");
+        text += "export interface I".concat(outPutData.sheetname, " {");
+        outPutData.headInfo.keys.forEach(function (key, index) {
+            text += "\r\n\t".concat(key.name, ":").concat(key.type).concat(index < outPutData.headInfo.keys.length - 1 ? ',' : '', " //").concat(key.des);
+        });
+        text += '\r\n}\r\n';
+        text += "export let ".concat(outPutData.sheetname, ": { [key: string]: I").concat(outPutData.sheetname, " }=\r\n{");
         if (jsobj.length > 0 && JSON.stringify(jsobj[0]) != '{}') {
             text = StringUtil_1.default.getTsFileString(jsobj, outPutData.sheetname, text, outPutData.headInfo);
         }

+ 10 - 1
src/ExcelUtil.ts

@@ -118,7 +118,16 @@ export default class ExcelUtil {
                 if (ret.keys.findIndex(v => v == name) != -1) {
                     Config.checkState(RetCode.COL_NAME_REPEAT, `${StringUtil.getCheckString(address, ret)} \n同一个表中发现列名重复!${name}`)
                 }
-                ret.keys.push({name, outputclient, outputserver, type, isUniq, isArray, canZeroStr})
+                ret.keys.push({
+                    name,
+                    outputclient,
+                    outputserver,
+                    type,
+                    isUniq,
+                    isArray,
+                    canZeroStr,
+                    des: worksheet[col + 2]?.v
+                })
                 delete worksheet[address];  // 删除表头信息
             }
 

+ 8 - 1
src/FileUtil.ts

@@ -124,13 +124,19 @@ export default class FileUtil {
     public static saveTsAlone(outPutData) {
         let text = '/* eslint-disable */\r\n'
         let jsobj = outPutData.jsobj
-        text += `export let ${outPutData.sheetname}=\r\n{`
+        text += `export interface I${outPutData.sheetname} {`
+        outPutData.headInfo.keys.forEach((key, index) => {
+            text += `\r\n\t${key.name}:${key.type}${index < outPutData.headInfo.keys.length - 1 ? ',' : ''} //${key.des}`
+        })
+        text += '\r\n}\r\n'
+        text += `export let ${outPutData.sheetname}: { [key: string]: I${outPutData.sheetname} }=\r\n{`
         if (jsobj.length > 0 && JSON.stringify(jsobj[0]) != '{}') {
             text = StringUtil.getTsFileString(jsobj, outPutData.sheetname, text, outPutData.headInfo)
         }
         text += '\r\n}\r\n'
         this.saveText(text, `${outPutData.sheetname}.ts`)
     }
+
     /**
      * 保存为单独的js格式文件
      * @param outPutData
@@ -145,6 +151,7 @@ export default class FileUtil {
         text += '\r\n}\r\n'
         this.saveText(text, `${outPutData.sheetname}.js`)
     }
+
     /**
      * 保存为ts格式文件
      * @param outPutData