|
@@ -516,13 +516,57 @@ export function hasSpace(s) {
|
|
|
const str2 = s.replace(/[\r\n]/g, "");
|
|
|
return !(str2 === s);
|
|
|
}
|
|
|
+function com1(str, arr) {
|
|
|
+ let s = (arr.find((si) => si.key === str)|| {}).value || str;
|
|
|
+ return s;
|
|
|
+}
|
|
|
+function com2(str, arr) {
|
|
|
+ console.log(str);
|
|
|
+ console.log(arr);
|
|
|
+ let s = "";
|
|
|
+ for (let i = 0; i < str.length; i++) {
|
|
|
+ console.log((arr.find((si) => si.key === str[i])|| {}).value || str[i] );
|
|
|
+ s += (arr.find((si) => si.key === str[i])|| {}).value || str[i];
|
|
|
+ }
|
|
|
+ return s;
|
|
|
+}
|
|
|
+
|
|
|
//营业执照成立日期大写转小写
|
|
|
export function invTime(s) {
|
|
|
+ const option = [
|
|
|
+ { key: "一", value: "1" },
|
|
|
+ { key: "二", value: "2" },
|
|
|
+ { key: "三", value: "3" },
|
|
|
+ { key: "四", value: "4" },
|
|
|
+ { key: "五", value: "5" },
|
|
|
+ { key: "六", value: "6" },
|
|
|
+ { key: "七", value: "7" },
|
|
|
+ { key: "八", value: "8" },
|
|
|
+ { key: "九", value: "9" },
|
|
|
+
|
|
|
+ ];
|
|
|
+ const year = [
|
|
|
+ { key: "0", value: "0" },
|
|
|
+ { key: "零", value: "0" },
|
|
|
+ ].concat(option);
|
|
|
+ const day1 = [ { key: "十", value: "10" }].concat(option);
|
|
|
+ const day2 = [{ key: "十", value: "1" }];
|
|
|
let str = ["年", "月", "日"];
|
|
|
let si = s.replace(/[\r\n]/g, "").replace(/\s/g, "");
|
|
|
+ let arr1 = "",
|
|
|
+ arr2 = "",
|
|
|
+ arr3 = "";
|
|
|
for (let i = 0; i < str.length; i++) {
|
|
|
si = si.replace(str[i], i == 2 ? "" : "-");
|
|
|
}
|
|
|
let arr = si.split("-");
|
|
|
- return arr;
|
|
|
+ if (arr.length !== 3) {
|
|
|
+ return "";
|
|
|
+ } else {
|
|
|
+ arr1 = com2(arr[0], year);
|
|
|
+ arr2 = arr[1].length > 1 ? com2(arr[1], year.concat(day2)) : com1(arr[1], day1);
|
|
|
+ arr3 = arr[2].length > 1 ? com2(arr[2], year.concat(day2)) : com1(arr[1], day1);
|
|
|
+ return `${arr1 + "-" + arr2 + "-" + arr3}`;
|
|
|
+ }
|
|
|
}
|
|
|
+
|