index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <div class="page">
  3. <el-card shadow="nover">
  4. <el-form :model="state.tableData.param" ref="queryRef" :inline="true" label-width="60px">
  5. <el-form-item label="关键字" prop="keyWord">
  6. <el-input v-model="state.tableData.param.name" placeholder="请输入关键字" clearable size="default" @keyup.enter="queryList" />
  7. </el-form-item>
  8. <el-form-item>
  9. <el-button v-auth="'query'" size="default" type="primary" class="ml10" @click="queryList">
  10. <el-icon>
  11. <ele-Search />
  12. </el-icon>
  13. 查询
  14. </el-button>
  15. <el-button v-auth="'reset'" size="default" @click="resetQuery(queryRef)">
  16. <el-icon>
  17. <ele-Refresh />
  18. </el-icon>
  19. 重置
  20. </el-button>
  21. <el-button v-auth="'add'" size="default" type="primary" class="ml10" @click="operate('add')">
  22. <el-icon>
  23. <ele-FolderAdd />
  24. </el-icon>
  25. 新增证书
  26. </el-button>
  27. </el-form-item>
  28. </el-form>
  29. <el-table :data="state.tableData.data" v-loading="state.tableData.loading" style="width: 100%">
  30. <!-- <el-table-column type="selection" width="55" align="center" /> -->
  31. <el-table-column v-col="'id'" label="ID" align="center" prop="id" width="100" />
  32. <el-table-column v-col="'name'" label="证书名称" prop="name" min-width="120" show-overflow-tooltip />
  33. <el-table-column v-col="'standard'" label="证书标准" prop="standard" min-width="120" show-overflow-tooltip>
  34. <template #default="scope">
  35. {{ filterStandard(scope.row.standard) }}
  36. <!-- <el-button size="small" text type="primary" @click="operate('editParams', scope.row)">编辑</el-button> -->
  37. <!-- <el-button size="small" text type="danger" @click="operate('delete', scope.row)">删除</el-button> -->
  38. </template>
  39. </el-table-column>
  40. <el-table-column v-col="'description'" label="说明" prop="description" min-width="120" show-overflow-tooltip />
  41. <el-table-column label="状态" width="120" align="center">
  42. <template #default="scope">
  43. <el-switch v-auth="'startOrStop'" v-model="scope.row.status" inline-prompt :active-value="1" :inactive-value="0" active-text="启" inactive-text="禁" @change="handleStatusChange(scope.row)"></el-switch>
  44. <span v-noauth="'startOrStop'">{{ scope.row.status ? '正常' : '暂停' }}</span>
  45. </template>
  46. </el-table-column>
  47. <el-table-column v-col="'handle'" label="操作" width="180" align="center" fixed="right">
  48. <template #default="scope">
  49. <el-button size="small" v-auth="'edit'" text type="primary" @click="operate('editParams', scope.row)">编辑</el-button>
  50. <el-button size="small" v-auth="'del'" text type="info" @click="operate('delete', scope.row)">删除</el-button>
  51. </template>
  52. </el-table-column>
  53. </el-table>
  54. <pagination v-show="state.tableData.total > 0" :total="state.tableData.total" v-model:page="state.tableData.param.pageNum" v-model:limit="state.tableData.param.pageSize" @pagination="queryList" />
  55. <EditParams ref="editParamsRef" @update="queryList" />
  56. </el-card>
  57. </div>
  58. </template>
  59. <script lang="ts" setup>
  60. import { reactive, onMounted, ref, getCurrentInstance } from 'vue';
  61. import { ElMessageBox, ElMessage, FormInstance } from 'element-plus';
  62. import api from '/@/api/certificateManagement';
  63. import EditParams from './component/editParams.vue';
  64. const { proxy } = getCurrentInstance() as any;
  65. const { network_certificate } = proxy.useDict('network_certificate');
  66. const previewRef = ref();
  67. const editParamsRef = ref();
  68. const buildConfigRef = ref();
  69. const queryRef = ref();
  70. const state = reactive({
  71. ids: [],
  72. tableData: {
  73. data: [],
  74. loading: false,
  75. param: {
  76. pageNum: 1,
  77. PageSize: 10,
  78. status: -1,
  79. name: ""
  80. },
  81. total: 0
  82. },
  83. });
  84. // 初始化表格数据
  85. const initTableData = () => {
  86. queryList();
  87. };
  88. const queryList = () => {
  89. state.tableData.loading = true
  90. api.certificateManagement.getList(state.tableData.param).then((res: any) => {
  91. state.tableData.data = res.Info || [];
  92. state.tableData.loading = false
  93. state.tableData.total = res.total
  94. });
  95. };
  96. const filterStandard = (type: any) => {
  97. let opt = network_certificate.value.filter((ele: any) => {
  98. return ele.value == type
  99. })
  100. return opt[0]?.label
  101. }
  102. // 状态修改
  103. const handleStatusChange = (row: any) => {
  104. let text = row.status === 1 ? '启用' : '停用';
  105. ElMessageBox.confirm('确认要"' + text + '":"' + row.name + '"证书吗?', '警告', {
  106. confirmButtonText: '确定',
  107. cancelButtonText: '取消',
  108. type: 'warning',
  109. })
  110. .then(function () {
  111. return api.certificateManagement.editStatus({ id: row.id, status: row.status });
  112. })
  113. .then(() => {
  114. ElMessage.success(text + '成功');
  115. })
  116. .catch(function () {
  117. row.status = row.status === 0 ? 1 : 0;
  118. });
  119. };
  120. // 页面加载时
  121. onMounted(() => {
  122. initTableData();
  123. });
  124. /** 重置按钮操作 */
  125. const resetQuery = (formEl: FormInstance | undefined) => {
  126. if (!formEl) return;
  127. formEl.resetFields();
  128. queryList();
  129. };
  130. const operate = (type: string, row: any) => {
  131. switch (type) {
  132. case 'preview':
  133. previewRef.value.openDialog({ ...row })
  134. break
  135. case 'add':
  136. editParamsRef.value.openDialog()
  137. break
  138. case 'editParams':
  139. editParamsRef.value.openDialog({ ...row })
  140. break
  141. case 'buildConfig':
  142. buildConfigRef.value.openDialog({ ...row })
  143. break
  144. case 'delete':
  145. ElMessageBox.confirm(`是否确认删除编号为"${row.id}"的数据项?`, '提示', {
  146. confirmButtonText: '确认',
  147. cancelButtonText: '取消',
  148. type: 'warning',
  149. })
  150. .then(() => {
  151. api.certificateManagement.del(row.id).then(() => {
  152. ElMessage.success('删除成功');
  153. queryList();
  154. });
  155. })
  156. .catch(() => { });
  157. break
  158. }
  159. }
  160. </script>