list.vue 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <el-card shadow="hover">
  3. <div class="search">
  4. <el-form :inline="true">
  5. <el-form-item>
  6. <el-input
  7. size="default"
  8. v-model="params.keyWord"
  9. style="width: 200px; margin-left: 20px"
  10. class="search-input"
  11. placeholder="请输入搜索关键字"
  12. @keyup.enter.native="getList(1)"
  13. clearable
  14. >
  15. </el-input>
  16. <el-button size="default" type="primary" class="ml10" @click="getList(1)">
  17. <el-icon>
  18. <ele-Search />
  19. </el-icon>
  20. 查询
  21. </el-button>
  22. </el-form-item>
  23. <el-form-item>
  24. <el-button type="success" @click="add()">
  25. <el-icon>
  26. <ele-FolderAdd />
  27. </el-icon>
  28. 新增图纸
  29. </el-button>
  30. </el-form-item>
  31. </el-form>
  32. </div>
  33. <el-table :data="tableData" style="width: 100%" row-key="id" v-loading="loading">
  34. <!-- <el-table-column type="index" label="序号" width="60" align="center" /> -->
  35. <el-table-column prop="id" label="ID" width="60" show-overflow-tooltip></el-table-column>
  36. <el-table-column prop="name" label="组态图名称" show-overflow-tooltip></el-table-column>
  37. <el-table-column prop="createdAt" label="创建时间" min-width="100" align="center"></el-table-column>
  38. <el-table-column prop="updatedAt" label="更新时间" min-width="100" align="center"></el-table-column>
  39. <el-table-column label="操作" width="160" align="center">
  40. <template #default="scope">
  41. <el-button size="small" text type="primary" v-if="!scope.row.folderName" @click="view(scope.row)">预览</el-button>
  42. <el-button size="small" text type="warning" @click="edit(scope.row)">编辑</el-button>
  43. <el-button size="small" text type="danger" @click="del(scope.row)">删除</el-button>
  44. </template>
  45. </el-table-column>
  46. </el-table>
  47. <pagination v-if="params.total" :total="params.total" v-model:page="params.pageNum" v-model:limit="params.pageSize" @pagination="getList()" />
  48. </el-card>
  49. </template>
  50. <script lang="ts" setup>
  51. import api from '/@/api/configuration';
  52. import { Session } from '/@/utils/storage';
  53. import { useSearch } from '/@/hooks/useCommon';
  54. import { ElMessageBox, ElMessage } from 'element-plus';
  55. const { params, tableData, getList, loading } = useSearch<any[]>(api.getList, 'data', { keyWord: '' });
  56. getList();
  57. const view = (row: any) => {
  58. const url = import.meta.env.VITE_TOPO_URL + '/?token=' + encodeURIComponent(Session.get('token')) + '#/show/' + row.id;
  59. // const url = import.meta.env.VITE_TOPO_URL + '/?token=' + encodeURIComponent(Session.get('token')) + `&bgColor=FF9900` + '#/show/' + row.id;
  60. // console.log(url);
  61. window.open(url);
  62. };
  63. const add = () => {
  64. const url = import.meta.env.VITE_TOPO_URL + '/?token=' + encodeURIComponent(Session.get('token')) + '#/editor/new';
  65. // console.log(url);
  66. window.open(url);
  67. };
  68. const edit = (row: any) => {
  69. const url = import.meta.env.VITE_TOPO_URL + '/?token=' + encodeURIComponent(Session.get('token')) + '#/editor/' + row.id;
  70. // console.log(url);
  71. window.open(url);
  72. };
  73. const del = (row: any) => {
  74. ElMessageBox.confirm(`此操作将删除图形:“${row.name}”,是否继续?`, '提示', {
  75. confirmButtonText: '确认',
  76. cancelButtonText: '取消',
  77. type: 'warning',
  78. }).then(async () => {
  79. await api.del(row.id);
  80. ElMessage.success('删除成功');
  81. getList(1);
  82. });
  83. };
  84. </script>