|
|
@@ -448,6 +448,43 @@
|
|
|
<div style="margin-top:5px;">
|
|
|
<p v-for="nv in calc.rsp.nvList" :key="nv.name">{{ nv.name }} 摄入:{{ nv.nvIn }}{{ nv.nvUnit }}, ({{ nv.nv }}{{ nv.nvUnit }}/{{ nv.nvSpec }}{{ nv.nvSpecUnit }})</p>
|
|
|
</div>
|
|
|
+
|
|
|
+ <div style="margin-top:5px;">
|
|
|
+ <el-input v-model="cf.req.fromAmt" placeholder="源单位数量" style="width:100px;margin-right:10px;" />
|
|
|
+ <DataSelect
|
|
|
+ url="/api/units"
|
|
|
+ placeholder="源单位"
|
|
|
+ :value.sync="cf.req.fromUnitId"
|
|
|
+ :label.sync="cf.req.fromUnit"
|
|
|
+ :initOptions="dlg.form.modifierUnitOptions"
|
|
|
+ width="110px"
|
|
|
+ />
|
|
|
+ -
|
|
|
+ <DataSelect
|
|
|
+ url="/api/units"
|
|
|
+ placeholder="目标单位"
|
|
|
+ :value.sync="cf.req.toUnitId"
|
|
|
+ :label.sync="cf.req.toUnit"
|
|
|
+ :initOptions="dlg.form.modifierUnitOptions"
|
|
|
+ width="110px"
|
|
|
+ />
|
|
|
+ <el-button :loading="cf.loading" size="mini" type="success" style="margin-left:15px;" @click="calcCf">计算转换</el-button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div>
|
|
|
+ <span v-if="!!cf.rsp.error">
|
|
|
+ {{ cf.rsp.error }}
|
|
|
+ </span>
|
|
|
+ <span v-else-if="cf.rsp.steps.length>0">
|
|
|
+ <div style="margin-bottom:5px;">
|
|
|
+ {{ cf.rsp.fromAmt }}{{ cf.rsp.fromUnit }} * {{ cf.rsp.cf }} = {{ cf.rsp.toAmt }}{{ cf.rsp.toUnit }}
|
|
|
+ </div>
|
|
|
+ <div v-for="step in cf.rsp.steps" :key="step.convert.fromUnit" style="margin-bottom:5px;">
|
|
|
+ 【1{{ step.convert.fromUnit }} * {{ step.convert.cf }} = 1{{ step.convert.toUnit }},{{ step.cf }}】
|
|
|
+ {{ step.fromAmt }}{{ step.convert.fromUnit }} * {{ step.convert.cf }} = {{ step.toAmt }}{{ step.convert.toUnit }}
|
|
|
+ </div>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
</el-tab-pane>
|
|
|
</el-tabs>
|
|
|
</el-form>
|
|
|
@@ -523,6 +560,19 @@ export default {
|
|
|
nvList: []
|
|
|
}
|
|
|
},
|
|
|
+ cf: {
|
|
|
+ loading: false,
|
|
|
+ req: {
|
|
|
+ fromAmt: undefined,
|
|
|
+ fromUnitId: undefined,
|
|
|
+ fromUnit: undefined,
|
|
|
+ toUnitId: undefined,
|
|
|
+ toUnit: undefined
|
|
|
+ },
|
|
|
+ rsp: {
|
|
|
+ steps: []
|
|
|
+ }
|
|
|
+ },
|
|
|
dlg: {
|
|
|
form: {
|
|
|
infoTab: 'base',
|
|
|
@@ -708,6 +758,15 @@ export default {
|
|
|
this.calc.loading = false
|
|
|
})
|
|
|
},
|
|
|
+ // 计算单位转换
|
|
|
+ calcCf() {
|
|
|
+ this.cf.loading = true
|
|
|
+ fPost(`/api/foods/${this.dlg.form.data.id}/unit-cf`, this.cf.req).then(res => {
|
|
|
+ this.cf.rsp = res
|
|
|
+ }).finally(() => {
|
|
|
+ this.cf.loading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
// 刷新 CF
|
|
|
refreshCf() {
|
|
|
fGet(`/api/foods/${this.dlg.form.data.id}/cfs`).then(res => {
|