index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <el-card shadow="hover">
  3. <div class="search">
  4. <el-form :inline="true">
  5. <el-form-item>
  6. <el-button type="success" @click="addOrEdit()">
  7. <el-icon>
  8. <ele-FolderAdd />
  9. </el-icon>
  10. 新增大屏
  11. </el-button>
  12. </el-form-item>
  13. </el-form>
  14. </div>
  15. <el-table :data="tableData" style="width: 100%" v-loading="loading">
  16. <el-table-column type="index" label="序号" width="60" align="center" />
  17. <el-table-column prop="id" label="ID" show-overflow-tooltip></el-table-column>
  18. <el-table-column prop="projectName" label="项目名称" show-overflow-tooltip></el-table-column>
  19. <el-table-column prop="remarks" label="描述" show-overflow-tooltip></el-table-column>
  20. <el-table-column prop="createdAt" label="创建时间" min-width="100" align="center"></el-table-column>
  21. <el-table-column prop="updatedAt" label="更新时间" min-width="100" align="center"></el-table-column>
  22. <el-table-column label="操作" width="200" align="center">
  23. <template #default="scope">
  24. <el-button size="small" text type="primary" @click="preview(scope.row)">预览</el-button>
  25. <el-button size="small" text type="warning" @click="addOrEdit(scope.row)">编辑</el-button>
  26. <el-button size="small" text type="warning" @click="edit(scope.row)">设计大屏</el-button>
  27. <el-button size="small" text type="danger" @click="onDel(scope.row)">删除</el-button>
  28. </template>
  29. </el-table-column>
  30. </el-table>
  31. <pagination v-if="params.total" :total="params.total" v-model:page="params.pageNum" v-model:limit="params.pageSize" @pagination="getList()" />
  32. <EditForm ref="editFormRef" @getList="getList()"></EditForm>
  33. </el-card>
  34. </template>
  35. <script lang="ts" setup>
  36. import { ref } from 'vue';
  37. import api from '/@/api/screen';
  38. import { ElMessageBox, ElMessage } from 'element-plus';
  39. import { useSearch } from '/@/hooks/useCommon';
  40. import EditForm from './edit.vue';
  41. const editFormRef = ref();
  42. const { params, tableData, getList, loading } = useSearch<any[]>(api.getList, 'Data', { name: '', address: '' });
  43. getList();
  44. const addOrEdit = async (row?: any) => {
  45. if (row) {
  46. editFormRef.value.open(row);
  47. return;
  48. } else {
  49. editFormRef.value.open();
  50. }
  51. };
  52. // const add = async () => {
  53. // ElMessageBox.prompt('请输入项目名称', '创建大屏项目', {
  54. // confirmButtonText: '确认',
  55. // cancelButtonText: '取消',
  56. // inputValidator: (value: string) => {
  57. // if (value.trim()) {
  58. // return true;
  59. // } else {
  60. // return '请输入项目名称';
  61. // }
  62. // },
  63. // inputErrorMessage: '请输入描述',
  64. // }).then(async ({ value: projectName }) => {
  65. // ElMessageBox.prompt('请输入描述', '创建大屏项目', {
  66. // confirmButtonText: '确认',
  67. // cancelButtonText: '取消',
  68. // }).then(async ({ value: remarks }) => {
  69. // await api.add({
  70. // indexImage: null,
  71. // projectName,
  72. // remarks,
  73. // });
  74. // ElMessage.success('新增成功');
  75. // getList();
  76. // });
  77. // });
  78. // };
  79. const edit = async (row: any) => {
  80. const url = import.meta.env.VITE_SCREEN_URL + '#/chart/home/' + row.id;
  81. window.open(url);
  82. };
  83. const preview = async (row: any) => {
  84. const url = import.meta.env.VITE_SCREEN_URL + '#/chart/preview/' + row.id;
  85. window.open(url);
  86. };
  87. const onDel = (row: any) => {
  88. ElMessageBox.confirm(`此操作将删除接口:“${row.projectName}”,是否继续?`, '提示', {
  89. confirmButtonText: '确认',
  90. cancelButtonText: '取消',
  91. type: 'warning',
  92. }).then(async () => {
  93. await api.del([row.id as string]);
  94. ElMessage.success('删除成功');
  95. getList();
  96. });
  97. };
  98. </script>