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.
95 lines
2.7 KiB
95 lines
2.7 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">
|
||
2 years ago
|
<el-form-item v-for="item in items" :label="item.name || t(item.i18n)" :prop="item.code">
|
||
|
<NoobSelect v-if="item.dict" v-model="param[item.code]" :dict="item.dict" full
|
||
|
:placeholder="t('rule.pleaseSelect') + (item.name || t(item.i18n))" :disabled="item.disabled" />
|
||
|
<NoobDate v-else-if="item.date" v-model="param[item.code]" :formater="item.formater" full
|
||
|
:placeholder="t('rule.pleaseSelect') + (item.name || t(item.i18n))" :disabled="item.disabled" />
|
||
|
<slot v-else-if="item.slot" :name="item.code" />
|
||
|
<NoobInput v-else v-model="param[item.code]" full :type="item.type"
|
||
|
:placeholder="t('rule.pleaseEnter') + (item.name || t(item.i18n))" :disabled="item.disabled" />
|
||
|
</el-form-item>
|
||
2 years ago
|
<slot></slot>
|
||
|
<el-form-item class="form-btns">
|
||
2 years ago
|
<NoobButton type="primary" @click="formConfirm">{{ t('base.confirm') }}</NoobButton>
|
||
|
<NoobButton type="info" @click="emit('cancel')">{{ t('base.cancel') }}</NoobButton>
|
||
2 years ago
|
</el-form-item>
|
||
|
</el-form>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script lang="ts" setup>
|
||
|
import { onMounted, ref, watch } from "vue";
|
||
|
import { FormInstance } from "element-plus";
|
||
2 years ago
|
import { useI18n } from 'vue3-i18n';
|
||
|
import { NoobSelect, NoobInput, NoobDate, NoobButton } from "noob-mengyxu";
|
||
|
const { t } = useI18n();
|
||
2 years ago
|
|
||
|
const prop = defineProps({
|
||
|
width: {
|
||
|
type: Number,
|
||
|
default: 80,
|
||
|
},
|
||
|
param: {
|
||
|
type: Object,
|
||
|
default: {},
|
||
|
},
|
||
|
rules: {
|
||
|
type: Object,
|
||
|
default: {},
|
||
|
},
|
||
|
class: {
|
||
|
type: String,
|
||
|
default: '',
|
||
|
},
|
||
2 years ago
|
type: {
|
||
|
type: String,
|
||
|
default: null,
|
||
|
},
|
||
|
items: {
|
||
|
type: Array<any>(),
|
||
|
default: [],
|
||
|
},
|
||
2 years ago
|
});
|
||
|
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();
|
||
|
});
|
||
|
|
||
2 years ago
|
defineExpose({ clearValidate })
|
||
|
|
||
2 years ago
|
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>
|