Browse Source

修改bug & 优化

main
kkerwin 2 years ago
parent
commit
b2cb99535f
  1. 11
      projects/admin/src/app/components/user-list/user-list.component.html
  2. 8
      projects/admin/src/app/components/user-list/user-list.component.ts
  3. 11
      projects/admin/src/app/pages/dish/dish.component.html
  4. 4
      projects/admin/src/app/pages/dish/dish.component.less
  5. 9
      projects/admin/src/app/pages/dish/dish.component.ts
  6. 4
      projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.html
  7. 12
      projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.html
  8. 4
      projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts
  9. 1
      projects/admin/src/app/pages/system/user-manage/user-manage.component.html
  10. 10
      projects/cdk/src/services/api.service.ts
  11. 23
      projects/cdk/src/utils/index.ts
  12. 10
      projects/client/src/app/components/user-list/user-list.component.html
  13. 8
      projects/client/src/app/components/user-list/user-list.component.ts
  14. 69
      projects/client/src/app/pages/dashboard/dashboard.component.html
  15. 39
      projects/client/src/app/pages/dashboard/dashboard.component.less
  16. 11
      projects/client/src/app/pages/dish/dish.component.html
  17. 4
      projects/client/src/app/pages/dish/dish.component.less
  18. 10
      projects/client/src/app/pages/dish/dish.component.ts
  19. 17
      projects/client/src/app/pages/food/food.component.html
  20. 2
      projects/client/src/app/pages/food/food.component.ts
  21. 4
      projects/client/src/app/pages/ingredients/ingredient-form/ingredient-form.component.html
  22. 17
      projects/client/src/app/pages/system/org-info/org-info.component.ts
  23. 3
      projects/client/src/app/pages/system/user-manage/user-manage.component.html

11
projects/admin/src/app/components/user-list/user-list.component.html

@ -62,6 +62,16 @@
<input nz-input placeholder="请输入用户姓名" formControlName="name" />
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label nzSpan="6" nzRequired>
角色
</nz-form-label>
<nz-form-control nzSpan="12" [nzErrorTip]="formErrorTipsTpl">
<nz-select formControlName="roleId">
<nz-option *ngFor="let item of roleList" [nzValue]="item.id" [nzLabel]="item.roleName"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label nzSpan="6" nzRequired>
账号
@ -70,6 +80,7 @@
<input nz-input placeholder="请输入用户账号" formControlName="uid" />
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label nzSpan="6" nzRequired>
密码

8
projects/admin/src/app/components/user-list/user-list.component.ts

