浏览代码

feat(wise-cost-util): 获取特征及内容,增加参数divided

vian 4 年之前
父节点
当前提交
b3bbff1a1a
共有 2 个文件被更改,包括 8 次插入6 次删除
  1. 1 1
      wise-cost-util/package.json
  2. 7 5
      wise-cost-util/src/bill.ts

+ 1 - 1
wise-cost-util/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@sc/wise-cost-util",
-  "version": "1.0.5",
+  "version": "1.0.6",
   "description": "wise-cost项目前后端业务通用工具包",
   "main": "./dist/index.cjs.js",
   "module": "./dist/index.esm.js",

+ 7 - 5
wise-cost-util/src/bill.ts

@@ -21,15 +21,16 @@ export interface IJobAndCharacter extends IJobsAndCharacterText {
 
 export const getJobsAndCharacterText = (
   jobContents: IJobContent[],
-  itemCharacters: IItemCharacter[]
+  itemCharacters: IItemCharacter[],
+  divided = false // 分别对应
 ): IJobsAndCharacterText => {
-  const jobContentText = '';
+  let jobContentText = '';
   let itemCharacterText = '';
   let onlyJobContentText = '';
   let onlyItemCharacterText = '';
   jobContents.sort((a, b) => a.seq - b.seq);
   itemCharacters.sort((a, b) => a.seq - b.seq);
-  const characterTextArray: string[] = ['[项目特征]'];
+  const characterTextArray: string[] = divided ? [] : ['[项目特征]'];
   let i = 1;
   for (const item of itemCharacters) {
     if (item.isChecked) characterTextArray.push(`${i}. ${item.character || ''}: ${item.eigenvalue || ''}`);
@@ -37,14 +38,15 @@ export const getJobsAndCharacterText = (
   }
   onlyItemCharacterText = characterTextArray.join('\n');
 
-  const jobTextArray = ['[工作内容]'];
+  const jobTextArray = divided ? [] : ['[工作内容]'];
   i = 1;
   for (const job of jobContents) {
     if (job.isChecked) jobTextArray.push(`${i}. ${job.content || ''}`);
     i += 1;
   }
   onlyJobContentText = jobTextArray.join('\n');
-  itemCharacterText = `${onlyItemCharacterText}\n${onlyJobContentText}`;
+  jobContentText = divided ? onlyJobContentText : '';
+  itemCharacterText = divided ? onlyItemCharacterText : `${onlyItemCharacterText}\n${onlyJobContentText}`;
   return { jobContentText, itemCharacterText, onlyItemCharacterText, onlyJobContentText };
 };