Merge remote-tracking branch 'origin/master'

# Conflicts:
#	dvadmin-ui/src/views/vadmin/system/dict/data.vue
pull/38/head
李强 2021-07-11 15:43:47 +08:00
commit 6d7bf613c8
2 changed files with 65 additions and 47 deletions

View File

@ -258,7 +258,7 @@ class ExportLoginInforSerializer(CustomModelSerializer):
class Meta: class Meta:
model = LoginInfor model = LoginInfor
fields = ('id', 'creator_name', 'ipaddr', 'loginLocation', 'browser', 'os', fields = ('id', 'creator_name', 'ipaddr', 'loginLocation', 'browser', 'os',
'status', 'msg', 'creator_name') 'status', 'msg')
# ================================================= # # ================================================= #

View File

@ -1,6 +1,11 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form v-show="showSearch" ref="queryForm" :model="queryParams" :inline="true" label-width="68px"> <el-form
v-show="showSearch"
ref="queryForm"
:model="queryParams" :inline="true"
label-width="68px"
>
<el-form-item label="字典名称" prop="dictType"> <el-form-item label="字典名称" prop="dictType">
<el-select v-model="queryParams.dictType" size="small"> <el-select v-model="queryParams.dictType" size="small">
<el-option <el-option
@ -21,7 +26,12 @@
/> />
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="数据状态" clearable size="small"> <el-select
v-model="queryParams.status"
placeholder="数据状态"
clearable
size="small"
>
<el-option <el-option
v-for="dict in statusOptions" v-for="dict in statusOptions"
:key="dict.dictValue" :key="dict.dictValue"
@ -31,7 +41,9 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<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-search" size="mini" @click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -92,7 +104,11 @@
<right-toolbar :show-search.sync="showSearch" @queryTable="getList" /> <right-toolbar :show-search.sync="showSearch" @queryTable="getList" />
</el-row> </el-row>
<el-table v-loading="loading" :data="dataList" @selection-change="handleSelectionChange"> <el-table
v-loading="loading"
:data="dataList"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="字典编码" align="center" prop="id" /> <el-table-column label="字典编码" align="center" prop="id" />
<el-table-column label="字典标签" align="center" prop="dictLabel" /> <el-table-column label="字典标签" align="center" prop="dictLabel" />
@ -106,8 +122,18 @@
/> />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" /> <el-table-column
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> label="状态"
align="center"
prop="status"
:formatter="statusFormat"
/>
<el-table-column
label="备注"
align="center"
prop="remark"
:show-overflow-tooltip="true"
/>
<el-table-column label="创建时间" align="center" prop="create_datetime" width="180"> <el-table-column label="创建时间" align="center" prop="create_datetime" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.create_datetime) }}</span> <span>{{ parseTime(scope.row.create_datetime) }}</span>
@ -139,7 +165,7 @@
</el-table> </el-table>
<pagination <pagination
v-show="total>0" v-show="total > 0"
:total="total" :total="total"
:page.sync="queryParams.pageNum" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" :limit.sync="queryParams.pageSize"
@ -162,10 +188,7 @@
<el-input-number v-model="form.sort" controls-position="right" :min="0" /> <el-input-number v-model="form.sort" controls-position="right" :min="0" />
</el-form-item> </el-form-item>
<el-form-item label="是否默认" prop="is_default"> <el-form-item label="是否默认" prop="is_default">
<el-switch <el-switch v-model="form.is_default" active-text="" inactive-text=""
v-model="form.is_default"
active-text="是"
inactive-text="否"
/> />
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
@ -174,7 +197,8 @@
v-for="dict in statusOptions" v-for="dict in statusOptions"
:key="dict.dictValue" :key="dict.dictValue"
:label="dict.dictValue" :label="dict.dictValue"
>{{ dict.dictLabel }}</el-radio> >{{ dict.dictLabel }}</el-radio
>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
@ -190,7 +214,7 @@
</template> </template>
<script> <script>
import { addData, delData, exportData, getData, listData, updateData } from "@/api/vadmin/system/dict/data"; import { addData, delData, exportData, getData, listData, updateData ,} from "@/api/vadmin/system/dict/data";
import { getType, listType, clearCache } from "@/api/vadmin/system/dict/type"; import { getType, listType, clearCache } from "@/api/vadmin/system/dict/type";
export default { export default {
@ -224,39 +248,33 @@ export default {
// //
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 1000, pageSize: 10,
dictName: undefined, dictName: undefined,
dictType: undefined, dictType: undefined,
status: undefined status: undefined,
}, },
// //
form: {}, form: {},
// //
rules: { rules: {
name: [ name: [{ required: true, message: "数据标签不能为空", trigger: "blur" }],
{ required: true, message: "数据标签不能为空", trigger: "blur" } dictValue: [{ required: true, message: "数据键值不能为空", trigger: "blur" }],
], sort: [{ required: true, message: "数据顺序不能为空", trigger: "blur" }],
dictValue: [ },
{ required: true, message: "数据键值不能为空", trigger: "blur" }
],
sort: [
{ required: true, message: "数据顺序不能为空", trigger: "blur" }
]
}
}; };
}, },
created() { created() {
const dictId = this.$route.params && this.$route.params.dictId; const dictId = this.$route.params && this.$route.params.dictId;
this.getType(dictId); this.getType(dictId);
this.getTypeList(); this.getTypeList();
this.getDicts("sys_normal_disable").then(response => { this.getDicts("sys_normal_disable").then((response) => {
this.statusOptions = response.data; this.statusOptions = response.data;
}); });
}, },
methods: { methods: {
/** 查询字典类型详细 */ /** 查询字典类型详细 */
getType(dictId) { getType(dictId) {
getType(dictId).then(response => { getType(dictId).then((response) => {
this.queryParams.dictType = response.data.dictType; this.queryParams.dictType = response.data.dictType;
this.defaultDictType = response.data.dictType; this.defaultDictType = response.data.dictType;
this.getList(); this.getList();
@ -264,14 +282,14 @@ export default {
}, },
/** 查询字典类型列表 */ /** 查询字典类型列表 */
getTypeList() { getTypeList() {
listType({ pageNum: "all" }).then(response => { listType({ pageNum: "all" }).then((response) => {
this.typeOptions = response.data; this.typeOptions = response.data;
}); });
}, },
/** 查询字典数据列表 */ /** 查询字典数据列表 */
getList() { getList() {
this.loading = true; this.loading = true;
listData(this.queryParams).then(response => { listData(this.queryParams).then((response) => {
this.dataList = response.data.results; this.dataList = response.data.results;
this.total = response.data.count; this.total = response.data.count;
this.loading = false; this.loading = false;
@ -294,14 +312,14 @@ export default {
dictValue: undefined, dictValue: undefined,
sort: 0, sort: 0,
status: this.selectDictDefault(this.typeOptions), status: this.selectDictDefault(this.typeOptions),
remark: undefined remark: undefined,
}; };
this.resetForm("form"); this.resetForm("form");
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
let dictId = ""; let dictId = "";
this.typeOptions.map(val => { this.typeOptions.map((val) => {
if (val.dictType === this.queryParams.dictType) { if (val.dictType === this.queryParams.dictType) {
dictId = val.id; dictId = val.id;
} }
@ -325,7 +343,7 @@ export default {
}, },
// //
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.id); this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1; this.single = selection.length !== 1;
this.multiple = !selection.length; this.multiple = !selection.length;
}, },
@ -333,18 +351,18 @@ export default {
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset();
const id = row.id || this.ids; const id = row.id || this.ids;
getData(id).then(response => { getData(id).then((response) => {
this.form = response.data; this.form = response.data;
this.open = true; this.open = true;
this.title = "修改字典数据"; this.title = "修改字典数据";
}); });
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm: function() { submitForm: function () {
this.$refs["form"].validate(valid => { this.$refs["form"].validate((valid) => {
if (valid) { if (valid) {
if (this.form.id !== undefined) { if (this.form.id !== undefined) {
updateData(this.form).then(response => { updateData(this.form).then((response) => {
this.msgSuccess("修改成功"); this.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
@ -352,7 +370,7 @@ export default {
} else { } else {
const dictId = this.$route.params && this.$route.params.dictId; const dictId = this.$route.params && this.$route.params.dictId;
this.form.dict_data = dictId; this.form.dict_data = dictId;
addData(this.form).then(response => { addData(this.form).then((response) => {
this.msgSuccess("新增成功"); this.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
@ -367,10 +385,10 @@ export default {
this.$confirm('是否确认删除字典编码为"' + dictCodes + '"的数据项?', "警告", { this.$confirm('是否确认删除字典编码为"' + dictCodes + '"的数据项?', "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning",
}).then(function() { }).then(function() {
return delData(dictCodes); return delData(dictCodes);})
}).then(() => { .then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.msgSuccess("删除成功");
}); });
@ -381,19 +399,19 @@ export default {
this.$confirm("是否确认导出所有数据项?", "警告", { this.$confirm("是否确认导出所有数据项?", "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning",
}).then(function() { }).then(function() {
return exportData(queryParams); return exportData(queryParams);})
}).then(response => { .then((response) => {
this.download(response.data.file_url, response.data.name); this.download(response.data.file_url, response.data.name);
}); });
}, },
/** 清理缓存按钮操作 */ /** 清理缓存按钮操作 */
handleClearCache() { handleClearCache() {
clearCache().then(response => { clearCache().then((response) => {
this.msgSuccess("清理成功"); this.msgSuccess("清理成功");
}); });
} },
} },
}; };
</script> </script>