12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <template>
- <el-card shadow="hover">
- <div class="search">
- <el-form :inline="true">
- <el-form-item>
- <el-input
- size="default"
- v-model="params.keyWord"
- style="width: 200px; margin-left: 20px"
- class="search-input"
- placeholder="请输入搜索关键字"
- @keyup.enter.native="getList(1)"
- clearable
- >
- </el-input>
- <el-button size="default" type="primary" class="ml10" @click="getList(1)">
- <el-icon>
- <ele-Search />
- </el-icon>
- 查询
- </el-button>
- </el-form-item>
- <el-form-item>
- <el-button type="success" @click="add()">
- <el-icon>
- <ele-FolderAdd />
- </el-icon>
- 新增图纸
- </el-button>
- </el-form-item>
- </el-form>
- </div>
- <el-table :data="tableData" style="width: 100%" row-key="id" v-loading="loading">
- <!-- <el-table-column type="index" label="序号" width="60" align="center" /> -->
- <el-table-column prop="id" label="ID" width="60" show-overflow-tooltip></el-table-column>
- <el-table-column prop="name" label="组态图名称" show-overflow-tooltip></el-table-column>
- <el-table-column prop="createdAt" label="创建时间" min-width="100" align="center"></el-table-column>
- <el-table-column prop="updatedAt" label="更新时间" min-width="100" align="center"></el-table-column>
- <el-table-column label="操作" width="160" align="center">
- <template #default="scope">
- <el-button size="small" text type="primary" v-if="!scope.row.folderName" @click="view(scope.row)">预览</el-button>
- <el-button size="small" text type="warning" @click="edit(scope.row)">编辑</el-button>
- <el-button size="small" text type="danger" @click="del(scope.row)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <pagination v-if="params.total" :total="params.total" v-model:page="params.pageNum" v-model:limit="params.pageSize" @pagination="getList()" />
- </el-card>
- </template>
- <script lang="ts" setup>
- import api from '/@/api/configuration';
- import { Session } from '/@/utils/storage';
- import { useSearch } from '/@/hooks/useCommon';
- import { ElMessageBox, ElMessage } from 'element-plus';
- const { params, tableData, getList, loading } = useSearch<any[]>(api.getList, 'data', { keyWord: '' });
- getList();
- const view = (row: any) => {
- const url = import.meta.env.VITE_TOPO_URL + '/?token=' + encodeURIComponent(Session.get('token')) + '#/show/' + row.id;
- // const url = import.meta.env.VITE_TOPO_URL + '/?token=' + encodeURIComponent(Session.get('token')) + `&bgColor=FF9900` + '#/show/' + row.id;
- // console.log(url);
- window.open(url);
- };
- const add = () => {
- const url = import.meta.env.VITE_TOPO_URL + '/?token=' + encodeURIComponent(Session.get('token')) + '#/editor/new';
- // console.log(url);
- window.open(url);
- };
- const edit = (row: any) => {
- const url = import.meta.env.VITE_TOPO_URL + '/?token=' + encodeURIComponent(Session.get('token')) + '#/editor/' + row.id;
- // console.log(url);
- window.open(url);
- };
- const del = (row: any) => {
- ElMessageBox.confirm(`此操作将删除图形:“${row.name}”,是否继续?`, '提示', {
- confirmButtonText: '确认',
- cancelButtonText: '取消',
- type: 'warning',
- }).then(async () => {
- await api.del(row.id);
- ElMessage.success('删除成功');
- getList(1);
- });
- };
- </script>
|