手机端API
# 移动端API库
前言:由于手机端的运行环境变化,需要重新定义方法供程序的正常的运行, 标准js语法和api都支持,比如if、for、settimeout、indexOf等,但浏览器专用的window、document、navigator、location对象,包括cookie等存储,只有在浏览器中才有,app端现在全部都不支持使用, 标准的css基本都是支持的。
# 一、提议
# 1.this拥有当前页面的所有信息
当自定义函数中this取方法报错时,尝试
顶级使用
var that=this,后续使用that代替this
# 2.报错处理
2.1 一般语法错误 会有弹框处理,
2.2 自己进行中断判断时,需要告知程序是否继续进行后续操作,继续需返回true,无需继续进行则需要返回false
# 3.要求:
每一句建议以
;
结尾 ,否则可能会存在执行报错的情况
# 4.可选
根据情况决定是否填写参数,或者参数是否为空 ' '
# 5.下拉框赋值
给下拉框赋值时,需要同时赋值其显示字段
赋值规则即对象名后加
_name
//APP写法:
this.trobj["mes_patrol_temptaskitem_actualConclusion"]=3
this.trobj["mes_patrol_temptaskitem_actualConclusion_name"]="正常"
//PC写法:
xjx.setValue(tr,'actualConclusion',3);
2
3
4
5
6
# 6.列表参照
列表参照如果设置了普通按钮,则基础的确认和取消按钮就会消失
# 二、版本信息
版本 | 更新时间 | 描述 |
---|---|---|
v1.0.0 | 2024-1-1 | |
v1.0.1 | 2024-1-8 | 新增directPrint列表调用打印机方法 |
V1.0.2 | 2024-12-13 | 新增若干方法,若干方法新增参数 |
# 三、交互
# 3.1. 提示框
脚本 | 描述 | 应用于 |
---|---|---|
this.Toast | 显示提示框 | 用于弹出提示框 |
this.hideToast | 隐藏提示框 | 用于隐藏弹出的提示框 |
this.showLoading | 显示加载提示框 | 弹出一个正在加载的提示 |
this.hideLoading | 隐藏加载提示框 | 隐藏弹出的加载提示 |
# 3.1.1 this.Toast 显示提示框
使用说明:
/**
* @description 提示
* @param title 提示内容 【类型:String】
* @param icon 显示图标 【可选】 可选值 success,error,loading,none 【类型:String】
* @param time 显示时间单位/毫秒)【可选】 【类型:Number】
*/
this.Toast(title,icon,time);
// 实例
this.Toast("这是一个提示","success");
2
3
4
5
6
7
8
9
# 3.1.2 this.hideToast 隐藏提示框
使用说明:
/**
* @description 隐藏提示
*/
this.hideToast();
2
3
4
# 3.1.3 this.showLoading 显示加载提示框
使用说明:
/**
* @description 显示加载提示
* @param title 提示的文字内容 【类型:String】
*/
this.showLoading(title);
// 实例
this.showLoading("正在加载");
2
3
4
5
6
7
# 3.1.4 this.hideLoading 隐藏加载提示框
使用说明:
/**
* @description 隐藏加载提示
*/
this.hideLoading();
2
3
4
# 3.2. 选择提示框
脚本 | 描述 | 应用于 |
---|---|---|
this.showModal | 显示模态弹窗 | 弹出一个能点击确认取消的弹框,以及回调操作 |
# 3.2.1 this.showModal 显示模态弹窗
使用说明:
/**
* @description 显示模态框(选择框)
* @param title 提示的标题 【可选】 默认显示 ‘提示’ 【类型:String】
* @param content 提示的内容 【类型:String】
* @param fn 回调函数 【类型:Function】
*/
this.showModal(title,content,fn);
// 示例
this.showModal("提示","确定要吃饭吗",(res)=>{
if(res){
//返回true的业务逻辑
}else{
//返回false的业务逻辑 (可选)
};
// res 返回 true,false
});
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
实例
//App端写法:
this.showModal("维修提示","确定要开始维修吗",(res)=>{
if(res){
if(starttime!=""){
his.ExcuteListsql("getState@pid="+pid)
}
if(starttime==''){
this.ExcuteListSql("getState@pid="+pid).then(res=>{
this.ExcuteListSql("getStatetime@tid="+ypsysid)
})
}
}
})
//PC端对比:
if(confirm("确定要开始维修吗?"))
{
if (starttime!=''){
var result=RoadUI.AjaxRequest('getState@pid='+pid);
}
if(starttime==''){
var result=RoadUI.AjaxRequest('getState@pid='+pid);
var results=RoadUI.AjaxRequest('getStatetime@tid='+ypsysid);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 3.3. 警告框
脚本 | 描述 | 应用于 |
---|---|---|
this.Alert | 弹出警告框 | 像平台alert作用一样 |
# 3.3.1 this.Alert 弹出警告框
使用说明:
/**
* @description 打开提示框
* @param title 提示的内容 【类型:String】
* @param type 类型 可选值:'success','error','warn','info' 【类型:String】
*/
this.Alert(title,type);
// 示例
this.Alert('成功提示','success');
this.Alert('错误提示','error');
this.Alert('警告提示','warn');
this.Alert('普通提示','info');
2
3
4
5
6
7
8
9
10
11
实例
//App端写法:
this.Alert("哈哈哈哈","info");
//PC端对比:
alert("哈哈哈哈");
2
3
4
5
# 3.4. 弹出输入框
脚本 | 描述 | 应用于 |
---|---|---|
this.showPrompt | 弹出输入框 | 作用如平台prompt一般 |
# 3.4.1 this.showPrompt 弹出输入框
使用说明:
/**
* @description 显示提示输入框
* @param title 提示的标题 【类型:String】
* @param content 提示的内容 【类型:String】
* @param fn 回调函数 【类型:Function】
*/
this.showPrompt(title,content,fn);
// 示例
this.showPrompt("提示","请输入内容",({res,content})=>{
// res 确认状态 true/false content 输入的内容,未输入则为空
if(res){
// 点击确认之后的操作
}else{
// 点击取消之后的操作
}
});
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 四、通用
# 4.1 本地存储
脚本 | 描述 | 应用于 |
---|---|---|
this.setStorage | 存储缓存 | 将数据缓存至手机内存中 |
this.getStorage | 获取存储值 | 从手机内存中去除缓存的值 |
this.removeStorage | 删除本地存储 | 移除某一条缓存的值 |
this.clearStorage | 清除本地存储 | 清楚所有缓存的数据 |
# 4.1.1 this.setStorage 存储缓存
/**
* @description 存储缓存
* @param key 缓存的键 【类型:String】
* @param value 缓存的值 【类型:String】
*/
this.setStorage(key,value);
// 示例
this.setStorage("aa","sandjandkasndklasndka");
2
3
4
5
6
7
8
# 4.1.2 this.getStorage 获取存储值
/**
* @description 获取存储值
* @param key 缓存的键【类型:String】
*/
this.getStorage(key);
// 示例
let aa = this.getStorage("aa");
//aa 就会为sandjandkasndklasndka
2
3
4
5
6
7
8
# 4.1.3 this.removeStorage 删除本地存储
/**
* @description 删除本地存储
* @param key 缓存的键【类型:String】
*/
this.removeStorage (key);
// 示例
this.removeStorage("aa");
2
3
4
5
6
7
# 4.1.4 this.clearStorage 清除本地存储
/**
* @description 清除本地存储
*/
this.clearStorage();
2
3
4
# 4.2 定时器/延时器
// 1.延时器
let timer = setTimeout(()=>{
//执行逻辑
},执行时间【毫秒】)
// *示例
// 延时一秒控制台打印 '过了1s执行'
let timer = setTimeout(()=>{
console.log("过了1s执行")
},1000)
// 2.定时器
let inter = setInterval(()=>{
// 执行逻辑
},执行时间【毫秒】)
// *示例
// 每过1s执行控制台打印'a'
let inter = setInterval(()=>{
console.log("a")
},1000)
// 清除定时器/延时器
clearTimeout(timer);
clearInterval(inter);
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 4.3.基本信息
脚本 | 描述 | 应用于 |
---|---|---|
this.userInfo | 获取当前用户信息 | 取当前登录用户的信息 |
this.userSysid | 获取当前用户SYSID | 直接取当前登录用户的SYSID |
this.formLocation | 获取当前位置的定位信息 | 表单中自动将读取到的经纬度信息 存入主表 latitude/longitude 字段 |
this.scanInfo | 调用扫码 | 调用扫码模块获取扫码的数据 |
this.nfcRead | 调用NFC | 调用手机NFC模块,获取读取的数据 |
this.$forceUpdate | 强制刷新 | 当值改变,但是页面未展示时,强制刷新即可 |
# 4.3.1 this.userInfo 获取当前用户信息
/* 获取当前登录用户的基本信息 */
// 用法
var info=this.userInfo();
var sysid=info.SYSID;
var USER_Name=info.USER_Name;
2
3
4
5
# 4.3.2 this.userSysid 获取当前用户SYSID
/* 获取当前登录用户的SYSID */
// 用法
var sysid=this.userSysid();
2
3
# 4.3.3 this.formLocation 获取当前位置的定位信息
/* 此方法用于表单中获取经纬度信息 */
/* 会自动将读取到的经纬度信息 存入主表 latitude/longitude 字段 */
// 用法
this.formLocation(); //调用一下即可
2
3
4
# 4.3.4 this.scanInfo 调用扫码
/**
* @description 此方法用于扫码,返回错误提示,或者扫码后的数据
* @param fn 返回正确扫码数据之后的回调函数 【类型:Function】
* @param method 是否隐藏相册中选取 默认false 【类型:Boolean】
*/
this.scanInfo(fn,method);
// 示例
this.scanInfo((res)=>{
//res 为扫码的值
if(res){
console.log(res);
}
},true);
2
3
4
5
6
7
8
9
10
11
12
13
# 4.3.5 this.nfcRead 调用NFC
/**
* @description 此方法用于调用NFC
* @param fn 返回正确读取数据之后的回调函数 【类型:Function】
*/
this.nfcRead(fn);
// 示例
this.nfcRead((res)=>{
//res 为读取后的值
if(res){
console.log(res);
}
});
2
3
4
5
6
7
8
9
10
11
12
# 4.3.6 this.$forceUpdate 强制刷新
/* 强制刷新 */
/* 当值改变,但是页面未展示时,强制刷新即可 */
// 用法
this.$forceUpdate(); //调用一下即可
2
3
4
# 4.4 文件预览
/**
* @description 文件预览 支持图片,视频,文件,word,execl,ppt,pdf(可能需要本地应用支持)
* @param path 平台文件路径 【类型:String】
*/
this.filePreview(path);
// 示例
this.filePreview("/RoadFlowEngine/Content/UploadFiles/202410/31/1730368674452.jpg");
2
3
4
5
6
7
# 五、列表
# 5.1 参数
脚本 | 描述 | 应用于 |
---|---|---|
this.cItem | 当前点击 的行的值集合 | 一般配合列表按钮使用,当列表按钮点击时得到 |
this.FormID | 当前列表绑定的表单ID | 便获取当前列表绑定的表单id |
this.pid | 当前绑定的列表ID | 方便获取当前列表id |
this.row | 当前列表数据集合 | 方便获取当前列表所有已加载的数据集合 |
this.form | 当前列表筛选项的值对象 | 方便获取当前列表的筛选条件的数据集合 |
this.checkItems | 当前选中 的列数据集合 | 获取选中的列表行数据的集合 |
this.bobj | 回调返回的值 | 为参照回调值的对象集合 可为数组或者对象 |
# 5.1.1 this.cItem 当前点击
的行的值集合 【类型:Object】
/* 一般配合列表按钮使用 */
/* this.cItem 值为当前行对象数据,当列表按钮点击时得到 */
// 用法
let pid =this.cItem.pid; // 获取当前行中字段为pid的值
2
3
4
实例
//APP端:
let sysid=this.cItem.SYSID // cItem中取SYSID
//PC端对比:
view("$datarow&SYSID&$") // datarow 中取SYSID
2
3
4
5
# 5.1.2 this.FormID 当前列表绑定的表单ID【类型:String】
/* 方便获取当前列表绑定的表单id */
// 用法
let formid= this.FormID;
2
3
4
# 5.1.3 this.pid 当前绑定的列表ID【类型:String】
/* 方便获取当前列表id */
// 用法
let pid= this.pid;
2
3
4
# 5.1.4 this.row 当前列表数据集合 【类型:Array】
/*
方便获取当前列表的已加载的数据集合
由于数据是分页获取,所以只能取当前已经加载出来的所有数据
*/
// 示例 假如列表中有三条且存在cid,cname字段
let id1=this.row[0].cid; //取第一条数据的cid字段的值
let id2=this.row[2].cid; // 取第三条数据的cid字段的值
let name1 =this.row[1].cname; // 取第二条数据的cname字段的值
2
3
4
5
6
7
8
9
10
# 5.1.5 this.form 当前列表筛选项的值对象 【类型:Object】
/* 方便获取当前列表的筛选条件的对象集合 */
// 示例
暂无
2
3
4
# 5.1.6 this.checkItems 当前选中
的列数据集合【类型:Array】
/* 一般配合`普通按钮`使用,获取选中的列表行数据的集合 */
/* 注:`先选中`的行数据在第一项*/
// 示例 假设选中一条数据且存在字段为tid,tname
let tid = this.checkItems[0].tid // 获取选中的第一条数据字段为tid的值
let tname=this.checkItems[0].tname //获取选中的第一条数据字段为tname的值
2
3
4
5
6
# 5.1.7 this.bobj 回调返回的值 【类型:Array/Object 】
/* 一般用于列表筛选条件的文本按钮参照控件格式 */
/* 为参照回调值的对象集合 可为数组或者对象 */
/* this.bobj为对象和数组取决于配置时 是否 返回多条数据 */
// 示例
let cid=this.bobj.cid // 取回填值中字段cid的值 this.bobj为对象情况下
let cid=this.bobj[0].cid // 取回填值中字段cid的值 this.bobj为数组情况下
2
3
4
5
6
7
# 5.2 方法
脚本 | 描述 | 应用于 |
---|---|---|
this.setQuerys | 设置列表查询条件的值 | 设置列表查询条件的值 |
this.ExcuteListSql | 处理Sql管理的值 | 执行列表的sql管理 |
this.addFlow | 打开新增流程表单 | 打开列表绑定的流程表单 |
this.addForm | 打开新增表单 | 打开列表绑定的普通表单 |
this.toForm | 打开表单详情页 | 打开列表绑定的表单详情 |
this.toFlow | 打开流程表单页 | 打开列表绑定的流程表单详情 |
this.rowData | 读取最先选中的第一行某个字段对应的值 | 获取列表选中的第一行数据 |
this.delRow | 删除行数据 | 删除选中行/某行数据 |
this.checkRowId | 获取选中的一行数据ID | |
this.toList | 跳转到对应的列表页面 | 跳转到对应的列表页面 |
this.toPbList | 打开参照列表 | 打开参照列表 |
this.getlists | 刷新列表 | 刷新列表数据 |
# 5.2.1 this.setQuerys 设置列表查询条件的值
使用说明:
/**
* @description 设置列表查询条件的值
* @param arr 控件名和值的键值对集合 【类型:Array】
*/
this.setQuerys(arr)
// 示例
// 单个赋值
this.setQuerys([{"ExchName_L2PN2ZT":'哈哈哈'}])
// 多个赋值
this.setQuerys([{"jxdw_J4400P0":'哈哈哈'},{"name_D20006J":"ASQs"}])
// 错误写法1 arr数组中不能一个值中有两个键值
this.setQuerys([{"ExchName_L2PN2ZT":'Hello',"ExchCode_L2PN2ZT":"World"}])
// 错误写法2 arr数组中必须是对象
this.setQuerys([{"ExchName_L2PN2ZT",'Hello'}])
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 5.2.2 this.ExcuteListSql处理Sql管理的值
使用说明
/**
* @description 处理列表sql管理
* @param sql 写法雨平台一致 【类型:String】
*/
this.ExcuteListSql(sql).then(res=>{}).catch(err=>{})
// 示例 把 RoadUI.AjaxRequest("getAction@sysid="+ypsysid);替换成app支持的代码如下:
this.ExcuteListSql("getAuditor@ypsysid="+iId)
.then(res=>{
// res 为数据请求后返回的值
if(res.Code==200){
// 成功返回的逻辑
}
});
2
3
4
5
6
7
8
9
10
11
12
13
实例
//App端写法:
this.showModal("维修提示","确定要开始维修吗",(res)=>{
if(res){
if(starttime!=""){
his.ExcuteListsql("getState@pid="+pid)
}
if(starttime==''){
this.ExcuteListSql("getState@pid="+pid).then(res=>{
this.ExcuteListSql("getStatetime@tid="+ypsysid)
})
}
}
})
//PC端对比:
if(confirm("确定要开始维修吗?"))
{
if (starttime!=''){
var result=RoadUI.AjaxRequest('getState@pid='+pid);
}
if(starttime==''){
var result=RoadUI.AjaxRequest('getState@pid='+pid);
var results=RoadUI.AjaxRequest('getStatetime@tid='+ypsysid);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 5.2.3 this.addFlow 打开新增流程表单
使用说明:
/**
* @description 打开新增流程表单
* @param flowid 需要打开的流程 【类型:String】
* @param title 打开的表单标题【可选】 【类型:String】
* @param params 链接传值【可选】【类型:Object】
*/
this.addFlow(flowid,title,params)
//示例
this.addFlow('6467847e-c324-5409-f740-c19b4865e03b','工单制定');
this.addFlow('6467847e-c324-5409-f740-c19b4865e03b');
2
3
4
5
6
7
8
9
10
11
实例:
//APP端:
this.addFlow("b9d50150-1af5-0d5d-61ee-5e4e95ac58a")
this.addFlow("b9d50150-1af5-0d5d-61ee-5e4e95ac58a","标题",{version:2})
// 注:一定注意 在params中添加version:2 会打开平台最新流程,不加参数会打开老流程 toFlow同理
//PC端对比:
TestOp("b9d50150-1af5-0d5d-61ee-5e4e95ac58a")
function TestOp(flowid,taskid,stepid,groupid,instanceid,formopenmode,flowstate){
var data={
flowid:flowid,//流程ID
taskid:taskid,//任务ID
stepid:stepid,//步骤
groupid:groupid,//人员组
instanceid:instanceid,//实例
formopenmode:$formopenmode,
formopenmode:0,
height:window.document.body.offsetHeight,
width:window.document.body.offsetwidth
}
processHandle(data)
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 5.2.4 this.addForm 打开新增表单
使用说明:
/**
* @description 打开新增表单
* @param title 打开的表单标题【可选】 【类型:String】
* @param formid 需要打开的表单id【可选】 【类型:String】
* @param params 链接传值【可选】【类型:Object】
*/
this.addForm(title,formid,params);
//示例
this.addForm('我要新增一个');
this.addForm('新增','104c7e73-96c2-3029-70c4-2bfe3579779f'); //打开id为104c7e73-96c2-3029-70c4-2bfe3579779f的表单
2
3
4
5
6
7
8
9
10
实例
// APP端:
this.addForm()
//PC端对比:
add()
2
3
4
5
# 5.2.5 this.toForm 打开详情页
使用说明:
/**
* @description 打开表单详情
* @param title 打开的表单标题【可选】 【类型:String】
* @param isView 是否查看0/1(查看)【可选】 【类型:Number】
* @param sysid 自定义实例id【可选】【类型:String】
* @param formid 自定义表单Id【可选】【类型:String】
* @param params 链接传值【可选】【类型:Object】
*/
this.toForm(title,isView,sysid,formid,params);
//实例
this.toForm("详情页",0,"6467847e-c324-5409-f740-c19b4865e03b","6467847e-c324-5409-f740-c19b4865e03b",{"signType":1,"taskid":"adsasadasdas"});
2
3
4
5
6
7
8
9
10
11
12
13
实例
1. 需要复选框选中情况
// APP端:
let ypsysid=this.checkRowId()
this.toForm('详情','o',ypsysid)
//PC端
var arr=[];
var checkRows=window.getlistChecked();
var checkRow=checkRows[0];
ypsysid=checkRow.SYSID
view(ypsysid);
2
3
4
5
6
7
8
9
10
11
- 列表按钮内操作
// APP端
this.toForm()
// PC端
view("$datarow&SYSID&$")
2
3
4
5
3.跳转不是当前列表绑定的表单
// APP端:
let yqsysid=this.checkRowId();
this.toForm("延期",0,yqsysid,'104c7e73-96c2-3029-70c4-2bfe3579779')
// PC端:
var checkRow=checkRows[0];
yqsysid=checkRow.SYSID;
window.open("/apps/tt-web/WorkF1owRun/SubTableEdit?secondtableeditform=104c7e73-96c2-3029-70c4-2bfe3579779f&formopenmode=0&access=platform&busid="+yqsysid,"延其月","width=1024,height=550");
2
3
4
5
6
7
8
# 5.2.6 this.toFlow 打开流程详情页
使用说明:
/**
* @description 打开流程表单详情 仅支持为列表按钮
* @param isView 是否可编辑0/1(不可编辑)【可选】 【类型:Number】
* @param params 链接传值【可选】【类型:Object】
*/
this.toFlow(isView,params);
// 示例
this.toFlow(0); //可编辑(待办)
2
3
4
5
6
7
8
实例:
//APP端:
this.toFlow(0)
this.toFlow(0,{version:2})
// 注:一定注意 在params中添加version:2 会打开平台最新流程,不加参数会打开老流程
//PC端对比:
htTestOp('$datarow&FlowID,ID,StepID,GroupID,InstanceID,SYSID&$');
function htTestOp(flowid,taskid,stepid,groupid,instanceid,formopenmode,flowstate){
var data={
flowid:flowid,//流程ID
taskid:taskid,//任务ID
stepid:stepid,//步骤
groupid:groupid,//人员组
instanceid:instanceid,//实例
formopenmode:$formopenmode,
formopenmode:1,
height:window.document.body.offsetHeight,
width:window.document.body.offsetwidth
}
processHandle(data)
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 5.2.7 this.rowData 读取最先选中的第一行某个字段对应的值
使用说明:
/**
* @description 读取最先选中的第一行某个字段对应的值
* @param filed 字段名称 (必填)【类型:String】
*/
this.rowData(filed);
// 实例
// 这个方法会返回这个字段的值
let sysid= this.rowData('SYSID'); //可以这种方式接收
2
3
4
5
6
7
8
9
10
实例
//APP端
var sysid=this.rowData("SYSID")
// PC端
var arr=[]
var checkRows=window.getlistChecked()
var checkRow=checkRow[0]
var sysid =checkRow.SYSID
2
3
4
5
6
7
8
# 5.2.8 this.delRow 删除行数据
/**
* @description 删除行数据
* @param sysid 数据的sysid【可选】 【类型:String】
*/
this.delRow(sysid);
// 实例
this.delRow("6467847e-c324-5409-f740-c19b4865e03b");
2
3
4
5
6
7
实例
1.按钮为列表按钮时
// APP端:
this.delRow()
//PC端:
del("$datarow&SYSID&$")
2
3
4
5
2.列表为普通按钮
// APP端:
let sysid=this.checkRowId()
this.delRow(sysid)
//PC端:
var arr=[]
var checkRows=window.getlistChecked()
var checkRow=checkRow[0]
var sysid =checkRow.SYSID
del(sysid)
2
3
4
5
6
7
8
9
10
# 5.2.9 this.checkRowId 返回选中
数据的sysid
/**
* @description 返回选中数据的sysid
*/
this.checkRowId();
// 返回选中的第一条数据的sysid
//示例:
let sysid=this.checkRowId();
2
3
4
5
6
7
实例
// APP端:
var sysid = this.checkRowId();
//PC端:
var arr=[]
var checkRows=window.getlistChecked()
var checkRow=checkRow[0]
var sysid =checkRow.SYSID
2
3
4
5
6
7
8
# 5.2.10 this.toList 打开列表
/**
* @description 跳转到对应的列表页面
* @param id 列表ID 【类型:String】
* @param name 列表标题 【类型:String】
*/
this.toList(id,name);
// 返回选中的第一条数据的sysid
//示例:
this.toList("bb0a1e9311f54d34ae536f52a9fa41b3","设备润滑"); // 跳转到设备润滑列表
2
3
4
5
6
7
8
9
实例
// APP端:
this.toList("e6b53f738c18496d9eda6742d09f3189","不停车");
//PC端:
window.open("/ProgramBui1der/Run?programid=e6b53f738c18496d9eda6742d09f3189")
2
3
4
5
# 5.2.11 this.toPbList 打开二级列表
/**
* @description 打开二级列表
* @param id 列表id 【类型:String】
* @param titles 列表标题 【类型:String】
* @param otherCon 其余参数 【类型:String】
* @param mutil 是否多选0单选1多选 【默认单选】 【类型:Number】
*/
this.toPbList(id,titles,otherCon,mutil);
//示例
let oCon=`ParentID='4de5376440164eb0bdcd188fe93369ae'`;
this.toPbList('4de5376440164eb0bdcd188fe93369ae','详情呐',oCon,0);
2
3
4
5
6
7
8
9
10
11
实例
// APP端
var oCon="ParentID='"+ypsysid+"'"
this.toPbList("4de5376440164eb0bdcd188fe93369ae","巡检完成区域",oCon);
// PC端
let ypsysid=checkRow.SYSID
window.open("/ProgramBui1der/Run?programid=e6b53f738c18496d9eda6742d09f3189&OtherCon=ParentID='"+ypsysid+"'","巡检完成区域")
2
3
4
5
6
7
# 5.2.12 this.getlists 刷新列表数据
/**
* @description 刷新列表数据
*/
this.getlists();
2
3
4
5
# 5.2.13 this.directPrintMain 调用打印机
/**
* @description 调用打印机
* @param name 打印模板名称 【类型:String】
* @param masterKey 主键ID 【类型:String】
* @param printQty 打印数量 【类型:Number】
* @param isPreview 是否预览false否 true是 【类型:boolean】
*/
this.directPrintMain(name, masterKey, printQty, isPreview)
//
this.directPrintMain("EamPrintTemplate1",this.cItem.SYSID,1,false)
2
3
4
5
6
7
8
9
10
11
# 六、表单
脚本 | 描述 | 应用于 |
---|---|---|
this.form | 表单主表的值 | 表单中主表值的对象集合 |
this.formid | 表单的id | 便捷获取当前表单ID |
this.trobj | 当前行的值 ( 行加载/行点击时) | 用于获取子表中正在点击 的行数据 |
this.sub | 当前行的索引( PT定位哪一行) | 用于获取子表中正在点击 的第几行 |
this.bobj | 回调返回的值 | 参照列表返回的值 |
this.saveResult | 表单提交后返回数据 | 表单提交后返回数据 |
# 6.1参数
# 6.1.1 this.form 表单主表的值 【类型:Object】
/* 表单中主表值的对象集合 */
/* 可以从中取主单控件的值 */
// 用法
this.form["iit_eq_btcjxhead.jxdw"]=res[0].Name; //赋值
let Name=this.form["iit_eq_btcjxhead.jxdw"]; // 取值
2
3
4
5
实例
// APP端:
var aaa =this.form["iit_eq_btcjxhead.flow_hidden_1"];
this.form["iit_eq_btcjxhead.jxdw"]=res[0].Name; this.form["iit_eq_btcjxhead.MaintenanceUnitNo"]=res[O].WERKS; this.form["iit_eq_btcjxhead.Workshop"]=res[0].TXT;
this.form["iit_eq_btcjxhead.FEVoR"]=res[O].FEVoR; this.form["iit_eq_btcjxhead.WorkID"]=res[0].sysids; // 赋值
// PC端:
var aaa=$("#iit_eq_btcjxhead\\.flow_hidden_1").val() // 取值
S("#iit_eq_btcjxhead\\.jxdw").val(results[o].Name)//赋值
$("#iit_eq_btcjxhead\\.MaintenanceUnitNo").val(results[O].WERKS) //赋值
$("#iit_eq_btcjxhead\\.Workshop").val(results[0].TXT) //赋值
$("#iit_eq_btcjxhead\\.FEVOR").val(results[O].FEVoR)//赋值
S("#iit_eq_btcjxhead\\.WorkID").val(results[0].sysids)//试值
2
3
4
5
6
7
8
9
10
11
12
# 6.1.2 this.formid 表单的id 【类型:String】
/* 当前表单的id */
//用法
var formid=this.formid
2
3
# 6.1.3 this.trobj 当前行的值 ( 行加载/行点击时) 【类型:Object】
/* 当前行的值 主要用于行加载,行点击事件 */
this.trobj["aaaaaaa"]="aaaa" //赋值
var aa==this.trobj["aaaaaa"] // 取值
2
3
实例
// APP端:
this.trobj["mes_patrol_temptaskitem_actualConclusion"]=116
this.trobj["mes_patrol_temptaskitem_actualConclusion_name"]="异常"
// PC端:
xjx.setValue(tr,'actualConclusion',1);
2
3
4
5
# 6.1.4 this.sub 当前行的索引 ( PT定位哪一行) 【类型:Number】
/* 获取当前点击的行的索引 结合行内禁用某一项使用 */
// this.itemDisable("mes_patrol_temptaskitem_passReason",true,this.sub)
2
3
实例
// APP端:
this.itemDisable("mes_patrol_temptaskitem_passReason",true,this.sub)
// PC端:
$("tr[rowindex="+trobj.rowIndex+"']input[colname='mes_patrol_temptaskitem_passReason']").removeAttr("disabled");
2
3
4
5
# 6.1.5 this.bobj 回调返回的值 【类型 Array /Object】
/* 文本按钮,弹出框 回调返回的值 */
/* this.bobj为对象和数组取决于配置时 是否 返回多条数据 */
// 示例
let cid=this.bobj.cid // 取回填值中字段cid的值 this.bobj为对象情况下
let cid=this.bobj[0].cid // 取回填值中字段cid的值 this.bobj为数组情况下
2
3
4
5
实例
// APP端:
this.form["mes_patrol_task.InsLineID"]=this.bobj.sysid
this.form["mes_patrol_task.InsLineName"]=this.bobj.name
this.form["mes_patrol_task.InsLineCode"]=this.bobj.code
this.form["mes_patrol_task.flow_text_1"]=this.bobj.valueTypeName
this.form["mes_patrol_task.InspectionType"]=this.bobj.valueType
// PC端:
S("#mes_patrol_task\\.InsLineID").val(data.sysid);
S("#mes_patrol_task\.InsLineName").val(data.name);
$("#mes_patrol_task\\.InsLineCode").val(data.code);
$("#mes_patrol_task\\.flow_text_1").val(data.valueTypeName);
$("#mes_patrol_task\\.InspectionType").val(data.valueType);
2
3
4
5
6
7
8
9
10
11
12
13
# 6.1.6 this.saveResult 表单提交后返回数据
this.saveResult
1.正常表单返回数据
// {
// "Result": true,
// "Print": {
// "Isprint": false,
// "PrintData": []
// },
// "Dic": "{\"name\":\"312\",\"sysId\":\"d2c4d84a-4e23-4b93-9878-6f28e429d878\"}",
// "FormResult": null
// }
2.正常流程返回数据
// {
// "isSuccess": true,
// "DebugInfo": "处理流程步骤结果:成功<br/>调试信息:已发送到:审批",
// "FlowProcess": {
// "IsSuccess": true,
// "Messages": "已发送到:审批",
// "DebugMessages": "已发送到:审批",
// "Other": null,
// "NextTasks": [
// {
// "SYSID": "bd7a64a44bb9433a81884a6103ddc5cb",
// "PrevID": "033ffb3afc8d423cb7a9f6fbe020958a",
// "PrevStepID": "47d83eb6b19b4367b031ba8a0ba2ae81",
// "FlowID": "bd3da899c8124a1e86dfaa08bc643370",
// "StepID": "87780ff565ad4c40b64081c2a5b8de10",
// "StepName": "审批",
// "InstanceID": "61c6da43-2a6b-4fb6-9320-e1c1e5fd2222",
// "GroupID": "3cacbf233c704e15b235135c1d2619c6",
// "Type": 0,
// "Title": "未命名任务(质量检验-来料请检)",
// "SenderID": "f794f599-0d1e-4bca-bd37-c59f0e90ea5a",
// "SenderName": "虚拟人员",
// "SenderTime": "2024-12-13 17:19:25",
// "ReceiveID": "28d294a7b81a4cb7948f496807c1c213",
// "ReceiveName": "gongcheng",
// "ReceiveTime": "2024-12-13 17:19:25",
// "OpenTime": null,
// "CompletedTime": null,
// "ActualCompletedTime": null,
// "Comment": "",
// "IsSign": null,
// "Status": 0,
// "OtherType": 0,
// "Note": null,
// "Sort": 2,
// "Files": null,
// "SignPath": null
// }
// ]
// },
// "SaveResult": null,
// "Print": {
// "Isprint": false,
// "PrintData": null
// }
// }
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# 6.2 方法
脚本 | 描述 | 应用于 |
---|---|---|
this.itemDisabled | 表单项禁用 | 启用禁用表单主表控件 |
this.subDisabled | 子表项禁用 | 启用禁用表单子表控件 |
this.itemShow | 表单项隐藏 | 显示隐藏表单主表控件 |
this.subShow | 子单项显示隐藏 | 显示隐藏表单子表控件 |
this.radioDisabled | 单选禁用 | 单选控件禁用 |
this.tagRadioDisabled | 单选禁用(页签中) | 单选控件禁用(页签中) |
this.radioCheck | 单选选中 | 单选控件启用 |
this.tagRadioCheck | 单选选中(页签中) | 单选控件启用(页签中) |
this.checkCheck | 多选选中 | 多选控件选中 |
this.tagCheckCheck | 多选选中(页签中) | 多选控件选中(页签中) |
this.checkDisabled | 多选禁用 | 多选控件禁用 |
this.tagCheckDisabled | 多选禁用(页签中) | 多选控件禁用(页签中) |
this.itemChange | 调用某个控件的change事件 | 调用某个控件的change事件 |
this.setFormValue | 表单主表多个参数赋值 | 将多个值赋值给表单主表数据 |
ExcuteFormSqlManager | 执行表单SQL管理 | 执行表单中绑定的sql管理 |
this.setValue | 子表赋值 | 给子表的数据赋值 |
this.getValue | 子表取值 | 取子表中的数据 |
this.loadData | 子表数据加载 | 加载时给子表赋值 |
this.getRowCount | 获取某个子表对象行的数量 | 获取某个子表的数据数量 |
this.ptData | 获取某个子表的全部数据 | 获取某个子表的数据 |
this.setPtData | 给子表赋值 | 通过SQL管理查询出来的数据给子表赋值 |
this.headerSelect | 下拉框赋值 | 给主表下拉框控件赋值 |
this.setRowSelect | 子表下拉框赋值 | 给子表下拉框赋值 |
this.$query | 链接中参数 | 获取链接中的参数 |
this.GetJson | 查询sql的值 | 自定义SQL查询值 |
this.refreshList | 刷新上一个页面的列表数据 | 用于修改后刷新上一个页面的数据 |
this.clearRows | 清空PT数据 | 清空PT数据 |
this.itemFocus | 表单项选中 | 表单项选中 |
this.tagFocus | 表单项在页签内选中 | 表单项在页签内选中 |
this.addRow | PT添加一行 | PT添加一行 |
this.removeRow | PT移除某一行 | PT移除某一行 |
this.backEvent | 自定义表单按钮返回事件 | 表单自定义按钮提供返回上级页面的功能,并提供操作数据能力 |
# 6.2.1 this.itemDisabled 表单项禁用
/**
* @description 表单项禁用
* @param name 控件名称 【类型:String】
* @param isdisabled true/false 禁用/不禁用 【类型:Boolean】
* @param index PT单列单行禁用时的下标【PT使用时需传值this.ptIndex】 【类型:Number】
*/
this.itemDisabled(name,isdisabled,index)
//示例:
this.itemDisabled("iit_eq_btcjxhead.flow_radio_1",true) //主表某一项被禁用
this.itemDisabled("iit_eq_btcjxhead.flow_radio_1_aaaa",true,0) //pt第一行某一项被禁用
2
3
4
5
6
7
8
9
10
实例
// APP端:
this.itemDisabled("mes_patrol_task.flow_select_l",true);
this.itemDisabled("mes_patrol_task.PlanStartTime",true);
this.itemDisabled("mes_patrol_task.PlanEndTime",true);
// PC端:
$("#mes_patrol_task\\.flow_select_1").attr("disabled",'disabled');
S("#mes_patrol_task\\.PlanStartTime").attr("disabled",'disabled');
$("#mes_patrol_task'\.PlanEndTime").attr("disabled",'disabled');
2
3
4
5
6
7
8
9
10
# 6.2.2 this.subDisabled 子表项禁用
/**
* @description 子表项禁用
* @param name 子表对象名称 【类型:String】
* @param field 禁用的字段名称 【类型:String】
* @param isdisabled true/false 禁用/不禁用 【类型:Boolean】
* @param index PT单列单行禁用时的下标【当填入-1时,将会禁用关于这个字段的所有列】 【类型:Number】
* @param load 是否初次加载PT,设置为true时(用于行加载是设置列禁用) 【类型:Boolean】
* @param tagName 页签名称(如果pt在页签中) 【类型:String】
*/
this.subDisabled(name,field,isdisabled,index,load,tagName)
//示例:
this.subDisabled("tb","Part",true,this.sub) //子表某一行一列被禁用
this.subDisabled("tb","Part",true,-1) //pt第所有行某一项全部禁用
this.subDisabled("tb","Part",true,-1,"tag_57") //pt在页签中
2
3
4
5
6
7
8
9
10
11
12
13
14
# 6.2.3 this.itemShow 表单项隐藏
/**
* @description 表单项隐藏 隐藏域控件是不支持的(隐藏域本身就是隐藏的)
* @param name 控件名称【类型:String】
* @param isshow true/false 显示/隐藏 【类型:Boolean】
*/
this.itemShow(name,isshow)
//示例:
this.itemShow("iit_eq_btcjxhead.flow_radio_1",true) //主表某一项被隐藏
2
3
4
5
6
7
8
实例
// APP端:
this.itemShow("label_ManualSignReason",true);
this.itemShow("mes_patrol_resultentry.ManualSignReason",true);
this.itemShow("label_ManualSignReason",false);
this.itemShow("mes_patrol_resultentry.ManualSignReason",false);
// PC端:
$("#label_ManualSignReason").show();
$("#mes_patrol_resultentry\\.ManualSignReason").show();
$("#label_ManualSignReason").hide();
$("#mes_patrol_resultentry\\.ManualSignReason").hide();
2
3
4
5
6
7
8
9
10
11
# 6.2.4 this.subShow 子单项显示隐藏
/**
* @description 子单项显示隐藏
* @param name 子表对象名称 【类型:String】
* @param field 显示隐藏的字段名称 【类型:String】
* @param isdisabled true/false 显示/隐藏 【类型:Boolean】
* @param index PT单列单行显示隐藏时的下标【当填入-1时,将会作用于关于这个字段的所有列】 【类型:Number】
* @param load 是否初次加载PT,设置为true时(用于行加载是设置列禁用) 【类型:Boolean】
* @param tagName 页签名称(如果pt在页签中) 【类型:String】
*/
this.subShow(name,field,isdisabled,index,load,tagName)
//示例:
this.subShow("tb","Part",true,this.sub) //子表某一行一列被显示
this.subShow("tb","Part",false,-1) //pt第所有行某一项全部隐藏
this.subShow("lrjg","actualResults",false,"",true) //pt行加载时隐藏
this.subShow("lrjg","actualResults",false,"",true,"tag_57") //pt在页签中
2
3
4
5
6
7
8
9
10
11
12
13
14
15
实例
// APP端:
this.subShow("tb","Part",true,this.sub) //子表某一行一列被显示
this.subShow("tb","Part",false,-1) //pt第所有行某一项全部隐藏
this.subShow("lrjg","actualResults",false,"",true) //pt行加载时隐藏
// PC端:
// 暂无
2
3
4
5
6
# 6.2.5 this.radioDisabled 单选禁用
/**
* @description 单选禁用
* @name 控件名称 【类型:String】
* @index 禁用的单选下标 数组格式(多个禁用) 【类型:Array】
* @index state true/false 禁用/不禁用 【类型:Boolean】
*/
this.radioDisabled(name,index,state)
//示例:
this.radioDisabled("iit_eq_btcjxhead.flow_radio_1",[0,1],true)
2
3
4
5
6
7
8
9
# 6.2.5.1 this.tagRadioDisabled 单选禁用(页签中)
/**
* @description 单选禁用(页签中)
* @name 控件名称 【类型:String】
* @index 禁用的单选下标 数组格式(多个禁用) 【类型:Array】
* @index state true/false 禁用/不禁用 【类型:Boolean】
* @param tagName 页签名称 【类型:string】
*/
this.tagRadioDisabled(name,index,state,tagName)
//示例:
this.tagRadioDisabled("iit_eq_btcjxhead.flow_radio_1",[0,1],true,"tag_57")
2
3
4
5
6
7
8
9
10
# 5.2.6 this.radioCheck 单选选中
/**
* @description 单选选中
* @name 控件名称 【类型:String】
* @index 选中的单选下标 只能填一个
*/
this.radioCheck(name,index)
//示例:
this.radioCheck("iit_eq_btcjxhead.flow_radio_1",0)
2
3
4
5
6
7
8
# 5.2.6.1 this.tagRadioCheck 单选选中(页签中)
/**
* @description 单选选中(页签中)
* @param name 控件名称 【类型:String】
* @param index 选中的单选下标 只能填一个
* @param param tagName 页签名称 【类型:string】
*/
this.tagRadioCheck(name,index,tagName)
//示例:
this.tagRadioCheck("iit_eq_btcjxhead.flow_radio_1",0,"tag_57")
2
3
4
5
6
7
8
9
# 6.2.7 this.checkDisabled 多选禁用
/**
* @description 多选禁用
* @param name 控件名称 【类型:String】
* @param index 禁用的单选下标 数组格式(多个禁用) 【类型:Array】
* @param state true/false 禁用/不禁用 【类型:boolean】
*/
this.checkDisabled(name,index,state)
//示例:
this.checkDisabled("iit_eq_btcjxhead.flow_checkbox_1",[0,1],true)
2
3
4
5
6
7
8
9
# 6.2.7.1 this.tagCheckDisabled 多选禁用(页签中)
/**
* @description 多选禁用(页签中)
* @param name 控件名称 【类型:String】
* @param index 禁用的单选下标 数组格式(多个禁用) 【类型:Array】
* @param state true/false 禁用/不禁用 【类型:boolean】
* @param tagName 页签名称 【类型:string】
*/
this.tagCheckDisabled(name,index,state,tagName)
//示例:
this.tagCheckDisabled("iit_eq_btcjxhead.flow_checkbox_1",[0,1],true,"tag_57")
2
3
4
5
6
7
8
9
10
# 6.2.8 this.checkCheck 多选选中
/**
* @description 多选选中
* @param name 控件名称 【类型:String】
* @param index 选中的单选下标 数组格式(多个选中) 【类型:Array】
*/
this.checkCheck(name,index)
//示例: this.checkCheck("iit_eq_btcjxhead.flow_checkbox_1",[1,2])
2
3
4
5
6
7
# 6.2.8.1 this.tagCheckCheck 多选选中(页签中)
/**
* @description 多选选中(页签中)
* @param name 控件名称 【类型:String】
* @param index 选中的单选下标 数组格式(多个选中) 【类型:Array】
* @param tagName 页签名称 【类型:string】
*/
this.tagCheckCheck(name,index,tagName)
//示例: this.tagCheckCheck("iit_eq_btcjxhead.flow_checkbox_1",[1,2],"tag_57")
2
3
4
5
6
7
8
# 6.2.9 this.itemChange 调用某个控件的change事件
/**
* @description 调用某个控件的change方法
* @param name 控件名称 【类型:String】
*/
this.itemChange(name);
//示例:
this.itemChange("iit_eq_btcjxhead.flow_radio_1");
2
3
4
5
6
7
实例
// APP端:
this.itemChange("item");
// PC端:
$("#item").change()
2
3
4
# 6.2.10 this.setFormValue表单主表多个参数赋值
/**
* @description 调用某个控件的change方法
* @param arr 赋值的键值的数组集合 格式:[{"控件名称1":"传入的值1"},{"控件名称2":"传入的值2"}] 【类型:Array】
*/
this.setFormValue(arr);
// 示例
this.setFormValue([{"sysid":"1231231231"},{"username":'2312'}]);
2
3
4
5
6
7
实例
// APP端:
let arr =[{"iit_eq_btcjxhead.jxdw":res[0].Name},
{"iit_eq_btcjxhead.MaintenanceUnitNo":res[0].WERKS},
{"iit_eq_btcjxhead.Workshop":res[0].TXT},
{"iit_eq_btcjxhead.FEVOR":res[0].FEVOR},
{"iit_eq_btcjxhead.WorkID":res[0].sysids}];
this.setFormValue(arr);
// PC端:
var aa=resuitloj.personname
$("#iit_eq_btcjxhead\\.jxdw").val(results[0].Name)
$("#iit_eq_btcjxhead\\.MaintenanceUnitNo").val(results[O].WERKS)
$("#iit_eq_btcjxhead\\.Workshop").val(results[0].TXT)
$("#iit_eq_btcjxhead\\.FEVoR").val(results[O].FEVoR)
$("#iit_eq_btcjxhead\\.WorkID").val(results[0].sysids)
2
3
4
5
6
7
8
9
10
11
12
13
14
# 6.2.11 ExcuteFormSqlManager 执行表单SQL管理
/**
* @description 执行表单SQL管理
* @param key sql管理的关键key 【类型:String】
* @param arg sql中多个占位符键值对象 【类型:String】
*/
this.ExcuteFormSqlManager(key,...arg).then(res=>{
//res 为返回的值 不需要进行json.parse转化
}).catch(err=>{
// err 为报错的结果
})
// 示例
this.ExcuteFormSqlManager("getAction",{"userid":this.userSysid()})
.then(res=>{
var aa=res[0].personname;
let arr =[{"iit_eq_btcjxhead.jxdw":res[0].Name},
{"iit_eq_btcjxhead.MaintenanceUnitNo":res[0].WERKS},
{"iit_eq_btcjxhead.Workshop":res[0].TXT},
{"iit_eq_btcjxhead.FEVOR":res[0].FEVOR},
{"iit_eq_btcjxhead.WorkID":res[0].sysids}];
this.setFormValue(arr);
})
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
实例
// APP端:
this.ExcuteFormSqlManager("getAction",{"userid":this.userSysid()})
.then(res=>{
var aa=res[0].personname;
this.form["Name"]=aa
})
// PC端:
var result=RoaduI.AjaxRequest("getAction@userid="+aaa);
results=JSON.parse(result)
$("#Name").val(results[0].Name)
2
3
4
5
6
7
8
9
10
# 6.2.12 this.setValue PT赋值
/**
* @description PT赋值,同PC用法基本一致
* @param tb pt对象名称 【类型:Array】
* @param collection 需要赋值和对象中取值的字段,键值集合 【类型:Array/String】
* @param data 字段值 【单行单列赋值必填】 【类型:Array/String】
* @param add 是否添加一行 【Boolean】
* @param top 是否加在最前 【类型:Boolean】
* @param tagName 页签名称(当前PT是否在页签内) 【类型:String】New
* 多行自动赋值,主要看返回的this.bobj否是数组
*/
this.setValue(tb,collection,data,add,top,tagName)
// 示例
var cols=[{Key:"personInChargeCode",Value:"SYSID"},{Key:"personInCharge",Value:"USER_Name"}];
this.setValue("txt",cols);
this.setValue("txt","MinorCode",aa.join(','));
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
实例
单行单列赋值 this.setValue(tb,collection,data)中 data需要传值
// APP端:
this.setValue("txt","Code","code001")
// PC端:
txt.setValue(trobj,"Code","code001")
2
3
4
多行=>单/多列赋值【this.bobj为对象类型 只会赋值一行,为数组时则会多行赋值】 this.setValue(tb,collection,data)中 data不需要传值 默认数据源为返回的值
// APP端:
var cols=[{Key:"personInChargeCode",Value:"SYSID"},{Key:"personInCharge",Value:"UsER_Name"}];
this.setValue("txt",cols)
// PC端:
var cols=[{Key:"personInChargeCode",Value:"SYSID"},{Key:"personInCharge",Value:"USER_Name"}];
txt.setValue(trobj,cols,data);
2
3
4
5
6
存在add的情况【通常为PT 的 弹出按钮】 top:可设置新增的一行排在第一行
// APP端:
var cols=[{Key:"a":Value:"111"},{Key:'b':Value:'22'}]
this.setValue("tb",cols,"",true)
// PC端:
var cols=[{Key:"a":Value:"111"},{Key:'b':Value:'22'}]
var trobj =tb.addRow()
tb.setValue(trobj,cols,data)
2
3
4
5
6
7
# 6.2.13 this.getValue PT取值
/**
* @description PT取当前行某个字段的值
* @param tb pt对象名称 【类型:String】
* @param name 需要取值的字段【类型:String】
* @param all 是否取所有行name字段的值 【可选】【类型:Boolean】
*/
this.setValue(tb,name,all)
// 示例
let pass = this.getValue("xjx","actualIsPass"); // 取对象名为xjx的PT中当前点击行的actualIsPass字段的值
var getSkipValues=this.getValue('lrjg',"IsPass",true); // 取对象名为lrjg的PT中所有的IsPass字段的值
2
3
4
5
6
7
8
9
10
11
实例
1.取当前点击行的值
// APP端:
this.getValue("tb","isPass")
// PC端:
tb.getValue(trobj,"isPass")
2
3
4
- 取所有值
// APP端:
this.getValue("tb","isPass",true)
// PC端:
tb.getValue("isPass",false)
2
3
4
5
# 6.2.14 this.loadData PT数据加载
/**
* @description PT数据加载
* @param tb pt对象名称 【类型:String】
* @param key sql管理的关键key 【类型:String】
* @param tagName 页签名称 如果当前PT在页签内 【类型:String】可选
* @param ...arg sql中多个占位符键值对象,可以多个 【类型:Object】
*/
this.loadData(tb,key,tagName,...arg);
// 示例
this.loadData("tb","getAction","",{'userid':this.userSysid()}); //将SQL管理getAction查询到的值直接赋值到对象为tb的PT行中
2
3
4
5
6
7
8
9
10
11
实例
// APP端:
this.loadData("xjx","selItems","",{"aaa":111},{"bbb":2222})
this.loadData("xjx","selItems","tag_57",{"aaa":111},{"bbb":2222}) //在页签内
// PC端:
var sql ="selItems@aaa="+data.aaa+"&bbb="+data.bbb
xjx.loadData(sql )
2
3
4
5
6
# 6.2.15 this.getRowCount 获取某个PT对象行的数量
/**
* @description 获取某个PT对象的行数量
* @param tb pt对象名称 【类型:String】
*/
this.getRowCount(tb);
// 示例
this.getRowCount("tb"); // 获取对象名为tb的PT的行数量
2
3
4
5
6
7
8
实例
// APP端:
this.getRowCount("tb"); // 名称为tb的子表对象的数据行数量
// PC端:
tb.getRowCount()
2
3
4
5
# 6.2.16 this.ptData 获取某个PT的全部数据
/**
* @description 获取某个PT的全部数据
* @param tb pt对象名称 【类型:String】
*/
this.ptData(tb);
// 示例
this.ptData("tb"); // 获取对象名为tb的PT的全部数据
2
3
4
5
6
7
8
# 6.2.17 this.setPtData 给PT赋值
/**
* @description 给PT赋值
* @param tb pt对象名称 【类型:String】
* @param res 值的集合 【类型:Array】
* @param type 添加类型 【类型:Number】 0:清空数据后添加(默认);1:在当前基础上向后添加;2:在当前基础上前面添加
* @param tagName 页签名称 如果当前PT在页签内 【类型:String】可选
*/
this.setPtData(tb,res,type,tagName);
2
3
4
5
6
7
8
9
实例
// APP端:
// 联合ExcuteFormSqlManager使用
this.ExcuteFormSqlManager("LotSql",{"LotNo":LotNo})
.then(res=>{
if(res.length>0){
this.setPtData("tb",res,1)
}
})
// PC端:
var result=RoadUI.AjaxRequest('LotSql@LotNo='+LotNo);
tb.loadDat(JSON.parse(result),2)
2
3
4
5
6
7
8
9
10
11
12
# 6.2.18 this.headerSelect 下拉框赋值
/**
* @description 下拉框赋值
* @param name 表单项名称 【类型:String】
* @param sql sql值 【类型:String】
* @param type 添加类型 【类型:Number】 0:清空数据后添加(默认);1:在当前基础上向后添加;2:在当前基础上前面添加
* @param isTag 是否在页签内 【类型:Boolean】
* @param tagName 页签名称 如果当前PT在页签内 【类型:String】
* @param setFirst 是否设置当前控件值为查询出来的第一个值 【类型:Boolean】
*/
this.headerSelect(name,sql,type,isTag,tagName,setFirst);
2
3
4
5
6
7
8
9
10
11
实例
// APP端:
this.headerSelect("mes_store_outstorehead.ToStore5etID","select sysid,name form mes_set");
// PC端:
header_select("mes_store_outstorehead.ToStoreSetID","select SYSID,Name from Mes_Set");
//在页签内
this.headerSelect("mes_store_outstorehead.ToStore5etID","select sysid,name form mes_set",1,true,"tag_57");
// 设置默认
this.headerSelect("mes_supplier.flow_select_1","select sysid,name form mes_set",0,false,"",true)
2
3
4
5
6
7
8
9
# 6.2.19 this.setRowSelect PT下拉框赋值
/**
* @description 下拉框赋值
* @param name pt对象名称 【类型:String】
* @param field 列字段 【类型:String】
* @param index 添加位置 -1,所有列,>0 时;所填写的列
* @param sql 赋值SQL 【类型:String】
* @param type 添加类型 【类型:Number】 0:清空数据后添加(默认);1:在当前基础上向后添加;2:在当前基础上前面添加
* @param load 是否初次加载PT,设置为true时(用于行加载是设置列禁用) 【类型:Boolean】
* @param tagName 页签名称 如果当前PT在页签内 【类型:String】
*/
this.setRowSelect(name,field,index,sql,type,load,tagName);
// 示例
this.setRowSelect("tb","isPass",0,"select sysid,name from smart_userinfo",0,true,"tag_57") // 行加载时执行
2
3
4
5
6
7
8
9
10
11
12
13
14
15
PC:
# 6.2.20 this.$query 链接中参数
/**
* @description 获取链接中的参数
* @param tb pt对象名称 【类型:String】
*/
let sysid = this.$query().sysid
2
3
4
5
6
实例
// APP端
var type =this.$query().type // 取链接中传过来的type参数
//PC端
window.GetQueryString("type") // 取链接中传过来的type参数
2
3
4
5
6
# 6.2.21 this.GetJson查询sql的值
/**
* @description 查询sql的值
* @param tb pt对象名称 【类型:String】
*/
this.GetJson({sql:sql})
.then(res=>{
// 数据在res.Data中
})
2
3
4
5
6
7
8
9
实例
// APP端:
var sql =`select * from mes_aa`;
this.GetJson({sql:sql})
.then(res=>{
// res.Data 为查询结果
})
// PC端:
var sql =`select * from mes_aa`;
var result =RoadUI.AjaxRequest(sql);
result =JSON.parse(result)
// result为sql查询结果
2
3
4
5
6
7
8
9
10
11
# 6.2.22 this.refreshList 刷新上一个页面的列表数据
//用于修改后刷新上一个页面的数据
this.refreshList();
2
# 6.2.23 this.clearRows 清空PT数据
/**
* @description 清空PT数据
* @param name pt对象名称 【类型:String】
* @param tagName 页签名称(如果当前PT在页签内) 【类型:String】
*/
this.clearRows(name,tagName);
// 示例
this.clearRows("tb2");// 正常写法
this.clearRows("tb2","tag_57"); //在页签内写法
2
3
4
5
6
7
8
9
# 6.2.24 this.itemFocus 表单项选中
/**
* @description 表单项选中
* @param name 表单项名称 【类型:String】
*/
this.itemFocus(name);
// 示例
this.itemFocus("mes_store_outstorehead.ToStore5etID");
2
3
4
5
6
7
# 6.2.25 this.tagFocus 页签内表单项选中
/**
* @description 页签内表单项选中
* @param name 表单项名称 【类型:String】
* @param tagName 页签名称【类型:String】
*/
this.tagFocus(name,tagName);
// 示例
this.tagFocus("mes_store_outstorehead.ToStore5etID","tag_57"); //在页签内写法
2
3
4
5
6
7
8
# 6.2.26 this.addRow PT添加一行
/**
* @description PT添加一行
* @param tb pt对象名称 【类型:String】
* @param tagName 页签名称【类型:String】
*/
this.addRow(tb,tagName);
// 示例
this.addRow("tb1"); //在页签内写法
this.addRow("tb1","tag_57"); //在页签内写法
2
3
4
5
6
7
8
9
# 6.2.27 this.removeRow PT删除一行
/**
* @description PT添加一行
* @param tb pt对象名称 【类型:String】
* @param i 第几行下标从0开始 【类型:Number】
* @param tagName 页签名称【类型:String】
*/
this.removeRow(tb,i,tagName);
// 示例
this.removeRow("tb1",1); //在页签内写法
this.removeRow("tb1",i,"tag_57"); //在页签内写法
2
3
4
5
6
7
8
9
10
# 6.2.28 this.backEvent 自定义表单按钮返回事件
/**
* @description 自定义表单按钮返回事件
* @param fn 执行的函数 【类型:function】
* @param needBack 页签名称【类型:Boolean】
*/
this.backEvent(fn,needBack=true);
// 示例 当前表单提交并希望将当前某一项数据回传给上一级页面
this.backEvent((router)=>{
// router fn中上级页面的数据集合
router.form["xxxx"] ="xxx" // 上级页面为表单可为form中的某一项复制
router.addRow("tb") // 上级页面为表单调用addRow方法为pt新增一行
router.addFlow(0) // 上级页面为列表可继续跳转新增流程页面
})
// 示例 当前表单提交并希望将当前某一项数据回传给上一级页面
this.backEvent((router)=>{
},false) //设置false 则表单自定义按钮执行完 不会进行跳转
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 6.3. 控件目前支持的事件
# 6.3.1 文本框/文本域
- tap 点击
- appchange 输入的时候实时触发
- appblur 文本框失去焦点
- appfocus 文本框获得焦点
# 6.3.2下拉列表/日期时间
- tap 点击
- longtap 长按
- appchange 主动改变值时触发
# 6.3.3 按钮/页签
- tap 点击
# 6.3.4 单选/复选
- appchange 值改变时触发
# 6.3.5 PT=>弹出页面/下拉
- tap 点击
- longtap 长按
- appchange 下拉是主动改变值时触发 ;弹出页面是值回填时就会触发
# 6.3.6 PT=>文本框/文本域
- tap 点击
- appchange 输入的时候实时触发
- appblur 文本框失去焦点
- appfocus 文本框获得焦点
# 七、流程
# 7.1 方法
脚本 | 描述 | 应用于 |
---|---|---|
this.stepCheck | 流程下个步骤选中 | 自定义选择下一个步骤 |
this.stepDisabled | 流程下个步骤禁用 | 禁用下一个步骤某一项禁止选中 |
# 7.1.1 this.stepCheck 流程下个步骤选中
/**
* @description 流程下个步骤选中
* @param id 步骤单选id 【类型:String】
*/
this.stepCheck(id);
// 示例
this.stepCheck('836641b4-cd59-41d1-bd92-be0d9644a1d6');
2
3
4
5
6
7
# 7.1.2 this.stepDisabled 流程下个步骤禁用
/**
* @description 流程下个步骤选中
* @param id 步骤单选id 【类型:String】
* @param id 是否禁用 true/false 【类型:Boolean】
*/
this.stepDisabled(id,disabled);
// 示例
this.stepDisabled('836641b4-cd59-41d1-bd92-be0d9644a1d6',true)
2
3
4
5
6
7
8
实例
// APP端:
this.stepDisabled('836641b4-cd59-41d1-bd92-be0d9644a1d6',false);
this.stepCheck('836641b4-cd59-41d1-bd92-be0d9644a1d6');
this.stepDisab1ed(*836641b4-cd59-41d1-bd92-be0d9644a1d6',true);
// PC端:
$("#ses_hrm_riskhandles\\.flow_text_2").show();
$("#ses_hrm_riskhandles\\.flow_text_3").show();
$("#836641b4-cd59-41d1-bd92-be0d9644a1d6").attr("disabled",false).prop("checked",true);
$("#bb9faf2e-12ac-4c45-8c28-2e58512a8d91").prop("checked",false).attr("disabled",true);
2
3
4
5
6
7
8
9
# 7.2 参数
参数名 | 描述 | 应用于 |
---|---|---|
this.saveBtnType | 当前流程点击的按钮类型 | 通过不用的流程按钮执行不同的动作 |
# 7.2.1 this.saveBtnType 当前流程点击的按钮类型
this.saveBtnType //返回的数据有
1.send //发送
2.save //保存
3.invalid //作废
4.completed //完成
5.back //退回
6.copy //抄送
7.submit //提交
2
3
4
5
6
7
8
# 八、参照页面
脚本 | 描述 | 应用于 |
---|---|---|
this.cItem | 当前点击行的数据 | 获取参照页面中当前点击行的数据 |
this.row | 当前参照页面所有行的数据 | 获取参照页面中所有已加载的数据 |
# 8.1 参数
# 8.1.1 this.cItem 当前点击行的数据
/* this.cItem 值为当前行对象数据 */
// 用法
let pid =this.cItem.pid; // 获取当前行中字段为pid的值
2
3
# 8.1.2 this.row 当前参照页面所有行的数据
/* 方便获取当前参照页面所有行的数据 */
// 示例 假如列表中有三条且存在cid,cname字段
let id1=this.row[0].cid; //取第一条数据的cid字段的值
let id2=this.row[2].cid; // 取第三条数据的cid字段的值
let name1 =this.row[1].cname; // 取第二条数据的cname字段的值
2
3
4
5
6
# 8.2. 方法
脚本 | 描述 | 应用于 |
---|---|---|
this.lookMap | 查询巡检路线地图 | 用于打开地图查看巡检路线(只能在巡检里面用) |
this.refreshList | 刷新上一个页面的列表数据 | 用于修改后刷新上一个页面的数据 |
# 8.2.1 this.lookMap 查询巡检路线地图
/* 用于打开地图查看巡检路线*/
/* 只能在巡检里面用 */
//用法
this.lookMap();
2
3
4
# 8.2.2 this.refreshList 刷新上一个页面的列表数据
//用于修改后刷新上一个页面的数据
this.refreshList();
2
# 九、其余脚本
脚本 | 描述 | 应用于 |
---|---|---|
this.http.get | GET请求 | 网络GET请求 |
this.http.post | POST请求 | 网络POST请求 |
this.freeBackdata | fci自由活动 | fci自由活动 |
只能请求平台内部接口 !!!
只能请求平台内部接口 !!!
只能请求平台内部接口 !!!
# 9.1 GET请求
使用说明:
/**
* @description 网络请求GET
* @param url 接口地址 接口 【类型:String】
* @param data 参数 【类型:Object】
* @param option 网络配置 【类型:Object】
*/
this.http.get(url,data,option)
// 示例 get为小写,仅小写
this.http.get('Login/Login',{name:'aa',pwd:'bb'}).then(res=>{}).catch(err=>{})
.then(res=>{
// 成功响应进行的操作
TODO
})
.catch(err=>{
// 请求失败后进行的操作
TODO
})
/// 注:可在option内添加customUrl字段 自定义url 【POST同理】
this.http.get('http://tentai.cn:8033/api/Login/Login',{name:'aa',pwd:'bb'},{
customUrl:true, // 自定义url,可不只请求内部接口
header:{
'content-type': 'application/json',// 请求类型
}
}).then(res=>{}).catch(err=>{})
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 9.2 POST请求
/**
* @description 网络请求POST
* @param url 接口地址 【类型:String】
* 地址参数有所删减
api/PatrolApi/PatrolInputResultUpload => PatrolApi/PatrolInputResultUpload
* @param data 参数 【类型:Object】
* @param option 网络配置 【类型:Object】
*/
this.http.post(url,data,option).then(res=>{}).catch(err=>{})
// 示例 post为小写,仅小写
this.http.post('Login/Login',{name:'aa',pwd:'bb'})
.then(res=>{
// 成功响应进行的操作
TODO
})
.catch(err=>{
// 请求失败后进行的操作
TODO
})
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
实例
// APP端
var json ={"SYSID":"aaaa"}
this.http.post("PatrolApi/PartrolInputResultUpload",json)
.then(res=>{
// 请求成功
if(r.Result){
// TODO
}
})
.catch(err=>{
// 请求失败
// TODO
})
// PC端
TentaiUI.Common.post_not_async("api/PatrolApi/PatrolInputResultUpload",{"JsonData":jsonData},function(s){
if(s.Result){
// 请求成功 TODO
}else{
// 请求失败 TODO
}
})
//GET与POST方法写法一致
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 9.3 this.freeBackdata fci自由活动表单回执
/**
* @description fci自由活动
* @param {Object} data 回传数据
*/
this.freeBackdata(data);
//data参数
// sysid:必填 一般传递当前提交后返回的数据id
// result:可选 提供的当前表单的数据用于记录的字段值 自定义对象接口
// 自由活动回传格式
let data =JSON.parse(this.saveResult.Dic) //this.saveResult在本文档中搜索查看内容
let sysid=data.sysId
let title=data.name
this.freeBackdata({
sysid:sysid,
result:{
title:title
}
})
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 9.4 this.getVarValue fci工单参数赋值中获取当前活动的值
/**
* @description 获取当前活动的值
* @param {Object} x 当前活动
*/
this.getVarValue()
// 具体获取的值看工艺流程活动->变量更新页面查看每个活动的值结构
2
3
4
5
6
7
8
9