提交 33a00402 编写于 作者: RedPig97's avatar RedPig97

update: 样式优化

上级 84c2a190
......@@ -4,6 +4,9 @@
gap: 10px;
.el-select {
width: 100%;
.el-input__suffix {
right: 25px;
}
}
.app-ey-mpicker__item {
width: 100%;
......
<template>
<div class="app-ey-mpicker">
<div class="app-ey-mpicker__item" v-for="count in selectCount" :key="count">
<el-select :value="getSelectLabel(count-1)" filterable remote :remote-method="onSearch" size="small" @change="onSelect" :disabled="disabled">
<template v-if="!valueItems[count-1]">
<el-select
:value="valueItems[count - 1]"
filterable
remote
:remote-method="onSearch"
size="small"
@change="onSelect($event, valueItems[count - 1])"
@clear="onRemove(valueItems[count - 1], true)"
@visible-change="onSelectOpen($event, count - 1)"
:clearable="selectCount == 1"
:disabled="disabled"
>
<el-option v-for="(item, index) in items" :key="index" :label="item[deMajorField]" :value="item[deKeyField]"></el-option>
</template>
</el-select>
<span class="app-ey-mpicker__search">
<i class="el-icon-search" @click="openView(valueItems[count-1])"></i>
<i class="el-icon-search" @click="openView(valueItems[count - 1])"></i>
</span>
<div class="app-ey-mpicker__button">
<img v-if="count === selectCount" src="assets/img/ic_add_circle.svg" @click="selectCount++">
<img v-else src="assets/img/remove_circle.svg" @click="onRemove(valueItems[count-1])">
<img v-if="count === selectCount" src="assets/img/ic_add_circle.svg" @click="selectCount++" />
<img v-else src="assets/img/remove_circle.svg" @click="onRemove(valueItems[count - 1])" />
</div>
</div>
</div>
</template>
<script lang = 'ts'>
import { Component, Vue, Prop, Watch } from 'vue-property-decorator';
import { Subject } from 'rxjs';
<script lang="ts">
import { Component, Vue, Prop, Watch } from "vue-property-decorator";
import { Subject } from "rxjs";
@Component({
})
@Component({})
export default class AppEYMPicker extends Vue {
/**
* 传入url
*/
......@@ -60,7 +67,7 @@ export default class AppEYMPicker extends Vue {
* @type {any}
* @memberof AppEYMPicker
*/
@Prop() public localContext!:any;
@Prop() public localContext!: any;
/**
* 局部导航参数
......@@ -68,7 +75,7 @@ export default class AppEYMPicker extends Vue {
* @type {any}
* @memberof AppEYMPicker
*/
@Prop() public localParam!:any;
@Prop() public localParam!: any;
/**
* 表单项名称
......@@ -97,7 +104,7 @@ export default class AppEYMPicker extends Vue {
* @type {*}
* @memberof AppEYMPicker
*/
@Prop({default: () => {}}) public acParams?: any;
@Prop({ default: () => {} }) public acParams?: any;
/**
* 应用实体主信息属性名称
......@@ -105,7 +112,7 @@ export default class AppEYMPicker extends Vue {
* @type {string}
* @memberof AppEYMPicker
*/
@Prop({default: 'srfmajortext'}) public deMajorField!: string;
@Prop({ default: "srfmajortext" }) public deMajorField!: string;
/**
* 应用实体主键属性名称
......@@ -113,7 +120,7 @@ export default class AppEYMPicker extends Vue {
* @type {string}
* @memberof AppEYMPicker
*/
@Prop({default: 'srfkey'}) public deKeyField!: string;
@Prop({ default: "srfkey" }) public deKeyField!: string;
/**
* 表单服务
......@@ -166,7 +173,7 @@ export default class AppEYMPicker extends Vue {
* @param newVal
* @param val
*/
@Watch('curvalue', {immediate:true, deep: true })
@Watch("curvalue", { immediate: true, deep: true })
oncurvalueChange(newVal: any, val: any) {
this.valueItems = [];
this.selectItems = [];
......@@ -177,16 +184,16 @@ export default class AppEYMPicker extends Vue {
this.valueItems.push(item[this.deKeyField]);
});
} catch (error) {
if((error as any).name === 'SyntaxError'){
let srfkeys:any = newVal.split(',');
let srfmajortexts:any = null;
if(this.valueitem && this.activeData[this.valueitem]){
srfmajortexts = this.activeData[this.valueitem].split(',');
if ((error as any).name === "SyntaxError") {
let srfkeys: any = newVal.split(",");
let srfmajortexts: any = null;
if (this.valueitem && this.activeData[this.valueitem]) {
srfmajortexts = this.activeData[this.valueitem].split(",");
}
if(srfkeys.length && srfkeys.length > 0 && srfmajortexts.length && srfmajortexts.length > 0 && srfkeys.length == srfmajortexts.length){
if (srfkeys.length && srfkeys.length > 0 && srfmajortexts.length && srfmajortexts.length > 0 && srfkeys.length == srfmajortexts.length) {
srfkeys.forEach((id: any, index: number) => {
this.valueItems.push(id);
this.selectItems.push({[this.deKeyField]: id, [this.deMajorField]: srfmajortexts[index]});
this.selectItems.push({ [this.deKeyField]: id, [this.deMajorField]: srfmajortexts[index] });
});
}
}
......@@ -195,6 +202,19 @@ export default class AppEYMPicker extends Vue {
this.$forceUpdate();
}
/**
* 下拉切换回调
* @param boolean
*/
public onSelectOpen(visible: boolean, index: number): void {
if (visible) {
const label = this.getSelectLabel(index);
if (this.items.length == 0 || !label) {
this.onSearch(label);
}
}
}
/**
* 远程执行搜索
*
......@@ -211,28 +231,31 @@ export default class AppEYMPicker extends Vue {
// 参数处理
let _context = data.context;
let _param = data.param;
Object.assign(_param ,{ query: query });
Object.assign(_param, { query: query });
if (this.activeData) {
Object.assign(_param, { srfreferdata: this.activeData });
}
// 错误信息国际化
let error: string = (this.$t('components.appMpicker.error') as any);
let miss: string = (this.$t('components.appMpicker.miss') as any);
let requestException: string = (this.$t('components.appMpicker.requestException') as any);
if(!this.service){
this.$Notice.error({ title: error, desc: miss+'service' });
} else if(!this.acParams.serviceName) {
this.$Notice.error({ title: error, desc: miss+'serviceName' });
} else if(!this.acParams.interfaceName) {
this.$Notice.error({ title: error, desc: miss+'interfaceName' });
let error: string = this.$t("components.appMpicker.error") as any;
let miss: string = this.$t("components.appMpicker.miss") as any;
let requestException: string = this.$t("components.appMpicker.requestException") as any;
if (!this.service) {
this.$Notice.error({ title: error, desc: miss + "service" });
} else if (!this.acParams.serviceName) {
this.$Notice.error({ title: error, desc: miss + "serviceName" });
} else if (!this.acParams.interfaceName) {
this.$Notice.error({ title: error, desc: miss + "interfaceName" });
} else {
this.service.getItems(this.acParams.serviceName,this.acParams.interfaceName, _context, _param).then((response: any) => {
this.service
.getItems(this.acParams.serviceName, this.acParams.interfaceName, _context, _param)
.then((response: any) => {
if (!response) {
this.$Notice.error({ title: error, desc: requestException });
} else {
this.items = [...response];
}
}).catch((error: any) => {
})
.catch((error: any) => {
console.log(error);
});
}
......@@ -241,27 +264,13 @@ export default class AppEYMPicker extends Vue {
/**
* 下拉选中回调
*
* @param {*} selects
* @param {*} value
* @memberof AppEYMPicker
*/
public onSelect(selects: any) {
let val: Array<any> = [];
if (selects.length > 0) {
selects.forEach((select: any) => {
let index = this.items.findIndex((item) => Object.is(item[this.deKeyField], select));
if (index >= 0) {
let item = this.items[index];
val.push({ [this.deKeyField]: item[this.deKeyField], [this.deMajorField]: item[this.deMajorField] });
} else {
index = this.selectItems.findIndex((item: any) => Object.is(item[this.deKeyField], select));
if (index >= 0) {
let item = this.selectItems[index];
val.push(item);
}
}
});
let value = val.length > 0 ? JSON.stringify(this.formatValue(val)) : '';
this.$emit('formitemvaluechange', { name: this.name, value: value });
public onSelect(value: string, valueItem: string) {
const item = this.items.find((item) => Object.is(item[this.deKeyField], value));
if (item) {
this.computeItemSelect([item], valueItem);
}
}
......@@ -271,15 +280,40 @@ export default class AppEYMPicker extends Vue {
* @param {*} tag
* @memberof AppEYMPicker
*/
public onRemove(tag: any) {
let index = this.selectItems.findIndex((item: any) => Object.is(item[this.deKeyField], tag));
public onRemove(value: string, isClear: boolean = false) {
let index = this.selectItems.findIndex((item: any) => Object.is(item[this.deKeyField], value));
if (index >= 0) {
this.selectItems.splice(index, 1);
let value = this.selectItems.length > 0 ? JSON.stringify(this.formatValue(this.selectItems)) : '';
this.$emit('formitemvaluechange', { name: this.name, value: value });
let value = this.selectItems.length > 0 ? JSON.stringify(this.formatValue(this.selectItems)) : "";
console.log(value, 123);
this.$emit("formitemvaluechange", { name: this.name, value: value });
}
if (!isClear) {
this.selectCount--;
}
}
/**
* 移除标签回调
*
* @param {*} items
* @memberof AppEYMPicker
*/
public computeItemSelect(items: any[], value: string) {
if (value) {
const index = this.selectItems.findIndex((item: any) => Object.is(item[this.deKeyField], value));
if (index != -1) {
this.selectItems.splice(index, 1, ...items);
}
} else {
this.selectItems.push(...items);
}
if (this.name && this.activeData) {
let value = this.selectItems.length > 0 ? JSON.stringify(this.formatValue(this.selectItems)) : "";
console.log(value, 123);
this.$emit("formitemvaluechange", { name: this.name, value: value });
}
}
/**
* 公共参数处理
......@@ -290,20 +324,20 @@ export default class AppEYMPicker extends Vue {
*/
public handlePublicParams(arg: any): boolean {
if (!this.activeData) {
this.$Notice.error({ title: (this.$t('components.AppMpicker.error') as any), desc: (this.$t('components.AppMpicker.formdataException') as any) });
this.$Notice.error({ title: this.$t("components.AppMpicker.error") as any, desc: this.$t("components.AppMpicker.formdataException") as any });
return false;
}
// 合并表单参数
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.activeData,arg.context,arg.param,this.localContext);
Object.assign(arg.context,_context);
if (this.localContext && Object.keys(this.localContext).length > 0) {
let _context = this.$util.computedNavData(this.activeData, 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.activeData,arg.param,arg.param,this.localParam);
Object.assign(arg.param,_param);
if (this.localParam && Object.keys(this.localParam).length > 0) {
let _param = this.$util.computedNavData(this.activeData, arg.param, arg.param, this.localParam);
Object.assign(arg.param, _param);
}
return true;
}
......@@ -331,17 +365,17 @@ export default class AppEYMPicker extends Vue {
let _context = data.context;
let _viewparams = data.param;
let _selectItems = JSON.parse(JSON.stringify(this.selectItems));
if(!Object.is(this.deKeyField,"srfkey")){
_selectItems.forEach((item:any, index:number)=>{
if (!Object.is(this.deKeyField, "srfkey")) {
_selectItems.forEach((item: any, index: number) => {
_selectItems[index].srfkey = item[this.deKeyField];
});
}
_context = Object.assign(_context, { srfparentdata: { srfparentkey: this.activeData[this.deKeyField] }, });
_viewparams = Object.assign(_viewparams,{ selectedData: [..._selectItems]});
_context = Object.assign(_context, { srfparentdata: { srfparentkey: this.activeData[this.deKeyField] } });
_viewparams = Object.assign(_viewparams, { selectedData: [..._selectItems] });
let formdata = this.activeData;
const modal: Subject<any> = this.$appmodal.openModal(view, _context, _viewparams)
const modal: Subject<any> = this.$appmodal.openModal(view, _context, _viewparams);
modal.subscribe((result: any) => {
if (!result || !Object.is(result.ret, 'OK')) {
if (!result || !Object.is(result.ret, "OK")) {
return;
}
let selects: Array<any> = [];
......@@ -350,19 +384,8 @@ export default class AppEYMPicker extends Vue {
selects.push({ [this.deKeyField]: select[this.deKeyField], [this.deMajorField]: select[this.deMajorField] });
});
}
if (value) {
const index = this.selectItems.findIndex((item: any) => Object.is(item[this.deKeyField], value));
if (index != -1) {
this.selectItems.splice(index, 1, ...selects);
}
} else {
this.selectItems.push(...selects);
}
if (this.name && this.activeData) {
let value = this.selectItems.length > 0 ? JSON.stringify(this.formatValue(this.selectItems)) : '';
this.$emit('formitemvaluechange', { name: this.name, value: value });
}
})
this.computeItemSelect(selects, value);
});
}
}
......@@ -372,13 +395,13 @@ export default class AppEYMPicker extends Vue {
* @param {any[]} value 需要转换的数组
* @memberof AppEYMPicker
*/
public parseValue(value: any[]){
public parseValue(value: any[]) {
let result = [];
if(this.deKeyField !== "srfkey" || this.deMajorField !== "srfmajortext"){
if (this.deKeyField !== "srfkey" || this.deMajorField !== "srfmajortext") {
value.forEach((item: any) => {
result.push({[this.deMajorField]: item.srfmajortext, [this.deKeyField]: item.srfkey});
result.push({ [this.deMajorField]: item.srfmajortext, [this.deKeyField]: item.srfkey });
});
}else{
} else {
result = value;
}
return result;
......@@ -390,21 +413,20 @@ export default class AppEYMPicker extends Vue {
* @param {any[]} value 需要转换的数组
* @memberof AppEYMPicker
*/
public formatValue(value: any[]){
public formatValue(value: any[]) {
let result = [];
if(this.deKeyField !== "srfkey" || this.deMajorField !== "srfmajortext"){
if (this.deKeyField !== "srfkey" || this.deMajorField !== "srfmajortext") {
value.forEach((item: any) => {
result.push({srfmajortext : item[this.deMajorField], srfkey : item[this.deKeyField]});
result.push({ srfmajortext: item[this.deMajorField], srfkey: item[this.deKeyField] });
});
}else{
} else {
result = value;
}
return result;
const res = new Map();
return result.filter((item: any) => !res.has(item.srfmajortext) && res.set(item.srfmajortext, item.srfkey));
}
}
</script>
<style lang="scss">
@import './app-ey-mpicker.scss';
@import "./app-ey-mpicker.scss";
</style>
<template>
<div class="app-ey-upload">
<el-row>
<el-col v-for="(item,index) in uploadFileList" :key="index" class="app-ey-upload__item app-ey-upload__preview">
<el-col v-for="(item,index) in uploadFileList" :key="'preview' + index" class="app-ey-upload__item app-ey-upload__preview">
<span class="file-title" @click="onDownload(item)">
<span>{{item.name}}</span>
</span>
......@@ -22,7 +22,7 @@
<img src="assets/img/remove_circle.svg" @click="onRemove(item,index)">
</div>
</el-col>
<el-col v-if="!previewMode" v-for="count in buttonCount" :key="count" class="app-ey-upload__item">
<el-col v-if="!previewMode" v-for="count in buttonCount" :key="'button' + count" class="app-ey-upload__item">
<el-upload
ref="upload"
list-type="text"
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册