189 lines
7.6 KiB
HTML
189 lines
7.6 KiB
HTML
<!--#
|
|
layout("/layouts/platform.html"){
|
|
#-->
|
|
|
|
<div id="app">
|
|
<el-card shadow="never">
|
|
<search @search="doSearch">
|
|
<search-item label="平台">
|
|
<el-select v-model="pageForm.platform" :clearable="false" @change="doSearch">
|
|
<el-option v-for="item in dict.type.SYS_MENU_PLATFORM" :value="item.code" :key="item.value" :label="item.label"></el-option>
|
|
</el-select>
|
|
</search-item>
|
|
<search-item label="名称">
|
|
<el-input v-model="pageForm.searchKeyword" placeholder="请输入名称" clearable></el-input>
|
|
</search-item>
|
|
</search>
|
|
</el-card>
|
|
|
|
<el-card shadow="never">
|
|
<table-tool>
|
|
<el-button size="small" type="primary" @click="openAdd">添加模块</el-button>
|
|
</table-tool>
|
|
<el-table :data="tableData" :size="tableSize" @sort-change="pageOrder" align="center" header-align="center">
|
|
<el-table-column
|
|
:label="column.label"
|
|
:prop="column.prop"
|
|
:key="column.prop"
|
|
:sortable="column.sortable"
|
|
align="center"
|
|
header-align="center"
|
|
show-overflow-tooltip
|
|
v-for="column in tableColumns"
|
|
>
|
|
<template scope="{row}" v-if="column.prop=='icon'">
|
|
<el-image lazy :src="row.icon" style="height: 30px; width: 30px" fit="cover">
|
|
<div slot="error" class="image-slot">
|
|
<i class="el-icon-picture-outline"></i>
|
|
</div>
|
|
</el-image>
|
|
</template>
|
|
<template scope="{row}" v-else-if="column.prop=='faIcon'">
|
|
<i :class="row.faIcon"></i>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="操作" width="200px">
|
|
<template scope="{row}">
|
|
<el-button @click="openEdit(row)" size="mini" type="primary">编辑</el-button>
|
|
<el-button @click="doDelete(row.id)" size="mini" type="danger">删除</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<!--#include("/layouts/pagination.html"){}#-->
|
|
</el-card>
|
|
|
|
<el-dialog :visible.sync="formDialogVisible" :title="formData.id ? '编辑模块' : '添加模块'">
|
|
<el-form :model="formData" :rules="formRules" label-width="120px" ref="form">
|
|
<el-form-item label="所属平台" prop="platform">
|
|
<el-select v-model="formData.platform" :clearable="false" @change="doSearch" placeholder="请选择平台">
|
|
<el-option v-for="item in dict.type.SYS_MENU_PLATFORM" :value="item.code" :key="item.value" :label="item.label"></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="模块名称" prop="name">
|
|
<el-input v-model="formData.name" maxlength="8"></el-input>
|
|
</el-form-item>
|
|
<el-form-item label="模块图片" prop="icon">
|
|
<file-upload
|
|
:value.sync="formData.icon"
|
|
:upload_number="1"
|
|
upload_mode="image"
|
|
upload_result_category="interval"
|
|
upload_result_type="url"
|
|
></file-upload>
|
|
</el-form-item>
|
|
<el-form-item label="图标" prop="faIcon">
|
|
<el-input maxlength="100" placeholder="图标" v-model="formData.faIcon"></el-input>
|
|
<i :class="formData.faIcon" v-if="formData.faIcon"></i>
|
|
</el-form-item>
|
|
<el-form-item label="排序编号" prop="sortNum">
|
|
<el-input-number v-model="formData.sortNum" :min="1" :precision="0"></el-input-number>
|
|
</el-form-item>
|
|
</el-form>
|
|
<el-row type="flex" justify="end">
|
|
<el-button @click="formDialogVisible=false">取消</el-button>
|
|
<el-button type="primary" @click="doSubmit">确定</el-button>
|
|
</el-row>
|
|
</el-dialog>
|
|
</div>
|
|
|
|
<script nonce="${cspNonce!}">
|
|
new Vue({
|
|
el: "#app",
|
|
dicts: ["SYS_MENU_PLATFORM"],
|
|
mixins: [initTableMixins],
|
|
data() {
|
|
return {
|
|
formDialogVisible: false,
|
|
formData: {
|
|
id: null,
|
|
name: null,
|
|
icon: null,
|
|
sortNum: null
|
|
},
|
|
formRules: {
|
|
platform: [{ required: true, message: "请填写", trigger: ["blur", "change"] }],
|
|
name: [{ required: true, message: "请填写", trigger: ["blur", "change"] }],
|
|
icon: [{ required: true, message: "请填写", trigger: ["blur", "change"] }],
|
|
sortNum: [{ required: true, message: "请输入", trigger: ["blur", "change"] }],
|
|
faIcon: [{ required: true, message: "请填写", trigger: ["blur", "change"] }]
|
|
},
|
|
firstMenus: [],
|
|
tableColumns: [
|
|
{ label: "排序编号", prop: "sortNum", sortable: true },
|
|
{ label: "所属平台", prop: "platform", sortable: true },
|
|
{ label: "模块名称", prop: "name" },
|
|
{ label: "模块图标", prop: "icon" },
|
|
{ label: "模块图标", prop: "faIcon" }
|
|
],
|
|
pageForm: {}
|
|
}
|
|
},
|
|
watch: {
|
|
"formData.icon"(val) {
|
|
this.$refs.form.validateField("icon", (errMsg) => {
|
|
console.log(errMsg)
|
|
})
|
|
}
|
|
},
|
|
methods: {
|
|
async openAdd() {
|
|
if (this.$refs.form) {
|
|
this.$refs.form.resetFields()
|
|
}
|
|
this.formData = {
|
|
sortNum: this.tableData.length + 1
|
|
}
|
|
this.formDialogVisible = true
|
|
},
|
|
openEdit(row) {
|
|
this.formDialogVisible = true
|
|
this.$nextTick(() => {
|
|
this.formData = { ...row }
|
|
})
|
|
},
|
|
|
|
async doSubmit() {
|
|
const valid = await this.$refs.form.validate()
|
|
if (!valid) return
|
|
const { id } = this.formData
|
|
const url = loc() + (id ? "/update" : "/insert")
|
|
const resp = await this.$axios.post(url, this.formData)
|
|
if (resp.code === 0) {
|
|
this.pageData()
|
|
this.formDialogVisible = false
|
|
this.$message.success(resp.msg)
|
|
}
|
|
},
|
|
|
|
doDelete(id) {
|
|
this.$confirm("您确定要删除吗?", "提示", {
|
|
confirmButtonText: "确定",
|
|
cancelButtonText: "取消",
|
|
type: "warning"
|
|
})
|
|
.then(() => {
|
|
this.$axios.post(loc() + "/delete", { id }).then((resp) => {
|
|
if (resp.code === 0) {
|
|
this.doSearch()
|
|
this.$message.success(resp.msg)
|
|
}
|
|
})
|
|
})
|
|
.catch(() => {})
|
|
}
|
|
},
|
|
created() {
|
|
setTimeout(() => {
|
|
if (this.dict.type.SYS_MENU_PLATFORM) {
|
|
this.pageForm.platform = this.dict.type.SYS_MENU_PLATFORM[0].code
|
|
this.pageData()
|
|
}
|
|
}, 500)
|
|
}
|
|
})
|
|
</script>
|
|
<!--#
|
|
}
|
|
#-->
|