Bladeren bron

temp save

liujq 4 jaren geleden
bovenliggende
commit
ee7687009f

+ 3 - 0
src/api/user.js

@@ -22,6 +22,9 @@ export default {
   admanswerlist: params => { // 问答-回答列表
     return getRequest('/adm/answer/list', params)
   },
+  admquestionadd: params => { // 问答-添加问题
+    return getRequestNoSort('/adm/question/add', params, 'loading')
+  },
   admansweradd: params => { // 问答-添加回答
     return getRequestNoSort('/adm/answer/add', params, 'loading')
   },

+ 5 - 0
src/views/house/components/searchForm/Index.vue

@@ -2,6 +2,7 @@
   <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-plus" class="xl-form-btn bgc2" @click="addHandle">添加</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>
@@ -22,6 +23,10 @@ export default {
     this.getDef()
   },
   methods: {
+    addHandle () {
+      this.parentData.isDtlShow = true
+      this.parentData.curObj = {}
+    },
     subwayLineChange (val) {
       this.getDef('change')
     },

+ 94 - 0
src/views/qa/components/popup/AEdit.vue

@@ -0,0 +1,94 @@
+<template>
+  <div>
+    <el-dialog
+      v-loading="loading"
+      :show-close="false"
+      :close-on-click-modal="false"
+      :visible.sync="isShow"
+      :title="'我来回答'"
+      :fullscreen="false"
+      width="700px"
+      custom-class="xl-dialog"
+      center
+    >
+      <base-form ref="ruleForm" class="lib-edit" :data="formData" :is-inline="false" label-width="110px">
+        <div slot="footer" style="padding-top: 20px;">
+          <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
+          <el-button class="xl-form-btn t1" @click="close('confirm')">确定</el-button>
+        </div>
+      </base-form>
+    </el-dialog>
+  </div>
+</template>
+<script>
+export default {
+  components: { },
+  mixins,
+  props: {
+    isShow: Boolean,
+    curObj: Object
+  },
+  inject: ['parentData'],
+  data() {
+    return {
+      formData: [],
+      loading: true,
+      cObj: {},
+      isShowMap: false
+    }
+  },
+  watch: {
+    isShow: function(val) {
+      if (val) {
+        this.getDef()
+      }
+    },
+  },
+  methods: {
+    getDef() {
+      let disabled = false
+      if (this.curObj.id) disabled = true
+      this.formData = [
+        { label: '问题', key: 'question_cont', type: 'textarea', disabled },
+        { label: '回答', key: 'answer_cont', type: 'textarea', rules: 1 },
+      ]
+      this.setDefaultValue(this.curObj)
+    },
+    close(str) {
+      if (str === 'confirm') {
+        this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
+          if (valid) {
+            const oldform = this.$refs.ruleForm.baseForm
+            const newForm = { ...oldform }
+            if (this.curObj.id) {
+              newForm.question_id = this.curObj.id
+            }
+            let apiStr = 'admansweradd'
+            if (newForm.id) apiStr = 'admansweradd'
+            delete newForm.question_cont
+            this.$api.user[apiStr](newForm).then(data => {
+              this.$msgs(newForm.id ? '编辑成功' : '新增成功')
+              this.$emit('close', newForm)
+            })
+          }
+        })
+      } else {
+        this.$emit('close')
+        this.setDefaultValue()
+      }
+    }
+  }
+}
+</script>
+<style lang="scss" scoped>
+@import '../../../../styles/libEdit.scss';
+.lib-edit {
+  padding-top: 0;
+  ::v-deep .el-form-item {
+    margin-bottom: 10px;
+  }
+  ::v-deep .el-date-editor.el-input {
+    width: 100%;
+  }
+}
+</style>

+ 93 - 0
src/views/qa/components/popup/QEdit.vue

