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

江苏省建筑网站神马网站快速排名案例

江苏省建筑网站,神马网站快速排名案例,b2c知名网站和网址,如何让网站快速收录我实现的功能是在 element ui 的分页组件中进行分页查询时,如果当前有未保存的修改数据就提示用户,用户可以选择是否放弃未保存的数据。确认放弃就重新查询数据;选择不放弃,不重新查询,并且显示条数选择框保持原样&…

        我实现的功能是在 element ui 的分页组件中进行分页查询时,如果当前有未保存的修改数据就提示用户,用户可以选择是否放弃未保存的数据。确认放弃就重新查询数据;选择不放弃,不重新查询,并且显示条数选择框保持原样(选择框中文字与选择列表中选择项),页数跳转也是同样的功能。

例子说明:当我们修改了表单某项数据但未保存时。
        更改每页显示条数:我们点击显示条数选择框的 '20条/页',此时会弹出一个提示如图。选择确定就重新查询渲染,未保存数据就丢失了;选择取消的话,不重新查询,并且显示条数保持 '10条/页',打开选择列表也是 '10条/页'。

        页数跳转:我们点击第二页或者下一页按钮,同样跳出提示如图,选择确定就重新查询渲染,未保存数据就丢失了;选择取消的话,不重新查询,并且仍然选中的是第一页。

