增加是否可评论

This commit is contained in:
aixianling
2022-05-25 11:55:34 +08:00
parent bcef93975e
commit 67d3ad9bca
2 changed files with 188 additions and 183 deletions

View File

@@ -1,73 +1,72 @@
<template> <template>
<div class="doc-circulation ailist-wrapper"> <div class="doc-circulation ailist-wrapper">
<keep-alive :include="['List']"> <keep-alive :include="['List']">
<component ref="component" :is="component" @change="onChange" :params="params" :instance="instance" :dict="dict"></component> <component ref="component" :is="component" @change="onChange" :params="params" :instance="instance" :dict="dict"/>
</keep-alive> </keep-alive>
</div> </div>
</template> </template>
<script> <script>
import List from './components/List' import List from './components/List'
import Add from './components/Add' import Add from './components/Add'
import Detail from './components/Detail' import Detail from './components/Detail'
export default { export default {
name: 'AppContentManage', name: 'AppContentManage',
label: '内容管理', label: '内容管理',
props: { props: {
instance: Function, instance: Function,
dict: Object dict: Object
}, },
data () { data() {
return { return {
component: 'List', component: 'List',
params: {}, params: {},
include: [] include: []
}
},
components: {
Add,
List,
Detail
},
created() {
this.dict.load("yesOrNo")
},
methods: {
onChange(data) {
if (data.type === 'Add') {
this.component = 'Add'
this.params = data.params
} }
},
components: { if (data.type === 'Detail') {
Add, this.component = 'Detail'
List, this.params = data.params
Detail }
},
mounted () { if (data.type === 'list') {
}, this.component = 'List'
this.params = data.params
methods: { this.$nextTick(() => {
onChange (data) { if (data.isRefresh) {
if (data.type === 'Add') { this.$refs.component.getList()
this.component = 'Add' }
this.params = data.params })
}
if (data.type === 'Detail') {
this.component = 'Detail'
this.params = data.params
}
if (data.type === 'list') {
this.component = 'List'
this.params = data.params
this.$nextTick(() => {
if (data.isRefresh) {
this.$refs.component.getList()
}
})
}
} }
} }
} }
}
</script> </script>
<style lang="scss"> <style lang="scss">
.doc-circulation { .doc-circulation {
height: 100%; height: 100%;
background: #F3F6F9; background: #F3F6F9;
overflow: auto; overflow: auto;
} }
</style> </style>

View File