@ -38,6 +38,8 @@ export class UserListComponent implements OnChanges {
@Input() role!: UserRoleDTO;
@Input() roleList: UserRoleDTO[] = [];
@Output() onReload = new EventEmitter();
searchValue = "";
@ -48,6 +50,7 @@ export class UserListComponent implements OnChanges {
uid: new FormControl("", [FormValidators.required("请输入账号")]),
name: new FormControl("", [FormValidators.required("请输入姓名")]),
password: new FormControl("", [FormValidators.required("请输入密码")]),
roleId: new FormControl("", [FormValidators.required("请选择角色")]),
});
ngOnInit(): void {}
@ -88,6 +91,9 @@ export class UserListComponent implements OnChanges {
if (item) {
this.userFrom.patchValue(item);
}
this.userFrom.patchValue({
roleId: this.role.id,
});
this.modal.create({
nzTitle: item ? "编辑用户" : "新增用户",
nzContent: this.userFormTpl,
@ -96,7 +102,7 @@ export class UserListComponent implements OnChanges {
},
nzOnOk: async () => {
if (Utils.validateFormGroup(this.userFrom)) {
const user = { ...this.userFrom.value, roleId: this.role.id };
const user = { ...this.userFrom.value };
user["password"] = MD5(user.password!).toString().substring(16).toUpperCase();
let notExist = true;
if ((item && item.uid !== user.uid) || !item) {

11
projects/admin/src/app/pages/dish/dish.component.html

@ -2,7 +2,8 @@
<ng-template #pageExtraTpl>
<nz-space>
<button *nzSpaceItem nz-button [disabled]="!selectedIds.length" (click)="deleteItem()">批量删除</button>
<button *nzSpaceItem nz-button>批量打印营养标签</button>
<button *nzSpaceItem nz-button [disabled]="!selectedIds.length"
(click)="printTag()">批量打印营养标签</button>
<button *nzSpaceItem nz-button nzType="primary" (click)="showFoodForm()">
<i nz-icon nzType="plus"></i>
新增菜品
@ -98,13 +99,13 @@
<ng-template #printContent>
<div class="printContent"
*ngIf="printData">
*ngFor="let item of printData">
<table class="print-table">
<tbody>
<tr>
<th colspan="3">
{{printData.name}}
{{item.name}}
</th>
</tr>
<tr>
@ -125,7 +126,7 @@
</tr>
</tbody>
<tbody>
<tr *ngFor="let th of printData.component">
<tr *ngFor="let th of item.component">
<td [width]="'38.2%'">{{ th.name }}</td>
<td class="text-center">{{ th.nutrition }}</td>
<td class="text-center">{{ th.nvr }}</td>
@ -134,7 +135,7 @@
</tbody>
</table>
<div>
主要原料:{{printData.ingredients.join(',')}}
主要原料:{{item.ingredients.join(',')}}
</div>
<div>
1毫克(mg)钠相当于2.5毫克食盐

4
projects/admin/src/app/pages/dish/dish.component.less

@ -6,3 +6,7 @@
background-position: center;
background-repeat: no-repeat;
}
.printContent {
page-break-after: always;
}

9
projects/admin/src/app/pages/dish/dish.component.ts

@ -119,7 +119,7 @@ export class DishComponent {
{
title: "打印营养标签",
premissions: [],
onClick: this.print.bind(this),
onClick: this.printTag.bind(this),
},
{
title: "编辑",
@ -134,12 +134,13 @@ export class DishComponent {
]);
}
print(v: any) {
printTag(v?: any) {
this.msg.loading("数据请求中,请不要刷新页面", {
nzDuration: 0,
});
const ids = v ? [v.id] : this.selectedIds;
this.api
.getDishLabel(v.id)
.getDishLabel(ids)
.pipe(
finalize(() => {
setTimeout(() => {
@ -148,7 +149,7 @@ export class DishComponent {
})
)
.subscribe((res) => {
this.printData = res.body[0];
this.printData = res.body;
this.printRef.print();
});
}

4
projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.html

@ -23,9 +23,9 @@
<button *nzSpaceItem nz-button (click)="createNewMenu()">
新建食谱
</button>
<button *nzSpaceItem nz-button>
<!-- <button *nzSpaceItem nz-button>
导入食谱
</button>
</button> -->
<button *nzSpaceItem nz-button (click)="previewMenu()">
食谱预览
</button>

12
projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.html

@ -117,7 +117,7 @@
<ng-container *ngIf="p.nutritions.length > 0">
<h3 class="mb-2">每人每天能量和营养素供给量标准</h3>
<div nz-row [nzGutter]="[48,12]">
<div nz-col nzSpan="12" *ngFor="let n of p.nutritions">
<div nz-col nzSpan="24" nzXXl="12" *ngFor="let n of p.nutritions">
<div class="flex items-center">
<div class="w-40">
<nz-select nzPlaceHolder="请选择" class="w-full" [(ngModel)]="n.nutrition">
@ -128,15 +128,15 @@
</nz-select>
</div>
<div class="flex-1 ml-2">
<nz-space nzAlign="center">
<input *nzSpaceItem nz-input placeholder="最小值" type="number"
<div class="flex">
<input nz-input placeholder="最小值" type="number"
[(ngModel)]="n.min" />
<div class="px-2" *nzSpaceItem>
<div class="px-2 w-10">
~
</div>
<input *nzSpaceItem nz-input placeholder="最大值" type="number"
<input nz-input placeholder="最大值" type="number"
[(ngModel)]="n.max" />
</nz-space>
</div>
</div>
<div class="ml-2">
<nz-space nzAlign="center">

4
projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts

@ -72,7 +72,7 @@ export class StandardSettingComponent {
? []
: Object.entries(v).map(([kn, vn]) => {
return {
ul: vn?.ul ?? 0,
ul: vn?.ul ?? void 0,
hasUl: !!vn?.ul,
max: vn?.max ?? 0,
min: vn?.min ?? 0,
@ -126,7 +126,7 @@ export class StandardSettingComponent {
return {
...a,
[c.name]: c.nutritions.reduce((an, cn) => {
const ul = cn.hasUl ? { ul: cn.ul } : {};
const ul = { ul: cn.hasUl ? cn.ul : void 0 };
return {
...an,
[cn.nutrition]: {

1
projects/admin/src/app/pages/system/user-manage/user-manage.component.html

@ -57,6 +57,7 @@
*ngIf="role && tab.toString() === '0'"
[users]="currentUserList"
[role]="role"
[roleList]="roleList"
(onReload)="reloadUserList()">
</app-user-list>

10
projects/cdk/src/services/api.service.ts

@ -117,7 +117,7 @@ export class ApiService {
}
updateRole(rule: AnyObject) {
const body = Utils.objectToFormData(rule);
const body = Utils.objectToFormData(rule, true);
const method = rule["roleId"] ? "post" : "put";
return this.http[method]<ResponseType>("/api/role", body);
}
@ -269,13 +269,13 @@ export class ApiService {
);
}
markFood(mark: string, ingredient: string) {
const params = Utils.objectToFormData({ mark, ingredient });
markFood(mark: string, key: string) {
const params = Utils.objectToFormData({ mark, key });
return this.http.put<ResponseType>("/api/ingredient/mark", params);
}
removeFoodMark(ingredient: string) {
const params = Utils.objectToFormData({ ingredient });
removeFoodMark(key: string) {
const params = Utils.objectToFormData({ key });
return this.http.delete<ResponseType>("/api/ingredient/mark", { body: params });
}

23
projects/cdk/src/utils/index.ts

@ -61,15 +61,20 @@ export class Utils {
return params;
}
static objectToFormData(obj: AnyObject): FormData {
static objectToFormData(obj: AnyObject, arrayComma?: boolean): FormData {
let params = new FormData();
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
let value = obj[key];
if (![void 0, null, ""].includes(value)) {
if (typeof value === "object" && !Array.isArray(value)) {
params.append(key, JSON.stringify(value));
if (typeof value === "object") {
if (arrayComma && Array.isArray(value)) {
params.append(key, value.join(","));
} else {
params.append(key, JSON.stringify(value));
}
} else {
params.append(key, value);
}
@ -80,18 +85,6 @@ export class Utils {
return params;
}
static buildFormData = (formData: FormData, data: any, parentKey = "") => {
if (data && typeof data === "object" && !(data instanceof Date) && !(data instanceof File)) {
Object.keys(data).forEach((key) => {
Utils.buildFormData(formData, data[key], parentKey ? `${parentKey}[${key}]` : key);
});
} else {
const value = data == null ? "" : data;
formData.append(parentKey, value);
}
};
static objectStringify(o: AnyObject, option?: StringifyOptions) {
const config = {
skipEmptyString: true,

10
projects/client/src/app/components/user-list/user-list.component.html

@ -62,6 +62,16 @@
<input nz-input placeholder="请输入用户姓名" formControlName="name" />
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label nzSpan="6" nzRequired>
角色
</nz-form-label>
<nz-form-control nzSpan="12" [nzErrorTip]="formErrorTipsTpl">
<nz-select formControlName="roleId">
<nz-option *ngFor="let item of roleList" [nzValue]="item.id" [nzLabel]="item.roleName"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label nzSpan="6" nzRequired>
账号

8
projects/client/src/app/components/user-list/user-list.component.ts

@ -38,6 +38,8 @@ export class UserListComponent implements OnChanges {
@Input() role!: UserRoleDTO;
@Input() roleList: UserRoleDTO[] = [];
@Output() onReload = new EventEmitter();
searchValue = "";
@ -48,6 +50,7 @@ export class UserListComponent implements OnChanges {
uid: new FormControl("", [FormValidators.required("请输入账号")]),
name: new FormControl("", [FormValidators.required("请输入姓名")]),
password: new FormControl("", [FormValidators.required("请输入密码")]),
roleId: new FormControl("", [FormValidators.required("请选择角色")]),
});
ngOnInit(): void {}
@ -88,6 +91,9 @@ export class UserListComponent implements OnChanges {
if (item) {
this.userFrom.patchValue(item);
}
this.userFrom.patchValue({
roleId: this.role.id,
});
this.modal.create({
nzTitle: item ? "编辑用户" : "新增用户",
nzContent: this.userFormTpl,
@ -96,7 +102,7 @@ export class UserListComponent implements OnChanges {
},
nzOnOk: async () => {
if (Utils.validateFormGroup(this.userFrom)) {
const user = { ...this.userFrom.value, roleId: this.role.id };
const user = { ...this.userFrom.value };
user["password"] = MD5(user.password!).toString().substring(16).toUpperCase();
let notExist = true;
if ((item && item.uid !== user.uid) || !item) {

69
projects/client/src/app/pages/dashboard/dashboard.component.html

@ -1,5 +1,74 @@
<app-page [pageTitle]="'使用流程'">
<nz-card>
<div class="flow">
<div class="ellipse item">
开始
</div>
<div class="item">
进入【配餐设置】,修改三餐摄入能量、营养比例
<span class="arrow" nz-icon nzType="down" nzTheme="outline"></span>
</div>
<div class="item">
进入【菜品管理】,新增/编辑菜品,并打印营养标签
<span class="arrow" nz-icon nzType="down" nzTheme="outline"></span>
</div>
<div class="item">
进入【食谱管理-食谱库】,创建食谱
<span class="arrow" nz-icon nzType="down" nzTheme="outline"></span>
</div>
<div class="item">
<span class="arrow" nz-icon nzType="down" nzTheme="outline"></span>
<div>
1、填写食谱名称
</div>
<div>
2、选择营养标准
</div>
<div>
3、选择适用月份
</div>
<div>
4、选择配餐天数
</div>
<div>
5、选择配餐餐次
</div>
</div>
<div class="item">
<span class="arrow" nz-icon nzType="down" nzTheme="outline"></span>
<div>
1、按餐次添加菜品及重量
</div>
<div>
2、根据营养分析实时调整菜品
</div>
</div>
<div class="item">
<span class="arrow" nz-icon nzType="down" nzTheme="outline"></span>
<div>
1、点击右上角【食谱预览】完成查看食谱全貌
</div>
<div>
2、确认食谱应用分析结果
</div>
</div>
<div class="item">
<span class="arrow" nz-icon nzType="down" nzTheme="outline"></span>
保存食谱
</div>
<div class="item">
<span class="arrow" nz-icon nzType="down" nzTheme="outline"></span>
在食谱库列表中发起审核
</div>
<div class="item">
<span class="arrow" nz-icon nzType="down" nzTheme="outline"></span>
等待审核通过后发布食谱
</div>
<div class="item ellipse">
<span class="arrow" nz-icon nzType="down" nzTheme="outline"></span>
结束
</div>
</div>
</nz-card>
</app-page>

39
projects/client/src/app/pages/dashboard/dashboard.component.less

@ -0,0 +1,39 @@
.flow {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
.item {
width: 256px;
margin-bottom: 48px;
padding: 24px;
position: relative;
border-radius: 4px;
border: 1px solid #333;
text-align: center;
&:not(:last-child):after {
content: '';
width: 1px;
height: 48px;
position: absolute;
bottom: -48px;
left: 50%;
transform: translateX(-50%);
background-color: #333;
}
&.ellipse {
width: 180px;
border-radius: 50%;
}
.arrow {
position: absolute;
left: 50%;
top: -12px;
transform: translateX(-50%);
}
}
}

11
projects/client/src/app/pages/dish/dish.component.html

@ -26,7 +26,8 @@
<nz-space>
<button *nzSpaceItem nz-button [disabled]="!selectedIds.length"
(click)="deleteItem()">批量删除</button>
<button *nzSpaceItem nz-button>批量打印营养标签</button>
<button *nzSpaceItem nz-button [disabled]="!selectedIds.length"
(click)="printTag()">批量打印营养标签</button>
<button *nzSpaceItem nz-button nzType="primary" (click)="showFoodForm()">
<i nz-icon nzType="plus"></i>
新增菜品
@ -106,13 +107,13 @@
<ng-template #printContent>
<div class="printContent"
*ngIf="printData">
*ngFor="let item of printData">
<table class="print-table">
<tbody>
<tr>
<th colspan="3">
{{printData.name}}
{{item.name}}
</th>
</tr>
<tr>
@ -133,7 +134,7 @@
</tr>
</tbody>
<tbody>
<tr *ngFor="let th of printData.component">
<tr *ngFor="let th of item.component">
<td [width]="'38.2%'">{{ th.name }}</td>
<td class="text-center">{{ th.nutrition }}</td>
<td class="text-center">{{ th.nvr }}</td>
@ -142,7 +143,7 @@
</tbody>
</table>
<div>
主要原料:{{printData.ingredients.join(',')}}
主要原料:{{item.ingredients.join(',')}}
</div>
<div>
1毫克(mg)钠相当于2.5毫克食盐

4
projects/client/src/app/pages/dish/dish.component.less

@ -16,3 +16,7 @@
background-position: center;
background-repeat: no-repeat;
}
.printContent {
page-break-after: always;
}

10
projects/client/src/app/pages/dish/dish.component.ts

@ -100,7 +100,7 @@ export class DishComponent {
{
title: "打印营养标签",
premissions: [],
onClick: this.print.bind(this),
onClick: this.printTag.bind(this),
},
{
title: "编辑",
@ -147,12 +147,13 @@ export class DishComponent {
}
}
print(v: any) {
printTag(v?: any) {
this.msg.loading("数据请求中,请不要刷新页面", {
nzDuration: 0,
});
const ids = v ? [v.id] : this.selectedIds;
this.api
.getDishLabel(v.id)
.getDishLabel(ids)
.pipe(
finalize(() => {
setTimeout(() => {
@ -161,9 +162,8 @@ export class DishComponent {
})
)
.subscribe((res) => {
this.printData = res.body[0];
this.printData = res.body;
this.printRef.print();
this.msg.remove();
});
}

17
projects/client/src/app/pages/food/food.component.html

@ -53,18 +53,11 @@
<ng-template #renderColumnsTpl let-data let-key="key" let-row="row">
<ng-container [ngSwitch]="key">
<ng-container *ngSwitchCase="'nutrientArr'">
<a nz-popover
[nzPopoverContent]="popoverTpl"
nzPopoverTitle="营养素">
<b>{{data.length}}</b>中营养素
</a>
<ng-template #popoverTpl>
<div class=" max-w-sm max-h-60 overflow-auto">
<nz-tag *ngFor="let item of data" class="m-1">
{{item.label}}:{{item.value}}{{item.measurement}}
</nz-tag>
</div>
</ng-template>
<div class="flex flex-wrap">
<nz-tag *ngFor="let item of data" class="m-1">
{{item.label}}:{{item.value}}{{item.measurement}}
</nz-tag>
</div>
</ng-container>
<ng-container *ngSwitchCase="'mark'">
<nz-tag *ngIf="data === '常用'" nzColor="success">{{data}}</nz-tag>

2
projects/client/src/app/pages/food/food.component.ts

@ -60,7 +60,7 @@ export class FoodComponent implements OnInit, OnDestroy {
{ key: "name", title: "食材名称" },
{ key: "type", title: "食材类型" },
{ key: "mark", title: "标签" },
{ key: "nutrientArr", title: "营养素(每100g可食部)" },
{ key: "nutrientArr", title: "营养素(每100g可食部)", width: "40%" },
]);
this.tableList = this.tableList.setOptions([

4
projects/client/src/app/pages/ingredients/ingredient-form/ingredient-form.component.html

@ -25,9 +25,9 @@
<button *nzSpaceItem nz-button (click)="createNewMenu()">
新建食谱
</button>
<button *nzSpaceItem nz-button>
<!-- <button *nzSpaceItem nz-button>
导入食谱
</button>
</button> -->
<button *nzSpaceItem nz-button (click)="previewMenu()">
食谱预览
</button>

17
projects/client/src/app/pages/system/org-info/org-info.component.ts

@ -1,4 +1,4 @@
import { Component, OnInit, TemplateRef } from "@angular/core";
import { ChangeDetectorRef, Component, OnInit, TemplateRef } from "@angular/core";
import { NzModalService } from "ng-zorro-antd/modal";
import { format } from "date-fns";
import { ApiService } from "@cdk/services";
@ -21,7 +21,8 @@ export class OrgInfoComponent implements OnInit {
private api: ApiService,
private modal: NzModalService,
private msg: NzMessageService,
private router: Router
private router: Router,
private cdr: ChangeDetectorRef
) {}
account: any = this.api.account;
@ -55,6 +56,18 @@ export class OrgInfoComponent implements OnInit {
if (Utils.validateFormGroup(e.formGroup)) {
const res = await lastValueFrom(this.api.saveOrg({ ...e.formGroup.value, venderId: this.account.vender.id }));
this.msg.success(res.desc);
localStorage.setItem(
this.api.accountKey,
JSON.stringify({
...this.account,
vender: {
...this.account.vender,
...e.formGroup.value,
venderId: this.account.vender.id,
},
})
);
window.location.reload();
return true;
}
return false;

3
projects/client/src/app/pages/system/user-manage/user-manage.component.html

@ -3,7 +3,7 @@
<div nz-row class="h-full overflow-hidden bg-white rounded-lg">
<div nz-col nzFlex="220px" class="user-type h-full">
<nz-card
class="h-full flex"
class="h-full flex flex-col"
[nzBordered]="false"
nzTitle="用户角色"
[nzBodyStyle]="{padding:'1px 0 0 0',flex:'1', 'overflow':'hidden'}">
@ -56,6 +56,7 @@
*ngIf="role && tab.toString() === '0'"
[users]="currentUserList"
[role]="role"
[roleList]="roleList"
(onReload)="reloadUserList()">
</app-user-list>

Loading…
Cancel
Save