index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <div class="topicContent">
  3. <!-- <Banner /> -->
  4. <div class="content">
  5. <byTable
  6. :source="sourceList.data"
  7. :pagination="sourceList.pagination"
  8. :config="config"
  9. :loading="loading"
  10. highlight-current-row
  11. :action-list="[]"
  12. @get-list="getList">
  13. <template #slotName="{ item }">
  14. {{ item.createTime }}
  15. </template>
  16. </byTable>
  17. </div>
  18. <el-dialog title="回复列表" v-if="replyCommonModal" v-model="replyCommonModal" width="1000" class="replyCommonModal" v-loading="loading">
  19. <replyList :data="formData"></replyList>
  20. <template #footer>
  21. <el-button @click="replyCommonModal = false" size="large">关闭</el-button>
  22. </template>
  23. </el-dialog>
  24. </div>
  25. </template>
  26. <script setup>
  27. /* eslint-disable vue/no-unused-components */
  28. import { ElMessage, ElMessageBox } from "element-plus";
  29. import byTable from "@/components/byTable/index.vue";
  30. import { computed, ref } from "vue";
  31. import replyList from "./replyList.vue";
  32. const loading = ref(false);
  33. const sourceList = ref({
  34. data: [],
  35. pagination: {
  36. total: 3,
  37. pageNum: 1,
  38. pageSize: 10,
  39. },
  40. });
  41. const replyCommonModal = ref(false);
  42. const { proxy } = getCurrentInstance();
  43. const config = computed(() => {
  44. return [
  45. {
  46. attrs: {
  47. label: "序号",
  48. prop: "id",
  49. },
  50. },
  51. {
  52. attrs: {
  53. label: "主题",
  54. prop: "title",
  55. },
  56. },
  57. {
  58. attrs: {
  59. label: "作者",
  60. prop: "authorName",
  61. },
  62. },
  63. {
  64. attrs: {
  65. label: "发帖时间",
  66. prop: "createTime",
  67. align: "center",
  68. },
  69. },
  70. {
  71. attrs: {
  72. label: "浏览量",
  73. prop: "views",
  74. }
  75. },
  76. {
  77. attrs: {
  78. label: "是否热门",
  79. prop: "toping",
  80. },
  81. render(type) {
  82. return type == "1" ? "是" : "否";
  83. },
  84. },
  85. {
  86. attrs: {
  87. label: "操作",
  88. width: "200",
  89. align: "right",
  90. },
  91. // 渲染 el-button,一般用在最后一列。
  92. renderHTML(row) {
  93. return [
  94. {
  95. attrs: {
  96. label: "查看回复",
  97. type: "primary",
  98. text: true,
  99. },
  100. el: "button",
  101. click() {
  102. openReplyModal(row);
  103. },
  104. },
  105. {
  106. attrs: {
  107. label: "删除",
  108. type: "danger",
  109. text: true,
  110. },
  111. el: "button",
  112. click() {
  113. prefixDel(row);
  114. },
  115. },
  116. ];
  117. },
  118. },
  119. ];
  120. });
  121. let formData = reactive({
  122. data: {},
  123. treeData: [],
  124. subCategoryList:[],
  125. });
  126. const formOption = reactive({
  127. inline: true,
  128. labelWidth: 100,
  129. itemWidth: 100,
  130. rules: [],
  131. });
  132. const byform = ref(null);
  133. const getList = async (req) => {
  134. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  135. loading.value = true;
  136. proxy.post("/topicContent/page", sourceList.value.pagination).then((data) => {
  137. sourceList.value.data = data.rows;
  138. sourceList.value.pagination.total = data.total;
  139. setTimeout(() => {
  140. loading.value = false;
  141. }, 200);
  142. });
  143. };
  144. //打开回复列表弹窗
  145. const openReplyModal = (row) => {
  146. formData.data = { ...row };
  147. replyCommonModal.value = true;
  148. };
  149. //删除
  150. const prefixDel = (row) => {
  151. ElMessageBox.confirm("你是否删除此主题?", "提示", {
  152. confirmButtonText: "确定",
  153. cancelButtonText: "取消",
  154. type: "warning",
  155. }).then(() => {
  156. proxy.post("/topicReplies/hasReply", { topicId: row.id }).then((res) => {
  157. if(res){
  158. ElMessageBox.confirm("此主题下有回复,删除后所有回复也将一并删除,是否确认删除?", "提示", {
  159. confirmButtonText: "确定",
  160. cancelButtonText: "取消",
  161. type: "warning",
  162. }).then(() => {
  163. del(row.id)
  164. });
  165. }else{
  166. del(row.id)
  167. }
  168. });
  169. });
  170. };
  171. const del = (id) => {
  172. proxy.post("/topicContent/delete", { id: id }).then((res) => {
  173. ElMessage({
  174. message: "操作成功",
  175. type: "success",
  176. });
  177. getList();
  178. });
  179. }
  180. getList();
  181. </script>
  182. <style lang="scss" scoped>
  183. .tenant {
  184. padding: 20px;
  185. }
  186. </style>