This commit is contained in:
wangshiming
2021-11-30 10:17:00 +08:00
parent 08d5b09401
commit 30dcfbb4f1
18 changed files with 1411 additions and 13 deletions

View File

@ -0,0 +1,24 @@
<div class="main">
<nz-card [nzTitle]="formTitle" style="margin-top: 20px">
<div class="myForm">
<sf #sf [compact]="true" [ui]="ui" [schema]="schema" [button]="'none'" [formData]="formData"></sf>
<form nz-form>
<nz-form-item>
<nz-form-control [nzSpan]="24" [nzOffset]="5" *ngIf="this.formData?.type !== 'view'">
<button
nz-button
type="button"
nzType="primary"
(click)="formSubmit()"
[disabled]="!sf.valid"
[nzLoading]="service.http.loading"
>
保存
</button>
<button nz-button type="button" (click)="goBack()">取消</button>
</nz-form-control>
</nz-form-item>
</form>
</div>
</nz-card>
</div>

View File

@ -0,0 +1,6 @@
:host {
.myForm {
width: 600px;
margin: 3rem 0;
}
}

View File

@ -0,0 +1,23 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CmcComponentsTagsAddComponent } from './edit-info.component';
describe('CmcComponentsTagsAddComponent', () => {
let component: CmcComponentsTagsAddComponent;
let fixture: ComponentFixture<CmcComponentsTagsAddComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [CmcComponentsTagsAddComponent],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CmcComponentsTagsAddComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,260 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { SFComponent, SFSchema, SFSelectWidgetSchema, SFUISchema } from '@delon/form';
import { ModalHelper } from '@delon/theme';
import { GoodsService } from 'src/app/routes/cmc/services/goods.service';
@Component({
selector: 'app-cmc-components-add',
templateUrl: './add.component.html',
styleUrls: ['./add.component.less'],
})
export class CmcComponentsTagsAddComponent implements OnInit {
@ViewChild('sf', { static: false })
sf!: SFComponent;
i: any;
schema!: SFSchema;
ui!: SFUISchema;
cateData: any = [];
formTitle: any = '新增标签';
formData: any = {
// avatar:[
// {
// uid: -1,
// name: 'LOGO',
// status: 'done',
// url: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
// response: {
// url: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
// },
// },
// ],
// name:'西四'
};
constructor(public service: GoodsService, private modal: ModalHelper, private route: ActivatedRoute) {
const { flag, type, id } = route.snapshot?.queryParams;
Object.assign(this.formData, { flag, type, id });
}
ngOnInit() {
this.initSF();
if (this.formData.flag !== '3') {
this.getCates();
} else {
this.getBusinessCates();
}
// console.log(this.formData, 'this.formData');
if (this.formData.type === 'edit') {
this.formTitle = '编辑标签';
}
if (this.formData.type === 'view') {
this.formTitle = '查看标签';
}
if (this.formData.type !== 'add') {
if (this.formData.flag !== '3') {
this.getInfo();
} else {
this.getBusinessInfo();
}
}
}
initSF() {
this.schema = {
properties: {
name: {
title: '标签名称',
type: 'string',
maxLength: 8,
},
categoryId: {
title: '关联分类',
type: 'string',
default: this.formData?.categoryId || [],
enum: this.cateData,
ui: {
widget: 'tree-select',
checkable: true, // 节点前添加 Checkbox 复选框
allowClear: true, // 支持清除
virtualHeight: '480px',
// checkStrictly: true, // checkable 状态下节点选择完全受控(父子节点选中状态不再关联)
// defaultExpandAll: false, // 默认展开所有树节点
// expandedKeys: this.formData?.categoryId || [], // 默认展开指定的树节点
change: (e) => {
console.log(e);
},
// valueProperty: 'key',
// labelProperty: 'title',
// asyncData: () =>
// this.service.request(this.service.$api_get_labelCategorys).pipe(
// map((data: any) => {
// return data.map((m: any) => {
// return { title: m.name, key: m.id };
// });
// }),
// ),
} as SFSelectWidgetSchema,
},
remark: {
title: '标签介绍',
type: 'string',
maxLength: 50,
ui: {
widget: 'textarea',
placeholder: '请输入标签介绍',
autosize: { minRows: 3, maxRows: 6 },
errors: {
required: '请输入标签介绍',
},
},
},
},
required: ['name', 'categoryId', 'remark'],
};
this.ui = {
'*': {
spanLabel: 5,
grid: { span: 24 },
},
};
}
getCates() {
const params = {
flag: this.formData.flag,
};
const cateApi = this.service.$api_get_category_treeList;
this.service.request(cateApi, params).subscribe((res) => {
// res.map((i: any) => {
// i.key = i.id;
// i.title = i.name;
// if (i.children) {
// i.children.map((j: any) => {
// j.key = j.id;
// j.title = j.name;
// if (j.children) {
// j.children.map((k: any) => {
// k.key = k.id;
// k.title = k.name;
// });
// }
// });
// }
// });
this.cateData = res;
this.initSF();
});
}
getBusinessCates() {
const params = {
flag: this.formData.flag,
};
const cateApi = this.service.$api_get_business_cateList;
this.service.request(cateApi, params).subscribe((res) => {
// res.map((i: any) => {
// i.key = i.id;
// i.title = i.name;
// if (i.children) {
// i.children.map((j: any) => {
// j.key = j.id;
// j.title = j.name;
// if (j.children) {
// j.children.map((k: any) => {
// k.key = k.id;
// k.title = k.name;
// });
// }
// });
// }
// });
this.cateData = res;
this.initSF();
});
}
getInfo() {
const params = {
labelId: this.formData.id,
};
this.service.http.post(this.service.$api_get_labelDetail, params).subscribe((res) => {
const resData = res.data;
if (res.data?.categoryIds) {
resData.categoryId = res.data?.categoryIds.split(',');
}
delete resData.categoryIds;
Object.assign(this.formData, resData);
// console.log(this.formData, 'this.formData');
this.initSF();
});
}
getBusinessInfo() {
const params = {
id: this.formData.id,
};
this.service.http.post(this.service.$api_get_business_labelDetail, params).subscribe((res) => {
const resData = res.data;
if (res.data?.categoryIdList) {
resData.categoryId = res.data?.categoryIdList;
}
delete resData.categoryIdList;
Object.assign(this.formData, resData);
this.initSF();
});
}
formSubmit() {
const cateIds: any[] = [];
let saveApi = this.service.$api_label_save;
if (this.formData.flag !== '3') {
this.sf.value.categoryId.map((i: any) => {
this.cateData.map((j: any) => {
if (j.children) {
if (i === j.key) {
j.children.map((k: any) => {
if (k.children) {
k.children.map((m: any) => {
cateIds.push(m.key);
});
} else {
cateIds.push(k.key);
}
});
} else if (i !== j.key) {
j.children.map((k: any) => {
if (i === k.key && k.children) {
k.children.map((m: any) => {
cateIds.push(m.key);
});
} else {
cateIds.push(i);
}
});
}
} else {
if (i === j.key) {
cateIds.push(i);
}
}
});
});
}
const params: any = {
...this.sf.value,
};
if (this.formData.flag !== '3') {
const uniqueArr = [...new Set(cateIds)];
params.categoryId = uniqueArr.toString();
saveApi = this.service.$api_label_save;
} else {
saveApi = this.service.$api_business_label_save;
params.categoryIdList = this.sf.value.categoryId;
delete params.categoryId;
}
this.service.http.post(saveApi, params).subscribe((res) => {
if (res.data) {
this.service.msgSrv.success('提交成功');
this.goBack();
}
});
}
goBack() {
history.go(-1);
}
}

View File

@ -0,0 +1,92 @@
<page-header-wrapper [title]="'企业审核列表'" [content]="content">
<nz-card>
<!-- 搜索表单 -->
<div nz-row nzGutter="8">
<!-- 查询字段小于或等于3个时不显示伸缩按钮 -->
<div nz-col nzSpan="24" *ngIf="queryFieldCount <= 4">
<sf
#sf
[schema]="schema"
[ui]="ui"
[mode]="'search'"
[disabled]="!sf?.valid"
[loading]="service.http.loading"
(formSubmit)="st?.load(1)"
(formReset)="resetSF()"
></sf>
</div>
<!-- 查询字段大于3个时根据展开状态调整布局 -->
<ng-container *ngIf="queryFieldCount > 4">
<div nz-col [nzSpan]="_$expand ? 24 : 18">
<sf #sf [schema]="schema" [ui]="ui" [compact]="true" [button]="'none'"></sf>
</div>
<div nz-col [nzSpan]="_$expand ? 24 : 6" [class.text-right]="_$expand">
<button nz-button nzType="primary" [disabled]="!sf.valid" [nzLoading]="service.http.loading" (click)="st?.load(1)">查询</button>
<button nz-button (click)="resetSF()">重置</button>
<button nz-button nzType="primary" [nzLoading]="service.http.loading" (click)="st?.load(1)">导出</button>
<button nz-button nzType="link" (click)="expandToggle()">
{{ !_$expand ? '展开' : '收起' }}
<i nz-icon [nzType]="!_$expand ? 'down' : 'up'"></i>
</button>
</div>
</ng-container>
</div>
</nz-card>
<div style="margin-bottom: 20px; text-align: right"></div>
<nz-card nzTitle="标签列表" >
<!-- 数据列表 -->
<st
#st
multiSort
[data]="datalist"
[columns]="columns"
[req]="{ method: 'POST', allInBody: true, reName: { pi: 'pageIndex', ps: 'pageSize' }, params: reqParams }"
[res]="{ reName: { list: 'data.records', total: 'data.total' } }"
[page]="{ show: true, showSize: true, pageSizes: [10, 20, 30, 50, 100, 200, 300, 500, 1000] }"
[loading]="service.http.loading"
>
</st>
</nz-card>
<ng-template #content>
<nz-tabset class="tabs-wrap">
<nz-tab *ngFor="let tab of tabs" [nzTitle]="tab.name" (nzSelect)="changeTab(tab)"> </nz-tab>
</nz-tabset>
</ng-template>
</page-header-wrapper>
<!-- <nz-modal
[(nzVisible)]="isVisible"
[nzTitle]="mdTitle"
[nzFooter]="modalFooter"
(nzOnCancel)="handleCancel()"
(nzOnOk)="handleOk()"
[nzWidth]="700"
>
<ng-container>
</ng-container>
<ng-template #modalFooter>
<button nz-button nzType="default" (click)="handleCancel()">取消</button>
<button
nz-button
nzType="primary"
*ngIf="mdType === 2"
[disabled]="!sf1?.valid"
(click)="handleOk()"
[nzLoading]="service.http.loading"
>
确定
</button>
<button
nz-button
nzType="primary"
*ngIf="mdType === 3"
[disabled]="!sf1?.valid"
(click)="handleOk()"
[nzLoading]="service.http.loading"
>
重新提交
</button>
<button nz-button nzType="primary" *ngIf="mdType === 4" (click)="handleCancel()">确定</button>
</ng-template>
</nz-modal> -->

View File

@ -0,0 +1,10 @@
:host {
::ng-deep {
.tabs-wrap > .ant-tabs-nav {
margin-bottom: 0;
}
.myForm .ant-upload.ant-upload-select-picture-card > .ant-upload {
flex-direction: column !important;
}
}
}

View File

@ -0,0 +1,23 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CmcComponentsTagsComponent } from './tags.component';
describe('CmcComponentsTagsComponent', () => {
let component: CmcComponentsTagsComponent;
let fixture: ComponentFixture<CmcComponentsTagsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [CmcComponentsTagsComponent],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CmcComponentsTagsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,310 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { STChange, STColumn, STComponent, STData } from '@delon/abc/st';
import { SFComponent, SFSchema, SFUISchema } from '@delon/form';
import { NzModalService } from 'ng-zorro-antd/modal';
import { UsermanageService } from '../../../services/usercenter.service';
@Component({
selector: 'app-Freight-components-enterprise-audit',
templateUrl: './enterprise-audit.component.html',
styleUrls: ['./enterprise-audit.component.less'],
})
export class FreightComponentsEnterpriseAuditComponent implements OnInit {
_$expand = false;
ui!: SFUISchema;
schema!: SFSchema;
columns!: STColumn[];
@ViewChild('st', { static: false }) st!: STComponent;
@ViewChild('sf', { static: false }) sf!: SFComponent;
tabType = 1;
tabs = [
{
name: '企业审核',
type: 1,
isActived: false,
},
{
name: '企业管理员审核',
type: 2,
isActived: false,
},
];
datalist = [
{
storeName: '企业名称',
contactsName: '152746565',
enterpriseName: '湖南',
unifiedSocialCreditCode: '45454',
contactsPhone: '*97889461561',
effectiveDateStr: '废弃eww',
enStatusStr2: '已驳回',
enStatusStr3: '正常',
unifiedSocialCreditCode3: '常用服务',
unifiedSocialCreditCode2: '正常',
tenantId: 1
},
{
storeName: '企业名称',
contactsName: '152746565',
enterpriseName: '湖南',
unifiedSocialCreditCode: '45454',
contactsPhone: '*97889461561',
effectiveDateStr: '废弃eww',
enStatusStr2: '待审核',
enStatusStr3: '正常',
unifiedSocialCreditCode3: '常用服务',
unifiedSocialCreditCode2: '正常',
tenantId: 2
},
]
isVisible = false;
mdType!: any;
cateData = [];
// stApi = this.service.$api_get_labelList;
constructor(public service: UsermanageService, private router: Router, private modal: NzModalService) {}
/**
* 查询字段个数
*/
get queryFieldCount(): number {
return Object.keys(this.schema?.properties || {}).length;
}
/**
* 查询参数
*/
get reqParams() {
const params = Object.assign({}, this.sf?.value || {}, {
flag: this.tabType,
});
delete params._$expand;
return { ...params };
}
/**
* 选中行
*/
get selectedRows() {
return this.st?.list.filter((item) => item.checked) || [];
}
/**
* 伸缩查询条件
*/
expandToggle() {
this._$expand = !this._$expand;
this.sf?.setValue('/expand', this._$expand);
}
/**
* 重置表单
*/
resetSF() {
this.sf.reset();
this._$expand = false;
}
/**
* 程序初始化入口
*/
ngOnInit() {
this.initSF();
this.initST();
}
/**
* 初始化查询表单
*/
initSF() {
this.schema = {
properties: {
expand: { type: 'boolean', ui: { hidden: true } },
name: { title: '企业名称', type: 'string' },
contactsName: {
title: '联系人',
type: 'string',
ui: {
showRequired: false,
},
},
phone: {
title: '手机号',
type: 'string',
format: 'mobile',
maxLength: 11,
ui: {
placeholder: '请输入手机号',
},
},
enStatus2: {
type: 'string',
title: '状态',
enum: [
{ label: '全部', value: '' },
{ label: '正常', value: 0 },
{ label: '冻结', value: 1 },
{ label: '废弃', value: 2 },
],
default: '',
ui: {
widget: 'select',
visibleIf: {
expand: (value: boolean) => value,
},
},
},
},
};
this.ui = { '*': { spanLabelFixed: 100, grid: { span: 8, gutter: 4 } } };
}
/**
* 初始化数据列表
*/
initST() {
this.columns = [
{ title: '企业名称', className: 'text-center', index: 'storeName' },
{ title: '联系人', className: 'text-center', index: 'contactsName' },
{ title: '税源地', className: 'text-center', render: 'enterpriseName' },
{ title: '累计运单金额', className: 'text-center', index: 'unifiedSocialCreditCode' },
{
title: '状态',
className: 'text-center',
index: 'enStatusStr2',
type: 'badge',
badge: {
: { text: '待审核', color: 'success' },
: { text: '已驳回', color: 'warning' },
},
},
{ title: '常用服务', className: 'text-center', index: 'unifiedSocialCreditCode3' },
{ title: '推广业务员', className: 'text-center', index: 'unifiedSocialCreditCode2' },
{
title: '操作',
fixed: 'right',
width: '180px',
className: 'text-center',
buttons: [
{ text: '查看', click: (_record) => this.addOne('view', _record) },
],
},
];
}
/**
* 数据列表状态变化事件
*/
change(e: STChange) {
// console.log(e.checkbox);
}
/**
* 新增实例
*/
addOne(type: any, record: any) {
// this.router.navigate(['../add'], { relativeTo: this.ar });
this.router.navigate(['/cmc/tags/add'], {
queryParams: {
id: record.id,
type,
flag: this.tabType,
},
});
}
/**
* 编辑单个实例
* @param record 记录实例
*/
editOne(record: STData) {
// this.router.navigate(['../edit', record.uuid], { relativeTo: this.ar });
}
/**
* 删除单个实例
* @param record 记录实例
*/
delOne(record: STData) {
// let delApi = this.service.$api_label_deletebatch;
// if (this.tabType === 3) {
// delApi = this.service.$api_business_label_delete;
// } else {
// delApi = this.service.$api_label_deletebatch;
// }
this.modal.confirm({
nzTitle: '<i>删除确认</i>',
nzContent: `<b>即将删除 当前行数据,请仔细核对,避免误操作!<br>是否删除?</br>`,
nzOnOk: () =>
console.log('1')
// this.service.http.post(delApi, [record.id]).subscribe((res) => {
// console.log(res, 'del');
// if (res === true || res.data === true) {
// this.service.msgSrv.success('删除成功!');
// setTimeout(() => {
// this.st?.reload();
// }, 500);
// } else {
// this.service.msgSrv.error('删除失败!');
// }
// }),
});
}
/**
* 删除多个实例
*/
delMany(record: STData) {
this.modal.confirm({
nzTitle: '<i>删除确认</i>',
nzContent: `<b>即将删除 当前行数据,请仔细核对,避免误操作!<br>是否删除?</br>`,
nzOnOk: () =>
console.log('')
// this.service.http.post(this.service.$api_label_deletebatch, [record.id]).subscribe((res) => {
// if (res === true) {
// this.service.msgSrv.success('删除成功!');
// this.st?.reload();
// }
// }),
});
/*
const delData = this.st.list.filter((item) => item.checked).map((item) => item.id);
if (delData.length > 0) {
this.modal.confirm({
nzTitle: '<i>删除确认</i>',
nzContent: `<b>即将删除 <i>${delData.length}</i> 条数据,请仔细核对,避免误操作!<br>是否删除?</br>`,
nzOnOk: () =>
this.service.delMany(delData).subscribe((res) => {
if (res === true) {
this.service.msgSrv.success('数据删除成功!');
this.st?.reload();
}
}),
});
}
*/
}
// 切换Tab
changeTab(item: any) {
this.tabType = item.type;
this.sf?.reset();
// if (item.type === 3) {
// this.stApi = this.service.$api_get_business_labelList;
// } else {
// this.stApi = this.service.$api_get_labelList;
// }
// setTimeout(() => {
// this.tabs.forEach((i) => (i.isActived = false));
// item.isActived = !item.isActived;
// this.st.load(1);
// this.st.resetColumns();
// }, 500);
}
// checkType(): boolean {
// return this.mdType === 2 ? true : false;
// }
}