路由传参
zyfxzykhclick(el){
let me=this
let khmc = el.name 获取图表的name
let xzqyid=me.formItem.whdwjc 单位ID
let value=el.value //获取 表格里面的数字
// let xzqyid = this.$dictConfig.getValueByTidAndLabel(999, khmc)
this.$router.push({
path:"/zyfxzykh",
query: {
xzqyid:xzqyid,
// whdwid: me.formItem.whdwjc,
// sfywczg:nfc,
khmc:khmc,
value:value,
}
})
//资源地图接口
homey.getzymap({xzqyid: me.daiweiId}).then(res => {
})
},
接受上个页面的路由传参
let query = me.$route.query
//获取上个页面的单位ID
本地的赋值给路由传过来的参数
// me.charts.optionsu.xAxis[0].data=query.khmc
me.form.queryParam.dept = query.xzqyid
me.charts.optionsu.xAxis[0].data = query.khmc
me.charts.optionsu.series[0].data = query.value
另外 一种传参方式
一个点击事件
rwtj(el) {
let me =this
let val = el.seriesName
// 巡视状态
let XSZT =this.$dictConfig.getValueByTidAndLabel(104, val) 从字典值里面取状态
let GDZY = el.name// 根据单位名称 查找
this.$router.push({
path:"/task/manage",
query: {
//搜索区域单位编码
dwbm: me.form.queryParam.dept,
xswc: GDZY, //巡视状态
// xswc: XSZT, //巡视状态
GDZY: GDZY, //工单专业
startTime:moment(me.form.queryParam.startTime).format('YYYY-MM-DD HH:mm:ss'),
endTime:moment(me.form.queryParam.endTime).format('YYYY-MM-DD HH:mm:ss'),
}
})
},
在挂载之前接受上个页面的传参
beforeMount() {
//挂载之前
let me =this;
if (JSON.stringify(this.$route.query) =="{}") {
// window.history.back(-1);
}else {
// 接受 上个页面 传的 开始时间&结束时间参数
me.form.whdwid =this.$route.query.whdwid ==undefined ?'' :this.$route.query.whdwid //单位id
me.form.xszt =this.$route.query.xszt ==undefined ?'' :this.$route.query.xszt //巡视状态
me.form.GDZY =this.$route.query.GDZY ==undefined ?'' :this.$route.query.GDZY //工单专业
me.form.pdsj1 =this.$route.query.pdsj1 ==undefined ? me.form.pdsj1 :this.$route.query.pdsj1 //开始时间
me.form.pdsj2 =this.$route.query.pdsj2 ==undefined ? me.form.pdsj2 :this.$route.query.pdsj2 //结束时间
me.gdglURL =this.$pageConfig.GDGL_URL +'?' +'whdwid=' + me.form.whdwid +'&' +'xszt=' + me.form.xszt +'&' +'GDZY=' + me.form.GDZY +'&' +'pdsj1=' + me.form.pdsj1 +'&' +'pdsj2=' + me.form.pdsj2
// console.log(me.gdglURL )
}
}
组件跟路由之间传参
点击事件带名字过去
//输电 配电路由传参 配电路由传参
sdrwclick:function (xzlx) {
if (xzlx) {
let me =this
//反正都是取的当前时间和前一天,路由过去后自己取呗,为什么非要参数传过去
me.$router.push({
//url query里传参数用这个
// path: '/task-BD',
// query: {
// whdwsjbm: me.whdwid,
// xzlx: xzlx
// },
//vue route 组件之间传参数用这个
name:'task-BD',
params: {
whdwsjbm: me.whdwid,
xzlx: xzlx
}
})
}else {
me.$systemMessage.alert({
title:'错误',
content:'参数错误:'
})
}
},
接受上个页面传参
//vue组件传参
let routeParams =this.$route.params
//url query传参
let routeQuery =this.$route.query
if (routeParams && routeQuery) {
me.sblxname = routeParams.xzlx || routeQuery.xzlx
me.form.startTime =moment().subtract(1, 'days').format(this.$pageConfig.SECOND_FORMAT)
me.form.endTime =moment().format(this.$pageConfig.SECOND_FORMAT)
me.form.xzlx = routeParams.xzlx || routeQuery.xzlx
me.form.whdwsjbm = routeParams.whdwsjbm || routeQuery.whdwsjbm
}