| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- //表单操作相关js文件
- window.ss.form = window.ss.form || {};
- //提交表单的方法
- ss.form.submit = function (param){
- const {
- id, url, width, height, minHeight, maxHeight, targetWin
- } = param;
- // 无校验直接提交,兼容无校验页面 by xu 20251211
- const needValidate = window.ssVm && window.ssVm.validations && window.ssVm.validations.size > 0;
- if(!needValidate || window.ssVm.validateAllAndShowMsg()){
- let f = null;//表单元素对象
- if (id) {
- // 如果id不为空,根据id获取元素
- f = document.getElementById(id);
- } else {
- // 如果id为空,获取页面第一个form元素
- f = document.querySelector('form');
- }
- if(!f){
- alert('表单不存在');
- return;
- }
- if(url)
- f.action = url;
- if (width && height && minHeight && maxHeight) {
- ss.display.resizeComponent(
- width,
- height,
- minHeight,
- maxHeight
- );
- }
- if(targetWin){
- ss.form.submit2TargetWin(targetWin);
- }else{
- f.submit();
- }
- return true;
- }else
- return false;
- }
- ss.form.submit2TargetWin = function (targetWin) {
- const firstForm = document.querySelector('form');
- if(firstForm==null){
- console.log("找不到form!");
- }
- var myform = firstForm.cloneNode(true);
- myform.style.display = "none";
- firstForm.parentNode.innerHTML = "";
- targetWin.document.body.appendChild(myform);
- myform.submit();
- }
- ss.form.confirm = function (title,msg,yesFun,noFun){
- const isConfirmed = confirm(msg);
- if (isConfirmed) {
- console.log("用户确认yes");
- if(yesFun)
- yesFun();
- } else {
- console.log("用户取消");
- if(noFun)
- noFun();
- }
- }
|