From 9ea0041fabffb1610dbec0d71ae7f79db1206598 Mon Sep 17 00:00:00 2001
From: Sxile <3440626@qq.com>
Date: 星期五, 19 六月 2020 16:01:48 +0800
Subject: [PATCH] 常量接口修改为常量类
---
ruoyi-ui/src/views/system/dict/data.vue | 115 +++++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 95 insertions(+), 20 deletions(-)
diff --git a/ruoyi-ui/src/views/system/dict/data.vue b/ruoyi-ui/src/views/system/dict/data.vue
index fe1b12d..f5eb63e 100644
--- a/ruoyi-ui/src/views/system/dict/data.vue
+++ b/ruoyi-ui/src/views/system/dict/data.vue
@@ -1,7 +1,7 @@
<template>
<div class="app-container">
- <el-form :inline="true">
- <el-form-item label="瀛楀吀鍚嶇О">
+ <el-form :model="queryParams" ref="queryForm" :inline="true">
+ <el-form-item label="瀛楀吀鍚嶇О" prop="dictType">
<el-select v-model="queryParams.dictType" size="small">
<el-option
v-for="item in typeOptions"
@@ -11,7 +11,7 @@
/>
</el-select>
</el-form-item>
- <el-form-item label="瀛楀吀鏍囩">
+ <el-form-item label="瀛楀吀鏍囩" prop="dictLabel">
<el-input
v-model="queryParams.dictLabel"
placeholder="璇疯緭鍏ュ瓧鍏告爣绛�"
@@ -20,7 +20,7 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
- <el-form-item label="鐘舵��">
+ <el-form-item label="鐘舵��" prop="status">
<el-select v-model="queryParams.status" placeholder="鏁版嵁鐘舵��" clearable size="small">
<el-option
v-for="dict in statusOptions"
@@ -32,11 +32,53 @@
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">鎼滅储</el-button>
- <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:dict:add']">鏂板</el-button>
+ <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">閲嶇疆</el-button>
</el-form-item>
</el-form>
- <el-table v-loading="loading" :data="dataList" style="width: 100%;">
+ <el-row :gutter="10" class="mb8">
+ <el-col :span="1.5">
+ <el-button
+ type="primary"
+ icon="el-icon-plus"
+ size="mini"
+ @click="handleAdd"
+ v-hasPermi="['system:dict:add']"
+ >鏂板</el-button>
+ </el-col>
+ <el-col :span="1.5">
+ <el-button
+ type="success"
+ icon="el-icon-edit"
+ size="mini"
+ :disabled="single"
+ @click="handleUpdate"
+ v-hasPermi="['system:dict:edit']"
+ >淇敼</el-button>
+ </el-col>
+ <el-col :span="1.5">
+ <el-button
+ type="danger"
+ icon="el-icon-delete"
+ size="mini"
+ :disabled="multiple"
+ @click="handleDelete"
+ v-hasPermi="['system:dict:remove']"
+ >鍒犻櫎</el-button>
+ </el-col>
+ <el-col :span="1.5">
+ <el-button
+ type="warning"
+ icon="el-icon-download"
+ size="mini"
+ @click="handleExport"
+ v-hasPermi="['system:dict:export']"
+ >瀵煎嚭</el-button>
+ </el-col>
+ </el-row>
+
+ <el-table v-loading="loading" :data="dataList" @selection-change="handleSelectionChange">
+ <el-table-column type="selection" width="55" align="center" />
<el-table-column label="瀛楀吀缂栫爜" align="center" prop="dictCode" />
<el-table-column label="瀛楀吀鏍囩" align="center" prop="dictLabel" />
<el-table-column label="瀛楀吀閿��" align="center" prop="dictValue" />
@@ -45,15 +87,15 @@
<el-table-column label="澶囨敞" align="center" prop="remark" :show-overflow-tooltip="true" />
<el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="180">
<template slot-scope="scope">
- <span>{{ dateFormat(scope.row.createTime) }}</span>
+ <span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
- <el-button
- size="mini"
- type="text"
- icon="el-icon-edit"
+ <el-button
+ size="mini"
+ type="text"
+ icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:dict:edit']"
>淇敼</el-button>
@@ -77,7 +119,7 @@
/>
<!-- 娣诲姞鎴栦慨鏀瑰弬鏁伴厤缃璇濇 -->
- <el-dialog :title="title" :visible.sync="open" width="500px">
+ <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="瀛楀吀绫诲瀷">
<el-input v-model="form.dictType" :disabled="true" />
@@ -113,18 +155,27 @@
</template>
<script>
-import { listData, getData, delData, addData, updateData } from "@/api/system/dict/data";
+import { listData, getData, delData, addData, updateData, exportData } from "@/api/system/dict/data";
import { listType, getType } from "@/api/system/dict/type";
export default {
+ name: "Data",
data() {
return {
// 閬僵灞�
loading: true,
+ // 閫変腑鏁扮粍
+ ids: [],
+ // 闈炲崟涓鐢�
+ single: true,
+ // 闈炲涓鐢�
+ multiple: true,
// 鎬绘潯鏁�
total: 0,
// 瀛楀吀琛ㄦ牸鏁版嵁
dataList: [],
+ // 榛樿瀛楀吀绫诲瀷
+ defaultDictType: "",
// 寮瑰嚭灞傛爣棰�
title: "",
// 鏄惁鏄剧ず寮瑰嚭灞�
@@ -170,6 +221,7 @@
getType(dictId) {
getType(dictId).then(response => {
this.queryParams.dictType = response.data.dictType;
+ this.defaultDictType = response.data.dictType;
this.getList();
});
},
@@ -214,6 +266,12 @@
this.queryParams.pageNum = 1;
this.getList();
},
+ /** 閲嶇疆鎸夐挳鎿嶄綔 */
+ resetQuery() {
+ this.resetForm("queryForm");
+ this.queryParams.dictType = this.defaultDictType;
+ this.handleQuery();
+ },
/** 鏂板鎸夐挳鎿嶄綔 */
handleAdd() {
this.reset();
@@ -221,10 +279,17 @@
this.title = "娣诲姞瀛楀吀鏁版嵁";
this.form.dictType = this.queryParams.dictType;
},
+ // 澶氶�夋閫変腑鏁版嵁
+ handleSelectionChange(selection) {
+ this.ids = selection.map(item => item.dictCode)
+ this.single = selection.length!=1
+ this.multiple = !selection.length
+ },
/** 淇敼鎸夐挳鎿嶄綔 */
handleUpdate(row) {
this.reset();
- getData(row.dictCode).then(response => {
+ const dictCode = row.dictCode || this.ids
+ getData(dictCode).then(response => {
this.form = response.data;
this.open = true;
this.title = "淇敼瀛楀吀鏁版嵁";
@@ -240,8 +305,6 @@
this.msgSuccess("淇敼鎴愬姛");
this.open = false;
this.getList();
- } else {
- this.msgError(response.msg);
}
});
} else {
@@ -250,8 +313,6 @@
this.msgSuccess("鏂板鎴愬姛");
this.open = false;
this.getList();
- } else {
- this.msgError(response.msg);
}
});
}
@@ -260,16 +321,30 @@
},
/** 鍒犻櫎鎸夐挳鎿嶄綔 */
handleDelete(row) {
- this.$confirm('鏄惁纭鍒犻櫎鍚嶇О涓�"' + row.dictLabel + '"鐨勬暟鎹」?', "璀﹀憡", {
+ const dictCodes = row.dictCode || this.ids;
+ this.$confirm('鏄惁纭鍒犻櫎瀛楀吀缂栫爜涓�"' + dictCodes + '"鐨勬暟鎹」?', "璀﹀憡", {
confirmButtonText: "纭畾",
cancelButtonText: "鍙栨秷",
type: "warning"
}).then(function() {
- return delData(row.dictCode);
+ return delData(dictCodes);
}).then(() => {
this.getList();
this.msgSuccess("鍒犻櫎鎴愬姛");
}).catch(function() {});
+ },
+ /** 瀵煎嚭鎸夐挳鎿嶄綔 */
+ handleExport() {
+ const queryParams = this.queryParams;
+ this.$confirm('鏄惁纭瀵煎嚭鎵�鏈夋暟鎹」?', "璀﹀憡", {
+ confirmButtonText: "纭畾",
+ cancelButtonText: "鍙栨秷",
+ type: "warning"
+ }).then(function() {
+ return exportData(queryParams);
+ }).then(response => {
+ this.download(response.msg);
+ }).catch(function() {});
}
}
};
--
Gitblit v1.9.3