You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.6 KiB
73 lines
1.6 KiB
2 years ago
|
<template>
|
||
|
<div class="modify-form">
|
||
|
<el-form label-position="right" :class="class" :label-width="width ? width + 'px' : ''" :model="param"
|
||
|
ref="modifyForm" :rules="rules">
|
||
|
<slot></slot>
|
||
|
<el-form-item class="form-btns">
|
||
2 years ago
|
<el-button type="primary" @click="formConfirm">确定</el-button>
|
||
2 years ago
|
<el-button type="info" @click="emit('cancel')">取消</el-button>
|
||
|
</el-form-item>
|
||
|
</el-form>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script lang="ts" setup>
|
||
|
import { onMounted, ref, watch } from "vue";
|
||
|
import { FormInstance } from "element-plus";
|
||
|
|
||
|
const prop = defineProps({
|
||
|
width: {
|
||
|
type: Number,
|
||
|
default: 80,
|
||
|
},
|
||
|
param: {
|
||
|
type: Object,
|
||
|
default: {},
|
||
|
},
|
||
|
rules: {
|
||
|
type: Object,
|
||
|
default: {},
|
||
|
},
|
||
|
class: {
|
||
|
type: String,
|
||
|
default: '',
|
||
|
},
|
||
|
});
|
||
|
const emit = defineEmits(["confirm", "cancel"]);
|
||
|
const modifyForm = ref<FormInstance>();
|
||
|
|
||
|
const formConfirm = () => {
|
||
|
if (!modifyForm.value) return;
|
||
|
modifyForm.value?.validate((valid, fields) => {
|
||
|
if (valid) {
|
||
|
emit("confirm");
|
||
2 years ago
|
modifyForm.value?.clearValidate();
|
||
2 years ago
|
}
|
||
|
});
|
||
|
};
|
||
|
|
||
|
const clearValidate = () => {
|
||
|
modifyForm.value?.clearValidate();
|
||
|
}
|
||
|
|
||
|
watch(() => prop.param, () => {
|
||
|
modifyForm.value?.clearValidate();
|
||
|
});
|
||
|
|
||
|
onMounted(() => {
|
||
|
});
|
||
|
</script>
|
||
|
<style lang="scss" scoped>
|
||
|
//@import url(); 引入公共css类
|
||
2 years ago
|
::v-deep .el-select {
|
||
|
width: 100%;
|
||
|
}
|
||
|
|
||
|
::v-deep .el-date-editor {
|
||
|
width: 100% !important;
|
||
|
}
|
||
|
|
||
|
::v-deep .el-autocomplete {
|
||
|
width: 100%;
|
||
2 years ago
|
}
|
||
|
</style>
|