|
@@ -1,10 +1,23 @@
|
|
|
-import { IJobContent, IItemCharacter } from '@sc/types';
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ IJobContent,
|
|
|
|
|
+ IItemCharacter,
|
|
|
|
|
+ IStdBill,
|
|
|
|
|
+ IStdJobContent,
|
|
|
|
|
+ IStdItemCharacter,
|
|
|
|
|
+} from '@sc/types';
|
|
|
|
|
|
|
|
interface IJobsAndCharacterText {
|
|
interface IJobsAndCharacterText {
|
|
|
jobContentText: string;
|
|
jobContentText: string;
|
|
|
itemCharacterText: string;
|
|
itemCharacterText: string;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+interface IJobContentMap {
|
|
|
|
|
+ [id: string]: IStdJobContent;
|
|
|
|
|
+}
|
|
|
|
|
+interface IItemCharacterMap {
|
|
|
|
|
+ [id: string]: IStdItemCharacter;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export interface IJobAndCharacter extends IJobsAndCharacterText {
|
|
export interface IJobAndCharacter extends IJobsAndCharacterText {
|
|
|
jobContents: IJobContent[];
|
|
jobContents: IJobContent[];
|
|
|
itemCharacters: IItemCharacter[];
|
|
itemCharacters: IItemCharacter[];
|
|
@@ -32,3 +45,48 @@ export const getJobsAndCharacterText = (
|
|
|
itemCharacterText = textArray.join('\n');
|
|
itemCharacterText = textArray.join('\n');
|
|
|
return { jobContentText, itemCharacterText };
|
|
return { jobContentText, itemCharacterText };
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
|
|
+export const getJobContents = (
|
|
|
|
|
+ stdBill: IStdBill,
|
|
|
|
|
+ stdJobContenMap: IJobContentMap
|
|
|
|
|
+): IJobContent[] => {
|
|
|
|
|
+ const jobs: IJobContent[] = [];
|
|
|
|
|
+ let i = 1;
|
|
|
|
|
+ for (const j of stdBill.jobs) {
|
|
|
|
|
+ const job = stdJobContenMap[j.id];
|
|
|
|
|
+ if (job) {
|
|
|
|
|
+ jobs.push({ serialNo: i + 1, content: job.content, isChecked: true });
|
|
|
|
|
+ i += 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return jobs;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+export const getItemCharacters = (
|
|
|
|
|
+ stdBill: IStdBill,
|
|
|
|
|
+ itemCharacterMap: IItemCharacterMap
|
|
|
|
|
+): IItemCharacter[] => {
|
|
|
|
|
+ const characters: IItemCharacter[] = [];
|
|
|
|
|
+ let i = 1;
|
|
|
|
|
+ for (const item of stdBill.items) {
|
|
|
|
|
+ const character = itemCharacterMap[item.id];
|
|
|
|
|
+ if (character) {
|
|
|
|
|
+ const newItem: IItemCharacter = {
|
|
|
|
|
+ serialNo: i + 1,
|
|
|
|
|
+ character: character.content,
|
|
|
|
|
+ eigenvalue: [],
|
|
|
|
|
+ isChecked: false,
|
|
|
|
|
+ };
|
|
|
|
|
+ const eigenvalues = character.itemValue;
|
|
|
|
|
+ for (let j = 0; j < eigenvalues.length; j += 1) {
|
|
|
|
|
+ const newValue = { value: eigenvalues[j].value, isSelected: false };
|
|
|
|
|
+ newItem.eigenvalue.push(newValue);
|
|
|
|
|
+ }
|
|
|
|
|
+ characters.push(newItem);
|
|
|
|
|
+ i += 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return characters;
|
|
|
|
|
+};
|