This commit is contained in:
Taric Xin
2022-02-24 20:21:20 +08:00
parent f7efbe28c0
commit f69d4595a9
7 changed files with 227 additions and 19 deletions

View File

@ -16,8 +16,41 @@
</div>
</nz-card>
<nz-card>
<div class="d-flex align-items-center mb-md " style="justify-content: end;">
<button nz-button (click)="editRoleBatch()">修改角色</button>
<button nz-button (click)="editIWBatch()">修改网络货运人</button>
<div class="ml-md">
已选择
<strong class="text-primary">{{ selectedRows.length }}</strong> 条数据
<a *ngIf="selectedRows.length > 0" (click)="st.clearCheck()" class="ml-lg">清空</a>
</div>
</div>
<!-- 数据列表 -->
<st #st [columns]="columns" [data]='service.$api_freight_config_page' [req]="{ process: beforeReq }"
[scroll]="{ x: '1200px' }" [loading]="service.http.loading">
[scroll]="{ x: '1200px' }" [loading]="service.http.loading" (change)="stChange($event)">
</st>
</nz-card>
</nz-card>
<ng-template #IWModal>
<div nz-row nzGutter="8">
<div nz-col nzSpan="24" se-container [labelWidth]="120">
<se [col]="1" label="网络货运人" required>
<nz-select nzPlaceHolder="请选择" [(ngModel)]="networkTransporter">
<nz-option [nzValue]="item.value" [nzLabel]="item.label" *ngFor="let item of ltdId"></nz-option>
</nz-select>
</se>
</div>
</div>
</ng-template>
<ng-template #roleModal>
<div nz-row nzGutter="8">
<div nz-col nzSpan="24" se-container [labelWidth]="120">
<se [col]="1" label="企业角色" required>
<nz-select nzPlaceHolder="请选择" [(ngModel)]="roleId">
<nz-option [nzValue]="item.value" [nzLabel]="item.label" *ngFor="let item of roles"></nz-option>
</nz-select>
</se>
</div>
</div>
</ng-template>

View File

