子表单字段写入数组
功能简介
可以将前端事件请求接口返回数据中的数组,存入表单字段单字段中。
前端事件对于子表字段的支持可以分为两种情况:
- 触发字段为主表字段,返回字段为子表字段
- 触发字段为子表字段,返回字段也为子表字段
触发字段为主表字段
触发字段为主表字段,返回值字段为子表字段时,可以接收数组数据,并且自动按数组的行数创建创建相同行数的子表单。
如查询快递的接口,将接口返回数据中的context写入 物流信息.物流状态
中,time写入物流信息.物流时间
Jsonpath配置方式:使用[*]可以选取不固定长度的数组,数组里面每有一行会自动在子表单创建一行;
例如返回数据为:
{
"showapi_res_error": "",
"showapi_res_id": "63105d080de376fb3c38573",
"showapi_res_code": 0,
"showapi_fee_num": 1,
"showapi_res_body": {
"queryTimes": 8,
"upgrade_info": "",
"fee_num": 1,
"status": 4,
"expSpellName": "zhongtong",
"msg": "查询成功",
"updateStr": "2022-09-01 15:19:37",
"possibleExpList": [],
"flag": true,
"tel": "95311",
"ret_code": 0,
"logo": "http://static.showapi.com/app2/img/expImg/zto.jpg",
"expTextName": "中通快递",
"data": [
{
"context": "快件已被【菜鸟物业店】代收,,感谢使用中通快递,期待再次为您服务!",
"time": "2022-08-26 11:25:25"
},
{
"context": "【长沙望城县】 的彭师傅() 正在第1次派件, 请保持电话畅通,并耐心等待(95720为中通快递员外呼专属号码,请放心接听)",
"time": "2022-08-26 09:06:47"
},
{
"context": "快件已经到达 【长沙望城县】",
"time": "2022-08-26 09:06:46"
},
{
"context": "快件离开 【长沙中转部】 已发往 【长沙望城县】",
"time": "2022-08-26 03:34:05"
},
{
"context": "快件已经到达 【长沙中转部】",
"time": "2022-08-26 02:30:57"
},
{
"context": "快件离开 【保定中转】 已发往 【长沙中转部】",
"time": "2022-08-24 21:25:08"
},
{
"context": "快件已经到达 【保定中转】",
"time": "2022-08-24 21:23:03"
},
{
"context": "快件离开 【保定里县】 已发往 【长沙中转部】",
"time": "2022-08-24 17:38:35"
},
{
"context": "【保定里县】的 蠡县城内() 已揽收",
"time": "2022-08-24 17:05:20"
}
],
"mailNo": "78608477976240",
"dataSize": 9,
"update": 1662016777267
}
}
根据规则,获取数组第一行的数据:
$['showapi_res_body']['data'][*]['time']
这里的[0]表示索引数组第一行的数据。而如果我们是要获取数组里面所有的time,根据其行数自动在子表单创建行,则可以写成:
$['showapi_res_body']['data'][*]['time']
触发字段为子表字段
触发字段为子表字段,返回值字段也为子表字段时,与触发字段和返回值字段都是主表字段的情况类似,触发字段和返回值字段在子表单的同一行内存在对应关系。
以下图中的天气查询为例,城市字段为触发字段,当输入城市之后,将会自动触发前端事件查询天气并返回天气值写入子表单同一行中对应的天气字段内。
此时返回数据为:
{
"showapi_res_code": 0,
"showapi_res_error": "",
"showapi_res_body": {
"cityInfo": {//查询的地区基本资料
"c6": "yunnan",//城市所在省英文名
"c5": "丽江",//城市所在市中文名
"c4": "lijiang",//城市所在市英文名
"c3": "丽江",//城市中文名
"c9": "中国",//城市所在国家中文名
"c8": "china",//城市所在国家英文名
"c7": "云南",//城市所在省中文名
"c17": "+8",
"c16": "AZ9888",//雷达站号
"c1": "101291401",//区域id
"c2": "lijiang",//城市英文名
"c11": "0888",//城市区号
"longitude": 100.222,//经度
"c10": "2",//城市级别
"latitude": 26.903,//纬度
"c12": "674100",//邮编
"c15": "2394"//海拔
},
"now": {//现在实时的天气情况
"aqi": "71", //空气质量指数,越小越好
"aqiDetail": { //aqi明细数据
"aqi": "71",
"area": "北京",
"area_code": "beijing",
"co": "0.817", //一氧化碳1小时平均
"no2": "52", //二氧化氮1小时平均
"o3": "33", //臭氧1小时平均
"o3_8h": "9", //臭氧8小时平均
"pm10": "56", //颗粒物(粒径小于等于10μm)1小时平均
"pm2_5": "51", //颗粒物(粒径小于等于2.5μm)1小时平均
"primary_pollutant": "颗粒物(PM2.5)",
"quality": "良", //空气质量指数类别,有“优质、良好、轻度污染、中度污染、重度污染、严重污染”6类
"so2": "3" //二氧化硫1小时平均
},
"sd": "70%", //空气湿度
"temperature": "15", //当前气温
"temperature_time": "18:30", //采集时间
"weather": "晴", //天气文字标识
"weather_pic": "http://appimg.showapi.com/images/weather/icon/day/00.png", //天气图片地址
"wind_direction": "北风", //风向名称
"wind_power": "1级" //风力
},
"f1": {//今天的天气预报 ,f2是明天,f3是后天,直到f7
"air_press": "1008 hPa", //大气压
"day": "20151023", //日期
"day_air_temperature": "18", //白天天气温度(摄氏度)
"day_weather": "晴", //白天天气标识
"day_weather_pic": "http://app1.showapi.com/weather/icon/day/00.png", //白天天气图标
"day_wind_direction": "无持续风向", //白天风向
"day_wind_power": "微风<10m/h", //白天风力
"jiangshui": "3%", //降水概率
"night_air_temperature": "9", //晚上气温(摄氏度)
"night_weather": "晴",//晚上天气标识
"night_weather_pic": "http://app1.showapi.com/weather/icon/night/00.png", //晚上天气图标
"night_wind_direction": "无持续风向", //晚上风向
"night_wind_power": "微风<10m/h", //晚上风力
"sun_begin_end": "06:35|17:23", //日出|日落时间
"weekday": 5, //星期几
"ziwaixian": "中等", //紫外线强度
"index": {
"yh": {//约会指数
"title": "较不适宜",
"desc": "建议尽量不要去室外约会。"
},
"ls": {//晾晒指数
"title": "不宜",
"desc": "降水可能会淋湿衣物,请选择在室内晾晒。"
},
"clothes": {//穿衣指数
"title": "较舒适",
"desc": "建议穿薄外套或牛仔裤等服装。"
},
"dy": {//钓鱼指数
"title": "不宜",
"desc": "天气不好,不适宜垂钓。"
},
"beauty": {//化妆指数
"title": "保湿",
"desc": "请选用中性保湿型霜类化妆品。"
},
"xq": {//心情指数
"title": "较差",
"desc": "雨水可能会使心绪无端地挂上轻愁。"
},
"travel": {//旅游
"title": "适宜",
"desc": "较弱降水和微风将伴您共赴旅程。"
},
"hc": {//划船指数
"title": "不适宜",
"desc": "天气不好,建议选择别的娱乐方式。"
},
"zs": {//中暑指数
"title": "无",
"desc": "气温不高,中暑几率极低。"
},
"cold": {//感冒
"title": "较易发",
"desc": "降温幅度较大,预防感冒。"
},
"gj": {//逛街指数
"title": "较适宜",
"desc": "有降水,逛街需要带雨具。"
},
"uv": {//紫外线
"title": "最弱",
"desc": "辐射弱,涂擦SPF8-12防晒护肤品。"
},
"cl": {//晨练指数
"title": "较不宜",
"desc": "室外锻炼请携带雨具。"
},
"glass": {//太阳镜
"title": "不需要",
"desc": "白天能见度差不需要佩戴太阳镜"
},
"wash_car": {//洗车
"title": "不宜",
"desc": "有雨,雨水和泥水会弄脏爱车。"
},
"aqi": {//空气质量指数,越小越好
"title": "中",
"desc": "无需特别防护"
},
"ac": {//空调控制
"title": "较少开启",
"desc": "体感舒适,不需要开启空调。"
},
"mf": {//美发指数
"title": "一般",
"desc": "建议选用防晒滋润型护发品或带遮阳帽。"
},
"ag": {//过敏指数
"title": "极不易发",
"desc": "无需担心过敏,可放心外出,享受生活。"
},
"pj": {//啤酒指数
"title": "较适宜",
"desc": "适量的饮用啤酒,注意不要过量。"
},
"nl": {//夜生活指数
"title": "较不适宜",
"desc": "建议夜生活最好在室内进行。"
},
"pk": {//放风筝指数
"title": "不宜",
"desc": "天气不好,不适宜放风筝。"
}
},
"alarmList": [
{
"city": "大连", //预警城市
"issueContent": "大风蓝色预警:预计23日23时到24日08时:大连、锦州、营口、盘锦、葫芦岛地区陆地偏北风6级,阵风7级;渤海、渤海海峡、黄海北部偏北风7级,阵风8级。大连、丹东、锦州、营口、盘锦、葫芦岛附近海域和航线将受影响,请注意防范。省气象灾害预警中心10月23日16时35分发布",
"issueTime": "2015-10-23 16:40:00",
"province": "辽宁省",
"signalLevel": "蓝色",
"signalType": "大风"
}
],
"3hourForcast": [
{
"hour": "20时-23时 ",
"temperature": "12℃/10℃",
"weather": "晴",
"weather_pic": "http://app1.showapi.com/weather/icon/night/00.png",
"wind_direction": "无持续风向",
"wind_power": "微风"
},
{
"hour": "23时-02时 ",
"temperature": "10℃/9℃",
"weather": "晴",
"weather_pic": "http://app1.showapi.com/weather/icon/night/00.png",
"wind_direction": "无持续风向",
"wind_power": "微风"
},
{
"hour": "02时-05时 ",
"temperature": "10℃/9℃",
"weather": "晴",
"weather_pic": "http://app1.showapi.com/weather/icon/night/00.png",
"wind_direction": "无持续风向",
"wind_power": "微风"
},
{
"hour": "05时-08时 ",
"temperature": "13℃/10℃",
"weather": "晴",
"weather_pic": "http://app1.showapi.com/weather/icon/day/00.png",
"wind_direction": "无持续风向",
"wind_power": "微风"
}
]
},
"hourDataList": [ //当天每半小时数据的累积数组。当天0点清空重新累积。
{
"aqi": "53",
"aqiDetail": {
"num": "12",
"co": "0.3",
"area": "北京",
"so2": "3",
"o3": "52",
"no2": "16",
"aqi": "32",
"quality": "优质",
"pm10": "15",
"pm2_5": "6",
"o3_8h": "62",
"primary_pollutant": ""
},
"sd": "85%",
"temperature": "9",
"temperature_time": "00:00",
"weather": "多云",
"weather_pic": "http://appimg.showapi.com/images/weather/icon/night/01.png",
"wind_direction": "北风",
"wind_power": "1级"
},
{
"aqi": "53",
"aqiDetail": {},
"sd": "81%",
"temperature": "10",
"temperature_time": "00:30",
"weather": "多云",
"weather_pic": "http://appimg.showapi.com/images/weather/icon/night/01.png",
"wind_direction": "北风",
"wind_power": "1级"
}
],
"ret_code": 0,
"time": "20151023180000"
}
}
那么,只需要将子字段“天气”的返回值设置为:
$['showapi_res_body']['now']['weather']
将子字段"温度"设置为:
$['showapi_res_body']['now']['temperature']