zhl-methods 1.1.7 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/js/ScanUDI.js +24 -19
  2. package/package.json +1 -1
package/js/ScanUDI.js CHANGED
@@ -83,34 +83,39 @@ export default class ScanUDI {
83
83
  expiry_time: this.setDateFormat(expiry_time, "expiry", manufacture_time),
84
84
  batch_no: batch_no.toUpperCase(),
85
85
  serial_no,
86
+ udi: str.replace(/[^a-zA-Z0-9]/g, ""),
86
87
  };
87
88
  return obj;
88
89
  }
89
90
  setDateFormat(date, type, expand) {
90
91
  try {
91
- if (date.length === 8 && data.substr(data.length - 2) == "00") {
92
- if (type === "expiry") {
93
- date = dayjs(date).endOf("month");
92
+ if (date) {
93
+ if (date.length === 8 && data.substr(data.length - 2) == "00") {
94
+ if (type === "expiry") {
95
+ date = dayjs(date).endOf("month");
96
+ }
97
+ date = dayjs(date).startOf("month");
94
98
  }
95
- date = dayjs(date).startOf("month");
96
- }
97
- if (date.length === 6) {
98
- if (date.substring(0, 2) === expand.substring(0, 2)) {
99
- // 年月(6位) - 202507
100
- date = date + "01";
101
- } else {
102
- // 年后两位月日(6位) - 250708
103
- date = "20" + date;
99
+ if (date.length === 6) {
100
+ if (date.substring(0, 2) === expand.substring(0, 2)) {
101
+ // 年月(6) - 202507
102
+ date = date + "01";
103
+ } else {
104
+ // 年后两位月日(6位) - 250708
105
+ date = "20" + date;
106
+ }
104
107
  }
105
- }
106
- // 年后两位月(4) - 2507
107
- if (date.length === 4) {
108
- if (type === "expiry") {
109
- date = dayjs("20" + date).endOf("month");
108
+ // 年后两位月(4位) - 2507
109
+ if (date.length === 4) {
110
+ if (type === "expiry") {
111
+ date = dayjs("20" + date).endOf("month");
112
+ }
113
+ date = "20" + date + "01";
110
114
  }
111
- date = "20" + date + "01";
115
+ return dayjs(date).format("YYYY-MM-DD");
116
+ } else {
117
+ return "";
112
118
  }
113
- return dayjs(date).format("YYYY-MM-DD");
114
119
  } catch (error) {
115
120
  console.log(error, "setDateFormat error");
116
121
  return date;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zhl-methods",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "license": "ISC",
5
5
  "dependencies": {
6
6
  "dayjs": "^1.11.15",