first commit
This commit is contained in:
@@ -0,0 +1,226 @@
|
||||
<!--#
|
||||
layout("/layouts/platform.html"){
|
||||
#-->
|
||||
|
||||
<div id="app">
|
||||
<guava ref="guava">
|
||||
<!-- <el-card shadow="never">
|
||||
|
||||
</el-card>-->
|
||||
|
||||
<el-card class="mt10" shadow="never">
|
||||
<template #header>
|
||||
<div style="display:flex;justify-content: space-between;align-items: center">
|
||||
<h3 style="color: #1867b0">模块中心</h3>
|
||||
<el-button size="medium" type="primary" @click="openAdd">添加模块</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<el-table :data="tableData" :size="tableSize" @sort-change="pageOrder"
|
||||
align="center"
|
||||
header-align="center">
|
||||
<!--<el-table-column :index="indexMethod" align="center" header-align="center" label="序号" type="index"
|
||||
width="80px"></el-table-column>-->
|
||||
<el-table-column
|
||||
:label="column.label"
|
||||
:prop="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
|
||||
@click="viewImage(row.icon[0].id)"
|
||||
style="height: 30px;width: 30px"
|
||||
:src="APP_DOMAIN+FILE_STREAM_PREVIEW_ADDRESS+'?id='+row.icon[0].id"
|
||||
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=='containsMenu'">
|
||||
{{firstMenus.filter(v=>row.containsMenu.includes(v.id)).map(v=>v.name).join('、')}}
|
||||
</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>
|
||||
</el-card>
|
||||
|
||||
<template #edit>
|
||||
<el-form :model="formData" :rules="formRules" label-width="120px" ref="form">
|
||||
<el-form-item label="模块名称" prop="moduleName">
|
||||
<el-input v-model="formData.moduleName" maxlength="8"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="模块图标" prop="icon">
|
||||
<file-upload max="1" :type="['png']" :files.sync="formData.icon"></file-upload>
|
||||
</el-form-item>
|
||||
<el-form-item label="包含菜单" prop="containsMenu">
|
||||
<el-checkbox-group v-model="formData.containsMenu">
|
||||
<el-checkbox v-for="item in firstMenus" :label="item.id"
|
||||
:disabled="menuCheckBoxDisabled(item.id)">
|
||||
{{item.name}}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</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="$refs.guava.index()">取消</el-button>
|
||||
<el-button type="primary" @click="doSubmit">确定</el-button>
|
||||
</el-row>
|
||||
|
||||
</template>
|
||||
|
||||
</guava>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const vue = new Vue({
|
||||
el: '#app',
|
||||
mixins: [initTableMixins],
|
||||
data() {
|
||||
return {
|
||||
formDialogVisible: false,
|
||||
formData: {
|
||||
id: null,
|
||||
moduleName: null,
|
||||
icon: [],
|
||||
containsMenu: [],
|
||||
sortNum: null
|
||||
},
|
||||
formRules: {
|
||||
moduleName: [{required: true, message: '请填写', trigger: ['blur', 'change']}],
|
||||
icon: [{required: true, message: '请填写', trigger: ['blur', 'change']}],
|
||||
containsMenu: [{required: true, message: '请选择', trigger: ['blur', 'change']}],
|
||||
sortNum: [{required: true, message: '请输入', trigger: ['blur', 'change']}],
|
||||
},
|
||||
firstMenus: [],
|
||||
tableColumns: [
|
||||
{label: '排序编号', prop: 'sortNum', sortable: true},
|
||||
{label: '模块名称', prop: 'moduleName'},
|
||||
{label: '模块图标', prop: 'icon'},
|
||||
{label: '包含菜单', prop: 'containsMenu'}
|
||||
],
|
||||
hasSetMenus: [],
|
||||
cloneContainsMenu: []
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'formData.icon'(val) {
|
||||
this.$refs.form.validateField('icon', (errMsg) => {
|
||||
console.log(errMsg)
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async openAdd() {
|
||||
await this.getHasSetMenus()
|
||||
if (this.$refs.form) {
|
||||
this.$refs.form.resetFields()
|
||||
}
|
||||
this.formData = {
|
||||
id: null,
|
||||
moduleName: null,
|
||||
icon: [],
|
||||
containsMenu: [],
|
||||
sortNum: this.tableData.length + 1
|
||||
}
|
||||
this.$refs.guava.edit()
|
||||
},
|
||||
async findFirstMenus() {
|
||||
const resp = await $.get(loc() + '/findFirstMenus')
|
||||
if (resp.code === 0) {
|
||||
this.firstMenus = resp.data
|
||||
}
|
||||
},
|
||||
async doSubmit() {
|
||||
const valid = await this.$refs.form.validate()
|
||||
if (!valid) return
|
||||
const {id} = this.formData
|
||||
const url = loc() + (id ? '/doEdit' : '/doAdd')
|
||||
const resp = await $.post(url, {entranceModule: JSON.stringify(this.formData)})
|
||||
if (resp.code === 0) {
|
||||
this.pageData()
|
||||
this.notifySuccess(resp.msg)
|
||||
this.$refs.guava.index()
|
||||
if (headerNavBarVueApp) {
|
||||
headerNavBarVueApp.init()
|
||||
}
|
||||
} else {
|
||||
this.notifyWarning(resp.msg)
|
||||
}
|
||||
},
|
||||
async pageData() {
|
||||
sublime.showLoadingbar()
|
||||
const resp = await $.post(loc() + '/pageData')
|
||||
sublime.closeLoadingbar()
|
||||
if (resp.code === 0) {
|
||||
this.tableData = resp.data
|
||||
} else {
|
||||
this.notifyWarning(resp.msg)
|
||||
}
|
||||
},
|
||||
async doDelete(id) {
|
||||
const confirm = await this.$confirm('您确定要删除吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
if (confirm !== 'confirm') return
|
||||
const resp = await $.post(loc() + '/doDelete/' + id)
|
||||
if (resp.code === 0) {
|
||||
this.doSearch()
|
||||
this.notifySuccess(resp.msg)
|
||||
if (headerNavBarVueApp) {
|
||||
headerNavBarVueApp.init()
|
||||
}
|
||||
} else {
|
||||
this.notifyWarning(resp.msg)
|
||||
}
|
||||
},
|
||||
openEdit(row) {
|
||||
this.getHasSetMenus()
|
||||
this.$refs.guava.edit()
|
||||
this.formData = {...row}
|
||||
this.cloneContainsMenu = this.formData.containsMenu
|
||||
this.$nextTick(() => {
|
||||
this.$refs.form.validateField('icon', (errMsg) => {
|
||||
console.log(errMsg)
|
||||
})
|
||||
})
|
||||
},
|
||||
async getHasSetMenus() {
|
||||
const {data} = await $.get(loc() + '/getHasSetMenus')
|
||||
this.hasSetMenus = data
|
||||
console.log(data)
|
||||
},
|
||||
menuCheckBoxDisabled(id) {
|
||||
if (this.formData.id == null) {
|
||||
return this.hasSetMenus.includes(id)
|
||||
} else {
|
||||
return this.hasSetMenus.filter(v => !this.cloneContainsMenu.includes(v)).includes(id)
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.pageData()
|
||||
this.findFirstMenus()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
Reference in New Issue
Block a user