2025-11-27 16:55:35 +08:00
|
|
|
|
var totalProId = localStorage.getItem("totalProId");
|
2025-12-05 15:39:43 +08:00
|
|
|
|
var token = localStorage.getItem("smz-token");
|
2025-11-27 16:55:35 +08:00
|
|
|
|
var form,laydate
|
|
|
|
|
|
var gxListArr=[];
|
|
|
|
|
|
|
|
|
|
|
|
var selectedGxListInParent = [];// 父页面存储已选数据
|
|
|
|
|
|
$(function () {
|
|
|
|
|
|
layui.use(['form', 'laydate', 'upload'], function () {
|
|
|
|
|
|
form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
|
|
|
|
|
|
laydate = layui.laydate;
|
|
|
|
|
|
form.render();
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
getPro(); // 初始化时加载工程名称下拉列表
|
|
|
|
|
|
getSub("");
|
|
|
|
|
|
getTeam("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 生成甲方二维码
|
|
|
|
|
|
$("#generateQrCodeA").click(function () {
|
|
|
|
|
|
generateQrCode("partya");
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 生成乙方二维码
|
|
|
|
|
|
$("#generateQrCodeB").click(function () {
|
|
|
|
|
|
generateQrCode("partyb");
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 更新甲方签名
|
|
|
|
|
|
$("#updateSignatureA").click(function () {
|
|
|
|
|
|
updateSignature("partya");
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 更新乙方签名
|
|
|
|
|
|
$("#updateSignatureB").click(function () {
|
|
|
|
|
|
updateSignature("partyb");
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
form.on('submit(formDemo)', function (data) {
|
|
|
|
|
|
insertContract(data); //新增合同信息
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//查询分包
|
|
|
|
|
|
form.on('select(proId)', function (data) {
|
|
|
|
|
|
getSub(data.value);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//查询班组
|
|
|
|
|
|
form.on('select(subId)', function (data) {
|
|
|
|
|
|
getTeam(data.value);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
laydate.render({
|
|
|
|
|
|
elem: '#contractDate' //指定元素 元素选择器
|
|
|
|
|
|
, type: 'date' //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒)
|
|
|
|
|
|
, trigger: 'click'
|
|
|
|
|
|
, format: 'yyyy-MM-dd' //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss
|
|
|
|
|
|
// , value: new Date() //初始值 今天
|
|
|
|
|
|
, btns: ['clear', 'now', 'confirm'] //选择框右下角显示的按钮 清除-现在-确定
|
|
|
|
|
|
, done: function (value, date) {//时间回调
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
laydate.render({
|
|
|
|
|
|
elem: '#planStartTime' //指定元素 元素选择器
|
|
|
|
|
|
, type: 'date' //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒)
|
|
|
|
|
|
, trigger: 'click'
|
|
|
|
|
|
, format: 'yyyy-MM-dd' //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss
|
|
|
|
|
|
// , value: new Date() //初始值 今天
|
|
|
|
|
|
, btns: ['clear', 'now', 'confirm'] //选择框右下角显示的按钮 清除-现在-确定
|
|
|
|
|
|
, done: function (value, date) {//时间回调
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
laydate.render({
|
|
|
|
|
|
elem: '#planEndTime' //指定元素 元素选择器
|
|
|
|
|
|
, type: 'date' //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒)
|
|
|
|
|
|
, trigger: 'click'
|
|
|
|
|
|
, format: 'yyyy-MM-dd' //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss
|
|
|
|
|
|
// , value: new Date() //初始值 今天
|
|
|
|
|
|
, btns: ['clear', 'now', 'confirm'] //选择框右下角显示的按钮 清除-现在-确定
|
|
|
|
|
|
, done: function (value, date) {//时间回调
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 自定义校验规则:暂定协议价
|
|
|
|
|
|
form.verify({
|
|
|
|
|
|
contractMoneyCheck: function (value, item) {
|
|
|
|
|
|
if (!value) return '请输入暂定协议价';
|
|
|
|
|
|
// 只允许数字和小数点,最多两位小数
|
|
|
|
|
|
if (!/^\d+(\.\d{1,2})?$/.test(value)) {
|
|
|
|
|
|
return '请输入正确的小写金额,最多两位小数';
|
|
|
|
|
|
}
|
|
|
|
|
|
// 金额范围限制(可选)
|
|
|
|
|
|
if (parseFloat(value) <= 0) {
|
|
|
|
|
|
return '金额必须大于0';
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
gxList: function (value, item) {
|
|
|
|
|
|
if (!value) return '请选择工序';
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
partyaImageUuid: function (value, item) {
|
|
|
|
|
|
if (!value) return '甲方签字不能为空';
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
partybImageUuid: function (value, item) {
|
|
|
|
|
|
if (!value) return '乙方签字不能为空';
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
form.on('submit(nextStep)', function (data) {
|
|
|
|
|
|
nextStep();
|
|
|
|
|
|
return false;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 渲染表单
|
|
|
|
|
|
form.render();
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function insertContract(data) {
|
|
|
|
|
|
var selectedOption = $("#proId option:selected");
|
|
|
|
|
|
data.field.proName = selectedOption.text(); // 获取 name(显示文本)
|
|
|
|
|
|
data.field.abbreviation = selectedOption.attr("data-abbreviation"); // 获取 abbreviation
|
|
|
|
|
|
|
|
|
|
|
|
var subOption = $("#subId option:selected");
|
|
|
|
|
|
data.field.subName = subOption.text();
|
|
|
|
|
|
|
|
|
|
|
|
var teamOption = $("#teamId option:selected");
|
|
|
|
|
|
data.field.teamName = teamOption.text();
|
|
|
|
|
|
|
|
|
|
|
|
data.field.partyaImage = $("#partyaImagePath").val();
|
|
|
|
|
|
data.field.partybImage = $("#partybImagePath").val();
|
|
|
|
|
|
|
|
|
|
|
|
data.field.contractMoneyMax = toChineseNumber(data.field.contractMoney);
|
|
|
|
|
|
|
|
|
|
|
|
data.field.gxList = gxListArr;
|
|
|
|
|
|
// alert(gxListArr)
|
|
|
|
|
|
|
|
|
|
|
|
// 加载提示
|
|
|
|
|
|
var loadingMsg = parent.layer.msg('数据上传中,请稍候...', {icon: 16, scrollbar: false, time: 0, shade: [0.8, '#393D49']});
|
|
|
|
|
|
var formUrl = ctxPath + "/teamSmallBagDryTreaty/addData";
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: 'POST',
|
|
|
|
|
|
async: false, // 默认异步true,false表示同步
|
|
|
|
|
|
url: formUrl, // 请求地址
|
|
|
|
|
|
contentType: "application/json; charset=utf-8",
|
|
|
|
|
|
dataType: 'json', // 服务器返回数据类型
|
|
|
|
|
|
data: JSON.stringify(data.field), //获取提交的表单字段
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
|
layer.close(loadingMsg); // 关闭提示层
|
|
|
|
|
|
if (data.resMsg == "保存成功") {
|
|
|
|
|
|
parent.layer.alert('新增成功', {icon: 1, time: 2000});
|
|
|
|
|
|
setTimeout("reloading()", 2001);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
parent.layer.alert('新增失败', {icon: 2, time: 2000});
|
|
|
|
|
|
// setTimeout("reloading()", 2001);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
error: function (XMLHttpRequest, textStatus, e) {
|
|
|
|
|
|
layer.msg('数据请求发生异常,请稍后重试', {icon: 16, scrollbar: false});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
parent.layer.close(loadingMsg); //再执行关闭
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取工程
|
|
|
|
|
|
* */
|
|
|
|
|
|
function getPro() {
|
|
|
|
|
|
$("#proId").html("");
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: 'get',
|
|
|
|
|
|
url: ctxPath + '/commonSelect/getPros',
|
|
|
|
|
|
data: {},
|
|
|
|
|
|
async: false,
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
|
var html = '<option value="">请选择工程</option>';
|
|
|
|
|
|
for (var i = 0; i < data.obj.length; i++) {
|
|
|
|
|
|
html += '<option value="' + data.obj[i].id + '" data-abbreviation="' + data.obj[i].abbreviation + '">' + data.obj[i].name + '</option>';
|
|
|
|
|
|
}
|
|
|
|
|
|
$("#proId").html(html);
|
|
|
|
|
|
form.render(); //这里就是我们要渲染的地方了
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取分包名称(甲方)
|
|
|
|
|
|
* */
|
|
|
|
|
|
function getSub(proId) {
|
|
|
|
|
|
$("#subId").html("");
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: 'get',
|
|
|
|
|
|
url: ctxPath + '/commonSelect/getSetAuthSubs',
|
|
|
|
|
|
data: {
|
|
|
|
|
|
proId:proId
|
|
|
|
|
|
},
|
|
|
|
|
|
async: false,
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
|
var html = '<option value="">请选择分包</option>';
|
|
|
|
|
|
for (var i = 0; i < data.obj.length; i++) {
|
|
|
|
|
|
html += '<option value="' + data.obj[i].id + '">' + data.obj[i].name + '</option>';
|
|
|
|
|
|
}
|
|
|
|
|
|
$("#subId").html(html);
|
|
|
|
|
|
form.render(); //这里就是我们要渲染的地方了
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取分包名称(甲方)
|
|
|
|
|
|
* */
|
|
|
|
|
|
function getTeam(subId) {
|
|
|
|
|
|
$("#teamId").html("");
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: 'get',
|
|
|
|
|
|
url: ctxPath + '/commonSelect/getSubTeams',
|
|
|
|
|
|
data: {
|
|
|
|
|
|
subId:subId
|
|
|
|
|
|
},
|
|
|
|
|
|
async: false,
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
|
var html = '<option value="">请选择班组</option>';
|
|
|
|
|
|
for (var i = 0; i < data.obj.length; i++) {
|
|
|
|
|
|
html += '<option value="' + data.obj[i].id + '">' + data.obj[i].name + '</option>';
|
|
|
|
|
|
}
|
|
|
|
|
|
$("#teamId").html(html);
|
|
|
|
|
|
form.render(); //这里就是我们要渲染的地方了
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function lumpSum(){
|
|
|
|
|
|
var proId = $("#proId").val();
|
|
|
|
|
|
if(proId == "" || proId == null){
|
|
|
|
|
|
layer.msg('请先选择工程', {icon: 2});
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
localStorage.setItem("lumpSumProId", proId);
|
|
|
|
|
|
localStorage.setItem("lumpSumType", "1");
|
|
|
|
|
|
let index = layer.open({
|
|
|
|
|
|
title: ['选择包干工序及桩位', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|
|
|
|
|
type: 2,
|
|
|
|
|
|
content: 'lumpSum.html',
|
|
|
|
|
|
area: ['90%', '90%'],
|
|
|
|
|
|
maxmin: false,
|
|
|
|
|
|
btn: ['确定','关闭'],
|
|
|
|
|
|
success: function(layero, index){
|
|
|
|
|
|
var myIframe = window[layero.find('iframe')[0]['name']];
|
|
|
|
|
|
var fnc = myIframe.receiveDataFromParent(JSON.stringify(selectedGxListInParent)); //aaa()为子页面的方法
|
|
|
|
|
|
},
|
|
|
|
|
|
yes: function (index, layero) {
|
|
|
|
|
|
// 获取弹出层中的form表单元素
|
|
|
|
|
|
var formSubmit = layer.getChildFrame('form', index);
|
|
|
|
|
|
var submited = formSubmit.find('button')[1];
|
|
|
|
|
|
submited.click();
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 父页面 JS
|
|
|
|
|
|
function receiveDataFromChild(gxList,resultStrings) {
|
|
|
|
|
|
selectedGxListInParent = JSON.parse(gxList); // 更新父页面缓存
|
|
|
|
|
|
console.log('收到子页面数据:', gxList);
|
|
|
|
|
|
console.log('收到子页面数据groupedData:', resultStrings);
|
|
|
|
|
|
const cleaned = JSON.parse(resultStrings).map(item => item.replace(/\s+/g, ''));
|
|
|
|
|
|
// 第二步:处理每一项,生成标准化格式
|
|
|
|
|
|
const formatted = cleaned.map(item => {
|
|
|
|
|
|
// 使用正则提取工序名 和 桩位列表
|
|
|
|
|
|
const nameMatch = item.match(/^([\u4e00-\u9fa5]+)(?:工序)/);
|
|
|
|
|
|
const pileMatch = item.match(/桩位(.*)/);
|
|
|
|
|
|
if (!nameMatch || !pileMatch) return item;
|
|
|
|
|
|
const gxName = nameMatch[1]; // 工序名
|
|
|
|
|
|
let piles = pileMatch[1]; // 桩位字符串
|
|
|
|
|
|
// 去重 + 排序(可选)
|
|
|
|
|
|
const uniquePiles = [...new Set(piles.split(','))].filter(Boolean).join(',');
|
|
|
|
|
|
// 返回标准格式
|
|
|
|
|
|
return `${gxName}工序${uniquePiles}桩位`;
|
|
|
|
|
|
});
|
|
|
|
|
|
if(formatted.length > 0){
|
|
|
|
|
|
$("#gxList").val("1");
|
|
|
|
|
|
}
|
|
|
|
|
|
$("#selectedProcessAndPile").html(formatted.join('<br>'));
|
|
|
|
|
|
gxListArr = formatGxList(gxList);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function formatGxList(gxListStr) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 步骤一:解析 JSON 字符串
|
|
|
|
|
|
const parsed = JSON.parse(gxListStr);
|
|
|
|
|
|
// 步骤二:遍历数组,提取每个对象中的字段并清理空格
|
|
|
|
|
|
return parsed.map(item => ({
|
|
|
|
|
|
gxId: item.gxId.trim(), // 直接取并去空格
|
|
|
|
|
|
gxName: item.gxName.trim(),
|
|
|
|
|
|
gxZw: item.gxZw.trim()
|
|
|
|
|
|
}));
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
console.error("JSON 解析失败", e);
|
|
|
|
|
|
return [];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function generateUUID() {
|
|
|
|
|
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
|
|
|
|
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
|
|
|
|
return v.toString(16);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 生成二维码并写入 input
|
|
|
|
|
|
function generateQrCode(party) {
|
|
|
|
|
|
var uuid = generateUUID(); // 生成唯一 UUID
|
|
|
|
|
|
// var inputId = party + "Image";
|
|
|
|
|
|
var inputId = party + "ImageUuid";
|
|
|
|
|
|
var qrCodeContainerId = party + "QrCodeContainer";
|
|
|
|
|
|
|
|
|
|
|
|
console.log("uuid: " + uuid)
|
|
|
|
|
|
$("#" + inputId).val(uuid); // 填充 input 框
|
|
|
|
|
|
|
|
|
|
|
|
// 发送请求到后台生成二维码
|
|
|
|
|
|
var formUrl = ctxPath + "/teamSmallBagDryTreaty/addQrCode";
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: 'POST',
|
|
|
|
|
|
url: formUrl,
|
|
|
|
|
|
contentType: "application/json; charset=utf-8", // 设置为 JSON 类型
|
|
|
|
|
|
dataType: "json",
|
|
|
|
|
|
data: JSON.stringify({ uuid: uuid }), // 转为 JSON 字符串
|
|
|
|
|
|
success: function (res) {
|
|
|
|
|
|
if (res.res !=1 ) {
|
|
|
|
|
|
layer.msg("生成二维码失败", { icon: 2 });
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 创建弹窗容器
|
|
|
|
|
|
let $content = $('<div>', {
|
|
|
|
|
|
style: 'text-align:center; padding:10px;'
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
let $imgContainer = $('<div>').attr('id', qrCodeContainerId);
|
|
|
|
|
|
$content.append($imgContainer);
|
|
|
|
|
|
|
|
|
|
|
|
// 显示弹窗
|
|
|
|
|
|
let index = layer.open({
|
|
|
|
|
|
type: 1,
|
|
|
|
|
|
title: '电子签名二维码',
|
|
|
|
|
|
area: ['200px', '250px'],
|
|
|
|
|
|
content: $content[0].outerHTML, // 转为字符串插入弹窗
|
|
|
|
|
|
success: function () {
|
|
|
|
|
|
// 弹窗打开后执行生成二维码
|
|
|
|
|
|
QRCode.toCanvas(uuid, {
|
|
|
|
|
|
errorCorrectionLevel: 'H',
|
|
|
|
|
|
width: 180
|
|
|
|
|
|
}, function (error, canvas) {
|
|
|
|
|
|
if (error) {
|
|
|
|
|
|
layer.msg("生成二维码失败", { icon: 2 });
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 插入二维码到弹窗中
|
|
|
|
|
|
$("#" + qrCodeContainerId).html(canvas);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
error: function (xhr, status, error) {
|
|
|
|
|
|
layer.msg('数据请求异常,请稍后重试', { icon: 2 });
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function updateSignature(party) {
|
|
|
|
|
|
var uuid = $("#" + party + "ImageUuid").val();
|
|
|
|
|
|
// var uuid ="565456546";
|
|
|
|
|
|
if (!uuid) {
|
|
|
|
|
|
layer.msg("请先生成二维码", { icon: 2 });
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 调用接口获取图片 URL
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
url: ctxPath + "/teamSmallBagDryTreaty/getSignPhoto",
|
|
|
|
|
|
type: "GET",
|
|
|
|
|
|
data: { uuid: uuid },
|
|
|
|
|
|
success: function (res) {
|
|
|
|
|
|
if (res.res !=1 ) {
|
|
|
|
|
|
layer.msg(res.resMsg || "获取图片失败", { icon: 2 });
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!res.obj.signPath){
|
|
|
|
|
|
layer.msg("请先完成签名", { icon: 2 });
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 填入 input 框
|
|
|
|
|
|
var imageUrl = dataPath + "/" + res.obj.signPath;
|
|
|
|
|
|
// $("#" + party + "Image").val( imageUrl );
|
|
|
|
|
|
// 设置隐藏字段,用于表单提交
|
|
|
|
|
|
$("#" + party + "ImagePath").val(res.obj.signPath); // ✅ 存储图片路径
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置图片预览
|
|
|
|
|
|
var previewContainer = $("#" + party + "ImagePreview");
|
|
|
|
|
|
previewContainer.html('<img src="' + imageUrl + '" style="max-width: 200px; max-height: 200px; border: 1px solid #ccc;">');
|
|
|
|
|
|
|
|
|
|
|
|
layer.msg("更新成功", { icon: 1 });
|
|
|
|
|
|
},
|
|
|
|
|
|
error: function () {
|
|
|
|
|
|
layer.msg("请求失败,请稍后重试", { icon: 2 });
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 小写金额转中文大写金额
|
|
|
|
|
|
function toChineseNumber(num) {
|
|
|
|
|
|
var AA = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"];
|
|
|
|
|
|
var BB = ["", "拾", "佰", "仟", "万", "亿", "", "", "点", ""];
|
|
|
|
|
|
|
|
|
|
|
|
var str = (num + "").replace(/(^0*)/g, ""); // 去除前导0
|
|
|
|
|
|
var integerPart = str.split(".")[0] || "0";
|
|
|
|
|
|
var decimalPart = str.split(".")[1];
|
|
|
|
|
|
|
|
|
|
|
|
var result = "";
|
|
|
|
|
|
|
|
|
|
|
|
// 处理整数部分
|
|
|
|
|
|
for (var i = 0; i < integerPart.length; i++) {
|
|
|
|
|
|
var digit = integerPart.charAt(i);
|
|
|
|
|
|
var pos = integerPart.length - i - 1;
|
|
|
|
|
|
|
|
|
|
|
|
result += AA[digit];
|
|
|
|
|
|
|
|
|
|
|
|
if (digit !== "0") {
|
|
|
|
|
|
switch (pos % 4) {
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
result += "拾"; break;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
result += "佰"; break;
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
result += "仟"; break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (pos === 4 || pos === 8) {
|
|
|
|
|
|
result += "万";
|
|
|
|
|
|
} else if (pos === 5 || pos === 9) {
|
|
|
|
|
|
result += "亿";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 每四位一组,处理完千位之后要处理是否补零
|
|
|
|
|
|
if (pos % 4 === 0 && i < integerPart.length - 1 && integerPart.charAt(i + 1) !== "0") {
|
|
|
|
|
|
result += "零";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 去掉多余的“零”和开头的“一十”
|
|
|
|
|
|
result = result.replace(/零+/g, '零').replace(/^一十/, '十');
|
|
|
|
|
|
|
|
|
|
|
|
// 处理小数部分
|
|
|
|
|
|
if (decimalPart) {
|
|
|
|
|
|
result += "点";
|
|
|
|
|
|
|
|
|
|
|
|
// 最多取两位小数
|
|
|
|
|
|
if (decimalPart.length >= 1) {
|
|
|
|
|
|
result += AA[decimalPart.charAt(0)];
|
|
|
|
|
|
}
|
|
|
|
|
|
if (decimalPart.length >= 2) {
|
|
|
|
|
|
result += AA[decimalPart.charAt(1)];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result + "元";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function reloading() {
|
|
|
|
|
|
var index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
|
|
|
|
|
|
parent.layer.close(index); //再执行关闭
|
|
|
|
|
|
// window.parent.location.reload();
|
|
|
|
|
|
|
|
|
|
|
|
if (parent && typeof parent.reloading === 'function') {
|
|
|
|
|
|
parent.reloading(); // 假设父页面定义了 reloadData 函数
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function cancel(){
|
|
|
|
|
|
var index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
|
|
|
|
|
|
parent.layer.close(index); //再执行关闭
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function nextStep() {
|
|
|
|
|
|
var startTime = $("#planStartTime").val();
|
|
|
|
|
|
var endTime = $("#planEndTime").val();
|
|
|
|
|
|
|
|
|
|
|
|
var partyaImagePath = $("#partyaImagePath").val();
|
|
|
|
|
|
var partybImagePath = $("#partybImagePath").val();
|
|
|
|
|
|
if(!partyaImagePath){
|
|
|
|
|
|
layer.msg("请先完成甲方签名", { icon: 2 });
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!partybImagePath){
|
|
|
|
|
|
layer.msg("请先完成乙方签名", { icon: 2 });
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (startTime && endTime && startTime > endTime) {
|
|
|
|
|
|
layer.msg("开始时间不能大于结束时间", { icon: 2 });
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 获取表单数据
|
|
|
|
|
|
const formData = {
|
|
|
|
|
|
agreementNumber: $("#agreementNumber").val(),
|
|
|
|
|
|
proId: $("#proId").val(),
|
|
|
|
|
|
proName: $("#proId option:selected").text(),
|
|
|
|
|
|
abbreviation: $("#proId option:selected").attr("data-abbreviation"),
|
|
|
|
|
|
subId: $("#subId").val(),
|
|
|
|
|
|
subName: $("#subId option:selected").text(),
|
|
|
|
|
|
teamId: $("#teamId").val(),
|
|
|
|
|
|
teamName: $("#teamId option:selected").text(),
|
|
|
|
|
|
partyUser: $("#partyUser").val(),
|
|
|
|
|
|
contractDate: $("#contractDate").val(),
|
|
|
|
|
|
contractLocation: $("#contractLocation").val(),
|
|
|
|
|
|
proLocation: $("#proLocation").val(),
|
|
|
|
|
|
proScale: $("#proScale").val(),
|
|
|
|
|
|
contractMoney: $("#contractMoney").val(),
|
|
|
|
|
|
contractMoneyMax: toChineseNumber($("#contractMoney").val()), // 转换为大写金额
|
|
|
|
|
|
partyaImage: $("#partyaImagePath").val(),
|
|
|
|
|
|
partybImage: $("#partybImagePath").val(),
|
|
|
|
|
|
planStartTime: $("#planStartTime").val(),
|
|
|
|
|
|
planEndTime: $("#planEndTime").val(),
|
|
|
|
|
|
gxList: gxListArr || [], // 工序列表
|
|
|
|
|
|
selectedProcessAndPile:$("#selectedProcessAndPile").html(),
|
|
|
|
|
|
gxInfo:$("#gxInfo").val()
|
|
|
|
|
|
};
|
|
|
|
|
|
// 存储到 localStorage 用于预览页读取
|
|
|
|
|
|
localStorage.setItem("contractPreviewData", JSON.stringify(formData));
|
|
|
|
|
|
// 打开预览页面
|
|
|
|
|
|
layer.open({
|
|
|
|
|
|
title: '合同预览',
|
|
|
|
|
|
type: 2,
|
|
|
|
|
|
content: 'teamPackageManageContractPreview.html',
|
|
|
|
|
|
area: ['95%', '95%'],
|
|
|
|
|
|
maxmin: true,
|
|
|
|
|
|
btn: ['确认', '返回'],
|
|
|
|
|
|
// yes: function (index, layero) {
|
|
|
|
|
|
// // 在预览页点击“确认”时触发提交
|
|
|
|
|
|
// const iframeWindow = layer.getChildFrame(index);
|
|
|
|
|
|
// if (iframeWindow && iframeWindow.submitPreviewForm) {
|
|
|
|
|
|
// alert(1)
|
|
|
|
|
|
// iframeWindow.submitPreviewForm(); // 调用预览页的方法提交数据
|
|
|
|
|
|
// }
|
|
|
|
|
|
// },
|
|
|
|
|
|
yes: function (index, layero) {
|
|
|
|
|
|
// 获取弹出层中的form表单元素
|
|
|
|
|
|
var formSubmit = layer.getChildFrame('form', index);
|
|
|
|
|
|
var submited = formSubmit.find('button')[0];
|
|
|
|
|
|
submited.click();
|
|
|
|
|
|
// example.ajax.reload(); // 刷新页面
|
|
|
|
|
|
},
|
|
|
|
|
|
btn2: function () {
|
|
|
|
|
|
// 返回编辑页
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|