|
|
@@ -1,112 +1,121 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
- <el-form inline ref="ruleFormRef" :model="form">
|
|
|
- <el-form-item style="margin-top: 20px;">
|
|
|
- <el-input v-model="form.name" :placeholder="`请输入` + props.type + `名称`" class="input-with-select">
|
|
|
-
|
|
|
- <template #append>
|
|
|
- <el-button :icon="Search" @click="findDataByName(ruleFormRef)" />
|
|
|
- </template>
|
|
|
- </el-input>
|
|
|
-
|
|
|
- <!-- <el-input style="width: 200px" :placeholder="`请输入` + props.type + `名称`" v-model="form.name" clearable
|
|
|
+ <div>
|
|
|
+ <el-form inline ref="ruleFormRef" :model="form">
|
|
|
+ <el-form-item style="margin-top: 20px">
|
|
|
+ <el-input
|
|
|
+ v-model="form.name"
|
|
|
+ :placeholder="`请输入` + props.type + `名称`"
|
|
|
+ class="input-with-select"
|
|
|
+ >
|
|
|
+ <template #append>
|
|
|
+ <el-button :icon="Search" @click="findDataByName(ruleFormRef)" />
|
|
|
+ </template>
|
|
|
+ </el-input>
|
|
|
+
|
|
|
+ <!-- <el-input style="width: 200px" :placeholder="`请输入` + props.type + `名称`" v-model="form.name" clearable
|
|
|
@clear="clearData" /> -->
|
|
|
- </el-form-item>
|
|
|
- <!-- <el-button type="primary" :icon="Search" @click="findDataByName(ruleFormRef)">查询</el-button> -->
|
|
|
- <el-button type="primary" :icon="Plus" @click="addForm" style="position: absolute;right:0;width: 100px;">
|
|
|
- 模板</el-button>
|
|
|
- </el-form>
|
|
|
- </div>
|
|
|
-
|
|
|
-
|
|
|
- <el-drawer v-model="titleDrawer" direction="rtl" :title="currentType" :before-close="handleClose">
|
|
|
- <DrawerCommonVue :detail="drawerFormData" @submit-drawer="submitDrawer" />
|
|
|
- </el-drawer>
|
|
|
+ </el-form-item>
|
|
|
+ <!-- <el-button type="primary" :icon="Search" @click="findDataByName(ruleFormRef)">查询</el-button> -->
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ :icon="Plus"
|
|
|
+ @click="addForm"
|
|
|
+ style="position: absolute; right: 0; width: 100px"
|
|
|
+ >
|
|
|
+ 模板</el-button
|
|
|
+ >
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-drawer v-model="titleDrawer" direction="rtl" :title="currentType" :before-close="handleClose">
|
|
|
+ <DrawerCommonVue :detail="drawerFormData" @submit-drawer="submitDrawer" />
|
|
|
+ </el-drawer>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { Search, Plus } from '@element-plus/icons-vue';
|
|
|
-import { onMounted, ref, watch } from 'vue';
|
|
|
-import { ElMessageBox, FormInstance } from 'element-plus';
|
|
|
-import DrawerCommonVue, { FormModelCommon } from './DrawerCommon.vue';
|
|
|
-
|
|
|
-export type CreateType = '添加模板' | '修改模板';
|
|
|
-const props = defineProps<{ type: string, pagesize: number, pagenumber: number, drawer: boolean }>();
|
|
|
-const emit = defineEmits(['findDataByName', 'submitDrawer', 'handleClose', 'addForm', 'clearData'])
|
|
|
-const form = ref({
|
|
|
+ import { Search, Plus } from '@element-plus/icons-vue';
|
|
|
+ import { onMounted, ref, watch } from 'vue';
|
|
|
+ import { ElMessageBox, FormInstance } from 'element-plus';
|
|
|
+ import DrawerCommonVue, { FormModelCommon } from './DrawerCommon.vue';
|
|
|
+
|
|
|
+ export type CreateType = '添加模板' | '修改模板';
|
|
|
+ const props = defineProps<{
|
|
|
+ type: string;
|
|
|
+ pagesize: number;
|
|
|
+ pagenumber: number;
|
|
|
+ drawer: boolean;
|
|
|
+ }>();
|
|
|
+ const emit = defineEmits([
|
|
|
+ 'findDataByName',
|
|
|
+ 'submitDrawer',
|
|
|
+ 'handleClose',
|
|
|
+ 'addForm',
|
|
|
+ 'clearData',
|
|
|
+ ]);
|
|
|
+ const form = ref({
|
|
|
name: '',
|
|
|
-});
|
|
|
-const ruleFormRef = ref<FormInstance>();
|
|
|
-const currentType = ref<CreateType>('添加模板');
|
|
|
-const drawerFormData = ref<FormModelCommon>({} as FormModelCommon);
|
|
|
-
|
|
|
-
|
|
|
-export interface DataCommon {
|
|
|
- name: string,
|
|
|
- size: number,
|
|
|
- page: number,
|
|
|
-}
|
|
|
-
|
|
|
-const titleDrawer = ref(false);
|
|
|
-watch(
|
|
|
+ });
|
|
|
+ const ruleFormRef = ref<FormInstance>();
|
|
|
+ const currentType = ref<CreateType>('添加模板');
|
|
|
+ const defaultFormValue = { id: 0, code: '', name: '', remark: '', status: 0 };
|
|
|
+ const drawerFormData = ref<FormModelCommon>({ ...defaultFormValue } as FormModelCommon);
|
|
|
+
|
|
|
+ export interface DataCommon {
|
|
|
+ name: string;
|
|
|
+ size: number;
|
|
|
+ page: number;
|
|
|
+ }
|
|
|
+
|
|
|
+ const titleDrawer = ref(false);
|
|
|
+ watch(
|
|
|
() => props.drawer,
|
|
|
(newdrawer) => {
|
|
|
- titleDrawer.value = newdrawer;
|
|
|
+ titleDrawer.value = newdrawer;
|
|
|
},
|
|
|
{ immediate: true },
|
|
|
-);
|
|
|
-
|
|
|
+ );
|
|
|
|
|
|
-// 根据名称找到数据-finish
|
|
|
-function findDataByName(formEl: FormInstance | undefined) {
|
|
|
- console.log('findDataByName')
|
|
|
+ // 根据名称找到数据-finish
|
|
|
+ function findDataByName(formEl: FormInstance | undefined) {
|
|
|
+ console.log('findDataByName');
|
|
|
if (!formEl) return;
|
|
|
formEl.validate((valid, fields) => {
|
|
|
- if (valid) {
|
|
|
- const data = ref<DataCommon>({
|
|
|
- name: form.value.name,
|
|
|
- size: props.pagesize,
|
|
|
- page: props.pagenumber,
|
|
|
- })
|
|
|
- emit('findDataByName', data.value);
|
|
|
- } else {
|
|
|
- console.log('error submit!', fields);
|
|
|
- }
|
|
|
+ if (valid) {
|
|
|
+ const data = ref<DataCommon>({
|
|
|
+ name: form.value.name,
|
|
|
+ size: props.pagesize,
|
|
|
+ page: props.pagenumber,
|
|
|
+ });
|
|
|
+ emit('findDataByName', data.value);
|
|
|
+ } else {
|
|
|
+ console.log('error submit!', fields);
|
|
|
+ }
|
|
|
});
|
|
|
-}
|
|
|
+ }
|
|
|
|
|
|
-function addForm() {
|
|
|
+ function addForm() {
|
|
|
currentType.value = '添加模板';
|
|
|
- emit('addForm')
|
|
|
-}
|
|
|
+ emit('addForm');
|
|
|
+ }
|
|
|
|
|
|
-// 添加
|
|
|
-function submitDrawer(data) {
|
|
|
+ // 添加
|
|
|
+ function submitDrawer(data) {
|
|
|
emit('submitDrawer', data);
|
|
|
- drawerFormData.value = { id: 0, code: '', name: '', remark: '', status: 0 };
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-const handleClose = (done: () => void) => {
|
|
|
- ElMessageBox.confirm('是否确认关闭?')
|
|
|
- .then(() => {
|
|
|
- done();
|
|
|
- emit('handleClose');
|
|
|
- })
|
|
|
- .catch(() => {
|
|
|
- // catch error
|
|
|
- });
|
|
|
- // emit('handleClose');
|
|
|
-};
|
|
|
-
|
|
|
-// function clearData() {
|
|
|
-// emit('clearData');
|
|
|
-// }
|
|
|
+ setTimeout(() => {
|
|
|
+ drawerFormData.value = { ...defaultFormValue };
|
|
|
+ }, 500);
|
|
|
+ }
|
|
|
|
|
|
+ const handleClose = (done: () => void) => {
|
|
|
+ done();
|
|
|
+ emit('handleClose');
|
|
|
+ };
|
|
|
|
|
|
-onMounted(() => {
|
|
|
+ // function clearData() {
|
|
|
+ // emit('clearData');
|
|
|
+ // }
|
|
|
|
|
|
-});
|
|
|
+ onMounted(() => {});
|
|
|
</script>
|
|
|
|
|
|
-<style scoped></style>
|
|
|
+<style scoped></style>
|