Merge branch 'develop' of https://gitee.com/darlk/ShengTangManage into xzj

This commit is contained in:
xiezhijun 2021-03-03 16:44:24 +08:00
commit 77148e9067
3 changed files with 283 additions and 263 deletions

View File

@ -14,7 +14,7 @@
icon="el-icon-plus" icon="el-icon-plus"
size="mini" size="mini"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['orderPause:pause:add']" v-hasPermi="['recipes:pause:add']"
>新增</el-button >新增</el-button
> >
</el-col> </el-col>
@ -24,7 +24,7 @@
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
@click="handleExport" @click="handleExport"
v-hasPermi="['orderPause:pause:export']" v-hasPermi="['recipes:pause:export']"
>导出</el-button >导出</el-button
> >
</el-col> </el-col>
@ -96,7 +96,7 @@
type="text" type="text"
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['orderPause:pause:edit']" v-hasPermi="['recipes:pause:edit']"
>修改</el-button >修改</el-button
> >
<el-button <el-button
@ -104,7 +104,7 @@
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['orderPause:pause:remove']" v-hasPermi="['recipes:pause:remove']"
>删除</el-button >删除</el-button
> >
</template> </template>

View File

@ -247,17 +247,10 @@
:summary-method="getSummaries" :summary-method="getSummaries"
style="width: 100%" style="width: 100%"
> >
<el-table-column prop="name" label="食材"></el-table-column> <el-table-column prop="name" label="食材" align="center" />
<el-table-column label="通俗计量"> <el-table-column label="通俗计量" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<span class="cus-unit"> <span class="cus-unit">
<!-- <el-input-number
v-model="scope.row.cusWeight"
size="mini"
controls-position="right"
step="0.5"
:min="0.5"
/> -->
<el-select size="mini" v-model="scope.row.cusWeight"> <el-select size="mini" v-model="scope.row.cusWeight">
<el-option <el-option
v-for="dict in cusWeightOptions" v-for="dict in cusWeightOptions"
@ -277,7 +270,7 @@
</span> </span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="weight" label="重量(g)"> <el-table-column prop="weight" label="重量(g)" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input-number <el-input-number
class="weight" class="weight"
@ -290,11 +283,31 @@
/> />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="proteinRatio" label="蛋白质/100g"> <el-table-column
</el-table-column> prop="proteinRatio"
<el-table-column prop="fatRatio" label="脂肪/100g"> label="蛋白质/100g"
</el-table-column> align="center"
<el-table-column prop="carbonRatio" label="碳水/100g"> />
<el-table-column
prop="fatRatio"
label="脂肪/100g"
align="center"
/>
<el-table-column
prop="carbonRatio"
label="碳水/100g"
align="center"
/>
<el-table-column label="热量/100g" align="center">
<template slot-scope="scope">
{{
`${(
scope.row.proteinRatio * 4 +
scope.row.fatRatio * 9 +
scope.row.carbonRatio * 4
).toFixed(1)} kcal`
}}
</template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-form-item> </el-form-item>

View File

