This commit is contained in:
Taric Xin
2022-01-05 14:11:29 +08:00
parent ae2bde8d33
commit 9e129f9a3f
4 changed files with 114 additions and 181 deletions

View File

@ -1,5 +1,6 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { SFComponent, SFSchema, SFUISchema } from '@delon/form';
import { dateTimePickerUtil } from '@delon/util';
import { SystemService } from '../../services/system.service';
@Component({
@ -8,102 +9,65 @@ import { SystemService } from '../../services/system.service';
styleUrls: ['./basic-setting.component.less']
})
export class BasicSettingComponent implements OnInit {
formDate: any = {
isAudit: false,
isEveryDay: false,
isEveryWeek: false
};
tabs = [
{
name: '货主提现设置'
},
{
name: '司机提现设置'
},
{
name: '路桥发票设置'
},
{
name: '风险单监控'
}
];
selectedTab = 0;
tabs: any[] = [];
selectedTab: any = null;
checkOptionsOne = [
{ label: '周一', value: '周一', checked: true },
{ label: '周二', value: '周二' },
{ label: '周三', value: '周三' },
{ label: '周四', value: '周四' },
{ label: '周五', value: '周五' },
{ label: '周六', value: '周六' },
{ label: '周日', value: '周日' }
];
configList: any = [
{
configId: '1475393700370898945',
itemKey: 'goods.name.config.type.3.3',
itemType: 1,
itemValue: '{"data":false,"type":"radio","trueLable":"开启","falseLable":"关闭"}',
name: '货主是否可以设置车队长',
parentId: '0',
remark: ''
},
{
configId: '1475393700370898945',
itemKey: 'goods.name.config.type.3.4',
itemType: 1,
itemValue: '{"data":false,"type":"radio","trueLable":"开启","falseLable":"关闭"}',
name: '货主企业四要素校验开关',
parentId: '0',
remark: ''
},
{
configId: '1475393700370898945',
itemKey: 'goods.name.config.type.3.5',
itemType: 1,
itemValue: '{"data":false,"type":"radio","trueLable":"开启","falseLable":"关闭"}',
name: '货主提现功能开关',
parentId: '0',
remark: ''
},
{
configId: '1475393700370898945',
itemKey: 'goods.name.config.type.3.5',
itemType: 1,
itemValue: '{"data":"","type":"input","afterLable":"%"}',
name: '货主费率配置',
parentId: '0',
remark: ''
},
{
configId: '1475393700370898945',
itemKey: 'goods.name.config.type.3.5',
itemType: 1,
itemValue: '{"data":"5","type":"input","afterLable":"次"}',
name: '单个用户每天最大发送短信次数',
parentId: '0',
remark: ''
},
{
configId: '1475393700370898945',
itemKey: 'goods.name.config.type.3.5',
itemType: 1,
itemValue: '{"data":true,"type":"radio","trueLable":"开启","falseLable":"关闭","isCustom":true}',
name: '合同单权限',
parentId: '0',
remark: ''
}
];
configList: any = [];
constructor(private service: SystemService) {}
ngOnInit() {
this.configList = this.configList.map((item: any) => ({ ...item, itemValue: JSON.parse(item.itemValue) }));
this.getTypeList();
}
changeType(type: number): void {
getTypeList() {
this.service.request(this.service.$api_get_config_tree, { configFullKey: 'sys.config' }).subscribe((res: Array<any>) => {
if (res?.length > 0) {
const typeData = res.find(config => config.configFullKey === 'sys.config');
if (typeData) {
this.tabs = typeData.children;
this.selectedTab = typeData.children[0];
this.getConfigList(this.selectedTab.id);
}
}
});
}
getConfigList(id: string) {
this.service.request(this.service.$api_get_config_by_parent_id, { id }).subscribe((res: Array<any>) => {
if (res?.length > 0) {
res = res.map(item => ({
...item,
remark: item.remark ? JSON.parse(item.remark) : null,
itemValue: item.itemValue ? JSON.parse(item.itemValue) : item.itemValue
}));
this.configList = res;
console.log(res);
} else {
this.configList = [];
}
});
}
changeType(type: any): void {
this.selectedTab = type;
console.log(type);
this.getConfigList(this.selectedTab.id);
}
saveAction() {
if (this.configList?.length < 0) {
return;
}
const params = this.configList.map((item: any) => ({
...item,
remark: item.remark ? JSON.stringify(item.remark) : null,
itemValue: item.itemValue ? JSON.stringify(item.itemValue) : null
}));
this.service.request(this.service.$api_update_config_batch, params).subscribe(res => {
if (res) {
this.service.msgSrv.success('修改配置成功');
this.getConfigList(this.selectedTab.id);
}
});
}
}