Browse Source

增加弹框

master
zq 1 week ago
parent
commit
f347549349
  1. 26
      .npmignore
  2. 30
      examples/src/App.vue
  3. 15
      packages/.eslintrc.js
  4. 7
      packages/GuipDialog/index.js
  5. 131
      packages/GuipDialog/src/index.vue
  6. 14
      packages/GuipRadio/src/index.vue
  7. 19
      packages/GuipSelect/src/index.vue
  8. 9
      packages/index.js

26
.npmignore

@ -1,8 +1,24 @@
# 忽略文件 # 忽略文件
examples/ examples/
build/
node_modules/ node_modules/
*.log *.map
*.md *.html
*.yml
webpack.config.js # 本地开发文件
.gitignore .DS_Store
*.local
# 日志文件
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# 编辑器目录和文件
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

30
examples/src/App.vue

@ -1,6 +1,6 @@
<template> <template>
<div id="app" class="demo-container"> <div id="app" class="demo-container">
<el-form :model="form" :rules="rules" class="el-row demo-ruleForm" ref="formRef"> <el-form :model="form" class="el-row demo-ruleForm" ref="formRef">
<!-- 按钮组件示例 --> <!-- 按钮组件示例 -->
<section class="demo-section"> <section class="demo-section">
@ -129,12 +129,12 @@
<div class="ele-item"> <div class="ele-item">
<label for="">单选框(对象格式)</label> <label for="">单选框(对象格式)</label>
<GuipRadio v-model="form.language" :options="languageOptions" label="选择语言" prop="language" <GuipRadio v-model="form.language" :options="languageOptions" label="选择语言" prop="language"
@change="radioChange" :rules="rules.language" /> @change="radioChange" />
</div> </div>
<div class="ele-item"> <div class="ele-item">
<label for="">单选框2数组格式 + 自定义取值</label> <label for="">单选框2数组格式 + 自定义取值</label>
<GuipRadio v-model="form.language" :options="languageOptions1" label="自定义属性" prop="language" <GuipRadio v-model="form.language" :options="languageOptions1" label="自定义属性" prop="language"
@change="radioChange" :rules="rules.language" label-key="name" :disabledKeys="['1']" value-key="id" /> @change="radioChange" label-key="name" :disabledKeys="['1']" value-key="id" />
</div> </div>
<div class="ele-item"> <div class="ele-item">
<label for="">单选框</label> <label for="">单选框</label>
@ -842,18 +842,18 @@ export default {
// this.handleInput('') // this.handleInput('')
console.log(value, 'value===qinghcu'); console.log(value, 'value===qinghcu');
}, },
getList() { // getList() {
const dataList = rules(); // const dataList = rules();
dataList.forEach((item) => { // dataList.forEach((item) => {
if (item.field === "id") { // if (item.field === "id") {
item.options = this.cities; // item.options = this.cities;
} // }
if (item.field === "id1") { // if (item.field === "id1") {
item.options = this.optionss; // item.options = this.optionss;
} // }
}); // });
this.formList = dataList; // this.formList = dataList;
}, // },
save() { save() {
this.$refs.VabForm.submitForm("ruleForm"); this.$refs.VabForm.submitForm("ruleForm");
}, },

15
packages/.eslintrc.js

@ -1,17 +1,22 @@
// .eslintrc.js
module.exports = { module.exports = {
root: true,
env: { env: {
browser: true, browser: true,
es2021: true node: true,
es6: true
}, },
extends: [ extends: [
'eslint:recommended', 'eslint:recommended',
'plugin:vue/essential' 'plugin:vue/essential'
], ],
parserOptions: { parserOptions: {
ecmaVersion: 12, ecmaVersion: 2018, // 改为 2018(兼容 Vue 2)
sourceType: 'module' sourceType: 'module',
parser: 'babel-eslint'
}, },
rules: { rules: {
'vue/multi-word-component-names': 'off' 'vue/multi-word-component-names': 'off',
} 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
} }
}

7
packages/GuipDialog/index.js

@ -0,0 +1,7 @@
import GuipDialog from './src/index.vue'
GuipDialog.install = function(Vue) {
Vue.component(GuipDialog.name || 'GuipDialog', GuipDialog)
}
export default GuipDialog

131
packages/GuipDialog/src/index.vue

