|
@@ -1,75 +1,282 @@
|
|
|
<template>
|
|
|
- <div class="app-container">
|
|
|
- <el-table
|
|
|
- v-loading="listLoading"
|
|
|
- :data="list"
|
|
|
- element-loading-text="Loading"
|
|
|
- border
|
|
|
- highlight-current-row
|
|
|
- >
|
|
|
- <el-table-column align="center" label="ID" width="95">
|
|
|
- <template slot-scope="scope">
|
|
|
- {{ scope.$index }}
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="Title">
|
|
|
- <template slot-scope="scope">
|
|
|
- {{ scope.row.title }}
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="Author" width="110" align="center">
|
|
|
- <template slot-scope="scope">
|
|
|
- <span>{{ scope.row.author }}</span>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="Pageviews" width="110" align="center">
|
|
|
- <template slot-scope="scope">
|
|
|
- {{ scope.row.pageviews }}
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column class-name="status-col" label="Status" width="110" align="center">
|
|
|
- <template slot-scope="scope">
|
|
|
- <el-tag :type="scope.row.status | statusFilter">{{ scope.row.status }}</el-tag>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column align="center" prop="created_at" label="Display_time" width="200">
|
|
|
- <template slot-scope="scope">
|
|
|
- <i class="el-icon-time" />
|
|
|
- <span>{{ scope.row.display_time }}</span>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
+ <div class="faq-container">
|
|
|
+ <div class="filter-box">
|
|
|
+ <div class="list-filter">
|
|
|
+ <el-form ref="filterForm" :model="formData" inline>
|
|
|
+ <el-form-item label="问题标题">
|
|
|
+ <el-input v-model="formData.title" class="filter-item" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="问题内容">
|
|
|
+ <el-input v-model="formData.content" class="filter-item" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item class="filter-btn">
|
|
|
+ <el-button type="primary" @click="searchTable">查询</el-button>
|
|
|
+ <el-button type="danger" @click="resetForm">重置</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="faq-box">
|
|
|
+ <div class="list-button">
|
|
|
+ <el-button type="primary" @click="showEdit('ADD')">新增</el-button>
|
|
|
+ </div>
|
|
|
+ <div v-loading="loading" class="list-box">
|
|
|
+ <el-scrollbar class="list-scrollbar">
|
|
|
+ <div class="list-item-box">
|
|
|
+ <div v-for="item in tableData" :key="item.id" class="list-item">
|
|
|
+ <div class="item-header">
|
|
|
+ {{ item.title }}
|
|
|
+ </div>
|
|
|
+ <div class="item-content">
|
|
|
+ {{ item.content }}
|
|
|
+ </div>
|
|
|
+ <div class="item-footer">
|
|
|
+ <el-button type="text" icon="el-icon-tickets" @click="showEdit('VIEW', item)">详情</el-button>
|
|
|
+ <el-button type="text" icon="el-icon-edit" @click="showEdit('EDIT', item)">编辑</el-button>
|
|
|
+ <el-button type="text" icon="el-icon-delete" @click="deleteItem(item.id)">删除</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <i v-for="num in 3" :key="'padding'+num" class="list-item-padding" />
|
|
|
+ </div>
|
|
|
+ </el-scrollbar>
|
|
|
+ <div v-if="total > 0" class="page">
|
|
|
+ <el-pagination
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
+ :current-page="current"
|
|
|
+ :total="total"
|
|
|
+ :page-sizes="pageSizeAll"
|
|
|
+ :page-size="size"
|
|
|
+ @size-change="handleSizeChange"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <faq-edit ref="faqEdit" @refreshData="searchTable" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { fetchFaqList, pushDeleteFaq } from '@/api/faq'
|
|
|
+
|
|
|
+import { hasValidRecords } from '@/utils/convert'
|
|
|
+
|
|
|
+import FaqEdit from './FaqEdit'
|
|
|
|
|
|
export default {
|
|
|
- filters: {
|
|
|
- statusFilter(status) {
|
|
|
- const statusMap = {
|
|
|
- published: 'success',
|
|
|
- draft: 'gray',
|
|
|
- deleted: 'danger'
|
|
|
- }
|
|
|
- return statusMap[status]
|
|
|
- }
|
|
|
- },
|
|
|
+ name: 'Faq',
|
|
|
+ components: { FaqEdit },
|
|
|
data() {
|
|
|
return {
|
|
|
- list: null,
|
|
|
- listLoading: true
|
|
|
+ // table
|
|
|
+ current: 1,
|
|
|
+ size: 16,
|
|
|
+ total: 0,
|
|
|
+ pageSizeAll: [10, 16, 20, 50, 100, 200, 500],
|
|
|
+ tableData: [],
|
|
|
+ // filter
|
|
|
+ formData: {
|
|
|
+ title: '',
|
|
|
+ content: ''
|
|
|
+ },
|
|
|
+ // others
|
|
|
+ loading: false
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- this.fetchData()
|
|
|
+ this.searchTable()
|
|
|
},
|
|
|
methods: {
|
|
|
- fetchData() {
|
|
|
- this.listLoading = true
|
|
|
- this.list = []
|
|
|
- this.listLoading = false
|
|
|
+ // 改变每页显示条数
|
|
|
+ handleSizeChange(val) {
|
|
|
+ this.current = 1
|
|
|
+ this.size = val
|
|
|
+ this.getTablelist()
|
|
|
+ },
|
|
|
+ // 切换第几页
|
|
|
+ handleCurrentChange(val) {
|
|
|
+ this.current = val
|
|
|
+ this.getTablelist()
|
|
|
+ },
|
|
|
+ // 重置搜索项
|
|
|
+ resetForm(formName) {
|
|
|
+ this.$refs[formName].resetFields()
|
|
|
+ this.searchTable()
|
|
|
+ },
|
|
|
+ // 点击搜索按钮
|
|
|
+ searchTable() {
|
|
|
+ this.current = 1
|
|
|
+ this.getTablelist()
|
|
|
+ },
|
|
|
+ // 获取table数据
|
|
|
+ getTablelist() {
|
|
|
+ this.loading = true
|
|
|
+ const params = {
|
|
|
+ page: this.current,
|
|
|
+ size: this.size,
|
|
|
+ order: '',
|
|
|
+ params: {
|
|
|
+ delFlag: 0,
|
|
|
+ title: this.formData.title,
|
|
|
+ content: this.formData.content
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fetchFaqList(params).then(response => {
|
|
|
+ if (hasValidRecords(response)) {
|
|
|
+ this.tableData = response.data.records
|
|
|
+ this.total = response.data.total
|
|
|
+ } else {
|
|
|
+ this.tableData = []
|
|
|
+ this.total = 0
|
|
|
+ }
|
|
|
+ this.loading = false
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ this.loading = false
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ duration: 0,
|
|
|
+ showClose: true,
|
|
|
+ message: '获取列表出错: ' + error.message
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ showEdit(viewType, data) {
|
|
|
+ this.$refs['faqEdit'].open(viewType, data)
|
|
|
+ },
|
|
|
+ deleteItem(id) {
|
|
|
+ this.loading = true
|
|
|
+ pushDeleteFaq(id).then(res => {
|
|
|
+ this.$message.success('删除成功!')
|
|
|
+ this.getTablelist()
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ this.loading = false
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ duration: 0,
|
|
|
+ showClose: true,
|
|
|
+ message: '删除出错: ' + error.message
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.faq-container {
|
|
|
+ min-width: 900px;
|
|
|
+
|
|
|
+ .filter-box, .faq-box {
|
|
|
+ background-color: #fff;
|
|
|
+ padding: 10px 0 10px 20px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .filter-box {
|
|
|
+ margin-bottom: 16px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .list-filter {
|
|
|
+ height: 40px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .faq-box {
|
|
|
+ height: calc(100% - 76px);
|
|
|
+
|
|
|
+ .page {
|
|
|
+ margin-right: 5px;
|
|
|
+ text-align: right;
|
|
|
+ }
|
|
|
+
|
|
|
+ ::v-deep {
|
|
|
+ .el-scrollbar__wrap{
|
|
|
+ overflow-x: hidden;
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-scrollbar__bar.is-horizontal {
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .list-button {
|
|
|
+ height: 50px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .list-box {
|
|
|
+ height: calc(100% - 50px);
|
|
|
+ }
|
|
|
+
|
|
|
+ .list-scrollbar {
|
|
|
+ height: calc(100% - 32px);
|
|
|
+ }
|
|
|
+
|
|
|
+ .list-item-box {
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ justify-content: space-between;
|
|
|
+ margin-right: 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .list-item, .list-item-padding {
|
|
|
+ width: 420px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .list-item-padding {
|
|
|
+ height: 0;
|
|
|
+ display: block;
|
|
|
+ }
|
|
|
+
|
|
|
+ .list-item {
|
|
|
+ height: 200px;
|
|
|
+ border: 1px solid rgba(0,0,0,0.15);
|
|
|
+ border-radius: 4px;
|
|
|
+ margin-right: 5px;
|
|
|
+ margin-bottom: 16px;
|
|
|
+ position: relative;
|
|
|
+
|
|
|
+ .item-header, .item-content {
|
|
|
+ margin: 0 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .item-header {
|
|
|
+ height: 50px;
|
|
|
+ line-height: 50px;
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: bold;
|
|
|
+ color: rgba(0,0,0,0.85);
|
|
|
+ border-bottom: 1px solid rgba(0,0,0,0.09);
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ overflow: hidden;
|
|
|
+ white-space: nowrap;
|
|
|
+ }
|
|
|
+
|
|
|
+ .item-content {
|
|
|
+ overflow: hidden;
|
|
|
+ padding: 5px 0;
|
|
|
+ font-size: 14px;
|
|
|
+ line-height: 23px;
|
|
|
+ height: 100px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .item-footer {
|
|
|
+ width: 100%;
|
|
|
+ height: 50px;
|
|
|
+ line-height: 50px;
|
|
|
+ text-align: center;
|
|
|
+ font-size: 14px;
|
|
|
+ background: rgba(0,0,0,0.04);
|
|
|
+
|
|
|
+ .el-button {
|
|
|
+ width: calc(100% /3 - 20px / 3);
|
|
|
+ color: rgba(0,0,0,0.65);
|
|
|
+ }
|
|
|
+ .el-button+.el-button {
|
|
|
+ border-left: 1px solid rgba(0,0,0,0.10);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|
|
|
+
|