| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 | 
							- "use strict";
 
- const common_vendor = require("../../common/vendor.js");
 
- const formatToFraction = (num) => {
 
-   if (typeof num === "undefined")
 
-     return 0;
 
-   const parsedNumber = typeof num === "string" ? parseFloat(num) : num;
 
-   return parseFloat((parsedNumber / 100).toFixed(2));
 
- };
 
- const floatToFixed2 = (num) => {
 
-   let str = "0.00";
 
-   if (typeof num === "undefined") {
 
-     return str;
 
-   }
 
-   const f = formatToFraction(num);
 
-   const decimalPart = f.toString().split(".")[1];
 
-   const len = decimalPart ? decimalPart.length : 0;
 
-   switch (len) {
 
-     case 0:
 
-       str = f.toString() + ".00";
 
-       break;
 
-     case 1:
 
-       str = f.toString() + ".0";
 
-       break;
 
-     case 2:
 
-       str = f.toString();
 
-       break;
 
-   }
 
-   return str;
 
- };
 
- function formatDate(date, format) {
 
-   if (!date) {
 
-     return "";
 
-   }
 
-   if (format === void 0) {
 
-     format = "YYYY-MM-DD HH:mm:ss";
 
-   }
 
-   return common_vendor.dayjs(date).format(format);
 
- }
 
- function handleTree(data, id = "id", parentId = "parentId", children = "children", rootId = 0) {
 
-   const cloneData = JSON.parse(JSON.stringify(data));
 
-   const treeData = cloneData.filter((father) => {
 
-     let branchArr = cloneData.filter((child) => {
 
-       return father[id] === child[parentId];
 
-     });
 
-     branchArr.length > 0 ? father.children = branchArr : "";
 
-     return father[parentId] === rootId;
 
-   });
 
-   return treeData !== "" ? treeData : data;
 
- }
 
- function resetPagination(pagination) {
 
-   pagination.list = [];
 
-   pagination.total = 0;
 
-   pagination.pageNo = 1;
 
- }
 
- exports.floatToFixed2 = floatToFixed2;
 
- exports.formatDate = formatDate;
 
- exports.handleTree = handleTree;
 
- exports.resetPagination = resetPagination;
 
 
  |