|
|
@@ -260,19 +260,18 @@ $(document).ready(() => {
|
|
|
SpreadJsObj.initSheet(previewSheet, previewSpreadSetting);
|
|
|
const qtyCol = previewSpreadSetting.cols.find(x => { return x.field === 'qty'; });
|
|
|
if (qtyCol) {
|
|
|
- previewData.forEach(x => {
|
|
|
- let calcExpr = qtyCol.expr;
|
|
|
- previewSpreadSetting.cols.forEach(c => {
|
|
|
- if (c.type !== 'Number' || c.field === 'qty') return;
|
|
|
- calcExpr = calcExpr.replace(new RegExp(c.field, 'gm'), x[c.field]);
|
|
|
- });
|
|
|
- x.calc_expr = calcExpr;
|
|
|
+ for (const pd of previewData) {
|
|
|
+ pd.calcExpr = qtyCol.expr;
|
|
|
+ for (const col of previewSpreadSetting.cols) {
|
|
|
+ if (col.type !== 'Number' || col.field === 'qty') continue;
|
|
|
+ pd.calcExpr = pd.calcExpr.replace(new RegExp(col.field, 'gm'), pd[col.field]);
|
|
|
+ }
|
|
|
try {
|
|
|
- x.qty = ZhCalc.round(ZhCalc.mathCalcExpr(calcExpr.replace(new RegExp('%', 'gm'), '/100')), qtyCol.decimal);
|
|
|
- } catch {
|
|
|
- x.qty = 0;
|
|
|
+ pd.qty = ZhCalc.round(ZhCalc.mathCalcExpr(pd.calcExpr.replace(new RegExp('%', 'gm'), '/100')), qtyCol.decimal);
|
|
|
+ } catch(err) {
|
|
|
+ pd.qty = 0;
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
SpreadJsObj.loadSheetData(previewSheet, SpreadJsObj.DataType.Data, previewData);
|
|
|
});
|
|
|
@@ -291,16 +290,9 @@ $(document).ready(() => {
|
|
|
let curTemplate;
|
|
|
|
|
|
const loadTemplateDetail = async function(template) {
|
|
|
- const result = await postDataAsync('load', { filter: 'detail', id: template.id, type: 'posCalc' });
|
|
|
+ const result = await postDataAsync('load', {filter: 'detail', id: template.id, type: 'posCalc'});
|
|
|
if (result && result.detail) template.col_set = result.detail.col_set;
|
|
|
- // template.col_set = [
|
|
|
- // { title: '名称', width: 80, type: 'str', field: 'str1' },
|
|
|
- // { title: '长度', width: 80, type: 'num', field: 'num1', decimal: 2, unit: 'm', calc_code: 'A' },
|
|
|
- // { title: '宽度', width: 80, type: 'num', field: 'num2', decimal: 2, unit: 'm', calc_code: 'B' },
|
|
|
- // { title: '高度', width: 80, type: 'num', field: 'num3', decimal: 2, unit: 'm', calc_code: 'C' },
|
|
|
- // { title: '数量', width: 80, type: 'qty', field: 'qty', decimal: 2, expr: 'A*B*C' },
|
|
|
- // ];
|
|
|
- };
|
|
|
+ }
|
|
|
const refreshTemplate = async function() {
|
|
|
if (!curTemplate) {
|
|
|
// todo 隐藏模板详细界面
|