bonus-ui/src/views/base/mobile/baseSetting/index.vue

253 lines
9.6 KiB
Vue

<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="描述">
<el-input v-model="queryParams.itemDescription" placeholder="请输入描述" maxlength="20" clearable style="width: 220px"/>
</el-form-item>
<el-form-item>
<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-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<!-- <el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col> -->
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="tableListData" border size="mini">
<el-table-column label="序号" align="center" width="80" type="index">
<template scope="scope">
<span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
</template>
</el-table-column>
<el-table-column label="设置描述" align="center" prop="itemDescription" :show-overflow-tooltip="true"/>
<el-table-column label="参数键名" align="center" prop="itemName" :show-overflow-tooltip="true"/>
<el-table-column label="参数键值" align="center" prop="itemValue" :show-overflow-tooltip="true"/>
<el-table-column label="用途类型" align="center" prop="usageType" :show-overflow-tooltip="true">
<template scope="scope">
<span v-if="scope.row.usageType==1">后台</span>
<span v-if="scope.row.usageType==2">APP</span>
<span v-if="scope.row.usageType==3">双屏消费机</span>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" :show-overflow-tooltip="true"/>
<el-table-column label="更新时间" align="center" prop="updateTime" :show-overflow-tooltip="true"/>
<el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>编辑</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改参数配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row>
<el-col :span="24">
<el-form-item label="设置描述" prop="itemDescription">
<el-input v-model="form.itemDescription" placeholder="请输入设置描述" maxlength="30" clearable/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="参数键名" prop="itemName">
<el-input v-model="form.itemName" placeholder="请输入参数键名" disabled maxlength="30"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="参数键值" prop="itemValue">
<el-input v-model="form.itemValue" placeholder="请输入参数键值" maxlength="30" clearable/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="用途类型" prop="usageType">
<el-select v-model="form.usageType" style="width: 100%">
<el-option label="后台" value="1"></el-option>
<el-option label="APP" value="2"></el-option>
<el-option label="双屏消费机" value="3"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
<el-dialog :visible.sync="dialogVisible" width="700px">
<img style="width: 100%;height: 100%;" :src="dialogImageUrl" alt="">
</el-dialog>
</div>
</template>
<script>
import { getSettingListApi,addSettingApi,updateSettingApi,removeSettingApi } from "@/api/base/mobile.js";
import { imgUpLoadTwo } from '@/api/system/upload'
export default {
name: "",
dicts: [],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
//表格数据
tableListData: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
itemDescription: undefined,
},
// 表单参数
form: {},
// 表单校验
rules: {
itemDescription: [
{ required: true, message: "设置描述不能为空", trigger: "blur" }
],
itemValue: [
{ required: true, message: "参数键值不能为空", trigger: "blur" }
],
usageType: [
{ required: true, message: "用途类型不能为空", trigger: "change" }
],
}
};
},
created() {
this.getList();
},
methods: {
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 查询列表 */
getList() {
this.loading = true;
let param = {
"pageNum": this.queryParams.pageNum,
"pageSize": this.queryParams.pageSize,
"itemDescription": this.queryParams.itemDescription
}
getSettingListApi(param).then(response => {
this.tableListData = response.rows;
this.total = Number(response.total);
this.loading = false;
});
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "新增";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
this.form = Object.assign({}, row)
this.open = true;
this.title = "修改";
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {};
this.$set(this.form,"usageType","2")
this.resetForm("form");
},
/** 提交按钮 */
submitForm: function() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != undefined) {
updateSettingApi(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addSettingApi(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
this.$modal.confirm('是否确认删除数据项?').then(function() {
return removeSettingApi({id:row.id});
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
}
};
</script>
<style lang="scss" scoped>
//隐藏图片上传框的css
::v-deep.disabled {
.el-upload--picture-card {
display: none;
}
}
</style>