|
@@ -57,9 +57,10 @@ $(function () {
|
|
|
const monthsCols = [];
|
|
|
if(scheduleMonth.length > 0) {
|
|
|
for (const sm of scheduleMonth) {
|
|
|
+ const readOnly = sm.sj_gcl !== null || sm.sj_tp !== null;
|
|
|
const yearmonth = sm.yearmonth.split('-')[0] + '年' + parseInt(sm.yearmonth.split('-')[1]) + '月';
|
|
|
- const cols = {title: yearmonth + '|计划工程量', colSpan: '2|1', rowSpan: '1|1', field: sm.yearmonth+'_gcl', hAlign: 2, width: 90, type: 'Number', readOnly: 'readOnly.gcl'};
|
|
|
- const cols2 = {title: '|计划金额(万元)', colSpan: '|1', rowSpan: '|1', field: sm.yearmonth+'_tp', hAlign: 2, width: 90, type: 'Number', readOnly: 'readOnly.tp'};
|
|
|
+ const cols = {title: yearmonth + '|计划工程量', colSpan: '2|1', rowSpan: '1|1', field: sm.yearmonth+'_gcl', hAlign: 2, width: 90, type: 'Number', readOnly: readOnly ? readOnly : 'readOnly.gcl'};
|
|
|
+ const cols2 = {title: '|计划金额(万元)', colSpan: '|1', rowSpan: '|1', field: sm.yearmonth+'_tp', hAlign: 2, width: 90, type: 'Number', readOnly: readOnly ? readOnly : 'readOnly.tp'};
|
|
|
monthsCols.push(cols);
|
|
|
monthsCols.push(cols2);
|
|
|
}
|
|
@@ -155,7 +156,55 @@ $(function () {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ editEnded: function (e, info) {
|
|
|
+ if (info.sheet.zh_setting) {
|
|
|
+ const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
+ const validText = is_numeric(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);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (isNaN(validText)) {
|
|
|
+ toastr.error('不能输入其它非数字类型字符');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ select[col.field] = validText;
|
|
|
+ const yearmonth = col.field.split('_')[0];
|
|
|
+ const mode = col.field.split('_')[1];
|
|
|
+ let plan_gcl = 0;
|
|
|
+ let plan_tp = 0;
|
|
|
+ if (mode === 'tp') {
|
|
|
+ plan_gcl = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.div(validText, select.dgn_price), tenderInfo.decimal.up) : 0;
|
|
|
+ plan_tp = validText;
|
|
|
+ select[yearmonth + '_gcl'] = plan_gcl;
|
|
|
+ } else {
|
|
|
+ plan_gcl = validText;
|
|
|
+ plan_tp = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(validText, select.dgn_price), tenderInfo.decimal.tp) : 0;
|
|
|
+ select[yearmonth + '_tp'] = plan_tp;
|
|
|
+ }
|
|
|
+ const updateData = {
|
|
|
+ lid: select.ledger_id,
|
|
|
+ yearmonth,
|
|
|
+ plan_gcl,
|
|
|
+ plan_tp,
|
|
|
+ };
|
|
|
+ console.log(updateData);
|
|
|
+ // postData(window.location.pathname + '/save', {type: 'mode', postData: updateData}, function (result) {
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ // })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ deletePress: function (sheet) {
|
|
|
+ return;
|
|
|
+ },
|
|
|
};
|
|
|
+
|
|
|
+ ledgerSpread.bind(spreadNS.Events.EditEnded, ledgerSpreadObj.editEnded);
|
|
|
+ SpreadJsObj.addDeleteBind(ledgerSpread, ledgerSpreadObj.deletePress);
|
|
|
+
|
|
|
// 进度计算方式选择
|
|
|
$('.mode-select').on('click', function () {
|
|
|
const _self = $(this);
|
|
@@ -316,10 +365,14 @@ function setLeafData(tree) {
|
|
|
if (!child && !t.is_leaf) {
|
|
|
t.is_leaf = true;
|
|
|
}
|
|
|
- for(const m of scheduleMonth) {
|
|
|
- t[m.yearmonth] = m.sj_gcl !== null || m.sj_tp !== null;
|
|
|
- }
|
|
|
newtree.push(t);
|
|
|
}
|
|
|
return newtree;
|
|
|
}
|
|
|
+const is_numeric = (value) => {
|
|
|
+ if (typeof(value) === 'object') {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return !Number.isNaN(Number(value)) && value.toString().trim() !== '';
|
|
|
+ }
|
|
|
+};
|