Browse Source

组件更新

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

2
examples/src/App.vue

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

13
packages/GroupFormBtns/src/index.vue

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

158
packages/GuipInput/src/index.vue

@ -1,44 +1,104 @@
<template>
<el-form-item :style="{ ...styleObject }" :required="required"
:class="[{ 'column': column }, { 'w510': addClass == 'w510' }, { 'w388': addClass == 'w388' }, 'form-item']" :label="label"
:prop="prop" :rules="rules">
<el-form-item
:style="{ ...styleObject}"
: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>
<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)"
@blur="$emit('blur', inputValue)" @focus="$emit('focus', inputValue)" class="guip-input">
<!-- 自定义前面小图标 -->
<!-- 统一的输入框渲染 -->
<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-input
ref="inputRef"
: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)"
@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>
<!-- :error="errorMessage" show-message -->
<!-- <i slot="suffix" v-if="empty" class="el-icon-close" @click="handleClear">h</i> -->
<!-- <el-button slot="append" v-if="hasBtn" type="primary" @click="$emit('enter',value)">搜索</el-button> -->
</el-input>
<!-- 单位 -->
<span class="guip-input-unit" v-if="unit">{{ unit }}</span>
<span class="unit" v-if="unit">{{ unit }}</span>
</div>
</div>
</el-form-item>
</template>
<script>
export default {
name: 'GuipInput',
props: ['value', 'styleObject', 'disabled', 'defaultValue', 'placeholder','required',
'maxlength', 'minLength', 'clear', 'width', 'height', 'showWordLimit',
'label', 'type', 'prop', 'rules', 'column', 'addClass', 'desc', 'unit'],
props: {
value: [String, Number],
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() {
return {
inputValue: this.value || this.defaultValue,
@ -51,35 +111,23 @@ export default {
placeholder1: ''
}
},
watch: { // value prop 便 inputValue
// defaultValue(newVal) {
// console.log(newVal,'newVal');
// this.inputValue = newVal;
// },
watch: {
value(newVal) {
this.inputValue = newVal;
},
defaultValue(newVal) {
// valuedefaultValue
if (!this.value && newVal !== this.inputValue) {
this.inputValue = newVal;
}
}
},
created() {
//
// if (this.defaultValue != null) {
// this.inputValue = this.defaultValue;
// }
//
if (this.placeholder) {
this.placeholder1 = this.placeholder;
}
//
if (this.maxlength) {
this.maxlength1 = this.maxlength;
}
//
if (this.minLength) {
this.minLength1 = this.minLength;
}
@ -94,46 +142,24 @@ export default {
item.onmouseout = function () {
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: {
// input
// changeInput(event){
// this.$emit('input', event);
// }
// handleClear(){
// console.log('---');
// this.$emit('clear', '')
// }
handleKeydown(e) {
console.log(e);
// if (e.key === '1') {
e.preventDefault(); //
// }
e.preventDefault();
},
}
}
</script>
<style lang="scss" scoped>
.unit {
position: absolute;
right: 12px;
top: 50%;
transform: translateY(-50%);
pointer-events: none;
}
</style>

72
packages/GuipRadio/src/index.vue

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

106
packages/GuipSelect/src/index.vue

@ -1,14 +1,49 @@
<template>
<el-form-item :style="{ ...style, height: height, ...styleObject }" :required="required"
:class="[{ 'column': column }, { 'w510': addClass == 'w510' }, { 'w388': addClass == 'w388' }, 'form-item']"
:label="label" :prop="prop" :rules="rules">
<el-form-item
:style="{ ...style, height: height, ...styleObject }"
: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>
<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)"
:disabled="item.disabled" :value="getItemValue(item)">
<!-- 统一的选择框渲染 -->
<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-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>
</template>
@ -48,7 +83,17 @@ export default {
rules: [Object, Array],
column: Boolean,
addClass: String,
desc: String
desc: String,
//
clientFormFlex: {
type: Boolean,
default: false
},
//
clientFormLabel: {
type: String,
default: ''
}
},
data() {
return {
@ -61,9 +106,10 @@ export default {
processedOptions() {
// options
let options = this.options || [];
// [1,12,22]
if (Array.isArray(options) && options.every(item => typeof item !== 'object')) {
return options.map((item, index) => ({
// [1,12,22]
if (Array.isArray(options) && options.length > 0 && options.every(item => typeof item !== 'object')) {
options = options.map((item,index) => ({
[this.valueKey]: index,
[this.labelKey]: item
}));
@ -77,9 +123,14 @@ export default {
}));
}
// options
if (!Array.isArray(options)) {
options = [];
}
// extraItemoptions
if (this.extraItem && Object.keys(this.extraItem).length > 0) {
return [
options = [
{
[this.labelKey]: this.extraItem.label || '',
[this.valueKey]: this.extraItem.value || '',
@ -88,6 +139,7 @@ export default {
...options
];
}
return options;
}
},
@ -109,21 +161,15 @@ export default {
if (this.value !== undefined && this.value !== null) {
this.selectedValue = this.value
}
//
if (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: {
@ -131,13 +177,29 @@ export default {
getItemValue(item) {
return item[this.valueKey]
},
// label
getItemLabel(item) {
return item[this.labelKey]
},
//
handleChange(value) {
this.$emit('input', 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

579
packages/styles/common.scss

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