@@ -9,7 +9,8 @@
<template #content> <template #content>
<el-form class="ai-form" :model="form" label-width="120px" ref="form"> <el-form class="ai-form" :model="form" label-width="120px" ref="form">
<el-form-item label="模块名称" style="width: 100%;" prop="moduleName" :rules="[{required: true, message: '请输入模块名称', trigger: 'blur'}]"> <el-form-item label="模块名称" style="width: 100%;" prop="moduleName" :rules="[{required: true, message: '请输入模块名称', trigger: 'blur'}]">
<el-input type="input" style="width: 300px" size="small" v-model="form.moduleName" clearable placeholder="请输入模块名称" maxlength="30" show-word-limit></el-input> <el-input type="input" style="width: 300px" size="small" v-model="form.moduleName" clearable placeholder="请输入模块名称" maxlength="30"
show-word-limit></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="menuName" label="菜单名称" :rules="[{required: true, message: '请选择菜单', trigger: 'change'}]"> <el-form-item prop="menuName" label="菜单名称" :rules="[{required: true, message: '请选择菜单', trigger: 'change'}]">
<el-input type="input" style="width: 300px" disabled size="small" v-model="form.menuName" clearable placeholder="请选择菜单"> <el-input type="input" style="width: 300px" disabled size="small" v-model="form.menuName" clearable placeholder="请选择菜单">
@@ -24,25 +25,30 @@
<el-radio label="1"></el-radio> <el-radio label="1"></el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="是否可评论" style="width: 100%;" prop="isComment" :rules="[{required: true, message: '请选择是否可评论'}]">
<el-radio-group v-model="form.isComment">
<el-radio v-for="op in dict.getDict('yseOrNo')" :label="op.dictValue">{{ op.dictName }}</el-radio>
</el-radio-group>
</el-form-item>
</el-form> </el-form>
</template> </template>
</ai-card> </ai-card>
<ai-dialog <ai-dialog
:visible.sync="isShowAdd" :visible.sync="isShowAdd"
width="880px" width="880px"
height="580px" height="580px"
title="选择菜单" title="选择菜单"
@close="onClose" @close="onClose"
@onConfirm="onConfirm"> @onConfirm="onConfirm">
<el-tree <el-tree
:data="treeData" :data="treeData"
node-key="id" node-key="id"
ref="tree" ref="tree"
@node-click="onChange" @node-click="onChange"
highlight-current highlight-current
:default-expanded-keys="defaultExpandedKeys" :default-expanded-keys="defaultExpandedKeys"
:default-checked-keys="defaulCheckedKeys" :default-checked-keys="defaulCheckedKeys"
:props="defaultProps"> :props="defaultProps">
</el-tree> </el-tree>
</ai-dialog> </ai-dialog>
</template> </template>
@@ -54,130 +60,130 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex' import {mapState} from 'vuex'
export default { export default {
name: 'Add', name: 'Add',
props: { props: {
instance: Function, instance: Function,
dict: Object, dict: Object,
params: Object params: Object
}, },
data () { data() {
return { return {
info: {}, info: {},
form: { form: {
moduleName: '', moduleName: '',
menuId: '', menuId: '',
menuName: '', menuName: '',
needExamine: '0' needExamine: '0'
}, },
isShowAdd: false, isShowAdd: false,
treeData: [], treeData: [],
id: '', id: '',
chooseNode: {}, chooseNode: {},
defaultExpandedKeys: [], defaultExpandedKeys: [],
defaulCheckedKeys: [], defaulCheckedKeys: [],
defaultProps: { defaultProps: {
children: 'subSet', children: 'subSet',
label: 'name', label: 'name',
disabled: e => { disabled: e => {
return e.type !== '1' return e.type !== '1'
}
} }
} }
}, }
},
computed: {
...mapState(['user']) computed: {
}, ...mapState(['user'])
},
created () {
this.getMenuList() created() {
if (this.params && this.params.id) { this.getMenuList()
this.id = this.params.id if (this.params && this.params.id) {
this.getInfo(this.params.id) this.id = this.params.id
} this.getInfo(this.params.id)
}, }
},
methods: {
getInfo (id) { methods: {
this.instance.post(`/app/appcontentmoduleinfo/queryDetailById?id=${id}`).then(res => { getInfo(id) {
if (res.code === 0) { this.instance.post(`/app/appcontentmoduleinfo/queryDetailById?id=${id}`).then(res => {
this.form = res.data if (res.code === 0) {
} this.form = res.data
}) }
}, })
},
showAdd () {
this.isShowAdd = true showAdd() {
this.isShowAdd = true
this.$nextTick(() => {
this.$refs.tree.setCurrentKey(this.form.menuId) this.$nextTick(() => {
this.defaultExpandedKeys = [this.form.menuId] this.$refs.tree.setCurrentKey(this.form.menuId)
this.chooseNode = { this.defaultExpandedKeys = [this.form.menuId]
menuId: this.form.menuId, this.chooseNode = {
menuName: this.form.menuName, menuId: this.form.menuId,
type: '1' menuName: this.form.menuName,
} type: '1'
}) }
}, })
},
onClose () {
onClose() {
},
},
onConfirm () {
if (this.chooseNode.type === '1') { onConfirm() {
this.form.menuId = this.chooseNode.id if (this.chooseNode.type === '1') {
this.form.menuName = this.chooseNode.name this.form.menuId = this.chooseNode.id
this.form.menuName = this.chooseNode.name
this.isShowAdd = false
} else { this.isShowAdd = false
this.$message.error('无法选择') } else {
} this.$message.error('无法选择')
}, }
},
onChange (e) {
this.chooseNode = e onChange(e) {
}, this.chooseNode = e
},
getMenuList () {
this.instance.post(`/admin/menu/menuTree?containPermission=0`).then(res => { getMenuList() {
if (res.code === 0) { this.instance.post(`/admin/menu/menuTree?containPermission=0`).then(res => {
this.treeData = res.data if (res.code === 0) {
} this.treeData = res.data
}) }
}, })
},
confirm () {
this.$refs.form.validate((valid) => { confirm() {
if (valid) { this.$refs.form.validate((valid) => {
this.instance.post(`/app/appcontentmoduleinfo/addOrUpdate`, { if (valid) {
...this.form, this.instance.post(`/app/appcontentmoduleinfo/addOrUpdate`, {
id: this.params.id || '' ...this.form,
}).then(res => { id: this.params.id || ''
if (res.code == 0) { }).then(res => {
this.$message.success('提交成功') if (res.code == 0) {
setTimeout(() => { this.$message.success('提交成功')
this.cancel(true) setTimeout(() => {
}, 600) this.cancel(true)
} }, 600)
}) }
} })
}) }
}, })
},
cancel (isRefresh) {
this.$emit('change', { cancel(isRefresh) {
type: 'list', this.$emit('change', {
isRefresh: !!isRefresh type: 'list',
}) isRefresh: !!isRefresh
} })
} }
} }
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">