提交 f18e3b07 编写于 作者: lijinyang's avatar lijinyang

穿梭框本地文件默认分隔符

上级 53c833d5
......@@ -3,7 +3,7 @@
@on-open-change="transferRefresh"
@on-change="dataChange"
v-model="dataRight"
:style="{width:width}"
:style="{width:width===undefined?'586px':width}"
multiple
>
<Option class="hidden" :value="item" v-for="(item,i) in dataRight" :key="i">{{findLabel(item)}}</Option>
......@@ -17,7 +17,6 @@ import { ElSelect } from "element-ui/types/select";
@Component({})
export default class AppTransfer extends Vue {
/**
* 左侧框数据
*/
......@@ -31,7 +30,7 @@ export default class AppTransfer extends Vue {
/**
* 穿梭框宽度
*/
@Prop() public width:any;
@Prop() public width: any ;
/**
* 代码表服务对象
......@@ -54,7 +53,7 @@ export default class AppTransfer extends Vue {
/**
* 表单传入字符串值分隔符
*/
@Prop() public valueSeparator?: string;
@Prop() public valueSeparator!: string;
/**
* 当前选中值
* @type {any}
......@@ -83,14 +82,26 @@ export default class AppTransfer extends Vue {
* @memberof AppTransfer
*/
dataChange(e: any) {
let _valueSeparator: any;
_valueSeparator = this.initValueSeparator(_valueSeparator);
let newVal: any;
newVal = e.join(`${this.valueSeparator}`);
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;
}
}
/**
* 传入额外参数
......@@ -170,8 +181,12 @@ export default class AppTransfer extends Vue {
this.codeListService
.getItems(this.tag, _context, _param)
.then((res: any) => {
console.log(res);
this.dataLeft = res;
this.initLeft();
console.log(this.dataLeft);
this.initRight();
})
.catch((error: any) => {
......@@ -222,7 +237,7 @@ export default class AppTransfer extends Vue {
this.dataLeft.push({
key: elem.id,
value: elem.value,
label: elem.label,
label: elem.text,
disabled: elem.disabled
});
});
......@@ -231,9 +246,11 @@ export default class AppTransfer extends Vue {
* 初始化右侧框数据
*/
public initRight() {
let _valueSeparator: any;
_valueSeparator = this.initValueSeparator(_valueSeparator);
let _data: any = this.itemValue;
if (_data) {
let newData: any[] = _data.split(`${this.valueSeparator}`);
let newData: any[] = _data.split(`${_valueSeparator}`);
this.dataLeft.forEach((elem: any) => {
newData.forEach((item: any) => {
if (item === elem.value) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册