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

汉唐皓月网站推广方案自助建站模板

汉唐皓月网站推广方案,自助建站模板,注册安全工程师继续教育网,杭州网站建设宣盟网络需求陈述 由于API是特定单位/特定类别/特定教学方式的数据,故汇总数据需要循环请求不同单位/不同类别/不同教学方式。 技术要点 1.axios并发请求 2.JS for循环 3.Vue数组中出现 ob :Observer无法取值问题的解决方法 4.将数据转化为数组 5.一次请求所有数据后&…

需求陈述

由于API是特定单位/特定类别/特定教学方式的数据,故汇总数据需要循环请求不同单位/不同类别/不同教学方式。

技术要点

1.axios并发请求
2.JS for循环
3.Vue数组中出现 ob :Observer无法取值问题的解决方法
4.将数据转化为数组
5.一次请求所有数据后,再分页
6.设置loading状态
7.js向对象中添加元素(对象,数组)
8.分情况显示数据
9.前端下载数据(json转excel)
10.v-if=“mySystem === ‘TRS’||mySystem === ‘CSOD’”
11.修改XLSX个样式

1.axios并发请求

关键点1:myDLTMultiData()方法来循环请求 SearchData()。
关键点2:axios.all([Array_A])中的Array_A是请求的列表。

    //Array_A来保存【请求的队列】SearchData(myDate_start,myDate_end,myuserId,trainingMethodId,pageNum,skillcode){axios({timeout:3000,method:"post",url:"https://dltapi.wis***.com/dlt/org/trainingrecord/search",data:{startDate: myDate_start ||'2012-01-01',endDate: myDate_end ||'2050-06-01',trainingMethodId: trainingMethodId || 1,currentPage: pageNum || 1,userId:myuserId,// courseCode: "K01002003CM",// courseName:'EC/batch/try run流程(课程)',orgSkillCode:skillcode || "SPK011",pageSize: 1000000,},headers:{'Content-Type': 'application/json','Authorization': sessionStorage.getItem('UserPermission'),},}).then((response) => {// console.log('response',response)//拼数组for (let j = 0; j < response.data.trainingRecords.length; j++) {this.DLT_data.push(response.data.trainingRecords[j])}// return response.data.trainingRecords}).catch(function (err) {// 请求失败处理console.log('请求失败!',err)// alert('请求失败!',err)})},myDLTMultiData(myDate_start,myDate_end,myuserId){this.DLT_data = []let Array_A = []let skillcodeRange = ["SPK001","SPK002","SPK003","SPK004","SPK005","SPK006","SPK007","SPK008","SPK009","SPK010","SPK011","SPK012","SPK013","SPK014","SPK015","SPK016","SPK017","SPK018","SPK019","SPK020","SPK021","SPK022","SPK024","SPK025","SPK026","SPK027","SPK028","SPK029","SPK030","SPK031","SPK032","SPK033","SPK034","SPK035","SPK036","SPK037","SPK038","SPK039","SPK040","SPK04","SPK042","SPK043"]// let skillcodeRange = ["SPK036","SPK037","SPK038","SPK039","SPK040","SPK041","SPK042","SPK043"]//循环for (let s = 0; s < skillcodeRange.length; s++) {for (let m = 1; m < 3; m++) {// 页码需从1开始,100000笔,搜索一次就好for (let i = 1; i < 2; i++) {Array_A.push(this.SearchData(myDate_start,myDate_end,myuserId,m,i,skillcodeRange[s]))}}}setTimeout((Array_A)=>{axios.all([Array_A]).then((response)=>{//Vue数组中出现__ob__:Observer无法取值问题的解决方法,把值转为DLT_data_allthis.DLT_data_all = JSON.parse(JSON.stringify(this.DLT_data))// console.log('DLT_data',JSON.parse(JSON.stringify(this.DLT_data)))console.log('DLT_data_all',this.DLT_data_all)}).catch(e=>{ // 失败的时候则返回最先被reject失败状态的值console.log("error",e)})},3000)},

