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

File diff suppressed because it is too large Load Diff