优化代码
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
:key="item.value"
|
||||
:index="index"
|
||||
:class="item.raw.cssClass"
|
||||
>{{ item.label + ' ' }}</span
|
||||
>{{ item.label + " " }}</span
|
||||
>
|
||||
<el-tag
|
||||
v-else
|
||||
@ -17,7 +17,7 @@
|
||||
:type="item.raw.listClass == 'primary' ? '' : item.raw.listClass"
|
||||
:class="item.raw.cssClass"
|
||||
>
|
||||
{{ item.label + ' ' }}
|
||||
{{ item.label + " " }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</template>
|
||||
@ -49,39 +49,39 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
values() {
|
||||
if (this.value !== null && typeof this.value !== 'undefined') {
|
||||
if (this.value !== null && typeof this.value !== "undefined") {
|
||||
return Array.isArray(this.value) ? this.value : [String(this.value)];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
unmatch(){
|
||||
unmatch() {
|
||||
this.unmatchArray = [];
|
||||
if (this.value !== null && typeof this.value !== 'undefined') {
|
||||
if (this.value !== null && typeof this.value !== "undefined") {
|
||||
// 传入值为非数组
|
||||
if(!Array.isArray(this.value)){
|
||||
if(this.options.some(v=> v.value == this.value )) return false;
|
||||
if (!Array.isArray(this.value)) {
|
||||
if (this.options.some((v) => v.value == this.value)) return false;
|
||||
this.unmatchArray.push(this.value);
|
||||
return true;
|
||||
}
|
||||
// 传入值为Array
|
||||
this.value.forEach(item => {
|
||||
if (!this.options.some(v=> v.value == item )) this.unmatchArray.push(item)
|
||||
this.value.forEach((item) => {
|
||||
if (!this.options.some((v) => v.value == item))
|
||||
this.unmatchArray.push(item);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
// 没有value不显示
|
||||
return false;
|
||||
},
|
||||
|
||||
},
|
||||
filters: {
|
||||
handleArray(array) {
|
||||
if(array.length===0) return '';
|
||||
if (array.length === 0) return "";
|
||||
return array.reduce((pre, cur) => {
|
||||
return pre + ' ' + cur;
|
||||
return pre + " " + cur;
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { isArray } from 'util'
|
||||
import { exportDefault, titleCase } from '@/utils/index'
|
||||
import { trigger } from './config'
|
||||
|
||||
@ -133,12 +132,12 @@ function buildRules(conf, ruleList) {
|
||||
const rules = []
|
||||
if (trigger[conf.tag]) {
|
||||
if (conf.required) {
|
||||
const type = isArray(conf.defaultValue) ? 'type: \'array\',' : ''
|
||||
let message = isArray(conf.defaultValue) ? `请至少选择一个${conf.vModel}` : conf.placeholder
|
||||
const type = Array.isArray(conf.defaultValue) ? 'type: \'array\',' : ''
|
||||
let message = Array.isArray(conf.defaultValue) ? `请至少选择一个${conf.vModel}` : conf.placeholder
|
||||
if (message === undefined) message = `${conf.label}不能为空`
|
||||
rules.push(`{ required: true, ${type} message: '${message}', trigger: '${trigger[conf.tag]}' }`)
|
||||
}
|
||||
if (conf.regList && isArray(conf.regList)) {
|
||||
if (conf.regList && Array.isArray(conf.regList)) {
|
||||
conf.regList.forEach(item => {
|
||||
if (item.pattern) {
|
||||
rules.push(`{ pattern: ${eval(item.pattern)}, message: '${item.message}', trigger: '${trigger[conf.tag]}' }`)
|
||||
|
@ -888,7 +888,7 @@
|
||||
</div>
|
||||
<div class="body">
|
||||
<img
|
||||
src="https://oscimg.oschina.net/oscnet/up-d6695f82666e5018f715c41cb7ee60d3b73.png"
|
||||
src="http://ruoyi.vip/images/pay.png"
|
||||
alt="donate"
|
||||
width="100%"
|
||||
/>
|
||||
|
Reference in New Issue
Block a user