|
@@ -3,35 +3,35 @@
|
|
|
<div class="filter-container">
|
|
<div class="filter-container">
|
|
|
From单位:
|
|
From单位:
|
|
|
<el-select
|
|
<el-select
|
|
|
|
|
+ ref="fromUnitSelect"
|
|
|
v-model="params.fromUnit"
|
|
v-model="params.fromUnit"
|
|
|
filterable
|
|
filterable
|
|
|
reserve-keyword
|
|
reserve-keyword
|
|
|
style="width: 200px;margin-left: 10px;"
|
|
style="width: 200px;margin-left: 10px;"
|
|
|
placeholder="请输入单位关键词"
|
|
placeholder="请输入单位关键词"
|
|
|
- ref="fromUnitSelect"
|
|
|
|
|
>
|
|
>
|
|
|
<el-option
|
|
<el-option
|
|
|
v-for="item in units"
|
|
v-for="item in units"
|
|
|
:key="item.id"
|
|
:key="item.id"
|
|
|
:label="item.name"
|
|
:label="item.name"
|
|
|
- :value="item.id">
|
|
|
|
|
- </el-option>
|
|
|
|
|
|
|
+ :value="item.id"
|
|
|
|
|
+ />
|
|
|
</el-select>
|
|
</el-select>
|
|
|
To单位:
|
|
To单位:
|
|
|
<el-select
|
|
<el-select
|
|
|
|
|
+ ref="toUnitSelect"
|
|
|
v-model="params.toUnit"
|
|
v-model="params.toUnit"
|
|
|
filterable
|
|
filterable
|
|
|
reserve-keyword
|
|
reserve-keyword
|
|
|
style="width: 200px;margin-left: 10px;"
|
|
style="width: 200px;margin-left: 10px;"
|
|
|
placeholder="请输入单位关键词"
|
|
placeholder="请输入单位关键词"
|
|
|
- ref="toUnitSelect"
|
|
|
|
|
>
|
|
>
|
|
|
<el-option
|
|
<el-option
|
|
|
v-for="item in units"
|
|
v-for="item in units"
|
|
|
:key="item.id"
|
|
:key="item.id"
|
|
|
:label="item.name"
|
|
:label="item.name"
|
|
|
- :value="item.id">
|
|
|
|
|
- </el-option>
|
|
|
|
|
|
|
+ :value="item.id"
|
|
|
|
|
+ />
|
|
|
</el-select>
|
|
</el-select>
|
|
|
转换率:
|
|
转换率:
|
|
|
<el-input v-model="params.ratio" placeholder="1 FromUnit = * ToUnit" style="width: 200px" />
|
|
<el-input v-model="params.ratio" placeholder="1 FromUnit = * ToUnit" style="width: 200px" />
|
|
@@ -39,7 +39,8 @@
|
|
|
class="filter-item"
|
|
class="filter-item"
|
|
|
style="margin-left: 10px;"
|
|
style="margin-left: 10px;"
|
|
|
type="primary"
|
|
type="primary"
|
|
|
- @click="addFoodUnit">
|
|
|
|
|
|
|
+ @click="addFoodUnit"
|
|
|
|
|
+ >
|
|
|
添加
|
|
添加
|
|
|
</el-button>
|
|
</el-button>
|
|
|
</div>
|
|
</div>
|
|
@@ -69,7 +70,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100">
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100">
|
|
|
- <template slot-scope="{row,$index}">
|
|
|
|
|
|
|
+ <template slot-scope="{row}">
|
|
|
<el-button size="mini" type="danger" @click="removeFoodUnit(row)">
|
|
<el-button size="mini" type="danger" @click="removeFoodUnit(row)">
|
|
|
删除
|
|
删除
|
|
|
</el-button>
|
|
</el-button>
|
|
@@ -80,58 +81,58 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
- import { getBaseUnits } from '@/api/unit'
|
|
|
|
|
- import { getFoodUnits, createOrUpdateFoodUnit, removeFoodUnit } from '@/api/food'
|
|
|
|
|
|
|
+import { getBaseUnits } from '@/api/unit'
|
|
|
|
|
+import { getFoodUnits, createOrUpdateFoodUnit, removeFoodUnit } from '@/api/food'
|
|
|
|
|
|
|
|
- export default {
|
|
|
|
|
- name: 'FoodUnit',
|
|
|
|
|
- created() {
|
|
|
|
|
- this.foodId = this.$route.params && this.$route.params.id
|
|
|
|
|
- this.fetchBaseUnits()
|
|
|
|
|
- this.fetchData()
|
|
|
|
|
|
|
+export default {
|
|
|
|
|
+ name: 'FoodUnit',
|
|
|
|
|
+ data() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ units: [],
|
|
|
|
|
+ params: {},
|
|
|
|
|
+ listLoading: false,
|
|
|
|
|
+ list: []
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ created() {
|
|
|
|
|
+ this.foodId = this.$route.params && this.$route.params.id
|
|
|
|
|
+ this.fetchBaseUnits()
|
|
|
|
|
+ this.fetchData()
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ fetchBaseUnits() {
|
|
|
|
|
+ getBaseUnits().then(res => {
|
|
|
|
|
+ this.units = res.data.list
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ fetchData() {
|
|
|
|
|
+ getFoodUnits(this.foodId).then(res => {
|
|
|
|
|
+ this.list = res.data.list
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
- data() {
|
|
|
|
|
- return {
|
|
|
|
|
- units: [],
|
|
|
|
|
- params: {},
|
|
|
|
|
- listLoading: false,
|
|
|
|
|
- list: []
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ addFoodUnit() {
|
|
|
|
|
+ this.params.foodId = this.foodId
|
|
|
|
|
+ createOrUpdateFoodUnit(this.foodId, this.params).then(res => {
|
|
|
|
|
+ this.$message.success('提交成功')
|
|
|
|
|
+ this.$refs.fromUnitSelect.focus()
|
|
|
|
|
+ this.fetchData()
|
|
|
|
|
+ }).catch(res => {
|
|
|
|
|
+ this.$message.error(res.data.message)
|
|
|
|
|
+ this.fetchData()
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
- methods: {
|
|
|
|
|
- fetchBaseUnits() {
|
|
|
|
|
- getBaseUnits().then(res => {
|
|
|
|
|
- this.units = res.data.list
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- fetchData() {
|
|
|
|
|
- getFoodUnits(this.foodId).then(res => {
|
|
|
|
|
- this.list = res.data.list
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- addFoodUnit() {
|
|
|
|
|
- this.params.foodId = this.foodId
|
|
|
|
|
- createOrUpdateFoodUnit(this.foodId, this.params).then(res => {
|
|
|
|
|
- this.$message.success('提交成功')
|
|
|
|
|
- this.$refs.fromUnitSelect.focus()
|
|
|
|
|
- this.fetchData()
|
|
|
|
|
- }).catch(res => {
|
|
|
|
|
- this.$message.error(res.data.message)
|
|
|
|
|
- this.fetchData()
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- removeFoodUnit(row) {
|
|
|
|
|
- removeFoodUnit(this.foodId, row).then(res => {
|
|
|
|
|
- this.$message.success('提交成功')
|
|
|
|
|
- this.fetchData()
|
|
|
|
|
- this.$refs.fromUnitSelect.focus()
|
|
|
|
|
- }).catch(res => {
|
|
|
|
|
- this.$message.error(res.data.message)
|
|
|
|
|
- this.fetchData()
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ removeFoodUnit(row) {
|
|
|
|
|
+ removeFoodUnit(this.foodId, row).then(res => {
|
|
|
|
|
+ this.$message.success('提交成功')
|
|
|
|
|
+ this.fetchData()
|
|
|
|
|
+ this.$refs.fromUnitSelect.focus()
|
|
|
|
|
+ }).catch(res => {
|
|
|
|
|
+ this.$message.error(res.data.message)
|
|
|
|
|
+ this.fetchData()
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+}
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
<style scoped>
|