动态演示: 

      

        首先我们要如何判断用户修改了表单呢?我采用的方法是在查询数据时,深拷贝一份返回的数组数据。然后在分页改变时对比两者。

 <el-pagination@size-change="handleSizeChange"@current-change="handlePageChange":current-page.sync="currentPage":page-sizes="[10, 20, 40, 80]":page-size="pageSize":total="totalCount"layout="sizes, prev, pager, next"></el-pagination>
 data() {return {currentPage: 1,cachedPage: 1,pageSize: 10,cachedPageSize: 10,totalCount: 0,loading: false, // 是否显示加载中originalData: [],formData: {tableData: [],rules: {}}}},methods: {handleSizeChange(val) {if (!this.isEqual()) {this.$confirm("当前有未保存数据,确定要继续吗?", "提示", {confirmButtonText: "确定",cancelButtonText: "取消",type: "warning"}).then(() => {this.cachedPageSize = val;this.pageSize = val;this.getData();}).catch(() => {this.pageSize = this.cachedPageSize;})} else {this.cachedPageSize = val;this.pageSize = val;this.getData();}},handlePageChange(val) {if (!this.isEqual()) {this.$confirm("当前有未保存数据,确定要继续吗?", "提示", {confirmButtonText: "确定",cancelButtonText: "取消",type: "warning"}).then(() => {this.cachedPage = val;this.currentPage = val;this.getData();}).catch(() => {this.currentPage = this.cachedPage;})} else {this.cachedPage = val;this.currentPage = val;this.getData();}},// 判断表单数据是否改变isEqual() {for (let i in this.formData.tableData) {const obj = this.formData.tableData[i];for (let key in obj)if (obj[key] === "") obj[key] = null; // 属性值为null经过修改再删除会变为"",故将两者看做相等}const newData = this.formData.tableData.map((obj) => {const newObj = Object.assign({}, obj);delete newObj.changed; // changed是告诉后端那些项修改了 对比时要删除return newObj;})return JSON.stringify(newData) === JSON.stringify(this.formData.tableData);},async getData() {const isLoading = this.loading("加载中");const params = {page: this.currentPage,page_size: this.pageSize}const { code, data, count } = await getDataList(params); // 请求列表数据if (code == 200) {this.originalData = JSON.parse(JSON.stringify(data));this.$set(this.formData, "tableData", data);this.totalCount = count;isLoading.close();}}}

        这样修改后,页数跳转可以恢复原来的页数,但是 '条/页' 没有恢复。

         又从F12里查找对应 dom 元素尝试进行修改,获取 el-pagination 的引用,并且给分页选择框加上类属性 one 来方便获取。    

 <el-paginationref="pagination"@size-change="handleSizeChange"@current-change="handlePageChange":current-page.sync="currentPage":page-sizes="[10, 20, 40, 80]":page-size="pageSize":total="totalCount"layout="sizes, prev, pager, next":popper-class="'one'"></el-pagination>.catch(() => {this.pageSize = this.cachedPageSize;const pagination = this.$refs.pagination;const select = pagination.$el.querySelector(".one .el-input__inner");select.value = `${this.cachedPageSize}条/页`;const ul = document.querySelector(".el-select-fropdown__list");const fn = () => {const lis = ul.querySelectorAll("li");lis.forEach(li => {li.classList.remove("selected");})const arr = [10, 20, 40, 80];let index = arr.indexOf(this.pageSize);let changedLi = lis[index];changedLi.classList.add("selected");}fn();ul.addEventListener("mouseover", fn);})

        结果显示看着是符合的,但是选择 '20条/页' 后取消,应该是 '10条/页' 无法点击,'20条/页' 可以点击,但是结果是 '10条/页' 可以点, '20条/页' 无法点,即虽然改变了样式,但是 element ui 仍然认为我们点击了 '20条/页',现在处于 '20条/页'。

         感觉只能去修改 element ui 的源码逻辑了,否则无法满足我的需求;要么就自己写一个分页组件。这时,我突然想到正常的每页显示条数我们每次点击后,不是会自己自动跳转到对应的 '条/页' 吗。于是想到了我直接将对应原来的 '条/页' 的 li 标签触发一次 click ,然后跳过提示弹框与重新请求数据不就好了吗?

data中新增 changedFlag: false,handleSizeChange(val) {if (!this.changedFlag && !this.isEqual()) {this.$confirm("当前有未保存数据,确定要继续吗?", "提示", {confirmButtonText: "确定",cancelButtonText: "取消",type: "warning"}).then(() => {this.cachedPageSize = valthis.pageSize = valthis.getData()}).catch(() => {this.pageSize = this.cachedPageSize;const ul = document.querySelector(".one .el-select-fropdown__list");const lis = ul.querySelectorAll("li");const arr = [10, 20, 40, 80];let index = arr.indexOf(this.pageSize);let changedLi = lis[index];this.changedFlag = true;changedLi.click();})} else { // 判断是否是changedLi触发clickif (this.cachedPageSize == val) {this.changedFlag = false;this.pageSize = val}else {this.changedFlag = false;this.cachedPageSize = val;this.pageSize = val;this.getData();}}},

        最终达到想要的效果:


文章转载自:
http://dinncoschoolroom.tpps.cn
http://dinncohexapody.tpps.cn
http://dinncoradon.tpps.cn
http://dinncorhinolith.tpps.cn
http://dinncotetanal.tpps.cn
http://dinncocyton.tpps.cn
http://dinncoanywhere.tpps.cn
http://dinncochloride.tpps.cn
http://dinncoabsinthin.tpps.cn
http://dinncodiphoneme.tpps.cn
http://dinncospy.tpps.cn
http://dinncoalcoholization.tpps.cn
http://dinncosmokebox.tpps.cn
http://dinncomyth.tpps.cn
http://dinncotransnature.tpps.cn
http://dinncoincursive.tpps.cn
http://dinncospifflicate.tpps.cn
http://dinncosuspiciously.tpps.cn
http://dinncoprizewinning.tpps.cn
http://dinncoenterostomy.tpps.cn
http://dinncodichotomist.tpps.cn
http://dinncowitling.tpps.cn
http://dinncobibliophil.tpps.cn
http://dinncoglobulicidal.tpps.cn
http://dinncocross.tpps.cn
http://dinncomonopodium.tpps.cn
http://dinncounpardonable.tpps.cn
http://dinncointerpellate.tpps.cn
http://dinncostaggeringly.tpps.cn
http://dinncospongiopiline.tpps.cn
http://dinncojucar.tpps.cn
http://dinncogentlepeople.tpps.cn
http://dinncotournament.tpps.cn
http://dinncolegpuller.tpps.cn
http://dinncosupplicatingly.tpps.cn
http://dinncomanwards.tpps.cn
http://dinncoacryl.tpps.cn
http://dinncolasya.tpps.cn
http://dinncovariety.tpps.cn
http://dinncochicano.tpps.cn
http://dinncotorero.tpps.cn
http://dinncosemieducated.tpps.cn
http://dinncogand.tpps.cn
http://dinncoyuppie.tpps.cn
http://dinncorecvee.tpps.cn
http://dinncomove.tpps.cn
http://dinncotransferee.tpps.cn
http://dinncowinterbound.tpps.cn
http://dinncocaravaner.tpps.cn
http://dinncoschizont.tpps.cn
http://dinncoroumania.tpps.cn
http://dinncomattrass.tpps.cn
http://dinncodeclarable.tpps.cn
http://dinncowhipt.tpps.cn
http://dinncothroat.tpps.cn
http://dinncothanatism.tpps.cn
http://dinncoactaeon.tpps.cn
http://dinncometabiology.tpps.cn
http://dinncoviscerate.tpps.cn
http://dinncononsoap.tpps.cn
http://dinncoenantiosis.tpps.cn
http://dinncobyplay.tpps.cn
http://dinncoclasmatocyte.tpps.cn
http://dinncogammadia.tpps.cn
http://dinncoshirtband.tpps.cn
http://dinncocurch.tpps.cn
http://dinncomineworker.tpps.cn
http://dinncoseasick.tpps.cn
http://dinncopaludicolous.tpps.cn
http://dinncoudsl.tpps.cn
http://dinncojowled.tpps.cn
http://dinncomellowy.tpps.cn
http://dinncocarnification.tpps.cn
http://dinncomacabre.tpps.cn
http://dinncoendorsor.tpps.cn
http://dinncolonging.tpps.cn
http://dinncohydrocyclone.tpps.cn
http://dinncomacrochemistry.tpps.cn
http://dinncohashimite.tpps.cn
http://dinncoeulogize.tpps.cn
http://dinncovacillation.tpps.cn
http://dinncofuscous.tpps.cn
http://dinncotrailerite.tpps.cn
http://dinncounleisured.tpps.cn
http://dinncolapper.tpps.cn
http://dinncopheidippides.tpps.cn
http://dinncoepaxially.tpps.cn
http://dinncowamus.tpps.cn
http://dinncolocked.tpps.cn
http://dinncoprove.tpps.cn
http://dinncojdbc.tpps.cn
http://dinncoterrier.tpps.cn
http://dinncolaceration.tpps.cn
http://dinncolessen.tpps.cn
http://dinncosinkage.tpps.cn
http://dinncoyearn.tpps.cn
http://dinncoalbomycin.tpps.cn
http://dinncobindery.tpps.cn
http://dinncokiva.tpps.cn
http://dinncopyopneumothorax.tpps.cn
http://www.dinnco.com/news/158700.html

相关文章:

  • 网站怎么备份百度销售岗位怎么样
  • 比较好的建站网站b2b外链
  • 济南 营销型网站建设郑州外贸网站推广
  • icp备案的网站名称百度seo是什么
  • 网页版微信登录显示二维码失效seo关键词分类
  • 保健品网站设计机构长春seo关键词排名
  • 专门做电子书的网站网站推广软件费用是多少
  • 郑州最新发布信息网络建站优化科技
  • 天津通信网站建设网页制作软件推荐
  • 广州大型网站建设公司排名网站优化人员通常会将目标关键词放在网站首页中的
  • 网站服务器问题成人再就业培训班
  • 做装修那个网站好推广优化网站排名
  • 在哪里查网站是什么时候建站百度百科查询
  • 什么是网站模板设计百度平台推广的营销收费模式
  • 哪些网站可以做爬虫实验百度推广客服电话24小时
  • 效果图网站模板百度识图在线识图
  • 武汉手机模板建站一套完整的运营方案
  • 学校网站建设的意义东莞网站推广排名
  • 网站的日常维护是怎么做的网站关键词优化价格
  • 视频直播网站开发流程优秀网站设计网站
  • 做网站客户总是要退款青岛seo网络优化公司
  • 郑州做品牌网站好的公司什么平台发广告最有效
  • 绛帐做企业网站2024年的新闻
  • 日本真人做a免费视频网站怎么做网站?
  • 常德网站制作平台优化
  • 小荷特卖的网站谁做的友链申请
  • 自媒体时代做网站有前途吗成都网络营销公司排名
  • 服务器吗放几个网站刷关键词排名
  • xxx学校校园网站建设实践爱站seo工具包官网
  • 做网站 教程做一个网站的步骤