|
@@ -22,23 +22,41 @@ const BatchImportStageGcl = function (setting) {
|
|
|
|
|
|
const items = getItems(data);
|
|
const items = getItems(data);
|
|
const cellType = new spreadNS.CellTypes.ComboBox().itemHeight(10).editorValueType(spreadNS.CellTypes.EditorValueType.value).items(items);
|
|
const cellType = new spreadNS.CellTypes.ComboBox().itemHeight(10).editorValueType(spreadNS.CellTypes.EditorValueType.value).items(items);
|
|
- biObj.sheet.getCell(i, 2).cellType(cellType);
|
|
|
|
|
|
+ biObj.sheet.getCell(i, 3).cellType(cellType);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- trEditEnded: function (e, info) {
|
|
|
|
|
|
+ EditEnded: function (e, info) {
|
|
const data = SpreadJsObj.getSelectObject(info.sheet);
|
|
const data = SpreadJsObj.getSelectObject(info.sheet);
|
|
const col = info.sheet.zh_setting.cols[info.col];
|
|
const col = info.sheet.zh_setting.cols[info.col];
|
|
data[col.field] = info.sheet.getValue(info.row, info.col);
|
|
data[col.field] = info.sheet.getValue(info.row, info.col);
|
|
},
|
|
},
|
|
|
|
+ ButtonClicked: function (e, info) {
|
|
|
|
+ if (!info.sheet.zh_setting) return;
|
|
|
|
+
|
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
|
+ if (col.field !== 'selected') return;
|
|
|
|
+
|
|
|
|
+ const node = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
|
+ const newValue = !node.selected;
|
|
|
|
+ const parent = node.lid ? node : info.sheet.zh_tree.getParent(node);
|
|
|
|
+ parent.selected = newValue;
|
|
|
|
+ if (parent.children && parent.children.length > 0) {
|
|
|
|
+ for (const child of parent.children) {
|
|
|
|
+ child.selected = newValue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.sheet.zh_tree.getNodeIndex(parent), parent.children.length + 1);
|
|
|
|
+ },
|
|
reloadBatchTree() {
|
|
reloadBatchTree() {
|
|
this.batchTree.clearDatas();
|
|
this.batchTree.clearDatas();
|
|
for (const h of this.history) {
|
|
for (const h of this.history) {
|
|
if (!h.ledger_node) continue;
|
|
if (!h.ledger_node) continue;
|
|
|
|
|
|
- const ledgerData = { lid: h.lid, ledger_id: h.ledger_node.ledger_id, code: h.ledger_node.code, name: h.ledger_node.name, ledger_node: h.ledger_node };
|
|
|
|
|
|
+ const ledgerData = { lid: h.lid, ledger_id: h.ledger_node.ledger_id, code: h.ledger_node.code, name: h.ledger_node.name, ledger_node: h.ledger_node, selected: h.tenders.length > 0 };
|
|
const batchNode = this.batchTree.addNode(ledgerData, null);
|
|
const batchNode = this.batchTree.addNode(ledgerData, null);
|
|
for (const t of h.tenders) {
|
|
for (const t of h.tenders) {
|
|
const tenderData = JSON.parse(JSON.stringify(t));
|
|
const tenderData = JSON.parse(JSON.stringify(t));
|
|
|
|
+ tenderData.selected = true;
|
|
const tender = this.tenderSourceTree.nodes.find(y => { return y.tid === t.tid });
|
|
const tender = this.tenderSourceTree.nodes.find(y => { return y.tid === t.tid });
|
|
tenderData.stageCount = tender.stageCount;
|
|
tenderData.stageCount = tender.stageCount;
|
|
this.batchTree.addNode(tenderData, batchNode);
|
|
this.batchTree.addNode(tenderData, batchNode);
|
|
@@ -74,11 +92,10 @@ const BatchImportStageGcl = function (setting) {
|
|
this.sheet = this.spread.getActiveSheet();
|
|
this.sheet = this.spread.getActiveSheet();
|
|
SpreadJsObj.initSheet(this.sheet, {
|
|
SpreadJsObj.initSheet(this.sheet, {
|
|
cols: [
|
|
cols: [
|
|
- // {title: '选择', field: 'selected', hAlign: 1, width: 40, formatter: '@', cellType: 'checkbox'},
|
|
|
|
|
|
+ {title: '选择', field: 'selected', hAlign: 1, width: 40, formatter: '@', cellType: 'checkbox'},
|
|
{title: '编号', field: 'code', hAlign: 0, width: 180, formatter: '@', cellType: 'tree'},
|
|
{title: '编号', field: 'code', hAlign: 0, width: 180, formatter: '@', cellType: 'tree'},
|
|
{title: '名称/引用标段', field: 'name', hAlign: 0, width: 180, formatter: '@'},
|
|
{title: '名称/引用标段', field: 'name', hAlign: 0, width: 180, formatter: '@'},
|
|
{title: '可选期', field: 'stage', hAlign: 1, width: 60, formatter: '@'},
|
|
{title: '可选期', field: 'stage', hAlign: 1, width: 60, formatter: '@'},
|
|
- // {title: '覆盖数据', field: 'is_cover', hAlign: 1, width: 60, cellType: 'checkbox'},
|
|
|
|
{title: '状态', field: 'status', hAlign: 1, width: 60, formatter: '@'},
|
|
{title: '状态', field: 'status', hAlign: 1, width: 60, formatter: '@'},
|
|
{title: '错误信息', field: 'error', hAlign: 1, width: 60, formatter: '@'},
|
|
{title: '错误信息', field: 'error', hAlign: 1, width: 60, formatter: '@'},
|
|
],
|
|
],
|
|
@@ -90,7 +107,8 @@ const BatchImportStageGcl = function (setting) {
|
|
font: '12px 微软雅黑',
|
|
font: '12px 微软雅黑',
|
|
selectedBackColor: '#fffacd',
|
|
selectedBackColor: '#fffacd',
|
|
});
|
|
});
|
|
- this.spread.bind(spreadNS.Events.EditEnded, biObj.trEditEnded);
|
|
|
|
|
|
+ this.spread.bind(spreadNS.Events.EditEnded, biObj.EditEnded);
|
|
|
|
+ this.spread.bind(spreadNS.Events.ButtonClicked, biObj.ButtonClicked);
|
|
|
|
|
|
this.batchTree = createNewPathTree('gather', {
|
|
this.batchTree = createNewPathTree('gather', {
|
|
id: 'id',
|
|
id: 'id',
|
|
@@ -100,6 +118,7 @@ const BatchImportStageGcl = function (setting) {
|
|
rootId: -1,
|
|
rootId: -1,
|
|
fullPath: 'full_path',
|
|
fullPath: 'full_path',
|
|
});
|
|
});
|
|
|
|
+ this.loadHistory();
|
|
},
|
|
},
|
|
checkErrors: function () {
|
|
checkErrors: function () {
|
|
const hasError = this.batchTree.children.findIndex(x => { return x.error > 0; }) >= 0;
|
|
const hasError = this.batchTree.children.findIndex(x => { return x.error > 0; }) >= 0;
|
|
@@ -120,24 +139,37 @@ const BatchImportStageGcl = function (setting) {
|
|
node.errors = result.sumLoadHis.errors;
|
|
node.errors = result.sumLoadHis.errors;
|
|
node.error = node.errors ? node.errors.length : 0;
|
|
node.error = node.errors ? node.errors.length : 0;
|
|
},
|
|
},
|
|
|
|
+ beforeBatchImport: function () {
|
|
|
|
+ this.batchTree.children.forEach(x => {
|
|
|
|
+ x.status = x.selected ? '等待中' : '';
|
|
|
|
+ x.error = 0;
|
|
|
|
+ x.errors = [];
|
|
|
|
+ });
|
|
|
|
+ SpreadJsObj.reloadColData(this.sheet, 4, 2);
|
|
|
|
+ },
|
|
batchImport: async function () {
|
|
batchImport: async function () {
|
|
$('#bi-start')[0].disabled = true;
|
|
$('#bi-start')[0].disabled = true;
|
|
biObj.batching = true;
|
|
biObj.batching = true;
|
|
|
|
+ this.beforeBatchImport();
|
|
const cover = $('#bi-cover')[0].checked;
|
|
const cover = $('#bi-cover')[0].checked;
|
|
for (const node of this.batchTree.children) {
|
|
for (const node of this.batchTree.children) {
|
|
- if (!node.children || node.children.length === 0) continue;
|
|
|
|
|
|
+ if (!node.selected) continue;
|
|
|
|
+
|
|
const row = this.batchTree.getNodeIndex(node);
|
|
const row = this.batchTree.getNodeIndex(node);
|
|
- try {
|
|
|
|
- node.status = '开始导入';
|
|
|
|
- SpreadJsObj.reLoadRowData(biObj.sheet, row);
|
|
|
|
- await biObj.importStageGcl(node, cover);
|
|
|
|
- node.status = '导入完成';
|
|
|
|
- SpreadJsObj.reLoadRowData(biObj.sheet, row);
|
|
|
|
- } catch(err) {
|
|
|
|
- console.log(err);
|
|
|
|
- node.status = '导入失败';
|
|
|
|
- SpreadJsObj.reLoadRowData(biObj.sheet, row);
|
|
|
|
|
|
+ if (!node.children || node.children.length === 0) {
|
|
|
|
+ node.status = '无数据';
|
|
|
|
+ } else {
|
|
|
|
+ try {
|
|
|
|
+ node.status = '开始导入';
|
|
|
|
+ SpreadJsObj.reLoadRowData(biObj.sheet, row);
|
|
|
|
+ await biObj.importStageGcl(node, cover);
|
|
|
|
+ node.status = '导入完成';
|
|
|
|
+ } catch(err) {
|
|
|
|
+ console.log(err);
|
|
|
|
+ node.status = '导入失败';
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ SpreadJsObj.reLoadRowData(biObj.sheet, row);
|
|
}
|
|
}
|
|
biObj.batching = false;
|
|
biObj.batching = false;
|
|
$('#bi-start')[0].disabled = false;
|
|
$('#bi-start')[0].disabled = false;
|
|
@@ -191,7 +223,7 @@ const BatchImportStageGcl = function (setting) {
|
|
|
|
|
|
$('#batch-import').on('shown.bs.modal', () => {
|
|
$('#batch-import').on('shown.bs.modal', () => {
|
|
biObj.initBatchImport();
|
|
biObj.initBatchImport();
|
|
- biObj.loadHistory();
|
|
|
|
|
|
+ // biObj.loadHistory();
|
|
});
|
|
});
|
|
|
|
|
|
$('#bi-start').click(function () {
|
|
$('#bi-start').click(function () {
|