提交 77349a50 编写于 作者: tony001's avatar tony001

Update app-transfer.vue

上级 255b92d6
......@@ -3,7 +3,7 @@
@on-open-change="transferRefresh"
@on-change="dataChange"
v-model="dataRight"
:style="{width:width===undefined?'586px':width}"
:style="{width:width?width:'586px'}"
multiple
>
<Option class="hidden" :value="item" v-for="(item,i) in dataRight" :key="i">{{findLabel(item)}}</Option>
......@@ -17,43 +17,23 @@ import { ElSelect } from "element-ui/types/select";
@Component({})
export default class AppTransfer extends Vue {
/**
* 左侧框数据
*/
public dataLeft: any[] = [];
/**
* 右侧框数据
*/
public dataRight: any[] = [];
/**
* 穿梭框宽度
*/
@Prop() public width: any;
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof AppTransfer
*/
public codeListService: CodeListService = new CodeListService({
$store: this.$store
});
/**
* 查询参数
* @type {*}
* @memberof AppTransfer
*/
public queryParam: any;
@Prop() public width: any;
/**
* 表单传入字符串值分隔符
*
* @type {string}
* @memberof AppTransfer
*/
@Prop() public valueSeparator!: string;
/**
* 当前选中值
* @type {any}
......@@ -93,33 +73,6 @@ export default class AppTransfer extends Vue {
*/
@Prop() public localParam!: any;
/**
* 组件change事件,右侧框数据变化时
* @memberof AppTransfer
*/
dataChange(e: any) {
let _valueSeparator: any;
_valueSeparator = this.initValueSeparator(_valueSeparator);
let newVal: any;
newVal = e.join(`${_valueSeparator}`);
if (newVal) {
this.$emit("change", newVal);
} else {
this.$emit("change", null);
}
}
/**
* 初始化valueSeparator
*/
public initValueSeparator(_valueSeparator: any) {
if (this.valueSeparator === undefined) {
return ",";
} else {
return this.valueSeparator;
}
}
/**
* 视图上下文
*
......@@ -138,6 +91,7 @@ export default class AppTransfer extends Vue {
/**
* 是否禁用
*
* @type {any}
* @memberof AppTransfer
*
......@@ -145,18 +99,38 @@ export default class AppTransfer extends Vue {
@Prop() public disabled?: any;
/**
* 是否支持过滤
* @type {boolean}
* placeholder
*
* @type {string}
* @memberof AppTransfer
*
*/
@Prop() public placeholder?: string;
/**
* 左侧框数据
*
* @type {any[]}
* @memberof AppTransfer
*/
@Prop() public filterable?: boolean;
public dataLeft: any[] = [];
/**
* 下拉选提示内容
* @type {string}
* 右侧框数据
*
* @type {any[]}
* @memberof AppTransfer
*/
@Prop() public placeholder?: string;
public dataRight: any[] = [];
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof AppTransfer
*/
public codeListService: CodeListService = new CodeListService({$store: this.$store});
/**
* vue 生命周期
......@@ -167,8 +141,34 @@ export default class AppTransfer extends Vue {
this.dataHandle();
}
/**
* 组件change事件,右侧框数据变化时
*
* @memberof AppTransfer
*/
dataChange(e: any) {
let _valueSeparator: string = this.initValueSeparator();
let newVal: string = e.join(`${_valueSeparator}`);
if (newVal) {
this.$emit("change", newVal);
} else {
this.$emit("change", null);
}
}
/**
* 初始化valueSeparator
*
* @memberof AppTransfer
*/
public initValueSeparator() {
return this.valueSeparator?this.valueSeparator:",";
}
/**
* 数据处理
*
* @memberof AppTransfer
*/
public dataHandle() {
if (this.tag && Object.is(this.codelistType, "STATIC")) {
......@@ -187,14 +187,11 @@ export default class AppTransfer extends Vue {
// 参数处理
let _context = data.context;
let _param = data.param;
this.codeListService
.getItems(this.tag, _context, _param)
.then((res: any) => {
this.codeListService.getItems(this.tag, _context, _param).then((res: any) => {
this.dataLeft = res;
this.initLeft();
this.initRight();
})
.catch((error: any) => {
}).catch((error: any) => {
console.log(`----${this.tag}----代码表不存在`);
});
}
......@@ -207,35 +204,25 @@ export default class AppTransfer extends Vue {
* @returns
* @memberof AppTransfer
*/
public handlePublicParams(arg: any) {
// 合并表单参数
arg.param = this.viewparams
? JSON.parse(JSON.stringify(this.viewparams))
: {};
arg.param = this.viewparams? JSON.parse(JSON.stringify(this.viewparams)): {};
arg.context = this.context ? JSON.parse(JSON.stringify(this.context)) : {};
// 附加参数处理
if (this.localContext && Object.keys(this.localContext).length > 0) {
let _context = this.$util.computedNavData(
this.itemValue,
arg.context,
arg.param,
this.localContext
);
let _context = this.$util.computedNavData(this.itemValue,arg.context,arg.param,this.localContext);
Object.assign(arg.context, _context);
}
if (this.localParam && Object.keys(this.localParam).length > 0) {
let _param = this.$util.computedNavData(
this.itemValue,
arg.context,
arg.param,
this.localParam
);
let _param = this.$util.computedNavData(this.itemValue,arg.context,arg.param,this.localParam);
Object.assign(arg.param, _param);
}
}
/**
* 初始化左侧框数据
*
* @memberof AppTransfer
*/
public initLeft() {
let left: any[] = [];
......@@ -250,12 +237,15 @@ export default class AppTransfer extends Vue {
});
});
}
/**
* 初始化右侧框数据
*
* @memberof AppTransfer
*/
public initRight() {
let _valueSeparator: any;
_valueSeparator = this.initValueSeparator(_valueSeparator);
_valueSeparator = this.initValueSeparator();
let _data: any = this.itemValue;
if (_data) {
let _dataRight: any = [];
......@@ -270,8 +260,11 @@ export default class AppTransfer extends Vue {
this.dataRight = _dataRight;
}
}
/**
* 穿梭框打开时刷新数据
*
* @memberof AppTransfer
*/
public transferRefresh(e: any) {
if (e && this.codelistType === "DYNAMIC") {
......@@ -282,12 +275,15 @@ export default class AppTransfer extends Vue {
/**
* 找到dataLeft中key与dataRight中item相等的元素,返回label
*
* @memberof AppTransfer
*/
public findLabel(item: any) {
for (const elem of this.dataLeft) {
if (elem.key === item) return elem.label;
}
}
}
</script>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册