当前位置: 首页 > news >正文

浙江经营性网站备案百度官网网站

浙江经营性网站备案,百度官网网站,做公众号要不要有自己的网站,用网站做自我介绍自己Vue3 TypeScript Element Plus 开启边框 > 调整列宽(拖动表头)> 保存列宽(本地存储)> 加载列宽(读取本地数据) 初始效果: 1、开启边框,点击【设置列宽】 2、调整列宽&am…

Vue3 + TypeScript + Element Plus 开启边框 > 调整列宽(拖动表头)> 保存列宽(本地存储)> 加载列宽(读取本地数据)

初始效果:

1、开启边框,点击【设置列宽】

 2、调整列宽,在表头的纵向边框处,按住拖动

3、保存列宽,列宽数据保存在本地 localStorage

4、打开页面,加载列宽 ,从本地 localStorage 中读取列宽数据

技术栈:

1、涉及表格属性:border、 @header-dragend

2、涉及表格列属性:prop、width

3、本地存储 localStorage

4、相关逻辑:存储表格列宽 localStorage.setItem、加载表格列宽 localStorage.getItem

相关代码:Reagent.vue

<script setup lang="ts" name="Reagent">
......// 边框标识
const isBorder = ref(false);// 设置列宽
const onSetColumnWidthClick = () => {isBorder.value = !isBorder.value;
};// 存储表格列宽
const saveColumnWidth = (newWidth: number, oldWidth: number, column: TableColumnCtx<IReagent>, event: MouseEvent) => {let prop = column.property;localStorage.setItem(`reagent_colWidth_${prop}`, newWidth.toString());
};// 加载表格列宽
const loadColumnWidth = (prop: string, defaultValue: number) => {let colWidth = localStorage.getItem(`reagent_colWidth_${prop}`);return colWidth ? parseInt(colWidth, 10) : defaultValue;
};......
</script><template>......<BasePreventReClickButton class="header-btn" type="primary" plain :onClick="onSetColumnWidthClick" :delay="0">设置列宽</BasePreventReClickButton>......<el-tableref="table":data="store.reagentPageList"v-loading="store.loading":border="isBorder"highlight-current-rowstripe:show-summary="false"style="width: 100%; height: 100%"@header-dragend="saveColumnWidth"><el-table-columntype="index"prop="index"label="序号":width="loadColumnWidth(`index`, 60)"fixed="left"header-align="center"align="center" /><el-table-columnprop="reagentName"label="名称 规格"min-width="200"fixed="left"header-align="left"sortableshow-overflow-tooltip><template #default="scope"><span class="material-name">{{ scope.row.reagentName }}</span><span class="material-spec">{{ scope.row.reagentSpec }}</span></template></el-table-column><el-table-columnprop="batchNo"label="批号":width="loadColumnWidth(`batchNo`, 120)"header-align="left"show-overflow-tooltip /><el-table-columnprop="validityDate"label="有效期至":width="loadColumnWidth(`validityDate`, 110)"header-align="center"align="center"show-overflow-tooltip /><el-table-columnprop="amount":width="loadColumnWidth(`amount`, 80)"header-align="center"align="center"resizableshow-overflow-tooltip><template #header><div class="custom-table-column-header-amount-unit-div">库存数量</div></template><template #default="scope"><div class="custom-table-row-default-amount-unit-div"><span>{{ scope.row.amount }}</span><span>{{ scope.row.reagentUnit }}</span></div></template></el-table-column><el-table-column label="操作" header-align="center" align="center" fixed="right" width="150"><template #default="scope"><el-buttonclass="table-btn"type="primary"size="default"text@click="onModifyClick(scope.$index, scope.row)">查改</el-button><el-button class="table-btn" type="warning" size="default" text @click="onLogoutClick(scope.row.id)">注销</el-button><el-button class="table-btn" type="primary" size="default" text @click="onTransactionsClick(scope.row.id)">明细</el-button></template></el-table-column></el-table>......
</template>

完整代码:Reagent.vue

