index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <el-input @keyup.enter="handleSearch" class="w200px mr5px" v-model="queryForm.keyWord" placeholder="关键字搜索"/>
  5. <el-button v-throttle type="primary" @click="handleSearch">
  6. <i-ep-search/>
  7. 搜索
  8. </el-button>
  9. <el-button v-throttle @click="openDialog()" color="#11a983">
  10. <i-ep-plus/>
  11. 增加
  12. </el-button>
  13. <el-button v-throttle type="primary" @click="refreshTableInfo">
  14. <i-ep-refresh/>
  15. </el-button>
  16. </div>
  17. <div class="table-con">
  18. <el-table
  19. :max-height="tableHeight"
  20. v-loading="loading"
  21. :data="tableData"
  22. highlight-current-row
  23. border
  24. >
  25. <el-table-column label="操作" width="140">
  26. <template #default="{row}">
  27. <el-button link @click="openDialog(row.id)" type="primary">
  28. <i-ep-edit/>
  29. 编辑
  30. </el-button>
  31. <el-button link @click="handleDisable(row.id)" type="warning">删除</el-button>
  32. </template>
  33. </el-table-column>
  34. <el-table-column
  35. type="index"
  36. label="#"
  37. width="50">
  38. <template #default="scope">
  39. <span>{{ scope.$index + 1 }}</span>
  40. </template>
  41. </el-table-column>
  42. <el-table-column prop="groupName" width="150" label="分组名称"/>
  43. <el-table-column prop="caption" width="150" label="标题名称"/>
  44. <el-table-column prop="siteLabel" width="150" label="标签"/>
  45. <el-table-column prop="sortIndex" width="150" label="排序"/>
  46. <el-table-column
  47. prop="createTime"
  48. label="创建时间"
  49. >
  50. <template #default="{row}">
  51. <span v-if="row.createTime">
  52. {{ $filters.formatDate(row.createTime)}}
  53. </span>
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. <pagination
  58. v-if="total > 0"
  59. v-model:total="total"
  60. v-model:page="queryPage.pageIndex"
  61. v-model:limit="queryPage.pageSize"
  62. @pagination="getTableData"
  63. />
  64. </div>
  65. <child-dialog ref="childDialog" @dialogChange="dialogChange"></child-dialog>
  66. </div>
  67. </template>
  68. <script setup lang="ts">
  69. import {callSite} from "@/api/system";
  70. import ChildDialog from './compt/childDialog.vue'
  71. import {useTable} from '@/hooks/useTable'
  72. import {formatDate} from "@/utils/filters";
  73. const childDialog = ref<any>()
  74. //增加编辑
  75. function openDialog(item?: any) {
  76. childDialog.value.dialogVisible = true;
  77. if (item) {
  78. childDialog.value.dialogTitle = "编辑";
  79. nextTick(() => {
  80. childDialog.value.getItemData(item)
  81. });
  82. } else {
  83. nextTick(() => {
  84. childDialog.value.dialogTitle = "增加";
  85. childDialog.value.resetForm()
  86. })
  87. }
  88. }
  89. //禁用删除
  90. function handleDisable(id) {
  91. ElMessageBox.confirm("确认操作?", "警告", {
  92. confirmButtonText: "确定",
  93. cancelButtonText: "取消",
  94. type: "warning",
  95. }).then(() => {
  96. const params = {
  97. "businessMethod":'SiteContent_Delete',
  98. "params":JSON.stringify({
  99. "id": id
  100. })
  101. };
  102. callSite(params).then((response) => {
  103. if (response.httpCode == 200) {
  104. ElMessage.success("操作成功");
  105. getTableData();
  106. }
  107. })
  108. })
  109. }
  110. //修改成功后传递事件
  111. function dialogChange() {
  112. getTableData()
  113. }
  114. const queryForm = reactive({
  115. keyWord: '',
  116. voidFlag: 0
  117. })
  118. const {
  119. tableData,
  120. queryPage,
  121. total,
  122. loading,
  123. getTableData,
  124. tableHeight,
  125. handleSearch,//搜索
  126. refreshTableInfo,//刷新
  127. } = useTable(callSite, queryForm,'SiteContent_List');
  128. </script>