Browse Source

组件更新

develop
zq 4 weeks ago
parent
commit
8a698c3f21
  1. 2
      examples/src/App.vue
  2. 13
      packages/GroupFormBtns/src/index.vue
  3. 188
      packages/GuipInput/src/index.vue
  4. 82
      packages/GuipRadio/src/index.vue
  5. 116
      packages/GuipSelect/src/index.vue
  6. 1
      packages/assets/uploadIcon.svg
  7. 1
      packages/assets/uploadIcon_light.svg
  8. 801
      packages/styles/common.scss

2
examples/src/App.vue

@ -4,7 +4,7 @@
<!-- 当前示例项目未配置路由相关信息--暂时注释 --> <!-- 当前示例项目未配置路由相关信息--暂时注释 -->
<!-- <Breadcrumb /> --> <!-- <Breadcrumb /> -->
<section class="demo-section"> <section class="demo-section column gap12">
<h2>页面提示框集合</h2> <h2>页面提示框集合</h2>
<PromptText text='这是一个提示框' :type="1" /> <PromptText text='这是一个提示框' :type="1" />
<PromptText text='这是一个提示框' :type="2" /> <PromptText text='这是一个提示框' :type="2" />

13
packages/GroupFormBtns/src/index.vue

@ -1,9 +1,7 @@
<template> <template>
<div class="btns-wrap flex"> <div class="btns-wrap flex" :class="flex == 'start' ? 'flex-start' :''">
<GuipButton type="ignore" @click="cancelClick">取消</GuipButton> <GuipButton type="ignore" @click="cancelClick">{{cancelText || '取消'}}</GuipButton>
<GuipButton type="primary" @click="confirmClick">保存</GuipButton> <GuipButton type="primary" @click="confirmClick">{{confirmText ||'保存'}}</GuipButton>
</div> </div>
</template> </template>
<script> <script>
@ -11,7 +9,7 @@ import GuipButton from '../../GuipButton/src/index.vue';
export default { export default {
name: 'GroupFormBtns', name: 'GroupFormBtns',
props: [''], props: ['cancelText','confirmText','flex'],
components: { components: {
GuipButton GuipButton
}, },
@ -35,4 +33,7 @@ export default {
margin-top: 24px; margin-top: 24px;
justify-content: flex-end; justify-content: flex-end;
} }
.flex-start{
justify-content: flex-start;
}
</style> </style>

188
packages/GuipInput/src/index.vue

@ -1,44 +1,104 @@
<template> <template>
<el-form-item :style="{ ...styleObject }" :required="required" <el-form-item
:class="[{ 'column': column }, { 'w510': addClass == 'w510' }, { 'w388': addClass == 'w388' }, 'form-item']" :label="label" :style="{ ...styleObject}"
:prop="prop" :rules="rules"> :required="required"
:class="[
{ 'column': column },
{ 'w510': addClass == 'w510' },
{ 'w388': addClass == 'w388' },
{ 'client-form-flex': clientFormFlex },
'form-item'
]"
:label="clientFormFlex ? '' : label"
:prop="prop"
:rules="rules"
>
<p v-if="desc" class="desc_right">{{ desc }}</p> <p v-if="desc" class="desc_right">{{ desc }}</p>
<el-input :type="type" v-bind="$attrs" :placeholder="placeholder1" :disabled="disabled" :maxlength="maxlength1"
:style="{ width: width, height: height }" :value="inputValue" :minLength="minLength1" :show-word-limit="showWordLimit" <!-- 统一的输入框渲染 -->
@input="$emit('input', $event)" @keydown="handleKeydown" @change="$emit('change', $event)" <div :class="clientFormFlex ? 'client-form-flex-wrapper' : ''" style="width:100%">
@blur="$emit('blur', inputValue)" @focus="$emit('focus', inputValue)" class="guip-input"> <!-- 特殊样式布局的标签 -->
<!-- 自定义前面小图标 --> <div v-if="clientFormFlex" class="flex-label">
<template v-slot:prepend> <div class="label-text">{{ clientFormLabel || label }}</div>
<slot name="prependshow"></slot> <span class="colon"></span>
</template> </div>
<template v-slot:prefix>
<slot name="prefix"></slot> <!-- 输入框容器 -->
</template> <div :class="clientFormFlex ? 'flex-input' : ''">
<!-- 清除小图标 --> <el-input
<template v-slot:suffix> ref="inputRef"
<slot name="suffix"></slot> :type="type"
</template> v-bind="$attrs"
<template v-slot:append> :placeholder="placeholder1"
<slot name="appendshow"></slot> :disabled="disabled"
</template> :maxlength="maxlength1"
:style="{ width: width, height: height }"
<!-- :error="errorMessage" show-message --> :value="inputValue"
:minLength="minLength1"
<!-- <i slot="suffix" v-if="empty" class="el-icon-close" @click="handleClear">h</i> --> :show-word-limit="showWordLimit"
<!-- <el-button slot="append" v-if="hasBtn" type="primary" @click="$emit('enter',value)">搜索</el-button> --> @input="$emit('input', $event)"
</el-input> @keydown="handleKeydown"
<!-- 单位 --> @change="$emit('change', $event)"
<span class="guip-input-unit" v-if="unit">{{ unit }}</span> @blur="$emit('blur', inputValue)"
@focus="$emit('focus', inputValue)"
>
<template v-slot:prepend>
<slot name="prependshow"></slot>
</template>
<template v-slot:prefix>
<slot name="prefix"></slot>
</template>
<template v-slot:suffix>
<slot name="suffix"></slot>
</template>
<template v-slot:append>
<slot name="appendshow"></slot>
</template>
</el-input>
<!-- 单位 -->
<span class="unit" v-if="unit">{{ unit }}</span>
</div>
</div>
</el-form-item> </el-form-item>
</template> </template>
<script> <script>
export default { export default {
name: 'GuipInput', name: 'GuipInput',
props: ['value', 'styleObject', 'disabled', 'defaultValue', 'placeholder','required', props: {
'maxlength', 'minLength', 'clear', 'width', 'height', 'showWordLimit', value: [String, Number],
'label', 'type', 'prop', 'rules', 'column', 'addClass', 'desc', 'unit'], styleObject: Object,
disabled: Boolean,
defaultValue: [String, Number],
placeholder: String,
required: Boolean,
maxlength: [String, Number],
minLength: [String, Number],
clear: Boolean,
width: String,
height: String,
showWordLimit: Boolean,
label: String,
type: {
type: String,
default: 'text'
},
prop: String,
rules: [Object, Array],
column: Boolean,
addClass: String,
desc: String,
unit: String,
//
clientFormFlex: {
type: Boolean,
default: false
},
//
clientFormLabel: {
type: String,
default: ''
}
},
data() { data() {
return { return {
inputValue: this.value || this.defaultValue, inputValue: this.value || this.defaultValue,
@ -51,35 +111,23 @@ export default {
placeholder1: '' placeholder1: ''
} }
}, },
watch: { // value prop 便 inputValue watch: {
// defaultValue(newVal) {
// console.log(newVal,'newVal');
// this.inputValue = newVal;
// },
value(newVal) { value(newVal) {
this.inputValue = newVal; this.inputValue = newVal;
}, },
defaultValue(newVal) { defaultValue(newVal) {
// valuedefaultValue
if (!this.value && newVal !== this.inputValue) { if (!this.value && newVal !== this.inputValue) {
this.inputValue = newVal; this.inputValue = newVal;
} }
} }
}, },
created() { created() {
//
// if (this.defaultValue != null) {
// this.inputValue = this.defaultValue;
// }
//
if (this.placeholder) { if (this.placeholder) {
this.placeholder1 = this.placeholder; this.placeholder1 = this.placeholder;
} }
//
if (this.maxlength) { if (this.maxlength) {
this.maxlength1 = this.maxlength; this.maxlength1 = this.maxlength;
} }
//
if (this.minLength) { if (this.minLength) {
this.minLength1 = this.minLength; this.minLength1 = this.minLength;
} }
@ -94,46 +142,24 @@ export default {
item.onmouseout = function () { item.onmouseout = function () {
item.classList.remove("hoverclass") item.classList.remove("hoverclass")
} }
// item.addEventListener('mouseover',function(){
// console.log('');
// item.classList.add("hoverclass")
// })
// item.addEventListener('mouseoout',function(){
// console.log('');
// item.classList.remove("hoverclass")
// })
// item.addEventListener('mouseoenter',function(){
// console.log('---');
// item.classList.add("hoverclass")
// })
// item.addEventListener('mouseoleave',function(){
// console.log('');
// item.classList.remove("hoverclass")
// })
}) })
// console.log(el,'====9999');
// if(els&& this.styleObject){
// for(var key in this.styleObject){
// els.style[key] = this.styleObject[key]
// }
// }
}) })
}, },
methods: { methods: {
// input
// changeInput(event){
// this.$emit('input', event);
// }
// handleClear(){
// console.log('---');
// this.$emit('clear', '')
// }
handleKeydown(e) { handleKeydown(e) {
console.log(e); console.log(e);
// if (e.key === '1') { e.preventDefault();
e.preventDefault(); //
// }
}, },
} }
} }
</script> </script>
<style lang="scss" scoped>
.unit {
position: absolute;
right: 12px;
top: 50%;
transform: translateY(-50%);
pointer-events: none;
}
</style>