<script setup lang="ts" name="Reagent">
import BasePreventReClickButton from "@/components/base/BasePreventReClickButton.vue";
import { Search } from "@element-plus/icons-vue";
import { ElMessage, ElMessageBox, type TableColumnCtx } from "element-plus";
import { isEqual } from "lodash-es";
import { nextTick, onMounted, ref } from "vue";
import ReagentApplyDialog from "./reagent/comps/ReagentApplyDialog.vue";
import ReagentInDialog from "./reagent/comps/ReagentInDialog.vue";
import ReagentInfoDialog from "./reagent/comps/ReagentInfoDialog.vue";
import ReagentOutDialog from "./reagent/comps/ReagentOutDialog.vue";
import ReagentTransactionsDrawer from "./reagent/comps/ReagentTransactionsDrawer.vue";
import useReagentStore from "./reagent/stores";
import type { IReagent } from "./reagent/types";const store = useReagentStore();
// 当前表格选择行
const currentSelectedRow = ref<IReagent>({id: 0,reagentCategory: "",reagentNo: "",reagentName: "",reagentSpec: "",reagentUnit: ""
});
// 是否新增
const isNew = ref(true);
// 试剂耗材入库模态框实例对象
const reagentInDialogRef = ref<InstanceType<typeof ReagentInDialog> | null>(null);
// 试剂耗材申领模态框实例对象
const reagentApplyDialogRef = ref<InstanceType<typeof ReagentApplyDialog> | null>(null);
// 试剂耗材出库模态框实例对象
const reagentOutDialogRef = ref<InstanceType<typeof ReagentOutDialog> | null>(null);
// 试剂耗材信息模态框实例对象
const reagentInfoDialogRef = ref<InstanceType<typeof ReagentInfoDialog> | null>(null);
// 试剂耗材流转记录抽屉实例对象
const reagentTransactionsDrawerRef = ref<InstanceType<typeof ReagentTransactionsDrawer> | null>(null);
// 边框标识
const isBorder = ref(false);// 入库
const onInClick = () => {isNew.value = true;// 打开试剂耗材入库模态框reagentInDialogRef.value?.openDialog();
};// 申领
const onReceiveClick = () => {//  打开试剂耗材申领模态框reagentApplyDialogRef.value?.openDialog();
};// 出库
const onOutClick = () => {// 打开试剂耗材出库模态框reagentOutDialogRef.value?.openDialog();
};// 明细查询
const onDetailClick = async () => {await reagentTransactionsDrawerRef.value?.openDrawerByQuery();
};// 刷新数据
const onRefreshClick = async () => {await store.fetchReagentPageList();
};// 查询
const onQueryClick = async () => {// 分页页数及显示数量变动监听标识,设置为 false,后面更改 page,不会触发分页监听store.onPageOrSizeChangeValid = false;// 重置当前页码为 1store.queryObj.pageHelper.page = 1;// 刷新数据await onRefreshClick();
};// 查改
const onModifyClick = async (index: number, row: IReagent) => {isNew.value = false;currentSelectedRow.value = row;await nextTick();reagentInfoDialogRef.value?.openDialog();
};// 注销
const onLogoutClick = async (id: number) => {try {await ElMessageBox.confirm("确定注销吗?", "询问", {cancelButtonText: "取消",confirmButtonText: "确定",type: "warning"});await store.fetchLogoutReagent(id);ElMessage.success("注销成功!");// 刷新数据await onRefreshClick();} catch (error) {}
};// 明细(流转明细)
const onTransactionsClick = async (id: number) => {await reagentTransactionsDrawerRef.value?.openDrawerByTransactions(id);
};// 更新试剂
const handleUpdateReagent = async (reagent: IReagent) => {// 两个对象不相同,需要更新数据;如果两个对象相同(所有属性值都相同),不需要更新数据if (!isEqual(currentSelectedRow.value, reagent)) {try {// 发送网络请求,更新数据await store.fetchUpdateReagent(reagent);} catch (error) {return;}// 使用浅拷贝,复制对象引用,同步更新页面数据Object.assign(currentSelectedRow.value, reagent);}
};// 改变页码、显示数量,重新获取数据
const onPageOrSizeChange = async (currentPage: number, pageSize: number) => {if (!store.onPageOrSizeChangeValid) {return;}store.queryObj.pageHelper.page = currentPage;store.queryObj.pageHelper.size = pageSize;// 刷新数据await onRefreshClick();
};// 设置列宽
const onSetColumnWidthClick = () => {isBorder.value = !isBorder.value;
};// 存储表格列宽
const saveColumnWidth = (newWidth: number, oldWidth: number, column: TableColumnCtx<IReagent>, event: MouseEvent) => {let prop = column.property;localStorage.setItem(`reagent_colWidth_${prop}`, newWidth.toString());
};// 加载表格列宽
const loadColumnWidth = (prop: string, defaultValue: number) => {let colWidth = localStorage.getItem(`reagent_colWidth_${prop}`);return colWidth ? parseInt(colWidth, 10) : defaultValue;
};onMounted(async () => {// 刷新数据await onRefreshClick();
});
</script><template><el-container class="container"><el-header class="header"><!-- 标题 --><div class="header-title">试剂耗材管理</div><!-- 操作栏 --><div class="header-operation"><div><BasePreventReClickButton class="header-btn" type="primary" plain :onClick="onInClick">入库</BasePreventReClickButton><BasePreventReClickButton class="header-btn" type="primary" plain :onClick="onReceiveClick" :delay="0">申领</BasePreventReClickButton><BasePreventReClickButton class="header-btn" type="primary" plain :onClick="onOutClick" :delay="0">出库</BasePreventReClickButton><BasePreventReClickButton class="header-btn" type="primary" plain :onClick="onDetailClick" :delay="0">明细查询</BasePreventReClickButton><BasePreventReClickButton class="header-btn" type="primary" plain :onClick="onRefreshClick" :delay="0">刷新数据</BasePreventReClickButton><BasePreventReClickButton class="header-btn" type="primary" plain :onClick="onSetColumnWidthClick" :delay="0">设置列宽</BasePreventReClickButton></div><div class="query-div"><el-input v-model="store.queryObj.reagentName" placeholder="请输入试剂关键字进行查询" clearable><template #prefix><el-icon><Search /></el-icon></template></el-input><BasePreventReClickButton class="query-btn" type="primary" plain :onClick="onQueryClick" :delay="100">查询</BasePreventReClickButton></div></div></el-header><el-main class="main"><!-- 展示区 --><el-tableref="table":data="store.reagentPageList"v-loading="store.loading":border="isBorder"highlight-current-rowstripe:show-summary="false"style="width: 100%; height: 100%"@header-dragend="saveColumnWidth"><el-table-columntype="index"prop="index"label="序号":width="loadColumnWidth(`index`, 60)"fixed="left"header-align="center"align="center" /><el-table-columnprop="reagentName"label="名称 规格"min-width="200"fixed="left"header-align="left"sortableshow-overflow-tooltip><template #default="scope"><span class="material-name">{{ scope.row.reagentName }}</span><span class="material-spec">{{ scope.row.reagentSpec }}</span></template></el-table-column><el-table-columnprop="batchNo"label="批号":width="loadColumnWidth(`batchNo`, 120)"header-align="left"show-overflow-tooltip /><el-table-columnprop="validityDate"label="有效期至":width="loadColumnWidth(`validityDate`, 110)"header-align="center"align="center"show-overflow-tooltip /><el-table-columnprop="amount":width="loadColumnWidth(`amount`, 80)"header-align="center"align="center"resizableshow-overflow-tooltip><template #header><div class="custom-table-column-header-amount-unit-div">库存数量</div></template><template #default="scope"><div class="custom-table-row-default-amount-unit-div"><span>{{ scope.row.amount }}</span><span>{{ scope.row.reagentUnit }}</span></div></template></el-table-column><!-- <el-table-column prop="total" label="余额" width="110" header-align="right" align="right" show-overflow-tooltip><template #default="scope">{{ formatMoney(scope.row.total, "¥", 2) }}</template></el-table-column> --><el-table-column label="操作" header-align="center" align="center" fixed="right" width="150"><template #default="scope"><el-buttonclass="table-btn"type="primary"size="default"text@click="onModifyClick(scope.$index, scope.row)">查改</el-button><el-button class="table-btn" type="warning" size="default" text @click="onLogoutClick(scope.row.id)">注销</el-button><el-button class="table-btn" type="primary" size="default" text @click="onTransactionsClick(scope.row.id)">明细</el-button></template></el-table-column></el-table></el-main><el-footer class="footer"><!-- 分页 --><el-pagination:total="store.total":page-sizes="[20, 50, 100, 200, 500]"v-model:page-size="store.queryObj.pageHelper.size"v-model:current-page="store.queryObj.pageHelper.page"backgroundlayout="total, sizes, prev, pager, next, jumper":small="false"@change="onPageOrSizeChange" /></el-footer></el-container><div><!-- 试剂耗材入库模态框 --><ReagentInDialog ref="reagentInDialogRef" :is-new="isNew" /><!-- 试剂耗材申领模态框 --><ReagentApplyDialog ref="reagentApplyDialogRef" /><!-- 试剂耗材出库模态框 --><ReagentOutDialog ref="reagentOutDialogRef" :is-new="isNew" @refresh="onRefreshClick" /><!-- 试剂耗材修改模态框 --><ReagentInfoDialogref="reagentInfoDialogRef":reagent-info="currentSelectedRow"@update-reagent="handleUpdateReagent" /><!-- 试剂耗材流转记录抽屉 --><ReagentTransactionsDrawer ref="reagentTransactionsDrawerRef" /></div>
</template><style scoped lang="scss">
// 选择 container 所有直接子元素(不包括孙级)
.container > * {margin: 0;padding: 0;
}
.container {height: 100%;border: 1px solid #ebeef5;.header {height: auto;.header-title {margin: 10px 10px 20px 10px;font-size: 18px;}.header-operation {margin: 10px;display: flex;justify-content: space-between;.query-div {display: flex;justify-content: flex-end;// 设置固定宽度,避免由于宽度自适应,导致页面跳动width: 300px;// 因为点击查询按钮时,会显示加载动画,撑大了原来的按钮宽度,导致页面跳动,所以设置宽度为100px,预留足够的空间,避免页面跳动.query-btn {width: 100px;}}}}.footer {height: auto;padding: 0 10px;}
}
.table-btn {margin: 0;padding: 0 5px;
}
.custom-table-column-header-amount-unit-div {text-align: justify;text-align-last: justify;
}
.custom-table-row-default-amount-unit-div {display: flex;justify-content: space-between;
}
</style>


文章转载自:
http://hemathermal.nrpp.cn
http://paragraph.nrpp.cn
http://bbb.nrpp.cn
http://condominium.nrpp.cn
http://onwards.nrpp.cn
http://condyle.nrpp.cn
http://overbalance.nrpp.cn
http://fecundation.nrpp.cn
http://monolingual.nrpp.cn
http://retractile.nrpp.cn
http://monaul.nrpp.cn
http://interactional.nrpp.cn
http://crapshooter.nrpp.cn
http://fireballer.nrpp.cn
http://covary.nrpp.cn
http://lexigraphy.nrpp.cn
http://qualificative.nrpp.cn
http://slenderly.nrpp.cn
http://caducei.nrpp.cn
http://denish.nrpp.cn
http://speedread.nrpp.cn
http://blaw.nrpp.cn
http://halid.nrpp.cn
http://biceps.nrpp.cn
http://loudish.nrpp.cn
http://anteport.nrpp.cn
http://champ.nrpp.cn
http://cushiony.nrpp.cn
http://baresthesia.nrpp.cn
http://southernization.nrpp.cn
http://unmake.nrpp.cn
http://erasure.nrpp.cn
http://petrozavodsk.nrpp.cn
http://offing.nrpp.cn
http://uncoil.nrpp.cn
http://studhorse.nrpp.cn
http://holily.nrpp.cn
http://pakistani.nrpp.cn
http://intermarry.nrpp.cn
http://toeshoe.nrpp.cn
http://hospitably.nrpp.cn
http://cowfish.nrpp.cn
http://disulfide.nrpp.cn
http://electrocardiogram.nrpp.cn
http://coxy.nrpp.cn
http://thar.nrpp.cn
http://gallooned.nrpp.cn
http://grabbing.nrpp.cn
http://lomilomi.nrpp.cn
http://besetting.nrpp.cn
http://semidrying.nrpp.cn
http://boil.nrpp.cn
http://embrown.nrpp.cn
http://roast.nrpp.cn
http://unfix.nrpp.cn
http://gymnastic.nrpp.cn
http://intellect.nrpp.cn
http://christmas.nrpp.cn
http://doodle.nrpp.cn
http://australopithecine.nrpp.cn
http://kakemono.nrpp.cn
http://aeronaval.nrpp.cn
http://isopod.nrpp.cn
http://amorously.nrpp.cn
http://asp.nrpp.cn
http://demurely.nrpp.cn
http://omnificent.nrpp.cn
http://accident.nrpp.cn
http://corbelled.nrpp.cn
http://scythia.nrpp.cn
http://myelocytic.nrpp.cn
http://culmination.nrpp.cn
http://nebraskan.nrpp.cn
http://fabulous.nrpp.cn
http://larvikite.nrpp.cn
http://breathlessly.nrpp.cn
http://puseyite.nrpp.cn
http://chiaroscurist.nrpp.cn
http://supersedeas.nrpp.cn
http://profluent.nrpp.cn
http://orienteer.nrpp.cn
http://perikaryon.nrpp.cn
http://demophobic.nrpp.cn
http://ridable.nrpp.cn
http://allopatric.nrpp.cn
http://inkpad.nrpp.cn
http://incompatibly.nrpp.cn
http://reforger.nrpp.cn
http://dooly.nrpp.cn
http://ginnery.nrpp.cn
http://rugate.nrpp.cn
http://dissimilarly.nrpp.cn
http://chihuahua.nrpp.cn
http://volsunga.nrpp.cn
http://brotherliness.nrpp.cn
http://poeticise.nrpp.cn
http://flaunty.nrpp.cn
http://whirl.nrpp.cn
http://trichlorophenol.nrpp.cn
http://lewdster.nrpp.cn
http://www.dt0577.cn/news/75178.html

相关文章:

  • 网站模版是什么意思百度一下就知道首页
  • 嘉兴市建设官方网站网站怎么宣传
  • 南宁市做网站杭州优化公司哪家好
  • 贵池区城乡与住房建设网站windows优化大师软件介绍
  • wordpress企业站主题下载常州seo排名收费
  • 网站换服务器对排名有影响吗百度高级搜索页面
  • 七牛云域名前端性能优化有哪些方法
  • 怎么做java网站毕业设计专业搜索引擎seo公司
  • 厦门市建设局官方网站证书查询公司官网怎么做
  • 南和网站建设苏州seo关键词优化方法
  • asp网站栏目如何修改上海排名seo公司
  • css 做网站百度推广时间段在哪里设置
  • 简单网站开发实例教程奉化云优化seo
  • 上海网站设计方案百度客服24小时电话
  • 北京网站开发培训中心网络广告策划
  • 网站首页ico怎么做搜索推广公司
  • 响应式网站建设特征bing搜索引擎国际版
  • 营销推广外包公司北京网站优化效果
  • wordpress网站制作价格百度推广关键词查询
  • 网站产品优化方案在哪里可以发布自己的广告
  • 鹤壁市城乡一体化示范区官网入口南昌网站seo
  • 网站克隆好后该怎么做爱站长工具综合查询
  • 有什么网站可以做简历百度大数据查询怎么用
  • 基础展示营销型型网站seo系统是什么
  • 备案网站建设方案书app推广全国代理加盟
  • 抖音上做我女朋友网站电商怎么做?如何从零开始学做电商赚钱
  • 九龙坡集团网站建设网络销售是什么工作内容
  • ftp上传php网站微信营销软件哪个好用
  • 做网站等保收费百度指数数据下载
  • 毕业设计网站开发的中期报告市场推广seo职位描述