|
@@ -9,23 +9,21 @@ $(document).ready(function() {
|
|
|
pid: 'tree_pid',
|
|
|
order: 'tree_order',
|
|
|
level: 'tree_level',
|
|
|
+ isLeaf: 'tree_is_leaf',
|
|
|
+ fullPath: 'tree_full_path',
|
|
|
rootId: -1,
|
|
|
- autoExpand: 3,
|
|
|
- markExpandKey: 'bills-expand',
|
|
|
- markExpandSubKey: window.location.pathname.split('/')[2],
|
|
|
- calcFields: ['cur_tp', 'pre_tp', 'end_tp'],
|
|
|
};
|
|
|
this.spreadSetting = {
|
|
|
baseCols: [
|
|
|
- {title: '编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 70, formatter: '@'},
|
|
|
+ {title: '编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 230, formatter: '@', cellType: 'tree'},
|
|
|
{title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 185, formatter: '@'},
|
|
|
{title: '规格', colSpan: '1', rowSpan: '2', field: 'spec', hAlign: 0, width: 150, formatter: '@'},
|
|
|
{title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 50, formatter: '@', cellType: 'unit'},
|
|
|
{title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number'},
|
|
|
],
|
|
|
extraCols: [
|
|
|
- {title: '%s|数量', colSpan: '2|1', rowSpan: '1|1', field: '{%s}_qty{%d}', hAlign: 2, width: 60, type: 'Number', },
|
|
|
- {title: '|金额', colSpan: '|1', rowSpan: '|1', field: '{%s}_tp{%d}', hAlign: 2, width: 60, type: 'Number', },
|
|
|
+ {title: '%s|数量', colSpan: '2|1', rowSpan: '1|1', field: 'qty_{%d}', hAlign: 2, width: 60, type: 'Number', },
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'tp_{%d}', hAlign: 2, width: 60, type: 'Number', },
|
|
|
],
|
|
|
emptyRows: 3,
|
|
|
headRows: 2,
|
|
@@ -33,6 +31,19 @@ $(document).ready(function() {
|
|
|
defaultRowHeight: 21,
|
|
|
headerFont: '12px 微软雅黑',
|
|
|
font: '12px 微软雅黑',
|
|
|
+ readOnly: true,
|
|
|
+ };
|
|
|
+ this.spreadSetting.getColor = function (sheet, data, row, col, defaultColor) {
|
|
|
+ function checkDiffer(data) {
|
|
|
+ const fieldSufs = sheet.zh_setting.fieldSufs;
|
|
|
+ if (fieldSufs.length <= 1) return false;
|
|
|
+ const base = data['qty_' + fieldSufs[0]];
|
|
|
+ for (let i = 1; i< fieldSufs.length; i++) {
|
|
|
+ const compare = data['qty_' + fieldSufs[i]];
|
|
|
+ if ((base || compare) && (compare!== base)) return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return checkDiffer(data) ? spreadColor.safe.differ : defaultColor;
|
|
|
};
|
|
|
this.tree = createNewPathTree('ledger', this.treeSetting);
|
|
|
this.ckBillsSpread = window.location.pathname + '-billsSelect';
|
|
@@ -41,19 +52,59 @@ $(document).ready(function() {
|
|
|
}
|
|
|
refreshSpreadSetting(roles) {
|
|
|
this.spreadSetting.cols = [];
|
|
|
+ this.spreadSetting.fieldSufs = [];
|
|
|
for (const col of this.spreadSetting.baseCols) {
|
|
|
this.spreadSetting.cols.push(col);
|
|
|
}
|
|
|
- // todo 根据参与审批的人加载数据
|
|
|
+ for (const role of roles) {
|
|
|
+ this.spreadSetting.fieldSufs.push(role.order);
|
|
|
+ for (const ec of this.spreadSetting.extraCols) {
|
|
|
+ const col = JSON.parse(JSON.stringify(ec));
|
|
|
+ col.title = _.replace(col.title, '%s', role.name);
|
|
|
+ col.field = _.replace(col.field, '{%d}', role.order);
|
|
|
+ this.spreadSetting.cols.push(col);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
initSpread(roles = []) {
|
|
|
this.refreshSpreadSetting(roles);
|
|
|
SpreadJsObj.initSheet(this.sheet, this.spreadSetting);
|
|
|
}
|
|
|
- loadData(datas, roles, history) {
|
|
|
+ analysisCompareData(datas, roles){
|
|
|
+ const findHis = function (role, history) {
|
|
|
+ let his = null;
|
|
|
+ for (const h of history) {
|
|
|
+ if (h.times < role.times || (h.times === role.times && h.order <= role.order)) {
|
|
|
+ his = h;
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return his;
|
|
|
+ };
|
|
|
+ for (const d of datas) {
|
|
|
+ if (!d.tree_is_leaf) continue;
|
|
|
+ d.cur_his.sort((x, y) => { return x.times === y.times ? x.order - y.order : x.times - y.times; });
|
|
|
+ for (const r of roles) {
|
|
|
+ if (r.latest) {
|
|
|
+ d[`qty_${r.order}`] = d.cur_qty;
|
|
|
+ d[`tp_${r.order}`] = d.cur_tp;
|
|
|
+ } else {
|
|
|
+ const rHis = findHis(r, d.cur_his);
|
|
|
+ if (rHis) {
|
|
|
+ d[`qty_${r.order}`] = rHis.qty;
|
|
|
+ d[`tp_${r.order}`] = rHis.tp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ loadData(datas, roles) {
|
|
|
// todo 整理数据
|
|
|
this.initSpread(roles);
|
|
|
+ this.analysisCompareData(datas, roles);
|
|
|
this.tree.loadDatas(datas);
|
|
|
+ this.tree.setting.calcFields = roles.map(x => { return `tp_${x.order}`});
|
|
|
treeCalc.calculateAll(this.tree);
|
|
|
SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Tree, this.tree);
|
|
|
SpreadJsObj.loadTopAndSelect(this.sheet, this.ckBillsSpread);
|
|
@@ -62,8 +113,8 @@ $(document).ready(function() {
|
|
|
const billsObj = new BillsObj();
|
|
|
|
|
|
// 加载安全生产费数据
|
|
|
- postData('load', { filter: 'bills;audit;history' }, function(result) {
|
|
|
- billsObj.loadData(result.bills);
|
|
|
+ postData('load', { filter: 'billsCompare;auditFlow' }, function(result) {
|
|
|
+ billsObj.loadData(result.billsCompare, result.auditFlow);
|
|
|
});
|
|
|
|
|
|
// 导航Menu
|