@ -96,13 +96,11 @@
icon="el-icon-search" icon="el-icon-search"
size="mini" size="mini"
@click="handleQuery" @click="handleQuery"
>搜索 >搜索
</el-button </el-button>
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery" <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置 >重置
</el-button </el-button>
>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -114,7 +112,7 @@
size="mini" size="mini"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['custom:ingredient:add']" v-hasPermi="['custom:ingredient:add']"
>新增 >新增
</el-button> </el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
@ -124,7 +122,7 @@
size="mini" size="mini"
@click="handleExport" @click="handleExport"
v-hasPermi="['custom:ingredient:export']" v-hasPermi="['custom:ingredient:export']"
>导出 >导出
</el-button> </el-button>
</el-col> </el-col>
<right-toolbar <right-toolbar
@ -179,6 +177,17 @@
align="center" align="center"
prop="carbonRatio" prop="carbonRatio"
/> />
<el-table-column label="每百克热量(千卡)" align="center" width="120">
<template slot-scope="scope">
{{
(
scope.row.proteinRatio * 4 +
scope.row.fatRatio * 9 +
scope.row.carbonRatio * 4
).toFixed(1)
}}
</template>
</el-table-column>
<el-table-column <el-table-column
label="地域" label="地域"
align="center" align="center"
@ -192,15 +201,15 @@
width="120" width="120"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<autohideinfo :data="string2Arr(scope.row.notRec)"/> <autohideinfo :data="string2Arr(scope.row.notRec)" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="推荐人群" align="center" prop="rec" width="120"> <el-table-column label="推荐人群" align="center" prop="rec" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<autohideinfo :data="string2Arr(scope.row.rec)"/> <autohideinfo :data="string2Arr(scope.row.rec)" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="备注" align="center" prop="remark"/> <el-table-column label="备注" align="center" prop="remark" />
<el-table-column <el-table-column
label="操作" label="操作"
align="center" align="center"
@ -213,7 +222,7 @@
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['custom:ingredient:edit']" v-hasPermi="['custom:ingredient:edit']"
>修改 >修改
</el-button> </el-button>
<el-button <el-button
size="mini" size="mini"
@ -221,7 +230,7 @@
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['custom:ingredient:remove']" v-hasPermi="['custom:ingredient:remove']"
>删除 >删除
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -241,7 +250,7 @@
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="食材名称" prop="name" label-width="90px"> <el-form-item label="食材名称" prop="name" label-width="90px">
<el-input v-model="form.name" placeholder="请输入食材名称"/> <el-input v-model="form.name" placeholder="请输入食材名称" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
@ -376,244 +385,242 @@
</template> </template>
<script> <script>
import { import {
addIngredient, addIngredient,
delIngredient, delIngredient,
exportIngredient, exportIngredient,
getIngredient, getIngredient,
listIngredient, listIngredient,
updateIngredient, updateIngredient,
} from "@/api/custom/ingredient"; } from "@/api/custom/ingredient";
import AutoHideInfo from "@/components/AutoHideInfo"; import AutoHideInfo from "@/components/AutoHideInfo";
import {listPhysicalSigns} from "@/api/custom/physicalSigns"; import { listPhysicalSigns } from "@/api/custom/physicalSigns";
export default { export default {
name: "Ingredient", name: "Ingredient",
components: { components: {
autohideinfo: AutoHideInfo, autohideinfo: AutoHideInfo,
},
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
ingredientList: [],
//
reviewStatusOptions: [],
//
title: "",
//
open: false,
//
typeOptions: [],
//
areaOptions: [],
//
physicalSignsOptions: [],
//
queryParams: {
pageNum: 1,
pageSize: 10,
name: null,
type: null,
area: null,
notRecIds: null,
recIds: null,
reviewStatus: null,
},
//
form: {},
//
rules: {},
};
},
created() {
this.getList();
this.getDicts("cus_ing_type").then((response) => {
this.typeOptions = response.data;
});
this.getDicts("cus_area").then((response) => {
this.areaOptions = response.data;
});
this.getDicts("cus_review_status").then((response) => {
this.reviewStatusOptions = response.data;
});
listPhysicalSigns().then((response) => {
this.physicalSignsOptions = response.rows.map((obj) => ({
dictLabel: obj.name,
dictValue: obj.id,
}));
});
},
methods: {
/** 查询食材列表 */
getList() {
this.loading = true;
listIngredient(this.queryParams).then((response) => {
this.ingredientList = response.rows;
this.total = response.total;
this.loading = false;
});
}, },
data() { //
return { typeFormat(row, column) {
// return this.selectDictLabel(this.typeOptions, row.type);
loading: true, },
// //
ids: [], areaFormat(row, column) {
// return this.selectDictLabel(this.areaOptions, row.area);
single: true, },
// //
multiple: true, cancel() {
// this.open = false;
showSearch: true, this.reset();
// },
total: 0, //
// reset() {
ingredientList: [], this.form = {
// id: null,
reviewStatusOptions: [], name: null,
// type: null,
title: "", proteinRatio: null,
// fatRatio: null,
open: false, carbonRatio: null,
// area: null,
typeOptions: [], notRecIds: [],
// recIds: [],
areaOptions: [], remark: null,
// createBy: null,
physicalSignsOptions: [], createTime: null,
// updateBy: null,
queryParams: { updateTime: null,
pageNum: 1,
pageSize: 10,
name: null,
type: null,
area: null,
notRecIds: null,
recIds: null,
reviewStatus: null,
},
//
form: {},
//
rules: {},
}; };
this.resetForm("form");
}, },
created() { /** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList(); this.getList();
this.getDicts("cus_ing_type").then((response) => {
this.typeOptions = response.data;
});
this.getDicts("cus_area").then((response) => {
this.areaOptions = response.data;
});
this.getDicts("cus_review_status").then((response) => {
this.reviewStatusOptions = response.data;
});
listPhysicalSigns().then((response) => {
this.physicalSignsOptions = response.rows.map((obj) => ({
dictLabel: obj.name,
dictValue: obj.id,
}));
});
}, },
methods: { /** 重置按钮操作 */
/** 查询食材列表 */ resetQuery() {
getList() { this.resetForm("queryForm");
this.loading = true; this.handleQuery();
listIngredient(this.queryParams).then((response) => { },
this.ingredientList = response.rows; //
this.total = response.total; handleSelectionChange(selection) {
this.loading = false; this.ids = selection.map((item) => item.id);
}); this.single = selection.length !== 1;
}, this.multiple = !selection.length;
// },
typeFormat(row, column) { /** 新增按钮操作 */
return this.selectDictLabel(this.typeOptions, row.type); handleAdd() {
}, this.reset();
// this.open = true;
areaFormat(row, column) { this.title = "添加食材";
return this.selectDictLabel(this.areaOptions, row.area); },
}, /** 修改按钮操作 */
// handleUpdate(row) {
cancel() { this.reset();
this.open = false; const id = row.id || this.ids;
this.reset(); getIngredient(id).then((response) => {
}, this.form = response.data;
// this.form.notRecIds = this.form.notRec
reset() { ? this.form.notRec
this.form = { .split(",")
id: null, .map(
name: null, (label) =>
type: null, this.physicalSignsOptions.find(
proteinRatio: null, (pObj) => pObj.dictLabel === label
fatRatio: null, ).dictValue
carbonRatio: null, )
area: null, : [];
notRecIds: [], this.form.recIds = this.form.rec
recIds: [], ? this.form.rec
remark: null, .split(",")
createBy: null, .map(
createTime: null, (label) =>
updateBy: null, this.physicalSignsOptions.find(
updateTime: null, (pObj) => pObj.dictLabel === label
}; ).dictValue
this.resetForm("form"); )
}, : [];
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true; this.open = true;
this.title = "添加食材"; this.title = "修改食材";
}, });
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids;
getIngredient(id).then((response) => {
this.form = response.data;
this.form.notRecIds = this.form.notRec
? this.form.notRec
.split(",")
.map(
(label) =>
this.physicalSignsOptions.find(
(pObj) => pObj.dictLabel === label
).dictValue
)
: [];
this.form.recIds = this.form.rec
? this.form.rec
.split(",")
.map(
(label) =>
this.physicalSignsOptions.find(
(pObj) => pObj.dictLabel === label
).dictValue
)
: [];
this.open = true;
this.title = "修改食材";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id != null) {
updateIngredient(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
});
} else {
addIngredient(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
}
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除食材编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(function () {
return delIngredient(ids);
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
})
.catch(function () {
});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm("是否确认导出所有食材数据项?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(function () {
return exportIngredient(queryParams);
})
.then((response) => {
this.download(response.msg);
})
.catch(function () {
});
},
string2Arr(str) {
return str ? str.split(',') : []
}
}, },
}; /** 提交按钮 */
submitForm() {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id != null) {
updateIngredient(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
});
} else {
addIngredient(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
}
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除食材编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(function () {
return delIngredient(ids);
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
})
.catch(function () {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm("是否确认导出所有食材数据项?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(function () {
return exportIngredient(queryParams);
})
.then((response) => {
this.download(response.msg);
})
.catch(function () {});
},
string2Arr(str) {
return str ? str.split(",") : [];
},
},
};
</script> </script>