|
@@ -0,0 +1,721 @@
|
|
|
+(function () {
|
|
|
+ let viewState = z.ui.comm.getUrlParam("_o");
|
|
|
+ let read = z.ui.comm.getUrlParam("read");
|
|
|
+ let finance = z.ui.comm.getUrlParam("finance");
|
|
|
+ let boatCarArr = [];
|
|
|
+ let otherArr = [];
|
|
|
+ let subsidyAmount = 0;
|
|
|
+ window.onload = function (ex) {
|
|
|
+ z.ui.laydate("[name='createReqVO$startTime']").init({
|
|
|
+ type: 'date',
|
|
|
+ maxlink: "[name='createReqVO$endTime']",
|
|
|
+ format: 'yyyy-MM-dd',
|
|
|
+ done: function (value, date, endDate) {
|
|
|
+ let endTime = z.ui.laydate("[name='createReqVO$endTime']").getValue();
|
|
|
+ if (value && endTime) {
|
|
|
+ getWorkDays(value, endTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ z.ui.laydate("[name='createReqVO$endTime']").init({
|
|
|
+ type: 'date',
|
|
|
+ minlink: "[name='createReqVO$startTime']",
|
|
|
+ format: 'yyyy-MM-dd',
|
|
|
+ done: function (value, date, endDate) {
|
|
|
+ let startTime = z.ui.laydate("[name='createReqVO$startTime']").getValue();
|
|
|
+ if (value && startTime) {
|
|
|
+ getWorkDays(startTime, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ subsidyAmount = z.ui.input("[name='createReqVO$subsidyAmount']").getValue();
|
|
|
+ boatCarView();
|
|
|
+ otherView();
|
|
|
+ $("#addBoatCar").click(function () {
|
|
|
+ let boatCarObj = {
|
|
|
+ id: "",
|
|
|
+ travelCostId: "",
|
|
|
+ departDate: "",
|
|
|
+ departPlace: "",
|
|
|
+ arriveDate: "",
|
|
|
+ arrivePlace: "",
|
|
|
+ invoiceNums: "",
|
|
|
+ amount: "",
|
|
|
+ remark: "",
|
|
|
+ vehicle: ""
|
|
|
+ }
|
|
|
+ boatCarArr.push(boatCarObj);
|
|
|
+ generateBoatCarTableTrHtml(boatCarArr.length - 1)
|
|
|
+ })
|
|
|
+ $("#addOther").click(function () {
|
|
|
+ let otherObj = {
|
|
|
+ id: "",
|
|
|
+ travelCostId: "",
|
|
|
+ costDate: "",
|
|
|
+ costType: "",
|
|
|
+ costPlace: "",
|
|
|
+ invoiceNums: "",
|
|
|
+ amount: "",
|
|
|
+ remark: ""
|
|
|
+ }
|
|
|
+ otherArr.push(otherObj);
|
|
|
+ generateOtherTableTrHtml(otherArr.length - 1)
|
|
|
+ })
|
|
|
+ $("#selectProject").click(function () {
|
|
|
+ selectProject(null, setProject);
|
|
|
+ })
|
|
|
+ initCompany();
|
|
|
+ bindEvents();
|
|
|
+ }
|
|
|
+
|
|
|
+ function boatCarView() {
|
|
|
+ let boatCars = JSON.parse(document.querySelector('#boatCarList').value)
|
|
|
+ //根据返回的json对象渲染
|
|
|
+ if (boatCars.length > 0) {
|
|
|
+ for (let i = 0; i < boatCars.length; i++) {
|
|
|
+ let obj = {
|
|
|
+ id: boatCars[i].id || '',
|
|
|
+ travelCostId: boatCars[i].travelCostId || '',
|
|
|
+ departDate: boatCars[i].departDate || '',
|
|
|
+ departPlace: boatCars[i].departPlace || '',
|
|
|
+ arriveDate: boatCars[i].arriveDate || '',
|
|
|
+ arrivePlace: boatCars[i].arrivePlace || '',
|
|
|
+ invoiceNums: boatCars[i].invoiceNums || '',
|
|
|
+ amount: boatCars[i].amount || '',
|
|
|
+ remark: boatCars[i].remark || '',
|
|
|
+ vehicle: boatCars[i].vehicle || ''
|
|
|
+ }
|
|
|
+ boatCarArr.push(obj)
|
|
|
+ }
|
|
|
+ for (let i = 0; i < boatCarArr.length; i++) {
|
|
|
+ generateBoatCarTableTrHtml(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function otherView() {
|
|
|
+ let others = JSON.parse(document.querySelector('#otherList').value)
|
|
|
+ //根据返回的json对象渲染
|
|
|
+ if (others.length > 0) {
|
|
|
+ for (let i = 0; i < others.length; i++) {
|
|
|
+ let obj = {
|
|
|
+ id: others[i].id || '',
|
|
|
+ travelCostId: others[i].travelCostId || '',
|
|
|
+ costDate: others[i].costDate || '',
|
|
|
+ costType: others[i].costType || '',
|
|
|
+ costPlace: others[i].costPlace || '',
|
|
|
+ costDate: others[i].costDate || '',
|
|
|
+ invoiceNums: others[i].invoiceNums || '',
|
|
|
+ amount: others[i].amount || '',
|
|
|
+ remark: others[i].remark || ''
|
|
|
+ }
|
|
|
+ otherArr.push(obj)
|
|
|
+ }
|
|
|
+ for (let i = 0; i < otherArr.length; i++) {
|
|
|
+ generateOtherTableTrHtml(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function getWorkDays(start, end) {
|
|
|
+ z.ui.ajax({
|
|
|
+ url: '/common/workday-list?dateDay%5B0%5D=' + start + '%2000%3A00%3A00&dateDay%5B1%5D=' + end + '%2023%3A59%3A59',
|
|
|
+ type: 'get',
|
|
|
+ success: function (result) {
|
|
|
+ if (result) {
|
|
|
+ travelDays = result.data.length
|
|
|
+ getSubsidy(result.data)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function generateBoatCarTableTrHtml(i) {
|
|
|
+ let vehicleTypeJSON = document.querySelector('#vehicleTypeJSON').value
|
|
|
+ var trDom = document.createElement("tr");
|
|
|
+ trDom.style.backgroundColor = "#fff";
|
|
|
+ trDom.id = "boat_car_" + i;
|
|
|
+ trDom.className = 'qjsjClass'
|
|
|
+ trDom.innerHTML = '<td name="boat_car_seq">' + (i + 1) + '</td>'
|
|
|
+ + '<td>'
|
|
|
+ + '<div class="form-flex">'
|
|
|
+ + '<div class="form-item" style="width: 100%;margin-right: 5px;">'
|
|
|
+ + '<div class="z-comp-date " name="TravelCostBoatCarDO[' + i + ']$departDate">'
|
|
|
+ + '<input type="text" value="">'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</td>'
|
|
|
+ + '<td>'
|
|
|
+ + '<div class="form-item">'
|
|
|
+ + '<div class="z-comp-input " name="TravelCostBoatCarDO[' + i + ']$departPlace">'
|
|
|
+ + '<input 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="TravelCostBoatCarDO[' + i + ']$arriveDate">'
|
|
|
+ + '<input type="text" value="">'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</td>'
|
|
|
+ + '<td>'
|
|
|
+ + '<div class="form-item">'
|
|
|
+ + '<div class="z-comp-input " name="TravelCostBoatCarDO[' + i + ']$arrivePlace">'
|
|
|
+ + '<input type="text" value="">'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</td>'
|
|
|
+ + '<td>'
|
|
|
+ + '<div class="form-item">'
|
|
|
+ + '<div class="z-comp-select " data =\' ' + vehicleTypeJSON + '\' name="TravelCostBoatCarDO[' + i + ']$vehicle">'
|
|
|
+ + '<div class="z-inputselect-bar">'
|
|
|
+ + '<span></span><i></i>'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</td>'
|
|
|
+ + '<td>'
|
|
|
+ + '<div class="form-item">'
|
|
|
+ + '<div class="z-comp-input " name="TravelCostBoatCarDO[' + i + ']$invoiceNums">'
|
|
|
+ + '<input type="number" value="">'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</td>'
|
|
|
+ + '<td>'
|
|
|
+ + '<div class="form-item">'
|
|
|
+ + '<div class="z-comp-input " name="TravelCostBoatCarDO[' + i + ']$amount">'
|
|
|
+ + '<input type="number" value="">'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</td>'
|
|
|
+ + '<td>'
|
|
|
+ + '<div class="form-item">'
|
|
|
+ + '<div class="z-comp-input" name="TravelCostBoatCarDO[' + i + ']$remark">'
|
|
|
+ + '<input type="text" value="">'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</td>'
|
|
|
+ + '<td>'
|
|
|
+ + '<div id="delBtn_boat_car' + (i) + '" class="table-btn delBtn_' + (i) + '" data-index="' + (i) + '">'
|
|
|
+ + '<span>删除</span>'
|
|
|
+ + '</div>'
|
|
|
+ + '</td>';
|
|
|
+ let trFragment = document.createDocumentFragment();
|
|
|
+ trFragment.appendChild(trDom);
|
|
|
+ $("#boatCarTbody").append(trFragment);
|
|
|
+ z.ui.date("[name='TravelCostBoatCarDO[" + i + "]$departDate']").init();
|
|
|
+ z.ui.date("[name='TravelCostBoatCarDO[" + i + "]$arriveDate']").init();
|
|
|
+ z.ui.select("[name='TravelCostBoatCarDO[" + i + "]$vehicle']").init();
|
|
|
+ if (boatCarArr[i].vehicle === '') {
|
|
|
+ z.ui.select("[name='TravelCostBoatCarDO[" + i + "]$vehicle']").setValue("1");
|
|
|
+ } else {
|
|
|
+ z.ui.select("[name='TravelCostBoatCarDO[" + i + "]$vehicle']").setValue(boatCarArr[i].vehicle + "");
|
|
|
+ }
|
|
|
+ if (!(!boatCarArr[i].departDate || boatCarArr[i].departDate.trim() === '')) {
|
|
|
+ z.ui.date("[name='TravelCostBoatCarDO[" + i + "]$departDate']").setValue(boatCarArr[i].departDate);
|
|
|
+ }
|
|
|
+ if (!(!boatCarArr[i].departPlace || boatCarArr[i].departPlace.trim() === '')) {
|
|
|
+ z.ui.input("[name='TravelCostBoatCarDO[" + i + "]$departPlace']").setValue(boatCarArr[i].departPlace);
|
|
|
+ }
|
|
|
+ if (!(!boatCarArr[i].arriveDate || boatCarArr[i].arriveDate.trim() === '')) {
|
|
|
+ z.ui.date("[name='TravelCostBoatCarDO[" + i + "]$arriveDate']").setValue(boatCarArr[i].arriveDate);
|
|
|
+ }
|
|
|
+ if (!(!boatCarArr[i].arrivePlace || boatCarArr[i].arrivePlace.trim() === '')) {
|
|
|
+ z.ui.input("[name='TravelCostBoatCarDO[" + i + "]$arrivePlace']").setValue(boatCarArr[i].arrivePlace);
|
|
|
+ }
|
|
|
+ if (boatCarArr[i].invoiceNums != '') {
|
|
|
+ z.ui.input("[name='TravelCostBoatCarDO[" + i + "]$invoiceNums']").setValue(boatCarArr[i].invoiceNums);
|
|
|
+ }
|
|
|
+ if (boatCarArr[i].amount != '') {
|
|
|
+ z.ui.input("[name='TravelCostBoatCarDO[" + i + "]$amount']").setValue(boatCarArr[i].amount);
|
|
|
+ totalBoatCarAmount()
|
|
|
+ totalAmount()
|
|
|
+ }
|
|
|
+ if (!(!boatCarArr[i].remark || boatCarArr[i].remark.trim() === '')) {
|
|
|
+ z.ui.input("[name='TravelCostBoatCarDO[" + i + "]$remark']").setValue(boatCarArr[i].remark);
|
|
|
+ }
|
|
|
+ let inpsJe = $("[name='TravelCostBoatCarDO[" + i + "]$amount']")[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 = ''
|
|
|
+ boatCarArr[i].amount = ''
|
|
|
+ } else {
|
|
|
+ boatCarArr[i].amount = inputInfo
|
|
|
+ }
|
|
|
+ totalBoatCarAmount()
|
|
|
+ totalAmount()
|
|
|
+ });
|
|
|
+ $("#delBtn_boat_car" + i).click(function () {
|
|
|
+ z.ui.confirm("compid").init({
|
|
|
+ content: "确定删除吗?",
|
|
|
+ onConfirm: function () {
|
|
|
+ var element = document.getElementById("boat_car_" + i);
|
|
|
+ element.remove();
|
|
|
+ boatCarArr = boatCarArr.splice(i, 1)
|
|
|
+ buildSeq("boat_car_seq");
|
|
|
+ totalBoatCarAmount();
|
|
|
+ totalAmount()
|
|
|
+ },
|
|
|
+ onCancel: function () {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ })
|
|
|
+ if (viewState === 'v' || read === '1') {
|
|
|
+ detailReadonly(i)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function generateOtherTableTrHtml(i) {
|
|
|
+ let otherTypeJSON = document.querySelector('#otherTypeJSON').value
|
|
|
+ var trDom = document.createElement("tr");
|
|
|
+ trDom.style.backgroundColor = "#fff";
|
|
|
+ trDom.id = "other_" + i;
|
|
|
+ trDom.className = 'qjsjClass'
|
|
|
+ trDom.innerHTML = '<td name="other_seq">' + (i + 1) + '</td>'
|
|
|
+ + '<td>'
|
|
|
+ + '<div class="form-item">'
|
|
|
+ + '<div class="z-comp-select " data =\' ' + otherTypeJSON + '\' name="TravelCostOtherDO[' + i + ']$costType">'
|
|
|
+ + '<div class="z-inputselect-bar">'
|
|
|
+ + '<span></span><i></i>'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</td>'
|
|
|
+ + '<td>'
|
|
|
+ + '<div class="form-flex">'
|
|
|
+ + '<div class="form-item" style="width: 100%;margin-right: 5px;">'
|
|
|
+ + '<div class="z-comp-date " name="TravelCostOtherDO[' + i + ']$costDate">'
|
|
|
+ + '<input type="text" value="">'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</td>'
|
|
|
+ + '<td>'
|
|
|
+ + '<div class="form-item">'
|
|
|
+ + '<div class="z-comp-input " name="TravelCostOtherDO[' + i + ']$costPlace">'
|
|
|
+ + '<input type="text" value="">'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</td>'
|
|
|
+ + '<td>'
|
|
|
+ + '<div class="form-item">'
|
|
|
+ + '<div class="z-comp-input " name="TravelCostOtherDO[' + i + ']$invoiceNums">'
|
|
|
+ + '<input type="number" value="">'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</td>'
|
|
|
+ + '<td>'
|
|
|
+ + '<div class="form-item">'
|
|
|
+ + '<div class="z-comp-input " name="TravelCostOtherDO[' + i + ']$amount">'
|
|
|
+ + '<input type="number" value="">'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</td>'
|
|
|
+ + '<td>'
|
|
|
+ + '<div class="form-item">'
|
|
|
+ + '<div class="z-comp-input" name="TravelCostOtherDO[' + i + ']$remark">'
|
|
|
+ + '<input type="text" value="">'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</td>'
|
|
|
+ + '<td>'
|
|
|
+ + '<div id="delBtn_other_' + (i) + '" class="table-btn delBtn_' + (i) + '" data-index="' + (i) + '">'
|
|
|
+ + '<span>删除</span>'
|
|
|
+ + '</div>'
|
|
|
+ + '</td>';
|
|
|
+ let trFragment = document.createDocumentFragment();
|
|
|
+ trFragment.appendChild(trDom);
|
|
|
+ $("#otherTbody").append(trFragment);
|
|
|
+ z.ui.date("[name='TravelCostOtherDO[" + i + "]$costDate']").init();
|
|
|
+ z.ui.select("[name='TravelCostOtherDO[" + i + "]$costType']").init();
|
|
|
+ if (!otherArr[i].costType || otherArr[i].costType.trim() === '') {
|
|
|
+ z.ui.select("[name='TravelCostOtherDO[" + i + "]$costType']").setValue("1");
|
|
|
+ otherArr[i].costType = "1";
|
|
|
+ } else {
|
|
|
+ z.ui.select("[name='TravelCostOtherDO[" + i + "]$costType']").setValue(otherArr[i].costType);
|
|
|
+ }
|
|
|
+ if (!(!otherArr[i].costDate || otherArr[i].costDate.trim() === '')) {
|
|
|
+ z.ui.date("[name='TravelCostOtherDO[" + i + "]$costDate']").setValue(otherArr[i].costDate);
|
|
|
+ }
|
|
|
+ if (!(!otherArr[i].costPlace || otherArr[i].costPlace.trim() === '')) {
|
|
|
+ z.ui.input("[name='TravelCostOtherDO[" + i + "]$costPlace']").setValue(otherArr[i].costPlace);
|
|
|
+ }
|
|
|
+ if (otherArr[i].invoiceNums != '') {
|
|
|
+ z.ui.input("[name='TravelCostOtherDO[" + i + "]$invoiceNums']").setValue(otherArr[i].invoiceNums);
|
|
|
+ }
|
|
|
+ if (otherArr[i].amount != '') {
|
|
|
+ z.ui.input("[name='TravelCostOtherDO[" + i + "]$amount']").setValue(otherArr[i].amount);
|
|
|
+ totalOtherAmount()
|
|
|
+ totalAmount()
|
|
|
+ }
|
|
|
+ if (!(!otherArr[i].remark || otherArr[i].remark.trim() === '')) {
|
|
|
+ z.ui.input("[name='TravelCostOtherDO[" + i + "]$remark']").setValue(otherArr[i].remark);
|
|
|
+ }
|
|
|
+ z.ui.select("[name='TravelCostOtherDO[" + i + "]$costType']").bindEvents({
|
|
|
+ onAfterSelect: function (value, data) {
|
|
|
+ otherArr[i].costType = value
|
|
|
+ }
|
|
|
+ });
|
|
|
+ let inpsJe = $("[name='TravelCostOtherDO[" + i + "]$amount']")[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 = ''
|
|
|
+ otherArr[i].amount = ''
|
|
|
+ } else {
|
|
|
+ otherArr[i].amount = inputInfo
|
|
|
+ }
|
|
|
+ totalOtherAmount()
|
|
|
+ totalAmount()
|
|
|
+ });
|
|
|
+ $("#delBtn_other_" + i).click(function () {
|
|
|
+ z.ui.confirm("compid").init({
|
|
|
+ content: "确定删除吗?",
|
|
|
+ onConfirm: function () {
|
|
|
+ var element = document.getElementById("other_" + i);
|
|
|
+ element.remove();
|
|
|
+ otherArr = otherArr.splice(i, 1)
|
|
|
+ buildSeq("other_seq");
|
|
|
+ totalOtherAmount()
|
|
|
+ totalAmount()
|
|
|
+ },
|
|
|
+ onCancel: function () {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ })
|
|
|
+ if (viewState === 'v' || read === '1') {
|
|
|
+ detailReadonly(i)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function detailReadonly(i) {
|
|
|
+ //财务审核时可以核减修改金额
|
|
|
+ if (finance === 1) {
|
|
|
+ //如果单据金额发生修改就代表核减了
|
|
|
+ }
|
|
|
+ $("#delBtn_" + i).css("display", "none");
|
|
|
+ $("[name='costType[" + i + "]']").addClass("z-readonly");
|
|
|
+ $("#selectProject_" + i).css("pointer-events", "none");
|
|
|
+ $("[name='costType[" + i + "]']").css("pointer-events", "none");
|
|
|
+ let detailElement = document.getElementById("qjsj_" + i);
|
|
|
+ let detailInput = detailElement.getElementsByTagName("input");
|
|
|
+ for (let j = 0; j < detailInput.length; j++) {
|
|
|
+ detailInput[j].disabled = true;
|
|
|
+ detailInput[j].className += "z-readonly"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //注册业务保存事件
|
|
|
+ function bindEvents() {
|
|
|
+ z.workflow.saveBtn.addListener("onSaveClick", saveForm);
|
|
|
+ }
|
|
|
+
|
|
|
+ function buildSeq(name) {
|
|
|
+ let elementsByName = document.getElementsByName(name);
|
|
|
+ for (let i = 0; i < elementsByName.length; i++) {
|
|
|
+ const seqElement = elementsByName[i];
|
|
|
+ seqElement.innerHTML = i + 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function totalBoatCarAmount() {
|
|
|
+ //金额汇总
|
|
|
+ let amount = 0
|
|
|
+ for (let obj of boatCarArr) {
|
|
|
+ amount += Number(obj.amount);
|
|
|
+ }
|
|
|
+ if (amount > 0) {
|
|
|
+ z.ui.input("[name='createReqVO$totalBoatCarCost']").setValue(amount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function totalOtherAmount() {
|
|
|
+ //金额汇总
|
|
|
+ let amount = 0
|
|
|
+ let carAmount = 0
|
|
|
+ for (let obj of otherArr) {
|
|
|
+ amount += Number(obj.amount);
|
|
|
+ if (obj.costType == "1") {
|
|
|
+ carAmount += Number(obj.amount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (amount > 0) {
|
|
|
+ z.ui.input("[name='createReqVO$totalOtherCost']").setValue(amount);
|
|
|
+ z.ui.input("[name='createReqVO$totalCityCarCost']").setValue(carAmount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function totalAmount() {
|
|
|
+ //金额汇总
|
|
|
+ let amount = 0
|
|
|
+ for (let obj of otherArr) {
|
|
|
+ amount += Number(obj.amount);
|
|
|
+ }
|
|
|
+ for (let obj of boatCarArr) {
|
|
|
+ amount += Number(obj.amount);
|
|
|
+ }
|
|
|
+ amount += Number(subsidyAmount);
|
|
|
+ amount = amount.toFixed(2)
|
|
|
+ if (amount > 0) {
|
|
|
+ z.ui.input("[name='createReqVO$totalAmount']").setValue(amount);
|
|
|
+ z.ui.input("[name='createReqVO$totalAmountCn']").setValue(convertCurrency(amount));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const weekList = ['星期', '周一', '周二', '周三', '周四', '周五', '周六', '周日']
|
|
|
+ function getSubsidy(workdays) {
|
|
|
+ // 获取要添加节点的html
|
|
|
+ const subsidyDetail = document.getElementsByName(
|
|
|
+ "createReqVO$subsidyDetail"
|
|
|
+ )[0];
|
|
|
+ let innerCheckBox = "";
|
|
|
+
|
|
|
+ subsidyAmount = 0; // 总数归0并重新计算
|
|
|
+
|
|
|
+ let subsidyArr = [];
|
|
|
+ for (const workday of workdays) {
|
|
|
+ let subsidyObj = {
|
|
|
+ workday: "",
|
|
|
+ checked: false,
|
|
|
+ dateDay: "",
|
|
|
+ dayOfWeek: "",
|
|
|
+ };
|
|
|
+ subsidyObj.workday = workday.isworkday;
|
|
|
+ subsidyObj.dateDay = new Date(workday.dateDay);
|
|
|
+ subsidyObj.dayOfWeek = workday.dayOfWeek;
|
|
|
+ if (workday.isworkday === 1) {
|
|
|
+ subsidyObj.checked = true;
|
|
|
+ }
|
|
|
+ subsidyArr.push(subsidyObj);
|
|
|
+
|
|
|
+ // 添加补贴明细选择框
|
|
|
+ const dateFormat = moment(workday.dateDay).format("YYYY-MM-DD");
|
|
|
+ const dayOfWeek = workday.dayOfWeek;
|
|
|
+ innerCheckBox += `
|
|
|
+ <span class="subsidy-detail-item">
|
|
|
+ <input class="detail-item-check-input" type="checkbox" id="${workday.dateDay}" value="${workday.dateDay}" ${workday.isworkday == 1 ? 'checked' : ''}>
|
|
|
+ <label>${dateFormat}(${weekList[dayOfWeek]})</label>
|
|
|
+ </span>
|
|
|
+ `;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 把选择框添加进去
|
|
|
+ subsidyDetail.innerHTML = innerCheckBox;
|
|
|
+ // 为每个生成的 checkbox 添加事件监听器
|
|
|
+ const checkboxes = subsidyDetail.querySelectorAll('.detail-item-check-input');
|
|
|
+ checkboxes.forEach((checkbox, index) => {
|
|
|
+ checkbox.addEventListener('change', function (event) {
|
|
|
+ const dateDetail = workdays[index]
|
|
|
+ if (event.target.checked) {
|
|
|
+ // Checkbox 被选中时的处理逻辑
|
|
|
+ // subsidyDetailChecked(dateDetail, true)
|
|
|
+ subsidyArr[index].checked = true;
|
|
|
+ totalAmountOnChange(subsidyArr)
|
|
|
+ } else {
|
|
|
+ // Checkbox 被取消选中时的处理逻辑
|
|
|
+ // subsidyDetailChecked(dateDetail, false)
|
|
|
+ subsidyArr[index].checked = false;
|
|
|
+ totalAmountOnChange(subsidyArr)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ // 更新总金额
|
|
|
+ totalAmountOnChange(subsidyArr)
|
|
|
+ }
|
|
|
+ /** 补贴明细选中时触发的事件 */
|
|
|
+ // function subsidyDetailChecked(detail, checked) {
|
|
|
+ // const dateFormat = moment(detail.dateDay).format("YYYY-MM-DD");
|
|
|
+ // console.log(dateFormat, checked, detail)
|
|
|
+ // }
|
|
|
+ /** 数据更改后输入框(补贴算法、途中补贴合计)内容变化 */
|
|
|
+ function totalAmountOnChange(subsidyArr) {
|
|
|
+ let work = 0;
|
|
|
+ let nonWork = 0;
|
|
|
+ subsidyAmount = 0
|
|
|
+ for (const subsidyArrElement of subsidyArr) {
|
|
|
+ if (subsidyArrElement.checked && subsidyArrElement.workday === 1) {
|
|
|
+ subsidyAmount += 50;
|
|
|
+ work++;
|
|
|
+ }
|
|
|
+ if (subsidyArrElement.checked && subsidyArrElement.workday === 0) {
|
|
|
+ subsidyAmount += 70;
|
|
|
+ nonWork++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let subsidyArithmeticValue =
|
|
|
+ "工作日(${work}天)* 50 + 非工作日(${nonWork}天)* 70 = 总额(${subsidyAmount}元)";
|
|
|
+ subsidyArithmeticValue = subsidyArithmeticValue
|
|
|
+ .replace("${work}", work + "")
|
|
|
+ .replace("${nonWork}", nonWork + "")
|
|
|
+ .replace("${subsidyAmount}", subsidyAmount + "");
|
|
|
+ z.ui.input("[name='createReqVO$subsidyAmount']").setValue(subsidyAmount);
|
|
|
+ z.ui
|
|
|
+ .input("[name='createReqVO$subsidyArithmetic']")
|
|
|
+ .setValue(subsidyArithmeticValue);
|
|
|
+ // 重新计算报销总额
|
|
|
+ totalAmount();
|
|
|
+ const stringValue = generateValue(subsidyArr)
|
|
|
+ console.log('string-Value', stringValue);
|
|
|
+ console.log('recoverCheck-Value', recoverCheckValue(stringValue))
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 通过选中数据生成特殊格式的复选框值
|
|
|
+ * 例:202403=28-1-D|29-1-D|30-1-E|31-0-E@202404=01-1-D|02-1-D|03-1-D|04-0-E
|
|
|
+ * 规则:
|
|
|
+ * 等号前代表年份月份,等号后第一位代表日期,不同月份连接符 @
|
|
|
+ * 第二位 1、选中0未选 checked: true 0 | false 1
|
|
|
+ * 第三位 D工作日、E非工作日 workday: 1 D | 0 E
|
|
|
+ */
|
|
|
+ function generateValue(data) {
|
|
|
+ const result = [];
|
|
|
+ let currentMonth = null;
|
|
|
+ let currentMonthString = '';
|
|
|
+ for (const item of data) {
|
|
|
+ const date = new Date(item.dateDay);
|
|
|
+ const month = date.getMonth() + 1;
|
|
|
+ const day = date.getDate();
|
|
|
+ if (month !== currentMonth) {
|
|
|
+ if (currentMonth !== null) {
|
|
|
+ result.push(currentMonthString);
|
|
|
+ }
|
|
|
+ currentMonth = month;
|
|
|
+ currentMonthString = `${date.getFullYear()}${month.toString().padStart(2, '0')}=`;
|
|
|
+ }
|
|
|
+ const checkedValue = item.checked ? '1' : '0';
|
|
|
+ const workdayValue = item.workday === 0 ? 'E' : 'D';
|
|
|
+ currentMonthString += `${day.toString().padStart(2, '0')}-${checkedValue}-${workdayValue}|`;
|
|
|
+ }
|
|
|
+ if (currentMonth !== null) {
|
|
|
+ result.push(currentMonthString);
|
|
|
+ }
|
|
|
+ return result.map((item) => item.slice(0, -1)).join('@');
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 接上一个方法,把生成的值恢复成选中的内容
|
|
|
+ * 返回数据示例:
|
|
|
+ * [{
|
|
|
+ * "date": "2024-03-28T00:00:00.000Z",
|
|
|
+ * "checked": true,
|
|
|
+ * "workday": 1,
|
|
|
+ * "dateFormat": "2024-03-27",
|
|
|
+ * "dayOfWeek": "周三"
|
|
|
+ * }]
|
|
|
+ */
|
|
|
+ const US_Days = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
|
|
|
+ function recoverCheckValue(value) {
|
|
|
+ const result = [];
|
|
|
+ const monthYearRegex = /^(\d{4})(\d{2})=/;
|
|
|
+ const itemRegex = /^(\d{2})-(\d)-(\w)$/;
|
|
|
+ for (const monthYearString of value.split('@')) {
|
|
|
+ const match = monthYearRegex.exec(monthYearString);
|
|
|
+ if (!match) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ const year = parseInt(match[1], 10);
|
|
|
+ const month = parseInt(match[2], 10);
|
|
|
+ for (const itemString of monthYearString.slice(match[0].length).split('|')) {
|
|
|
+ const itemMatch = itemRegex.exec(itemString);
|
|
|
+ if (!itemMatch) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ const day = parseInt(itemMatch[1], 10);
|
|
|
+ const checked = itemMatch[2] === '1';
|
|
|
+ const workday = itemMatch[3] === 'D' ? 1 : 0;
|
|
|
+ const date = new Date(year, month - 1, day);
|
|
|
+ result.push({
|
|
|
+ date,
|
|
|
+ checked,
|
|
|
+ workday,
|
|
|
+ dayOfWeek: US_Days[date.getDay()],
|
|
|
+ dateFormat: moment(date).format("YYYY-MM-DD")
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * all 工作流js传递到业务的参数 success执行的方法
|
|
|
+ * istransfer 工作流js传递到业务的参数 是否转件
|
|
|
+ * */
|
|
|
+ function saveForm(all, istransfer) {
|
|
|
+ var postData = z.ui.form.getFormFields($("[name=createReqVO]"));
|
|
|
+ if (postData === false) {
|
|
|
+ all({ success: false });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ postData.createReqVO.instanceId = z.ui.comm.getUrlParam("flowInstanceId");
|
|
|
+ var boatCarList = new Array()
|
|
|
+ var otherList = new Array()
|
|
|
+ for (let key of Object.keys(postData)) {
|
|
|
+ let mealName = postData[key];
|
|
|
+ if (key.startsWith("TravelCostBoatCarDO")) {
|
|
|
+ mealName.departDate = Date.parse(mealName.departDate);
|
|
|
+ mealName.arriveDate = Date.parse(mealName.arriveDate);
|
|
|
+ boatCarList.push(z.ui.form.childStringify(mealName));
|
|
|
+ }
|
|
|
+ if (key.startsWith("TravelCostOtherDO")) {
|
|
|
+ mealName.costDate = Date.parse(mealName.costDate);
|
|
|
+ otherList.push(z.ui.form.childStringify(mealName));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ postData.createReqVO.startTime = Date.parse(postData.createReqVO.startTime);
|
|
|
+ postData.createReqVO.endTime = Date.parse(postData.createReqVO.endTime);
|
|
|
+ postData.createReqVO.boatCarList = boatCarList;
|
|
|
+ postData.createReqVO.otherList = otherList;
|
|
|
+ z.ui.ajax({
|
|
|
+ type: "post",
|
|
|
+ url: "/TravelCost/update",
|
|
|
+ data: JSON.stringify(postData.createReqVO),
|
|
|
+ contentType: "application/json",
|
|
|
+ success: function () {
|
|
|
+ all({ success: true });
|
|
|
+ },
|
|
|
+ error: function () {
|
|
|
+ all({ success: false });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ function initCompany() {
|
|
|
+ z.ui.ajax({
|
|
|
+ type: "get",
|
|
|
+ url: "/common/company-tree",
|
|
|
+ data: {},
|
|
|
+ success: function (res) {
|
|
|
+ if (res && res.data.length > 0) {
|
|
|
+ selecttree("[name='createReqVO$paymentCompany']", res.data, clickCompany)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function () {
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ function clickCompany(even, treeId, treeNode) {
|
|
|
+ $("[name='createReqVO$paymentCompanyId']").val(treeNode.id);
|
|
|
+ }
|
|
|
+
|
|
|
+ function setProject(res) {
|
|
|
+ if (res.data) {
|
|
|
+ $("[name='createReqVO$projectId']").val(res.data.id);
|
|
|
+ z.ui.input("[name='createReqVO$projectName']").setValue(res.data.xmmc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}());
|