@ -0,0 +1,131 @@
<template>
<el-dialog :visible.sync="dialogShow" :title="title" v-bind="$attrs" append-to-body :width="width"
:show-close="showCloseButton" :before-close="handleClose" :class="type == 'center' ? 'center' : 'normal'">
<!-- 自定义内容 -->
<slot></slot>
<!-- 底部按钮 -->
<span v-if="showFooterButton" slot="footer"
:class="[type == 'center' ? 'dialog-footer-center' : 'dialog-footer-normal', 'flex']"
style="justify-content: space-between;">
<GuipButton v-if="showCancelButton" @click="handleCancel" type="ignore">{{ cancelText }}</GuipButton>
<GuipButton type="primary" @click="handleConfirm">{{ confirmText }}</GuipButton>
</span>
</el-dialog>
</template>
<script>
import GuipButton from '../../GuipButton/src/index.vue';
export default {
name: 'GuipDialog',
props: {
type: {
type: String,
default: 'normal'
},
//
dialogVisible: {
type: Boolean,
default: false,
},
//
title: {
type: String,
default: '提示',
},
//
width: {
type: String,
default: '599px',
},
//
showCloseButton: {
type: Boolean,
default: true,
},
//
showCancelButton: {
type: Boolean,
default: true,
},
//
showFooterButton: {
type: Boolean,
default: true,
},
//
cancelText: {
type: String,
default: '取消',
},
//
confirmText: {
type: String,
default: '确定',
},
},
components: {
GuipButton
},
computed: {
dialogShow: {
get() {
return this.dialogVisible;
},
set(newVal) {
this.$emit('dialogVisibleChange', newVal);
}
}
},
data() {
return {
// visible
internalVisible: this.visible,
// dialogVisible:false,
};
},
watch: {
// // prop internalVisible
// visible(newVal) {
// this.internalVisible = newVal;
// },
// // internalVisible
// internalVisible(newVal) {
// this.$emit('update:visible', newVal);
// },
},
methods: {
//
handleClose(done) {
this.$emit('close');
this.internalVisible = false; //
if (done) {
done();
}
},
//
handleCancel() {
this.$emit('cancel');
this.internalVisible = false; //
},
//
handleConfirm() {
this.$emit('confirm');
this.internalVisible = false; //
},
},
};
</script>
<style scoped lang="scss">
.el-dialog {
/* width: 599px; */
// min-height: 344px;
// .el-dialog__header{
// padding: 32px 32px 12px;
// }
// .el-dialog__body{
// padding: 0 32px 32px;
// }
}
</style>

14
packages/GuipRadio/src/index.vue

@ -12,7 +12,7 @@
<script> <script>
export default { export default {
name: 'GuipRadio', name: 'MyRadioGroup',
props: { props: {
// //
column: { column: {
@ -23,6 +23,10 @@ export default {
type: Boolean, type: Boolean,
default: false default: false
}, },
selectedLabelKey: {
type: String,
default: ''
},
// : // :
// 1. : [{ label: '', value: '', disabled: false }] // 1. : [{ label: '', value: '', disabled: false }]
// 2. : { key1: 'value1', key2: 'value2' } // 2. : { key1: 'value1', key2: 'value2' }
@ -131,7 +135,13 @@ export default {
return option.value; return option.value;
} }
return option[this.labelKey] || option; //
const isSelected = this.getValue(option) === this.selectedValue;
// selectedLabellabelKey
return isSelected && option[this.selectedLabelKey]
? option[this.selectedLabelKey]
: option[this.labelKey] || option;
}, },
getValue(option) { getValue(option) {
// //

19
packages/GuipSelect/src/index.vue

@ -30,6 +30,11 @@ export default {
type: String, type: String,
default: 'label' default: 'label'
}, },
//
extraItem: {
type: Object,
default: null
},
styleObject: Object, styleObject: Object,
disabled: Boolean, disabled: Boolean,
required: Boolean, required: Boolean,
@ -55,7 +60,19 @@ export default {
computed: { computed: {
// options // options
processedOptions() { processedOptions() {
return this.options || [] let options = this.options || [];
// extraItemoptions
if (this.extraItem && Object.keys(this.extraItem).length > 0) {
return [
{
[this.labelKey]: this.extraItem.label || '',
[this.valueKey]: this.extraItem.value || '',
disabled: this.extraItem.disabled || false
},
...options
];
}
return options;
} }
}, },
watch: { watch: {

9
packages/index.js

@ -14,6 +14,7 @@ import GuipRadio from './GuipRadio'
import GuipSelect from './GuipSelect' import GuipSelect from './GuipSelect'
import GuipFormItem from './GuipFormItem' import GuipFormItem from './GuipFormItem'
import CustomDropdown from './CustomDropdown' import CustomDropdown from './CustomDropdown'
import GuipDialog from './GuipDialog'
import 'element-ui/lib/theme-chalk/index.css' // 如果依赖Element import 'element-ui/lib/theme-chalk/index.css' // 如果依赖Element
import './styles/index.css' // 全局引入 import './styles/index.css' // 全局引入
import './styles/common.scss' // 全局引入 import './styles/common.scss' // 全局引入
@ -28,7 +29,8 @@ const components = [
GuipRadio, GuipRadio,
GuipSelect, GuipSelect,
GuipFormItem, GuipFormItem,
CustomDropdown CustomDropdown,
GuipDialog
] ]
const install = function (Vue) { const install = function (Vue) {
@ -36,6 +38,8 @@ const install = function (Vue) {
Vue.prototype.$eventBus = EventBus Vue.prototype.$eventBus = EventBus
Vue.prototype.$on = $on Vue.prototype.$on = $on
Vue.prototype.$emit = $emit Vue.prototype.$emit = $emit
Vue.prototype.$off = $off
Vue.prototype.$once = $once
Vue.directive('clickaway', clickaway) Vue.directive('clickaway', clickaway)
components.forEach(component => { components.forEach(component => {
if (!component.name) { if (!component.name) {
@ -56,5 +60,6 @@ export default {
GuipRadio, GuipRadio,
GuipSelect, GuipSelect,
GuipFormItem, GuipFormItem,
CustomDropdown CustomDropdown,
GuipDialog
} }
Loading…
Cancel
Save