提交 39181e96 编写于 作者: KK's avatar KK

多数据部件 删除冗余代码

上级 bacb3854
......@@ -4,7 +4,7 @@ import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import GlobalUiService from '@/global-ui-service/global-ui-service';
import { ControlBase } from '@ibiz-core'
import { ControlBase , MOBMDCTRLBase } from '@ibiz-core'
<#if appde??>
import ${srfclassname('${appde.getCodeName()}')}Service from '@/app-core/service/${srffilepath2(appde.getCodeName())}/${srffilepath2(appde.getCodeName())}-service';
import ${srfclassname('${ctrl.codeName}')}Service from '@/app-core/ctrl-service/${srffilepath2(appde.getCodeName())}/${srffilepath2(ctrl.codeName)}-${ctrl.getControlType()?lower_case}-service';
......@@ -22,10 +22,10 @@ import ${srfclassname('${ctrl.codeName}')}Service from '@/app-core/ctrl-service/
components: {
}
})
export default class ${srfclassname('${ctrl.codeName}')}Base extends ControlBase implements ControlInterface {
export default class ${srfclassname('${ctrl.codeName}')}Base extends <#if ctrl.getControlType() == 'MOBMDCTRL'>MOBMDCTRLBase<#else>ControlBase</#if> implements ControlInterface {
/**
* 获取部件类型
* 获取部件类型 ${ctrl.getControlType()?lower_case?cap_first}
*
* @returns {string}
* @memberof ${srfclassname('${ctrl.codeName}')}
......
......@@ -6,70 +6,6 @@
../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl
</#ibizinclude>
/**
* 视图类型
*
* @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop() protected viewType?: string | 'DEMOBMDVIEW' | 'DEMOBMDVIEW9' | 'DEMOBWFMDVIEW';
/**
* 显示处理提示
*
* @type {boolean}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop({ default: true }) protected showBusyIndicator?: boolean;
/**
* 部件行为--update
*
* @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop() protected updateAction!: string;
/**
* 部件行为--fetch
*
* @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop() protected fetchAction!: string;
/**
* 部件行为--remove
*
* @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop() protected removeAction!: string;
/**
* 部件行为--load
*
* @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop() protected loadAction!: string;
/**
* 部件行为--loaddraft
*
* @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop() protected loaddraftAction!: string;
/**
* 部件行为--create
*
* @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop() protected createAction!: string;
/**
* 部件样式
*
......@@ -78,105 +14,6 @@
*/
@Prop({default: '<#if ctrl.getMobListStyle?? && ctrl.getMobListStyle()??>${ctrl.getMobListStyle()}</#if>'}) protected controlStyle!: string | 'ICONVIEW' | 'LISTVIEW' | 'SWIPERVIEW' | 'LISTVIEW2' | 'LISTVIEW3' | 'LISTVIEW4';
/**
*上级传递的选中项
*@type {Array}
*@memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop() public selectedData?:Array<any>;
/**
* 新建打开视图
*
* @type {Function}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop() public newdata?: Function;
/**
* 打开视图
*
* @type {Function}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop() public opendata?: Function;
/**
* 当前选中数组
*
* @type {array}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public selectdata :any = [];
/**
* 关闭行为
*
* @type {Function}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop() public close?:Function;
/**
* 是否为临时模式
*
* @type {boolean}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop({ default: false}) public isTempMode?:boolean;
<#if view.getViewType()?? && view.getViewType()=='DEMOBPICKUPMDVIEW'>
/**
* 存放多数据选择数组(多选)
*
* @type {array}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public checkboxList:Array<string> = [];
/**
* 存放数据选择数组(单选)
*
* @type {object}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public radio:any = '';
/**
* 点击多选按钮触发
*
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public change(){
if(this.isMutli){
let checkboxLists= this.items.filter((item,index)=>{
if(this.checkboxList.indexOf(item.srfkey)!=-1){
return true;
}else{
return false;
}
})
this.$emit('selectchange',checkboxLists);
}else{
let radioItem = this.items.filter((item,index)=>{return item.srfkey==this.radio});
this.$emit('selectchange',radioItem);
}
}
</#if>
/**
* 列表键值对
*
* @type {Map}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public listMap: any = new Map();
/**
* 分页大小
......@@ -185,159 +22,7 @@
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public pageSize: number = ${ctrl.getPagingSize()?c};
/**
* 总页数
*
* @type {number}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public pageTotal: number = 0;
/**
* 当前页数
*
* @type {number}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public pageNumber: number = 1;
/**
* 判断底部数据是否全部加载完成,若为真,则 bottomMethod 不会被再次触发
*
* @type {number}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
get allLoaded() {
return ((this.pageNumber + 1) * this.pageSize) >= this.pageTotal ? true : false;
}
/**
* 底部状态
*
* @type {String}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
// public bottomStatus: String = "";
/**
* 顶部状态
*
* @type {String}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
// public topStatus: String = "";
/**
*
*
* @type {Number}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
// public moveTranslate: Number = 0;
/**
* searchKey 搜索关键字
*
* @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public searchKey:string = '';
/**
* 列表数组
*
* @param {Array<any>}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public items:Array<any> =[];
/**
* 选中数组
*
* @param {Array<any>}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public selectedArray:Array<any> = [];
/**
* 多选计数
*
* @param {number}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public selectednumber:number =0;
/**
* 搜索行为
*
* @param {string}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop() public searchAction?:string;
/**
* 是否为选择视图
*
* @param {boolean}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop() public isSelected?:boolean;
/**
* 是否多选
*
* @type {boolean}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop({default:false}) public isMutli?: boolean;
/**
* 单选选择值
*
* @param {string}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public selectedValue:string = "";
/**
* 底部改变状态
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public handleBottomChange(status: String) {
// this.bottomStatus = status;
}
/**
* 顶部改变状态
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public handleTopChange(status: String) {
// this.moveTranslate = 1;
// this.topStatus = status;
}
/**
* 上拉加载更多数据
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public async loadBottom(): Promise<any> {
this.pageNumber++;
let params = {};
if (this.viewparams) {
Object.assign(params, this.viewparams);
}
Object.assign(params, { query: this.searchKey, page: this.pageNumber, size: this.pageSize });
let response: any = await this.load(params, 'bottom');
let loadmoreBottom: any = this.$refs.loadmoreBottom;
if (loadmoreBottom) {
loadmoreBottom.complete();
}
}
/**
* 删除
*
......@@ -393,178 +78,6 @@
});
}
/**
* 刷新数据
*
* @returns {Promise<any>}
* @memberof ${srfclassname('${ctrl.name}')}
*/
public refresh(): Promise<any> {
return new Promise((resolve: any, reject: any) => {
this.load().then((res) => {
resolve(res);
}).catch((error: any) => {
reject(error);
})
})
}
/**
* 快速搜索
*
* @param {string} query
* @returns {Promise<any>}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public async quickSearch(query: string): Promise<any> {
this.searchKey = query;
this.pageNumber = 0;
const response = await this.load(Object.assign({ query: query }, { page: this.pageNumber, size: this.pageSize }), "init");
return response;
}
/**
* 数据加载
*
* @private
* @param {*} [data={}]
* @param {string} [type=""]
* @returns {Promise<any>}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
private async load(data: any = {}, type: string = ""): Promise<any> {
if (!data.page) {
Object.assign(data, { page: this.pageNumber });
}
if (!data.size) {
Object.assign(data, { size: this.pageSize });
}
//排序
if(data.data && data.data.sort){
Object.assign(data, { sort:data.data.sort });
}
const parentdata: any = {};
this.$emit('beforeload', parentdata);
Object.assign(data, parentdata);
const response: any = await this.service.search(this.fetchAction, this.context, data, this.showBusyIndicator);
if (!response || response.status !== 200) {
this.$notify({ type: 'danger', message: response.error.message });
return response;
}
this.$emit('load', (response.data && response.data.records) ? response.data.records : []);
this.pageTotal = response.data.total;
if (type == 'top') {
this.items = [];
this.items = response.data.records;
} else if (type == 'bottom') {
for (let i = 0; i < response.data.records.length; i++) {
this.items.push(response.data.records[i]);
}
} else {
this.items = [];
this.items = response.data.records;
}
return response;
}
/**
* 全选
*
* @private
* @param {*} [arg={}]
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
private handleClick() {
this.items.forEach((item: any) => {
item.value = true;
});
this.selectednumber = this.items.length;
}
/**
* checkbox 选中回调
*
* @param {*} data
* @returns
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public checkboxChange(data: any) {
let { detail } = data;
if (!detail) {
return;
}
let { value } = detail;
this.selectednumber = 0;
this.items.forEach((item: any, index: number) => {
if (item.value) {
this.selectednumber++;
}
if (Object.is(item.${appde.getCodeName()?lower_case}id, value)) {
if (detail.checked) {
this.selectdata.push(this.items[index]);
} else {
this.selectdata.splice(this.selectdata.findIndex((i: any) => i.value === item.value), 1)
}
}
});
this.$emit('selectionchange', this.selectdata);
}
/**
* 下拉刷新
*
* @returns {Promise<any>}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public async pullDownToRefresh(): Promise<any> {
this.pageNumber = 0;
let params = {};
if (this.viewparams) {
Object.assign(params, this.viewparams);
}
Object.assign(params, { query: this.searchKey, pageNumber: this.pageNumber, pageSize: this.pageSize });
let response: any = await this.load(params, 'top');
return response;
}
/**
* 点击列表数据跳转
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public goPage(item: String) {
this.selectedArray.push(item);
this.$emit('rowclick',item);
}
/**
* 获取多项数据
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public getDatas(): any[] {
return this.selectedArray;
}
/**
* 获取单项数据
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public getData(): any {
return this.selectedArray[0];
}
/**
* vue生命周期created
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public created() {
this.afterCreated();
}
/**
* 执行created后的逻辑
*
......@@ -610,15 +123,6 @@
</#if>
}
/**
* vue 生命周期
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public destroyed() {
this.afterDestroy();
}
/**
* 执行destroyed后的逻辑
*
......@@ -663,25 +167,6 @@
</#if>
}
/**
* 单选选中变化
*
* @memberof ${srfclassname('${ctrl.name}')}
*/
public onSimpleSelChange(item: any = {}) {
this.$emit('selectionchange', [item]);
this.selectedValue = item.srfkey;
this.selectedArray = [];
this.goPage(item);
}
/**
* 是否展示多选
*
* @memberof Mdctrl
*/
@Prop({default:false}) showCheack?: boolean;
/**
* 选中或取消事件
......@@ -706,75 +191,6 @@
});
}
/**
* 长按定时器
*
* @memberof ${srfclassname('${ctrl.name}')}
*/
public loop :any;
/**
* 开始长按
*
* @memberof ${srfclassname('${ctrl.name}')}
*/
public start () {
      clearTimeout(this.loop); //再次清空定时器,防止重复注册定时器
      this.loop = setTimeout(() => {
this.$emit('showCheackChange', !this.showCheack);
      }, 1000);
    }
/**
* 结束长按
*
* @memberof ${srfclassname('${ctrl.name}')}
*/
public end () {
clearTimeout(this.loop); //清空定时器,防止重复注册定时器
}
/**
* 全选事件
*
* @memberof ${srfclassname('${ctrl.name}')}
*/
public checkboxAll(item:any) {
this.selectAllIschecked = item.detail.checked;
if(this.selectAllIschecked){
this.selectedArray = JSON.parse(JSON.stringify(this.items));
}else{
this.selectedArray = [];
}
this.items.forEach((item:any,index:number)=>{
this.items[index].checked = this.selectAllIschecked
});
this.$forceUpdate();
}
/**
* 全选按钮选中状态
*
* @memberof ${srfclassname('${ctrl.name}')}
*/
public selectAllIschecked = false;
/**
* 关闭滑动项
*
* @memberof Mdctrl
*/
public closeSliding(){
let sliding :any = this.$refs.sliding;
if(sliding){
sliding.forEach((item:any) => {
item.closeOpened();
});
}
}
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl
</#ibizinclude>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册