Browse Source

修复新增字典类型后不能正确刷新字典数据的问题
修复界面右键刷新后再新增导致刷新事件多次触发的问题

zhontai 2 years ago
parent
commit
e35b7381c1

+ 3 - 2
src/views/admin/api/index.vue

@@ -50,7 +50,7 @@
 </template>
 </template>
 
 
 <script lang="ts" setup name="admin/api">
 <script lang="ts" setup name="admin/api">
-import { ref, reactive, onMounted, getCurrentInstance, onUnmounted, defineAsyncComponent } from 'vue'
+import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent } from 'vue'
 import { ApiListOutput } from '/@/api/admin/data-contracts'
 import { ApiListOutput } from '/@/api/admin/data-contracts'
 import { ApiApi } from '/@/api/admin/Api'
 import { ApiApi } from '/@/api/admin/Api'
 import { ApiApi as ApiExtApi } from '/@/api/admin.extend/Api'
 import { ApiApi as ApiExtApi } from '/@/api/admin.extend/Api'
@@ -82,12 +82,13 @@ onMounted(async () => {
   state.expandRowKeys = treeToList(cloneDeep(state.apiTreeData))
   state.expandRowKeys = treeToList(cloneDeep(state.apiTreeData))
     .filter((a: ApiListOutput) => a.parentId === 0)
     .filter((a: ApiListOutput) => a.parentId === 0)
     .map((a: ApiListOutput) => a.id + '') as string[]
     .map((a: ApiListOutput) => a.id + '') as string[]
+  eventBus.off('refreshApi')
   eventBus.on('refreshApi', async () => {
   eventBus.on('refreshApi', async () => {
     onQuery()
     onQuery()
   })
   })
 })
 })
 
 
-onUnmounted(() => {
+onBeforeMount(() => {
   eventBus.off('refreshApi')
   eventBus.off('refreshApi')
 })
 })
 
 

+ 20 - 9
src/views/admin/dictionary/components/dictionary-form.vue

@@ -9,12 +9,12 @@
             </el-form-item>
             </el-form-item>
           </el-col>
           </el-col>
           <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
           <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-            <el-form-item label="编码" prop="code" :rules="[{ required: true, message: '请输入编码', trigger: ['blur', 'change'] }]">
+            <el-form-item label="编码">
               <el-input v-model="form.code" autocomplete="off" />
               <el-input v-model="form.code" autocomplete="off" />
             </el-form-item>
             </el-form-item>
           </el-col>
           </el-col>
           <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
           <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-            <el-form-item label="字典值" prop="value" :rules="[{ required: true, message: '请输入字典值', trigger: ['blur', 'change'] }]">
+            <el-form-item label="字典值">
               <el-input v-model="form.value" autocomplete="off" />
               <el-input v-model="form.value" autocomplete="off" />
             </el-form-item>
             </el-form-item>
           </el-col>
           </el-col>
@@ -31,20 +31,26 @@
         </el-row>
         </el-row>
       </el-form>
       </el-form>
       <template #footer>
       <template #footer>
-        <span class="dialog-footer">
-          <el-button @click="onCancel" size="default">取 消</el-button>
-          <el-button type="primary" @click="onSure" size="default" :loading="state.sureLoading">确 定</el-button>
+        <span class="dialog-footer my-flex my-flex-y-center my-flex-between">
+          <div>
+            <el-checkbox v-if="!(state.form?.id > 0)" v-model="state.contiAdd">连续新增</el-checkbox>
+          </div>
+          <div>
+            <el-button @click="onCancel" size="default">取 消</el-button>
+            <el-button type="primary" @click="onSure" size="default" :loading="state.sureLoading">确 定</el-button>
+          </div>
         </span>
         </span>
       </template>
       </template>
     </el-dialog>
     </el-dialog>
   </div>
   </div>
 </template>
 </template>
 
 
-<script lang="ts" setup name="admin/dictionary/form">
+<script lang="ts" setup name="admin/dict/form">
 import { reactive, toRefs, getCurrentInstance, ref } from 'vue'
 import { reactive, toRefs, getCurrentInstance, ref } from 'vue'
 import { DictionaryAddInput, DictionaryUpdateInput } from '/@/api/admin/data-contracts'
 import { DictionaryAddInput, DictionaryUpdateInput } from '/@/api/admin/data-contracts'
 import { DictionaryApi } from '/@/api/admin/Dictionary'
 import { DictionaryApi } from '/@/api/admin/Dictionary'
 import eventBus from '/@/utils/mitt'
 import eventBus from '/@/utils/mitt'
