提交 12c8ec96 编写于 作者: KK's avatar KK

修复快速分组异常

上级 e6bdee4b
......@@ -29,25 +29,18 @@
</template>
<script lang="ts">
import {
Vue,
Component,
Prop,
Provide,
Emit,
Watch,
} from "vue-property-decorator";
import { Vue, Component, Prop, Provide, Emit, Watch, } from "vue-property-decorator";
@Component({
components: {},
components: {},
})
export default class AppQuickGroupTab extends Vue {
/**
* 快速分组代码表
*
* @type {any[]}
* @memberof ViewQuickGroupTab
*/
@Prop({ default: () => [] }) public items!: Array<any>;
/**
* 快速分组代码表
*
* @type {any[]}
* @memberof ViewQuickGroupTab
*/
@Prop({ default: () => [] }) public items!: Array<any>;
/**
* 快速分组代码表
......@@ -55,160 +48,159 @@ export default class AppQuickGroupTab extends Vue {
* @type {any[]}
* @memberof ViewQuickGroupTab
*/
@Prop({ default:0 }) public pageTotal!: number;
@Prop({ default: 0 }) public pageTotal!: number;
/**
* 渲染列表
*
* @type {any[]}
* @memberof AppQuickGroup
*/
public showItems: any[] = [];
/**
* 渲染列表
*
* @type {any[]}
* @memberof AppQuickGroup
*/
public showItems: any[] = [];
/**
* 子项列表
*
* @type {any[]}
* @memberof AppQuickGroup
*/
public subItems: any[] = [];
/**
* 子项列表
*
* @type {any[]}
* @memberof AppQuickGroup
*/
public subItems: any[] = [];
/**
* 监控代码表变化
*
* @memberof AppQuickGroup
*/
@Watch("items", { immediate: true })
public itemsWatch(): void {
if (this.items) {
this.items.every((item: any) => {
if (item.default) {
this.$nextTick(() => {
this.handleClick(item, true);
})
/**
* 监控代码表变化
*
* @memberof AppQuickGroup
*/
@Watch("items", { immediate: true })
public itemsWatch(): void {
if (this.items) {
this.items.every((item: any) => {
if (item.default) {
this.$nextTick(() => {
this.handleClick(item, true, true);
})
}
return !item.default;
});
this.showItems = this.handleDataSet(this.items);
}
return !item.default;
});
this.showItems = this.handleDataSet(this.items);
}
}
/**
* UI选中项
*
* @type {*}
* @memberof AppQuickGroup
*/
public selectedUiItem: any = {};
/**
* UI选中项
*
* @type {*}
* @memberof AppQuickGroup
*/
public selectedUiItem: any = {};
/**
* 是否选中当前项
*
* @param item 传入当前项
* @memberof AppQuickGroup
*/
public isSelectedItem(item: any): boolean {
if (this.selectedUiItem && this.selectedUiItem.id === item.id) {
return true;
} else {
return false;
/**
* 是否选中当前项
*
* @param item 传入当前项
* @memberof AppQuickGroup
*/
public isSelectedItem(item: any): boolean {
if (this.selectedUiItem && this.selectedUiItem.id === item.id) {
return true;
} else {
return false;
}
}
}
/**
* 处理代码表返回数据(树状结构)
*
* @param result 返回数组
* @memberof AppQuickGroup
*/
public handleDataSet(result: Array<any>): any[] {
let list: Array<any> = [];
if (result.length === 0) {
return list;
/**
* 处理代码表返回数据(树状结构)
*
* @param result 返回数组
* @memberof AppQuickGroup
*/
public handleDataSet(result: Array<any>): 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);
}
});
return list;
}
result.forEach((codeItem: any) => {
if (!codeItem.pvalue) {
let valueField: string = codeItem.value;
this.setChildCodeItems(valueField, result, codeItem);
list.push(codeItem);
}
});
return list;
}
/**
* 处理非根节点数据
*
* @param pValue 父值
* @param result 返回数组
* @param codeItem 代码项
* @memberof AppQuickGroup
*/
public setChildCodeItems(
pValue: string,
result: Array<any>,
codeItem: any
): void {
result.forEach((item: any) => {
if (item.pvalue == pValue) {
let valueField: string = item.value;
this.setChildCodeItems(valueField, result, item);
if (!codeItem.children) {
codeItem.children = [];
/**
* 处理非根节点数据
*
* @param pValue 父值
* @param result 返回数组
* @param codeItem 代码项
* @memberof AppQuickGroup
*/
public setChildCodeItems(pValue: string, result: Array<any>, codeItem: any): void {
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);
}
});
}
/**
* 处理点击事件
*
* @param $event 值
* @param isswitch 是否切换UI选中项
* @memberof AppQuickGroup
*/
public handleClick($event: any, isswitch: boolean = true, isDefalut: boolean = false): void {
if (isswitch) {
this.selectedUiItem = $event;
}
codeItem.children.push(item);
}
});
}
if ($event.children) {
if (this.subItems.length > 0) {
this.subItems.length = 0;
} else {
this.subItems.push(...$event.children);
}
} else {
this.subItems.length = 0;
this.items.forEach((item: any) => {
item.selected = false;
item.childSelected = false;
item.selectChildLabel = "";
})
$event.selected = true;
if ($event.pvalue) {
this.items.forEach((item: any) => {
if (item.value === $event.pvalue) {
item.childSelected = true;
item.selectChildLabel = $event.label;
}
})
}
if (!isDefalut) {
this.$emit("valuechange", $event);
}
/**
* 处理点击事件
*
* @param $event 值
* @param isswitch 是否切换UI选中项
* @memberof AppQuickGroup
*/
public handleClick($event: any, isswitch: boolean = true): void {
if (isswitch) {
this.selectedUiItem = $event;
}
this.$forceUpdate();
}
if ($event.children) {
if (this.subItems.length > 0) {
/**
* 关闭遮罩层
*
* @type {any[]}
* @memberof AppQuickGroup
*/
public closeBackdrop() {
this.subItems.length = 0;
} else {
this.subItems.push(...$event.children);
}
} else {
this.subItems.length = 0;
this.items.forEach((item:any) => {
item.selected = false;
item.childSelected = false;
item.selectChildLabel = "";
})
$event.selected = true;
if ($event.pvalue) {
this.items.forEach((item:any) => {
if (item.value === $event.pvalue) {
item.childSelected = true;
item.selectChildLabel = $event.label;
}
})
}
this.$emit("valuechange", $event);
this.$forceUpdate();
}
this.$forceUpdate();
}
/**
* 关闭遮罩层
*
* @type {any[]}
* @memberof AppQuickGroup
*/
public closeBackdrop () {
this.subItems.length = 0;
this.$forceUpdate();
}
}
</script>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册