|
@@ -0,0 +1,114 @@
|
|
|
+/**
|
|
|
+ * 机械单价相关
|
|
|
+ *
|
|
|
+ * @author CaiAoLin
|
|
|
+ * @date 2017/7/17
|
|
|
+ * @version
|
|
|
+ */
|
|
|
+let machineHeader = [];
|
|
|
+let machineSheet = null;
|
|
|
+let machineSpread = null;
|
|
|
+$(document).ready(function() {
|
|
|
+
|
|
|
+ initMachineExcel();
|
|
|
+
|
|
|
+ $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
|
|
+ currentTag = $(e.target).data('name');
|
|
|
+
|
|
|
+ // 获取工料机当前选中的行号
|
|
|
+ let projectGLJId = 0;
|
|
|
+ if (currentTag === "machine" && machineSpread !== null) {
|
|
|
+ // 筛选数据显示(显示普通机械)
|
|
|
+ filterDataByType([GLJTypeConst.GENERAL_MACHINE]);
|
|
|
+
|
|
|
+ // 获取数据
|
|
|
+ getRatioData(projectGLJId, getMachine);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+/**
|
|
|
+ * 初始化excel
|
|
|
+ *
|
|
|
+ * @return {void}
|
|
|
+ */
|
|
|
+function initMachineExcel() {
|
|
|
+ machineHeader = [
|
|
|
+ {name: '编码', field: 'code', visible: true},
|
|
|
+ {name: '名称', field: 'name', visible: true},
|
|
|
+ {name: '单位', field: 'unit_price.unit', visible: true},
|
|
|
+ {name: 'ID', field: 'id', visible: false},
|
|
|
+ {name: '类型', field: 'unit_price.type', visible: false},
|
|
|
+ {name: '基价单价', field: "unit_price.base_price", visible: true},
|
|
|
+ {name: '调整基价', field: 'adjust_price', visible: true},
|
|
|
+ {name: '市场单价', field: "unit_price.market_price", visible: true},
|
|
|
+ {name: '用量', field: 'consumption', visible: true, validator: 'number'},
|
|
|
+ {name: 'CID', field: 'mix_ratio_id', visible: false},
|
|
|
+ ];
|
|
|
+
|
|
|
+ let setting = {
|
|
|
+ header: []
|
|
|
+ };
|
|
|
+ let columnInfo = [];
|
|
|
+ for(let tmp of machineHeader) {
|
|
|
+ setting.header.push({headerName: tmp.name, headerWidth: 120});
|
|
|
+ columnInfo.push({name: tmp.field, displayName: tmp.name, visible: tmp.visible, cellType: tmp.cellType, size: 120});
|
|
|
+ }
|
|
|
+
|
|
|
+ machineSpread = sheetCommonObj.buildSheet(document.getElementById("machine"), setting, 3);
|
|
|
+ machineSpread.options.scrollbarShowMax = true;
|
|
|
+ machineSpread.options.scrollbarMaxAlign = true;
|
|
|
+ machineSpread.options.showHorizontalScrollbar = true;
|
|
|
+ machineSheet = machineSpread.getActiveSheet();
|
|
|
+
|
|
|
+ // 编码列号
|
|
|
+ let codeColumn = getFieldColumn(machineHeader, 'code');
|
|
|
+ // 单位列号
|
|
|
+ let unitColumn = getFieldColumn(machineHeader, 'unit_price.unit');
|
|
|
+ // 消耗量列号
|
|
|
+ let consumptionColumn = getFieldColumn(machineHeader, 'consumption');
|
|
|
+
|
|
|
+ // 居中样式
|
|
|
+ let centerStyleSetting = {hAlign: 1};
|
|
|
+ machineSheet.setStyle(-1, codeColumn, getStyle(centerStyleSetting), GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ machineSheet.setStyle(-1, unitColumn, getStyle(centerStyleSetting), GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+
|
|
|
+ // 设置表单不可编辑
|
|
|
+ machineSheet.options.isProtected = true;
|
|
|
+
|
|
|
+ // 设置可编辑列
|
|
|
+ machineSheet.getRange(-1, consumptionColumn, -1, 1).locked(false);
|
|
|
+
|
|
|
+ // 绑定数据格式
|
|
|
+ machineSheet.autoGenerateColumns = false;
|
|
|
+ machineSheet.bindColumns(columnInfo);
|
|
|
+
|
|
|
+ // 绑定事件
|
|
|
+ // machineSheet.bind(GC.Spread.Sheets.Events.ValueChanged, updateConsumption);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取对应的机械单价成功后方法
|
|
|
+ *
|
|
|
+ * @param {Object} response
|
|
|
+ * @return {void|boolean}
|
|
|
+ */
|
|
|
+function getMachine(response, type) {
|
|
|
+ switch (type) {
|
|
|
+ case 'success':
|
|
|
+ response.data = JSON.parse(response.data);
|
|
|
+ // 设置数据
|
|
|
+ machineSheet.setDataSource(response.data);
|
|
|
+ ratioSpecialColumn(response.data);
|
|
|
+ machineSpread.refresh();
|
|
|
+ break;
|
|
|
+ case 'fail':
|
|
|
+ // 设置数据
|
|
|
+ machineSheet.setDataSource(null);
|
|
|
+ machineSpread.refresh();
|
|
|
+ alert('不存在对应数据');
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|