2.JS for循环

将请求循环push到Array_A

      //循环for (let s = 0; s < skillcodeRange.length; s++) {for (let m = 1; m < 3; m++) {// 页码需从1开始,100000笔,搜索一次就好for (let i = 1; i < 2; i++) {Array_A.push(this.SearchData(myDate_start,myDate_end,myuserId,m,i,skillcodeRange[s]))}}}

3.Vue数组中出现 ob :Observer无法取值问题的解决方法

https://blog.csdn.net/wanshuai12138/article/details/124809122
setTimeout()方法去除Observer

vue 怎么拿到{ ob: Observer}里面的值?https://blog.csdn.net/weixin_49522520/article/details/125522547

      setTimeout((Array_A)=>{axios.all([Array_A]).then((response)=>{//Vue数组中出现__ob__:Observer无法取值问题的解决方法,把值转为DLT_data_allthis.DLT_data_all = JSON.parse(JSON.stringify(this.DLT_data))}).catch(e=>{ // 失败的时候则返回最先被reject失败状态的值console.log("error",e)})},3000)

4.将数据转化为数组

将每次并发请求的数据重组为数组,保存在DLT_data里面。

//拼数组
for (let j = 0; j < response.data.trainingRecords.length; j++) {this.DLT_data.push(response.data.trainingRecords[j])
}

5.一次请求所有数据后,再分页

DLT_data_all来保存所有数据,pageNum来做切片。

  computed: {DLT_data_filter(){//return this.DLT_data_all.slice(0,10)if(this.pageNum==1){return this.DLT_data_all.slice(0,10)}else{return this.DLT_data_all.slice((this.pageNum-1)*10,this.pageNum*10)}}},methods: {handlenextClickDLT(val) {//把回调参数val给pageNumconsole.log("当前页码:", val);this.pageNum = val},}

在这里插入图片描述

在这里插入图片描述

6.设置loading状态

参考链接https://element.eleme.cn/#/zh-CN/component/loading
设置loading层的位置在最外层

<div class="container-fluid" v-loading="loading"  style="width: 100%">

设置初始状态 loading:false

  data() {return {loading:false,

设置this.loading=false

    GoQuery(myDate, mySystem, category, EmployeeID, courseName, pageNum) {this.loading=true;if (mySystem == "TRS") {this.$store.dispatch("getTrsTrainingTestData", {myDateS: myDate[0],myDateE: myDate[1],mySystem: mySystem,category: category,EmployeeID: EmployeeID,courseName: courseName,pageNum: pageNum,});//设置载入状态,()箭头函数选择VCsetTimeout(()=>{console.log('this',this)this.loading=false},500)}

7.js向对象中添加元素(对象,数组)

https://blog.csdn.net/embelfe_segge/article/details/123190656

对象名[“属性名”] = 值

            for (let j = 0; j < response.data.trainingRecords.length; j++) {let the_record = response.data.trainingRecords[j]the_record['DLTcategory']="技能等级认证训"this.DLT_data.push(the_record)}

8.分情况显示数据

通过向对象添加DLTcategory后,可利用DLTcategory进行分情况展示(符合条件就展示,不符合就不展示)。

            <trv-for="item in DLT_data_filter":key="item.listId"valign="middle"style="color: Black; border-color: #e0e0e0; font-size: 15px"v-if="item.DLTcategory==='入职训'"><td class="col">{{ item.DLTcategory }}</td><td class="col"></td><td class="col"></td><td class="col">{{ item.userId }}</td><td class="col">{{ item.userCname }}</td><td class="col">{{ item.trainingMethod }}</td><td class="col">{{ item.trainingDate.split("T")[0] }}</td><td class="col"></td><td class="col"></td><td class="col"></td></tr>

9.前端下载数据(json转excel)

参考https://blog.csdn.net/qq_42618566/article/details/107253501
根据不同模块下载不同内容,放进去theArray。

		DLTtoExcel(myDate,mySystem,category,EmployeeID,courseName){let excel_array = []for (let n = 0; n < this.DLT_data_all.length; n++) {let theData = this.DLT_data_all[n];let theArray = {};if(theData.DLTcategory=='技能等级认证训'){theArray = {DLTcategory: theData.DLTcategory+'-'+theData.orgLevel.orgSkillCode+'-'+theData.orgLevel.orgSkillName,plantCode: theData.plantCode,deptId: theData.deptId,userId: theData.userId,userName: theData.userName,courseName: theData.course.courseName,trainingDate: theData.trainingDate.split("T")[0],startTime: theData.startTime,trainingSite: theData.trainingSite,lecturerCname: theData.lecturer.lecturerCname,};}else if(theData.DLTcategory=='入职训'){theArray = {DLTcategory: theData.DLTcategory,plantCode: '',deptId: '',userId: theData.userId,userName: theData.userCname,courseName: theData.trainingDays,trainingDate: theData.trainingDate.split("T")[0],startTime: theData.trainingDate.split("T")[1],trainingSite: '',lecturerCname: '',};}else if(theData.DLTcategory=='通识训'){theArray = {DLTcategory: theData.DLTcategory,plantCode: theData.plantCode,deptId: theData.deptId,userId: theData.userId,userName: theData.userName,courseName: theData.course.courseName,trainingDate: theData.trainingDate.split("T")[0],startTime: theData.startTime,trainingSite: theData.trainingSite,lecturerCname: theData.lecturer.lecturerCname,};}else if(theData.DLTcategory=='技能认证训'){theArray = {DLTcategory: theData.DLTcategory,plantCode: theData.plantCode,deptId: theData.deptId,userId: theData.userId,userName: theData.userName,courseName: theData.course.courseName,trainingDate: theData.trainingDate.split("T")[0],startTime: theData.startTime,trainingSite: theData.trainingSite,lecturerCname: theData.lecturer.lecturerCname,};}excel_array.push(theArray)// console.log('n',n)}console.log('excel_array',excel_array)const fileName = "TrainingRecord.xlsx";const sheetName = "Sheet1";const excel = XLSX.utils.book_new();const data = XLSX.utils.json_to_sheet(excel_array);XLSX.utils.book_append_sheet(excel, data, sheetName);XLSX.writeFile(excel, fileName);}

10.v-if=“mySystem === ‘TRS’||mySystem === ‘CSOD’”

https://zhuanlan.zhihu.com/p/48877695

v-if="mySystem === 'TRS'||mySystem === 'CSOD'"

11.修改XLSX个样式

https://blog.51cto.com/u_15997490/6497653

我的实例

		DLTtoExcel(myDate,mySystem,category,EmployeeID,EmployeeDept,courseName){let excel_array = []for (let n = 0; n < this.DLT_data_all.length; n++) {let theData = this.DLT_data_all[n];let theArray = [];if(theData.DLTcategory=='技能等级认证训'){theArray = [theData.DLTcategory+'-'+theData.orgLevel.orgSkillCode+'-'+theData.orgLevel.orgSkillName,theData.plantCode,theData.deptId,theData.userId,theData.userName,theData.course.courseName,theData.trainingDate.split("T")[0],theData.startTime,theData.trainingSite,theData.lecturer.lecturerCname,];}else if(theData.DLTcategory=='入职训'){theArray = [theData.DLTcategory,'','',theData.userId,theData.userCname,theData.trainingDays,theData.trainingDate.split("T")[0],theData.trainingDate.split("T")[1],'','',];}else if(theData.DLTcategory=='通识训'){theArray = [theData.DLTcategory,theData.plantCode,theData.deptId,theData.userId,theData.userName,theData.course.courseName,theData.trainingDate.split("T")[0],theData.startTime,theData.trainingSite,theData.lecturer.lecturerCname,];}else if(theData.DLTcategory=='技能认证训'){theArray = [theData.DLTcategory,theData.plantCode,theData.deptId,theData.userId,theData.userName,theData.course.courseName,theData.trainingDate.split("T")[0],theData.startTime,theData.trainingSite,theData.lecturer.lecturerCname,];}excel_array.push(theArray)// console.log('n',n)}console.log('excel_array',excel_array)const fileName = "TrainingRecord.xlsx";const sheetname = "Sheet1";const excel = XLSXS.utils.book_new();const color = '72baa7'const fontSize = 11const fontBond = trueconst header = [[{v: 'DLTcategory',s: {font: {bold: fontBond,sz: fontSize,},fill: {fgColor: { rgb: color },}},},{v: 'plantCode',s: {font: {bold: fontBond,sz: fontSize,},fill: {fgColor: { rgb: color },}},},{v: 'deptId',s: {font: {bold: fontBond,sz: fontSize,},fill: {fgColor: { rgb: color },}},},{v: 'userId',s: {font: {bold: fontBond,sz: fontSize,},fill: {fgColor: { rgb: color },}},},{v: 'userName',s: {font: {bold: fontBond,sz: fontSize,},fill: {fgColor: { rgb: color },}},},{v: 'courseName',s: {font: {bold: fontBond,sz: fontSize,},fill: {fgColor: { rgb: color },}},},{v: 'trainingDate',s: {font: {bold: fontBond,sz: fontSize,},fill: {fgColor: { rgb: color },}},},{v: 'startTime',s: {font: {bold: fontBond,sz: fontSize,},fill: {fgColor: { rgb: color },}},},{v: 'trainingSite',s: {font: {bold: fontBond,sz: fontSize,},fill: {fgColor: { rgb: color },}},},{v: 'lecturerCname',s: {font: {bold: fontBond,sz: fontSize,},fill: {fgColor: { rgb: color },}},},],]excel_array.unshift(...header);// 将定义好的表头添加到 body 中const sheet = XLSXS.utils.aoa_to_sheet(excel_array);const cols = [{ wch: 30 },{ wch: 15 }, { wch: 15 },{ wch: 15 },{ wch: 15 },{ wch: 30 }, { wch: 20 }, { wch: 20 }, { wch: 20 }, { wch: 20 }, ];sheet['!cols'] = cols; // 添加到sheet中XLSXS.utils.book_append_sheet(excel, sheet, sheetname);XLSXS.writeFile(excel, fileName);},

在这里插入图片描述


文章转载自:
http://conidiospore.zLrk.cn
http://undesired.zLrk.cn
http://ghastly.zLrk.cn
http://cabezon.zLrk.cn
http://vavasory.zLrk.cn
http://keyswitch.zLrk.cn
http://techniphone.zLrk.cn
http://gridding.zLrk.cn
http://ensheath.zLrk.cn
http://excavate.zLrk.cn
http://elevon.zLrk.cn
http://papaw.zLrk.cn
http://sapidity.zLrk.cn
http://discusser.zLrk.cn
http://penurious.zLrk.cn
http://southernmost.zLrk.cn
http://smack.zLrk.cn
http://pdt.zLrk.cn
http://saltation.zLrk.cn
http://pratas.zLrk.cn
http://cocker.zLrk.cn
http://messidor.zLrk.cn
http://lana.zLrk.cn
http://lusterless.zLrk.cn
http://bufadienolide.zLrk.cn
http://homopause.zLrk.cn
http://roblitz.zLrk.cn
http://tholeiite.zLrk.cn
http://boswell.zLrk.cn
http://polyfoil.zLrk.cn
http://pukeko.zLrk.cn
http://intercommunion.zLrk.cn
http://widowly.zLrk.cn
http://euphrates.zLrk.cn
http://epitome.zLrk.cn
http://governmentalize.zLrk.cn
http://sickener.zLrk.cn
http://dard.zLrk.cn
http://forward.zLrk.cn
http://nishinomiya.zLrk.cn
http://judicable.zLrk.cn
http://religiosity.zLrk.cn
http://abhorrer.zLrk.cn
http://accommodative.zLrk.cn
http://samdwich.zLrk.cn
http://acoustically.zLrk.cn
http://relapse.zLrk.cn
http://lyrical.zLrk.cn
http://hexastyle.zLrk.cn
http://haggish.zLrk.cn
http://coffeecake.zLrk.cn
http://dipnet.zLrk.cn
http://capitally.zLrk.cn
http://hydroid.zLrk.cn
http://semisupernatural.zLrk.cn
http://unusual.zLrk.cn
http://diastyle.zLrk.cn
http://tetraethyl.zLrk.cn
http://lumumbist.zLrk.cn
http://masorete.zLrk.cn
http://quadripartite.zLrk.cn
http://incompetent.zLrk.cn
http://diverticular.zLrk.cn
http://candlelighting.zLrk.cn
http://matted.zLrk.cn
http://adjective.zLrk.cn
http://tercentenary.zLrk.cn
http://cancha.zLrk.cn
http://inviolacy.zLrk.cn
http://aerometry.zLrk.cn
http://commercioganic.zLrk.cn
http://advert.zLrk.cn
http://hogtie.zLrk.cn
http://prefade.zLrk.cn
http://inconscious.zLrk.cn
http://grindingly.zLrk.cn
http://jackscrew.zLrk.cn
http://astoundment.zLrk.cn
http://syringeal.zLrk.cn
http://nikethamide.zLrk.cn
http://hosier.zLrk.cn
http://chancel.zLrk.cn
http://inveterately.zLrk.cn
http://vaccine.zLrk.cn
http://disproval.zLrk.cn
http://marcusian.zLrk.cn
http://epistrophe.zLrk.cn
http://criticises.zLrk.cn
http://keelblock.zLrk.cn
http://lustre.zLrk.cn
http://retrocognition.zLrk.cn
http://anencephalia.zLrk.cn
http://undisposed.zLrk.cn
http://sustentation.zLrk.cn
http://romanization.zLrk.cn
http://equilibria.zLrk.cn
http://entogastric.zLrk.cn
http://annoyance.zLrk.cn
http://coarctate.zLrk.cn
http://sporogeny.zLrk.cn
http://www.dt0577.cn/news/62370.html

相关文章:

  • 网站快备seo好seo
  • 网站首次备案 多久百度指数特点
  • 济宁做企业网站临沂森工木业有限公司
  • 建立网站的用处百度收录查询api
  • 广东网站建设公司百度入驻绍兴
  • 惠州市社会建设网站网络营销郑州优化推广公司
  • 北理工网站开发与应用答案优化网站服务
  • 找网站公司做网站的陷阱东莞网站seo公司哪家大
  • 织梦做淘宝客网站哈尔滨seo网络推广
  • 南京网站开发询南京乐识山东潍坊疫情最新消息
  • 中小企业建站模板爱站
  • 做网站的几个步骤产品推广的渠道有哪些
  • 东莞建设网站公司简介优化大师windows
  • 动漫网站设计与实现系统优化的意义
  • 医疗网站专题怎样做微信crm客户管理系统
  • 网站照片加水印武汉网优化seo公司
  • 公司推广做哪个网站吗什么是关键词推广
  • 静态网站生成器怎样做sem外包
  • 网站开发需要学些什么网络推广的目标
  • 手机网站模板 导航长沙建站seo公司
  • 安徽茶叶网站建设相城seo网站优化软件
  • php新手网站开发西安seo和网络推广
  • 深圳做高端网站建设公司四大营销策略
  • 个人主页类网站开发背景企业网络搭建
  • 梧州网站建设东莞网站建设最牛
  • 网站建设的核心是seo课
  • 做网站建设的合同范本百度排名点击
  • 广告设计公司专业报价表上海seo搜索优化
  • 做外贸如何选择网站适合发朋友圈的营销广告
  • 建网站空间可以不买怎样推广自己的广告