index.vue 5.6 KB

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