|
|
|
|
@@ -21,6 +21,7 @@
|
|
|
|
|
<span class="entry-meta">{{ parseTime(activeReport.reportDate,'{y}-{m}-{d}') }} 投入{{ activeReport.inputWeight }}t 产出{{ activeReport.outputWeight }}t</span>
|
|
|
|
|
<el-button type="primary" size="mini" style="float:right;margin-left:8px" @click="saveGrid" :loading="saving">保存</el-button>
|
|
|
|
|
<el-button size="mini" style="float:right;margin-left:8px" @click="openColCfg">列配置</el-button>
|
|
|
|
|
<el-button size="mini" style="float:right;margin-left:8px" icon="el-icon-money" @click="openPriceMgr">价格管理</el-button>
|
|
|
|
|
<span style="float:right;margin-right:12px;font-size:12px;color:#606266;display:flex;align-items:center">
|
|
|
|
|
<span style="margin-right:4px">{{ inputMode ? '录入' : '查看' }}</span>
|
|
|
|
|
<el-switch v-model="inputMode" size="small" />
|
|
|
|
|
@@ -174,11 +175,14 @@
|
|
|
|
|
</template>
|
|
|
|
|
<el-tag size="mini" class="vars-tag var-sys" @click="defForm.metricFormula=(defForm.metricFormula||'')+'input_weight'">input_weight</el-tag>
|
|
|
|
|
<el-tag size="mini" class="vars-tag var-sys" @click="defForm.metricFormula=(defForm.metricFormula||'')+'output_weight'">output_weight</el-tag>
|
|
|
|
|
<el-tag size="mini" class="vars-tag var-price" @click="defForm.metricFormula=(defForm.metricFormula||'')+'price'">price(价格)</el-tag>
|
|
|
|
|
<template v-for="c in allCols.filter(x=>x.$type==='metric'&&x.metricName)">
|
|
|
|
|
<el-tag :key="'v'+c.metricName" size="mini" class="vars-tag var-mtr" @click="defForm.metricFormula=(defForm.metricFormula||'')+'@{'+c.metricName+'}'">{{ c.metricName }}</el-tag>
|
|
|
|
|
</template>
|
|
|
|
|
</div>
|
|
|
|
|
<el-form-item label="单位"><el-input v-model="defForm.unit" placeholder="如 %" /></el-form-item>
|
|
|
|
|
<el-form-item label="使用单价"><el-switch v-model="defForm.usePrice" :active-value="1" :inactive-value="0" /></el-form-item>
|
|
|
|
|
<el-form-item label="单价"><el-input v-model="defForm.metricValue" type="number" placeholder="请输入单价" /></el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<div slot="footer">
|
|
|
|
|
<el-button type="primary" @click="submitMetricDef">确 定</el-button>
|
|
|
|
|
@@ -187,6 +191,24 @@
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
<!-- Price management -->
|
|
|
|
|
<el-dialog title="价格管理" :visible.sync="priceOpen" width="650px" top="5vh" append-to-body>
|
|
|
|
|
<el-table :data="priceList" border stripe size="mini">
|
|
|
|
|
<el-table-column label="指标名称" prop="metricName" width="150" />
|
|
|
|
|
<el-table-column label="公式" prop="metricFormula" min-width="180" show-overflow-tooltip />
|
|
|
|
|
<el-table-column label="单价" width="180" align="center">
|
|
|
|
|
<template slot-scope="s">
|
|
|
|
|
<el-input v-model="s.row.metricValue" type="number" size="mini" style="width:150px" />
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
<el-empty v-if="!priceList.length" description="暂无非使用单价的指标" />
|
|
|
|
|
<div slot="footer">
|
|
|
|
|
<el-button type="primary" @click="savePrices" :loading="priceSaving">保存</el-button>
|
|
|
|
|
<el-button @click="priceOpen=false">取消</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
<!-- Copy config -->
|
|
|
|
|
<el-dialog title="从已有报表复制配置" :visible.sync="copyCfgOpen" width="550px" append-to-body>
|
|
|
|
|
<el-table :data="copyReports" border stripe size="mini" highlight-current-row @current-change="copySrc=$event">
|
|
|
|
|
@@ -365,7 +387,8 @@ export default {
|
|
|
|
|
lineOptions: [],
|
|
|
|
|
lineType: null,
|
|
|
|
|
noLineType: false,
|
|
|
|
|
inputMode: false
|
|
|
|
|
inputMode: false,
|
|
|
|
|
priceOpen: false, priceList: [], priceSaving: false
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
@@ -511,7 +534,7 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
doPickMetric() {
|
|
|
|
|
this.selMp.forEach(m => {
|
|
|
|
|
this.allCols.push({ $type: 'metric', metricId: m.metricId, metricName: m.metricName, metricFormula: m.metricFormula, unit: m.remark||'', isShift: false, color: null })
|
|
|
|
|
this.allCols.push({ $type: 'metric', metricId: m.metricId, metricName: m.metricName, metricFormula: m.metricFormula, unit: m.remark||'', isShift: false, color: null, metricValue: m.metricValue, usePrice: m.usePrice })
|
|
|
|
|
})
|
|
|
|
|
this.metricPickOpen = false
|
|
|
|
|
},
|
|
|
|
|
@@ -521,15 +544,15 @@ export default {
|
|
|
|
|
this.mgrList = this._allMetricDefs || []
|
|
|
|
|
this.mgrOpen = true
|
|
|
|
|
},
|
|
|
|
|
addMetricDef() { this.defForm = { metricId: null, metricName: '', metricFormula: '', unit: '' }; this.defTitle = '新增指标'; this.defOpen = true },
|
|
|
|
|
editMetricDef(row) { this.defForm = { metricId: row.metricId, metricName: row.metricName, metricFormula: row.metricFormula, unit: row.remark||'' }; this.defTitle = '编辑指标'; this.defOpen = true },
|
|
|
|
|
addMetricDef() { this.defForm = { metricId: null, metricName: '', metricFormula: '', unit: '', usePrice: 0, metricValue: '' }; this.defTitle = '新增指标'; this.defOpen = true },
|
|
|
|
|
editMetricDef(row) { this.defForm = { metricId: row.metricId, metricName: row.metricName, metricFormula: row.metricFormula, unit: row.remark||'', usePrice: row.usePrice || 0, metricValue: row.metricValue || '' }; this.defTitle = '编辑指标'; this.defOpen = true },
|
|
|
|
|
async submitMetricDef() {
|
|
|
|
|
const f = this.defForm
|
|
|
|
|
if (!f.metricName) { this.$modal.msgWarning('请输入指标名称'); return }
|
|
|
|
|
if (f.metricId) {
|
|
|
|
|
await updateProdMetric({ metricId: f.metricId, metricName: f.metricName, metricFormula: f.metricFormula, remark: f.unit })
|
|
|
|
|
await updateProdMetric({ metricId: f.metricId, metricName: f.metricName, metricFormula: f.metricFormula, remark: f.unit, usePrice: f.usePrice, metricValue: f.metricValue || 0 })
|
|
|
|
|
} else {
|
|
|
|
|
await addProdMetric({ reportId: this.activeReport.reportId, metricCode: f.metricName, metricName: f.metricName, metricFormula: f.metricFormula, metricValue: 0, remark: f.unit || '' })
|
|
|
|
|
await addProdMetric({ reportId: this.activeReport.reportId, metricCode: f.metricName, metricName: f.metricName, metricFormula: f.metricFormula, metricValue: f.metricValue || 0, remark: f.unit || '', usePrice: f.usePrice })
|
|
|
|
|
}
|
|
|
|
|
this.defOpen = false; this.$modal.msgSuccess('保存成功')
|
|
|
|
|
await this.openMetricMgr()
|
|
|
|
|
@@ -542,6 +565,29 @@ export default {
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/* price management */
|
|
|
|
|
async openPriceMgr() {
|
|
|
|
|
await this.loadAllMetrics(this.activeReport.reportId)
|
|
|
|
|
this.priceList = (this._allMetricDefs || []).filter(m => m.usePrice == 1).map(m => ({
|
|
|
|
|
...m,
|
|
|
|
|
_originValue: m.metricValue
|
|
|
|
|
}))
|
|
|
|
|
this.priceOpen = true
|
|
|
|
|
},
|
|
|
|
|
async savePrices() {
|
|
|
|
|
this.priceSaving = true
|
|
|
|
|
try {
|
|
|
|
|
for (const m of this.priceList) {
|
|
|
|
|
if (m.metricValue !== m._originValue) {
|
|
|
|
|
await updateProdMetric({ metricId: m.metricId, metricValue: m.metricValue || 0 })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.priceOpen = false
|
|
|
|
|
this.$modal.msgSuccess('保存成功')
|
|
|
|
|
await this.loadAllMetrics(this.activeReport.reportId)
|
|
|
|
|
} finally { this.priceSaving = false }
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async saveColCfg() {
|
|
|
|
|
const rid = this.activeReport.reportId; this.colSaving = true
|
|
|
|
|
try {
|
|
|
|
|
@@ -549,7 +595,7 @@ export default {
|
|
|
|
|
for (const m of metricCols) {
|
|
|
|
|
if (!m.metricName) { this.$modal.msgWarning('存在空指标列'); return }
|
|
|
|
|
if (m.metricFormula) {
|
|
|
|
|
const testF = m.metricFormula.replace(/@\{[^}]+\}/g, '1').replace(/input_weight|output_weight/g, '1')
|
|
|
|
|
const testF = m.metricFormula.replace(/@\{[^}]+\}/g, '1').replace(/input_weight|output_weight|price/g, '1')
|
|
|
|
|
if (this.evalF(testF) === null) { this.$modal.msgError('指标 "' + m.metricName + '" 公式无效'); return }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -601,7 +647,7 @@ export default {
|
|
|
|
|
if (!def && c.id) {
|
|
|
|
|
try { const r = await getProdMetric(c.id); if (r.data) { def = r.data; this._allMetricDefs.push(def) } } catch(e) {}
|
|
|
|
|
}
|
|
|
|
|
if (def) cols.push({ $type: 'metric', metricId: def.metricId, metricName: def.metricName, metricFormula: def.metricFormula, unit: def.remark||'', isShift: !!c.s, color: c.c || null })
|
|
|
|
|
if (def) cols.push({ $type: 'metric', metricId: def.metricId, metricName: def.metricName, metricFormula: def.metricFormula, unit: def.remark||'', isShift: !!c.s, color: c.c || null, metricValue: def.metricValue, usePrice: def.usePrice })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.allCols = cols
|
|
|
|
|
@@ -649,7 +695,7 @@ export default {
|
|
|
|
|
f = f.replace(new RegExp('@\\{'+code+'\\}\\.甲班','g'), v).replace(new RegExp('@\\{'+code+'\\}\\.乙班','g'), v).replace(new RegExp('@\\{'+code+'\\}','g'), v)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
f = f.replace(/input_weight/g, rp.inputWeight||0).replace(/output_weight/g, rp.outputWeight||0)
|
|
|
|
|
f = f.replace(/input_weight/g, rp.inputWeight||0).replace(/output_weight/g, rp.outputWeight||0).replace(/price/g, (m.usePrice == 1) ? (m.metricValue || 0) : 0)
|
|
|
|
|
return this.evalF(f)
|
|
|
|
|
}
|
|
|
|
|
if (m.isShift) { row['mv'+m.mIdx+'_1']=ef('1'); row['mv'+m.mIdx+'_2']=ef('2') }
|
|
|
|
|
@@ -695,7 +741,7 @@ export default {
|
|
|
|
|
else if (sc.t === 'm') {
|
|
|
|
|
const sid = String(sc.id)
|
|
|
|
|
let def = this._allMetricDefs.find(m=>String(m.metricId)===sid)
|
|
|
|
|
if (def && !usedMids.has(sid)) { usedMids.add(sid); this.allCols.push({ $type:'metric', metricId:String(def.metricId), metricName:def.metricName, metricFormula:def.metricFormula, unit:def.remark||'', isShift:!!sc.s, color:sc.c||null }) }
|
|
|
|
|
if (def && !usedMids.has(sid)) { usedMids.add(sid); this.allCols.push({ $type:'metric', metricId:String(def.metricId), metricName:def.metricName, metricFormula:def.metricFormula, unit:def.remark||'', isShift:!!sc.s, color:sc.c||null, metricValue: def.metricValue, usePrice: def.usePrice }) }
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
this.copyCfgOpen = false; let mi = 0; this.allCols.forEach(c => { if (c.$type === 'metric') c.mIdx = mi++ })
|
|
|
|
|
@@ -778,6 +824,7 @@ export default {
|
|
|
|
|
.vars-tag:hover { opacity: 0.8; }
|
|
|
|
|
.var-sys { background: #ecf5ff; border-color: #d9ecff; color: #409eff; }
|
|
|
|
|
.var-mtr { background: #f0f9eb; border-color: #e1f3d8; color: #67c23a; }
|
|
|
|
|
.var-price { background: #fef0f0; border-color: #fbc4c4; color: #f56c6c; }
|
|
|
|
|
.drag-handle { cursor: grab; font-size: 14px; color: #909399; padding: 2px; display: inline-flex; align-items: center; }
|
|
|
|
|
.drag-handle:active { cursor: grabbing; }
|
|
|
|
|
.drag-handle:hover { color: #409eff; }
|
|
|
|
|
|