提交 4e4e75af 编写于 作者: misaka's avatar misaka

delete

上级 a6d441d6
<template>
<div class="design-tree-container">
<context-menu-container>
<el-tree
v-if="inited"
ref="treeexpbar_tree"
class="design-tree"
node-key="id"
lazy
:show-checkbox="!isSingleSelect"
:check-on-click-node="!isSingleSelect"
:default-expanded-keys="expandedKeys"
:props="{
label: 'text',
isLeaf: 'leaf',
children: 'children'
}"
:load="load"
:highlight-current="true"
:expand-on-click-node="false"
@check="onCheck"
@current-change="selectionChange"
:filter-node-method="filterNode"
>
<template slot-scope="{ node, data }">
<context-menu :contextMenuStyle="{width: '100%'}" :data="node" :renderContent="renderContextMenu">
<tooltip transfer style="width: 100%;" max-width="2000" placement="right">
<div class="tree-node" @dblclick="doDefaultAction(node)">
<span class="icon">
<i v-if=" data.iconcls && !Object.is(data.iconcls, '')" :class="data.iconcls"></i>
<img v-else-if="data.icon && !Object.is(data.icon, '')" :src="data.icon" />
<icon v-else-if="isOutputIconDefault" type="ios-paper-outline"></icon>&nbsp;
</span>
<span class="text">
<span v-if="data.html" v-html="data.html"></span>
<span v-else>{{ data.isUseLangRes ? $t(data.text) : data.text }}</span>
</span>
</div>
<template slot="content">
<span v-if="data.html" v-html="data.html"></span>
<span v-else>{{ data.isUseLangRes ? $t(data.text) : data.text }}</span>
</template>
</tooltip>
</context-menu>
</template>
</el-tree>
</context-menu-container>
</div>
</template>
<script lang='tsx'>
import { Vue, Component, Prop, Provide, Emit, Watch, Model } from 'vue-property-decorator';
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util } from '@/utils';
import AccountService from '@/service/account/account-service';
import AccountService from './account-treeview-service';
import AccountUIService from '@/uiservice/account/account-ui-service';
@Component({
components: {
}
})
export default class AccountBase extends Vue implements ControlInterface {
/**
* 名称
*
* @type {string}
* @memberof Account
*/
@Prop() public name?: string;
/**
* 视图通讯对象
*
* @type {Subject<ViewState>}
* @memberof Account
*/
@Prop() public viewState!: Subject<ViewState>;
/**
* 应用上下文
*
* @type {*}
* @memberof Account
*/
@Prop() public context: any;
/**
* 视图参数
*
* @type {*}
* @memberof Account
*/
@Prop() public viewparams: any;
/**
* 视图状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof Account
*/
public viewStateEvent: Subscription | undefined;
/**
* 获取部件类型
*
* @returns {string}
* @memberof Account
*/
public getControlType(): string {
return 'TREEVIEW'
}
/**
* 计数器服务对象集合
*
* @type {Array<*>}
* @memberof Account
*/
public counterServiceArray:Array<any> = [];
/**
* 建构部件服务对象
*
* @type {AccountService}
* @memberof Account
*/
public service: AccountService = new AccountService({ $store: this.$store });
/**
* 实体服务对象
*
* @type {AccountService}
* @memberof Account
*/
public appEntityService: AccountService = new AccountService({ $store: this.$store });
/**
* childaccount_cm 部件 click 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof Account
*/
public childaccount_cm_click($event: any, $event2?: any) {
if (Object.is($event.tag, 'deuiaction1')) {
this.childaccount_cm_deuiaction1_click(null, 'childaccount_cm', $event2);
}
if (Object.is($event.tag, 'deuiaction3')) {
this.childaccount_cm_deuiaction3_click(null, 'childaccount_cm', $event2);
}
if (Object.is($event.tag, 'deuiaction2')) {
this.childaccount_cm_deuiaction2_click(null, 'childaccount_cm', $event2);
}
}
/**
* rootaccount_cm 部件 click 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof Account
*/
public rootaccount_cm_click($event: any, $event2?: any) {
if (Object.is($event.tag, 'deuiaction1')) {
this.rootaccount_cm_deuiaction1_click(null, 'rootaccount_cm', $event2);
}
if (Object.is($event.tag, 'deuiaction3')) {
this.rootaccount_cm_deuiaction3_click(null, 'rootaccount_cm', $event2);
}
if (Object.is($event.tag, 'deuiaction2')) {
this.rootaccount_cm_deuiaction2_click(null, 'rootaccount_cm', $event2);
}
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public rootaccount_cm_deuiaction1_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this;
if (_this.getDatas && _this.getDatas instanceof Function) {
datas = [..._this.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
const curUIService:AccountUIService = new AccountUIService();
curUIService.Account_OpenMainEditView(datas,contextJO, paramJO, $event, xData,this,"Account");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public rootaccount_cm_deuiaction3_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this;
if (_this.getDatas && _this.getDatas instanceof Function) {
datas = [..._this.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
const curUIService:AccountUIService = new AccountUIService();
curUIService.Account_Disable(datas,contextJO, paramJO, $event, xData,this,"Account");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public rootaccount_cm_deuiaction2_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this;
if (_this.getDatas && _this.getDatas instanceof Function) {
datas = [..._this.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
const curUIService:AccountUIService = new AccountUIService();
curUIService.Account_Remove(datas,contextJO, paramJO, $event, xData,this,"Account");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public childaccount_cm_deuiaction1_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this;
if (_this.getDatas && _this.getDatas instanceof Function) {
datas = [..._this.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
const curUIService:AccountUIService = new AccountUIService();
curUIService.Account_OpenMainEditView(datas,contextJO, paramJO, $event, xData,this,"Account");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public childaccount_cm_deuiaction3_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this;
if (_this.getDatas && _this.getDatas instanceof Function) {
datas = [..._this.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
const curUIService:AccountUIService = new AccountUIService();
curUIService.Account_Disable(datas,contextJO, paramJO, $event, xData,this,"Account");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public childaccount_cm_deuiaction2_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this;
if (_this.getDatas && _this.getDatas instanceof Function) {
datas = [..._this.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
const curUIService:AccountUIService = new AccountUIService();
curUIService.Account_Remove(datas,contextJO, paramJO, $event, xData,this,"Account");
}
/**
* 关闭视图
*
* @param {any} args
* @memberof Account
*/
public closeView(args: any): void {
let _this: any = this;
_this.$emit('closeview', [args]);
}
/**
* 计数器刷新
*
* @memberof Account
*/
public counterRefresh(){
const _this:any =this;
if(_this.counterServiceArray && _this.counterServiceArray.length >0){
_this.counterServiceArray.forEach((item:any) =>{
if(item.refreshData && item.refreshData instanceof Function){
item.refreshData();
}
})
}
}
/**
* 获取多项数据
*
* @returns {any[]}
* @memberof Account
*/
public getDatas(): any[] {
return [this.currentselectedNode];
}
/**
* 获取单项树
*
* @returns {*}
* @memberof Account
*/
public getData(): any {
return this.currentselectedNode;
}
/**
* 是否单选
*
* @type {boolean}
* @memberof Account
*/
@Prop({ default: true }) public isSingleSelect!: boolean;
/**
* 是否默认选中第一条数据
*
* @type {boolean}
* @memberof Account
*/
@Prop({ default: false }) public isSelectFirstDefault!: boolean;
/**
* 枝干节点是否可用(具有数据能力,可抛出)
*
* @type {string}
* @memberof Account
*/
@Prop({default:true}) public isBranchAvailable!: boolean;
/**
* 显示处理提示
*
* @type {boolean}
* @memberof Account
*/
@Prop({ default: true }) public showBusyIndicator?: boolean;
/**
* 初始化完成
*
* @type {boolean}
* @memberof Account
*/
public inited: boolean = false;
/**
* 已选中数据集合
*
* @type {*}
* @memberof Account
*/
public selectedNodes: any = [];
/**
* 当前选中数据项
*
* @type {*}
* @memberof Account
*/
public currentselectedNode: any = {};
/**
* 选中数据字符串
*
* @type {string}
* @memberof Account
*/
@Prop() public selectedData?: string;
/**
* 选中值变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Account
*/
@Watch('selectedData')
public onValueChange(newVal: any, oldVal: any) {
this.echoselectedNodes = newVal ? this.isSingleSelect ? JSON.parse(newVal)[0] : JSON.parse(newVal) : [];
this.selectedNodes = [];
if(this.echoselectedNodes.length > 0){
let AllnodesObj = (this.$refs.treeexpbar_tree as any).store.nodesMap;
let AllnodesArray : any[] = [];
for (const key in AllnodesObj) {
if (AllnodesObj.hasOwnProperty(key)) {
AllnodesArray.push(AllnodesObj[key].data);
}
}
this.setDefaultSelection(AllnodesArray);
}
}
/**
* 回显选中数据集合
*
* @type {*}
* @memberof Account
*/
public echoselectedNodes:any[] = this.selectedData ? ( this.isSingleSelect ? [JSON.parse(this.selectedData)[0]] : JSON.parse(this.selectedData)) : [];
/**
* 部件行为--update
*
* @type {string}
* @memberof Account
*/
@Prop() public updateAction!: string;
/**
* 部件行为--fetch
*
* @type {string}
* @memberof Account
*/
@Prop() public fetchAction!: string;
/**
* 部件行为--remove
*
* @type {string}
* @memberof Account
*/
@Prop() public removeAction!: string;
/**
* 部件行为--load
*
* @type {string}
* @memberof Account
*/
@Prop() public loadAction!: string;
/**
* 部件行为--create
*
* @type {string}
* @memberof Account
*/
@Prop() public createAction!: string;
/**
* 过滤属性
*
* @type {string}
* @memberof Account
*/
public srfnodefilter: string = '';
/**
* 默认输出图标
*
* @type {boolean}
* @memberof Account
*/
public isOutputIconDefault: boolean = true;
/**
* 数据展开主键
*
* @type {string[]}
* @memberof Account
*/
@Provide()
public expandedKeys: string[] = [];
/**
* 选中数据变更事件
*
* @public
* @param {*} data
* @param {*} data 当前节点对应传入对象
* @param {*} checkedState 树目前选中状态对象
* @memberof Account
*/
public onCheck(data: any, checkedState: any) {
// 处理多选数据
if(!this.isSingleSelect){
let leafNodes = checkedState.checkedNodes.filter((item:any) => item.leaf);
this.selectedNodes = JSON.parse(JSON.stringify(leafNodes));
this.$emit('selectionchange', this.selectedNodes);
}
}
/**
* 选中数据变更事件
*
* @public
* @param {*} data 节点对应传入对象
* @param {*} node 节点对应node对象
* @memberof Account
*/
public selectionChange(data: any, node: any) {
// 禁用项处理
if (data.disabled){
node.isCurrent = false;
return;
}
// 只处理最底层子节点
if(this.isBranchAvailable || data.leaf){
this.currentselectedNode = JSON.parse(JSON.stringify(data));
// 单选直接替换
if(this.isSingleSelect){
this.selectedNodes = [this.currentselectedNode];
this.$emit('selectionchange', this.selectedNodes);
}
// 多选用check方法
}
}
/**
* Vue声明周期(处理组件的输入属性)
*
* @memberof Account
*/
public created() {
this.afterCreated();
}
/**
* 执行created后的逻辑
*
* @memberof Account
*/
public afterCreated(){
if (this.viewState) {
this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
if (!Object.is(tag, this.name)) {
return;
}
if (Object.is('load', action)) {
this.inited = false;
this.$nextTick(() => {
this.inited = true;
});
}
if (Object.is('filter', action)) {
this.srfnodefilter = data.srfnodefilter;
this.refresh_all();
}
if (Object.is('refresh_parent', action)) {
this.refresh_parent();
}
});
}
}
/**
* 对树节点进行筛选操作
* @memberof OrderTree
*/
public filterNode(value:any, data:any) {
if (!value) return true;
return data.text.indexOf(value) !== -1;
}
/**
* vue 生命周期
*
* @memberof Account
*/
public destroyed() {
this.afterDestroy();
}
/**
* 执行destroyed后的逻辑
*
* @memberof Account
*/
public afterDestroy() {
if (this.viewStateEvent) {
this.viewStateEvent.unsubscribe();
}
}
/**
* 刷新数据
*
* @memberof Account
*/
public refresh_all(): void {
this.inited = false;
this.$nextTick(() => {
this.inited = true;
});
}
/**
* 刷新父节点
*
* @memberof Account
*/
public refresh_parent(): void {
if (Object.keys(this.currentselectedNode).length === 0) {
return;
}
const tree: any = this.$refs.treeexpbar_tree;
const node: any = tree.getNode(this.currentselectedNode.id);
if (!node || !node.parent) {
return;
}
let curNode:any = {};
const { parent: _parent } = node;
curNode = Util.deepObjectMerge(curNode,_parent);
let tempContext:any = {};
if(curNode.data && curNode.data.srfappctx){
Object.assign(tempContext,curNode.data.srfappctx);
}else{
Object.assign(tempContext,this.context);
}
const id: string = _parent.key ? _parent.key : '#';
const param: any = { srfnodeid: id };
this.refresh_node(tempContext,param, true);
}
/**
* 数据加载
*
* @param {*} node
* @memberof Account
*/
public load(node: any = {}, resolve?: any) {
if (node.data && node.data.children) {
resolve(node.data.children);
return;
}
const params: any = {
srfnodeid: node.data && node.data.id ? node.data.id : "#",
srfnodefilter: this.srfnodefilter
};
let tempViewParams:any = JSON.parse(JSON.stringify(this.viewparams));
let curNode:any = {};
curNode = Util.deepObjectMerge(curNode,node);
let tempContext:any = this.computecurNodeContext(curNode);
if(curNode.data && curNode.data.srfparentdename){
Object.assign(tempContext,{srfparentdename:curNode.data.srfparentdename});
Object.assign(tempViewParams,{srfparentdename:curNode.data.srfparentdename});
}
if(curNode.data && curNode.data.srfparentkey){
Object.assign(tempContext,{srfparentkey:curNode.data.srfparentkey});
Object.assign(tempViewParams,{srfparentkey:curNode.data.srfparentkey});
}
Object.assign(params,{viewparams:tempViewParams});
this.service.getNodes(tempContext,params).then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({ title: "错误", desc: response.info });
resolve([]);
return;
}
const _items = response.data;
this.formatExpanded(_items);
resolve([..._items]);
let isRoot = Object.is(node.level,0);
let isSelectedAll = node.checked;
this.setDefaultSelection(_items, isRoot, isSelectedAll);
this.$emit("load", _items);
}).catch((response: any) => {
resolve([]);
if (response && response.status === 401) {
return;
}
this.$Notice.error({ title: "错误", desc: response.info });
});
}
/**
* 计算当前节点的上下文
*
* @param {*} curNode 当前节点
* @memberof Account
*/
public computecurNodeContext(curNode:any){
let tempContext:any = {};
if(curNode && curNode.data && curNode.data.srfappctx){
tempContext = JSON.parse(JSON.stringify(curNode.data.srfappctx));
}else{
tempContext = JSON.parse(JSON.stringify(this.context));
}
return tempContext;
}
/**
* 刷新功能
*
* @param {any[]} args
* @memberof Account
*/
public refresh(args: any[]): void {
this.refresh_all();
}
/**
* 刷新节点
*
* @public
* @param {*} [curContext] 当前节点上下文
* @param {*} [arg={}] 当前节点附加参数
* @param {boolean} parentnode 是否是刷新父节点
* @memberof Account
*/
public refresh_node(curContext:any,arg: any = {}, parentnode: boolean): void {
const { srfnodeid: id } = arg;
Object.assign(arg,{viewparams:this.viewparams});
const get: Promise<any> = this.service.getNodes(JSON.parse(JSON.stringify(this.context)),arg);
get.then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({ title: '错误', desc: response.info });
return;
}
const _items = [...response.data];
this.formatExpanded(_items);
const tree: any = this.$refs.treeexpbar_tree;
tree.updateKeyChildren(id, _items);
if (parentnode) {
this.currentselectedNode = {};
}
this.setDefaultSelection(_items);
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
this.$Notice.error({ title: '错误', desc: response.info });
});
}
/**
* 默认展开节点
*
* @public
* @param {any[]} items
* @returns {any[]}
* @memberof Account
*/
public formatExpanded(items: any[]): any[] {
const data: any[] = [];
items.forEach((item) => {
if (item.expanded || (item.children && item.children.length > 0)) {
this.expandedKeys.push(item.id);
}
});
return data;
}
/**
* 设置默认选中,回显数项,选中所有子节点
*
* @param {any[]} items 当前节点所有子节点集合
* @param {boolean} isRoot 是否是加载根节点
* @param {boolean} isSelectedAll 是否选中所有子节点
* @memberof MainTree
*/
public setDefaultSelection(items: any[], isRoot: boolean = false, isSelectedAll: boolean = false): void {
if(items.length == 0){
return;
}
let defaultData: any;
// 导航中选中第一条配置的默认选中,没有选中第一条
if(this.isSelectFirstDefault){
if(this.isSingleSelect){
let index = items.findIndex((item: any) => item.selected);
if(index === -1) {
if(isRoot){
index = 0;
}else{
return;
}
}
defaultData = items[index];
this.setTreeNodeHighLight(defaultData);
this.currentselectedNode = JSON.parse(JSON.stringify(defaultData));
if(this.isBranchAvailable || defaultData.leaf){
this.selectedNodes = [this.currentselectedNode];
this.$emit('selectionchange', this.selectedNodes);
}
}
}
// 已选数据的回显
if(this.echoselectedNodes && this.echoselectedNodes.length > 0){
let checkedNodes = items.filter((item:any)=>{
return this.echoselectedNodes.some((val:any)=> {
if(Object.is(item.srfkey,val.srfkey) && Object.is(item.srfmajortext,val.srfmajortext)){
val.used = true;
return true;
}
});
});
if(checkedNodes.length > 0){
this.echoselectedNodes = this.echoselectedNodes.filter((item:any)=> !item.used);
// 父节点选中时,不需要执行这段,会选中所有子节点
if(!isSelectedAll){
if(this.isSingleSelect){
this.setTreeNodeHighLight(checkedNodes[0]);
this.currentselectedNode = JSON.parse(JSON.stringify(checkedNodes[0]));
this.selectedNodes = [this.currentselectedNode];
}else{
this.selectedNodes = this.selectedNodes.concat(checkedNodes);
const tree: any = this.$refs.treeexpbar_tree;
tree.setCheckedNodes(this.selectedNodes);
}
}
}
}
// 父节点选中时,选中所有子节点
if(isSelectedAll){
let leafNodes = items.filter((item:any) => item.leaf);
this.selectedNodes = this.selectedNodes.concat(leafNodes);
this.$emit('selectionchange', this.selectedNodes);
}
}
/**
* 绘制右击菜单
*
* @param {*} node
* @returns
* @memberof Account
*/
public renderContextMenu(node: any) {
let content;
if (node && node.data) {
const data: any = JSON.parse(JSON.stringify(node.data));
this.currentselectedNode = { ...data };
const tags: string[] = data.id.split(';');
if (tags[0] === "ChildAccount") {
content = this.renderContextMenuChildaccount();
}
if (tags[0] === "RootAccount") {
content = this.renderContextMenuRootaccount();
}
}
return content;
}
/**
* 绘制ChildAccount类型右键菜单
*
* @param {*} node
* @returns
* @memberof Account
*/
public renderContextMenuChildaccount() {
return (
<dropdown class="tree-right-menu" trigger="custom" visible={true} on-on-click={($event: any) => this.childaccount_cm_click({tag: $event})}>
<dropdown-menu slot="list">
<dropdown-item name="deuiaction1">
<i class='fa fa-edit'></i>
编辑
</dropdown-item>
<dropdown-item name="deuiaction3">
<i class='fa fa-minus'></i>
停用
</dropdown-item>
<dropdown-item name="deuiaction2">
删除
</dropdown-item>
</dropdown-menu>
</dropdown>
);
}
/**
* 绘制RootAccount类型右键菜单
*
* @param {*} node
* @returns
* @memberof Account
*/
public renderContextMenuRootaccount() {
return (
<dropdown class="tree-right-menu" trigger="custom" visible={true} on-on-click={($event: any) => this.rootaccount_cm_click({tag: $event})}>
<dropdown-menu slot="list">
<dropdown-item name="deuiaction1">
<i class='fa fa-edit'></i>
编辑
</dropdown-item>
<dropdown-item name="deuiaction3">
<i class='fa fa-minus'></i>
停用
</dropdown-item>
<dropdown-item name="deuiaction2">
删除
</dropdown-item>
</dropdown-menu>
</dropdown>
);
}
/**
* 设置选中高亮
*
* @param {*} data
* @memberof Account
*/
public setTreeNodeHighLight(data: any): void {
const tree: any = this.$refs.treeexpbar_tree;
tree.setCurrentKey(data.id);
}
/**
* 执行默认界面行为
*
* @param {*} node
* @memberof AppView
*/
public doDefaultAction(node: any) {
if (node && node.data) {
const data: any = node.data;
const tags: string[] = data.id.split(';');
}
this.$emit('nodedblclick', this.selectedNodes);
}
}
</script>
<style lang='less'>
@import './account-treeview.less';
</style>
\ No newline at end of file
/**
* Account 部件模型
*
* @export
* @class AccountModel
*/
export default class AccountModel {
/**
* 获取数据项集合
*
* @returns {any[]}
* @memberof AccountModel
*/
public getDataItems(): any[] {
return [
{
name: 'address1_primarycontactname',
},
{
name: 'openrevenue_date',
},
{
name: 'address2_utcoffset',
},
{
name: 'fax',
},
{
name: 'address1_composite',
},
{
name: 'entityimage',
},
{
name: 'emailaddress1',
},
{
name: 'overriddencreatedon',
},
{
name: 'address1_stateorprovince',
},
{
name: 'openrevenue',
},
{
name: 'address1_upszone',
},
{
name: 'followemail',
},
{
name: 'marketingonly',
},
{
name: 'numberofemployees',
},
{
name: 'telephone1',
},
{
name: 'aging60',
},
{
name: 'sharesoutstanding',
},
{
name: 'address2_freighttermscode',
},
{
name: 'entityimage_timestamp',
},
{
name: 'revenue_base',
},
{
name: 'accountratingcode',
},
{
name: 'donotbulkemail',
},
{
name: 'aging30',
},
{
name: 'donotbulkpostalmail',
},
{
name: 'creditlimit_base',
},
{
name: 'timezoneruleversionnumber',
},
{
name: 'customertypecode',
},
{
name: 'address2_longitude',
},
{
name: 'accountname',
},
{
name: 'participatesinworkflow',
},
{
name: 'preferredcontactmethodcode',
},
{
name: 'preferredappointmentdaycode',
},
{
name: 'marketcap',
},
{
name: 'address2_telephone1',
},
{
name: 'businesstypecode',
},
{
name: 'entityimageid',
},
{
name: 'address2_city',
},
{
name: 'ownershipcode',
},
{
name: 'utcconversiontimezonecode',
},
{
name: 'accountnumber',
},
{
name: 'address1_telephone2',
},
{
name: 'address1_line1',
},
{
name: 'donotphone',
},
{
name: 'address1_telephone3',
},
{
name: 'exchangerate',
},
{
name: 'address2_line2',
},
{
name: 'address2_telephone3',
},
{
name: 'address1_telephone1',
},
{
name: 'address1_fax',
},
{
name: 'address1_freighttermscode',
},
{
name: 'description',
},
{
name: 'merged',
},
{
name: 'address1_shippingmethodcode',
},
{
name: 'address1_name',
},
{
name: 'aging30_base',
},
{
name: 'address2_telephone2',
},
{
name: 'account',
prop: 'accountid',
},
{
name: 'primarytwitterid',
},
{
name: 'tickersymbol',
},
{
name: 'stockexchange',
},
{
name: 'address2_stateorprovince',
},
{
name: 'ftpsiteurl',
},
{
name: 'statuscode',
},
{
name: 'websiteurl',
},
{
name: 'donotpostalmail',
},
{
name: 'address1_city',
},
{
name: 'address2_fax',
},
{
name: 'aging90_base',
},
{
name: 'opendeals_date',
},
{
name: 'traversedpath',
},
{
name: 'shippingmethodcode',
},
{
name: 'address1_line2',
},
{
name: 'openrevenue_base',
},
{
name: 'updatedate',
},
{
name: 'preferredsystemuseridyominame',
},
{
name: 'address2_line3',
},
{
name: 'address1_postalcode',
},
{
name: 'address2_latitude',
},
{
name: 'ibizprivate',
},
{
name: 'territorycode',
},
{
name: 'teamsfollowed',
},
{
name: 'yominame',
},
{
name: 'address1_latitude',
},
{
name: 'telephone3',
},
{
name: 'ownerid',
},
{
name: 'address2_country',
},
{
name: 'masteraccountidyominame',
},
{
name: 'industrycode',
},
{
name: 'lastonholdtime',
},
{
name: 'address2_addressid',
},
{
name: 'onholdtime',
},
{
name: 'accountclassificationcode',
},
{
name: 'address1_country',
},
{
name: 'address1_addresstypecode',
},
{
name: 'statecode',
},
{
name: 'address2_addresstypecode',
},
{
name: 'accountcategorycode',
},
{
name: 'emailaddress2',
},
{
name: 'address2_shippingmethodcode',
},
{
name: 'importsequencenumber',
},
{
name: 'primarysatoriid',
},
{
name: 'customersizecode',
},
{
name: 'opendeals',
},
{
name: 'donotsendmm',
},
{
name: 'processid',
},
{
name: 'paymenttermscode',
},
{
name: 'sic',
},
{
name: 'address2_primarycontactname',
},
{
name: 'address1_utcoffset',
},
{
name: 'owneridyominame',
},
{
name: 'lastusedincampaign',
},
{
name: 'aging60_base',
},
{
name: 'donotfax',
},
{
name: 'updateman',
},
{
name: 'openrevenue_state',
},
{
name: 'opendeals_state',
},
{
name: 'versionnumber',
},
{
name: 'address1_longitude',
},
{
name: 'aging90',
},
{
name: 'entityimage_url',
},
{
name: 'creditlimit',
},
{
name: 'preferredsystemuserid',
},
{
name: 'revenue',
},
{
name: 'address1_county',
},
{
name: 'address1_line3',
},
{
name: 'stageid',
},
{
name: 'donotemail',
},
{
name: 'address2_postalcode',
},
{
name: 'preferredappointmenttimecode',
},
{
name: 'address2_upszone',
},
{
name: 'createdate',
},
{
name: 'address2_county',
},
{
name: 'owneridtype',
},
{
name: 'address2_composite',
},
{
name: 'address2_name',
},
{
name: 'address2_line1',
},
{
name: 'marketcap_base',
},
{
name: 'emailaddress3',
},
{
name: 'telephone2',
},
{
name: 'createman',
},
{
name: 'address1_postofficebox',
},
{
name: 'creditonhold',
},
{
name: 'address1_addressid',
},
{
name: 'address2_postofficebox',
},
{
name: 'slaname',
},
{
name: 'originatingleadid',
},
{
name: 'transactioncurrencyid',
},
{
name: 'defaultpricelevelid',
},
{
name: 'parentaccountid',
},
{
name: 'preferredequipmentid',
},
{
name: 'territoryid',
},
{
name: 'primarycontactid',
},
{
name: 'slaid',
},
{
name: 'preferredserviceid',
},
{
name: 'originatingleadname',
},
{
name: 'defaultpricelevelname',
},
{
name: 'territoryname',
},
{
name: 'parentaccountname',
},
{
name: 'preferredequipmentname',
},
{
name: 'preferredservicename',
},
{
name: 'primarycontactname',
},
{
name: 'transactioncurrencyname',
},
]
}
}
\ No newline at end of file
import { Http,Util,Errorlog } from '@/utils';
import ControlService from '@/widgets/control-service';
import AccountService from '@/service/account/account-service';
import AccountModel from './account-treeview-model';
import CodeListService from '@service/app/codelist-service';
import i18n from '@/locale';
/**
* Account 部件服务对象
*
* @export
* @class AccountService
*/
export default class AccountService extends ControlService {
/**
* 客户服务对象
*
* @type {AccountService}
* @memberof AccountService
*/
public appEntityService: AccountService = new AccountService({ $store: this.getStore() });
/**
* 设置从数据模式
*
* @type {boolean}
* @memberof AccountService
*/
public setTempMode(){
this.isTempMode = false;
}
/**
* Creates an instance of AccountService.
*
* @param {*} [opts={}]
* @memberof AccountService
*/
constructor(opts: any = {}) {
super(opts);
this.model = new AccountModel();
}
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof AccountService
*/
public codeListService:CodeListService = new CodeListService({ $store: this.getStore() });
/**
* 节点分隔符号
*
* @public
* @type {string}
* @memberof AccountService
*/
public TREENODE_SEPARATOR: string = ';';
/**
* RootAccount节点分隔符号
*
* @public
* @type {string}
* @memberof AccountService
*/
public TREENODE_ROOTACCOUNT: string = 'RootAccount';
/**
* 全部客户节点分隔符号
*
* @public
* @type {string}
* @memberof AccountService
*/
public TREENODE_ROOT: string = 'ROOT';
/**
* ChildAccount节点分隔符号
*
* @public
* @type {string}
* @memberof AccountService
*/
public TREENODE_CHILDACCOUNT: string = 'ChildAccount';
/**
* 获取节点数据
*
* @param {string} action
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof AccountService
*/
@Errorlog
public async getNodes(context:any = {},data: any = {}, isloading?: boolean): Promise<any> {
let { srfparentkey, srfcat, srfnodeid, srfnodefilter, query }: { srfparentkey: string, srfcat: string, srfnodeid: string, srfnodefilter: string, query:string } = data;
srfnodefilter = query ? query : srfnodefilter;
let list: any[] = [];
let filter: any = {};
if (!srfnodeid || Object.is(srfnodeid, '#')) {
await this.fillRootNodes(context, filter, list);
return Promise.resolve({ status: 200, data: list });
}
let strTreeNodeId: string = srfnodeid;
let strRealNodeId: string = '';
let bRootSelect: boolean = false;
let strNodeType: string | null = null;
let strRootSelectNode: string = '';
if (Object.is(strTreeNodeId, this.TREENODE_ROOT)) {
strNodeType = this.TREENODE_ROOT;
if (srfparentkey) {
strRealNodeId = srfparentkey;
}
} else {
let nPos = strTreeNodeId.indexOf(this.TREENODE_SEPARATOR);
if (nPos === -1) {
return Promise.reject({ status: 500, data: { title: '失败', message: `树节点${strTreeNodeId}标识无效` } });
}
strNodeType = strTreeNodeId.substring(0, nPos);
strRealNodeId = strTreeNodeId.substring(nPos + 1);
}
Object.assign(filter,
{
srfparentkey: srfparentkey,
srfcat: srfcat,
srfnodefilter: srfnodefilter,
strRealNodeId: strRealNodeId,
srfnodeid: srfnodeid,
strNodeType: strNodeType,
viewparams: JSON.parse(JSON.stringify(data)).viewparams
}
);
// 分解节点标识
let nodeid: string[] = strRealNodeId.split(this.TREENODE_SEPARATOR);
for (let i = 0; i < nodeid.length; i++) {
switch (i) {
case 0:
Object.assign(filter, { nodeid: nodeid[0] });
break;
case 1:
Object.assign(filter, { nodeid2: nodeid[1] });
break;
case 2:
Object.assign(filter, { nodeid3: nodeid[2] });
break;
case 3:
Object.assign(filter, { nodeid4: nodeid[3] });
break;
default:
break;
}
}
if (Object.is(strNodeType, this.TREENODE_ROOTACCOUNT)) {
await this.fillRootaccountNodeChilds(context,filter, list);
return Promise.resolve({ status: 200, data: list });
}
if (Object.is(strNodeType, this.TREENODE_ROOT)) {
await this.fillRootNodeChilds(context,filter, list);
return Promise.resolve({ status: 200, data: list });
}
if (Object.is(strNodeType, this.TREENODE_CHILDACCOUNT)) {
await this.fillChildaccountNodeChilds(context,filter, list);
return Promise.resolve({ status: 200, data: list });
}
return Promise.resolve({ status: 500, data: { title: '失败', message: `树节点${strTreeNodeId}标识无效` } });
}
/**
* 填充 树视图节点[RootAccount]
*
* @public
* @param {any{}} context
* @param {*} filter
* @param {any[]} list
* @param {*} rsNavContext
* @param {*} rsNavParams
* @param {*} rsParams
* @returns {Promise<any>}
* @memberof AccountService
*/
@Errorlog
public fillRootaccountNodes(context:any={},filter: any, list: any[],rsNavContext?:any,rsNavParams?:any,rsParams?:any): Promise<any> {
context = this.handleResNavContext(context,filter,rsNavContext);
filter = this.handleResNavParams(context,filter,rsNavParams,rsParams);
return new Promise((resolve:any,reject:any) =>{
let searchFilter: any = {};
Object.assign(searchFilter, { total: false });
Object.assign(searchFilter, { query: filter.srfnodefilter });
let bFirst: boolean = true;
let records: any[] = [];
try {
this.searchRootaccount(context, searchFilter, filter).then((records:any) =>{
if(records && records.length >0){
records.forEach((entity: any) => {
let treeNode: any = {};
// 整理context
let strId: string = entity.accountid;
let strText: string = entity.accountname;
Object.assign(treeNode,{srfparentdename:'Account',srfparentkey:entity.accountid});
let tempContext:any = JSON.parse(JSON.stringify(context));
Object.assign(tempContext,{srfparentdename:'Account',srfparentkey:entity.accountid,account:strId})
Object.assign(treeNode,{srfappctx:tempContext});
Object.assign(treeNode,{'account':strId});
Object.assign(treeNode, { srfkey: strId });
Object.assign(treeNode, { text: strText, srfmajortext: strText });
let strNodeId: string = 'RootAccount';
strNodeId += this.TREENODE_SEPARATOR;
strNodeId += strId;
Object.assign(treeNode, { id: strNodeId });
Object.assign(treeNode, { expanded: filter.isautoexpand });
Object.assign(treeNode, { leaf: false });
Object.assign(treeNode, { curData: entity });
Object.assign(treeNode, { nodeid: treeNode.srfkey });
Object.assign(treeNode, { nodeid2: filter.strRealNodeId });
list.push(treeNode);
resolve(list);
bFirst = false;
});
}else{
resolve(list);
}
});
} catch (error) {
console.error(error);
}
});
}
/**
* 获取查询集合
*
* @public
* @param {any{}} context
* @param {*} searchFilter
* @param {*} filter
* @returns {any[]}
* @memberof TestEnetityDatasService
*/
@Errorlog
public searchRootaccount(context:any={}, searchFilter: any, filter: any): Promise<any> {
return new Promise((resolve:any,reject:any) =>{
if(filter.viewparams){
Object.assign(searchFilter,filter.viewparams);
}
if(!searchFilter.page){
Object.assign(searchFilter,{page:0});
}
if(!searchFilter.size){
Object.assign(searchFilter,{size:1000});
}
if(context && context.srfparentdename){
Object.assign(searchFilter,{srfparentdename:JSON.parse(JSON.stringify(context)).srfparentdename});
}
if(context && context.srfparentkey){
Object.assign(searchFilter,{srfparentkey:JSON.parse(JSON.stringify(context)).srfparentkey});
}
Object.assign(searchFilter,{sort: 'accountname,asc'})
const _appEntityService: any = this.appEntityService;
let list: any[] = [];
if (_appEntityService['FetchRoot'] && _appEntityService['FetchRoot'] instanceof Function) {
const response: Promise<any> = _appEntityService['FetchRoot'](context, searchFilter, false);
response.then((response: any) => {
if (!response.status || response.status !== 200) {
resolve([]);
console.log(JSON.stringify(context));
console.error('查询FetchRoot数据集异常!');
}
const data: any = response.data;
if (Object.keys(data).length > 0) {
list = JSON.parse(JSON.stringify(data));
resolve(list);
} else {
resolve([]);
}
}).catch((response: any) => {
resolve([]);
console.log(JSON.stringify(context));
console.error('查询FetchRoot数据集异常!');
});
}
})
}
/**
* 填充 树视图节点[RootAccount]子节点
*
* @public
* @param {any{}} context
* @param {*} filter
* @param {any[]} list
* @returns {Promise<any>}
* @memberof AccountService
*/
@Errorlog
public async fillRootaccountNodeChilds(context:any={}, filter: any, list: any[]): Promise<any> {
if (filter.srfnodefilter && !Object.is(filter.srfnodefilter,"")) {
// 填充ChildAccount
let ChildaccountRsNavContext:any = {};
let ChildaccountRsNavParams:any = {};
let ChildaccountRsParams:any = {};
await this.fillChildaccountNodes(context, filter, list ,ChildaccountRsNavContext,ChildaccountRsNavParams,ChildaccountRsParams);
} else {
// 填充ChildAccount
let ChildaccountRsNavContext:any = {};
let ChildaccountRsNavParams:any = {};
let ChildaccountRsParams:any = {};
await this.fillChildaccountNodes(context, filter, list ,ChildaccountRsNavContext,ChildaccountRsNavParams,ChildaccountRsParams);
}
}
/**
* 填充 树视图节点[全部客户]
*
* @public
* @param {any{}} context
* @param {*} filter
* @param {any[]} list
* @param {*} rsNavContext
* @param {*} rsNavParams
* @param {*} rsParams
* @returns {Promise<any>}
* @memberof AccountService
*/
@Errorlog
public fillRootNodes(context:any={},filter: any, list: any[],rsNavContext?:any,rsNavParams?:any,rsParams?:any): Promise<any> {
context = this.handleResNavContext(context,filter,rsNavContext);
filter = this.handleResNavParams(context,filter,rsNavParams,rsParams);
return new Promise((resolve:any,reject:any) =>{
let treeNode: any = {};
Object.assign(treeNode, { text: 'entities.account.account_treeview.nodes.root' });
Object.assign(treeNode, { isUseLangRes: true });
Object.assign(treeNode,{srfappctx:context});
Object.assign(treeNode, { srfmajortext: treeNode.text });
let strNodeId: string = 'ROOT';
Object.assign(treeNode, { srfkey: 'root' });
strNodeId += this.TREENODE_SEPARATOR;
strNodeId += 'root';
Object.assign(treeNode, { id: strNodeId });
Object.assign(treeNode, { expanded: filter.isAutoexpand });
Object.assign(treeNode, { leaf: false });
Object.assign(treeNode, { nodeid: treeNode.srfkey });
Object.assign(treeNode, { nodeid2: filter.strRealNodeId });
list.push(treeNode);
resolve(list);
});
}
/**
* 填充 树视图节点[全部客户]子节点
*
* @public
* @param {any{}} context
* @param {*} filter
* @param {any[]} list
* @returns {Promise<any>}
* @memberof AccountService
*/
@Errorlog
public async fillRootNodeChilds(context:any={}, filter: any, list: any[]): Promise<any> {
if (filter.srfnodefilter && !Object.is(filter.srfnodefilter,"")) {
// 填充RootAccount
let RootaccountRsNavContext:any = {};
let RootaccountRsNavParams:any = {};
let RootaccountRsParams:any = {};
await this.fillRootaccountNodes(context, filter, list ,RootaccountRsNavContext,RootaccountRsNavParams,RootaccountRsParams);
} else {
// 填充RootAccount
let RootaccountRsNavContext:any = {};
let RootaccountRsNavParams:any = {};
let RootaccountRsParams:any = {};
await this.fillRootaccountNodes(context, filter, list ,RootaccountRsNavContext,RootaccountRsNavParams,RootaccountRsParams);
}
}
/**
* 填充 树视图节点[ChildAccount]
*
* @public
* @param {any{}} context
* @param {*} filter
* @param {any[]} list
* @param {*} rsNavContext
* @param {*} rsNavParams
* @param {*} rsParams
* @returns {Promise<any>}
* @memberof AccountService
*/
@Errorlog
public fillChildaccountNodes(context:any={},filter: any, list: any[],rsNavContext?:any,rsNavParams?:any,rsParams?:any): Promise<any> {
context = this.handleResNavContext(context,filter,rsNavContext);
filter = this.handleResNavParams(context,filter,rsNavParams,rsParams);
return new Promise((resolve:any,reject:any) =>{
let searchFilter: any = {};
if (Object.is(filter.strNodeType, this.TREENODE_ROOTACCOUNT)) {
Object.assign(searchFilter, { n_parentaccountid_eq: filter.nodeid });
}
Object.assign(searchFilter, { total: false });
let bFirst: boolean = true;
let records: any[] = [];
try {
this.searchChildaccount(context, searchFilter, filter).then((records:any) =>{
if(records && records.length >0){
records.forEach((entity: any) => {
let treeNode: any = {};
// 整理context
let strId: string = entity.accountid;
let strText: string = entity.accountname;
Object.assign(treeNode,{srfparentdename:'Account',srfparentkey:entity.accountid});
let tempContext:any = JSON.parse(JSON.stringify(context));
Object.assign(tempContext,{srfparentdename:'Account',srfparentkey:entity.accountid,account:strId})
Object.assign(treeNode,{srfappctx:tempContext});
Object.assign(treeNode,{'account':strId});
Object.assign(treeNode, { srfkey: strId });
Object.assign(treeNode, { text: strText, srfmajortext: strText });
let strNodeId: string = 'ChildAccount';
strNodeId += this.TREENODE_SEPARATOR;
strNodeId += strId;
Object.assign(treeNode, { id: strNodeId });
Object.assign(treeNode, { expanded: filter.isautoexpand });
Object.assign(treeNode, { leaf: true });
Object.assign(treeNode, { curData: entity });
Object.assign(treeNode, { nodeid: treeNode.srfkey });
Object.assign(treeNode, { nodeid2: filter.strRealNodeId });
list.push(treeNode);
resolve(list);
bFirst = false;
});
}else{
resolve(list);
}
});
} catch (error) {
console.error(error);
}
});
}
/**
* 获取查询集合
*
* @public
* @param {any{}} context
* @param {*} searchFilter
* @param {*} filter
* @returns {any[]}
* @memberof TestEnetityDatasService
*/
@Errorlog
public searchChildaccount(context:any={}, searchFilter: any, filter: any): Promise<any> {
return new Promise((resolve:any,reject:any) =>{
if(filter.viewparams){
Object.assign(searchFilter,filter.viewparams);
}
if(!searchFilter.page){
Object.assign(searchFilter,{page:0});
}
if(!searchFilter.size){
Object.assign(searchFilter,{size:1000});
}
if(context && context.srfparentdename){
Object.assign(searchFilter,{srfparentdename:JSON.parse(JSON.stringify(context)).srfparentdename});
}
if(context && context.srfparentkey){
Object.assign(searchFilter,{srfparentkey:JSON.parse(JSON.stringify(context)).srfparentkey});
}
Object.assign(searchFilter,{sort: 'accountname,asc'})
const _appEntityService: any = this.appEntityService;
let list: any[] = [];
if (_appEntityService['FetchDefault'] && _appEntityService['FetchDefault'] instanceof Function) {
const response: Promise<any> = _appEntityService['FetchDefault'](context, searchFilter, false);
response.then((response: any) => {
if (!response.status || response.status !== 200) {
resolve([]);
console.log(JSON.stringify(context));
console.error('查询FetchDefault数据集异常!');
}
const data: any = response.data;
if (Object.keys(data).length > 0) {
list = JSON.parse(JSON.stringify(data));
resolve(list);
} else {
resolve([]);
}
}).catch((response: any) => {
resolve([]);
console.log(JSON.stringify(context));
console.error('查询FetchDefault数据集异常!');
});
}
})
}
/**
* 填充 树视图节点[ChildAccount]子节点
*
* @public
* @param {any{}} context
* @param {*} filter
* @param {any[]} list
* @returns {Promise<any>}
* @memberof AccountService
*/
@Errorlog
public async fillChildaccountNodeChilds(context:any={}, filter: any, list: any[]): Promise<any> {
if (filter.srfnodefilter && !Object.is(filter.srfnodefilter,"")) {
} else {
}
}
/**
* 处理代码表返回数据(树状结构)
*
* @param result 返回数组
* @param context 应用上下文
* @param callBack 回调
* @memberof AccountService
*/
public handleDataSet(result:Array<any>,context:any,callBack:any){
let list:Array<any> = [];
if(result.length === 0){
return list;
}
result.forEach((codeItem:any) =>{
if(!codeItem.pvalue){
let valueField:string = codeItem.value;
this.setChildCodeItems(valueField,result,codeItem);
list.push(codeItem);
}
})
this.setNodeData(list,context,callBack);
return list;
}
/**
* 处理非根节点数据
*
* @param result 返回数组
* @param context 应用上下文
* @param callBack 回调
* @memberof AccountService
*/
public setChildCodeItems(pValue:string,result:Array<any>,codeItem:any){
result.forEach((item:any) =>{
if(item.pvalue == pValue){
let valueField:string = item.value;
this.setChildCodeItems(valueField,result,item);
if(!codeItem.children){
codeItem.children = [];
}
codeItem.children.push(item);
}
})
}
/**
* 设置节点UI数据
*
* @param result 返回数组
* @param context 应用上下文
* @param callBack 回调
* @memberof AccountService
*/
public setNodeData(result:Array<any>,context:any,callBack:any){
result.forEach((item:any) =>{
if(item.children){
item.leaf = false;
this.setNodeData(item.children,context,callBack);
}else{
item.leaf = true;
}
callBack(context,item);
})
}
/**
* 处理节点关系导航上下文
*
* @param context 应用上下文
* @param filter 参数
* @param resNavContext 节点关系导航上下文
*
* @memberof AccountService
*/
public handleResNavContext(context:any,filter:any,resNavContext:any){
if(resNavContext && Object.keys(resNavContext).length > 0){
let tempContextData:any = JSON.parse(JSON.stringify(context));
let tempViewParams:any = {};
if(filter && filter.viewparams){
tempViewParams = filter.viewparams;
}
Object.keys(resNavContext).forEach((item:any) =>{
let curDataObj:any = resNavContext[item];
this.handleCustomDataLogic(context,tempViewParams,curDataObj,tempContextData,item);
})
return tempContextData;
}else{
return context;
}
}
/**
* 处理关系导航参数
*
* @param context 应用上下文
* @param filter 参数
* @param resNavParams 节点关系导航参数
* @param resParams 节点关系参数
*
* @memberof AccountService
*/
public handleResNavParams(context:any,filter:any,resNavParams:any,resParams:any){
if((resNavParams && Object.keys(resNavParams).length >0) || (resParams && Object.keys(resParams).length >0)){
let tempViewParamData:any = {};
let tempViewParams:any = {};
if(filter && filter.viewparams){
tempViewParams = filter.viewparams;
tempViewParamData = JSON.parse(JSON.stringify(filter.viewparams));
}
if( Object.keys(resNavParams).length > 0){
Object.keys(resNavParams).forEach((item:any) =>{
let curDataObj:any = resNavParams[item];
this.handleCustomDataLogic(context,tempViewParams,curDataObj,tempViewParamData,item);
})
}
if( Object.keys(resParams).length > 0){
Object.keys(resParams).forEach((item:any) =>{
let curDataObj:any = resParams[item];
tempViewParamData[item.toLowerCase()] = curDataObj.value;
})
}
Object.assign(filter,{viewparams:tempViewParamData});
return filter;
}else{
return filter;
}
}
/**
* 处理自定义节点关系导航数据
*
* @param context 应用上下文
* @param viewparams 参数
* @param curNavData 节点关系导航参数对象
* @param tempData 返回数据
* @param item 节点关系导航参数键值
*
* @memberof AccountService
*/
public handleCustomDataLogic(context:any,viewparams:any,curNavData:any,tempData:any,item:string){
// 直接值直接赋值
if(curNavData.isRawValue){
if(Object.is(curNavData.value,"null") || Object.is(curNavData.value,"")){
Object.defineProperty(tempData, item.toLowerCase(), {
value: null,
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(tempData, item.toLowerCase(), {
value: curNavData.value,
writable : true,
enumerable : true,
configurable : true
});
}
}else{
// 先从导航上下文取数,没有再从导航参数(URL)取数,如果导航上下文和导航参数都没有则为null
if(context[(curNavData.value).toLowerCase()]){
Object.defineProperty(tempData, item.toLowerCase(), {
value: context[(curNavData.value).toLowerCase()],
writable : true,
enumerable : true,
configurable : true
});
}else{
if(viewparams[(curNavData.value).toLowerCase()]){
Object.defineProperty(tempData, item.toLowerCase(), {
value: viewparams[(curNavData.value).toLowerCase()],
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(tempData, item.toLowerCase(), {
value: null,
writable : true,
enumerable : true,
configurable : true
});
}
}
}
}
}
\ No newline at end of file
<script lang='tsx'>
import { Component } from 'vue-property-decorator';
import AccountBase from './account-treeview-base.vue';
@Component({
components: {
}
})
export default class Account extends AccountBase {
}
</script>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册