@@ -0,0 +1,93 @@
+<template>
+  <div>
+    <el-dialog
+      v-loading="loading"
+      :show-close="false"
+      :close-on-click-modal="false"
+      :visible.sync="isShow"
+      :title="curObj.id ? '编辑问题' : '新增问题'"
+      :fullscreen="false"
+      width="700px"
+      custom-class="xl-dialog"
+      center
+    >
+      <base-form ref="ruleForm" class="lib-edit" :data="formData" :is-inline="false" label-width="110px">
+        <div slot="footer" style="padding-top: 20px;">
+          <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
+          <el-button class="xl-form-btn t1" @click="close('confirm')">确定</el-button>
+        </div>
+      </base-form>
+    </el-dialog>
+  </div>
+</template>
+<script>
+export default {
+  components: { },
+  mixins,
+  props: {
+    isShow: Boolean,
+    curObj: Object
+  },
+  inject: ['parentData'],
+  data() {
+    return {
+      formData: [],
+      loading: true,
+      cObj: {},
+      isShowMap: false
+    }
+  },
+  watch: {
+    isShow: function(val) {
+      if (val) {
+        this.getDef()
+      }
+    },
+  },
+  methods: {
+    getDef() {
+      let disabled = false
+      if (this.curObj.id) disabled = true
+      this.formData = [
+        { label: '标签', key: 'question_tag', multiple: true, rules: 1, type: 'select', options: this.$dictData.question_tag },
+        { label: '问题', key: 'question_cont', type: 'textarea', rules: 1 },
+      ]
+    },
+    close(str) {
+      if (str === 'confirm') {
+        this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
+          if (valid) {
+            const oldform = this.$refs.ruleForm.baseForm
+            const newForm = { ...oldform }
+            if (this.curObj.id) {
+              newForm.id = this.curObj.id
+            }
+            let apiStr = 'admquestionadd'
+            newForm.question_tag = newForm.question_tag.join(',')
+            if (newForm.id) apiStr = 'admquestionadd'
+            this.$api.user[apiStr](newForm).then(data => {
+              this.$msgs(newForm.id ? '编辑成功' : '新增成功')
+              this.$emit('close', newForm)
+            })
+          }
+        })
+      } else {
+        this.$emit('close')
+        this.setDefaultValue()
+      }
+    }
+  }
+}
+</script>
+<style lang="scss" scoped>
+@import '../../../../styles/libEdit.scss';
+.lib-edit {
+  padding-top: 0;
+  ::v-deep .el-form-item {
+    margin-bottom: 10px;
+  }
+  ::v-deep .el-date-editor.el-input {
+    width: 100%;
+  }
+}
+</style>

+ 47 - 4
src/views/qa/index.vue

@@ -12,24 +12,41 @@
       :page-size="pageSize"
       :total-records="totalRecords"
       @currentChange="pageHandle"
+      :isAdd="true"
+      @add="openQPopup"
+      :operationsDefaultLength="6"
     />
     <popup-edit
       :isShow="isDtlShow"
       :curObj="curObj"
       @close="closePopup"
     />
+    <q-edit
+      :isShow="isQShow"
+      :curObj="curObj"
+      @close="closeQPopup"
+    />
+    <a-edit
+      :isShow="isAShow"
+      :curObj="curObj"
+      @close="closeAPopup"
+    />
   </div>
 </template>
 <script>
 import { arrToObj } from '@/utils'
 import SearchForm from './components/searchForm/Index'
 import PopupEdit from './components/popup/answer'
+import QEdit from './components/popup/QEdit'
+import AEdit from './components/popup/AEdit'
 import baseTable from '_m/baseTable.js'
 export default {
   name: 'index',
   components: {
     SearchForm,
     PopupEdit,
+    QEdit,
+    AEdit,
   },
   provide() {
     return {
@@ -43,6 +60,8 @@ export default {
       searchForm: null,
       isDtlShow: false,
       curObj: {},
+      isQShow: false,
+      isAShow: false,
     }
   },
   computed: {
@@ -64,12 +83,13 @@ export default {
       rows: [
         { label: '问题内容', prop: 'question_cont', fullShow: true, minWidth: 200, align: 'left' },
         { label: '标签', prop: 'qtName' },
-        { label: '昵称', prop: 'nickname' },
-        { label: '头像', prop: 'avatar', type: 'img' },
+        // { label: '昵称', prop: 'nickname' },
+        // { label: '头像', prop: 'avatar', type: 'img' },
         { label: '提问时间', prop: 'create_at' },
-        { label: '操作', width: 200, type: 'handle2', operations:
+        { label: '操作', width: 240, type: 'handle2', operations:
           [
-            { label: '查看回答', func: this.openPopup, btnType: 'primary' },
+            { label: '我来回答', func: this.openAPopup, btnType: 'primary' },
+            { label: '查看回答', func: this.openPopup, btnType: 'success' },
             { label: '删除', func: this.delHandle, btnType: 'danger' },
           ]
         }
@@ -77,6 +97,29 @@ export default {
     }
   },
   methods: {
+    openQPopup () {
+      this.isQShow = true
+    },
+    closeQPopup (obj) {
+      this.isQShow = false
+      if (obj) {
+        this.fetchData()
+      }
+    },
+    openAPopup (row) {
+      if (row && row.id) {
+        this.curObj = row
+      } else {
+        this.curObj = {}
+      }
+      this.isAShow = true
+    },
+    closeAPopup (obj) {
+      this.isAShow = false
+      if (obj) {
+        this.fetchData()
+      }
+    },
     delHandle(row) {
       this.$msg(`您确定要删除该问题吗?`, 'confirm', () => {
         this.$api.user.admquestiondel({