Browse Source

temp save

liujq 4 years ago
parent
commit
7597bdf37e

+ 15 - 0
src/api/user.js

@@ -16,4 +16,19 @@ export default {
   admadmindel: params => { // 用户删除
     return getRequestNoSort('/adm/admin/del', params, 'loading')
   },
+  admquestionlist: params => { // 问答-问题列表
+    return getRequest('/adm/question/list', params)
+  },
+  admanswerlist: params => { // 问答-回答列表
+    return getRequest('/adm/answer/list', params)
+  },
+  admansweradd: params => { // 问答-添加回答
+    return getRequestNoSort('/adm/answer/add', params, 'loading')
+  },
+  admquestiondel: params => { // 问答-问题删除
+    return getRequestNoSort('/adm/question/del', params, 'loading')
+  },
+  admanswerdel: params => { // 问答-回答删除
+    return getRequestNoSort('/adm/answer/del', params, 'loading')
+  },
 }

+ 11 - 0
src/router/index.js

@@ -122,6 +122,17 @@ export const moreRoutes = [
   //     meta: { title: '用户管理', icon: 'dashboard', affix: true }
   //   }]
   // },
+  {
+    path: '/qa',
+    component: Layout,
+    redirect: '/qa/index',
+    children: [{
+      path: 'index',
+      name: 'QaIndex',
+      component: () => import('@/views/qa/index'),
+      meta: { title: '问答管理', icon: 'dashboard' }
+    }]
+  },
 ]
 export const constantRoutes = [
   {

+ 4 - 3
src/views/house/index.vue

@@ -14,7 +14,7 @@
       @currentChange="pageHandle"
       :isAdd="true"
       @add="openPopup"
-      :operationsDefaultLength="5"
+      :operationsDefaultLength="6"
     />
     <popup-edit
       :isShow="isDtlShow"
@@ -106,12 +106,13 @@ export default {
         { label: '创建时间', prop: 'create_at' },
         { label: '更新人', prop: 'update_by' },
         { label: '更新时间', prop: 'update_at' },
-        { label: '操作', width: 400, type: 'handle2', operations:
+        { label: '操作', width: 460, type: 'handle2', operations:
           [
             { label: '编辑信息', func: this.openPopup, btnType: 'primary' },
-            { label: '编辑相册', func: this.openPhotoPopup, btnType: 'success' },
+            { label: '编辑相册', func: this.openPhotoPopup, btnType: 'info' },
             { label: '楼盘动态', func: this.openNews, btnType: 'info' },
             { label: '模块主题', func: this.openTHEPopup, btnType: 'info' },
+            { label: '楼盘评论', func: this.openTHEPopup, btnType: 'info' },
             { label: '删除', func: this.delHandle, btnType: 'danger' },
           ]
         }

+ 95 - 0
src/views/qa/components/popup/answer.vue

@@ -0,0 +1,95 @@
+<template>
+  <div>
+    <el-dialog
+      :show-close="false"
+      :close-on-click-modal="false"
+      :visible.sync="isShow"
+      title="查看回答"
+      :fullscreen="false"
+      width="700px"
+      custom-class="xl-dialog"
+      center
+    >
+      <table-list
+        :list-loading="listLoading"
+        :data="aList"
+        :columns="listConfig"
+        :current-page="currentPage"
+        :page-size="pageSize"
+        :total-records="totalRecords"
+        @currentChange="pageHandle"
+      />
+      <div class="xl-form">
+        <div class="xl-form-footer">
+          <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
+        </div>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+<script>
+import baseTable from '_m/baseTable.js'
+export default {
+  components: {},
+  mixins: [...mixins, baseTable],
+  props: {
+    isShow: Boolean,
+    curObj: Object
+  },
+  inject: ['parentData'],
+  data() {
+    return {
+      apiStr: 'user.admanswerlist',
+      noCreated: true,
+      searchForm: {},
+      aList: [],
+    }
+  },
+  mounted() {
+    this.listConfig = {
+      rows: [
+        { label: '回答内容', prop: 'answer_cont', fullShow: true, minWidth: 200, align: 'left' },
+        { label: '昵称', prop: 'nickname' },
+        { label: '头像', prop: 'avatar', type: 'img' },
+        { label: '回答时间', prop: 'create_at' },
+        { label: '操作', width: 80, type: 'handle2', operations:
+          [
+            { label: '删除', func: this.delHandle, btnType: 'danger' },
+          ]
+        }
+      ]
+    }
+  },
+  watch: {
+    isShow: function(val) {
+      if (val) {
+        this.searchForm = {question_id: this.curObj.id}
+        this.fetchData()
+      }
+    },
+  },
+  methods: {
+    getMoreData (res) {
+      const data = res.answer_list || {}
+      this.aList = data.list || []
+      if (this.currentPage === 1) this.pageSize = data.page_size || 1
+      this.totalRecords = data.total ? Number(data.total) : 0
+    },
+    delHandle(row) {
+      this.$msg(`您确定要删除该问题吗?`, 'confirm', () => {
+        this.$api.user.admanswerdel({
+          answer_id: row.answer_id
+        }).then(data => {
+          this.$msgs(`已删除!`)
+          this.fetchData()
+        })
+      }, null, true)
+    },
+    close(str) {
+      this.$emit('close')
+    },
+  }
+}
+</script>
+<style lang="scss" scoped>
+</style>

+ 32 - 0
src/views/qa/components/searchForm/Index.vue

@@ -0,0 +1,32 @@
+<template>
+  <base-form slot="content" ref="ruleForm" :data="searchData">
+    <div slot="footer">
+      <el-button :loading="listLoading" icon="el-icon-search" class="xl-form-btn bgc1" @click="searchHandle">查询</el-button>
+      <!-- <el-button :loading="listLoading" icon="el-icon-document" class="xl-form-btn bgc2" @click="toExportExcel">导出{{ this.$route.meta.title }}信息</el-button> -->
+    </div>
+  </base-form>
+</template>
+<script>
+export default {
+  mixins: [],
+  props: {
+    listLoading: Boolean
+  },
+  inject: ['parentData'],
+  data() {
+    return {
+      searchData: [
+        { label: '问题', key: 'question_cont' },
+        { label: '标签', key: 'question_tag', type: 'select', options: this.$dictData.question_tag},
+      ]
+    }
+  },
+  methods: {
+    searchHandle() {
+      const oldform = this.$refs.ruleForm.baseForm
+      const newForm = { ...oldform }
+      this.$emit('change', newForm)
+    }
+  }
+}
+</script>

+ 103 - 0
src/views/qa/index.vue

@@ -0,0 +1,103 @@
+<template>
+  <div class="app-container">
+    <search-form
+      :list-loading="listLoading"
+      @change="searchHandle"
+    />
+    <table-list
+      :list-loading="listLoading"
+      :data="tableData2"
+      :columns="listConfig"
+      :current-page="currentPage"
+      :page-size="pageSize"
+      :total-records="totalRecords"
+      @currentChange="pageHandle"
+    />
+    <popup-edit
+      :isShow="isDtlShow"
+      :curObj="curObj"
+      @close="closePopup"
+    />
+  </div>
+</template>
+<script>
+import { arrToObj } from '@/utils'
+import SearchForm from './components/searchForm/Index'
+import PopupEdit from './components/popup/answer'
+import baseTable from '_m/baseTable.js'
+export default {
+  name: 'index',
+  components: {
+    SearchForm,
+    PopupEdit,
+  },
+  provide() {
+    return {
+      parentData: this
+    }
+  },
+  mixins: [baseTable],
+  data() {
+    return {
+      apiStr: 'user.admquestionlist',
+      searchForm: null,
+      isDtlShow: false,
+      curObj: {},
+    }
+  },
+  computed: {
+    tableData2() {
+      const arr = [...this.tableData]
+      arr.map(item => {
+        const question_tag = item.question_tag ? item.question_tag.split(',') : []
+        const qtName = question_tag.map(v => {
+          return arrToObj(this.$dictData.question_tag)[v]
+        })
+        item.qtName = qtName.join(',')
+      })
+      return arr
+    }
+  },
+  created() {},
+  mounted() {
+    this.listConfig = {
+      rows: [
+        { label: '问题内容', prop: 'question_cont', fullShow: true, minWidth: 200, align: 'left' },
+        { label: '标签', prop: 'qtName' },
+        { label: '昵称', prop: 'nickname' },
+        { label: '头像', prop: 'avatar', type: 'img' },
+        { label: '提问时间', prop: 'create_at' },
+        { label: '操作', width: 200, type: 'handle2', operations:
+          [
+            { label: '查看回答', func: this.openPopup, btnType: 'primary' },
+            { label: '删除', func: this.delHandle, btnType: 'danger' },
+          ]
+        }
+      ]
+    }
+  },
+  methods: {
+    delHandle(row) {
+      this.$msg(`您确定要删除该问题吗?`, 'confirm', () => {
+        this.$api.user.admquestiondel({
+          question_id: row.id
+        }).then(data => {
+          this.$msgs(`已删除!`)
+          this.fetchData()
+        })
+      }, null, true)
+    },
+    openPopup(row) {
+      if (row && row.id) {
+        this.curObj = row
+      } else {
+        this.curObj = {}
+      }
+      this.isDtlShow = true
+    },
+    closePopup(obj) {
+      this.isDtlShow = false
+    }
+  }
+}
+</script>