82
packages/GuipRadio/src/index.vue

@ -1,18 +1,48 @@
<template> <template>
<el-form-item :class="[{ 'column': column }, 'form-item']" :label="label" :prop="prop" :rules="rules" <el-form-item
:required="required"> :class="[
<el-radio-group v-model="selectedValue" v-bind="$attrs" @change="handleChange"> { 'column': column },
<el-radio v-for="(optionValue, optionKey) in normalizedOptions" :key="optionKey" { 'client-form-flex': clientFormFlex },
:label="getValue(optionValue)" :disabled="isDisabled(optionValue[valueKey])"> 'form-item'
{{ getLabel(optionValue) }} ]"
</el-radio> :label="clientFormFlex ? '' : label"
</el-radio-group> :prop="prop"
:rules="rules"
:required="required"
>
<!-- 统一的单选组渲染 -->
<div :class="clientFormFlex ? 'client-form-flex-wrapper' : ''" style="width:100%">
<!-- 特殊样式布局的标签 -->
<div v-if="clientFormFlex" class="flex-label">
<div class="label-text">{{ clientFormLabel || label }}</div>
<span class="colon"></span>
</div>
<!-- 单选组容器 -->
<div :class="clientFormFlex ? 'flex-input' : ''">
<el-radio-group
v-model="selectedValue"
v-bind="$attrs"
@change="handleChange"
class="radio-group-wrapper"
>
<el-radio
v-for="(optionValue, optionKey) in normalizedOptions"
:key="optionKey"
:label="getValue(optionValue)"
:disabled="isDisabled(optionValue[valueKey])"
>
{{ getLabel(optionValue) }}
</el-radio>
</el-radio-group>
</div>
</div>
</el-form-item> </el-form-item>
</template> </template>
<script> <script>
export default { export default {
name: 'GuipRadio', name: 'MyRadioGroup',
props: { props: {
// //
column: { column: {
@ -33,7 +63,6 @@ export default {
// 3.null // 3.null
// 4. // 4.
options: { options: {
// type: [Array, Object],
default: () => null, default: () => null,
validator: (value) => { validator: (value) => {
// null // null
@ -82,13 +111,23 @@ export default {
disabledKeys: { disabledKeys: {
type: Array, type: Array,
default: () => [] default: () => []
},
//
clientFormFlex: {
type: Boolean,
default: false
},
//
clientFormLabel: {
type: String,
default: ''
} }
}, },
computed: { computed: {
// //
normalizedOptions() { normalizedOptions() {
// nullundefined // nullundefined
if (this.options == null || !this.options) { if (this.options == null || !this.options) {
return []; return [];
} }
@ -129,12 +168,10 @@ export default {
}, },
getLabel(option) { getLabel(option) {
if (this.formatter) return this.formatter(option); if (this.formatter) return this.formatter(option);
// //
if (typeof option === 'object' && 'key' in option && 'value' in option) { if (typeof option === 'object' && 'key' in option && 'value' in option) {
return option.value; return option.value;
} }
// //
const isSelected = this.getValue(option) === this.selectedValue; const isSelected = this.getValue(option) === this.selectedValue;
@ -142,7 +179,6 @@ export default {
if (isSelected && option[this.selectedLabelKey]) { if (isSelected && option[this.selectedLabelKey]) {
return option[this.selectedLabelKey]; return option[this.selectedLabelKey];
} }
// labelKey // labelKey
if (typeof option === 'object' && this.labelKey in option) { if (typeof option === 'object' && this.labelKey in option) {
return option[this.labelKey]; return option[this.labelKey];
@ -154,7 +190,6 @@ export default {
if (typeof option === 'object' && 'key' in option && 'value' in option) { if (typeof option === 'object' && 'key' in option && 'value' in option) {
return option.key; return option.key;
} }
// valueKey // valueKey
if (typeof option === 'object' && this.valueKey in option) { if (typeof option === 'object' && this.valueKey in option) {
return option[this.valueKey]; return option[this.valueKey];
@ -169,9 +204,18 @@ export default {
}; };
</script> </script>
<style scoped> <style scoped lang="scss">
/* 自定义样式 */ /* 原有样式 */
.el-radio-group { .radio-group-wrapper {
margin: 10px 0; margin: 10px 0;
display: flex;
justify-content: flex-start;
gap: 20px 24px;
flex-wrap: wrap;
//
.client-form-flex & {
flex: 1;
}
} }
</style> </style>

116
packages/GuipSelect/src/index.vue

@ -1,14 +1,49 @@
<template> <template>
<el-form-item :style="{ ...style, height: height, ...styleObject }" :required="required" <el-form-item
:class="[{ 'column': column }, { 'w510': addClass == 'w510' }, { 'w388': addClass == 'w388' }, 'form-item']" :style="{ ...style, height: height, ...styleObject }"
:label="label" :prop="prop" :rules="rules"> :required="required"
:class="[
{ 'column': column },
{ 'w510': addClass == 'w510' },
{ 'w388': addClass == 'w388' },
{ 'client-form-flex': clientFormFlex },
'form-item'
]"
:label="clientFormFlex ? '' : label"
:prop="prop"
:rules="rules"
>
<p v-if="desc" class="desc_right">{{ desc }}</p> <p v-if="desc" class="desc_right">{{ desc }}</p>
<el-select :style="{ width: width }" :placeholder="placeholder1" @change="handleChange" v-model="selectedValue"
v-bind="$attrs"> <!-- 统一的选择框渲染 -->
<el-option v-for="item in processedOptions" :key="getItemValue(item)" :label="getItemLabel(item)" <div :class="clientFormFlex ? 'client-form-flex-wrapper' : ''" style="width:100%">
:disabled="item.disabled" :value="getItemValue(item)"> <!-- 特殊样式布局的标签 -->
</el-option> <div v-if="clientFormFlex" class="flex-label">
</el-select> <div class="label-text">{{ clientFormLabel || label }}</div>
<span class="colon"></span>
</div>
<!-- 选择框容器 -->
<div :class="clientFormFlex ? 'flex-input' : ''">
<el-select
ref="selectRef"
:style="{ width: width }"
:placeholder="placeholder1"
@change="handleChange"
v-model="selectedValue"
v-bind="$attrs"
>
<el-option
v-for="item in processedOptions"
:key="getItemValue(item)"
:label="getItemLabel(item)"
:disabled="item.disabled"
:value="getItemValue(item)"
>
</el-option>
</el-select>
</div>
</div>
</el-form-item> </el-form-item>
</template> </template>
@ -18,7 +53,7 @@ export default {
props: { props: {
value: [String, Number, Array], value: [String, Number, Array],
options: { options: {
type: [Array,Object], type: [Array, Object],
default: () => [] default: () => []
}, },
// //
@ -30,7 +65,7 @@ export default {
type: String, type: String,
default: 'label' default: 'label'
}, },
// //
extraItem: { extraItem: {
type: Object, type: Object,
default: null default: null
@ -48,7 +83,17 @@ export default {
rules: [Object, Array], rules: [Object, Array],
column: Boolean, column: Boolean,
addClass: String, addClass: String,
desc: String desc: String,
//
clientFormFlex: {
type: Boolean,
default: false
},
//
clientFormLabel: {
type: String,
default: ''
}
}, },
data() { data() {
return { return {
@ -61,9 +106,10 @@ export default {
processedOptions() { processedOptions() {
// options // options
let options = this.options || []; let options = this.options || [];
// [1,12,22]
if (Array.isArray(options) && options.every(item => typeof item !== 'object')) { // [1,12,22]
return options.map((item, index) => ({ if (Array.isArray(options) && options.length > 0 && options.every(item => typeof item !== 'object')) {
options = options.map((item,index) => ({
[this.valueKey]: index, [this.valueKey]: index,
[this.labelKey]: item [this.labelKey]: item
})); }));
@ -76,10 +122,15 @@ export default {
[this.labelKey]: options[key] [this.labelKey]: options[key]
})); }));
} }
// options
if (!Array.isArray(options)) {
options = [];
}
// extraItemoptions // extraItemoptions
if (this.extraItem && Object.keys(this.extraItem).length > 0) { if (this.extraItem && Object.keys(this.extraItem).length > 0) {
return [ options = [
{ {
[this.labelKey]: this.extraItem.label || '', [this.labelKey]: this.extraItem.label || '',
[this.valueKey]: this.extraItem.value || '', [this.valueKey]: this.extraItem.value || '',
@ -88,6 +139,7 @@ export default {
...options ...options
]; ];
} }
return options; return options;
} }
}, },
@ -109,21 +161,15 @@ export default {
if (this.value !== undefined && this.value !== null) { if (this.value !== undefined && this.value !== null) {
this.selectedValue = this.value this.selectedValue = this.value
} }
// //
if (this.placeholder) { if (this.placeholder) {
this.placeholder1 = this.placeholder this.placeholder1 = this.placeholder
} }
this.$nextTick(() => {
let els = document.querySelectorAll('.el-input');
els.forEach(item => {
item.onmouseover = function () {
item.classList.add("hoverclass")
}
item.onmouseout = function () {
item.classList.remove("hoverclass")
}
}) //
this.$nextTick(() => {
this.addHoverEffect();
}) })
}, },
methods: { methods: {
@ -131,13 +177,29 @@ export default {
getItemValue(item) { getItemValue(item) {
return item[this.valueKey] return item[this.valueKey]
}, },
// label // label
getItemLabel(item) { getItemLabel(item) {
return item[this.labelKey] return item[this.labelKey]
}, },
//
handleChange(value) { handleChange(value) {
this.$emit('input', value) this.$emit('input', value)
this.$emit('change', value) this.$emit('change', value)
},
//
addHoverEffect() {
const els = document.querySelectorAll('.el-input');
els.forEach(item => {
item.onmouseover = function () {
item.classList.add("hoverclass")
}
item.onmouseout = function () {
item.classList.remove("hoverclass")
}
})
} }
} }
} }

1
packages/assets/uploadIcon.svg

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="20" height="16" viewBox="0 0 20 16"><defs><clipPath id="master_svg0_166_43602"><rect x="0" y="0" width="20" height="16" rx="0"/></clipPath></defs><g clip-path="url(#master_svg0_166_43602)"><g transform="matrix(1,0,0,-1,0,30.6875)"><g><path d="M4.5,15.34375Q2.59375,15.40625,1.3125,16.65625Q0.0625,17.9375,0,19.84375Q0.03125,21.34375,0.84375,22.46875Q1.65625,23.59375,3,24.09375Q3,24.21875,3,24.34375Q3.0625,26.46875,4.46875,27.87495Q5.875,29.28125,8,29.34375Q9.40625,29.31255,10.5312,28.65625Q11.6562,27.96875,12.3438,26.84375Q13.0625,27.34375,14,27.34375Q15.2812,27.31255,16.125,26.46875Q16.9688,25.62495,17,24.34375Q17,23.78125,16.8125,23.25Q18.1875,22.96875,19.0938,21.875Q19.9688,20.8125,20,19.34375Q19.9688,17.65625,18.8438,16.5Q17.6875,15.375,16,15.34375L4.5,15.34375ZM6.96875,22.125Q6.53125,21.59375,6.96875,21.0625Q7.5,20.625,8.03125,21.0625L9.25,22.28125L9.25,18.09375Q9.3125,17.40625,10,17.34375Q10.6875,17.40625,10.75,18.09375L10.75,22.28125L11.9688,21.0625Q12.5,20.625,13.0312,21.0625Q13.4688,21.59375,13.0312,22.125L10.5312,24.625Q10,25.0625,9.46875,24.625L6.96875,22.125Z" fill="#626573" fill-opacity="1"/></g></g></g></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

1
packages/assets/uploadIcon_light.svg

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="20" height="16" viewBox="0 0 20 16"><defs><clipPath id="master_svg0_401_004793/89_47570"><rect x="0" y="0" width="20" height="16" rx="0"/></clipPath></defs><g clip-path="url(#master_svg0_401_004793/89_47570)"><g transform="matrix(1,0,0,-1,0,30.6875)"><g><path d="M4.5,15.34375Q2.59375,15.40625,1.3125,16.65625Q0.0625,17.9375,0,19.84375Q0.03125,21.34375,0.84375,22.46875Q1.65625,23.59375,3,24.09375Q3,24.21875,3,24.34375Q3.0625,26.46875,4.46875,27.87495Q5.875,29.28125,8,29.34375Q9.40625,29.31255,10.5312,28.65625Q11.6562,27.96875,12.3438,26.84375Q13.0625,27.34375,14,27.34375Q15.2812,27.31255,16.125,26.46875Q16.9688,25.62495,17,24.34375Q17,23.78125,16.8125,23.25Q18.1875,22.96875,19.0938,21.875Q19.9688,20.8125,20,19.34375Q19.9688,17.65625,18.8438,16.5Q17.6875,15.375,16,15.34375L4.5,15.34375ZM6.96875,22.125Q6.53125,21.59375,6.96875,21.0625Q7.5,20.625,8.03125,21.0625L9.25,22.28125L9.25,18.09375Q9.3125,17.40625,10,17.34375Q10.6875,17.40625,10.75,18.09375L10.75,22.28125L11.9688,21.0625Q12.5,20.625,13.0312,21.0625Q13.4688,21.59375,13.0312,22.125L10.5312,24.625Q10,25.0625,9.46875,24.625L6.96875,22.125Z" fill="#006AFF" fill-opacity="1"/></g></g></g></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

801
packages/styles/common.scss

File diff suppressed because it is too large
Loading…
Cancel
Save