+import { FormInstance } from 'element-plus'
 
 
 defineProps({
 defineProps({
   title: {
   title: {
@@ -55,17 +61,19 @@ defineProps({
 
 
 const { proxy } = getCurrentInstance() as any
 const { proxy } = getCurrentInstance() as any
 
 
-const formRef = ref()
+const formRef = ref<FormInstance>()
 const state = reactive({
 const state = reactive({
   showDialog: false,
   showDialog: false,
   sureLoading: false,
   sureLoading: false,
   form: {} as DictionaryAddInput & DictionaryUpdateInput,
   form: {} as DictionaryAddInput & DictionaryUpdateInput,
+  contiAdd: true,
 })
 })
 const { form } = toRefs(state)
 const { form } = toRefs(state)
 
 
 // 打开对话框
 // 打开对话框
 const open = async (row: any = {}) => {
 const open = async (row: any = {}) => {
   if (row.id > 0) {
   if (row.id > 0) {
+    state.contiAdd = false
     const res = await new DictionaryApi().get({ id: row.id }, { loading: true }).catch(() => {
     const res = await new DictionaryApi().get({ id: row.id }, { loading: true }).catch(() => {
       proxy.$modal.closeLoading()
       proxy.$modal.closeLoading()
     })
     })
@@ -86,7 +94,7 @@ const onCancel = () => {
 
 
 // 确定
 // 确定
 const onSure = () => {
 const onSure = () => {
-  formRef.value.validate(async (valid: boolean) => {
+  formRef.value!.validate(async (valid: boolean) => {
     if (!valid) return
     if (!valid) return
 
 
     state.sureLoading = true
     state.sureLoading = true
@@ -103,8 +111,11 @@ const onSure = () => {
     state.sureLoading = false
     state.sureLoading = false
 
 
     if (res?.success) {
     if (res?.success) {
+      if (state.contiAdd) {
+        formRef.value!.resetFields()
+      }
       eventBus.emit('refreshDict')
       eventBus.emit('refreshDict')
-      state.showDialog = false
+      state.showDialog = state.contiAdd
     }
     }
   })
   })
 }
 }

+ 1 - 1
src/views/admin/dictionary/components/dictionary-type-form.vue

@@ -35,7 +35,7 @@
   </div>
   </div>
 </template>
 </template>
 
 
-<script lang="ts" setup name="admin/dictionaryType/typeForm">
+<script lang="ts" setup name="admin/dictType/form">
 import { reactive, toRefs, getCurrentInstance, ref } from 'vue'
 import { reactive, toRefs, getCurrentInstance, ref } from 'vue'
 import { DictionaryTypeAddInput, DictionaryTypeUpdateInput } from '/@/api/admin/data-contracts'
 import { DictionaryTypeAddInput, DictionaryTypeUpdateInput } from '/@/api/admin/data-contracts'
 import { DictionaryTypeApi } from '/@/api/admin/DictionaryType'
 import { DictionaryTypeApi } from '/@/api/admin/DictionaryType'

+ 69 - 56
src/views/admin/dictionary/dictionary-type.vue

@@ -1,61 +1,67 @@
 <template>
 <template>
-  <el-card class="mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
-    <el-form :model="state.filterModel" :inline="true" @submit.stop.prevent>
-      <el-form-item prop="name">
-        <el-input v-model="state.filterModel.name" placeholder="名称或编码" @keyup.enter="onQuery" />
-      </el-form-item>
-      <el-form-item>
-        <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
-        <el-button v-auth="'api:admin:dictionary:add'" type="primary" icon="ele-Plus" @click="onAdd"> 新增 </el-button>
-      </el-form-item>
-    </el-form>
-  </el-card>
-
-  <el-card class="my-fill mt8" shadow="never">
-    <el-table
-      ref="tableRef"
-      v-loading="state.loading"
-      :data="state.dictionaryTypeListData"
-      row-key="id"
-      highlight-current-row
-      style="width: 100%"
-      @current-change="onTableCurrentChange"
-    >
-      <el-table-column prop="name" label="名称" min-width="120" show-overflow-tooltip />
-      <el-table-column prop="code" label="编码" min-width="120" show-overflow-tooltip />
-      <el-table-column label="状态" width="80" align="center" show-overflow-tooltip>
-        <template #default="{ row }">
-          <el-tag type="success" v-if="row.enabled">启用</el-tag>
-          <el-tag type="danger" v-else>禁用</el-tag>
-        </template>
-      </el-table-column>
-      <el-table-column label="操作" width="140" fixed="right" header-align="center" align="center">
-        <template #default="{ row }">
-          <el-button v-auth="'api:admin:dictionary:update'" icon="ele-EditPen" size="small" text type="primary" @click="onEdit(row)">编辑</el-button>
-          <el-button v-auth="'api:admin:dictionary:delete'" icon="ele-Delete" size="small" text type="danger" @click="onDelete(row)">删除</el-button>
-        </template>
-      </el-table-column>
-    </el-table>
-    <div class="my-flex my-flex-end" style="margin-top: 20px">
-      <el-pagination
-        v-model:currentPage="state.pageInput.currentPage"
-        v-model:page-size="state.pageInput.pageSize"
-        :total="state.total"
-        :page-sizes="[10, 20, 50, 100]"
-        small
-        background
-        @size-change="onSizeChange"
-        @current-change="onCurrentChange"
-        layout="total, sizes, prev, pager, next, jumper"
-      />
-    </div>
-  </el-card>
-
-  <dictionary-type-form ref="dictionaryTypeFormRef" :title="state.dictionaryTypeFormTitle"></dictionary-type-form>
+  <div class="my-flex-column w100 h100">
+    <el-card class="mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
+      <el-form :model="state.filterModel" :inline="true" @submit.stop.prevent>
+        <el-form-item prop="name">
+          <el-input v-model="state.filterModel.name" placeholder="名称或编码" @keyup.enter="onQuery" />
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
+          <el-button v-auth="'api:admin:dictionary:add'" type="primary" icon="ele-Plus" @click="onAdd"> 新增 </el-button>
+        </el-form-item>
+      </el-form>
+    </el-card>
+
+    <el-card class="my-fill mt8" shadow="never">
+      <el-table
+        ref="tableRef"
+        v-loading="state.loading"
+        :data="state.dictionaryTypeListData"
+        row-key="id"
+        highlight-current-row
+        style="width: 100%"
+        @current-change="onTableCurrentChange"
+      >
+        <el-table-column prop="name" label="名称" min-width="120" show-overflow-tooltip />
+        <el-table-column prop="code" label="编码" min-width="120" show-overflow-tooltip />
+        <el-table-column label="状态" width="80" align="center" show-overflow-tooltip>
+          <template #default="{ row }">
+            <el-tag type="success" v-if="row.enabled">启用</el-tag>
+            <el-tag type="danger" v-else>禁用</el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column label="操作" width="140" fixed="right" header-align="center" align="center">
+          <template #default="{ row }">
+            <el-button v-auth="'api:admin:dictionary:update'" icon="ele-EditPen" size="small" text type="primary" @click="onEdit(row)"
+              >编辑</el-button
+            >
+            <el-button v-auth="'api:admin:dictionary:delete'" icon="ele-Delete" size="small" text type="danger" @click="onDelete(row)"
+              >删除</el-button
+            >
+          </template>
+        </el-table-column>
+      </el-table>
+      <div class="my-flex my-flex-end" style="margin-top: 20px">
+        <el-pagination
+          v-model:currentPage="state.pageInput.currentPage"
+          v-model:page-size="state.pageInput.pageSize"
+          :total="state.total"
+          :page-sizes="[10, 20, 50, 100]"
+          small
+          background
+          @size-change="onSizeChange"
+          @current-change="onCurrentChange"
+          layout="total, sizes, prev, pager, next, jumper"
+        />
+      </div>
+    </el-card>
+
+    <dictionary-type-form ref="dictionaryTypeFormRef" :title="state.dictionaryTypeFormTitle"></dictionary-type-form>
+  </div>
 </template>
 </template>
 
 
 <script lang="ts" setup name="'admin/dictType'">
 <script lang="ts" setup name="'admin/dictType'">
-import { ref, reactive, onMounted, getCurrentInstance, onUnmounted, nextTick, defineAsyncComponent } from 'vue'
+import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, nextTick, defineAsyncComponent } from 'vue'
 import { DictionaryTypeListOutput, PageInputDictionaryTypeGetPageDto } from '/@/api/admin/data-contracts'
 import { DictionaryTypeListOutput, PageInputDictionaryTypeGetPageDto } from '/@/api/admin/data-contracts'
 import { DictionaryTypeApi } from '/@/api/admin/DictionaryType'
 import { DictionaryTypeApi } from '/@/api/admin/DictionaryType'
 import eventBus from '/@/utils/mitt'
 import eventBus from '/@/utils/mitt'
@@ -68,6 +74,8 @@ const { proxy } = getCurrentInstance() as any
 const tableRef = ref()
 const tableRef = ref()
 const dictionaryTypeFormRef = ref()
 const dictionaryTypeFormRef = ref()
 
 
+const emits = defineEmits(['change'])
+
 const state = reactive({
 const state = reactive({
   loading: false,
   loading: false,
   dictionaryTypeFormTitle: '',
   dictionaryTypeFormTitle: '',
@@ -80,16 +88,18 @@ const state = reactive({
     pageSize: 20,
     pageSize: 20,
   } as PageInputDictionaryTypeGetPageDto,
   } as PageInputDictionaryTypeGetPageDto,
   dictionaryTypeListData: [] as Array<DictionaryTypeListOutput>,
   dictionaryTypeListData: [] as Array<DictionaryTypeListOutput>,
+  lastCurrentRow: {} as DictionaryTypeListOutput,
 })
 })
 
 
 onMounted(() => {
 onMounted(() => {
   onQuery()
   onQuery()
+  eventBus.off('refreshDictType')
   eventBus.on('refreshDictType', () => {
   eventBus.on('refreshDictType', () => {
     onQuery()
     onQuery()
   })
   })
 })
 })
 
 
-onUnmounted(() => {
+onBeforeMount(() => {
   eventBus.off('refreshDictType')
   eventBus.off('refreshDictType')
 })
 })
 
 
@@ -140,7 +150,10 @@ const onCurrentChange = (val: number) => {
 }
 }
 
 
 const onTableCurrentChange = (currentRow: DictionaryTypeListOutput) => {
 const onTableCurrentChange = (currentRow: DictionaryTypeListOutput) => {
-  eventBus.emit('refreshDict', currentRow)
+  if (state.lastCurrentRow?.id != currentRow?.id) {
+    state.lastCurrentRow = currentRow
+    emits('change', currentRow)
+  }
 }
 }
 </script>
 </script>
 
 

+ 73 - 54
src/views/admin/dictionary/dictionary.vue

@@ -1,54 +1,60 @@
 <template>
 <template>
-  <el-card class="mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
-    <el-form :model="state.filterModel" :inline="true" @submit.stop.prevent>
-      <el-form-item prop="name">
-        <el-input v-model="state.filterModel.name" placeholder="名称或编码" @keyup.enter="onQuery" />
-      </el-form-item>
-      <el-form-item>
-        <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
-        <el-button v-auth="'api:admin:dictionary:add'" type="primary" icon="ele-Plus" @click="onAdd"> 新增 </el-button>
-      </el-form-item>
-    </el-form>
-  </el-card>
-
-  <el-card class="my-fill mt8" shadow="never">
-    <el-table v-loading="state.loading" :data="state.dictionaryListData" row-key="id" style="width: 100%">
-      <el-table-column prop="name" label="名称" min-width="120" show-overflow-tooltip />
-      <el-table-column prop="code" label="编码" min-width="120" show-overflow-tooltip />
-      <el-table-column prop="value" label="值" min-width="120" show-overflow-tooltip />
-      <el-table-column label="状态" width="70" align="center" show-overflow-tooltip>
-        <template #default="{ row }">
-          <el-tag type="success" v-if="row.enabled">启用</el-tag>
-          <el-tag type="danger" v-else>禁用</el-tag>
-        </template>
-      </el-table-column>
-      <el-table-column label="操作" width="140" fixed="right" header-align="center" align="center">
-        <template #default="{ row }">
-          <el-button v-auth="'api:admin:dictionary:update'" icon="ele-EditPen" size="small" text type="primary" @click="onEdit(row)">编辑</el-button>
-          <el-button v-auth="'api:admin:dictionary:delete'" icon="ele-Delete" size="small" text type="danger" @click="onDelete(row)">删除</el-button>
-        </template>
-      </el-table-column>
-    </el-table>
-    <div class="my-flex my-flex-end" style="margin-top: 20px">
-      <el-pagination
-        v-model:currentPage="state.pageInput.currentPage"
-        v-model:page-size="state.pageInput.pageSize"
-        :total="state.total"
-        :page-sizes="[10, 20, 50, 100]"
-        small
-        background
-        @size-change="onSizeChange"
-        @current-change="onCurrentChange"
-        layout="total, sizes, prev, pager, next, jumper"
-      />
-    </div>
-  </el-card>
-
-  <dictionary-form ref="dictionaryFormRef" :title="state.dictionaryFormTitle"></dictionary-form>
+  <div class="my-flex-column w100 h100">
+    <el-card class="mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
+      <el-form :model="state.filterModel" :inline="true" @submit.stop.prevent>
+        <el-form-item prop="name">
+          <el-input v-model="state.filterModel.name" placeholder="名称或编码" @keyup.enter="onQuery" />
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
+          <el-button v-auth="'api:admin:dictionary:add'" type="primary" icon="ele-Plus" @click="onAdd"> 新增 </el-button>
+        </el-form-item>
+      </el-form>
+    </el-card>
+
+    <el-card class="my-fill mt8" shadow="never">
+      <el-table v-loading="state.loading" :data="state.dictionaryListData" row-key="id" style="width: 100%">
+        <el-table-column prop="name" label="名称" min-width="120" show-overflow-tooltip />
+        <el-table-column prop="code" label="编码" min-width="120" show-overflow-tooltip />
+        <el-table-column prop="value" label="值" min-width="120" show-overflow-tooltip />
+        <el-table-column label="状态" width="70" align="center" show-overflow-tooltip>
+          <template #default="{ row }">
+            <el-tag type="success" v-if="row.enabled">启用</el-tag>
+            <el-tag type="danger" v-else>禁用</el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column label="操作" width="140" fixed="right" header-align="center" align="center">
+          <template #default="{ row }">
+            <el-button v-auth="'api:admin:dictionary:update'" icon="ele-EditPen" size="small" text type="primary" @click="onEdit(row)"
+              >编辑</el-button
+            >
+            <el-button v-auth="'api:admin:dictionary:delete'" icon="ele-Delete" size="small" text type="danger" @click="onDelete(row)"
+              >删除</el-button
+            >
+          </template>
+        </el-table-column>
+      </el-table>
+      <div class="my-flex my-flex-end" style="margin-top: 20px">
+        <el-pagination
+          v-model:currentPage="state.pageInput.currentPage"
+          v-model:page-size="state.pageInput.pageSize"
+          :total="state.total"
+          :page-sizes="[10, 20, 50, 100]"
+          small
+          background
+          @size-change="onSizeChange"
+          @current-change="onCurrentChange"
+          layout="total, sizes, prev, pager, next, jumper"
+        />
+      </div>
+    </el-card>
+
+    <dictionary-form ref="dictionaryFormRef" :title="state.dictionaryFormTitle"></dictionary-form>
+  </div>
 </template>
 </template>
 
 
-<script lang="ts" setup name="admin/dictType">
-import { ref, reactive, onMounted, getCurrentInstance, onUnmounted, defineAsyncComponent } from 'vue'
+<script lang="ts" setup name="admin/dictData">
+import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent } from 'vue'
 import { DictionaryListOutput, PageInputDictionaryGetPageDto, DictionaryTypeListOutput } from '/@/api/admin/data-contracts'
 import { DictionaryListOutput, PageInputDictionaryGetPageDto, DictionaryTypeListOutput } from '/@/api/admin/data-contracts'
 import { DictionaryApi } from '/@/api/admin/Dictionary'
 import { DictionaryApi } from '/@/api/admin/Dictionary'
 import eventBus from '/@/utils/mitt'
 import eventBus from '/@/utils/mitt'
@@ -77,16 +83,13 @@ const state = reactive({
 })
 })
 
 
 onMounted(() => {
 onMounted(() => {
-  eventBus.on('refreshDict', (data: DictionaryTypeListOutput) => {
-    if ((data?.id as number) > 0) {
-      state.filterModel.dictionaryTypeId = data.id as number
-      state.dictionaryTypeName = data.name as string
-    }
+  eventBus.off('refreshDict')
+  eventBus.on('refreshDict', () => {
     onQuery()
     onQuery()
   })
   })
 })
 })
 
 
-onUnmounted(() => {
+onBeforeMount(() => {
   eventBus.off('refreshDict')
   eventBus.off('refreshDict')
 })
 })
 
 
@@ -102,6 +105,10 @@ const onQuery = async () => {
 }
 }
 
 
 const onAdd = () => {
 const onAdd = () => {
+  if (!(state.filterModel.dictionaryTypeId > 0)) {
+    proxy.$modal.msgWarning('请选择字典类型')
+    return
+  }
   state.dictionaryFormTitle = `新增【${state.dictionaryTypeName}】字典`
   state.dictionaryFormTitle = `新增【${state.dictionaryTypeName}】字典`
   dictionaryFormRef.value.open({ dictionaryTypeId: state.filterModel.dictionaryTypeId })
   dictionaryFormRef.value.open({ dictionaryTypeId: state.filterModel.dictionaryTypeId })
 }
 }
@@ -130,6 +137,18 @@ const onCurrentChange = (val: number) => {
   state.pageInput.currentPage = val
   state.pageInput.currentPage = val
   onQuery()
   onQuery()
 }
 }
+
+const refresh = (data: DictionaryTypeListOutput) => {
+  if ((data?.id as number) > 0) {
+    state.filterModel.dictionaryTypeId = data.id as number
+    state.dictionaryTypeName = data.name as string
+    onQuery()
+  }
+}
+
+defineExpose({
+  refresh,
+})
 </script>
 </script>
 
 
 <style scoped lang="scss"></style>
 <style scoped lang="scss"></style>

+ 10 - 7
src/views/admin/dictionary/index.vue

@@ -1,26 +1,29 @@
 <template>
 <template>
   <my-layout>
   <my-layout>
     <pane size="50" min-size="30" max-size="70">
     <pane size="50" min-size="30" max-size="70">
-      <div class="my-flex-column w100 h100">
-        <dictionary-type></dictionary-type>
-      </div>
+      <dictionary-type @change="onChange"></dictionary-type>
     </pane>
     </pane>
     <pane>
     <pane>
-      <div class="my-flex-column w100 h100">
-        <dictionary></dictionary>
-      </div>
+      <dictionary ref="dictionaryRef"></dictionary>
     </pane>
     </pane>
   </my-layout>
   </my-layout>
 </template>
 </template>
 
 
 <script lang="ts" setup name="admin/dict">
 <script lang="ts" setup name="admin/dict">
-import { defineAsyncComponent } from 'vue'
+import { defineAsyncComponent, ref } from 'vue'
 import { Pane } from 'splitpanes'
 import { Pane } from 'splitpanes'
+import { DictionaryTypeListOutput } from '/@/api/admin/data-contracts'
 
 
 // 引入组件
 // 引入组件
 const DictionaryType = defineAsyncComponent(() => import('./dictionary-type.vue'))
 const DictionaryType = defineAsyncComponent(() => import('./dictionary-type.vue'))
 const Dictionary = defineAsyncComponent(() => import('./dictionary.vue'))
 const Dictionary = defineAsyncComponent(() => import('./dictionary.vue'))
 const MyLayout = defineAsyncComponent(() => import('/@/components/my-layout/index.vue'))
 const MyLayout = defineAsyncComponent(() => import('/@/components/my-layout/index.vue'))
+
+const dictionaryRef = ref()
+
+const onChange = (data: DictionaryTypeListOutput) => {
+  dictionaryRef.value?.refresh(data)
+}
 </script>
 </script>
 
 
 <style scoped lang="scss"></style>
 <style scoped lang="scss"></style>

+ 3 - 2
src/views/admin/file/index.vue

@@ -93,7 +93,7 @@
 </template>
 </template>
 
 
 <script lang="ts" setup name="admin/file">
 <script lang="ts" setup name="admin/file">
-import { ref, reactive, onMounted, onUnmounted, defineAsyncComponent, computed, getCurrentInstance } from 'vue'
+import { ref, reactive, onMounted, onBeforeMount, defineAsyncComponent, computed, getCurrentInstance } from 'vue'
 import { PageInputFileGetPageDto, FileGetPageOutput } from '/@/api/admin/data-contracts'
 import { PageInputFileGetPageDto, FileGetPageOutput } from '/@/api/admin/data-contracts'
 import { FileApi } from '/@/api/admin/File'
 import { FileApi } from '/@/api/admin/File'
 import dayjs from 'dayjs'
 import dayjs from 'dayjs'
@@ -136,12 +136,13 @@ const previewImglist = computed(() => {
 
 
 onMounted(() => {
 onMounted(() => {
   onQuery()
   onQuery()
+  eventBus.off('refreshFile')
   eventBus.on('refreshFile', async () => {
   eventBus.on('refreshFile', async () => {
     onQuery()
     onQuery()
   })
   })
 })
 })
 
 
-onUnmounted(() => {
+onBeforeMount(() => {
   eventBus.off('refreshFile')
   eventBus.off('refreshFile')
 })
 })
 
 

+ 1 - 1
src/views/admin/login/index.vue

@@ -84,8 +84,8 @@ onMounted(() => {
 }
 }
 .login-container {
 .login-container {
   height: 100%;
   height: 100%;
-  background: var(--el-color-white);
   min-height: 500px;
   min-height: 500px;
+  background: var(--el-color-white);
   .login-left {
   .login-left {
     flex: 1;
     flex: 1;
     position: relative;
     position: relative;

+ 3 - 2
src/views/admin/org/index.vue

@@ -61,7 +61,7 @@
 </template>
 </template>
 
 
 <script lang="ts" setup name="admin/org">
 <script lang="ts" setup name="admin/org">
-import { ref, reactive, onMounted, getCurrentInstance, onUnmounted, defineAsyncComponent } from 'vue'
+import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent } from 'vue'
 import { OrgListOutput } from '/@/api/admin/data-contracts'
 import { OrgListOutput } from '/@/api/admin/data-contracts'
 import { OrgApi } from '/@/api/admin/Org'
 import { OrgApi } from '/@/api/admin/Org'
 import { listToTree, filterTree } from '/@/utils/tree'
 import { listToTree, filterTree } from '/@/utils/tree'
@@ -86,12 +86,13 @@ const state = reactive({
 
 
 onMounted(() => {
 onMounted(() => {
   onQuery()
   onQuery()
+  eventBus.off('refreshOrg')
   eventBus.on('refreshOrg', () => {
   eventBus.on('refreshOrg', () => {
     onQuery()
     onQuery()
   })
   })
 })
 })
 
 
-onUnmounted(() => {
+onBeforeMount(() => {
   eventBus.off('refreshOrg')
   eventBus.off('refreshOrg')
 })
 })
 
 

+ 3 - 2
src/views/admin/permission/index.vue

@@ -108,7 +108,7 @@
 </template>
 </template>
 
 
 <script lang="ts" setup name="admin/permission">
 <script lang="ts" setup name="admin/permission">
-import { ref, reactive, onMounted, getCurrentInstance, onUnmounted, defineAsyncComponent } from 'vue'
+import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent } from 'vue'
 import { PermissionListOutput } from '/@/api/admin/data-contracts'
 import { PermissionListOutput } from '/@/api/admin/data-contracts'
 import { PermissionApi } from '/@/api/admin/Permission'
 import { PermissionApi } from '/@/api/admin/Permission'
 import { listToTree, treeToList, filterTree } from '/@/utils/tree'
 import { listToTree, treeToList, filterTree } from '/@/utils/tree'
@@ -144,12 +144,13 @@ onMounted(async () => {
   state.expandRowKeys = treeToList(cloneDeep(state.permissionTreeData))
   state.expandRowKeys = treeToList(cloneDeep(state.permissionTreeData))
     .filter((a: PermissionListOutput) => a.opened === true)
     .filter((a: PermissionListOutput) => a.opened === true)
     .map((a: PermissionListOutput) => a.id + '') as string[]
     .map((a: PermissionListOutput) => a.id + '') as string[]
+  eventBus.off('refreshPermission')
   eventBus.on('refreshPermission', async () => {
   eventBus.on('refreshPermission', async () => {
     onQuery()
     onQuery()
   })
   })
 })
 })
 
 
-onUnmounted(() => {
+onBeforeMount(() => {
   eventBus.off('refreshPermission')
   eventBus.off('refreshPermission')
 })
 })
 
 

+ 3 - 2
src/views/admin/role/index.vue

@@ -112,7 +112,7 @@
 </template>
 </template>
 
 
 <script lang="ts" setup name="admin/role">
 <script lang="ts" setup name="admin/role">
-import { ref, reactive, onMounted, getCurrentInstance, onUnmounted, nextTick, defineAsyncComponent } from 'vue'
+import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, nextTick, defineAsyncComponent } from 'vue'
 import { RoleGetListOutput, UserGetRoleUserListOutput, UserGetPageOutput, RoleAddRoleUserListInput, RoleType } from '/@/api/admin/data-contracts'
 import { RoleGetListOutput, UserGetRoleUserListOutput, UserGetPageOutput, RoleAddRoleUserListInput, RoleType } from '/@/api/admin/data-contracts'
 import { RoleApi } from '/@/api/admin/Role'
 import { RoleApi } from '/@/api/admin/Role'
 import { listToTree, filterTree } from '/@/utils/tree'
 import { listToTree, filterTree } from '/@/utils/tree'
@@ -156,12 +156,13 @@ const state = reactive({
 
 
 onMounted(() => {
 onMounted(() => {
   onQuery()
   onQuery()
+  eventBus.off('refreshRole')
   eventBus.on('refreshRole', async () => {
   eventBus.on('refreshRole', async () => {
     onQuery()
     onQuery()
   })
   })
 })
 })
 
 
-onUnmounted(() => {
+onBeforeMount(() => {
   eventBus.off('refreshRole')
   eventBus.off('refreshRole')
 })
 })
 
 

+ 3 - 2
src/views/admin/tenant/index.vue

@@ -74,7 +74,7 @@
 </template>
 </template>
 
 
 <script lang="ts" setup name="admin/tenant">
 <script lang="ts" setup name="admin/tenant">
-import { ref, reactive, onMounted, getCurrentInstance, onUnmounted, defineAsyncComponent } from 'vue'
+import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent } from 'vue'
 import { TenantListOutput, PageInputTenantGetPageDto } from '/@/api/admin/data-contracts'
 import { TenantListOutput, PageInputTenantGetPageDto } from '/@/api/admin/data-contracts'
 import { TenantApi } from '/@/api/admin/Tenant'
 import { TenantApi } from '/@/api/admin/Tenant'
 import eventBus from '/@/utils/mitt'
 import eventBus from '/@/utils/mitt'
@@ -106,12 +106,13 @@ const state = reactive({
 
 
 onMounted(() => {
 onMounted(() => {
   onQuery()
   onQuery()
+  eventBus.off('refreshTenant')
   eventBus.on('refreshTenant', async () => {
   eventBus.on('refreshTenant', async () => {
     onQuery()
     onQuery()
   })
   })
 })
 })
 
 
-onUnmounted(() => {
+onBeforeMount(() => {
   eventBus.off('refreshTenant')
   eventBus.off('refreshTenant')
 })
 })
 
 

+ 3 - 2
src/views/admin/user/components/user-form.vue

@@ -115,6 +115,7 @@ import { listToTree, treeToList } from '/@/utils/tree'
 import { cloneDeep } from 'lodash-es'
 import { cloneDeep } from 'lodash-es'
 import { isMobile, testMobile, testEmail } from '/@/utils/test'
 import { isMobile, testMobile, testEmail } from '/@/utils/test'
 import eventBus from '/@/utils/mitt'
 import eventBus from '/@/utils/mitt'
+import { FormInstance } from 'element-plus'
 
 
 // 引入组件
 // 引入组件
 const MySelectUser = defineAsyncComponent(() => import('./my-select-user.vue'))
 const MySelectUser = defineAsyncComponent(() => import('./my-select-user.vue'))
@@ -129,7 +130,7 @@ defineProps({
 const { proxy } = getCurrentInstance() as any
 const { proxy } = getCurrentInstance() as any
 
 
 const orgTreeSelectRef = ref()
 const orgTreeSelectRef = ref()
-const formRef = ref()
+const formRef = ref<FormInstance>()
 const state = reactive({
 const state = reactive({
   showDialog: false,
   showDialog: false,
   sureLoading: false,
   sureLoading: false,
@@ -248,7 +249,7 @@ const onCancel = () => {
 
 
 // 确定
 // 确定
 const onSure = () => {
 const onSure = () => {
-  formRef.value.validate(async (valid: boolean) => {
+  formRef.value!.validate(async (valid: boolean) => {
     if (!valid) return
     if (!valid) return
 
 
     state.sureLoading = true
     state.sureLoading = true

+ 3 - 2
src/views/admin/user/index.vue

@@ -96,7 +96,7 @@
 </template>
 </template>
 
 
 <script lang="ts" setup name="admin/user">
 <script lang="ts" setup name="admin/user">
-import { ref, reactive, onMounted, getCurrentInstance, onUnmounted, defineAsyncComponent } from 'vue'
+import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent } from 'vue'
 import { UserGetPageOutput, PageInputUserGetPageDto, OrgListOutput, UserSetManagerInput, UserResetPasswordInput } from '/@/api/admin/data-contracts'
 import { UserGetPageOutput, PageInputUserGetPageDto, OrgListOutput, UserSetManagerInput, UserResetPasswordInput } from '/@/api/admin/data-contracts'
 import { UserApi } from '/@/api/admin/User'
 import { UserApi } from '/@/api/admin/User'
 import eventBus from '/@/utils/mitt'
 import eventBus from '/@/utils/mitt'
@@ -157,12 +157,13 @@ const state = reactive({
 })
 })
 
 
 onMounted(() => {
 onMounted(() => {
+  eventBus.off('refreshUser')
   eventBus.on('refreshUser', async () => {
   eventBus.on('refreshUser', async () => {
     onQuery()
     onQuery()
   })
   })
 })
 })
 
 
-onUnmounted(() => {
+onBeforeMount(() => {
   eventBus.off('refreshUser')
   eventBus.off('refreshUser')
 })
 })
 
 

+ 3 - 2
src/views/admin/view/index.vue

@@ -46,7 +46,7 @@
 </template>
 </template>
 
 
 <script lang="ts" setup name="admin/view">
 <script lang="ts" setup name="admin/view">
-import { ref, reactive, onMounted, getCurrentInstance, onUnmounted, defineAsyncComponent } from 'vue'
+import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent } from 'vue'
 import { ViewListOutput } from '/@/api/admin/data-contracts'
 import { ViewListOutput } from '/@/api/admin/data-contracts'
 import { ViewApi } from '/@/api/admin/View'
 import { ViewApi } from '/@/api/admin/View'
 import { listToTree, filterTree } from '/@/utils/tree'
 import { listToTree, filterTree } from '/@/utils/tree'
@@ -71,12 +71,13 @@ const state = reactive({
 
 
 onMounted(() => {
 onMounted(() => {
   onQuery()
   onQuery()
+  eventBus.off('refreshView')
   eventBus.on('refreshView', async () => {
   eventBus.on('refreshView', async () => {
     onQuery()
     onQuery()
   })
   })
 })
 })
 
 
-onUnmounted(() => {
+onBeforeMount(() => {
   eventBus.off('refreshView')
   eventBus.off('refreshView')
 })
 })