|
@@ -88,3 +88,40 @@ export const getItemCharacters = (stdBill: IStdBill, itemCharacterMap: IItemChar
|
|
|
|
|
|
|
|
return characters;
|
|
return characters;
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
|
|
+// 对于含有中文的清单编号,分离出中文和数字
|
|
|
|
|
+export const separateBillCode = (code: string) => {
|
|
|
|
|
+ const result = code.match(/^([\u4e00-\u9fa5]+)(\d+)/);
|
|
|
|
|
+ if (result && result.length === 3) {
|
|
|
|
|
+ const pre = result[1];
|
|
|
|
|
+ const subCode = result[2];
|
|
|
|
|
+ return { pre, code: subCode };
|
|
|
|
|
+ }
|
|
|
|
|
+ return { pre: '', code };
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param sourceCode 清单ID
|
|
|
|
|
+ *
|
|
|
|
|
+ * 返回: isStd是否来自标准清单 code:标准清单编号
|
|
|
|
|
+ */
|
|
|
|
|
+export const matchAndGetStdBillCode = (sourceCode: string) => {
|
|
|
|
|
+ const { pre, code } = separateBillCode(sourceCode);
|
|
|
|
|
+ if (code.length === 12) {
|
|
|
|
|
+ return { isStd: true, code: pre + code.substring(0, 9) };
|
|
|
|
|
+ }
|
|
|
|
|
+ if (code.length === 9) {
|
|
|
|
|
+ return { isStd: true, code: pre + code };
|
|
|
|
|
+ }
|
|
|
|
|
+ return { isStd: false, code: sourceCode };
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 取标准清单编号
|
|
|
|
|
+export const getStdBillCode = (sourceCode: string) => {
|
|
|
|
|
+ const { isStd, code } = matchAndGetStdBillCode(sourceCode);
|
|
|
|
|
+ if (isStd) {
|
|
|
|
|
+ return code;
|
|
|
|
|
+ }
|
|
|
|
|
+ return '';
|
|
|
|
|
+};
|