Kaynağa Gözat

字典管理

汪钰 3 yıl önce
ebeveyn
işleme
c50f4d39b4

+ 0 - 1
ele-admin-template/src/api/system/dictionary/index.js

@@ -7,7 +7,6 @@ import request from '@/utils/request';
 export async function listDictionaries() {
   const res = await request.get('/system/dict/getPage', {});
   if (res.data.code == 0) {
-    console.log(res.data);
     return {
       list: res.data.data.records,
       count: res.data.data.total

+ 2 - 2
ele-admin-template/src/views/system/dictionary/components/dict-data.vue

@@ -125,8 +125,8 @@
             showOverflowTooltip: true
           },
           {
-            prop: 'createTime',
-            label: '创建时间',
+            prop: 'updateTime',
+            label: '上次更新时间',
 
             showOverflowTooltip: true,
             minWidth: 110,

+ 104 - 9
ele-admin-template/src/views/system/dictionary/components/dict-edit.vue

@@ -8,7 +8,20 @@
     :title="isUpdate ? '修改字典' : '添加字典'"
     @update:visible="updateVisible"
   >
-    <el-form ref="form" :model="form" :rules="rules" label-width="85px">
+    <div class="divider">
+      <div class="title">
+        <div class="ele-bg-primary"></div>
+        <span>基本信息</span>
+      </div>
+      <div class="ele-bg-primary" style="width: 100%; height: 2px"></div>
+    </div>
+    <el-form
+      ref="form"
+      :model="form"
+      :rules="rules"
+      label-width="85px"
+      style="margin-bottom: 10px"
+    >
       <el-row>
         <el-col :span="12">
           <el-form-item label="字典名称:" prop="name">
@@ -73,6 +86,70 @@
         </el-col>
       </el-row>
     </el-form>
+    <div class="divider">
+      <div class="title">
+        <div class="ele-bg-primary"></div>
+        <span>字典项配置</span>
+      </div>
+      <div class="ele-bg-primary" style="width: 100%; height: 2px"></div>
+    </div>
+    <div style="margin: 5px 0">
+      <el-button
+        size="small"
+        type="primary"
+        icon="el-icon-plus"
+        class="ele-btn-icon"
+        @click="pushArr"
+      >
+        添加
+      </el-button>
+
+      <el-button
+        size="small"
+        type="danger"
+        icon="el-icon-delete"
+        class="ele-btn-icon"
+        @click="removeArr"
+      >
+        删除
+      </el-button>
+    </div>
+    <el-table
+      :data="form.dictStaticSubmitPOList"
+      border
+      style="width: 100%"
+      @selection-change="handleSelectionChange"
+    >
+      <el-table-column type="selection" align="center"> </el-table-column>
+      <el-table-column prop="code" label="字典项编码">
+        <template slot-scope="scope">
+          <el-input v-model="scope.row.code" placeholder=""></el-input>
+        </template>
+      </el-table-column>
+      <el-table-column prop="name" label="字典项名称">
+        <template slot-scope="scope">
+          <el-input v-model="scope.row.name" placeholder=""></el-input>
+        </template>
+      </el-table-column>
+      <el-table-column prop="sort" label="排序">
+        <template slot-scope="scope">
+          <el-input
+            v-model="scope.row.sort"
+            @input="
+              scope.row.sort = String(scope.row.sort).replace(/[^\d]/g, '')
+            "
+          ></el-input>
+        </template>
+      </el-table-column>
+      <el-table-column prop="enable" label="启用">
+        <template slot-scope="scope">
+          <el-radio-group v-model="scope.row.enable">
+            <el-radio :label="1">是</el-radio>
+            <el-radio :label="0">否</el-radio>
+          </el-radio-group>
+        </template>
+      </el-table-column>
+    </el-table>
 
     <template v-slot:footer>
       <el-button @click="updateVisible(false)">取消</el-button>
@@ -92,7 +169,6 @@
   } from '@/api/system/dictionary-data';
 
   export default {
-    created() {},
     props: {
       // 弹窗是否打开
       visible: Boolean,
@@ -234,12 +310,11 @@
         isUpdate: false
       };
     },
-    created() {
-      if (this.id) {
-        this.getDetail();
-      }
-    },
+    created() {},
     methods: {
+      pushArr() {},
+      removeArr() {},
+      handleSelectionChange() {},
       /* 保存编辑 */
       save() {
         this.$refs.form.validate((valid) => {
@@ -277,9 +352,10 @@
     watch: {
       visible(visible) {
         if (visible) {
-          if (this.data) {
-            this.$util.assignObject(this.form, this.data);
+          if (this.id) {
+            // this.$util.assignObject(this.form, this.data);
             this.isUpdate = true;
+            this.getDetail();
           } else {
             this.isUpdate = false;
           }
@@ -291,3 +367,22 @@
     }
   };
 </script>
+<style lang="scss" scoped>
+  .divider {
+    margin-bottom: 20px;
+
+    .title {
+      display: flex;
+      align-items: center;
+      margin-bottom: 10px;
+      div {
+        width: 8px;
+        height: 20px;
+        margin-right: 10px;
+      }
+      span {
+        font-size: 20px;
+      }
+    }
+  }
+</style>

+ 2 - 2
ele-admin-template/vue.config.js

@@ -15,9 +15,9 @@ module.exports = {
     proxy: {
       // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
       '/api': {
-        target: 'http://192.168.3.51:18086', // 跨域请求的地址
+        // target: 'http://192.168.3.51:18086', // 跨域请求的地址
         // target: 'http://192.168.3.35:8080', // kang杨威
-        //target: 'http://192.168.3.25:8080', // 黄峥嵘
+        target: 'http://192.168.3.25:8080', // 黄峥嵘
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {
           '^/api': ''