目录代码整合

This commit is contained in:
aixianling
2022-05-10 20:02:37 +08:00
parent 71049f7f65
commit 036ee91533
324 changed files with 4 additions and 8321 deletions

View File

@@ -0,0 +1,113 @@
<template>
<ai-detail>
<template slot="title">
<ai-title :title="params.id ? '编辑小程序公告' : '添加小程序公告'" isShowBack isShowBottomBorder @onBackClick="cancel(false)">
</ai-title>
</template>
<template slot="content">
<ai-card title="基本信息">
<template #content>
<el-form ref="form" class="ai-form" :model="form" label-width="110px" label-position="right">
<el-form-item label="标题" style="width: 100%;" prop="title" :rules="[{ required: true, message: '请输入标题', trigger: 'blur' }]">
<el-input size="small" placeholder="请输入标题" :maxlength="30" v-model="form.title"></el-input>
</el-form-item>
<el-form-item label="发布组织" style="width: 100%;" prop="publishUnitName" :rules="[{ required: true, message: '请输入发布组织', trigger: 'blur' }]">
<el-input size="small" placeholder="请输入发布组织" :maxlength="50" v-model="form.publishUnitName"></el-input>
</el-form-item>
<el-form-item label="正文" style="width: 100%;" prop="content">
<ai-editor v-model="form.content" :instance="instance" />
</el-form-item>
<el-form-item label="图片" style="width: 100%;" prop="images">
<ai-uploader v-model="form.images" :instance="instance" :limit="9" isShowTip></ai-uploader>
</el-form-item>
</el-form>
</template>
</ai-card>
</template>
<template #footer>
<el-button @click="cancel">取消</el-button>
<el-button type="primary" @click="confirm">提交</el-button>
</template>
</ai-detail>
</template>
<script>
export default {
name: 'Add',
props: {
instance: Function,
dict: Object,
params: Object
},
data () {
return {
info: {},
form: {
title: '',
content: '',
publishUnitName: '',
images: []
},
id: ''
}
},
created () {
if (this.params && this.params.id) {
this.id = this.params.id
this.getInfo(this.params.id)
}
},
methods: {
getInfo (id) {
this.instance.post(`/app/appmininotice/queryDetailById?id=${id}`).then(res => {
if (res.code === 0) {
this.form = {
...res.data,
images: res.data.images ? JSON.parse(res.data.images) : []
}
}
})
},
onClose () {
this.form.explain = ''
},
confirm () {
this.$refs.form.validate((valid) => {
if (valid) {
if (!this.form.content && !this.form.images.length) {
return this.$message.error('请输入正文或上传图片')
}
this.instance.post(`/app/appmininotice/addOrUpdate`, {
...this.form,
images: this.form.images ? JSON.stringify(this.form.images) : []
}).then(res => {
if (res.code == 0) {
this.$message.success('提交成功')
setTimeout(() => {
this.cancel(true)
}, 600)
}
})
}
})
},
cancel (isRefresh) {
this.$emit('change', {
type: 'list',
isRefresh: !!isRefresh
})
}
}
}
</script>
<style scoped lang="scss">
</style>

View File

@@ -0,0 +1,71 @@
<template>
<ai-detail>
<template slot="title">
<ai-title title="详情" isShowBack isShowBottomBorder @onBackClick="cancel(false)">
</ai-title>
</template>
<template slot="content">
<ai-card title="基本信息">
<template #content>
<ai-wrapper>
<ai-info-item label="标题" isLine :value="info.title"></ai-info-item>
<ai-info-item label="发布组织" isLine :value="info.publishUnitName"></ai-info-item>
<ai-info-item label="正文" isLine>
<AiArticle :value="info.content"></AiArticle>
</ai-info-item>
<ai-info-item label="图片" isLine>
<ai-uploader v-model="info.images" disabled :instance="instance" :limit="9"></ai-uploader>
</ai-info-item>
</ai-wrapper>
</template>
</ai-card>
</template>
</ai-detail>
</template>
<script>
export default {
name: 'Detail',
props: {
instance: Function,
dict: Object,
params: Object
},
data () {
return {
info: {},
id: ''
}
},
created () {
if (this.params && this.params.id) {
this.id = this.params.id
this.getInfo(this.params.id)
}
},
methods: {
getInfo (id) {
this.instance.post(`/app/appmininotice/queryDetailById?id=${id}`).then(res => {
if (res.code === 0) {
this.info = res.data
this.info.images = res.data.images ? JSON.parse(res.data.images) : []
}
})
},
cancel (isRefresh) {
this.$emit('change', {
type: 'list',
isRefresh: !!isRefresh
})
}
}
}
</script>
<style scoped lang="scss">
</style>

View File

@@ -0,0 +1,138 @@
<template>
<ai-list class="notice">
<template slot="title">
<ai-title title="小程序公告" isShowBottomBorder></ai-title>
</template>
<template slot="content">
<ai-search-bar class="search-bar">
<template #left>
<el-button size="small" type="primary" icon="iconfont iconAdd" @click="toAdd('')">添加</el-button>
</template>
<template slot="right">
<el-input
v-model="search.title"
class="search-input"
size="small"
v-throttle="() => {search.current = 1, getList()}"
placeholder="请输入标题"
clearable
@change="getList"
@clear="search.current = 1, search.title = '', getList()"
suffix-icon="iconfont iconSearch">
</el-input>
</template>
</ai-search-bar>
<ai-table
:tableData="tableData"
:col-configs="colConfigs"
:total="total"
style="margin-top: 6px;"
:current.sync="search.current"
:size.sync="search.size"
@getList="getList">
<el-table-column slot="tags" label="标签">
<template slot-scope="{ row }">
<div class="table-tags">
<el-tag type="info" v-for="(item, index) in row.tags" size="small" :key="index">{{ item }}</el-tag>
</div>
</template>
</el-table-column>
<el-table-column slot="options" width="180px" fixed="right" label="操作" align="center">
<div class="table-options" slot-scope="{ row }">
<el-button type="text" @click="toDetail(row.id)">详情</el-button>
<el-button type="text" @click="toAdd(row.id)">编辑</el-button>
<el-button type="text" @click="remove(row.id)">删除</el-button>
</div>
</el-table-column>
</ai-table>
</template>
</ai-list>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'List',
props: {
instance: Function,
dict: Object
},
data() {
return {
search: {
current: 1,
size: 10,
title: ''
},
currIndex: -1,
areaList: [],
total: 10,
colConfigs: [
{prop: 'title', label: '标题', align: 'left'},
{prop: 'createUserName', label: '发布人', align: 'center' },
{prop: 'publishUnitName', label: '发布组织', align: 'center'},
{prop: 'createTime', label: '发布时间', align: 'center' },
{slot: 'options', label: '操作'}
],
tableData: []
}
},
computed: {
...mapState(['user'])
},
mounted() {
this.getList()
},
methods: {
getList() {
this.instance.post(`/app/appmininotice/list`, null, {
params: {
...this.search
}
}).then(res => {
if (res.code == 0) {
this.tableData = res.data.records
this.total = res.data.total
}
})
},
remove(id) {
this.$confirm('确定删除该数据?').then(() => {
this.instance.post(`/app/appmininotice/delete?ids=${id}`).then(res => {
if (res.code == 0) {
this.$message.success('删除成功!')
this.getList()
}
})
})
},
toDetail (id) {
this.$emit('change', {
type: 'Detail',
params: {
id: id || ''
}
})
},
toAdd(id) {
this.$emit('change', {
type: 'Add',
params: {
id: id || ''
}
})
}
}
}
</script>
<style lang="scss" scoped>
</style>