qa.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <div class="app-container">
  3. <search-form
  4. :list-loading="listLoading"
  5. @change="searchHandle"
  6. />
  7. <table-list
  8. :list-loading="listLoading"
  9. :data="tableData2"
  10. :columns="listConfig"
  11. :current-page="currentPage"
  12. :page-size="pageSize"
  13. :total-records="totalRecords"
  14. @currentChange="pageHandle"
  15. :isAdd="true"
  16. @add="openPopup"
  17. :operationsDefaultLength="6"
  18. />
  19. <popup-edit
  20. :isShow="isDtlShow"
  21. :curObj="curObj"
  22. @close="closePopup"
  23. />
  24. </div>
  25. </template>
  26. <script>
  27. import { arrToObj } from '@/utils'
  28. import SearchForm from './components/searchForm/QA'
  29. import PopupEdit from './components/popup/QAEdit'
  30. import baseTable from '_m/baseTable.js'
  31. export default {
  32. name: 'index',
  33. components: {
  34. SearchForm,
  35. PopupEdit,
  36. },
  37. provide() {
  38. return {
  39. parentData: this
  40. }
  41. },
  42. mixins: [baseTable],
  43. data() {
  44. return {
  45. apiStr: 'other.admqalist',
  46. searchForm: null,
  47. isDtlShow: false,
  48. curObj: {},
  49. }
  50. },
  51. computed: {
  52. tableData2() {
  53. const arr = [...this.tableData]
  54. arr.map(item => {})
  55. return arr
  56. }
  57. },
  58. created() {},
  59. mounted() {
  60. this.listConfig = {
  61. rows: [
  62. { label: '标签', prop: 'question_tag', type: 'flag', flags: arrToObj(this.$dictData.question_tag), width: 120 },
  63. { label: '问题', prop: 'question_cont', fullShow: true, minWidth: 200, align: 'left' },
  64. { label: '答案', prop: 'answer_cont', fullShow: true, minWidth: 200, align: 'left' },
  65. { label: '创建时间', prop: 'create_at' },
  66. { label: '操作', width: 120, type: 'handle2', operations:
  67. [
  68. { label: '编辑', func: this.openPopup, btnType: 'primary' },
  69. { label: '删除', func: this.delHandle, btnType: 'danger' },
  70. ]
  71. }
  72. ]
  73. }
  74. },
  75. methods: {
  76. delHandle(row) {
  77. this.$msg(`您确定要删除该问题吗?`, 'confirm', () => {
  78. this.$api.other.admqadel({
  79. id: row.id
  80. }).then(data => {
  81. this.$msgs(`已删除!`)
  82. this.fetchData()
  83. })
  84. }, null, true)
  85. },
  86. openPopup(row) {
  87. if (row && row.id) {
  88. this.curObj = row
  89. } else {
  90. this.curObj = {}
  91. }
  92. this.isDtlShow = true
  93. },
  94. closePopup(obj) {
  95. this.isDtlShow = false
  96. if (obj) {
  97. this.fetchData()
  98. }
  99. }
  100. }
  101. }
  102. </script>