常见分页步骤: Total: ? Page: ?/? Goto: ? | >|

本文介绍了一种基于HTML和JavaScript的网页分页实现方法,包括页面布局设计、JS脚本引入及后端数据处理等关键步骤。

常见分页步骤: Total: ? Page: ?/? Goto: ? |< < > >|

一、复制代码到指定的地方:

<div style="float:right" mce_style="float:right" > <table border="0" cellpadding="0" cellspacing="0" style="width:100%;" > <tr> <td style="width:100px;"> <span id="Pagination" style="display:none" mce_style="display:none"></span> Total: <span id="total" style="color: #1155BB" mce_style="color: #1155BB"></span> </td> <td style="width:100px;"> Page: <span id="page" style="color: #1155BB" mce_style="color: #1155BB"></span> </td> <td style="width:110px;"> Goto: <select id="selPager" onchange="movePage(this.selectedIndex)" class="dataSelect"> <option value="1">1</option> </select> </td> <td style="width:110px;"> <span style="float:right;padding-right:5px;" mce_style="float:right;padding-right:5px;"> <img id="firstPage" class="pageImg" border="0" onclick="movePage('first')" onmouseover="this.src='/eClinic/ec/images/page_first_select.gif'" onmouseout="this.src='/eClinic/ec/images/page_first.gif'" alt="First Page" src="/eClinic/ec/images/page_first.gif" mce_src="eClinic/ec/images/page_first.gif" /> <img id="previousPage" class="pageImg" border="0" onclick="movePage('previous')"onmouseover="this.src='/eClinic/ec/images/page_previous_select.gif'" onmouseout="this.src='/eClinic/ec/images/page_previous.gif'" alt="Previous Page" src="/eClinic/ec/images/page_previous.gif" mce_src="eClinic/ec/images/page_previous.gif" /> <img id="nextPage" class="pageImg" border="0" onclick="movePage('next')" onmouseover="this.src='/eClinic/ec/images/page_next_select.gif'" onmouseout="this.src='/eClinic/ec/images/page_next.gif'" alt="Next Page" src="/eClinic/ec/images/page_next.gif" mce_src="eClinic/ec/images/page_next.gif" /> <img id="lastPage" class="pageImg" border="0" onclick="movePage('last')" onmouseover="this.src='/eClinic/ec/images/page_last_select.gif'" onmouseout="this.src='/eClinic/ec/images/page_last.gif'" alt="Last Page" src="/eClinic/ec/images/page_last.gif" mce_src="eClinic/ec/images/page_last.gif" /> </span> </td> </tr> </table> </div>

padding-right:5px;这个是为了右边留一点空而已。

样式

.pageImg{vertical-align:bottom;float:left;}

二、引入JS
<link href="/eClinic/include/pagination/pagination.css" rel="stylesheet" type="text/css" />
<script src="/eClinic/include/pagination/jquery.pagination.js" type="text/javascript"></script>

<mce:script type="text/javascript"><!-- //---------------------------------Pagination------------------------------------------------------ //initial Pagination var opts = { callback: pageselectCallback }; opts.items_per_page =100; //page load $(document).ready(function() { initialPage(); }) //initial page base info () function initialPage() { var url = "alertList.aspx?pageOp=getCount"; $.post(url, function(data, textStatus) { opts.recordCount = parseInt(data); opts.pageCount = Math.floor(opts.recordCount % opts.items_per_page == 0 ? opts.recordCount / opts.items_per_page : opts.recordCount / opts.items_per_page + 1); opts.current_page = 0; var htmlStr = ""; for (var i = 0; i < opts.pageCount; i++) { htmlStr += "<option value='" + i + "'>" + (i + 1) + "</option>"; } $("#selPager").html(htmlStr); $("#Pagination").pagination(data, opts); }); } //get page content function pageselectCallback(page_index, jq) { $("#total").text(opts.recordCount); $("#page").text(opts.pageCount == 0 ? "0/0" : (page_index + 1) + "/" + opts.pageCount); opts.current_page = page_index; $("#selPager").val(page_index); var url = "alertList.aspx?" + "pageOp=getList" + "&pageIndex=" + page_index + "&pageSize=" + opts.items_per_page; $.post(url, function(data) { $("#tbodyList").html(data); }); } //change select or click pagination function movePage(type) { var pageIdx = 0; if (type == "first") { pageIdx = 0; } else if (type == "previous") { pageIdx = opts.current_page == 0 ? 0 : opts.current_page - 1; } else if (type == "next") { pageIdx = opts.current_page == opts.pageCount - 1 ? opts.pageCount - 1 : opts.current_page + 1; } else if (type == "last") { pageIdx = opts.pageCount - 1; } else { pageIdx = type; } pageselectCallback(pageIdx, $("#Pagination")); } // --></mce:script>

三、页面后置代码。
#region [ Page Load ]
protected void Page_Load(object sender, EventArgs e)
{
//Set Privilege
SetPrivilege();

string action = Request["action"];
if ("delete" == action)
{
int id = Convert.ToInt32(Request["id"]);
alertService.DeletePcip_AlertByAlertId(id);
}
if (!string.IsNullOrEmpty(Request["pageOp"]))
{
GetPaginationData();
}
}

private void GetPaginationData()
{
string data = "";
switch (Request["pageOp"])
{
case "getCount":
data = alertService.GetNotDeletedCount().ToString();
break;
case "getList":
int pageIndex = Convert.ToInt32(Request["pageIndex"]);
int pageSize = Convert.ToInt32(Request["pageSize"]);
DataTable dt = alertService.GetNotDeletedDataTableByPageSizeAndIndex(pageSize, pageIndex);

StringBuilder sb = new StringBuilder();
foreach (DataRow dr in dt.Rows)
{
sb.Append(string.Format(@"<tr style='height:25px;' ondblclick='edit({0})' class='{1}'>",
dr["alertId"], Convert.ToInt32(dr["Enabled"]) == 1 ? "showBGYellow" : "showBGRed"));
sb.Append(string.Format(@"<td><input onclick='' type='radio' name='rdoId' value='{0}' /></td>",dr["alertId"]));
sb.Append(string.Format(@"<td>{0}</td>",dr["Name"]));
sb.Append(string.Format(@"<td>{0}Clinics({1});{2}",
dr["DMDesc"].ToString().Trim() == "" ? "" : "Adhoc Query(" + dr["DMDesc"].ToString() + ");",
dr["ClinicCount"],
dr["OSName"].ToString().Trim()==""?"":"OrderSet("+dr["OSName"].ToString()+")"));
sb.Append(string.Format(@"<td>{0}</td>", dr["Format"]));
sb.Append(string.Format(@"<td>{0}</td>", dr["Description"]));
sb.Append(string.Format(@"<td>{0}</td>", dr["Criteria"]));
sb.Append(string.Format(@"<td>{0}</td>", dr["AdminNotes"]));
sb.Append(string.Format(@"<td>{0}</td>", GetDeployment(dr["Status"])));
sb.Append(string.Format(@"<td nowrap='nowrap'>{0}</td>", dr["dateCreated"]));
sb.Append(string.Format(@"<td align='center'>{0}</td>",Convert.ToInt32(dr["Enabled"])==1?"<img src=/"/eClinic/ec/images/select_hcfa.gif/">":"&nbsp;"));
sb.Append("</tr>");
}
data = sb.ToString();
break;
}
Response.Write(data);
Response.End();
}
#endregion

