|
@@ -0,0 +1,921 @@
|
|
|
+'use strict';
|
|
|
+
|
|
|
+/**
|
|
|
+ * 变更令详细页js
|
|
|
+ *
|
|
|
+ * @author EllisRan.
|
|
|
+ * @date 2018/11/22
|
|
|
+ * @version
|
|
|
+ */
|
|
|
+// 编号排序,多重判断
|
|
|
+function sortByCode(a, b) {
|
|
|
+ let code1 = a.code.split('-');
|
|
|
+ let code2 = b.code.split('-');
|
|
|
+ let code1length = code1.length;
|
|
|
+ let code2length = code2.length;
|
|
|
+ for (let i = 0; i < code1length; i ++) {
|
|
|
+ if (i+1 <= code2length) {
|
|
|
+ if (code1[i] != code2[i]) {
|
|
|
+ if (!/^\d+$/.test(code1[i])) {
|
|
|
+ return code1[i].charCodeAt() - code2[i].charCodeAt();
|
|
|
+ } else {
|
|
|
+ return parseInt(code1[i]) - parseInt(code2[i]);
|
|
|
+ }
|
|
|
+ } else if (i+1 == code1length && code1[i] == code2[i]) {
|
|
|
+ if (code1length == code2length) {
|
|
|
+ return 0;
|
|
|
+ } else {
|
|
|
+ return code1length - code2length;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (i+1 >= code1length) {
|
|
|
+ return 1;
|
|
|
+ } else {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+$.event.special.valuechange = {
|
|
|
+ teardown: function (namespaces) {
|
|
|
+ $(this).unbind('.valuechange');
|
|
|
+ },
|
|
|
+
|
|
|
+ handler: function (e) {
|
|
|
+ $.event.special.valuechange.triggerChanged($(this));
|
|
|
+ },
|
|
|
+
|
|
|
+ add: function (obj) {
|
|
|
+ $(this).on('keyup.valuechange cut.valuechange paste.valuechange input.valuechange', obj.selector, $.event.special.valuechange.handler)
|
|
|
+ },
|
|
|
+
|
|
|
+ triggerChanged: function (element) {
|
|
|
+ var current = element[0].contentEditable === 'true' ? element.html() : element.val()
|
|
|
+ , previous = typeof element.data('previous') === 'undefined' ? element[0].defaultValue : element.data('previous');
|
|
|
+ if (current !== previous) {
|
|
|
+ element.trigger('valuechange', [element.data('previous')]);
|
|
|
+ element.data('previous', current);
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+$(document).ready(() => {
|
|
|
+ const changeSpreadSetting = {
|
|
|
+ cols: [
|
|
|
+ {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 80, formatter: '@', readOnly: 'readOnly.isEdit'},
|
|
|
+ {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isEdit'},
|
|
|
+ {title: '变更部位', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isEdit'},
|
|
|
+ {title: '变更详情', colSpan: '1', rowSpan: '2', field: 'detail', hAlign: 0, width: 120, formatter: '@', readOnly: false},
|
|
|
+ {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: 'readOnly.isEdit', cellType: 'unit', comboItems: changeUnits},
|
|
|
+ {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit', getValue: 'getValue.unit_price'},
|
|
|
+ {title: '原设计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'oamount', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit', getValue: 'getValue.oamount'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'oa_tp', hAlign: 2, width: 80, formatter: '@', type: 'Number', readOnly: true, getValue: 'getValue.oa_tp'},
|
|
|
+ {title: '申请变更增(+)减(-)|数量', colSpan: '2|1', rowSpan: '1|1', field: 'camount', hAlign: 2, width: 60, type: 'Number', readOnly: false, getValue: 'getValue.camount'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'ca_tp', hAlign: 2, width: 80, formatter: '@', type: 'Number', readOnly: true, getValue: 'getValue.ca_tp'},
|
|
|
+ {title: '操作', colSpan: '1', rowSpan: '2', field: 'del_list', hAlign: 1, width: 40, readOnly: true, cellType: 'mouseTouch', getValue: 'getValue.del_list'},
|
|
|
+ ],
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 2,
|
|
|
+ headRowHeight: [25, 25],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ readOnly: readOnly,
|
|
|
+ };
|
|
|
+
|
|
|
+ const changeCol = {
|
|
|
+ getValue: {
|
|
|
+ unit_price: function(data) {
|
|
|
+ return ZhCalc.round(data.unit_price, unitPriceUnit);
|
|
|
+ },
|
|
|
+ oa_tp: function (data) {
|
|
|
+ return ZhCalc.round(ZhCalc.mul(data.unit_price, data.oamount), totalPriceUnit);
|
|
|
+ },
|
|
|
+ ca_tp: function (data) {
|
|
|
+ return ZhCalc.round(ZhCalc.mul(data.unit_price, data.camount), totalPriceUnit);
|
|
|
+ },
|
|
|
+ oamount: function (data) {
|
|
|
+ return ZhCalc.round(data.oamount, findDecimal(data.unit));
|
|
|
+ },
|
|
|
+ camount: function (data) {
|
|
|
+ return ZhCalc.round(data.camount, findDecimal(data.unit));
|
|
|
+ },
|
|
|
+ del_list: function (data) {
|
|
|
+ return '移除';
|
|
|
+ }
|
|
|
+ },
|
|
|
+ readOnly: {
|
|
|
+ isEdit: function (data) {
|
|
|
+ return !readOnly && data.lid != 0;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ const changeSpreadObj = {
|
|
|
+ makeSjsFooter: function () {
|
|
|
+ // 增加汇总行并设为锁定禁止编辑状态
|
|
|
+ changeSpreadSheet.addRows(changeSpreadSheet.getRowCount(), 1);
|
|
|
+ changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 0, '合计');
|
|
|
+ changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
|
|
|
+ changeSpreadObj.countSum();
|
|
|
+ },
|
|
|
+ countSum: function() {
|
|
|
+ const rowCount = changeSpreadSheet.getRowCount();
|
|
|
+ let oSum = 0,
|
|
|
+ cSum = 0;
|
|
|
+ for(var i = 0; i < rowCount - 1; i++){
|
|
|
+ oSum = ZhCalc.add(oSum, changeSpreadSheet.getValue(i, 7));
|
|
|
+ cSum = ZhCalc.add(cSum, changeSpreadSheet.getValue(i, 9));
|
|
|
+ }
|
|
|
+ changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 7, oSum !== 0 ? oSum : null);
|
|
|
+ changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 9, cSum !== 0 ? cSum : null);
|
|
|
+ },
|
|
|
+ add: function () {
|
|
|
+ postData(window.location.pathname + '/save', {type: 'add'}, function (result) {
|
|
|
+ if (result) {
|
|
|
+ changeList.push(result);
|
|
|
+ changeSpreadSheet.addRows(changeList.length - 1, 1);
|
|
|
+ SpreadJsObj.reLoadRowData(changeSpreadSheet, changeList.length - 1);
|
|
|
+ changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
|
|
|
+ changeSpreadSheet.setSelection(changeList.length - 1, 0, 1, 1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ del: function () {
|
|
|
+ const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
|
|
|
+ const index = changeList.indexOf(select);
|
|
|
+ if (index > -1) {
|
|
|
+ postData(window.location.pathname + '/save', {type: 'del', id: select.id}, function (result) {
|
|
|
+ changeList.splice(index, 1);
|
|
|
+ changeSpreadSheet.deleteRows(index, 1);
|
|
|
+ const sel = changeSpreadSheet.getSelections();
|
|
|
+ changeSpreadSheet.setSelection(0, 0, 1, 1);
|
|
|
+ if (select.lid != 0) {
|
|
|
+ tableDataRemake(changeListData);
|
|
|
+ }
|
|
|
+ changeSpreadObj.countSum();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ selectionChanged: function (e, info) {
|
|
|
+ const sel = info.sheet.getSelections()[0];
|
|
|
+ const col = info.sheet.zh_setting.cols[sel.col];
|
|
|
+ const data = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
+ if (col.field === 'del_list') {
|
|
|
+ changeSpreadObj.del();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ deletePress: function (sheet) {
|
|
|
+ return;
|
|
|
+ },
|
|
|
+ editEnded: function (e, info) {
|
|
|
+ if (info.sheet.zh_setting) {
|
|
|
+ const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
+ if (col.field === 'del_list') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 未改变值则不提交
|
|
|
+ let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
|
|
|
+ const orgValue = select[col.field];
|
|
|
+ if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 判断部分值是否输入的是数字判断和数据计算
|
|
|
+ if (col.type === 'Number') {
|
|
|
+ if (isNaN(validText)) {
|
|
|
+ toastr.error('不能输入其它非数字类型字符');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (col.field === 'unit_price') {
|
|
|
+ validText = ZhCalc.round(validText, unitPriceUnit);
|
|
|
+ } else {
|
|
|
+ validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (col.field === 'unit') {
|
|
|
+ select.camount = ZhCalc.round(select.camount, findDecimal(validText)) || 0;
|
|
|
+ select.oamount = ZhCalc.round(select.oamount, findDecimal(validText)) || 0;
|
|
|
+ }
|
|
|
+ select[col.field] = validText;
|
|
|
+ if(col.field === 'camount') {
|
|
|
+ select.spamount = ZhCalc.round(select.camount, findDecimal(select.unit)) || 0;
|
|
|
+ }
|
|
|
+ console.log(select);
|
|
|
+
|
|
|
+ // 更新至服务器
|
|
|
+ postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
|
|
|
+ changeList.splice(info.row, 1, select);
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ changeSpreadObj.countSum();
|
|
|
+ }, function () {
|
|
|
+ select[col.field] = orgValue;
|
|
|
+ if(col.field === 'camount') {
|
|
|
+ select.spamount = orgValue;
|
|
|
+ }
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ clipboardPasted(e, info) {
|
|
|
+ const hint = {
|
|
|
+ cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
|
|
|
+ numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
|
|
|
+ };
|
|
|
+ const range = info.cellRange;
|
|
|
+ const sortData = info.sheet.zh_data || [];
|
|
|
+ if (info.cellRange.row + info.cellRange.rowCount > sortData.length) {
|
|
|
+ toastMessageUniq(hint.cellError);
|
|
|
+ // SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
|
|
|
+ SpreadJsObj.reLoadSheetHeader(changeSpreadSheet);
|
|
|
+ SpreadJsObj.reLoadSheetData(changeSpreadSheet);
|
|
|
+ changeSpreadObj.makeSjsFooter();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (sortData.length > 0 && range.col + range.colCount > 10) {
|
|
|
+ toastMessageUniq(hint.cellError);
|
|
|
+ SpreadJsObj.reLoadSheetHeader(changeSpreadSheet);
|
|
|
+ SpreadJsObj.reLoadSheetData(changeSpreadSheet);
|
|
|
+ changeSpreadObj.makeSjsFooter();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const data = [];
|
|
|
+ // const rowData = [];
|
|
|
+ for (let iRow = 0; iRow < range.rowCount; iRow++) {
|
|
|
+ let bPaste = true;
|
|
|
+ const curRow = range.row + iRow;
|
|
|
+ // const materialData = JSON.parse(JSON.stringify(sortData[curRow]));
|
|
|
+ const cLData = { id: sortData[curRow].id };
|
|
|
+ const hintRow = range.rowCount > 1 ? curRow : '';
|
|
|
+ let sameCol = 0;
|
|
|
+ for (let iCol = 0; iCol < range.colCount; iCol++) {
|
|
|
+ const curCol = range.col + iCol;
|
|
|
+ const colSetting = info.sheet.zh_setting.cols[curCol];
|
|
|
+ if (!colSetting) continue;
|
|
|
+
|
|
|
+ let validText = info.sheet.getText(curRow, curCol);
|
|
|
+ validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
|
|
|
+ const orgValue = sortData[curRow][colSetting.field];
|
|
|
+ if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
|
|
|
+ sameCol++;
|
|
|
+ if (range.colCount === sameCol) {
|
|
|
+ bPaste = false;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (colSetting.type === 'Number') {
|
|
|
+ if (isNaN(validText)) {
|
|
|
+ toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
|
|
|
+ bPaste = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (colSetting.field === 'unit_price') {
|
|
|
+ validText = ZhCalc.round(validText, unitPriceUnit);
|
|
|
+ } else {
|
|
|
+ validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (colSetting.field === 'unit') {
|
|
|
+ //粘贴内容要为下拉列表里所有的单位,不然为空
|
|
|
+ if (changeUnits.indexOf(validText) === -1) {
|
|
|
+ validText = '';
|
|
|
+ }
|
|
|
+ cLData.camount = ZhCalc.round(sortData[curRow].camount, findDecimal(validText)) || 0;
|
|
|
+ cLData.oamount = ZhCalc.round(sortData[curRow].oamount, findDecimal(validText)) || 0;
|
|
|
+ }
|
|
|
+ cLData[colSetting.field] = validText;
|
|
|
+ sortData[curRow][colSetting.field] = validText;
|
|
|
+ cLData.spamount = ZhCalc.round(sortData[curRow].camount, findDecimal(validText)) || 0;
|
|
|
+ }
|
|
|
+ if (bPaste) {
|
|
|
+ data.push(cLData);
|
|
|
+ // rowData.push(curRow);
|
|
|
+ } else {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, curRow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (data.length === 0) {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log(data);
|
|
|
+ // 更新至服务器
|
|
|
+ postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
|
|
|
+ changeList = result;
|
|
|
+ SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
|
|
|
+ changeSpreadObj.makeSjsFooter();
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
+ return;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ const preUrl = window.location.pathname.split('/').slice(0, 4).join('/');
|
|
|
+ let changeListData;
|
|
|
+ let gclGatherData;
|
|
|
+ postData(preUrl + '/defaultBills', {}, function (result) {
|
|
|
+ gclGatherModel.loadLedgerData(result.bills);
|
|
|
+ gclGatherModel.loadPosData(result.pos);
|
|
|
+
|
|
|
+ gclGatherData = gclGatherModel.gatherGclData();
|
|
|
+ gclGatherData = _.filter(gclGatherData, function (item) {
|
|
|
+ return item.leafXmjs && item.leafXmjs.length !== 0;
|
|
|
+ });
|
|
|
+ for (const ggd in gclGatherData) {
|
|
|
+ if (gclGatherData[ggd].leafXmjs && gclGatherData[ggd].leafXmjs.length === 0) {
|
|
|
+ gclGatherData.splice(ggd, 1);
|
|
|
+ }
|
|
|
+ gclGatherData[ggd].code = gclGatherData[ggd].b_code;
|
|
|
+ }
|
|
|
+ // 数组去重
|
|
|
+ const dealBillList = result.dealBills;
|
|
|
+ for (const db of gclGatherData) {
|
|
|
+ const exist_index = dealBillList.findIndex(function (item) {
|
|
|
+ return item.code === db.code && item.name === db.name && item.unit === db.unit && item.unit_price === db.unit_price;
|
|
|
+ });
|
|
|
+ if (exist_index !== -1) {
|
|
|
+ dealBillList.splice(exist_index, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ changeListData = gclGatherData.concat(dealBillList).sort(sortByCode);
|
|
|
+ // 先加载台账数据
|
|
|
+ let listHtml = '';
|
|
|
+ let list_index = 1;
|
|
|
+ let gcl_index = 0;
|
|
|
+ for (const gcl of changeListData) {
|
|
|
+ const unit = gcl.unit !== undefined && gcl.unit !== null ? gcl.unit : '';
|
|
|
+ const quantity = gcl.quantity !== null && gcl.quantity !== undefined ? (unit !== '' ? ZhCalc.round(gcl.quantity, findDecimal(gcl.unit)) : gcl.quantity) : 0;
|
|
|
+ const unit_price = gcl.unit_price !== null && gcl.unit_price !== undefined ? gcl.unit_price : 0;
|
|
|
+ let gclhtml = gcl.leafXmjs !== undefined && gcl.leafXmjs !== null ? ' data-gcl="' + gcl_index + '"' : '';
|
|
|
+ gcl_index = gclhtml !== '' ? ++gcl_index : gcl_index;
|
|
|
+ const lid = gcl.leafXmjs !== undefined && gcl.leafXmjs !== null ? (gcl.leafXmjs.length !== 0 ? gcl.leafXmjs[0].gcl_id : false) : gcl.id;
|
|
|
+ if (lid) {
|
|
|
+ listHtml += '<tr data-lid="' + lid + '"' + gclhtml + ' data-index="' + list_index + '" data-bwmx="">' +
|
|
|
+ '<td class="text-center">' + list_index + '</td>' +
|
|
|
+ '<td>' + gcl.code + '</td>' +
|
|
|
+ '<td class="text-left">' + gcl.name + '</td>' +
|
|
|
+ '<td class="text-center">' + unit + '</td>' +
|
|
|
+ '<td class="text-right">' + (ZhCalc.round(unit_price, unitPriceUnit) ? ZhCalc.round(unit_price, unitPriceUnit) : 0) + '</td>' +
|
|
|
+ '<td class="text-right">' + quantity + '</td>' +
|
|
|
+ '</tr>';
|
|
|
+ list_index++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $('#table-list-select').html(listHtml);
|
|
|
+ tableDataRemake(changeListData);
|
|
|
+
|
|
|
+ SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
|
|
|
+ SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
|
|
|
+ SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
|
|
|
+ changeSpreadObj.makeSjsFooter();
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!readOnly) {
|
|
|
+ $('#add-white-btn').click(changeSpreadObj.add);
|
|
|
+ changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
|
|
|
+ changeSpread.bind(spreadNS.Events.SelectionChanged, changeSpreadObj.selectionChanged);
|
|
|
+ changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
|
|
|
+ SpreadJsObj.addDeleteBind(changeSpread, changeSpreadObj.deletePress);
|
|
|
+ changeSpreadSheet.getCell(-1, 10).foreColor('#dc3545');
|
|
|
+
|
|
|
+ // 右键菜单
|
|
|
+ $.contextMenu({
|
|
|
+ selector: '#change-spread',
|
|
|
+ build: function ($trigger, e) {
|
|
|
+ const target = SpreadJsObj.safeRightClickSelection($trigger, e, changeSpread);
|
|
|
+ return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
|
|
|
+ },
|
|
|
+ items: {
|
|
|
+ 'createList': {
|
|
|
+ name: '添加台账清单',
|
|
|
+ icon: 'fa-sign-in',
|
|
|
+ callback: function (key, opt) {
|
|
|
+ $('#addlist').modal('show');
|
|
|
+ },
|
|
|
+ },
|
|
|
+ 'createAdd': {
|
|
|
+ name: '添加空白清单',
|
|
|
+ icon: 'fa-sign-in',
|
|
|
+ callback: function (key, opt) {
|
|
|
+ changeSpreadObj.add(changeSpreadSheet);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ 'delete': {
|
|
|
+ name: '删除',
|
|
|
+ icon: 'fa-remove',
|
|
|
+ callback: function (key, opt) {
|
|
|
+ changeSpreadObj.del(changeSpreadSheet);
|
|
|
+ },
|
|
|
+ disabled: function (key, opt) {
|
|
|
+ const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
|
|
|
+ const sel = changeSpreadSheet.getSelections()[0];
|
|
|
+ console.log(select, sel);
|
|
|
+ if (!readOnly && select && sel.row !== changeSpreadSheet.getRowCount() - 1) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 清单选中和移除
|
|
|
+ $('body').on('click', '#table-list-select tr', function () {
|
|
|
+ $('#table-list-select tr').removeClass('table-warning');
|
|
|
+ $(this).addClass('table-warning');
|
|
|
+ const isCheck = $(this).hasClass('table-success') ? true : false;
|
|
|
+ const data_bwmx = $(this).attr('data-bwmx').split('$#$');
|
|
|
+ const isDeal = $(this).data('gcl') !== undefined ? true : false;
|
|
|
+ let codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'" gcl_id=""><td colspan="7" class="colspan_1"> </td><td class="colspan_2"><input type="checkbox"></td></tr>';
|
|
|
+ if (isDeal) {
|
|
|
+ const lid = $(this).data('lid');
|
|
|
+ let gcl = _.find(gclGatherData, function (item) {
|
|
|
+ return item.leafXmjs && item.leafXmjs[0].gcl_id === lid;
|
|
|
+ });
|
|
|
+ if (!gcl) {
|
|
|
+ gcl = gclGatherData[$(this).data('gcl')];
|
|
|
+ }
|
|
|
+ codeHtml = '';
|
|
|
+ for (const leaf of gcl.leafXmjs) {
|
|
|
+ const quantity = leaf.quantity !== undefined && leaf.quantity !== null ? leaf.quantity : 0;
|
|
|
+ const gcl_id = leaf.gcl_id ? leaf.gcl_id : '';
|
|
|
+ const bwmx = leaf.bwmx !== undefined ? leaf.bwmx : '';
|
|
|
+ const isChecked = data_bwmx.indexOf(leaf.code + '!_!' + (leaf.jldy ? leaf.jldy : '') + '!_!' + (leaf.gcl_id ? leaf.gcl_id : '0') + '!_!' + (bwmx !== '' ? bwmx : leaf.jldy ? leaf.jldy : '') + '*;*' + quantity) !== -1 && isCheck ? 'checked' : '';
|
|
|
+ codeHtml += '<tr quantity="' + quantity + '" gcl_id="' + gcl_id + '"><td>' + leaf.code + '</td>' +
|
|
|
+ '<td>' + (leaf.jldy ? leaf.jldy: '') + '</td>' +
|
|
|
+ '<td>' + (leaf.dwgc ? leaf.dwgc : '') + '</td>' +
|
|
|
+ '<td>' + (leaf.fbgc ? leaf.fbgc : '') + '</td>' +
|
|
|
+ '<td>' + (leaf.fxgc ? leaf.fxgc : '') + '</td>' +
|
|
|
+ '<td>' + bwmx + '</td>' +
|
|
|
+ '<td class="text-right">' + (ZhCalc.round(quantity, findDecimal(gcl.unit)) ? ZhCalc.round(quantity, findDecimal(gcl.unit)) : 0) + '</td>' +
|
|
|
+ '<td class="text-center"><input type="checkbox"' + isChecked +
|
|
|
+ '></td></tr>';
|
|
|
+ }
|
|
|
+ } else if (!isDeal && isCheck) {
|
|
|
+ codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'" gcl_id=""><td colspan="7" class="colspan_1"> </td><td class="colspan_2"><input type="checkbox" checked></td></tr>';
|
|
|
+ }
|
|
|
+ $('#code-list').attr('data-index', $(this).children('td').eq(0).text());
|
|
|
+ $('#code-input').val('');
|
|
|
+ $('#code-input').siblings('a').hide();
|
|
|
+ $('#code-list').html(codeHtml);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 右边项目节选择
|
|
|
+ $('body').on('click', '#code-list input', function () {
|
|
|
+ let index = $('#code-list').attr('data-index');
|
|
|
+ if ($(this).is(':checked')) {
|
|
|
+ // 去除其它可能已选的checked
|
|
|
+ // $('#code-list input').prop('checked', false);
|
|
|
+ $(this).prop('checked', true);
|
|
|
+ // 左边表单传值并添加class
|
|
|
+ $('#table-list-select tr[data-index="' + index + '"]').addClass('table-success');
|
|
|
+ // 去除部分data-detail值
|
|
|
+ let data_bwmx = [];
|
|
|
+ $('#code-list input:checked').each(function () {
|
|
|
+ const tr = $(this).parents('tr');
|
|
|
+ const length = tr.children('td').length;
|
|
|
+ const gcl_id = tr.attr('gcl_id');
|
|
|
+ const bwmx = length === 8 ? tr.children('td').eq(0).text() + '!_!' + tr.children('td').eq(1).text() + '!_!' + gcl_id + '!_!' + (tr.children('td').eq(5).text() !== '' ? tr.children('td').eq(5).text() : tr.children('td').eq(1).text()) : '0';
|
|
|
+ const quantity = tr.attr('quantity');
|
|
|
+ const de_qu = bwmx + '*;*' + quantity;
|
|
|
+ data_bwmx.push(de_qu);
|
|
|
+ });
|
|
|
+ data_bwmx = data_bwmx.join('$#$');
|
|
|
+ $('#table-list-select tr[data-index="' + index + '"]').attr('data-bwmx', data_bwmx);
|
|
|
+ } else {
|
|
|
+ // 判断还有无选中项目节编号
|
|
|
+ if ($('#code-list input').is(':checked')) {
|
|
|
+ // 去除部分data-detail值
|
|
|
+ let data_bwmx = [];
|
|
|
+ $('#code-list input:checked').each(function () {
|
|
|
+ const tr = $(this).parents('tr');
|
|
|
+ const length = tr.children('td').length;
|
|
|
+ const gcl_id = tr.attr('gcl_id');
|
|
|
+ const bwmx = length === 8 ? tr.children('td').eq(0).text() + '!_!'+ tr.children('td').eq(1).text() + '!_!' + gcl_id + '!_!' + (tr.children('td').eq(5).text() !== '' ? tr.children('td').eq(5).text() : tr.children('td').eq(1).text()) : '0';
|
|
|
+ const quantity = tr.attr('quantity');
|
|
|
+ const de_qu = bwmx + '*;*' + quantity;
|
|
|
+ data_bwmx.push(de_qu);
|
|
|
+ });
|
|
|
+ data_bwmx = data_bwmx.join('$#$');
|
|
|
+ $('#table-list-select tr[data-index="' + index + '"]').attr('data-bwmx', data_bwmx);
|
|
|
+ } else {
|
|
|
+ $('#table-list-select tr[data-index="' + index + '"]').removeClass('table-success');
|
|
|
+ $('#table-list-select tr[data-index="' + index + '"]').attr('data-bwmx', '');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 添加空白清单or签约清单
|
|
|
+ $('.add-list-btn').on('click', function () {
|
|
|
+ const newLedgerList = remakeChangeSpread();
|
|
|
+ // 更新至服务器
|
|
|
+ postData(window.location.pathname + '/save', { type:'ledger_list', updateData: newLedgerList }, function (result) {
|
|
|
+ changeList = result;
|
|
|
+ SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
|
|
|
+ changeSpreadObj.makeSjsFooter();
|
|
|
+ $('#addlist').modal('hide');
|
|
|
+ }, function () {
|
|
|
+ $('#addlist').modal('hide');
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ // 选中input所有值
|
|
|
+ $('body').on('focus', ".clist input", function() {
|
|
|
+ $(this).select();
|
|
|
+ });
|
|
|
+
|
|
|
+ // 取消选中清单
|
|
|
+ $('#cancel-list-btn').click(function () {
|
|
|
+ // $('#table-list-select tr').removeClass('table-success');
|
|
|
+ // $('#table-list-select tr').attr('data-bwmx', '');
|
|
|
+ // $('#code-list').html('');
|
|
|
+ tableDataRemake(changeListData);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 自动编号
|
|
|
+ $('.reduction-code').click(function () {
|
|
|
+ const code = $(this).attr('data-code');
|
|
|
+ $('input[name="code"]').val(code);
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#list-input').on('valuechange', function (e, previous) {
|
|
|
+ const value = $(this).val();
|
|
|
+ let showListData = changeListData;
|
|
|
+ if (value !== '') {
|
|
|
+ $(this).siblings('a').show();
|
|
|
+ showListData = _.filter(changeListData, function (c) {
|
|
|
+ return (c.code && c.code.indexOf(value) !== -1) || (c.name && c.name.indexOf(value) !== -1);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $(this).siblings('a').hide();
|
|
|
+ }
|
|
|
+ makeListTable(changeListData, showListData);
|
|
|
+ $('#table-list-select tr').removeClass('table-warning');
|
|
|
+ $('#code-input').val('');
|
|
|
+ $('#code-input').siblings('a').hide();
|
|
|
+ $('#code-list').html('');
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#code-input').on('valuechange', function (e, previous) {
|
|
|
+ const value = $(this).val();
|
|
|
+ if (value !== '') {
|
|
|
+ $(this).siblings('a').show();
|
|
|
+ } else {
|
|
|
+ $(this).siblings('a').hide();
|
|
|
+ }
|
|
|
+ makeCodeTable($(this).val());
|
|
|
+ });
|
|
|
+
|
|
|
+ $('.remove-btn').on('click', function () {
|
|
|
+ $(this).hide();
|
|
|
+ $(this).siblings('input').val('');
|
|
|
+ if ($(this).data('btn') === 'list') {
|
|
|
+ makeListTable(changeListData);
|
|
|
+ $('#table-list-select tr').removeClass('table-warning');
|
|
|
+ $('#code-list').html('');
|
|
|
+ } else {
|
|
|
+ makeCodeTable();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 记录变更信息操作
|
|
|
+ $('body').on('valuechange', '#change_form input[type="text"]', function (e, previous) {
|
|
|
+ changeInfo[$(this).attr('name')] = $(this).val();
|
|
|
+ judgeChange();
|
|
|
+ });
|
|
|
+ $('body').on('valuechange', '#change_form textarea', function (e, previous) {
|
|
|
+ changeInfo[$(this).attr('name')] = $(this).val().replace(/[\r\n]/g, '<br><br>');
|
|
|
+ judgeChange();
|
|
|
+ });
|
|
|
+ $('body').on('change', '#change_form select', function (e, previous) {
|
|
|
+ changeInfo[$(this).attr('name')] = $(this).val();
|
|
|
+ judgeChange();
|
|
|
+ });
|
|
|
+ $('body').on('click', '#change_form input[type="radio"]', function (e, previous) {
|
|
|
+ changeInfo[$(this).attr('name')] = $(this).val();
|
|
|
+ judgeChange();
|
|
|
+ });
|
|
|
+ $('body').on('click', '#change_form input[type="checkbox"]', function (e, previous) {
|
|
|
+ const typecheck = [];
|
|
|
+ $.each($('#change_form input[name="type[]"]:checked'), function () {
|
|
|
+ typecheck.push($(this).val());
|
|
|
+ });
|
|
|
+ changeInfo.type = typecheck.join(',');
|
|
|
+ judgeChange();
|
|
|
+ });
|
|
|
+
|
|
|
+ // 保存修改ajax提交(不刷新页面)
|
|
|
+ $('.save_change_btn').on('click', function () {
|
|
|
+ // 保存修改modal
|
|
|
+ if ($('input[name="code"]').val() === '') {
|
|
|
+ toastr.error('申请编号不能为空!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ($('input[name="name"]').val() === '') {
|
|
|
+ toastr.error('工程名称不能为空!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 更新至服务器
|
|
|
+ postData(window.location.pathname + '/save', { type:'info', updateData: changeInfo }, function (result) {
|
|
|
+ $('.reduction-code').attr('data-code', $('input[name="code"]').val());
|
|
|
+ toastr.success(result);
|
|
|
+ $('#show-save-btn').hide();
|
|
|
+ $('#sp-btn').show();
|
|
|
+ $('.title-main').removeClass('bg-warning');
|
|
|
+ back_changeInfo = Object.assign({}, changeInfo);
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#cancel_change').on('click', function () {
|
|
|
+ $('#show-save-btn').hide();
|
|
|
+ $('#sp-btn').show();
|
|
|
+ $('.title-main').removeClass('bg-warning');
|
|
|
+ if (!isObjEqual(changeInfo, back_changeInfo)) {
|
|
|
+ changeFormRemake();
|
|
|
+ }
|
|
|
+ toastr.success('已还原到上次保存状态');
|
|
|
+ });
|
|
|
+});
|
|
|
+function checkChangeFrom() {
|
|
|
+ let returnFlag = false;
|
|
|
+ // 表单判断
|
|
|
+ if ($('input[name="code"]').val() === '') {
|
|
|
+ toastr.error('申请编号不能为空!');
|
|
|
+ returnFlag = true;
|
|
|
+ }
|
|
|
+ if ($('input[name="name"]').val() === '') {
|
|
|
+ toastr.error('工程名称不能为空!');
|
|
|
+ returnFlag = true;
|
|
|
+ }
|
|
|
+ if ($('textarea[name="content"]').val() === '') {
|
|
|
+ toastr.error('工程变更理由及内容不能为空!');
|
|
|
+ returnFlag = true;
|
|
|
+ }
|
|
|
+ if (changeList.length === 0) {
|
|
|
+ toastr.error('请添加变更清单!');
|
|
|
+ returnFlag = true;
|
|
|
+ } else {
|
|
|
+ for (const [i,cl] of changeList.entries()) {
|
|
|
+ if (cl.code === '' || cl.name === '' || cl.oamount === '') {
|
|
|
+ toastr.error('变更清单第' + (i+1) + '行未完整填写数据(变更部位、变更详情、单位、单价可空)');
|
|
|
+ returnFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!checkAuditorFrom ()) {
|
|
|
+ returnFlag = true;
|
|
|
+ }
|
|
|
+ if (returnFlag) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|
|
|
+// 检查上报情况
|
|
|
+function checkAuditorFrom () {
|
|
|
+ if ($('#auditList li').length === 0) {
|
|
|
+ if(shenpi_status === shenpiConst.sp_status.gdspl) {
|
|
|
+ toastr.error('请联系管理员添加审批人');
|
|
|
+ } else {
|
|
|
+ toastr.error('请先选择审批人,再上报数据');
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+function tableDataRemake(changeListData) {
|
|
|
+ $('#table-list-select tr').removeClass('table-warning');
|
|
|
+ $('#table-list-select tr').removeClass('table-success');
|
|
|
+ $('#table-list-select tr').attr('data-bwmx', '');
|
|
|
+ $('#code-list').html('');
|
|
|
+ // 根据已添加的清单显示
|
|
|
+ if (changeList.length > 0 && changeList[0]) {
|
|
|
+ for (const [index,clinfo] of changeList.entries()) {
|
|
|
+ if (clinfo.lid != 0) {
|
|
|
+ let listinfo = changeListData.find(function (item) {
|
|
|
+ return (item.id !== undefined && item.id == clinfo.lid) || (item.id === undefined && item.leafXmjs !== undefined && item.leafXmjs.length !== 0 && item.leafXmjs[0].gcl_id == clinfo.lid);
|
|
|
+ });
|
|
|
+ if (listinfo === undefined) {
|
|
|
+ // 针对旧数据获取清单信息
|
|
|
+ listinfo = changeListData[clinfo.lid - 1];
|
|
|
+ if (listinfo === undefined) {
|
|
|
+ toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
|
|
|
+ changeList.splice(index, 1);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').addClass('table-success');
|
|
|
+ let pushbwmx = '0*;*0';
|
|
|
+ if (listinfo.leafXmjs !== undefined) {
|
|
|
+ const leafInfo = listinfo.leafXmjs.find(function (item) {
|
|
|
+ return (item.bwmx === undefined || item.bwmx === clinfo.bwmx) && (item.quantity !== null ? item.quantity === parseFloat(clinfo.oamount) : 0 === parseFloat(clinfo.oamount));
|
|
|
+ });
|
|
|
+ console.log(leafInfo);
|
|
|
+ if (leafInfo) {
|
|
|
+ pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' + (leafInfo.gcl_id ? leafInfo.gcl_id : '') + '!_!' + (leafInfo.bwmx !== undefined ? leafInfo.bwmx : '') + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
|
|
|
+ } else {
|
|
|
+ toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
|
|
|
+ changeList.splice(index, 1);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ pushbwmx = '0*;*' + (listinfo.quantity !== null ? listinfo.quantity : 0);
|
|
|
+ }
|
|
|
+ const bwmx = $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').attr('data-bwmx');
|
|
|
+ if (bwmx) {
|
|
|
+ const bwmxArray = bwmx.split('$#$');
|
|
|
+ bwmxArray.push(pushbwmx);
|
|
|
+ $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').attr('data-bwmx', bwmxArray.join('$#$'));
|
|
|
+ } else {
|
|
|
+ $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').attr('data-bwmx', pushbwmx);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $('#table-list-select tr[data-lid="'+ clinfo.lid +'"]').addClass('table-success');
|
|
|
+ let pushbwmx = '0*;*0';
|
|
|
+ if (listinfo.leafXmjs !== undefined) {
|
|
|
+ const leafInfo = listinfo.leafXmjs.find(function (item) {
|
|
|
+ return (item.bwmx === undefined || item.bwmx === clinfo.bwmx || item.jldy === clinfo.bwmx) && (item.quantity !== null ? item.quantity === parseFloat(clinfo.oamount) : 0 === parseFloat(clinfo.oamount));
|
|
|
+ });
|
|
|
+ if (leafInfo) {
|
|
|
+ pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' + (leafInfo.gcl_id ? leafInfo.gcl_id : '') + '!_!' + (leafInfo.bwmx !== undefined ? leafInfo.bwmx : (leafInfo.jldy ? leafInfo.jldy : '')) + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
|
|
|
+ } else {
|
|
|
+ toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
|
|
|
+ changeList.splice(index, 1);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ pushbwmx = '0*;*' + (listinfo.quantity !== null ? listinfo.quantity : 0);
|
|
|
+ }
|
|
|
+ const bwmx = $('#table-list-select tr[data-lid="'+ clinfo.lid +'"]').attr('data-bwmx');
|
|
|
+ if (bwmx) {
|
|
|
+ const bwmxArray = bwmx.split('$#$');
|
|
|
+ bwmxArray.push(pushbwmx);
|
|
|
+ $('#table-list-select tr[data-lid="'+ clinfo.lid +'"]').attr('data-bwmx', bwmxArray.join('$#$'));
|
|
|
+ } else {
|
|
|
+ $('#table-list-select tr[data-lid="'+ clinfo.lid +'"]').attr('data-bwmx', pushbwmx);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 清单搜索隐藏清单table部分值
|
|
|
+function makeListTable(changeListData, showListData = changeListData) {
|
|
|
+ // 先加载台账数据
|
|
|
+ let listHtml = '';
|
|
|
+ let list_index = 1;
|
|
|
+ let gcl_index = 0;
|
|
|
+ for (const [index,gcl] of changeListData.entries()) {
|
|
|
+ const isShow = _.find(showListData, gcl);
|
|
|
+ $('#table-list-select tr').eq(index).css('display', (isShow ? 'table-row' : 'none'));
|
|
|
+ }
|
|
|
+}
|
|
|
+// 项目节搜索隐藏code-table部分值
|
|
|
+function makeCodeTable(search = '') {
|
|
|
+ if (search === '') {
|
|
|
+ $('#code-list tr').css('display', 'table-row');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for(let i = 0; i < $('#code-list tr').length; i++) {
|
|
|
+ const length = $('#code-list tr').eq(i).children('td').length;
|
|
|
+ if (length === 8) {
|
|
|
+ const code = $('#code-list tr').eq(i).children('td').eq(0).text();
|
|
|
+ const name = $('#code-list tr').eq(i).children('td').eq(1).text();
|
|
|
+ const jldy = $('#code-list tr').eq(i).children('td').eq(5).text();
|
|
|
+ const isShow = code.indexOf(search) !== -1 || name.indexOf(search) !== -1 || jldy.indexOf(search) !== -1;
|
|
|
+ $('#code-list tr').eq(i).css('display', (isShow ? 'table-row' : 'none'));
|
|
|
+ } else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function remakeChangeSpread() {
|
|
|
+ const newTableList = [];
|
|
|
+ // 获取选中的签约清单判断并插入到原有清单中
|
|
|
+ $('#table-list-select .table-success').each(function(){
|
|
|
+ let code = $(this).children('td').eq(1).text();
|
|
|
+ let name = $(this).children('td').eq(2).text();
|
|
|
+ let unit = $(this).children('td').eq(3).text();
|
|
|
+ let price = $(this).children('td').eq(4).text();
|
|
|
+ // let oamount = $(this).children('td').eq(5).text();
|
|
|
+
|
|
|
+ // 根据单位获取数量的位数,并得出
|
|
|
+ // let numdecimal = findDecimal(unit);
|
|
|
+
|
|
|
+ // let scnum = makedecimalzero(numdecimal);
|
|
|
+ let scnum = 0;
|
|
|
+ // let detail = $(this).attr('data-detail') != 0 ? $(this).attr('data-detail').split('_')[1] : '';
|
|
|
+ let lid = $(this).data('lid');
|
|
|
+ let lindex = $(this).data('index');
|
|
|
+ // 原清单和数量改变
|
|
|
+ let data_bwmx = $(this).attr('data-bwmx').split('$#$');
|
|
|
+
|
|
|
+ for (const b of data_bwmx) {
|
|
|
+ const oamount = b.split('*;*')[1] != '' ? b.split('*;*')[1] : 0;
|
|
|
+ let bwmx = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[3] : '';
|
|
|
+ let xmj_code = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[0] : '';
|
|
|
+ let xmj_jldy = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[1] : '';
|
|
|
+ let gcl_id = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[2] : '';
|
|
|
+ let trlist = {
|
|
|
+ code,
|
|
|
+ name,
|
|
|
+ bwmx,
|
|
|
+ unit,
|
|
|
+ unit_price: price,
|
|
|
+ oamount,
|
|
|
+ camount: scnum,
|
|
|
+ detail: '',
|
|
|
+ lid,
|
|
|
+ xmj_code,
|
|
|
+ xmj_jldy,
|
|
|
+ gcl_id,
|
|
|
+ };
|
|
|
+ const radionInfo = changeList.find(function (info) {
|
|
|
+ return info.code === code && (info.lid == lid || parseInt(info.lid) === parseInt(lindex)) && gcl_id == info.gcl_id && info.bwmx === bwmx;
|
|
|
+ });
|
|
|
+ if (radionInfo) {
|
|
|
+ trlist.camount = radionInfo.camount;
|
|
|
+ trlist.detail = radionInfo.detail;
|
|
|
+ }
|
|
|
+ newTableList.push(trlist);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // const changeWhiteList = _.filter(changeList, function (item) {
|
|
|
+ // return item.lid == 0;
|
|
|
+ // });
|
|
|
+ // console.log(newTableList);
|
|
|
+ // changeList = newTableList.concat(changeWhiteList);
|
|
|
+ return newTableList;
|
|
|
+}
|
|
|
+//判断元素是否在数组中,相当于php的in_array();
|
|
|
+function in_array(arr, obj) {
|
|
|
+ let i = arr.length;
|
|
|
+ while (i--) {
|
|
|
+ if (arr[i] == obj) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+function isObjEqual(o1,o2){
|
|
|
+ var props1 = Object.getOwnPropertyNames(o1);
|
|
|
+ var props2 = Object.getOwnPropertyNames(o2);
|
|
|
+ if (props1.length != props2.length) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ for (var i = 0,max = props1.length; i < max; i++) {
|
|
|
+ var propName = props1[i];
|
|
|
+ if (o1[propName] !== o2[propName]) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+}
|
|
|
+// 判断是否有更改过
|
|
|
+function judgeChange() {
|
|
|
+ let change = false;
|
|
|
+ if (!isObjEqual(changeInfo, back_changeInfo)) {
|
|
|
+ change = true;
|
|
|
+ }
|
|
|
+ if (change) {
|
|
|
+ $('#show-save-btn').show();
|
|
|
+ $('#sp-btn').hide();
|
|
|
+ $('.title-main').addClass('bg-warning');
|
|
|
+ } else {
|
|
|
+ $('#show-save-btn').hide();
|
|
|
+ $('#sp-btn').show();
|
|
|
+ $('.title-main').removeClass('bg-warning');
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function changeFormRemake() {
|
|
|
+ changeInfo = Object.assign({}, back_changeInfo);
|
|
|
+ $('#change_form input[name="code"]').val(changeInfo.code);
|
|
|
+ $('#change_form input[name="name"]').val(changeInfo.name);
|
|
|
+ $('#change_form input[name="peg"]').val(changeInfo.peg);
|
|
|
+ $('#change_form input[name="org_name"]').val(changeInfo.org_name);
|
|
|
+ $('#change_form input[name="org_code"]').val(changeInfo.org_code);
|
|
|
+ $('#change_form input[name="new_name"]').val(changeInfo.new_name);
|
|
|
+ $('#change_form input[name="new_code"]').val(changeInfo.new_code);
|
|
|
+ $('#change_form textarea[name="content"]').val(changeInfo.content.replace(/<br><br>/g, '\r\n'));
|
|
|
+ $('#change_form textarea[name="basis"]').val(changeInfo.basis.replace(/<br><br>/g, '\r\n'));
|
|
|
+ $('#change_form textarea[name="expr"]').val(changeInfo.expr.replace(/<br><br>/g, '\r\n'));
|
|
|
+ $('#change_form textarea[name="memo"]').val(changeInfo.memo.replace(/<br><br>/g, '\r\n'));
|
|
|
+ $('#change_form select[name="type"]').val(changeInfo.type);
|
|
|
+ $('#change_form select[name="class"]').val(changeInfo.class);
|
|
|
+ $('#change_form select[name="quality"]').val(changeInfo.quality);
|
|
|
+ $('#change_form select[name="company"]').val(changeInfo.company);
|
|
|
+ $('#change_form input[name="charge"][value="'+ changeInfo.charge +'"]').prop('checked', true);
|
|
|
+ $('#change_form input[name="type[]"]').prop('checked', false);
|
|
|
+ const typecheck = changeInfo.type.split(',');
|
|
|
+ for (const type of typecheck) {
|
|
|
+ $('#change_form input[name="type[]"][value="'+ type +'"]').prop('checked', true);
|
|
|
+ }
|
|
|
+}
|