|
@@ -1,14 +1,18 @@
|
|
|
(function () {
|
|
|
+ var addDataThat = null;
|
|
|
let isTimes = []
|
|
|
let viewState = z.ui.comm.getUrlParam("_o");
|
|
|
let read = z.ui.comm.getUrlParam("read");
|
|
|
let finance = z.ui.comm.getUrlParam("finance");
|
|
|
let detailProjectIndex = 0;
|
|
|
+ let previousAmount = z.ui.input("[name='createReqVO$totalAmount']").getValue;
|
|
|
let costTypeJSON = JSON.parse(document.querySelector('#costTypeJSON').value)
|
|
|
window.onload = function (ex) {
|
|
|
let timeObject = document.querySelector('#detailList')
|
|
|
let arrays = JSON.parse(timeObject.value)
|
|
|
+ addDataThat = $("#addData")
|
|
|
$("#addData").click(function () {
|
|
|
+ addDataThat.attr('disabled', "true");
|
|
|
let obj = {
|
|
|
amount: "",
|
|
|
bz1: "",
|
|
@@ -28,7 +32,6 @@
|
|
|
isTimes.push(obj)
|
|
|
generateTableTrHtml(isTimes.length - 1)
|
|
|
buildQjsjSeq();
|
|
|
- detailTotalInit()
|
|
|
})
|
|
|
$("#selectProject").click(function () {
|
|
|
selectProjectAll(null, setProject);
|
|
@@ -56,128 +59,11 @@
|
|
|
}
|
|
|
isTimes.push(obj)
|
|
|
}
|
|
|
- updateView()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- function updateView() {
|
|
|
- let tbodyQjsq = document.querySelector('.tbodyQjsq')
|
|
|
- let html = ''
|
|
|
- for (let i = 0; i < isTimes.length; i++) {
|
|
|
- html += '<tr class="qjsjClass" id="qjsj_' + i + '" style="background:#fff">'
|
|
|
- + '<td name="qjsj_seq">' + (i + 1) + '</td>'
|
|
|
- + '<td>'
|
|
|
- + '<div class="form-flex">'
|
|
|
- + '<div class="form-item" style="width: 100%;margin-right: 5px;">'
|
|
|
- + '<input type="hidden" name="CommonCostDetailDO[' + i + ']$projectId" value="">'
|
|
|
- + '<div class="z-comp-input z-readonly" id="selectProject_' + i + '" name="CommonCostDetailDO[' + i + ']$projectName">'
|
|
|
- + '<input readonly type="text" value="">'
|
|
|
- + '</div>'
|
|
|
- + '</div>'
|
|
|
- + '</div>'
|
|
|
- + '</td>'
|
|
|
- + '<td>'
|
|
|
- + '<div class="form-item">'
|
|
|
- + '<div class="z-comp-input z-readonly" name="CommonCostDetailDO[' + i + ']$xmzrbm">'
|
|
|
- + '<input readonly type="text" value="">'
|
|
|
- + '</div>'
|
|
|
- + '</div>'
|
|
|
- + '</td>'
|
|
|
- + '<td>'
|
|
|
- + '<div class="form-flex">'
|
|
|
- + '<div class="form-item" style="width: 100%;margin-right: 5px;">'
|
|
|
- + '<div class="z-comp-date" name="CommonCostDetailDO[' + i + ']$costDate">'
|
|
|
- + '<input type="text" value="' + isTimes[i].costDate + '">'
|
|
|
- + '</div>'
|
|
|
- + '</div>'
|
|
|
- + '</div>'
|
|
|
- + '</td>'
|
|
|
- + '<td>'
|
|
|
- + '<div class="form-flex">'
|
|
|
- + '<div class="form-item" style="width: 100%;margin-right: 5px;">'
|
|
|
- + '<div class="z-comp-selecttree" name="costType[' + i + ']">'
|
|
|
- + '<input type="hidden" name="CommonCostDetailDO[' + i + ']$costType">'
|
|
|
- + '<div class="z-inputselect-bar">'
|
|
|
- + '<span></span><i></i>'
|
|
|
- + '</div>'
|
|
|
- + '</div>'
|
|
|
- + '</div>'
|
|
|
- + '</div>'
|
|
|
- + '</td>'
|
|
|
- + '<td>'
|
|
|
- + '<div class="form-item">'
|
|
|
- + '<div class="z-comp-input" name="CommonCostDetailDO[' + i + ']$costContent">'
|
|
|
- + '<input type="text" value="' + isTimes[i].costContent + '">'
|
|
|
- + '</div>'
|
|
|
- + '</div>'
|
|
|
- + '</td>'
|
|
|
- + '<td>'
|
|
|
- + '<div class="form-item">'
|
|
|
- + '<div class="z-comp-input" name="CommonCostDetailDO[' + i + ']$invoiceNums">'
|
|
|
- + '<input type="number" value="' + isTimes[i].invoiceNums + '">'
|
|
|
- + '</div>'
|
|
|
- + '</div>'
|
|
|
- + '</td>'
|
|
|
- + '<td>'
|
|
|
- + '<div class="form-item">'
|
|
|
- + '<div class="z-comp-input" name="CommonCostDetailDO[' + i + ']$amount">'
|
|
|
- + '<input type="number" value="' + isTimes[i].amount + '">'
|
|
|
- + '</div>'
|
|
|
- + '</div>'
|
|
|
- + '</td>'
|
|
|
- + '<td>'
|
|
|
- + '<div class="form-item">'
|
|
|
- + '<div class="z-comp-input" name="CommonCostDetailDO[' + i + ']$bz1">'
|
|
|
- + '<input type="text" value="' + isTimes[i].bz1 + '">'
|
|
|
- + '</div>'
|
|
|
- + '</div>'
|
|
|
- + '</td>'
|
|
|
- + '<td>'
|
|
|
- + '<div id="delBtn_' + (i) + '" class="table-btn delBtn_' + (i) + '" data-index="' + (i) + '">'
|
|
|
- + '<span>删除</span>'
|
|
|
- + '</div>'
|
|
|
- + '</td></tr>';
|
|
|
- }
|
|
|
- tbodyQjsq.innerHTML = html
|
|
|
- for (let i = 0; i < isTimes.length; i++) {
|
|
|
- costTypeJSON.forEach(obj => {
|
|
|
- obj.treeName = 'CommonCostDetailDO[' + i + ']$costType';
|
|
|
- })
|
|
|
- selecttree("[name='costType[" + i + "]']", costTypeJSON, clickCostType, allowChildClick)
|
|
|
- z.ui.date("[name='CommonCostDetailDO[" + i + "]$costDate']").init()
|
|
|
- z.ui.selecttree("[name='costType[" + i + "]']").setValue(isTimes[i].costType)
|
|
|
- $("[name='CommonCostDetailDO[" + i + "]$costType']").val(isTimes[i].costType);
|
|
|
- $("[name='CommonCostDetailDO[" + i + "]$projectId']").val(isTimes[i].projectId);
|
|
|
- z.ui.input("[name='CommonCostDetailDO[" + i + "]$projectName']").setValue(isTimes[i].projectName);
|
|
|
- z.ui.input("[name='CommonCostDetailDO[" + i + "]$xmzrbm']").setValue(isTimes[i].projectDeptName);
|
|
|
- $("#selectProject_" + i).click(function () {
|
|
|
- detailProjectIndex = i;
|
|
|
- selectProjectAll(null, setProject);
|
|
|
- })
|
|
|
- $("#delBtn_" + i).click(function () {
|
|
|
- z.ui.confirm("compid").init({
|
|
|
- content: "确定删除吗?",
|
|
|
- onConfirm: function () {
|
|
|
- var element = document.getElementById("qjsj_" + i);
|
|
|
- element.remove();
|
|
|
- buildQjsjSeq();
|
|
|
- isTimes = isTimes.splice(i, 1)
|
|
|
- updateView()
|
|
|
- jeSumInit(i)
|
|
|
- },
|
|
|
- onCancel: function () {
|
|
|
-
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- })
|
|
|
- if (viewState === 'v' || read === '1') {
|
|
|
- detailReadonly(i)
|
|
|
+ for (let i = 0; i < isTimes.length; i++) {
|
|
|
+ generateTableTrHtml(i);
|
|
|
}
|
|
|
}
|
|
|
- detailTotalInit()
|
|
|
}
|
|
|
-
|
|
|
function generateTableTrHtml(i) {
|
|
|
var trDom = document.createElement("tr");
|
|
|
trDom.style.backgroundColor = "#fff";
|
|
@@ -251,6 +137,9 @@
|
|
|
+ '</div>'
|
|
|
+ '</td>'
|
|
|
+ '<td>'
|
|
|
+ + '<div id="editBtn_' + (i) + '" class="table-btn editBtn_' + (i) + '" data-index="' + (i) + '">'
|
|
|
+ + '<span>保存</span>'
|
|
|
+ + '</div>'
|
|
|
+ '<div id="delBtn_' + (i) + '" class="table-btn delBtn_' + (i) + '" data-index="' + (i) + '">'
|
|
|
+ '<span>删除</span>'
|
|
|
+ '</div>'
|
|
@@ -263,9 +152,61 @@
|
|
|
})
|
|
|
selecttree("[name='costType[" + i + "]']", costTypeJSON, clickCostType, allowChildClick)
|
|
|
z.ui.date("[name='CommonCostDetailDO[" + i + "]$costDate']").init()
|
|
|
+ if (!(!isTimes[i].costType || isTimes[i].costType.trim() === '')) {
|
|
|
+ z.ui.selecttree("[name='costType[" + i + "]']").setValue(isTimes[i].costType)
|
|
|
+ $("[name='CommonCostDetailDO[" + i + "]$costType']").val(isTimes[i].costType);
|
|
|
+ }
|
|
|
+ if (!(!isTimes[i].projectId || isTimes[i].projectId.trim() === '')) {
|
|
|
+ $("[name='CommonCostDetailDO[" + i + "]$projectId']").val(isTimes[i].projectId);
|
|
|
+ }
|
|
|
+ if (!(!isTimes[i].projectName || isTimes[i].projectName.trim() === '')) {
|
|
|
+ z.ui.input("[name='CommonCostDetailDO[" + i + "]$projectName']").setValue(isTimes[i].projectName);
|
|
|
+ }
|
|
|
+ if (!(!isTimes[i].projectDeptName || isTimes[i].projectDeptName.trim() === '')) {
|
|
|
+ z.ui.input("[name='CommonCostDetailDO[" + i + "]$xmzrbm']").setValue(isTimes[i].projectDeptName);
|
|
|
+ }
|
|
|
+ if (!(!isTimes[i].costDate || isTimes[i].costDate.trim() === '')) {
|
|
|
+ z.ui.date("[name='CommonCostDetailDO[" + i + "]$costDate']").setValue(isTimes[i].costDate);
|
|
|
+ }
|
|
|
+ if (!(!isTimes[i].costContent || isTimes[i].costContent.trim() === '')) {
|
|
|
+ z.ui.input("[name='CommonCostDetailDO[" + i + "]$costContent']").setValue(isTimes[i].costContent);
|
|
|
+ }
|
|
|
+ if (isTimes[i].invoiceNums != '') {
|
|
|
+ z.ui.input("[name='CommonCostDetailDO[" + i + "]$invoiceNums']").setValue(isTimes[i].invoiceNums);
|
|
|
+ }
|
|
|
+ if (isTimes[i].amount != '') {
|
|
|
+ z.ui.input("[name='CommonCostDetailDO[" + i + "]$amount']").setValue(isTimes[i].amount);
|
|
|
+ }
|
|
|
+ if (!(!isTimes[i].bz1 || isTimes[i].bz1.trim() === '')) {
|
|
|
+ z.ui.input("[name='CommonCostDetailDO[" + i + "]$remark']").setValue(isTimes[i].bz1);
|
|
|
+ }
|
|
|
+ if (!(!isTimes[i].commonCostId || isTimes[i].commonCostId.trim() === '')) {
|
|
|
+ $("#editBtn_" + i).find("span").html("编辑")
|
|
|
+ detailReadonly(i, false)
|
|
|
+ $("#qjsj_" + i).addClass("form-table-disable")
|
|
|
+ }
|
|
|
$("#selectProject_" + i).click(function () {
|
|
|
detailProjectIndex = i;
|
|
|
- selectProjectAll(null, setProject);
|
|
|
+ selectProject(null, setProject);
|
|
|
+ })
|
|
|
+ detailTotalInit(i)
|
|
|
+ $("#editBtn_" + i).click(function () {
|
|
|
+ const span = $(this).find("span");
|
|
|
+ const html = span.html();
|
|
|
+ if (html === '编辑') {
|
|
|
+ span.html('保存')
|
|
|
+ detailWrite(i);
|
|
|
+ addDataThat.attr('disabled', "true");
|
|
|
+ $("#qjsj_" + i).removeClass("form-table-disable")
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (html === '保存') {
|
|
|
+ span.html('编辑')
|
|
|
+ detailReadonly(i, false)
|
|
|
+ addDataThat.removeAttr('disabled')
|
|
|
+ $("#qjsj_" + i).addClass("form-table-disable")
|
|
|
+ return;
|
|
|
+ }
|
|
|
})
|
|
|
$("#delBtn_" + i).click(function () {
|
|
|
z.ui.confirm("compid").init({
|
|
@@ -275,7 +216,8 @@
|
|
|
element.remove();
|
|
|
buildQjsjSeq();
|
|
|
isTimes = isTimes.splice(i, 1)
|
|
|
- jeSumInit(i)
|
|
|
+ jeSumInit(i);
|
|
|
+ addDataThat.removeAttr('disabled')
|
|
|
},
|
|
|
onCancel: function () {
|
|
|
|
|
@@ -283,14 +225,16 @@
|
|
|
})
|
|
|
|
|
|
})
|
|
|
+ if ((viewState === 'v' || read === '1') && finance != '1') {
|
|
|
+ detailReadonly(i)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- function detailReadonly(i) {
|
|
|
- //财务审核时可以核减修改金额
|
|
|
- if (finance === 1) {
|
|
|
- //如果单据金额发生修改就代表核减了
|
|
|
+ function detailReadonly(i, isBool = true) {
|
|
|
+ if (isBool) {
|
|
|
+ $("#delBtn_" + i).css("display", "none");
|
|
|
+ $("#editBtn_" + i).css("display", "none");
|
|
|
}
|
|
|
- $("#delBtn_" + i).css("display", "none");
|
|
|
$("[name='costType[" + i + "]']").addClass("z-readonly");
|
|
|
$("#selectProject_" + i).css("pointer-events", "none");
|
|
|
$("[name='costType[" + i + "]']").css("pointer-events", "none");
|
|
@@ -302,7 +246,21 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function detailTotalInit() {
|
|
|
+
|
|
|
+ function detailWrite(i) {
|
|
|
+ //财务审核时可以核减修改金额
|
|
|
+ $("[name='costType[" + i + "]']").removeClass("z-readonly");
|
|
|
+ $("#selectProject_" + i).css("pointer-events", "auto");
|
|
|
+ $("[name='costType[" + i + "]']").css("pointer-events", "auto");
|
|
|
+ let detailElement = document.getElementById("qjsj_" + i);
|
|
|
+ let detailInput = detailElement.getElementsByTagName("input");
|
|
|
+ for (let j = 0; j < detailInput.length; j++) {
|
|
|
+ detailInput[j].disabled = false;
|
|
|
+ $(detailInput[j]).removeClass("z-readonly")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function detailTotalInit(i) {
|
|
|
let obj = {
|
|
|
amount: "",
|
|
|
bz1: "",
|
|
@@ -318,31 +276,29 @@
|
|
|
projectName: "",
|
|
|
projectDeptName: ""
|
|
|
}
|
|
|
- for (let i = 0; i < isTimes.length; i++) {
|
|
|
- let inpsJe = $("[name='CommonCostDetailDO[" + i + "]$amount']")[0].children[0]; //金额
|
|
|
- let inpsPj = $("[name='CommonCostDetailDO[" + i + "]$invoiceNums']")[0].children[0];//单据张数
|
|
|
- inpsJe.addEventListener("blur", e => {
|
|
|
- let event = e || window.event;
|
|
|
- let inputInfo = event.target.value;
|
|
|
- if (!(inputInfo > 0)) {
|
|
|
- z.ui.alertWarning(`金额不能为负数、0`)
|
|
|
- inpsJe.value = ''
|
|
|
- } else {
|
|
|
- obj.amount = inputInfo
|
|
|
- jeSumInit()
|
|
|
- }
|
|
|
- });
|
|
|
- inpsPj.addEventListener("blur", e => {
|
|
|
- let event = e || window.event;
|
|
|
- let inputInfo = event.target.value;
|
|
|
- if (!(inputInfo > 0) || (String(inputInfo).indexOf('.') > -1)) {
|
|
|
- z.ui.alertWarning(`单据张数不能为负数、0、小数`)
|
|
|
- inpsPj.value = ''
|
|
|
- } else {
|
|
|
- obj.invoiceNums = inputInfo
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ let inpsJe = $("[name='CommonCostDetailDO[" + i + "]$amount']")[0].children[0]; //金额
|
|
|
+ let inpsPj = $("[name='CommonCostDetailDO[" + i + "]$invoiceNums']")[0].children[0];//单据张数
|
|
|
+ inpsJe.addEventListener("blur", e => {
|
|
|
+ let event = e || window.event;
|
|
|
+ let inputInfo = event.target.value;
|
|
|
+ if (!(inputInfo > 0)) {
|
|
|
+ z.ui.alertWarning(`金额不能为负数、0`)
|
|
|
+ inpsJe.value = ''
|
|
|
+ } else {
|
|
|
+ obj.amount = inputInfo
|
|
|
+ jeSumInit()
|
|
|
+ }
|
|
|
+ });
|
|
|
+ inpsPj.addEventListener("blur", e => {
|
|
|
+ let event = e || window.event;
|
|
|
+ let inputInfo = event.target.value;
|
|
|
+ if (!(inputInfo > 0) || (String(inputInfo).indexOf('.') > -1)) {
|
|
|
+ z.ui.alertWarning(`单据张数不能为负数、0、小数`)
|
|
|
+ inpsPj.value = ''
|
|
|
+ } else {
|
|
|
+ obj.invoiceNums = inputInfo
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
function jeSumInit(idx) {
|
|
@@ -362,13 +318,6 @@
|
|
|
|
|
|
//注册业务保存事件
|
|
|
function bindEvents() {
|
|
|
- let glcglist = window.glcglist;
|
|
|
- var list = JSON.parse(glcglist)
|
|
|
- var html="";
|
|
|
- for(var i=0;i<list.length;i++){
|
|
|
- html +="<a onclick=goAsset('"+list[i].instanceId+"')>"+list[i].userNickname+"("+list[i].createTime.substring(0,10)+")</a>";
|
|
|
- }
|
|
|
- $("#glcghtml").html(html);
|
|
|
z.workflow.saveBtn.addListener("onSaveClick", saveForm);
|
|
|
}
|
|
|
|
|
@@ -387,7 +336,7 @@
|
|
|
function saveForm(all, istransfer) {
|
|
|
var postData = z.ui.form.getFormFields($("[name=createReqVO]"));
|
|
|
if (postData === false) {
|
|
|
- all({ success: false });
|
|
|
+ all({success: false});
|
|
|
return;
|
|
|
}
|
|
|
postData.createReqVO.instanceId = z.ui.comm.getUrlParam("flowInstanceId");
|
|
@@ -399,6 +348,11 @@
|
|
|
detailList.push(z.ui.form.childStringify(mealName));
|
|
|
}
|
|
|
}
|
|
|
+ //发生金额变化
|
|
|
+ if(Number(postData.createReqVO.amount) != Number(previousAmount)){
|
|
|
+ let num = Number(previousAmount) - Number(postData.createReqVO.amount);
|
|
|
+ postData.createReqVO.bz3 = '发生了核减:'+'核减'+num+'(元)';
|
|
|
+ }
|
|
|
postData.createReqVO.detailList = detailList;
|
|
|
z.ui.ajax({
|
|
|
type: "post",
|