四、ServiceImpl
#region 4.3.3 分页:得到所有未删除的Pcip_Alert的个数
public int GetNotDeletedCount()
{
string sql = "select count(*) from Pcip_Alert where deleted=0";
return DbFactory.executeScalarInt(sql);
}
#endregion

#region 4.3.4 分页:根据pageSize和pageIndex得到所有未删除的Pcip_Alert的DataTable
public DataTable GetNotDeletedDataTableByPageSizeAndIndex(int pageSize, int pageIndex)
{
string sql =string.Format(@"
SELECT TOP {0} pa.*
FROM Pcip_Alert pa
WHERE pa.[Deleted] = 0
AND pa.AlertId NOT IN (SELECT TOP {1} pa2.AlertId
FROM Pcip_Alert pa2 where pa2.[Deleted] = 0
ORDER BY
pa2.AlertId DESC)
ORDER BY
pa.alertId DESC", pageSize,pageSize*pageIndex);
return DbFactory.getDataTableBySql(sql);
}
#endregion

解读学习代码: <script setup> import { carManGetService, carManStartService, carManStopService, carManDelService, vidallDataGetService } from '@/api/cloud.js' import { Plus, Delete, Edit, Search, Refresh } from '@element-plus/icons-vue' import { ref } from 'vue' import AddCar from './components/AddCar.vue' import SureDevice from './components/SureDevice.vue' import zhCn from 'element-plus/dist/locale/zh-cn.mjs' import CarvidSelect from '@/views/manage/components/CarvidSelect.vue' import DevcidSelect from '@/views/manage/components/DevcidSelect.vue' import { Picture as IconPicture } from '@element-plus/icons-vue' import { ElMessage, ElMessageBox, ElEmpty } from 'element-plus' const tableRef = ref([]) const carManDataList = ref([]) const total = ref(0) const updateDialog = ref() const deviceDialog = ref() // const editDialog = ref() const tableSelection = ref([]) const loading = ref(true) //定义请求参数对象 const params = ref({ pageNum: 1, pageSize: 10, cid: '', vid: '', key: '', status: '', enableStatus: '' }) //导入列表数据 const getCarManDataList = async () => { const res = await carManGetService(params.value) // 增加健壮性判断 if (res && res.data && res.data.data) { carManDataList.value = res.data.data.records total.value = res.data.data.total } else { carManDataList.value = [] total.value = 0 } loading.value = false } getCarManDataList() // 获所属车辆 const vidDataList = ref([]) const getRoleDataList = async () => { const res = await vidallDataGetService() vidDataList.value = res.data.data } getRoleDataList() //搜索 const onSearch = () => { params.value.pageNum = 1 getCarManDataList() } //重置 const onReset = () => { params.value.pageNum = 1 params.value.cid = '' params.value.vid = '' params.value.key = '' params.value.enableStatus = '' params.value.status = '' getCarManDataList() } //多选框 let ids = [] const handleSelectionChange = (selects) => { ids = [] tableSelection.value = selects selects.forEach((rows) => { ids.push(rows.id) }) console.log(ids) console.log(tableSelection.value) } // 表格样式 // const rowStyle = (val) => { // // console.log('1111', val) // if (val.rowIndex % 2 === 0) { // // 奇数行 // return { // 'text-align': 'center', // color: '#fff', // background: '#2e3a54' // // color: 'red' // } // } // // 偶数行 // else // return { // 'text-align': 'center', // color: '#fff', // backgroundColor: '#1f2940' // } // } // 搜索式输入框 const handleSearch = () => {} //新增 const onAddMessage = () => { updateDialog.value.open({}) } //编辑 const onEditTable = (row) => { console.log(row.status) updateDialog.value.open(row) } // 添加或者编辑 成功的回调 const onSuccess = (type) => { if (type === 'add') { // // 如果是添加,最好渲染最后一页 // const lastPage = Math.ceil((total.value + 1) / params.value.pageSize) // // 更新成最大页码数,再渲染 // params.value.pageNum = lastPage params.value.pageNum = 1 } getCarManDataList() } //启用禁用 const onStart = async (row) => { // console.log(row.status) // console.log(row.id) if (row.enableStatus === 0) { // params.value.id = row.id const res = await carManStartService({ id: row.id }) if (res.data.code === 200) { // console.log('错误', res) ElMessage.success('车辆已启用') } else if (res.data.code !== 200) { ElMessage.error(`${res.data.msg}`) } } else if (row.enableStatus === 1) { // params.value.id = row.id const res = await carManStopService({ id: row.id }) if (res.data.code === 200) { // console.log('错误', res) ElMessage.success('车辆已禁用') } else if (res.data.code !== 200) { ElMessage.error(`${res.data.msg}`) } } getCarManDataList() } // 绑定台架 const inSureDevice = async (row) => { deviceDialog.value.open(row) } // 删除逻辑 const onDeleteMessage = async () => { // 提示用户是否要删除 await ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', { confirmButtonText: '确定', cancelButtonText: '消', type: 'warning' }) const res = await carManDelService(ids) if (res.data.code == 200) { ElMessage.success('删除成功') getCarManDataList() tableRef.value.clearSelection() } else if (res.data.code !== 200) { ElMessage.error(`${res.data.msg}`) } } //处理分页逻辑 const handleSizeChange = (size) => { //每页条数改变后,从第一页开始渲染 params.value.pageNum = 1 params.value.pageSize = size getCarManDataList() } const handleCurrentChange = (page) => { params.value.pageNum = page getCarManDataList() } zhCn.el.pagination = { goto: '跳至', pageClassifier: '页', total: '共 {total} 条', pagesize: '条/页' } </script> <template> <div class="bread"> <el-breadcrumb separator="/"> <el-breadcrumb-item ><img src="@/assets/车辆管理i.png" style="width: 20px" /></el-breadcrumb-item> <el-breadcrumb-item>车辆管理</el-breadcrumb-item> <el-breadcrumb-item :to="{ path: '/manage/car' }" >车辆信息</el-breadcrumb-item > </el-breadcrumb> </div> <page-container> <AddCar ref="updateDialog" @success="onSuccess"></AddCar> <SureDevice ref="deviceDialog" @success="onSuccess"></SureDevice> <el-form inline class="search_form"> <el-form-item label="关键字:"> <el-input v-model="params.key" placeholder="请输入车辆名称、车牌号" clearable @input="handleSearch" ></el-input> </el-form-item> <el-form-item label="车辆编号:"> <CarvidSelect v-model="params.vid" placeholder="请选择车辆编号" clearable @input="handleSearch" ></CarvidSelect> </el-form-item> <el-form-item label="驾驶舱编号:"> <DevcidSelect v-model="params.cid" placeholder="请选择驾驶舱编号" clearable @input="handleSearch" ></DevcidSelect> </el-form-item> <el-form-item label="在线状态:"> <el-select v-model="params.status" placeholder="请选择在线状态" clearable > <el-option label="离线" :value="0"></el-option> <el-option label="在线" :value="1"></el-option> </el-select> </el-form-item> <el-form-item label="启用状态:"> <el-select v-model="params.enableStatus" placeholder="请选择启用状态" clearable > <el-option label="禁用" :value="0"></el-option> <el-option label="启用" :value="1"></el-option> </el-select> </el-form-item> <el-form-item> <el-button @click="onSearch" style="background-color: #165dff; color: #fff" ><el-icon style="padding-right: 5px"><Search /></el-icon> 搜索</el-button > <el-button @click="onReset" style="background-color: #fff; color: #000"> <el-icon style="padding-right: 5px"><Refresh /></el-icon> 重置</el-button > </el-form-item> </el-form> <el-form class="function_form" inline style="justify-content: end; display: flex" > <el-form-item style="margin-right: 0"> <!-- <el-button style="background-color: #366ef4; color: #fff" @click="onUpdate" :disabled="tableSelection.length === 0" ><el-icon style="padding-right: 5px"><Upload /></el-icon >一键升级</el-button > --> <el-button @click="onAddMessage" style="background-color: #165dff; color: #fff" > <el-icon style="padding-right: 5px"><Plus /></el-icon> 新增</el-button > <el-button @click="onDeleteMessage" :disabled="tableSelection.length === 0" style="background-color: #f53f3f; color: #fff" > <el-icon style="padding-right: 5px"><Delete /></el-icon> 删除</el-button > </el-form-item> </el-form> <el-table id="table" ref="tableRef" :row-key="(row) => row.id" @selection-change="handleSelectionChange" :data="carManDataList" style="width: 100%; margin-top: 10px" :header-cell-style="{ 'text-align': 'center', background: '#f2f3f5', color: '#000' }" :cell-style="{ 'text-align': 'center', color: '#000' }" > <el-table-column fixed type="selection" :reserve-selection="true" width="40" /> <el-table-column prop="vid" label="车辆编号" min-width="160" :show-overflow-tooltip="true" ><template #default="{ row }"> <div> {{ vidDataList.find((item) => row.vid == item.id)?.name || '-' }} </div> <div v-if="row.vid === '' || row.vid === null || row.vid === undefined" > - </div> </template> </el-table-column> <el-table-column prop="cid" label="驾驶舱编号" min-width="100" :show-overflow-tooltip="true" ><template #default="{ row }"> <div v-if="row.cid === '' || row.cid === null || row.cid === undefined" > - </div> </template> </el-table-column> <el-table-column prop="name" label="车辆名称" min-width="120" :show-overflow-tooltip="true" ><template #default="{ row }"> <div v-if=" row.name === '' || row.name === null || row.name === undefined " > - </div> </template> </el-table-column> <el-table-column prop="plateNumber" label="车辆牌照" min-width="120" :show-overflow-tooltip="true" ><template #default="{ row }"> <div v-if=" row.plateNumber === '' || row.plateNumber === null || row.plateNumber === undefined " > - </div> </template> </el-table-column> <!-- <el-table-column prop="abilities" label="车辆能力集" min-width="120" :show-overflow-tooltip="true" ><template #default="{ row }"> <div v-for="item in row.abilities" :key="item.id"> {{ item.name }}, </div> <div v-if=" row.abilities === '' || row.abilities === null || row.abilities === undefined || row.abilities.length === 0 " > - </div> </template> </el-table-column> <el-table-column prop="onboardDevices" label="车载设备" min-width="120" :show-overflow-tooltip="true" ><template #default="{ row }"> <div v-for="item in row.onboardDevices" :key="item.id"> {{ item.name }}, </div> <div v-if=" row.onboardDevices === '' || row.onboardDevices === null || row.onboardDevices === undefined || row.onboardDevices.length === 0 " > - </div> </template> </el-table-column> --> <el-table-column prop="picture" label="车辆图片" min-width="110" :show-overflow-tooltip="true" > <template #default="{ row }"> <el-image v-if="row.picture" :src="row.picture" alt="" style="width: 50px; height: 50px" > <template #error> <div class="image-slot"> <el-icon><icon-picture /></el-icon> </div> </template> </el-image> <div v-if=" row.picture === '' || row.picture === null || row.picture === undefined " > - </div> </template> </el-table-column> <el-table-column prop="status" label="在线状态" min-width="110" :show-overflow-tooltip="true" > <template #default="{ row }"> <el-tag v-if="row.status === 0" type="info">离线</el-tag> <el-tag v-if="row.status === 1" type="success">在线</el-tag> <div v-if=" row.status === '' || row.status === null || row.status === undefined " > - </div> </template> </el-table-column> <el-table-column prop="enableStatus" label="启用状态" min-width="110" :show-overflow-tooltip="true" > <template #default="{ row }"> <el-tag v-if="row.enableStatus === 0" type="danger">禁用</el-tag> <el-tag v-if="row.enableStatus === 1" type="success">启用</el-tag> <div v-if=" row.enableStatus === '' || row.enableStatus === null || row.enableStatus === undefined " > - </div> </template> </el-table-column> <el-table-column prop="hasGateway" label="是否具备网关" min-width="110" :show-overflow-tooltip="true" > <template #default="{ row }"> <div v-if="row.hasGateway === 0">否</div> <div v-if="row.hasGateway === 1">是</div> <div v-if=" row.hasGateway === '' || row.hasGateway === null || row.hasGateway === undefined " > - </div> </template> </el-table-column> <el-table-column prop="model" label="型号" min-width="110" :show-overflow-tooltip="true" > <template #default="{ row }"> <div v-if=" row.model === '' || row.model === null || row.model === undefined " > - </div> </template> </el-table-column> <el-table-column prop="manufactureDate" label="出厂日期" min-width="110" :show-overflow-tooltip="true" > <template #default="{ row }"> <div v-if=" row.manufactureDate === '' || row.manufactureDate === null || row.manufactureDate === undefined " > - </div> </template> </el-table-column> <el-table-column prop="organizeId" label="组织号" min-width="110" :show-overflow-tooltip="true" > <template #default="{ row }"> <div v-if=" row.organizeId === '' || row.organizeId === null || row.organizeId === undefined " > - </div> </template> </el-table-column> <el-table-column prop="created" label="创建时间" min-width="170" /> <el-table-column prop="last" label="更新时间" min-width="170" /> <el-table-column label="操作" width="260" fixed="right"> <template #default="{ row }"> <el-button class="operate" style="color: #165dff" link @click="onEditTable(row)" ><el-icon style="padding-right: 3px"><Edit /></el-icon >编辑</el-button > <el-text class="mx-1" style="color: #165dff; padding-left: 3px" >|</el-text > <el-button link @click="onStart(row)"> <el-button link v-if="row.enableStatus === 0" style="color: #00ff48" ><img style="width: 14px; padding-right: 3px" src="@/assets/logo.png" />启用</el-button > <el-button class="operate" link v-if="row.enableStatus === 1" style="color: #ff4646" ><img style="width: 13px; padding-right: 3px" src="@/assets/logo.png" />禁用</el-button > </el-button> <el-text class="mx-1" style="color: #165dff; padding-left: 3px" >|</el-text > <el-button link @click="inSureDevice(row)"> <el-button link style="color: #165dff" ><img style="width: 14px; padding-right: 3px" src="@/assets/logo.png" />绑定驾驶舱</el-button > </el-button> </template> </el-table-column> <template #empty> <el-empty description="没有数据"></el-empty> </template> </el-table> <el-pagination :teleported="false" v-model:current-page="params.pageNum" v-model:page-size="params.pageSize" :page-sizes="[5, 10]" layout="total,prev, pager, next,sizes" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" style="margin-top: 40px; margin-bottom: 40px; justify-content: end" /> </page-container> </template> <style lang="scss" scoped> .operate { margin-left: 0px !important; } // :deep .el-input__wrapper { // background-color: #f2f3f5; // } // 面包屑 .bread { height: 50px; display: flex; align-items: center; padding-left: 20px; :deep .el-breadcrumb__item:last-child .el-breadcrumb__inner { cursor: pointer !important; } } :deep .el-breadcrumb { display: flex; align-items: center; .el-breadcrumb__inner { color: #4e5969; } .el-breadcrumb__item { &:nth-child(1), &:last-child { .el-breadcrumb__inner { color: #1d2129; } } } } // 表格 :deep .el-scrollbar__wrap { max-height: 48vh; } // 分页 :deep .el-pagination { .el-pager li { // background-color: #fff; color: #000; // border: 1px solid #e5e5ea; border-radius: 2px; min-width: 32px; height: 32px; margin: 0 5px; } .el-pager li:hover { background-color: #e8f3ff; color: #165dff; } .el-pager li.is-active { background-color: #e8f3ff !important; color: #165dff !important; font-size: medium; } .btn-next, .btn-prev { // background-color: #fff; // border: 1px solid #e5e5ea; // border-radius: 5px; width: 32px; height: 32px; } } :deep .image-slot { display: flex; justify-content: center; align-items: center; width: 100%; height: 100%; background: var(--el-fill-color-light); color: var(--el-text-color-secondary); font-size: 20px; } </style>
06-18
<template> <div v-if="alltable" class="table-template"> <div class="table-content"> <!-- 动态显示隐藏列功能 --> <el-dropdown v-if="selectColumns" :hide-on-click="false" class="el-dropdown-selectColumn" trigger="click" @visible-change="dropdownSelectShow" > <span title="显示或隐藏某列" class="dropdown-button"> <el-icon :size="16"><Menu /></el-icon> </span> <template #dropdown> <el-dropdown-menu style="text-align: center"> <div class="dropdowntable" style="text-align: left"> <el-dropdown-item v-for="(item, index) in tableLabel" :key="index"> <template #default> <el-checkbox v-model="item.isShow" :checked="item.isShow" @change="reload" >{{ item.label }}</el-checkbox> </template> </el-dropdown-item> <el-dropdown-item v-if="tableCheckShow"> <template #default> <el-checkbox v-model="currTableOperationShow" :checked="currTableOperationShow" @change="reload" >操作</el-checkbox> </template> </el-dropdown-item> </div> </el-dropdown-menu> </template> </el-dropdown> <div class="table-main"> <el-table ref="multipleTable" v-loading="loading" :data="tableData" :row-key="rowKey" border :default-expand-all="defaultExpandAll" :highlight-current-row="highlightCurrentRow" :tree-props="treeProps" :height="height" :expand-row-keys="expandRowKeys" :span-method="spanMethod" @selection-change="selectionChange" @row-click="rowClick" @row-dblclick="rowdbClick" > <!--选择--> <el-table-column v-if="selectionShow" type="selection" align="center" fixed="left" :width="selectionWidth" :selectable="selectStatus" :reserve-selection="reserveSelection" /> <el-table-column v-if="radioShow && !selectionShow" :align="radioAlign" :width="radioWidth" > <template #default="scope"> <el-radio v-model="radioVal" :label="scope.row[rowKey]" :disabled="scope.row.radioStatus" @change="getRow(scope.row)" > <span /> </el-radio> </template> </el-table-column> <!--序号 自定义列序号--> <el-table-column v-if="indexShow" type="index" align="center" label="序号" fixed="left" :width="indexWidth" > <template #dafault="scope"> <span>{{ (nowPage - 1) * pageSize + scope.$index + 1 }}</span> </template> </el-table-column> <!-- 表格数据列 --> <template v-for="(item, index) in tableLabel"> <el-table-column v-if="selectColumns ? item.isShow || !isshowShow : true" :key="index" :prop="item.prop" :width="item.width" :min-width="item.minWidth" :fixed="item.fixed" :formatter="item.formatter" :align="item.align ? item.align : 'center'" :label="item.label" :show-overflow-tooltip="toolTip" > <template #default="scope"> <div v-if="item.isSelfContent"> <slot :scope="scope" :name="item.prop"></slot> </div> </template> </el-table-column> </template> <!--操作--> <el-table-column v-if="currTableOperationShow" :width="operationColumnWidth" label="操作" :align="operationAlign" fixed="right" > <template #default="scope"> <el-button v-if="addShow" size="small" type="success" title="新增" text @click="handleAdd(scope.row)" >新增</el-button> <el-button v-if="classifyAddShow && scope.row.children.length" size="small" type="success" text title="新增" @click="handleAdd(scope.row)" >新增</el-button> <el-button v-if="editShow" size="small" type="primary" text title="编辑" :disabled="scope.row.shareHolderStatus === 0" @click="handleEdit(scope.row)" >编辑</el-button> <el-button v-if="detailShow" size="small" text type="success" title="详情" @click="handleDetail(scope.row)" >详情</el-button> <el-button v-if="deleteShow" type="danger" text title="删除" size="small" @click="handleDelete(scope.row, scope.$index)" >删除</el-button> <slot :row="scope.row" :index="scope.$index" /> </template> </el-table-column> </el-table> </div> </div> <div> <!-- 自定义总计列,展示在表格内容下方,分页按钮上方 --> <slot name="totalContent"></slot> <div class="pagination-container"> <el-pagination v-if="paging" background :current-page="nowPage" :page-size="pageSize" :page-sizes="pageSizes" layout="total, sizes, prev, pager, next, jumper" :total="totalSize" @size-change="sizeChange" @current-change="currentChange" /> </div> </div> </div> </template> <script setup lang="ts"> import {ColumProps} from './types' import { PropType, reactive, toRefs, nextTick } from "vue" import { Check, Delete, Edit, Tickets, Menu } from '@element-plus/icons-vue' const props = defineProps({ //自定义列内容,比如加链接,加tag,加switch等 isSelfContent:{ type: Boolean, default: false, }, // 是否显示动态列功能,默认显示 selectColumns: { type: Boolean, default: true, }, // 表头列数据 tableLabel: { type: Array as PropType<ColumProps[]>, required: true, default: () => { return [] } }, // 表格没有操作列时,动态勾选的页面也没有操作勾选框 tableCheckShow: { type: Boolean, required: false, default: true }, // 表格最后操作列是否显示 tableOperationShow: { type: Boolean, required: false, default: true }, //加载中 loading: { type: Boolean, default: false }, // 表格数据 tableData: { type: Array, required: true, default: () => { return [] } }, // 行数据的key rowKey: { type: String, default: 'id' }, // 树结构表格是否默认打开 defaultExpandAll: { type: Boolean, default: false }, // 是否高亮显示某行 highlightCurrentRow: { type: Boolean, default: true }, // 树形表格渲染嵌套数据的配置选项{ hasChildren: 'hasChildren', children: 'children' } treeProps: { type: Object, default: () => { return {} } }, // 表格高度 height: { type: [Number, String], default: '100%' }, // 默认展开key数组 expandRowKeys: { type: Array, default: () => { return [] } }, //合并行单元格的列数组 columnList:{ type: Array, default: () => { return [] } }, // 单选按钮的默认值 radioValue: { type: [Number, String], default: -1 }, // 多选按钮,默认不显示多选 selectionShow: { type: Boolean, default: false }, // 多选宽度 selectionWidth: { type: Number, required: false, default: 50 }, // 数据更新后是否保留选择数据,仅对type=selection有效 reserveSelection: { type: Boolean, default: false }, // 单选 使用单选应将多选置为false radioShow: { type: Boolean, default: false }, // 单选对齐 radioAlign: { type: String, default: 'center' }, // 单选宽度 radioWidth: { type: Number, required: false, default: 35 }, // 序号列 indexShow: { type: Boolean, default: true }, // 序号宽度 indexWidth: { type: Number, required: false, default: 55 }, // 当前页 nowPage: { type: Number, default: 1 }, // 每页显示的条数 pageSize: { type: Number, default: 10 }, // 总条数 totalSize: { type: Number, default: 0 }, // 是否显示分页 paging: { type: Boolean, default: true }, // 是否控制列的动态显示 默认控制 isshowShow: { type: Boolean, default: true }, // 单元格内容超出宽度时是否...显示 toolTip: { type: Boolean, default: true }, // 表格操作列宽度 operationColumnWidth: { type: Number, required: false, default: 80 }, // 操作按钮对其方式 operationAlign: { type: String, default: 'center' }, // 显示详情操作按钮 detailShow: { type: Boolean, default: false }, // 显示编辑操作按钮 editShow: { type: Boolean, default: true }, // 显示新增操作按钮 addShow: { type: Boolean, default: false }, // 显示删除操作按钮 deleteShow: { type: Boolean, default: false }, classifyAddShow: { type: Boolean, default: false }, pageSizes: { type: Array as PropType<number[]>, default: () => { return [5, 10, 15, 20, 30, 50] } } }) const data = reactive({ alltable:true, currTableOperationShow:props.tableOperationShow, radioVal: props.radioValue, }) const {alltable, currTableOperationShow, radioVal} = toRefs(data) const emit = defineEmits(["selectionChange",'rowClick','rowdbClick','giveTableRowData','handleDetail','handleEdit','handleAdd','handleDelete','currentChange','sizeChange']) // 是否显示列的下拉框 function dropdownSelectShow(val:Boolean) { if (val === true) { var mo = (e:any) => { e.preventDefault() } document.body.style.overflow = 'hidden' document.addEventListener('touchmove', mo, false) // 禁止页面滑动 } } // 重新渲染 function reload() { data.alltable = false nextTick(() => { data.alltable = true }) } // 多选checkbox function selectionChange(val:object[]) { emit('selectionChange', val) } //单击行 function rowClick(row:any,column:any, event:any) { emit('rowClick', row) if (!row.radioStatus) { data.radioVal = row[props.rowKey] } } // 双击行 function rowdbClick(row:any, column:any, event:any) { emit('rowdbClick', row) } // 多选时是否禁用选择框,适用情形:从某个表格选择多条数据到另一个表格,已选过的数据不能再被选择,否则key重复 function selectStatus(row:any, index:number) { if (row.checkStatus) { return false } else { return true } } // 单选radio function getRow(row:any) { emit('giveTableRowData', row) } //合并列单元格 function spanMethod({row,columnIndex}:any){ const i = props.columnList.findIndex(v => v === columnIndex) if(i !== -1){ return { rowspan: row.rowSpan, colspan: 1, } }else{ return { rowspan: 1, colspan: 1, } } } // 查看详情 function handleDetail(row:any) { emit('handleDetail', row) } // 编辑 function handleEdit(row:any) { emit('handleEdit', row) } // 新增 function handleAdd(row:any) { emit('handleAdd', row) } // 删除 function handleDelete(row:any, index:number) { emit('handleDelete', row, index) } // 表格翻页 function currentChange(current:number) { emit('currentChange', current) } // 改变每页的条数 function sizeChange(size:number) { emit('sizeChange', size) } </script> <style lang="scss" scoped> .table-template{ height: 100%; position: relative; display: flex; flex-direction: column; .table-content{ flex:auto; position:relative; .table-main{ position:absolute; top:0; bottom:0; left:0; right:0; .el-button+.el-button{ margin-left:0px; } } } .el-dropdown-selectColumn { position: relative; float: right; z-index:999; // background-color: red; .dropdown-button { cursor: pointer; position: absolute; z-index: 9999; top: 5px; left: -20px; } .dropdowntable { width: 100%; max-height: 200px !important; overflow: auto !important; } } .selectColumn { margin-bottom: 10px; height: auto; } :deep(.pagination-container) { float:right; padding-top:5px; .el-pagination button, .el-pagination span:not([class*=suffix]) { font-size: 13px; min-width: 30px; height: 28px; line-height: 28px; } .el-pagination.is-background .btn-next, .el-pagination.is-background .btn-prev, .el-pagination.is-background .el-pager li { min-width: 30px; border-radius: 2px; margin: 0 5px; } .el-pagination .btn-next, .el-pagination .btn-prev { background-size: 16px; } .el-pagination__jump { margin-left: 24px; } .el-pagination__goto { margin-right:0px; } .el-pager li { padding: 0 4px; font-size: 13px; height: 26px; line-height: 26px; } .el-pagination .el-select .el-input { width: 100px; height:28px; } .el-pagination .el-input__inner { height:26px; } .el-pagination .is-first { margin-right:0px; height:26px!important; line-height: 30px!important; } } } </style> <template> <TableTemplate :loading="loading" :table-data="tableData.list" :table-label="tableLabel" :span-method="columnList" :now-page="tableData.currPage" :page-size="tableData.pageSize" :total-size="tableData.totalCount" :detail-show="false" :edit-show="false" :tableOperationShow="false" :highlight-current-row="true" row-key="chargeId" @currentChange="handleCurrentChange" @sizeChange="handleSizeChange" > <template #totalContent> <div class="total-container"> <div>充电量(kw.h):{{ countData.electricQuantity || 0 }}</div> <div>应付总额:{{ countData.totalMoney || 0 }} 元</div> <div>结算总额:{{ countData.closeMoney || 0 }} 元</div> <div>优惠总额:{{ countData.discountMoney || 0 }} 元</div> </div> </template> </TableTemplate> </template> <script setup lang="ts"> import { reactive } from "vue"; import { storeToRefs } from "pinia"; import TableTemplate from "@/components/TableTemplate/index.vue"; import carCardPayDetailStore from "@/store/modules/order/carCardPayDetail"; const store = carCardPayDetailStore(); const { loading, tableData, countData } = storeToRefs(store); const { searchForm } = store; const tableLabel = reactive([ { label: "日期", prop: "dates", isShow: true, minWidth: 90, },{ label: "会员姓名", prop: "memberName", isShow: true, minWidth: 100, },{ label: "手机号", prop: "memberMobile", isShow: true, minWidth: 100, },{ label: "VIN号", prop: "vin", isShow: true, minWidth: 140, },{ label: "车牌号", prop: "licensePlate", isShow: true, minWidth: 90, }, { label: "充电量(kw.h)", prop: "electricQuantity", isShow: true, minWidth: 90, }, { label: "应付金额(¥)", prop: "totalMoney", isShow: true, minWidth: 90, }, { label: "优惠金额(¥)", prop: "discountMoney", isShow: true, minWidth: 90, }, { label: "预付金额(¥)", prop: "prepayMoney", isShow: true, minWidth: 90, }, { label: "结算金额(¥)", prop: "closeMoney", isShow: true, minWidth: 90, }, { label: "所属公司1", prop: "value1", isShow: true, minWidth: 90, }, { label: "所属公司2", prop: "value2", isShow: true, minWidth: 90, }, { label: "所属公司3", prop: "value3", isShow: true, minWidth: 90, }, { label: "所属公司4", prop: "value4", isShow: true, minWidth: 90, }, { label: "所属公司5", prop: "value5", isShow: true, minWidth: 90, }, { label: "所属公司6", prop: "value6", isShow: true, minWidth: 90, }, { label: "所属公司", prop: "company", isShow: true, minWidth: 100, }, { label: "所属站点", prop: "siteName", isShow: true, minWidth: 100, } ]); const columnList = [12,13,14,15,16] // 改变当前页 function handleCurrentChange(val: number) { searchForm.nowPage = val; store.getTableData(searchForm); } // 改变当前显示条数 function handleSizeChange(val: number) { searchForm.nowPage = 1; searchForm.pageSize = val; store.getTableData(searchForm); } </script> 请帮我修改代码:span-method第12列到16列需要合并
最新发布
10-28
<template> <div> <div class="access"> <div class="access-system"> <TitleName text="平台接入系统" width="166px"></TitleName> <div class="access-left flex-right"> <div class="access-left-item" v-for="(v, i) in access" :key="i"> <div class="access-left-text" @click="accessSystem(v.text)">{{ v.data }}</div> <div class="access-left-item-text">{{ v.text }}</div> </div> </div> </div> <div class="access-statistics"> <TitleName text="平台接入统计" width="182px"></TitleName> <div class="access-right flex-left"> <div class="access-left-item" v-for="(v2, i2) in total" :key="i2"> <div :class="v2.text == '单位总计' ? 'access-left-text' : 'access-left-text2'" @click="todevice(v2.text, '')"> {{ v2.data }} </div> <div class="access-left-item-text">{{ v2.text }}</div> </div> </div> </div> </div> <!-- 添加CustomDialog组件 --> <CustomDialog v-model:visible="elevatorVisible" :title="elevatorTitle"> <!-- 电梯监控列表 --> <el-button type="primary" @click="openAddDialog" style="margin-top: -20px">新增</el-button> <el-table :data="elevatorData" v-loading="elevatorloading"> <el-table-column property="name" show-overflow-tooltip label="名称" /> <el-table-column property="deviceCode" show-overflow-tooltip label="设备编号" /> <el-table-column property="status" label="状态" width="60"> <template #default="{ row }"> <!-- <el-icon :color="row.status === 1 ? 'green' : 'red'"> <SuccessFilled v-if="row.status === 1" /> <CircleCloseFilled v-else /> </el-icon> --> {{ row.status === 1 ? '在线' : '离线' }} </template> </el-table-column> <el-table-column property="createTime" :formatter="formatDateTime" label="创建时间" /> <el-table-column property="updateTime" :formatter="formatDateTime" label="修改时间" /> <el-table-column label="操作" width="200px"> <template #default="{ row }"> <el-button style="margin-left: 5px" size="small" @click="openPlay(row)">播放</el-button> <el-button style="margin-left: 5px" size="small" @click="openEitd(row)">修改</el-button> <el-button style="margin-left: 5px" size="small" @click="openwarning(row)">预警</el-button> <!-- <el-button style="margin-left: 5px" @click="openwarning(row)" size="small">预警</el-button> --> </template> </el-table-column> </el-table> <!-- 分页组件 --> <div class="pagination-container"> <el-pagination v-model:current-page="pagination.currentPage" v-model:page-size="pagination.pageSize" :page-sizes="[5, 10, 20, 30]" :total="pagination.total" layout="total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange" @current-change="handleCurrentChange" /> </div> </CustomDialog> <!-- 新增 --> <CustomDialog v-model:visible="addVisible" :title="addTitle" typeEit="" style="height: 350px; width: 650px"> <el-form label-width="120px" style="max-width: 600px; margin-top: 10px" :model="ruleForm" status-icon class="demo-ruleForm"> <el-form-item label="身份证" prop="id"> <el-input v-model="ruleForm.id" placeholder="请输入身份证号" /> </el-form-item> <el-form-item label="名字" prop="name"> <el-input v-model="ruleForm.name" placeholder="名字" /> </el-form-item> <el-form-item label="设备代码" prop="deviceCode"> <el-input v-model="ruleForm.deviceCode" placeholder="请输入设备代码" /> </el-form-item> <el-form-item label="创建时间" prop="createTime"> <el-date-picker style="width: 480px" v-model="ruleForm.createTime" type="datetime" placeholder="请选择" /> </el-form-item> <el-form-item label="更新时间" prop="updateTime"> <el-date-picker style="width: 480px" v-model="ruleForm.updateTime" type="datetime" placeholder="请选择" /> </el-form-item> </el-form> <div style="width: 95%; display: flex; justify-content: flex-end"> <el-button type="primary" style="background-color: #153b63" @click="submitForm">确定</el-button> </div> </CustomDialog> <!-- 预警图片展示 --> <CustomDialog v-model:visible="warningVisible" :title="warningTitle" :mountShow="mountShow"> <el-table :data="warningData" v-loading="warningLoading" height="600px"> <el-table-column property="deviceCode" show-overflow-tooltip label="设备编号" /> <el-table-column property="status" label="状态" width="60"> <template #default="{ row }"> {{ row.status === 1 ? '在线' : '离线' }} </template> </el-table-column> <el-table-column prop="img" label="图片"> <template #default="{ row }"> <el-image v-for="(item, idx) in row.img.split(',')" :key="idx" :src="`/img/${item}`" :zoom-rate="1.2" :max-scale="7" :min-scale="0.2" preview-teleported="true" show-progress :preview-src-list="row.img.split(',').map((i: any) => `/img/${i}`)" fit="cover" style="width: 50px; height: 50px" /> </template> </el-table-column> <el-table-column property="createTime" :formatter="formatDateTime" label="创建时间" /> </el-table> <div class="pagination-container"> <el-pagination v-model:current-page="warningPage.currentPage" v-model:page-size="warningPage.pageSize" :page-sizes="[5, 10, 20]" :total="warningPage.total" layout="total, sizes, prev, pager, next, jumper" @size-change="warningSizeChange" @current-change="warningCurrentChange" /> </div> </CustomDialog> <div class="center-video" v-if="open"> <vue3videoPlay width="1200px" height="700" v-if="open" style="object-fit: cover" :autoPlay="options.autoPlay" :control="options.control" :loop="options.loop" :muted="options.muted" :src="`http://36.138.229.106:9092/hls/${videoUrl}.m3u8`" type="m3u8" /> <el-button class="close-btn" @click="closePlay">关闭 X</el-button> </div> </div> <!-- @click="todevice('', v2.text)" --> </template> <script lang="ts"> import { defineComponent, ref, defineEmits, onMounted, reactive, nextTick } from 'vue'; import TitleName from './TitleName.vue'; import { ElMessage, ElPopover, ElTooltip } from 'element-plus'; import { statisticsPlatform, statisticsPlatformResDataCurrent, statisticsSystemResDataCurrent } from '@/request/statisticsPlatform'; import { statisticsSystem } from '@/request/statisticsSystem'; import router from '@/router'; import CustomDialog from '@/components/CustomDialog.vue'; import vue3videoPlay from 'vue3-video-play'; // 引入npm i vue3-video-play --save import 'vue3-video-play/dist/style.css'; // 引入css样式 import WarningView from '@/UnitHome/WarningView.vue'; import dayjs from 'dayjs'; export default defineComponent({ components: { TitleName, CustomDialog, vue3videoPlay, }, setup(props, context) { const visible = ref(false); const total = ref<any[]>([]); const access = ref<any[]>([]); const elevatorVisible = ref(false); // 控制弹窗显示 const elevatorTitle = ref('电梯视频监控'); // 弹窗标题 const elevatorData = ref(); //电梯监控表格 const elevatorloading = ref(true); // const addVisible = ref(false); // 控制弹窗显示 const open = ref(false); // 电梯监控视频播放弹窗显示 const addTitle = ref<'新增电梯视频监控' | '修改电梯视频监控'>('新增电梯视频监控'); // 弹窗标题 const dialogType = ref<'add' | 'edit'>('add'); // 默认新增 const videoUrl = ref(''); //视频地址 const warningVisible = ref(false); // 预警弹窗 const warningTitle = ref('预警图片展示'); // 预警弹窗标题 const warningData = ref(); //预警列表 const warningLoading = ref(false); //预警loding const mountShow = ref(false); const videoPlayer = ref<HTMLVideoElement>(); interface VideoOptions { autoPlay: boolean; loop: boolean; control: boolean; muted: boolean; type: string; } const options = ref<VideoOptions>({ type: 'm3u8', //视频类型 autoPlay: true, //是否自动播放 loop: false, //是否循环播放 control: true, //是否显示控制条 muted: true, //静音 }); // 表单字段信息 const ruleForm = ref({ id: '', name: '', deviceCode: '', createTime: '', updateTime: '', }); // 分页参数 const pagination = ref({ currentPage: 1, pageSize: 10, total: 0, }); // 分页参数 const warningPage = ref({ currentPage: 1, pageSize: 10, total: 0, }); const resData = ref<statisticsSystemResDataCurrent>({ electronic: 0, water: 0, wireless: 0, surveillance: 0, fire: 0, elevator: 0, }); const resData2 = ref<statisticsPlatformResDataCurrent>({ unit: 0, sensor: 0, building: 0, surveillance: 0, equipment: 0, camera: 0, }); const iconClick = (v: any) => { console.log(321); }; const popoverData = ref({}); // 初始化数据 const fetchData = async () => { statisticsPlatform().then((res: any) => { resData2.value = res; total.value = [ { text: '单位总计', icon: require('../res/17.png'), data: resData2.value.unit, }, { text: '传感器总计', icon: require('../res/16.png'), data: resData2.value.sensor, }, // { // text: '建筑总计', // icon: require('../res/15.png'), // data: resData2.value.building, // }, { text: '监控点总计', icon: require('../res/14.png'), data: resData2.value.camera, }, { text: '消防设备总计', icon: require('../res/13.png'), data: resData2.value.equipment, }, { text: '视频设备总计', icon: require('../res/12.png'), data: resData2.value.surveillance, }, ]; }); statisticsSystem().then((res: any) => { resData.value = res; access.value = [ { text: '电气火灾系统', icon: require('../res/22.png'), data: resData.value.electronic, }, { text: '消防水源系统', icon: require('../res/21.png'), data: resData.value.water, }, { text: '无线报警系统', icon: require('../res/20.png'), data: resData.value.wireless, }, { text: '视频监控系统', icon: require('../res/19.png'), data: resData.value.surveillance, }, { text: '火灾报警系统', icon: require('../res/18.png'), data: resData.value.fire, }, { text: '电梯视频监控', icon: require('../res/18.png'), data: resData.value.fire, }, ]; }); }; const todevice = (v: string, v2: string) => { if (v.indexOf('总计') != -1 && v != '单位总计') { return; } if (v == '单位总计') { v = ''; } sessionStorage.Record2Id = JSON.stringify({ id: '', type: '', deviceType: v, page: 1, limit: 20, }); sessionStorage.deviceTitle = v2; router.push('/unitdevice'); }; // 获电梯数据(带分页) const fetchElevatorData = async () => { elevatorloading.value = true; try { const response = await fetch( `http://36.138.229.106:9091/yuShiDevice/getList?pageSize=${pagination.value.pageSize}&pageNo=${pagination.value.currentPage}` ); const res = await response.json(); elevatorData.value = res.data?.records || []; pagination.value.total = res.data?.total || 0; } catch (error) { console.error('获电梯数据失败:', error); ElMessage.error('获电梯数据失败'); } finally { elevatorloading.value = false; } }; const handleSizeChange = (val: number) => { pagination.value.pageSize = val; fetchElevatorData(); }; // 当前页改变 const handleCurrentChange = (val: number) => { pagination.value.currentPage = val; fetchElevatorData(); }; // 电梯视频监控数据列表 const accessSystem = (v: string) => { // 如果是电梯视频建监控,显示弹窗而不是跳转 if (v == '电梯视频监控') { elevatorVisible.value = true; // 重置分页参数 pagination.value.currentPage = 1; pagination.value.pageSize = 10; fetchElevatorData(); return; } }; // 事件格式转换 const formatDateTime = (row: any, column: any, cellValue: any) => { if (!cellValue) return '-'; return dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss'); }; // 新增设备弹窗打开 const openAddDialog = () => { dialogType.value = 'add'; ruleForm.value = { // 重置表单 id: '', name: '', deviceCode: '', createTime: '', updateTime: '', }; addVisible.value = true; return; }; // 新增表单 const submitForm = async () => { const data = ruleForm.value; const opt = { id: Number(data?.id), name: data?.name, deviceCode: data?.deviceCode, // createTime: dayjs(data?.createTime).format('YYYY-MM-DD HH:mm:ss'), // updateTime: dayjs(data?.updateTime).format('YYYY-MM-DD HH:mm:ss'), }; if (ruleForm.value && dialogType.value == 'add') { console.log('表单数据:', ruleForm.value); // 新增保存接口 fetch('http://36.138.229.106:9091/yuShiDevice/deviceInset', { method: 'POST', // 指定请求方法 headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ ...opt, }), }) .then((res: any) => { addVisible.value = false; ElMessage.success('新增成功'); fetchElevatorData(); }) .catch((error) => console.error('Error:', error)); } else { // 修改接口 fetch('http://36.138.229.106:9091/yuShiDevice/deviceUpdate', { method: 'POST', // 指定请求方法 headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ ...opt, }), }) .then((res: any) => { addVisible.value = false; ElMessage.success('修改成功'); fetchElevatorData(); }) .catch((error) => console.error('Error:', error)); } }; // 修改设备 const openEitd = (data: any) => { dialogType.value = 'edit'; addTitle.value = '修改电梯视频监控'; addVisible.value = true; ruleForm.value = { ...data }; }; // 视频播放 const openPlay = (row: any) => { fetch(`http://36.138.229.106:9091/yuShiDevice/yuShi?deviceId=${row.deviceCode}&type=${1}`) .then((res: any) => { videoUrl.value = row.deviceCode; open.value = true; }) .catch((error) => { console.error('获视频数据失败:', error); ElMessage.error('获视频数据失败'); }); // 错误处理 }; // 删除播放视频 const closePlay = async () => { if (videoUrl.value) { console.log(videoUrl.value, 'deviceCode.value'); open.value = false; try { const response = await fetch(`http://36.138.229.106:9091/yuShiDevice/yuShi?deviceId=${videoUrl.value}&type=${2}`); console.log(response, 'response'); } catch (error) { console.error('删除失败:', error); ElMessage.error('删除视频数据失败'); } } }; const deviceCode = ref(); // // 当前页改变 const warningCurrentChange = (val: number) => { warningPage.value.currentPage = val; fetcWarningData(); }; const warningSizeChange = (val: number) => { warningPage.value.pageSize = val; fetcWarningData(); }; // 获预警数据 const fetcWarningData = async () => { warningLoading.value = true; try { const response = await fetch( `http://36.138.229.106:9091/yuShiDevice/alarmList?deviceId=${deviceCode.value}&pageSize=${warningPage.value.pageSize}&pageNo=${warningPage.value.currentPage}` ); const res = await response.json(); warningLoading.value = false; warningData.value = res.data?.records || []; warningPage.value.total = res.data?.total || 0; } catch (error) { console.error('获视频数据失败:', error); ElMessage.error('获视频数据失败'); } }; // 预警操作 const openwarning = async (row: any) => { warningVisible.value = true; mountShow.value = true; deviceCode.value = row.deviceCode; // 重置分页参数 warningPage.value.currentPage = 1; warningPage.value.pageSize = 10; fetcWarningData(); }; // 组件挂载时获数据 onMounted(fetchData); return { access, total, visible, todevice, accessSystem, elevatorVisible, elevatorTitle, elevatorData, elevatorloading, formatDateTime, pagination, handleSizeChange, handleCurrentChange, openAddDialog, addVisible, addTitle, ruleForm, submitForm, openEitd, dialogType, openPlay, videoPlayer, videoUrl, open, options, closePlay, warningVisible, warningTitle, openwarning, warningData, warningLoading, warningSizeChange, warningCurrentChange, warningPage, mountShow, }; }, }); </script> <style lang="scss" scoped> .access { display: flex; justify-content: space-between; align-items: center; margin-top: 25px; margin-bottom: 10px; width: 356px; box-sizing: border-box; } .access-system, .access-statistics { display: flex; flex-direction: column; // padding-left: 8px; } .access-system { .access-left { display: flex; justify-content: space-around; align-items: center; flex-wrap: wrap; } } .access-left-item { white-space: nowrap; height: 55px; display: flex; flex-direction: column; justify-content: center; align-items: center; .access-left-text { cursor: pointer; color: #00ffff; font-size: 18px; border-bottom: 2px solid #00ffff; } .access-left-text2 { cursor: pointer; color: #00ffff; font-size: 18px; } } .access-left-item-box { width: 37px; height: 37px; border-radius: 50%; display: flex; cursor: pointer; justify-content: center; align-items: center; .access-left-item-icon { width: 37px; height: 37px; border-radius: 50%; } } .access-left-item-text { width: 72px; height: 14px; font-size: 10px; font-family: AlibabaPuHuiTi_2_55_Regular-, AlibabaPuHuiTi_2_55_Regular; font-weight: normal; color: #0283c2; text-align: center; margin-top: 8px; line-height: 12px; } .access-left, .access-right { width: 165px; height: 240px; display: flex; justify-content: space-around; align-items: center; flex-wrap: wrap; background: linear-gradient(180deg, rgba(1, 76, 131, 0.145) 0%, rgba(1, 76, 131, 0.11) 100%); border-radius: 3px 3px 3px 3px; } .flex-left { align-self: flex-start; } .flex-right { align-self: flex-end; } .popover { width: 100px; min-width: 0px !important; position: relative; height: 100px; font-size: 12px; background-color: #081343; color: #ffffff; text-align: center; box-shadow: 1px 1px 8px 2px #00ffff; border-radius: 3px; left: -12px; top: -13px; .popover-hr { height: 1px; width: 100%; background: linear-gradient( 90deg, rgba(1, 76, 131, 0.6) 0%, rgba(1, 76, 131, 0) 0%, rgba(0, 255, 255, 1) 52%, rgba(1, 76, 131, 0) 95%, rgba(1, 76, 131, 0.5) 100% ); } .popover-hr2 { position: absolute; left: 187px; top: 0; height: 190px; width: 1px !important; background: linear-gradient( 180deg, rgba(1, 76, 131, 0.6) 0%, rgba(1, 76, 131, 0) 0%, rgba(0, 255, 255, 1) 52%, rgba(1, 76, 131, 0) 95%, rgba(1, 76, 131, 0.5) 100% ); } .popover-hr3 { position: absolute; right: 187px; top: 0px; height: 190px; width: 1px !important; background: linear-gradient( 180deg, rgba(1, 76, 131, 0.6) 0%, rgba(1, 76, 131, 0) 0%, rgba(0, 255, 255, 1) 52%, rgba(1, 76, 131, 0) 95%, rgba(1, 76, 131, 0.5) 100% ); } > div { display: flex; width: 100px; height: 100px; > div { flex: 1; padding-top: 26px; } } .num { cursor: pointer; font-size: 17px; color: #00ffff; } } </style> <style lang="scss" scoped> /* 确保弹窗的 z-index 足够高 */ :deep(.el-dialog) { z-index: 2000 !important; } /* 确保图片预览的 z-index 高于弹窗 */ :deep(.el-image-viewer__wrapper) { z-index: 3000 !important; } // 视频样式 .center-video { position: fixed; top: 20%; left: 17%; z-index: 999999999; padding: 30px; background: rgba(0, 0, 0, 0.7); /* 可选:添加半透明背景 */ border-radius: 8px; .close-btn { position: absolute; top: 10px; /* 调整与顶部的距离 */ right: 10px; /* 调整与右侧的距离 */ z-index: 99999999999; background: rgba(255, 255, 255, 0.3); border: none; color: white; padding: 5px 10px; border-radius: 4px; cursor: pointer; } .close-btn:hover { background: rgba(255, 255, 255, 0.5); } } /* 添加分页样式 */ .pagination-container { margin-top: 12px; display: flex; justify-content: flex-end; :deep(.el-pager li) { background-color: #081242; color: #014c83; } :deep(.el-pager li.is-active) { color: #00ffff; border: 1px solid; } :deep(.el-pagination button) { background-color: #014c83; color: #279ee0; } :deep(.el-pagination__goto) { // background-color: #014c83; font-size: 12px; color: #279ee0; } :deep(.el-pagination__classifier) { background-color: #014c83; color: #279ee0; } :deep(.el-input__wrapper) { background-color: #014c83; color: #00ffff; } :deep(.el-input__inner) { color: #00ffff; } :deep(.el-input) { --el-input-border-color: #014c83; } } </style> 上面代码vue3+ts优化vue3videoPlay 插件打开链接时候服务器上传还没成功有延迟 这种情况怎么解决
06-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值