调整界面

This commit is contained in:
huangdeliang 2021-01-10 14:39:04 +08:00
parent 99a47de624
commit 5acdbf1c38
2 changed files with 467 additions and 271 deletions

View File

@ -0,0 +1,52 @@
<template>
<div class="autohideinfo_wrapper">
<div v-for="item in mData" :key="item">
{{ item }}
</div>
<div v-if="showMore">
<div>...</div>
<el-popover placement="top-start" width="200" popper-class="autohideinfo_detial" trigger="hover">
<div v-for="item in data" :key="item">{{ item }}</div>
<el-button type="text" slot="reference">详情</el-button>
</el-popover>
</div>
</div>
</template>
<script>
export default {
name: "AutoHideInfo",
data() {
return {
mData: [],
showMore: false,
};
},
props: {
data: {
type: Array,
default: [],
required: true,
},
},
watch: {
data: function (val, oldVal) {
if (val) {
this.showMore = val.length > 3;
this.mData = val.slice(0, 3);
}
},
},
};
</script>
<style>
.autohideinfo_wrapper {
}
.autohideinfo_detial {
max-height: 240px;
overflow: auto;
}
</style>

View File

@ -1,6 +1,12 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> <el-form
:model="queryParams"
ref="queryForm"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="食材名称" prop="name"> <el-form-item label="食材名称" prop="name">
<el-input <el-input
v-model="queryParams.name" v-model="queryParams.name"
@ -11,7 +17,12 @@
/> />
</el-form-item> </el-form-item>
<el-form-item label="食材类别" prop="type"> <el-form-item label="食材类别" prop="type">
<el-select v-model="queryParams.type" placeholder="请选择食材类别" clearable size="small"> <el-select
v-model="queryParams.type"
placeholder="请选择食材类别"
clearable
size="small"
>
<el-option <el-option
v-for="dict in typeOptions" v-for="dict in typeOptions"
:key="dict.dictValue" :key="dict.dictValue"
@ -21,7 +32,12 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="地域" prop="area"> <el-form-item label="地域" prop="area">
<el-select v-model="queryParams.area" placeholder="请选择地域" clearable size="small"> <el-select
v-model="queryParams.area"
placeholder="请选择地域"
clearable
size="small"
>
<el-option <el-option
v-for="dict in areaOptions" v-for="dict in areaOptions"
:key="dict.dictValue" :key="dict.dictValue"
@ -31,37 +47,60 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="忌口人群" prop="notRecIds"> <el-form-item label="忌口人群" prop="notRecIds">
<el-select v-model="queryParams.notRecIds" multiple placeholder="请选择体征"> <el-select
v-model="queryParams.notRecIds"
multiple
placeholder="请选择体征"
>
<el-option <el-option
v-for="dict in physicalSignsOptions" v-for="dict in physicalSignsOptions"
:key="dict.dictValue" :key="dict.dictValue"
:label="dict.dictLabel" :label="dict.dictLabel"
:value="dict.dictValue"> :value="dict.dictValue"
>
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="推荐人群" prop="recIds"> <el-form-item label="推荐人群" prop="recIds">
<el-select v-model="queryParams.recIds" multiple placeholder="请选择体征"> <el-select
v-model="queryParams.recIds"
multiple
placeholder="请选择体征"
>
<el-option <el-option
v-for="dict in physicalSignsOptions" v-for="dict in physicalSignsOptions"
:key="dict.dictValue" :key="dict.dictValue"
:label="dict.dictLabel" :label="dict.dictLabel"
:value="dict.dictValue"> :value="dict.dictValue"
>
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="审核状态" prop="reviewStatus"> <el-form-item label="审核状态" prop="reviewStatus">
<el-select v-model="queryParams.reviewStatus" placeholder="请选择审核状态" <el-select
clearable> v-model="queryParams.reviewStatus"
<el-option v-for="dict in reviewStatusOptions" placeholder="请选择审核状态"
:key="dict.dictValue" clearable
:label="dict.dictLabel" >
:value="dict.dictValue"/> <el-option
v-for="dict in reviewStatusOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-button
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> type="cyan"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -73,31 +112,9 @@
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-button-->
<!-- type="success"-->
<!-- icon="el-icon-edit"-->
<!-- size="mini"-->
<!-- :disabled="single"-->
<!-- @click="handleUpdate"-->
<!-- v-hasPermi="['custom:ingredient:edit']"-->
<!-- >修改-->
<!-- </el-button>-->
<!-- </el-col>-->
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="danger"-->
<!-- icon="el-icon-delete"-->
<!-- size="mini"-->
<!-- :disabled="multiple"-->
<!-- @click="handleDelete"-->
<!-- v-hasPermi="['custom:ingredient:remove']"-->
<!-- >删除-->
<!-- </el-button>-->
<!-- </el-col>-->
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
@ -105,34 +122,95 @@
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 :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="ingredientList" @selection-change="handleSelectionChange"> <el-table
<!-- <el-table-column type="selection" width="55" align="center" />--> v-loading="loading"
<!-- <el-table-column label="id" align="center" prop="id" />--> :data="ingredientList"
<el-table-column label="审核状态" align="center"> @selection-change="handleSelectionChange"
>
<el-table-column label="审核状态" align="center" fixed="left" width="80">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag <el-tag
:type="scope.row.reviewStatus === 'yes' ? 'success' : 'danger'" :type="scope.row.reviewStatus === 'yes' ? 'success' : 'danger'"
disable-transitions> disable-transitions
{{scope.row.reviewStatus === 'yes' ? '已审核':'未审核'}} >
{{ scope.row.reviewStatus === "yes" ? "已审核" : "未审核" }}
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="食材名称" align="center" prop="name"/> <el-table-column
<el-table-column label="食材类别" align="center" prop="type" :formatter="typeFormat"/> label="食材名称"
<el-table-column label="蛋白质比例(100g)" width="124" align="center" prop="proteinRatio"/> align="center"
<el-table-column label="脂肪比例(100g)" width="120" align="center" prop="fatRatio"/> prop="name"
<el-table-column label="碳水比例(100g)" width="120" align="center" prop="carbonRatio"/> fixed="left"
<el-table-column label="地域" align="center" prop="area" :formatter="areaFormat"/> width="120"
<el-table-column label="忌口人群" align="center" prop="notRec"/> />
<el-table-column label="推荐人群" align="center" prop="rec"/> <el-table-column
<el-table-column label="备注" align="center" prop="remark"/> label="食材类别"
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> align="center"
prop="type"
width="120"
:formatter="typeFormat"
/>
<el-table-column
label="蛋白质比例(100g)"
width="128"
align="center"
prop="proteinRatio"
/>
<el-table-column
label="脂肪比例(100g)"
width="120"
align="center"
prop="fatRatio"
/>
<el-table-column
label="碳水比例(100g)"
width="120"
align="center"
prop="carbonRatio"
/>
<el-table-column
label="地域"
align="center"
prop="area"
:formatter="areaFormat"
/>
<el-table-column
label="忌口人群"
align="center"
prop="notRec"
width="120"
>
<template slot-scope="scope">
<div v-if="scope.row.notRec">
<autohideinfo :data="scope.row.notRec.split(',')" />
</div>
</template>
</el-table-column>
<el-table-column label="推荐人群" align="center" prop="rec" width="120">
<template slot-scope="scope">
<div v-if="scope.row.rec">
<autohideinfo :data="scope.row.rec.split(',')" />
</div>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column
fixed="right"
label="操作"
width="180"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
size="mini" size="mini"
@ -140,7 +218,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"
@ -148,14 +226,14 @@
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>
</el-table> </el-table>
<pagination <pagination
v-show="total>0" v-show="total > 0"
:total="total" :total="total"
:page.sync="queryParams.pageNum" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" :limit.sync="queryParams.pageSize"
@ -168,24 +246,44 @@
<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">
<el-form-item label="蛋白质比例" prop="proteinRatio" label-width="90px"> <el-form-item
<el-input v-model="form.proteinRatio" placeholder="请输入蛋白质比例" style="width: 150px"/> label="蛋白质比例"
prop="proteinRatio"
label-width="90px"
>
<el-input
v-model="form.proteinRatio"
placeholder="请输入蛋白质比例"
style="width: 150px"
/>
/100g /100g
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="脂肪比例" prop="fatRatio" label-width="90px"> <el-form-item label="脂肪比例" prop="fatRatio" label-width="90px">
<el-input v-model="form.fatRatio" placeholder="请输入脂肪比例" style="width: 150px"/> <el-input
v-model="form.fatRatio"
placeholder="请输入脂肪比例"
style="width: 150px"
/>
/100g /100g
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="碳水比例" prop="carbonRatio" label-width="90px"> <el-form-item
<el-input v-model="form.carbonRatio" placeholder="请输入碳水比例" style="width: 150px"/> label="碳水比例"
prop="carbonRatio"
label-width="90px"
>
<el-input
v-model="form.carbonRatio"
placeholder="请输入碳水比例"
style="width: 150px"
/>
/100g /100g
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -215,42 +313,61 @@
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="忌口人群" label-width="90px"> <el-form-item label="忌口人群" label-width="90px">
<el-select v-model="form.notRecIds" multiple placeholder="请选择体征"> <el-select
v-model="form.notRecIds"
multiple
placeholder="请选择体征"
>
<el-option <el-option
v-for="dict in physicalSignsOptions" v-for="dict in physicalSignsOptions"
:key="dict.dictValue" :key="dict.dictValue"
:label="dict.dictLabel" :label="dict.dictLabel"
:value="dict.dictValue"> :value="dict.dictValue"
>
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="推荐人群" label-width="90px"> <el-form-item label="推荐人群" label-width="90px">
<el-select v-model="form.recIds" multiple placeholder="请选择体征"> <el-select
v-model="form.recIds"
multiple
placeholder="请选择体征"
>
<el-option <el-option
v-for="dict in physicalSignsOptions" v-for="dict in physicalSignsOptions"
:key="dict.dictValue" :key="dict.dictValue"
:label="dict.dictLabel" :label="dict.dictLabel"
:value="dict.dictValue"> :value="dict.dictValue"
>
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="审核状态" prop="reviewStatus"> <el-form-item label="审核状态" prop="reviewStatus">
<el-select v-model="form.reviewStatus" placeholder="请选择审核状态" <el-select
clearable> v-model="form.reviewStatus"
<el-option v-for="dict in reviewStatusOptions" placeholder="请选择审核状态"
:key="dict.dictValue" clearable
:label="dict.dictLabel" >
:value="dict.dictValue"/> <el-option
v-for="dict in reviewStatusOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="备注" prop="remark" label-width="90px"> <el-form-item label="备注" prop="remark" label-width="90px">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/> <el-input
v-model="form.remark"
type="textarea"
placeholder="请输入内容"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-form> </el-form>
@ -264,212 +381,239 @@
</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 {listPhysicalSigns} from "@/api/custom/physicalSigns"; import AutoHideInfo from "@/components/AutoHideInfo";
export default { import { listPhysicalSigns } from "@/api/custom/physicalSigns";
name: "Ingredient",
data() { export default {
return { name: "Ingredient",
// components: {
loading: true, autohideinfo: AutoHideInfo,
// },
ids: [], data() {
// return {
single: true, //
// loading: true,
multiple: true, //
// ids: [],
showSearch: true, //
// single: true,
total: 0, //
// multiple: true,
ingredientList: [], //
// showSearch: true,
reviewStatusOptions: [], //
// total: 0,
title: "", //
// ingredientList: [],
open: false, //
// reviewStatusOptions: [],
typeOptions: [], //
// title: "",
areaOptions: [], //
// open: false,
physicalSignsOptions: [], //
// typeOptions: [],
queryParams: { //
pageNum: 1, areaOptions: [],
pageSize: 10, //
name: null, physicalSignsOptions: [],
type: null, //
area: null, queryParams: {
notRecIds: null, pageNum: 1,
recIds: null, pageSize: 10,
reviewStatus: null name: null,
}, type: null,
// area: null,
form: {}, notRecIds: null,
// recIds: null,
rules: {} 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;
});
},
//
typeFormat(row, column) {
return this.selectDictLabel(this.typeOptions, row.type);
},
//
areaFormat(row, column) {
return this.selectDictLabel(this.areaOptions, row.area);
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
name: null,
type: null,
proteinRatio: null,
fatRatio: null,
carbonRatio: null,
area: null,
notRecIds: [],
recIds: [],
remark: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
}; };
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.rec
reset() { ? this.form.rec
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.notRec
recIds: [], ? this.form.notRec
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(); submitForm() {
const id = row.id || this.ids this.$refs["form"].validate((valid) => {
getIngredient(id).then(response => { if (valid) {
this.form = response.data; if (this.form.id != null) {
this.form.notRecIds = this.form.rec ? this.form.rec.split(',').map(label => this.physicalSignsOptions.find(pObj => pObj.dictLabel === label).dictValue) : []; updateIngredient(this.form).then((response) => {
this.form.recIds = this.form.notRec ? this.form.notRec.split(',').map(label => this.physicalSignsOptions.find(pObj => pObj.dictLabel === label).dictValue) : []; if (response.code === 200) {
this.open = true; this.msgSuccess("修改成功");
this.title = "修改食材"; this.open = false;
}); this.getList();
}, }
/** 提交按钮 */ });
submitForm() { } else {
this.$refs["form"].validate(valid => { addIngredient(this.form).then((response) => {
if (valid) { if (response.code === 200) {
if (this.form.id != null) { this.msgSuccess("新增成功");
updateIngredient(this.form).then(response => { this.open = false;
if (response.code === 200) { this.getList();
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; handleDelete(row) {
this.$confirm('是否确认删除食材编号为"' + ids + '"的数据项?', "警告", { const ids = row.id || this.ids;
confirmButtonText: "确定", this.$confirm('是否确认删除食材编号为"' + ids + '"的数据项?', "警告", {
cancelButtonText: "取消", confirmButtonText: "确定",
type: "warning" cancelButtonText: "取消",
}).then(function () { type: "warning",
})
.then(function () {
return delIngredient(ids); return delIngredient(ids);
}).then(() => { })
.then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.msgSuccess("删除成功");
}).catch(function () { })
}); .catch(function () {});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;
this.$confirm('是否确认导出所有食材数据项?', "警告", { this.$confirm("是否确认导出所有食材数据项?", "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning",
}).then(function () { })
.then(function () {
return exportIngredient(queryParams); return exportIngredient(queryParams);
}).then(response => { })
.then((response) => {
this.download(response.msg); this.download(response.msg);
}).catch(function () { })
}); .catch(function () {});
}, },
} },
}; };
</script> </script>