506 lines
23 KiB
HTML
506 lines
23 KiB
HTML
<!--#
|
|
layout("/layouts/platform.html"){
|
|
#-->
|
|
<style>
|
|
/* 系统参数页面固定占满平台内容区,避免页面主体产生纵向滚动条。 */
|
|
#app .sys-conf-layout {
|
|
display: flex;
|
|
flex-direction: column;
|
|
min-height: 0;
|
|
height: calc(100vh - 82px);
|
|
overflow: hidden;
|
|
}
|
|
#app .sys-conf-query-card {
|
|
flex: 0 0 auto;
|
|
}
|
|
/* 列表卡片占用剩余空间,数据超出时仅由 Element 表格内部滚动。 */
|
|
#app .sys-conf-list-card {
|
|
flex: 1 1 auto;
|
|
min-height: 0;
|
|
overflow: hidden;
|
|
}
|
|
#app .sys-conf-list-card > .el-card__body {
|
|
box-sizing: border-box;
|
|
display: flex;
|
|
flex-direction: column;
|
|
min-height: 0;
|
|
height: 100%;
|
|
overflow: hidden;
|
|
}
|
|
#app .sys-conf-list-card .ele-table-tool,
|
|
#app .sys-conf-list-card .el-pagination-container {
|
|
flex: 0 0 auto;
|
|
}
|
|
</style>
|
|
<div id="app" v-cloak>
|
|
<guava>
|
|
<div class="sys-conf-layout">
|
|
<el-card class="sys-conf-query-card" shadow="never">
|
|
<search @search="doSearch">
|
|
<search-item label="参数名">
|
|
<el-input v-model="pageForm.configKey" clearable placeholder="请输入参数名"
|
|
@keyup.enter.native="doSearch"></el-input>
|
|
</search-item>
|
|
</search>
|
|
</el-card>
|
|
<el-card class="mt10 sys-conf-list-card" shadow="never">
|
|
<table-tool label="系统参数">
|
|
<el-button @click="openAdd" size="small" type="primary" icon="el-icon-plus">新增</el-button>
|
|
</table-tool>
|
|
<el-table v-loading="tableLoading" :data="tableData" :height="tableHeight"
|
|
@sort-change="pageOrder" header-align="center" ref="tableRef" style="width: 100%">
|
|
<el-table-column header-align="center" label="参数名" prop="configKey" sortable
|
|
width="200"></el-table-column>
|
|
<el-table-column :show-overflow-tooltip="true" header-align="center" label="参数值" prop="configValue"
|
|
width="200"></el-table-column>
|
|
<el-table-column :show-overflow-tooltip="true" header-align="center" label="说明"
|
|
prop="note"></el-table-column>
|
|
<el-table-column label="操作" prop="note" width="120">
|
|
<template slot-scope="scope">
|
|
<el-dropdown @command="dropdownCommand">
|
|
<el-button size="mini">
|
|
<i class="ti-settings"></i>
|
|
<span class="ti-angle-down"></span>
|
|
</el-button>
|
|
<el-dropdown-menu slot="dropdown">
|
|
<el-dropdown-item :command="{type:'edit',id:scope.row.configKey}">修改
|
|
</el-dropdown-item>
|
|
<el-dropdown-item :command="{type:'delete',id:scope.row.configKey}"
|
|
v-if="scope.row.configKey.indexOf('App')<0">
|
|
删除
|
|
</el-dropdown-item>
|
|
</el-dropdown-menu>
|
|
</el-dropdown>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<!--#include("/layouts/pagination.html"){}#-->
|
|
</el-card>
|
|
</div>
|
|
</guava>
|
|
|
|
<el-dialog title="新增参数" :visible.sync="addDialogVisible" :close-on-click-modal="false" width="40%">
|
|
<el-form :model="formData" ref="addForm" :rules="formRules" label-width="80px">
|
|
<el-form-item prop="configKey" label="参数名">
|
|
<el-input maxlength="100" placeholder="参数名" v-model="formData.configKey" auto-complete="off"
|
|
tabindex="1" type="text"></el-input>
|
|
</el-form-item>
|
|
<el-form-item prop="configValue" label="参数值">
|
|
<el-input maxlength="100" placeholder="参数值" v-model="formData.configValue" auto-complete="off"
|
|
tabindex="2" type="text"></el-input>
|
|
</el-form-item>
|
|
<el-form-item prop="note" label="说 明">
|
|
<el-input type="textarea" v-model="formData.note"></el-input>
|
|
</el-form-item>
|
|
</el-form>
|
|
<span slot="footer" class="dialog-footer">
|
|
<el-button @click="addDialogVisible = false">取 消</el-button>
|
|
<el-button type="primary" @click="doAdd">确 定</el-button>
|
|
</span>
|
|
</el-dialog>
|
|
<el-dialog title="修改参数" :visible.sync="editDialogVisible" :close-on-click-modal="false" width="40%">
|
|
<el-form :model="formData" ref="editForm" :rules="formRules" label-width="80px">
|
|
<el-form-item prop="configKey" label="参数名">
|
|
<el-input
|
|
maxlength="100"
|
|
placeholder="参数名"
|
|
v-model="formData.configKey"
|
|
auto-complete="off"
|
|
tabindex="1"
|
|
type="text"
|
|
disabled
|
|
></el-input>
|
|
</el-form-item>
|
|
<el-form-item prop="configValue" label="参数值">
|
|
<template v-if="formData.configKey === 'AppLogo'">
|
|
<file-upload
|
|
key="AppLogo"
|
|
style="--upload-width: 214px;--upload-height:64px"
|
|
:value.sync="formData.configValue"
|
|
:upload_number="1"
|
|
upload_mode="image"
|
|
upload_result_category="interval"
|
|
upload_result_type="url"
|
|
></file-upload>
|
|
<span>最佳分辨率:428 x 128</span>
|
|
</template>
|
|
<template v-else-if="formData.configKey === 'AppHomeImg'">
|
|
<file-upload
|
|
key="AppHomeImg"
|
|
style="--upload-width: 214px;--upload-height:64px"
|
|
:value.sync="formData.configValue"
|
|
:upload_number="5"
|
|
upload_mode="image"
|
|
upload_result_category="interval"
|
|
upload_result_type="url"
|
|
></file-upload>
|
|
<span>PC 首页轮播图,最佳分辨率:2756 x 732,最多可上传 5 张,首页按上传顺序轮播</span>
|
|
</template>
|
|
<template v-else-if="formData.configKey === 'H5AppHomeImg'">
|
|
<file-upload
|
|
key="H5AppHomeImg"
|
|
style="--upload-width: 214px;--upload-height:110px"
|
|
:value.sync="formData.configValue"
|
|
:upload_number="5"
|
|
upload_mode="image"
|
|
upload_result_category="interval"
|
|
upload_result_type="url"
|
|
></file-upload>
|
|
<span>移动端首页轮播图,建议分辨率:750 x 386,最多可上传 5 张,首页按上传顺序轮播</span>
|
|
</template>
|
|
<template v-else-if="formData.configKey === 'PCHomeImg'">
|
|
<file-upload
|
|
key="PCHomeImg"
|
|
style="--upload-width: 214px;--upload-height:64px"
|
|
:value.sync="formData.configValue"
|
|
:upload_number="10"
|
|
upload_mode="image"
|
|
upload_result_category="interval"
|
|
upload_result_type="url"
|
|
></file-upload>
|
|
<span>最佳分辨率:2756 x 732,最多可上传 10 张,PC端首页按上传顺序轮播</span>
|
|
</template>
|
|
<template v-else-if="formData.configKey === 'AppFeaturedActivityImg'">
|
|
<file-upload
|
|
key="AppFeaturedActivityImg"
|
|
style="--upload-width: 214px;--upload-height:96px"
|
|
:value.sync="formData.configValue"
|
|
:upload_number="1"
|
|
upload_mode="image"
|
|
upload_result_category="interval"
|
|
upload_result_type="url"
|
|
></file-upload>
|
|
<span>最佳分辨率:750 x 280,精彩活动页顶部图片</span>
|
|
</template>
|
|
<template v-else-if="formData.configKey === 'AppFestivalBenefitImg'">
|
|
<file-upload
|
|
key="AppFestivalBenefitImg"
|
|
style="--upload-width: 214px;--upload-height:96px"
|
|
:value.sync="formData.configValue"
|
|
:upload_number="1"
|
|
upload_mode="image"
|
|
upload_result_category="interval"
|
|
upload_result_type="url"
|
|
></file-upload>
|
|
<span>最佳分辨率:750 x 280,节日福利页顶部图片</span>
|
|
</template>
|
|
<template v-else>
|
|
<div v-if="'true'===formData.configValue||'false'===formData.configValue">
|
|
<el-radio-group v-model="formData.configValue">
|
|
<el-radio label="true">是</el-radio>
|
|
<el-radio label="false">否</el-radio>
|
|
</el-radio-group>
|
|
</div>
|
|
<div v-else>
|
|
<el-input
|
|
maxlength="100"
|
|
placeholder="参数值"
|
|
v-model="formData.configValue"
|
|
auto-complete="off"
|
|
tabindex="2"
|
|
type="text"
|
|
></el-input>
|
|
</div>
|
|
</template>
|
|
</el-form-item>
|
|
<el-form-item prop="note" label="说 明">
|
|
<el-input type="textarea" v-model="formData.note"></el-input>
|
|
</el-form-item>
|
|
</el-form>
|
|
<span slot="footer" class="dialog-footer">
|
|
<el-button @click="editDialogVisible = false">取 消</el-button>
|
|
<el-button type="primary" @click="doEdit">确 定</el-button>
|
|
</span>
|
|
</el-dialog>
|
|
</div>
|
|
<script nonce="${cspNonce!}">
|
|
new Vue({
|
|
el: "#app",
|
|
data: function () {
|
|
return {
|
|
addDialogVisible: false,
|
|
editDialogVisible: false,
|
|
tableLoading: false,
|
|
tableHeight: 300,
|
|
tableResizeObserver: null,
|
|
pageRequestSequence: 0,
|
|
tableData: [],
|
|
pageForm: {
|
|
pageSize: 10,
|
|
pageNumber: 1,
|
|
pageOrderName: "",
|
|
pageOrderBy: "",
|
|
totalCount: 0,
|
|
configKey: ""
|
|
},
|
|
formData: {
|
|
configKey: "",
|
|
configValue: "",
|
|
note: ""
|
|
},
|
|
formRules: {
|
|
configKey: [{required: true, message: "请输入参数名", trigger: "blur"}],
|
|
configValue: [{required: true, message: "请输入参数值", trigger: "blur"}]
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
doSearch: function () {
|
|
this.pageForm.pageNumber = 1
|
|
this.pageData()
|
|
},
|
|
openAdd: function () {
|
|
this.addDialogVisible = true
|
|
this.formData = {} //打开新增窗口,表单先清空
|
|
},
|
|
doAdd: function () {
|
|
var self = this
|
|
var url = base + "/platform/sys/conf/addDo"
|
|
self.$refs["addForm"].validate(function (valid) {
|
|
if (valid) {
|
|
//表单验证通过
|
|
$.post(
|
|
url,
|
|
self.formData,
|
|
function (data) {
|
|
if (data.code == 0) {
|
|
self.$message({
|
|
message: data.msg,
|
|
type: "success"
|
|
})
|
|
self.addDialogVisible = false
|
|
self.pageData() //重新加载分页数据
|
|
} else {
|
|
self.$message({
|
|
message: data.msg,
|
|
type: "error"
|
|
})
|
|
}
|
|
},
|
|
"json"
|
|
)
|
|
}
|
|
})
|
|
},
|
|
doEdit: function () {
|
|
var self = this
|
|
var url = base + "/platform/sys/conf/editDo"
|
|
self.normalizeConfigValue()
|
|
self.$refs["editForm"].validate(function (valid) {
|
|
if (valid) {
|
|
$.post(
|
|
url,
|
|
self.formData,
|
|
function (data) {
|
|
if (data.code == 0) {
|
|
self.$message({
|
|
message: data.msg,
|
|
type: "success"
|
|
})
|
|
self.editDialogVisible = false
|
|
self.pageData() //重新加载分页数据
|
|
} else {
|
|
self.$message({
|
|
message: data.msg,
|
|
type: "error"
|
|
})
|
|
}
|
|
},
|
|
"json"
|
|
)
|
|
}
|
|
})
|
|
},
|
|
normalizeConfigValue: function () {
|
|
if (Array.isArray(this.formData.configValue)) {
|
|
this.formData.configValue = this.formData.configValue
|
|
.map(function (item) {
|
|
if (typeof item === "string") {
|
|
return item
|
|
}
|
|
if (item && item.response && item.response.data) {
|
|
return item.response.data
|
|
}
|
|
if (item && item.url) {
|
|
return item.url
|
|
}
|
|
if (item && item.data) {
|
|
return item.data
|
|
}
|
|
return ""
|
|
})
|
|
.filter(function (item) {
|
|
return item
|
|
})
|
|
.join(",")
|
|
}
|
|
if (typeof this.formData.configValue === "string") {
|
|
this.formData.configValue = this.formData.configValue
|
|
.split(",")
|
|
.map(function (item) {
|
|
return item.trim()
|
|
})
|
|
.filter(function (item) {
|
|
return item
|
|
})
|
|
.join(",")
|
|
}
|
|
},
|
|
pageOrder: function (column) {
|
|
//按字段排序
|
|
this.pageForm.pageOrderName = column.prop
|
|
this.pageForm.pageOrderBy = column.order
|
|
this.pageData()
|
|
},
|
|
pageNumberChange: function (val) {
|
|
//页码更新操作
|
|
this.pageForm.pageNumber = val
|
|
this.pageData()
|
|
},
|
|
pageSizeChange: function (val) {
|
|
//分页大小更新操作
|
|
this.pageForm.pageSize = val
|
|
this.pageData()
|
|
},
|
|
pageData: function () {
|
|
// 查询期间清空旧页并显示加载状态,快速连续查询时仅接收最后一次响应。
|
|
var self = this
|
|
var requestSequence = ++self.pageRequestSequence
|
|
self.tableData = []
|
|
self.tableLoading = true
|
|
$.post(base + "/platform/sys/conf/data", self.pageForm).then(function (data) {
|
|
if (requestSequence != self.pageRequestSequence) {
|
|
return
|
|
}
|
|
if (data.code == 0) {
|
|
self.tableData = data.data.list || []
|
|
self.pageForm.totalCount = data.data.totalCount || 0
|
|
self.updateTableHeight()
|
|
} else {
|
|
self.$message({
|
|
message: data.msg,
|
|
type: "error"
|
|
})
|
|
}
|
|
}).always(function () {
|
|
if (requestSequence == self.pageRequestSequence) {
|
|
self.tableLoading = false
|
|
}
|
|
})
|
|
},
|
|
updateTableHeight: function () {
|
|
var self = this
|
|
this.$nextTick(function () {
|
|
var cardBody = self.$el.querySelector(".sys-conf-list-card > .el-card__body")
|
|
if (!cardBody || cardBody.clientHeight <= 0) {
|
|
return
|
|
}
|
|
var getOuterHeight = function (element) {
|
|
if (!element) {
|
|
return 0
|
|
}
|
|
var style = window.getComputedStyle(element)
|
|
return element.offsetHeight
|
|
+ (parseFloat(style.marginTop) || 0)
|
|
+ (parseFloat(style.marginBottom) || 0)
|
|
}
|
|
var bodyStyle = window.getComputedStyle(cardBody)
|
|
var bodyPadding = (parseFloat(bodyStyle.paddingTop) || 0)
|
|
+ (parseFloat(bodyStyle.paddingBottom) || 0)
|
|
var tableTool = cardBody.querySelector(".ele-table-tool")
|
|
var pagination = cardBody.querySelector(".el-pagination-container")
|
|
var reservedHeight = bodyPadding + getOuterHeight(tableTool) + getOuterHeight(pagination)
|
|
self.tableHeight = Math.max(1, Math.floor(cardBody.clientHeight - reservedHeight))
|
|
self.$nextTick(function () {
|
|
if (self.$refs.tableRef) {
|
|
self.$refs.tableRef.doLayout()
|
|
}
|
|
})
|
|
})
|
|
},
|
|
dropdownCommand: function (command) {
|
|
//监听下拉框事件
|
|
var self = this
|
|
if ("edit" == command.type) {
|
|
$.post(
|
|
base + "/platform/sys/conf/edit/" + command.id,
|
|
{},
|
|
function (data) {
|
|
if (data.code == 0) {
|
|
self.formData = data.data //加载后台表单数据
|
|
self.editDialogVisible = true //打开编辑窗口
|
|
} else {
|
|
self.$message({
|
|
message: data.msg,
|
|
type: "error"
|
|
})
|
|
}
|
|
},
|
|
"json"
|
|
)
|
|
}
|
|
if ("delete" == command.type) {
|
|
self.$confirm("此操作将删除 " + command.id, "提示", {
|
|
confirmButtonText: "确定",
|
|
cancelButtonText: "取消",
|
|
type: "warning",
|
|
callback: function (a, b) {
|
|
if ("confirm" == a) {
|
|
//确认后再执行
|
|
$.post(
|
|
base + "/platform/sys/conf/delete/" + command.id,
|
|
{},
|
|
function (data) {
|
|
if (data.code == 0) {
|
|
self.$message({
|
|
message: data.msg,
|
|
type: "success"
|
|
})
|
|
self.pageData()
|
|
} else {
|
|
self.$message({
|
|
message: data.msg,
|
|
type: "error"
|
|
})
|
|
}
|
|
},
|
|
"json"
|
|
)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
},
|
|
created: function () {
|
|
this.pageData()
|
|
},
|
|
mounted: function () {
|
|
var self = this
|
|
this.updateTableHeight()
|
|
if (window.ResizeObserver) {
|
|
this.tableResizeObserver = new ResizeObserver(function () {
|
|
self.updateTableHeight()
|
|
})
|
|
this.tableResizeObserver.observe(this.$el)
|
|
} else {
|
|
this.resizeHandler = function () {
|
|
self.updateTableHeight()
|
|
}
|
|
window.addEventListener("resize", this.resizeHandler)
|
|
}
|
|
},
|
|
beforeDestroy: function () {
|
|
if (this.tableResizeObserver) {
|
|
this.tableResizeObserver.disconnect()
|
|
}
|
|
if (this.resizeHandler) {
|
|
window.removeEventListener("resize", this.resizeHandler)
|
|
}
|
|
}
|
|
})
|
|
</script>
|
|
<!--#
|
|
}
|
|
#-->
|