| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import { IJobContent, IItemCharacter, IStdBill, IStdJobContent, IStdItemCharacter } from '@sc/types';
- interface IJobsAndCharacterText {
- jobContentText: string;
- itemCharacterText: string;
- }
- interface IJobContentMap {
- [id: string]: IStdJobContent;
- }
- interface IItemCharacterMap {
- [id: string]: IStdItemCharacter;
- }
- export interface IJobAndCharacter extends IJobsAndCharacterText {
- jobContents: IJobContent[];
- itemCharacters: IItemCharacter[];
- }
- export const getJobsAndCharacterText = (
- jobContents: IJobContent[],
- itemCharacters: IItemCharacter[]
- ): IJobsAndCharacterText => {
- const jobContentText = '';
- let itemCharacterText = '';
- jobContents.sort((a, b) => a.seq - b.seq);
- itemCharacters.sort((a, b) => a.seq - b.seq);
- const textArray: string[] = ['[项目特征]'];
- let i = 1;
- for (const item of itemCharacters) {
- if (item.isChecked) textArray.push(`${i}. ${item.character || ''}: ${item.eigenvalue || ''}`);
- i += 1;
- }
- textArray.push('[工作内容]');
- i = 1;
- for (const job of jobContents) {
- if (job.isChecked) textArray.push(`${i}. ${job.content || ''}`);
- i += 1;
- }
- itemCharacterText = textArray.join('\n');
- return { jobContentText, itemCharacterText };
- };
- export const getJobContents = (stdBill: IStdBill, stdJobContentMap: IJobContentMap): IJobContent[] => {
- const jobs: IJobContent[] = [];
- let i = 1;
- for (const j of stdBill.jobs) {
- const job = stdJobContentMap[j.id];
- if (job) {
- jobs.push({ seq: 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 = {
- seq: i + 1,
- character: character.content,
- eigenvalueList: [],
- eigenvalue: '',
- isChecked: false,
- };
- const eigenvalues = character.itemValue;
- for (let j = 0; j < eigenvalues.length; j += 1) {
- newItem.eigenvalueList.push(eigenvalues[j].value);
- }
- characters.push(newItem);
- i += 1;
- }
- }
- return characters;
- };
|