@ -1,6 +1,6 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { STColumn, STComponent, STRequestOptions, STData } from '@delon/abc/st';
import { STColumn, STComponent, STRequestOptions, STData, STChange } from '@delon/abc/st';
import { SFUISchema, SFSchema, SFComponent } from '@delon/form';
import { ShipperBaseService, DynamicSettingModalComponent } from '@shared';
import { NzModalService } from 'ng-zorro-antd/modal';
@ -18,10 +18,22 @@ export class FreightConfigComponent implements OnInit {
@ViewChild('st', { static: false }) st!: STComponent;
@ViewChild('sf', { static: false }) sf!: SFComponent;
selectedRows: any[] = [];
@ViewChild('IWModal', { static: false })
IWModal!: any;
@ViewChild('roleModal', { static: false })
roleModal!: any;
ltdId: any = [];
roles: any = [];
networkTransporter = null;
roleId = null;
constructor(public service: UsermanageService, private modal: NzModalService, public shipperservice: ShipperBaseService) {}
ngOnInit() {
this.initST();
this.loadltdId();
this.loadRoles();
}
beforeReq = (requestOptions: STRequestOptions) => {
@ -34,6 +46,14 @@ export class FreightConfigComponent implements OnInit {
return requestOptions;
};
stChange(e: STChange): void {
switch (e.type) {
case 'checkbox':
this.selectedRows = e.checkbox!;
break;
}
}
settingAction(item?: any) {
const modal = this.modal.create({
nzTitle: '配置',
@ -44,20 +64,20 @@ export class FreightConfigComponent implements OnInit {
businessId: item.id,
formatTypeList: (item: any[]) => [
...item,
// {
// name: '权限配置',
// items: [
// {
// configType: 1,
// itemType: 999
// }
// ]
// },
{
name: '费率变更记录',
name: '权限配置',
configType: 1,
items: [
{
itemType: 999
}
]
},
{
name: '费率变更记录',
configType: 2,
items: [
{
configType: 2,
itemType: 999
}
]
@ -73,6 +93,68 @@ export class FreightConfigComponent implements OnInit {
});
}
editRoleBatch() {
if (this.selectedRows?.length <= 0) {
this.service.msgSrv.warning('请选择企业');
return;
}
this.roleId = null;
const modal = this.modal.create({
nzTitle: '修改角色',
nzContent: this.roleModal,
nzOnOk: () => {
if (!this.roleId) {
return false;
}
this.service
.request(this.service.$api_update_enter_role_batch, {
enterpriseIdList: this.selectedRows.map(i => i.id),
roleId: this.roleId
})
.subscribe((res: Array<string>) => {
if (res) {
this.service.msgSrv.success('修改成功');
this.st.load(1);
modal.destroy();
}
});
return false;
}
});
}
editIWBatch() {
if (this.selectedRows?.length <= 0) {
this.service.msgSrv.warning('请选择企业');
return;
}
this.networkTransporter = null;
const modal = this.modal.create({
nzTitle: '修改网络货运人',
nzContent: this.IWModal,
nzOnOk: () => {
if (!this.networkTransporter) {
return false;
}
this.service
.request(this.service.$api_update_enter_newowork_batch, {
enterpriseIdList: this.selectedRows.map(i => i.id),
networkTransporterId: this.networkTransporter
})
.subscribe((res: Array<string>) => {
if (res && res.length === 0) {
this.service.msgSrv.success('修改成功');
this.st.load(1);
modal.destroy();
} else {
this.service.msgSrv.error(`企业${res?.join(',')}修改失败`);
}
});
return false;
}
});
}
exportList() {
const params = {};
if (this.sf) {
@ -83,6 +165,21 @@ export class FreightConfigComponent implements OnInit {
this.service.downloadFile(this.service.$api_export_enterprise, params);
}
loadltdId() {
this.service.getNetworkFreightForwarder().subscribe(res => {
if (res) {
this.ltdId = res;
}
});
}
loadRoles() {
this.service.getRoles({ enterpriseId: 0, projectId: 0 }).subscribe(res => {
if (res) {
this.roles = res;
}
});
}
/**
* 重置表单
*/
@ -118,6 +215,7 @@ export class FreightConfigComponent implements OnInit {
initST(): STColumn[] {
return [
{ title: '', index: 'key', type: 'checkbox' },
{ title: '企业名称', className: 'text-center', index: 'enterpriseName', width: 350 },
{ title: '网络货运人', className: 'text-center', index: 'netTranName', width: 160 },
{

View File

@ -37,6 +37,10 @@ export class UsermanageService extends ShipperBaseService {
// 查询货主配置列表
$api_freight_config_page = '/api/mdc/cuc/enterpriseInfo/operate/list/configPage';
// 更新企业超级管理员权限
$api_update_enter_role_batch = '/api/mdc/cuc/enterpriseInfo/operate/updateRole';
// 批量更新企业网络货运人
$api_update_enter_newowork_batch = '/api/mdc/cuc/enterpriseInfo/operate/updatnNetworkTransporter';
// 货主员工列表(运营后台)
$api_get_user_list = '/api/mdc/cuc/userApp/getShipperUserList';

View File

@ -3,14 +3,13 @@
<custom-element>
<ng-container [ngSwitch]="selectedTab?.configType">
<ng-container *ngSwitchCase="1">
权限配置
<app-enter-auth [enterpriseId]="businessId"> </app-enter-auth>
</ng-container>
<ng-container *ngSwitchCase="2">
</ng-container>
<ng-container *ngSwitchDefault>
<app-rate-change [businessId]="businessId" [configFullKey]="configFullKey"></app-rate-change>
</ng-container>
<ng-container *ngSwitchDefault>
</ng-container>
</ng-container>
</custom-element>
</app-dynamic-setting-h5>

View File

@ -20,7 +20,14 @@ import { SEModule } from '@delon/abc/se';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { RateChangeComponent } from './rate-change/rate-change.component';
import { STModule } from '@delon/abc/st';
const COMPONENTS = [DynamicSettingH5Component, DynamicSettingModalComponent, FreightTableComponent, RateChangeComponent];
import { EnterAuthComponent } from './enter-auth/enter-auth.component';
const COMPONENTS = [
DynamicSettingH5Component,
DynamicSettingModalComponent,
FreightTableComponent,
RateChangeComponent,
EnterAuthComponent
];
@NgModule({
declarations: [...COMPONENTS],
imports: [CommonModule, FormsModule, SHARED_ZORRO_MODULES, SEModule, STModule],

View File

@ -0,0 +1,15 @@
<div nz-row nzGutter="8">
<div nz-col nzSpan="24" se-container [labelWidth]="120">
<se [col]="1" label="企业角色" required>
<nz-select nzPlaceHolder="请选择" [(ngModel)]="roleId" style="width: 150px;">
<nz-option [nzValue]="item.value" [nzLabel]="item.label" *ngFor="let item of roles"></nz-option>
</nz-select>
</se>
</div>
</div>
<div nz-row nzGutter="8">
<div nz-col nzSpan="24">
<button nz-button nzSize="large" nzType="primary" (click)="saveAction()" style="float: right;"
class="mt-md">保存</button>
</div>
</div>

View File

@ -0,0 +1,52 @@
import { Component, Input, OnInit } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { ShipperBaseService } from 'src/app/shared/services/business/shipper-base.service';
@Component({
selector: 'app-enter-auth',
templateUrl: './enter-auth.component.html'
})
export class EnterAuthComponent implements OnInit {
@Input()
enterpriseId = '';
@Input()
roleId = '';
roles: any[] = [];
constructor(private service: ShipperBaseService, private modalHelp: NzModalRef) {
this.loadRoles();
}
ngOnInit(): void {
console.log(this.enterpriseId);
this.loadEnterRole();
}
loadEnterRole() {
this.service.request('/api/mdc/cuc/enterpriseInfo/operate/getRole', { enterpriseId: this.enterpriseId }).subscribe(res => {
if (res) {
this.roleId = res.roleId;
}
});
}
loadRoles() {
this.service.getRoles({ enterpriseId: 0, projectId: 0 }).subscribe(res => {
if (res) {
this.roles = res;
}
});
}
saveAction() {
this.service
.request('/api/mdc/cuc/enterpriseInfo/operate/updateRole', { enterpriseIdList: [this.enterpriseId], roleId: this.roleId })
.subscribe(res => {
if (res) {
this.service.msgSrv.success('修改成功');
this.modalHelp.destroy(true);
}
});
}
}