Kaynağa Gözat

字典类型列表新增抽屉效果详细信息

RuoYi 2 ay önce
ebeveyn
işleme
5f80bd0371
2 değiştirilmiş dosya ile 225 ekleme ve 6 silme
  1. 202 0
      src/views/system/dict/detail.vue
  2. 23 6
      src/views/system/dict/index.vue

+ 202 - 0
src/views/system/dict/detail.vue

@@ -0,0 +1,202 @@
+<template>
+  <el-drawer :model-value="visible" direction="rtl" size="700px" append-to-body @update:model-value="$emit('update:visible', $event)">
+    <!-- 自定义标题 -->
+    <template #header>
+      <div class="drawer-head">
+        <el-icon style="color:#5b9bd5;margin-right:8px;"><List /></el-icon>
+        <span class="drawer-head-name">{{ row.dictName }}</span>
+        <span class="drawer-head-type">{{ row.dictType }}</span>
+      </div>
+    </template>
+
+    <div class="drawer-wrap">
+      <!-- 加载中 -->
+      <div v-if="loading" class="drawer-loading">
+        <el-icon class="is-loading"><Loading /></el-icon>
+        <span>加载中...</span>
+      </div>
+
+      <!-- 空数据 -->
+      <div v-else-if="!dataList.length" class="drawer-empty">
+        <el-icon style="font-size:36px;"><Document /></el-icon>
+        <div>暂无字典数据</div>
+      </div>
+
+      <template v-else>
+        <!-- 统计卡片 -->
+        <el-row :gutter="12" class="stat-row">
+          <el-col :span="disabledCount > 0 ? 8 : 12">
+            <div class="stat-card">
+              <div class="stat-num">{{ dataList.length }}</div>
+              <div class="stat-label">共计条目</div>
+            </div>
+          </el-col>
+          <el-col :span="disabledCount > 0 ? 8 : 12">
+            <div class="stat-card">
+              <div class="stat-num success">{{ normalCount }}</div>
+              <div class="stat-label">正常</div>
+            </div>
+          </el-col>
+          <el-col v-if="disabledCount > 0" :span="8">
+            <div class="stat-card">
+              <div class="stat-num danger">{{ disabledCount }}</div>
+              <div class="stat-label">停用</div>
+            </div>
+          </el-col>
+        </el-row>
+
+        <!-- 数据列表 -->
+        <div v-for="item in dataList" :key="item.dictCode" class="dict-item">
+          <div class="dict-cell">
+            <div class="dict-cell-key">标签</div>
+            <div class="dict-cell-val">
+              <el-tag v-if="item.listClass && item.listClass !== 'default'" :type="item.listClass === 'primary' ? undefined : item.listClass" size="small">{{ item.dictLabel }}</el-tag>
+              <span v-else>{{ item.dictLabel }}</span>
+            </div>
+          </div>
+          <div class="dict-cell">
+            <div class="dict-cell-key">键值</div>
+            <div class="dict-cell-val">{{ item.dictValue }}</div>
+          </div>
+          <div class="dict-cell">
+            <div class="dict-cell-key">状态</div>
+            <div class="dict-cell-val">
+              <el-tag :type="item.status === '0' ? 'success' : 'danger'" size="small">
+                {{ item.status === '0' ? '正常' : '停用' }}
+              </el-tag>
+            </div>
+          </div>
+        </div>
+      </template>
+    </div>
+  </el-drawer>
+</template>
+
+<script setup>
+import { listData } from '@/api/system/dict/data'
+
+const props = defineProps({
+  visible: { type: Boolean, default: false },
+  row: { type: Object, default: () => ({}) }
+})
+
+const emit = defineEmits(['update:visible'])
+
+const loading = ref(false)
+const dataList = ref([])
+
+const normalCount = computed(() => dataList.value.filter(r => r.status === '0').length)
+const disabledCount = computed(() => dataList.value.filter(r => r.status !== '0').length)
+
+watch(() => props.visible, (val) => {
+  if (val) {
+    loadData()
+  } else {
+    dataList.value = []
+  }
+})
+
+function loadData() {
+  if (!props.row?.dictType) return
+  loading.value = true
+  dataList.value = []
+  listData({ dictType: props.row.dictType, pageSize: 100, pageNum: 1 }).then(response => {
+    dataList.value = response.rows || []
+  }).catch(() => {}).finally(() => {
+    loading.value = false
+  })
+}
+</script>
+
+<style scoped>
+.drawer-head {
+  display: flex;
+  align-items: center;
+}
+.drawer-head-name {
+  font-size: 16px;
+  font-weight: 600;
+  color: #2c3e50;
+  margin-right: 8px;
+}
+.drawer-head-type {
+  font-size: 14px;
+  color: #95a5a6;
+  font-family: monospace;
+}
+.drawer-wrap {
+  padding: 0 20px 20px;
+}
+.drawer-loading {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  height: 120px;
+  color: #aaa;
+  font-size: 13px;
+  gap: 8px;
+}
+.drawer-empty {
+  text-align: center;
+  color: #bbb;
+  padding: 60px 0;
+  font-size: 13px;
+}
+.drawer-empty .el-icon {
+  display: block;
+  margin: 0 auto 8px;
+}
+.stat-row {
+  margin-bottom: 16px;
+}
+.stat-card {
+  background: #f7f9fb;
+  border: 1px solid #e8ecf0;
+  border-radius: 6px;
+  padding: 10px 14px;
+  text-align: center;
+}
+.stat-num {
+  font-size: 22px;
+  font-weight: 700;
+  color: #2c3e50;
+}
+.stat-num.success { color: #27ae60; }
+.stat-num.danger  { color: #e74c3c; }
+.stat-label {
+  font-size: 11px;
+  color: #95a5a6;
+  margin-top: 4px;
+}
+.dict-item {
+  display: grid;
+  grid-template-columns: 1fr 1fr 1fr;
+  border: 1px solid #e8ecf0;
+  border-radius: 6px;
+  overflow: hidden;
+  margin-bottom: 8px;
+}
+.dict-cell {
+  display: grid;
+  grid-template-columns: 70px 1fr;
+  border-right: 1px solid #f0f4f8;
+}
+.dict-cell:last-child {
+  border-right: 0;
+}
+.dict-cell-key {
+  padding: 9px 14px;
+  font-size: 12px;
+  color: #888;
+  background: #f7f9fb;
+  border-right: 1px solid #f0f4f8;
+}
+.dict-cell-val {
+  padding: 9px 14px;
+  font-size: 13px;
+  color: #2c3e50;
+  word-break: break-all;
+  display: flex;
+  align-items: center;
+}
+</style>

+ 23 - 6
src/views/system/dict/index.vue

@@ -106,11 +106,11 @@
          <el-table-column label="字典编号" align="center" prop="dictId" />
          <el-table-column label="字典名称" align="center" prop="dictName" :show-overflow-tooltip="true"/>
          <el-table-column label="字典类型" align="center" :show-overflow-tooltip="true">
-            <template #default="scope">
-               <router-link :to="'/system/dict-data/index/' + scope.row.dictId" class="link-type">
-                  <span>{{ scope.row.dictType }}</span>
-               </router-link>
-            </template>
+         <template #default="scope">
+            <a class="link-type" style="cursor:pointer" @click="handleViewData(scope.row)">
+               {{ scope.row.dictType }}
+            </a>
+         </template>
          </el-table-column>
          <el-table-column label="状态" align="center" prop="status">
             <template #default="scope">
@@ -123,9 +123,10 @@
                <span>{{ parseTime(scope.row.createTime) }}</span>
             </template>
          </el-table-column>
-         <el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width">
+         <el-table-column label="操作" align="center" width="280" class-name="small-padding fixed-width">
             <template #default="scope">
                <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:dict:edit']">修改</el-button>
+               <el-button link type="primary" icon="Fold" @click="handleDataList(scope.row)" v-hasPermi="['system:dict:edit']">列表</el-button>
                <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:dict:remove']">删除</el-button>
             </template>
          </el-table-column>
@@ -176,10 +177,13 @@
             </div>
          </template>
       </el-dialog>
+
+      <dict-data-drawer v-model:visible="drawerVisible" :row="drawerRow" />
    </div>
 </template>
 
 <script setup name="Dict">
+import DictDataDrawer from './detail'
 import useDictStore from '@/store/modules/dict'
 import { listType, getType, delType, addType, updateType, refreshCache } from "@/api/system/dict/type"
 
@@ -196,6 +200,8 @@ const multiple = ref(true)
 const total = ref(0)
 const title = ref("")
 const dateRange = ref([])
+const drawerVisible = ref(false)
+const drawerRow = ref({})
 
 const data = reactive({
   form: {},
@@ -269,6 +275,17 @@ function handleSelectionChange(selection) {
   multiple.value = !selection.length
 }
 
+/** 字典数据抽屉 */
+function handleViewData(row) {
+  drawerRow.value = row
+  drawerVisible.value = true
+}
+
+/** 字典数据列表页面 */
+function handleDataList(row) {
+  proxy.$tab.openPage("字典数据", '/system/dict-data/index/' + row.dictId)
+}
+
 /** 修改按钮操作 */
 function handleUpdate(row) {
   reset()