123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- const sjsSettingObj = (function () {
- const FxTreeStyle = {
- jz: 'jianzhu',
- };
- const setJzFxTreeStyle = function (setting) {
- setting.selectedBackColor = '#fffacd';
- setting.tree = {
- getFont: function (sheet, data, row, col, defaultFont) {
- if (sheet.zh_tree && data.level === 1) {
- return 'bold ' + defaultFont;
- } else {
- return defaultFont;
- }
- },
- getColor: function (sheet, data, row, col, defaultColor) {
- if (sheet.zh_tree) {
- if (data.level === 2) {
- return '#C4CAFB';
- } else if ((!data.b_code || data.b_code === '') && data.level > 2) {
- return '#DFE8F9';
- } else {
- return defaultColor;
- }
- } else {
- return defaultColor;
- }
- }
- }
- };
- const setFxTreeStyle = function (setting, tag) {
- switch (tag) {
- case FxTreeStyle.jz:
- setJzFxTreeStyle(setting);
- break;
- }
- };
- const setGridSelectStyle = function (setting) {
- setting.selectedBackColor = '#fffacd';
- };
- const setTpThousandthFormat = function (setting, fields = []) {
- for (const col of setting.cols) {
- if (col.field === 'total_price' || col.field.indexOf('tp') >= 0 || fields.indexOf(col.field) >= 0)
- col.formatter = '#,##0.######';
- }
- };
- const setThousandthFormat = function (setting, fields) {
- for (const f of fields) {
- const col = setting.cols.find(function (x) {
- return x.field === f
- });
- if (col) col.formatter = '#,##0.######';
- }
- };
- const setTpColsThousandthFormat = function (cols, fields = []) {
- for (const col of cols) {
- if (col.field === 'total_price' || col.field.indexOf('tp') >= 0 || fields.indexOf(col.field) >= 0)
- col.formatter = '#,##0.######';
- }
- };
- const setPropValue = function (setting, fields, prop, value) {
- for (const f of fields) {
- const col = setting.cols.find(function (x) {
- return x.field === f
- });
- if (col) col[prop] = value;
- }
- };
- const set3FCols = function (cols, rela) {
- for (const r of rela) {
- const col = _.find(cols, {field: r.field});
- if (col) {
- col.getValue = r.getValue;
- col.cellType = 'imageBtn';
- col.normalImg = '#rela-file-icon';
- col.indent = 12;
- col.imgAlign = 2;
- col.showImage = function (data) { return data && data[r.url_field]; }
- }
- }
- };
- const setQcCols = function (cols, rela){
- for (const r of rela) {
- const col = _.find(cols, {field: r.field});
- if (!col) continue;
- col.readOnly = true;
- col.cellType = 'activeImageBtn';
- col.normalImg = '#ellipsis-icon';
- col.indent = 5;
- col.showImage = r.showImage;
- }
- };
- const setOrgPriceCol = function (cols, rela) {
- for (const r of rela) {
- const col = _.find(cols, {field: r.field});
- if (col) {
- col.getValue = function (data) { return data.contract_pc_tp || data.qc_pc_tp || data.pc_tp ? data.org_price : null; };
- }
- }
- };
- const setNodeTypeCol = function (cols, rela) {
- for (const r of rela) {
- const col = _.find(cols, {field: r.field});
- if (col) {
- col.comboItems = nodeType;
- col.cellType = 'specCombo';
- col.comboEdit = function (sheet, data) {
- if (!data) return false;
- const tree = sheet.zh_tree;
- if (!tree) return false;
- const parent = tree.getParent(data);
- if (!parent) return false;
- const topParent = tree.getTopParent(data);
- return [1, 5].indexOf(topParent.node_type) >= 0;
- };
- }
- }
- };
- return {
- setFxTreeStyle, FxTreeStyle, setGridSelectStyle,
- setTpThousandthFormat, setThousandthFormat, setTpColsThousandthFormat,
- setPropValue, set3FCols, setQcCols, setOrgPriceCol, setNodeTypeCol,
- };
- })();
|