|
@@ -20,6 +20,63 @@ function loadUpdateMaterials(newMaterial, fields) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// function DatePickerCellType() {
|
|
|
+// }
|
|
|
+// DatePickerCellType.prototype = new GC.Spread.Sheets.CellTypes.Base();
|
|
|
+// DatePickerCellType.prototype.createEditorElement = function () {
|
|
|
+// //Create input presenter.
|
|
|
+// var input = document.createElement("input");
|
|
|
+// return input;
|
|
|
+// };
|
|
|
+// DatePickerCellType.prototype.activateEditor = function (editorContext, cellStyle, cellRect) {
|
|
|
+// //Initialize input editor.
|
|
|
+// if (editorContext) {
|
|
|
+// const $editor = $(editorContext);
|
|
|
+// GC.Spread.Sheets.CellTypes.Base.prototype.activateEditor.apply(this, arguments);
|
|
|
+// $editor.datepicker({
|
|
|
+// language: 'zh',
|
|
|
+// });
|
|
|
+// $editor.css("position", "absolute");
|
|
|
+// $editor.attr("gcUIElement", "gcEditingInput");
|
|
|
+// $(".ui-datepicker").attr("gcUIElement", "gcEditingInput");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// // DatePickerCellType.prototype.deactivateEditor = function (editorContext) {
|
|
|
+// // //Remove input editor when end editor status.
|
|
|
+// // if (editorContext) {
|
|
|
+// // var element = editorContext;
|
|
|
+// // $(element).datepicker().data('datepicker').hide();
|
|
|
+// // $(element).datepicker().data('datepicker').destroy();
|
|
|
+// // // $(element).datepicker("hide");
|
|
|
+// // // $(element).datepicker("destroy");
|
|
|
+// // }
|
|
|
+// // GC.Spread.Sheets.CellTypes.Base.prototype.deactivateEditor.apply(this, arguments)
|
|
|
+// // };
|
|
|
+// // DatePickerCellType.prototype.setEditorValue = function (editor, value) {
|
|
|
+// // //Sync value from Cell value to editor value.
|
|
|
+// // console.log($(editor), value);
|
|
|
+// // // $(editor).datepicker("setDate", value);
|
|
|
+// // $(editor).datepicker().data('datepicker').selectDate(value);
|
|
|
+// // };
|
|
|
+// // DatePickerCellType.prototype.getEditorValue = function (editor) {
|
|
|
+// // //Sync value from editor value to cell value.
|
|
|
+// // $(editor).datepicker({
|
|
|
+// // onSelect: function onSelect(fd, date) {
|
|
|
+// // console.log(fd);
|
|
|
+// // $(editor).val(fd);
|
|
|
+// // }
|
|
|
+// // });
|
|
|
+// // // return $(editor).datepicker("getDate");
|
|
|
+// // return $(editor).val();
|
|
|
+// // };
|
|
|
+// DatePickerCellType.prototype.updateEditor = function (editorContext, cellStyle, cellRect) {
|
|
|
+// if (editorContext) {
|
|
|
+// const $editor = $(editorContext);
|
|
|
+// $editor.css("width", cellRect.width - 1);
|
|
|
+// $editor.css("height", cellRect.height - 3);
|
|
|
+// }
|
|
|
+// };
|
|
|
+
|
|
|
function resetTpTable() {
|
|
|
const rate = $('#changeRate').val();
|
|
|
const bqhs = ZhCalc.round(ZhCalc.mul(m_tp, 1+rate/100), 2);
|
|
@@ -34,12 +91,12 @@ $(document).ready(() => {
|
|
|
const materialSpread = SpreadJsObj.createNewSpread($('#material-spread')[0]);
|
|
|
const materialSpreadSetting = {
|
|
|
cols: [
|
|
|
- {title: '调差类型', colSpan: '1', rowSpan: '2', field: 't_type', hAlign: 0, width: 80, formatter: '@', readOnly: 'readOnly.isEdit', cellType: 'customizeCombo', comboItems: materialType.t_type, cellTypeKey: 1},
|
|
|
+ {title: '调差类型', colSpan: '1', rowSpan: '2', field: 't_type', hAlign: 1, width: 80, formatter: '@', readOnly: 'readOnly.isEdit', cellType: 'customizeCombo', comboItems: materialType.t_type, cellTypeKey: 1},
|
|
|
{title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 60, formatter: '@', readOnly: 'readOnly.isEdit'},
|
|
|
{title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 180, formatter: '@', readOnly: 'readOnly.isEdit'},
|
|
|
{title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: 'readOnly.isEdit'},
|
|
|
{title: '规格', colSpan: '1', rowSpan: '2', field: 'spec', hAlign: 0, width: 180, formatter: '@', readOnly: 'readOnly.isEdit'},
|
|
|
- {title: '工料分类', colSpan: '1', rowSpan: '2', field: 'm_type', hAlign: 0, width: 60, readOnly: 'readOnly.isEdit', cellType: 'customizeCombo', comboItems: materialType.m_type, cellTypeKey: 2},
|
|
|
+ {title: '工料分类', colSpan: '1', rowSpan: '2', field: 'm_type', hAlign: 1, width: 60, readOnly: 'readOnly.isEdit', cellType: 'customizeCombo', comboItems: materialType.m_type, cellTypeKey: 2},
|
|
|
{title: '本期应耗数量', colSpan: '1', rowSpan: '2', field: 'quantity', hAlign: 2, width: 100, type: 'Number', readOnly: true},
|
|
|
{title: '基准价', colSpan: '1', rowSpan: '2', field: 'basic_price', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit'},
|
|
|
{title: '基准时间', colSpan: '1', rowSpan: '2', field: 'basic_times', hAlign: 0, width: 60, formatter: '@', readOnly: 'readOnly.isEdit'},
|
|
@@ -71,6 +128,7 @@ $(document).ready(() => {
|
|
|
// return !readOnly && data.t_type === 2 && data.mid === materialID;
|
|
|
return data.t_type === 2;
|
|
|
};
|
|
|
+
|
|
|
materialSpreadSetting.imageClick = function (data) {
|
|
|
if (data.t_type === 2) {
|
|
|
$('#bcyy').modal('show');
|
|
@@ -184,7 +242,7 @@ $(document).ready(() => {
|
|
|
const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
const col = info.sheet.zh_setting.cols[info.col];
|
|
|
// 未改变值则不提交
|
|
|
- const validText = info.editingText ? (typeof(info.editingText) === 'String' ? info.editingText.replace('\n', '') : info.editingText) : null;
|
|
|
+ const validText = _.isNumber(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
|
|
|
const orgValue = select[col.field];
|
|
|
if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
@@ -198,7 +256,7 @@ $(document).ready(() => {
|
|
|
return;
|
|
|
}
|
|
|
const num = parseFloat(validText);
|
|
|
- if (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num)) {
|
|
|
+ if (validText !== null && (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num))) {
|
|
|
toastr.error('请输入大于0并且小于3位小数的浮点数');
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
return;
|
|
@@ -211,7 +269,7 @@ $(document).ready(() => {
|
|
|
return;
|
|
|
}
|
|
|
const num = parseFloat(validText);
|
|
|
- if (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num)) {
|
|
|
+ if (validText !== null && (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num))) {
|
|
|
toastr.error('请输入大于0并且小于3位小数的浮点数');
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
return;
|
|
@@ -225,7 +283,7 @@ $(document).ready(() => {
|
|
|
return;
|
|
|
}
|
|
|
const num = parseFloat(validText);
|
|
|
- if (num < 0 || num > 100 || !/^\d+$/.test(num)) {
|
|
|
+ if (validText !== null && (num < 0 || num > 100 || !/^\d+$/.test(num))) {
|
|
|
toastr.error('只能输入0-100的正整数');
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
return;
|
|
@@ -239,7 +297,7 @@ $(document).ready(() => {
|
|
|
return;
|
|
|
}
|
|
|
const num = parseFloat(validText);
|
|
|
- if (num < 0 || num > 100 || !/^\d+$/.test(num)) {
|
|
|
+ if (validText !== null && (num < 0 || num > 100 || !/^\d+$/.test(num))) {
|
|
|
toastr.error('只能输入0-100的正整数');
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
return;
|
|
@@ -267,12 +325,161 @@ $(document).ready(() => {
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
+ deletePress: function (sheet) {
|
|
|
+ return;
|
|
|
+ },
|
|
|
+ clipboardPasted(e, info) {
|
|
|
+ // const tree = info.sheet.zh_tree;
|
|
|
+ // if (!tree) { return; }
|
|
|
+ const hint = {
|
|
|
+ codeEmpty: {type: 'error', msg: '请先输入编号'},
|
|
|
+ codeUsed: {type: 'error', msg: '该编号已存在,请重新输入。'},
|
|
|
+ numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
|
|
|
+ riskCan: {type: 'error', msg: '只能粘贴0-100的正整数'},
|
|
|
+ numberCan: {type: 'error', msg: '请粘贴大于0并且小于3位小数的浮点数'},
|
|
|
+ };
|
|
|
+ console.log(info);
|
|
|
+ const range = info.cellRange;
|
|
|
+ const sortData = info.sheet.zh_data || [];
|
|
|
+ if (info.cellRange.row + info.cellRange.rowCount > sortData.length) {
|
|
|
+ SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const data = [];
|
|
|
+ for (let iRow = 0; iRow < range.rowCount; iRow++) {
|
|
|
+ let bPaste = true;
|
|
|
+ const curRow = range.row + iRow;
|
|
|
+ const materialData = {id: sortData[curRow].id};
|
|
|
+ for (let iCol = 0; iCol < info.cellRange.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);
|
|
|
+ console.log(validText, isNaN(parseFloat(validText)));
|
|
|
+ validText = _.isNumber(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : null);
|
|
|
+ console.log(validText);
|
|
|
+ const orgValue = sortData[curRow][colSetting.field];
|
|
|
+ console.log(orgValue);
|
|
|
+ if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ materialData[colSetting.field] = validText;
|
|
|
+
|
|
|
+ // if (colSetting.type === 'Number') {
|
|
|
+ // const num = _.toNumber(materialData[colSetting.field]);
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ console.log(materialData);
|
|
|
+ }
|
|
|
+ if (data.length === 0) {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // if (info.sheet.zh_setting) {
|
|
|
+ // const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
+ // const col = info.sheet.zh_setting.cols[info.col];
|
|
|
+ // // 未改变值则不提交
|
|
|
+ // const validText = info.editingText ? trimInvalidChar(info.editingText) : null;
|
|
|
+ // const orgValue = select[col.field];
|
|
|
+ // if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // // 判断部分值是否输入的是数字判断和数据计算
|
|
|
+ // if (col.field === 'basic_price') {
|
|
|
+ // if (isNaN(validText)) {
|
|
|
+ // toastr.error('不能输入其它非数字类型字符');
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // const num = parseFloat(validText);
|
|
|
+ // if (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num)) {
|
|
|
+ // toastr.error('请输入大于0并且小于3位小数的浮点数');
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (col.field === 'msg_tp') {
|
|
|
+ // if (isNaN(validText)) {
|
|
|
+ // toastr.error('不能输入其它非数字类型字符');
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // const num = parseFloat(validText);
|
|
|
+ // if (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num)) {
|
|
|
+ // toastr.error('请输入大于0并且小于3位小数的浮点数');
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (col.field === 'm_up_risk') {
|
|
|
+ // // 只能输入正整数
|
|
|
+ // if (isNaN(validText)) {
|
|
|
+ // toastr.error('不能输入其它非数字类型字符');
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // const num = parseFloat(validText);
|
|
|
+ // if (num < 0 || num > 100 || !/^\d+$/.test(num)) {
|
|
|
+ // toastr.error('只能输入0-100的正整数');
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (col.field === 'm_down_risk') {
|
|
|
+ // // 只能输入正整数
|
|
|
+ // if (isNaN(validText)) {
|
|
|
+ // toastr.error('不能输入其它非数字类型字符');
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // const num = parseFloat(validText);
|
|
|
+ // if (num < 0 || num > 100 || !/^\d+$/.test(num)) {
|
|
|
+ // toastr.error('只能输入0-100的正整数');
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (col.field === 't_type') {
|
|
|
+ // if (validText === 1) {
|
|
|
+ // select.quantity = null;
|
|
|
+ // select.expr = null;
|
|
|
+ // select.m_tp = null;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // select[col.field] = validText;
|
|
|
+ // select.msg_spread = materialCol.getValue.msg_spread(select);
|
|
|
+ // select.m_spread = materialCol.getValue.m_spread(select);
|
|
|
+ // select.m_tp = materialCol.getValue.m_tp(select);
|
|
|
+ // // 更新至服务器
|
|
|
+ // postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
|
|
|
+ // m_tp = result.m_tp;
|
|
|
+ // resetTpTable();
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ // }, function () {
|
|
|
+ // select[col.field] = orgValue;
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ },
|
|
|
setReadOnly: function(readOnly) {
|
|
|
- SpreadJsObj.resetFieldReadOnly(materialSpread.getActiveSheet(), 'msg_spread', 'm_spread', 'm_tp', 'pre_tp', readOnly);
|
|
|
+ // SpreadJsObj.resetFieldReadOnly(materialSpread.getActiveSheet(), 'msg_spread', 'm_spread', 'm_tp', 'pre_tp', readOnly);
|
|
|
}
|
|
|
};
|
|
|
materialSpreadObj.refreshActn();
|
|
|
materialSpread.bind(spreadNS.Events.SelectionChanged, materialSpreadObj.selectionChanged);
|
|
|
+ materialSpread.bind(spreadNS.Events.ClipboardPasted, materialSpreadObj.clipboardPasted);
|
|
|
+ SpreadJsObj.addDeleteBind(materialSpread, materialSpreadObj.deletePress);
|
|
|
+ // const sheet = materialSpread.getActiveSheet();
|
|
|
+ // sheet.suspendPaint();
|
|
|
+ // var range = sheet.getRange(-1, 8, -1, 1);
|
|
|
+ // console.log(range);
|
|
|
+ // range.cellType(new DatePickerCellType());
|
|
|
+ // // range.formatter("yyyy-MM-dd");
|
|
|
+ // sheet.resumePaint();
|
|
|
+
|
|
|
if (!readOnly) {
|
|
|
$('#add').click(materialSpreadObj.add);
|
|
|
$('#del').click(materialSpreadObj.del);
|