Explorar o código

修改数据字典

汪钰 %!s(int64=3) %!d(string=hai) anos
pai
achega
3ad251860e

+ 2 - 2
ele-admin-template/src/api/system/dictionary-data/index.js

@@ -55,8 +55,8 @@ export async function updateDictionaryData(data) {
  * @param id 字典数据id
  */
 export async function removeDictionaryData(id) {
-  const res = await request.delete('/system/dictionary-data/' + id);
-  if (res.data.code === 0) {
+  const res = await request.post('/system/dict/removeDictInfoById', [id]);
+  if (res.data.code == 0) {
     return res.data.message;
   }
   return Promise.reject(new Error(res.data.message));

+ 11 - 5
ele-admin-template/src/api/system/dictionary/index.js

@@ -32,8 +32,8 @@ export async function addDictionary(data) {
  * @param data 字典信息
  */
 export async function updateDictionary(data) {
-  const res = await request.put('/system/dictionary', data);
-  if (res.data.code === 0) {
+  const res = await request.post('/system/dict/update', data);
+  if (res.data.code == 0) {
     return res.data.message;
   }
   return Promise.reject(new Error(res.data.message));
@@ -43,9 +43,15 @@ export async function updateDictionary(data) {
  * 删除字典
  * @param id 字典id
  */
-export async function removeDictionary(id) {
-  const res = await request.delete('/system/dictionary/' + id);
-  if (res.data.code === 0) {
+export async function removeDictionary(id, f) {
+  let res;
+  if (f) {
+    res = await request.post('/system/dict/removeDictInfoById', id);
+  } else {
+    res = await request.post('/system/dict/removeDictInfoById', [id]);
+  }
+
+  if (res.data.code == 0) {
     return res.data.message;
   }
   return Promise.reject(new Error(res.data.message));

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

@@ -172,7 +172,7 @@
       /* 删除 */
       remove(row) {
         const loading = this.$loading({ lock: true });
-        removeDictionaryData(row.dictDataId)
+        removeDictionary(row.id)
           .then((msg) => {
             loading.close();
             this.$message.success(msg);

+ 51 - 8
ele-admin-template/src/views/system/dictionary/components/dict-edit.vue

@@ -104,7 +104,7 @@
         添加
       </el-button>
 
-      <el-button
+      <!-- <el-button
         size="small"
         type="danger"
         icon="el-icon-delete"
@@ -112,10 +112,10 @@
         @click="removeArr"
       >
         删除
-      </el-button>
+      </el-button> -->
     </div>
     <el-table
-      :data="form.dictStaticSubmitPOList"
+      :data="tableData"
       border
       style="width: 100%"
       @selection-change="handleSelectionChange"
@@ -149,6 +149,21 @@
           </el-radio-group>
         </template>
       </el-table-column>
+      <el-table-column align="center" label="操作">
+        <template slot-scope="scope">
+          <el-popconfirm
+            class="ele-action"
+            title="确定要删除此字典项吗?"
+            @confirm="removeArr(scope)"
+          >
+            <template v-slot:reference>
+              <el-link type="danger" :underline="false" icon="el-icon-delete">
+                删除
+              </el-link>
+            </template>
+          </el-popconfirm>
+        </template>
+      </el-table-column>
     </el-table>
 
     <template v-slot:footer>
@@ -173,7 +188,7 @@
       // 弹窗是否打开
       visible: Boolean,
       // 修改回显的数据
-      id: String
+      id: String | Number
     },
     data() {
       const defaultForm = {
@@ -298,12 +313,12 @@
             showOverflowTooltip: true
           }
         ],
+        tableData: [],
         // 表格选中数据
         selection: [],
         datasource: {
           list: []
         },
-
         // 提交状态
         loading: false,
         // 是否是修改
@@ -311,9 +326,28 @@
       };
     },
     created() {},
+
     methods: {
-      pushArr() {},
-      removeArr() {},
+      pushArr() {
+        this.form.dictStaticSubmitPOList.push({
+          code: '',
+          enable: 1,
+          name: '',
+          sort: ''
+        });
+        this.filterArr();
+      },
+      removeArr(row) {
+        console.log(row);
+        let falg = this.form.dictStaticSubmitPOList[row.$index].deleted === 0;
+        if (falg) {
+          this.form.dictStaticSubmitPOList[row.$index].deleted = 1;
+          this.filterArr();
+        } else {
+          this.form.dictStaticSubmitPOList.splice(row.$index, 1);
+          this.filterArr();
+        }
+      },
       handleSelectionChange() {},
       /* 保存编辑 */
       save() {
@@ -336,6 +370,11 @@
             });
         });
       },
+      filterArr() {
+        this.tableData = this.form.dictStaticSubmitPOList.filter(
+          (item) => item.deleted !== 1
+        );
+      },
       /* 更新visible */
       updateVisible(value) {
         this.$emit('update:visible', value);
@@ -346,7 +385,11 @@
         this.form = res.data.dictInfoVO;
 
         this.form.dictStaticSubmitPOList = res.data.dictStaticVOList;
-        // this.datasource.list = this.from.dictStaticSubmitPOList;
+        if (this.form.dictStaticSubmitPOList.length > 0) {
+          this.filterArr();
+        } else {
+          this.tableTata = [];
+        }
       }
     },
     watch: {

+ 14 - 4
ele-admin-template/src/views/system/dictionary/index.vue

@@ -11,7 +11,7 @@
         >
           添加
         </el-button>
-        <el-button
+        <!-- <el-button
           size="small"
           type="warning"
           icon="el-icon-edit"
@@ -20,7 +20,7 @@
           @click="openEdit(current)"
         >
           修改
-        </el-button>
+        </el-button> -->
         <el-button
           size="small"
           type="danger"
@@ -57,7 +57,7 @@
 
         <template v-slot:content>
           <!-- 数据字典项列表 -->
-          <dict-data v-if="current" :dict-id="current.id" />
+          <dict-data ref="dictData" v-if="current" :dict-id="current.id" />
         </template>
       </ele-split-layout>
     </el-card>
@@ -115,6 +115,7 @@
       /* 刷新表格 */
       reload() {
         this.$refs.table.reload();
+        this.$refs.dictData.reload();
       },
       /* 显示编辑 */
       openEdit(row) {
@@ -127,8 +128,17 @@
           type: 'warning'
         })
           .then(() => {
+            if (this.$refs.dictData.selection.length == 0) {
+              this.$message({
+                message: '当前未选择数据',
+                type: 'error'
+              });
+              return;
+            }
+            let ids = this.$refs.dictData.selection.map((item) => item.id);
             const loading = this.$loading({ lock: true });
-            removeDictionary(this.current.dictId)
+
+            removeDictionary(ids, true)
               .then((msg) => {
                 loading.close();
                 this.$message.success(msg);

+ 1 - 0
ele-admin-template/vue.config.js

@@ -18,6 +18,7 @@ module.exports = {
         // target: 'http://192.168.3.51:18086', // 跨域请求的地址
         // target: 'http://192.168.3.35:8080', // kang杨威
         target: 'http://192.168.3.25:8080', // 黄峥嵘
+
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {
           '^/api': ''