diff --git a/src/app/routes/sys-setting/components/agreement-config/agreement-config.component.ts b/src/app/routes/sys-setting/components/agreement-config/agreement-config.component.ts
index 55272c75..90799802 100644
--- a/src/app/routes/sys-setting/components/agreement-config/agreement-config.component.ts
+++ b/src/app/routes/sys-setting/components/agreement-config/agreement-config.component.ts
@@ -13,39 +13,11 @@ import { EnvironmentService } from '@env/environment.service';
templateUrl: './agreement-config.component.html'
})
export class AgreementConfigComponentsBaseComponent implements OnInit {
- @ViewChild('sf1', { static: false }) sf1!: SFComponent;
-
- i: any;
- formDate: any = {};
+ @ViewChild('sf', { static: false }) sf!: SFComponent;
schema1!: SFSchema;
- ui1: SFUISchema = {};
- idx: any = 0;
isUpdate = false;
- type = 0;
- tabItem = {
- content: '',
- id: 0,
- modifyTime: '',
- type: '',
- typeName: ''
- };
- tabs = [
- {
- name: '《货主端用户注册协议》'
- },
- {
- name: '《司机端用户注册协议》'
- },
- {
- name: '《服务协议》'
- },
- {
- name: '《隐私政策》'
- },
- {
- name: '《人脸识别协议》'
- }
- ];
+ tabItem: any = {};
+ tabs: any[] = [];
constructor(private service: SystemService) {}
@@ -53,7 +25,8 @@ export class AgreementConfigComponentsBaseComponent implements OnInit {
this.loadAgreement();
this.initSF();
}
- initSF() {
+
+ initSF(data?: any) {
this.schema1 = {
properties: {
content: {
@@ -65,58 +38,51 @@ export class AgreementConfigComponentsBaseComponent implements OnInit {
config: {
height: 650
}
- }
+ },
+ default: data?.agreementContent || ''
}
}
};
- this.ui1 = {
- '*': {
- spanLabelFixed: 10,
- grid: { span: 24 }
+ }
+
+ changeType(item: any): void {
+ this.isUpdate = false;
+ this.tabItem = item;
+ }
+
+ loadAgreement(type?: number) {
+ this.service.request(`${this.service.$api_get_agreement_page}`).subscribe(res => {
+ if (res) {
+ res.records = res.records.map((item: any) => ({ ...item, agreementContent: decodeURIComponent(item.agreementContent) }));
+ this.tabs = res.records;
+ if (type) {
+ this.tabItem = res.records.find((i: any) => i.type === type);
+ } else {
+ this.tabItem = res.records?.[0];
+ }
}
- };
- }
-
- changeType(type: number): void {
- this.idx = type;
- if (type > 0) {
- this.isUpdate = false;
- this.type = +type;
-
- this.loadAgreement();
- }
- }
-
- loadAgreement() {
- // this.service.request(`${this.service.$api_general_getAgreement}`, { type: this.type }).subscribe((res) => {
- // console.log('🚀 ~ this.service.request ~ res', res);
- // if (res) {
- // this.tabItem = res;
- // }
- // });
+ });
}
update() {
this.isUpdate = true;
- console.log('🚀 ~ update ~ isUpdate', this.tabItem);
-
- this.formDate.content = this.tabItem.content;
- this.initSF();
+ this.initSF(this.tabItem);
}
save() {
const params = {
id: this.tabItem.id,
- content: encodeURIComponent(this.sf1?.value.content),
- type: this.type
+ agreementContent: encodeURIComponent(this.sf?.value.content),
+ type: this.tabItem.type,
+ agreementName: this.tabItem.agreementName
};
this.isUpdate = false;
- // this.service.request(`${this.service.$api_general_updateAgreement}`, params).subscribe((res) => {
- // if (res) {
- // this.service.msgSrv.success('保存成功');
- // this.changeType(this.type);
- // this.isUpdate = false;
- // }
- // });
+ this.service.request(`${this.service.$api_update_agreement}`, params).subscribe(res => {
+ if (res) {
+ this.service.msgSrv.success('保存成功');
+ this.isUpdate = false;
+ this.loadAgreement(this.tabItem.type);
+ }
+ });
}
cancel() {
diff --git a/src/app/routes/sys-setting/services/system.service.ts b/src/app/routes/sys-setting/services/system.service.ts
index a1ebed94..0a12e736 100644
--- a/src/app/routes/sys-setting/services/system.service.ts
+++ b/src/app/routes/sys-setting/services/system.service.ts
@@ -87,6 +87,11 @@ export class SystemService extends BaseService {
// 查询版本发布表
public $api_get_version_logs = '/api/mdc/versionPublish/list/page';
+ // 查询协议列表
+ public $api_get_agreement_page = '/api/mdc/pbc/agreementInfo/list/page';
+ // 编辑协议
+ public $api_update_agreement = '/api/mdc/pbc/agreementInfo/modifyAgreementInfo';
+
$api_getRoleTemplateInfo: string = '';
$api_getFunctionButtonInfo: string = '';
$api_getFunctionDataInfo: string = '';
diff --git a/src/app/shared/index.ts b/src/app/shared/index.ts
index 9d2d0dc2..1ade0aef 100644
--- a/src/app/shared/index.ts
+++ b/src/app/shared/index.ts
@@ -22,6 +22,7 @@ export * from './components/dict-select/index';
// Utils
export * from './utils';
export * from './services';
+export * from './pipes';
// Module
export * from './shared.module';
diff --git a/src/app/shared/pipes/index.ts b/src/app/shared/pipes/index.ts
new file mode 100644
index 00000000..08d84320
--- /dev/null
+++ b/src/app/shared/pipes/index.ts
@@ -0,0 +1,2 @@
+export * from './pipe.module';
+export * from './trushtml.pipe';
\ No newline at end of file
diff --git a/src/app/shared/pipes/pipe.module.ts b/src/app/shared/pipes/pipe.module.ts
new file mode 100644
index 00000000..d808239c
--- /dev/null
+++ b/src/app/shared/pipes/pipe.module.ts
@@ -0,0 +1,10 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { TrushtmlPipe } from './trushtml.pipe';
+
+@NgModule({
+ declarations: [TrushtmlPipe],
+ imports: [CommonModule],
+ exports: [TrushtmlPipe]
+})
+export class PipeModule {}
diff --git a/src/app/shared/pipes/trushtml.pipe.ts b/src/app/shared/pipes/trushtml.pipe.ts
new file mode 100644
index 00000000..d93e6459
--- /dev/null
+++ b/src/app/shared/pipes/trushtml.pipe.ts
@@ -0,0 +1,29 @@
+/*
+ * @Description:
+ * @Author: wsm
+ * @Date: 2021-06-23 17:02:20
+ * @LastEditTime: 2021-06-23 17:04:57
+ * @LastEditors: wsm
+ * @Reference:
+ */
+import { Pipe, PipeTransform } from '@angular/core';
+import { DomSanitizer } from '@angular/platform-browser';
+
+@Pipe({
+ name: 'safehtml',
+})
+export class TrushtmlPipe implements PipeTransform {
+ constructor(private sanitizer: DomSanitizer) {}
+
+ transform(value: any, args?: any): any {
+ try {
+ if (!value || value === '') {
+ return '';
+ }
+ return this.sanitizer.bypassSecurityTrustHtml(value);
+ } catch (e) {
+ console.warn(e);
+ return '';
+ }
+ }
+}
diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts
index e77a54ec..1bfce680 100644
--- a/src/app/shared/shared.module.ts
+++ b/src/app/shared/shared.module.ts
@@ -30,6 +30,7 @@ import { LogisticsTimeLineComponent } from './components/logistics-time-line/log
import { AmapModule } from './components/amap/amap.module';
import { ImageListModule } from './components/imagelist';
import { DictSelectComponent } from './components/dict-select';
+import { PipeModule } from './pipes';
const MODULES = [
AddressModule,
@@ -43,6 +44,7 @@ const MODULES = [
SharedThirdModule,
AmapModule,
ImageListModule,
+ PipeModule,
...PRO_SHARED_MODULES
];
// #endregion