This commit is contained in:
ln1778 2024-09-19 09:58:45 +08:00
parent 58b2d52adf
commit df94b0aa59
3 changed files with 1112 additions and 848 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "ag-element-ui", "name": "ag-element-ui",
"version": "0.1.20", "version": "0.1.21",
"main": "packages/index.js", "main": "packages/index.js",
"scripts": { "scripts": {
"dev": "vue-cli-service serve", "dev": "vue-cli-service serve",

View File

@ -1,46 +1,171 @@
<template> <template>
<el-form v-bind="$attrs" v-on="$listeners" :model="formValue" ref="formref"> <el-form v-bind="$attrs" v-on="$listeners" :model="formValue" ref="formref">
<ag-row> <ag-row>
<ag-col v-for="item,index in data" :key="index" :span="item.span||24"> <ag-col v-for="(item, index) in data" :key="index" :span="item.span || 24">
<el-form-item v-bind="item" :prop="item.enName" > <el-form-item v-bind="item" :prop="item.enName">
<slot :name="item.soltName" v-if="item.soltName" :row="item"/> <slot :name="item.soltName" v-if="item.soltName" :row="item" />
<div class="contentbox" v-else> <div class="contentbox" v-else>
<ag-input v-model="formValue[item.enName]" type="textarea" v-bind="item" v-if="item.type=='ag-textarea'" size="small" clearable></ag-input> <ag-input
<ag-input v-model="formValue[item.enName]" v-bind="item" v-if="item.type=='ag-input'" size="small" clearable></ag-input> v-model="formValue[item.enName]"
<ag-date-picker v-bind="item" v-model="formValue[item.enName]" v-if="item.type=='ag-date-picker'" size="small" clearable/> type="textarea"
<ag-select v-model="formValue[item.enName]" v-bind="item" v-if="item.type=='ag-select'" size="small" clearable/> v-bind="item"
<el-radio-group v-model="formValue[item.enName]" v-bind="item" v-if="item.type=='ag-radio'&&formValue[item.enName]" size="small" clearable> v-if="item.type == 'ag-textarea'"
<el-radio :label="it.value" v-for="it,index in item.options" :key="index">{{it.label}}</el-radio> size="small"
clearable
></ag-input>
<ag-input
v-model="formValue[item.enName]"
v-bind="item"
v-if="item.type == 'ag-input'"
size="small"
clearable
></ag-input>
<ag-date-picker
v-bind="item"
v-model="formValue[item.enName]"
v-if="item.type == 'ag-date-picker'"
size="small"
clearable
/>
<ag-select
v-model="formValue[item.enName]"
v-bind="item"
v-if="item.type == 'ag-select'"
size="small"
clearable
/>
<el-radio-group
v-model="formValue[item.enName]"
v-bind="item"
v-if="item.type == 'ag-radio' && formValue[item.enName]"
size="small"
clearable
>
<el-radio
:label="it.value"
v-for="(it, index) in item.options"
:key="index"
>{{ it.label }}</el-radio
>
</el-radio-group> </el-radio-group>
<el-checkbox-group v-bind="item" v-if="item.type=='ag-checkbox'&&formValue[item.enName]" v-model="formValue[item.enName]" size="small" clearable> <el-checkbox-group
<el-checkbox v-for="it,index in item.options" :label="it.value" :key="index">{{it.label}}</el-checkbox> v-bind="item"
v-if="item.type == 'ag-checkbox' && formValue[item.enName]"
v-model="formValue[item.enName]"
size="small"
clearable
>
<el-checkbox
v-for="(it, index) in item.options"
:label="it.value"
:key="index"
>{{ it.label }}</el-checkbox
>
</el-checkbox-group> </el-checkbox-group>
<el-input-number v-model="formValue[item.enName]" v-bind="item" v-if="item.type=='ag-input-number'" clearable></el-input-number> <el-input-number
<el-cascader v-model="formValue[item.enName]" v-bind="item" size="small" v-if="item.type=='ag-cascader'" clearable :style="{width:'100%'}"></el-cascader> v-model="formValue[item.enName]"
v-bind="item"
v-if="item.type == 'ag-input-number'"
clearable
></el-input-number>
<el-cascader
v-model="formValue[item.enName]"
v-bind="item"
size="small"
v-if="item.type == 'ag-cascader'"
clearable
:style="{ width: '100%' }"
></el-cascader>
<el-switch <el-switch
v-model="formValue[item.enName]" v-model="formValue[item.enName]"
v-bind="item" size="small" v-if="item.type=='ag-switch'&&formValue[item.enName]" > v-bind="item"
size="small"
v-if="item.type == 'ag-switch' && formValue[item.enName]"
>
</el-switch> </el-switch>
<el-slider v-model="formValue[item.enName]" <el-slider
v-bind="item" size="small" v-if="item.type=='ag-slider'"></el-slider> v-model="formValue[item.enName]"
v-bind="item"
size="small"
v-if="item.type == 'ag-slider'"
></el-slider>
<el-time-select <el-time-select
:style="{width:'100%'}" :style="{ width: '100%' }"
clearable clearable
v-model="formValue[item.enName]" v-model="formValue[item.enName]"
v-bind="item" size="small" v-bind="item"
v-if="item.type=='ag-time-select'" size="small"
:picker-options="item.options"> v-if="item.type == 'ag-time-select'"
:picker-options="item.options"
>
</el-time-select> </el-time-select>
<ag-upload v-bind="item" v-model="formValue[item.enName]" v-if="item.type=='ag-upload'" clear isPre></ag-upload> <ag-upload
<el-rate v-bind="item" v-model="formValue[item.enName]" v-if="item.type=='ag-rate'" size="small"></el-rate> v-bind="item"
<agColorPicker v-bind="item" v-model="formValue[item.enName]" v-if="item.type=='ag-color-picker'" size="small"> v-model="formValue[item.enName]"
v-if="item.type == 'ag-upload'"
@onError="$listeners.onError"
clear
isPre
></ag-upload>
<el-rate
v-bind="item"
v-model="formValue[item.enName]"
v-if="item.type == 'ag-rate'"
size="small"
></el-rate>
<agColorPicker
v-bind="item"
v-model="formValue[item.enName]"
v-if="item.type == 'ag-color-picker'"
size="small"
>
</agColorPicker> </agColorPicker>
<el-transfer :data="item.data" v-bind="item" v-model="formValue[item.enName]" v-if="item.type=='ag-transfer'" size="small"></el-transfer> <el-transfer
<agNumberRange v-bind="item" v-model="formValue[item.enName]" v-if="item.type=='ag-numberRange'" size="small" clearable/> :data="item.data"
<ag-multion-input v-bind="item" v-model="formValue[item.enName]" v-if="item.type=='ag-multion-input'" size="small" clearable/> v-bind="item"
<agQuery v-bind="item" v-model="formValue[item.enName]" v-if="item.type=='ag-query'" size="small" clearable/> v-model="formValue[item.enName]"
<ag-mution-checkbox :datas="item.datas" v-bind="item" :placeholder="item.placeholder" v-model="formValue[item.enName]" v-if="item.type=='ag-mution-checkbox'" size="small"> </ag-mution-checkbox> v-if="item.type == 'ag-transfer'"
<ag-multion-date-picker v-bind="item" v-model="formValue[item.enName]" v-if="item.type=='ag-multion-datte-picker'" size="small"/> size="small"
></el-transfer>
<agNumberRange
v-bind="item"
v-model="formValue[item.enName]"
v-if="item.type == 'ag-numberRange'"
size="small"
clearable
/>
<ag-multion-input
v-bind="item"
v-model="formValue[item.enName]"
v-if="item.type == 'ag-multion-input'"
size="small"
clearable
/>
<agQuery
v-bind="item"
v-model="formValue[item.enName]"
v-if="item.type == 'ag-query'"
size="small"
clearable
/>
<ag-mution-checkbox
:datas="item.datas"
v-bind="item"
:placeholder="item.placeholder"
v-model="formValue[item.enName]"
v-if="item.type == 'ag-mution-checkbox'"
size="small"
>
</ag-mution-checkbox>
<ag-multion-date-picker
v-bind="item"
v-model="formValue[item.enName]"
v-if="item.type == 'ag-multion-datte-picker'"
size="small"
/>
</div>
<div v-if="item.tip" class="tipbox">
<slot name="tip" :row="item"> {{ item.tip }}</slot>
</div> </div>
</el-form-item> </el-form-item>
</ag-col> </ag-col>
@ -48,144 +173,150 @@
<div class="footerbox" v-if="$listeners.onSubmit"> <div class="footerbox" v-if="$listeners.onSubmit">
<slot name="button" :value="formValue"> <slot name="button" :value="formValue">
<el-button @click="onSubmit" type="primary" size="small" class="submitbtn"> <el-button @click="onSubmit" type="primary" size="small" class="submitbtn">
{{submittitle||'提交'}} {{ submittitle || "提交" }}
</el-button> </el-button>
</slot> </slot>
</div> </div>
</el-form> </el-form>
</template> </template>
<script> <script>
import agInput from "./../../agInput/src/index.vue";
import agDatePicker from "./../../agDatePicker/src/index.vue";
import agSelect from "./../../agSelect/src/index.vue";
import agRow from "./../../agRow/src/index.vue";
import agCol from "./../../agCol/src/index.vue";
import agUpload from "./../../agUpload/src/index.vue";
import agColorPicker from "./../../agColorPicker/src/index.vue";
import agNumberRange from "./../../agNumberRange/src/index.vue";
import agMultionInput from "./../../agMultionInput/src/index.vue";
import agQuery from "./../../agQuery/src/index.vue";
import agMultionDatePicker from "../../agMultionDatePicker";
export default {
import agInput from './../../agInput/src/index.vue'; name: "agForm",
import agDatePicker from './../../agDatePicker/src/index.vue'; components: {
import agSelect from './../../agSelect/src/index.vue';
import agRow from './../../agRow/src/index.vue';
import agCol from './../../agCol/src/index.vue';
import agUpload from './../../agUpload/src/index.vue';
import agColorPicker from './../../agColorPicker/src/index.vue';
import agNumberRange from './../../agNumberRange/src/index.vue';
import agMultionInput from './../../agMultionInput/src/index.vue';
import agQuery from './../../agQuery/src/index.vue';
import agMultionDatePicker from '../../agMultionDatePicker';
export default{
name:"agForm",
components:{
agMultionDatePicker, agMultionDatePicker,
agInput:agInput, agInput: agInput,
agDatePicker, agDatePicker,
agSelect, agSelect,
agRow, agRow,
agCol, agCol,
agUpload:agUpload, agUpload: agUpload,
agColorPicker, agColorPicker,
agNumberRange, agNumberRange,
agMultionInput, agMultionInput,
agQuery agQuery,
}, },
props:{ props: {
submittitle:{ submittitle: {
type:String, type: String,
default:'提交' default: "提交",
}, },
data:{ data: {
type:Array, type: Array,
default(){ default() {
return [] return [];
}
},
span:{
type:Number,
default:24
}, },
}, },
data(){ span: {
return{ type: Number,
formValue:{ default: 24,
}
}
}, },
mounted(){ },
this.formValue=this.$attrs.value; data() {
setTimeout(()=>{ return {
formValue: {},
};
},
mounted() {
this.formValue = this.$attrs.value;
setTimeout(() => {
this.$refs.formref.clearValidate(); this.$refs.formref.clearValidate();
},1); }, 1);
if(this.$refs.formref){ if (this.$refs.formref) {
for(const key in this.$refs.formref){ for (const key in this.$refs.formref) {
if(!this[key]&&key!='value'){ if (!this[key] && key != "value") {
this[key]=this.$refs.formref[key]; this[key] = this.$refs.formref[key];
} }
} }
} }
}, },
watch:{ watch: {
value(val){ value(val) {
this.formValue = val; this.formValue = val;
setTimeout(()=>{ setTimeout(() => {
this.$refs.formref.clearValidate(); this.$refs.formref.clearValidate();
},1); }, 1);
}
}, },
methods:{
onSubmit(){
this.$emit('onSubmit',this.formValue)
}
}, },
} methods: {
</script> onSubmit() {
this.$emit("onSubmit", this.formValue);
},
},
};
</script>
<style lang="scss" scoped> <style lang="scss" scoped>
.footerbox{ .footerbox {
margin-top:12px; margin-top: 12px;
display:flex; display: flex;
justify-content:center; justify-content: center;
.submitbtn{ .submitbtn {
width:200px; width: 200px;
} }
} }
.el-form--inline{ .el-form--inline {
.el-form-item{ .el-form-item {
display:flex; display: flex;
} }
.el-form-item__content{ .el-form-item__content {
flex:1; flex: 1;
width:100%; width: 100%;
} }
} }
.contentbox{ .contentbox {
width:100%; width: 100%;
display: flex; display: flex;
align-items: stretch; align-items: stretch;
} }
.flexcenter{ .flexcenter {
display: flex; display: flex;
align-items: stretch; align-items: stretch;
} }
::v-deep{ .tipbox {
.el-form--inline{ width: 100%;
.el-form-item{ color: red;
display:flex;
} }
.el-form-item__content{ ::v-deep {
display:flex; .el-form--inline {
flex:1; .el-form-item {
width:100%; display: flex;
margin-left:0; }
.el-form-item__content {
display: flex;
flex: 1;
width: 100%;
flex-wrap: wrap;
margin-left: 0;
} }
} }
.el-form-item{ .el-form-item {
width:100%; width: 100%;
margin-bottom: 12px; margin-bottom: 12px;
} }
.el-form-item__content{ .el-form-item__content {
flex:1; flex: 1;
display:flex; display: flex;
width:100%; flex-wrap: wrap;
margin-left:0!important; width: 100%;
margin-left: 0 !important;
}
.el-radio-button__inner,
.el-radio-group {
display: flex;
align-items: center;
} }
} }
</style> </style>

File diff suppressed because it is too large Load Diff