调整界面
This commit is contained in:
parent
99a47de624
commit
5acdbf1c38
52
stdiet-ui/src/components/AutoHideInfo/index.vue
Normal file
52
stdiet-ui/src/components/AutoHideInfo/index.vue
Normal 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>
|
@ -1,6 +1,12 @@
|
||||
<template>
|
||||
<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-input
|
||||
v-model="queryParams.name"
|
||||
@ -11,7 +17,12 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
<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
|
||||
v-for="dict in typeOptions"
|
||||
:key="dict.dictValue"
|
||||
@ -21,7 +32,12 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<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
|
||||
v-for="dict in areaOptions"
|
||||
:key="dict.dictValue"
|
||||
@ -31,37 +47,60 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="忌口人群" prop="notRecIds">
|
||||
<el-select v-model="queryParams.notRecIds" multiple placeholder="请选择体征">
|
||||
<el-select
|
||||
v-model="queryParams.notRecIds"
|
||||
multiple
|
||||
placeholder="请选择体征"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in physicalSignsOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue">
|
||||
:value="dict.dictValue"
|
||||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="推荐人群" prop="recIds">
|
||||
<el-select v-model="queryParams.recIds" multiple placeholder="请选择体征">
|
||||
<el-select
|
||||
v-model="queryParams.recIds"
|
||||
multiple
|
||||
placeholder="请选择体征"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in physicalSignsOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue">
|
||||
:value="dict.dictValue"
|
||||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="审核状态" prop="reviewStatus">
|
||||
<el-select v-model="queryParams.reviewStatus" placeholder="请选择审核状态"
|
||||
clearable>
|
||||
<el-option v-for="dict in reviewStatusOptions"
|
||||
<el-select
|
||||
v-model="queryParams.reviewStatus"
|
||||
placeholder="请选择审核状态"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in reviewStatusOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"/>
|
||||
:value="dict.dictValue"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<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-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>
|
||||
|
||||
@ -76,28 +115,6 @@
|
||||
>新增
|
||||
</el-button>
|
||||
</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-button
|
||||
type="warning"
|
||||
@ -108,31 +125,92 @@
|
||||
>导出
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
<right-toolbar
|
||||
:showSearch.sync="showSearch"
|
||||
@queryTable="getList"
|
||||
></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="ingredientList" @selection-change="handleSelectionChange">
|
||||
<!-- <el-table-column type="selection" width="55" align="center" />-->
|
||||
<!-- <el-table-column label="id" align="center" prop="id" />-->
|
||||
<el-table-column label="审核状态" align="center">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="ingredientList"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column label="审核状态" align="center" fixed="left" width="80">
|
||||
<template slot-scope="scope">
|
||||
<el-tag
|
||||
:type="scope.row.reviewStatus === 'yes' ? 'success' : 'danger'"
|
||||
disable-transitions>
|
||||
{{scope.row.reviewStatus === 'yes' ? '已审核':'未审核'}}
|
||||
disable-transitions
|
||||
>
|
||||
{{ scope.row.reviewStatus === "yes" ? "已审核" : "未审核" }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="食材名称" align="center" prop="name"/>
|
||||
<el-table-column label="食材类别" align="center" prop="type" :formatter="typeFormat"/>
|
||||
<el-table-column label="蛋白质比例(100g)" width="124" 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"/>
|
||||
<el-table-column label="推荐人群" align="center" prop="rec"/>
|
||||
<el-table-column
|
||||
label="食材名称"
|
||||
align="center"
|
||||
prop="name"
|
||||
fixed="left"
|
||||
width="120"
|
||||
/>
|
||||
<el-table-column
|
||||
label="食材类别"
|
||||
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 label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<el-table-column
|
||||
fixed="right"
|
||||
label="操作"
|
||||
width="180"
|
||||
align="center"
|
||||
class-name="small-padding fixed-width"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
@ -172,20 +250,40 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="蛋白质比例" prop="proteinRatio" label-width="90px">
|
||||
<el-input v-model="form.proteinRatio" placeholder="请输入蛋白质比例" style="width: 150px"/>
|
||||
<el-form-item
|
||||
label="蛋白质比例"
|
||||
prop="proteinRatio"
|
||||
label-width="90px"
|
||||
>
|
||||
<el-input
|
||||
v-model="form.proteinRatio"
|
||||
placeholder="请输入蛋白质比例"
|
||||
style="width: 150px"
|
||||
/>
|
||||
/100g
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<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
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="碳水比例" prop="carbonRatio" label-width="90px">
|
||||
<el-input v-model="form.carbonRatio" placeholder="请输入碳水比例" style="width: 150px"/>
|
||||
<el-form-item
|
||||
label="碳水比例"
|
||||
prop="carbonRatio"
|
||||
label-width="90px"
|
||||
>
|
||||
<el-input
|
||||
v-model="form.carbonRatio"
|
||||
placeholder="请输入碳水比例"
|
||||
style="width: 150px"
|
||||
/>
|
||||
/100g
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -215,42 +313,61 @@
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<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
|
||||
v-for="dict in physicalSignsOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue">
|
||||
:value="dict.dictValue"
|
||||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<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
|
||||
v-for="dict in physicalSignsOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue">
|
||||
:value="dict.dictValue"
|
||||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="审核状态" prop="reviewStatus">
|
||||
<el-select v-model="form.reviewStatus" placeholder="请选择审核状态"
|
||||
clearable>
|
||||
<el-option v-for="dict in reviewStatusOptions"
|
||||
<el-select
|
||||
v-model="form.reviewStatus"
|
||||
placeholder="请选择审核状态"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in reviewStatusOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"/>
|
||||
:value="dict.dictValue"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<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-col>
|
||||
</el-form>
|
||||
@ -270,13 +387,18 @@
|
||||
exportIngredient,
|
||||
getIngredient,
|
||||
listIngredient,
|
||||
updateIngredient
|
||||
updateIngredient,
|
||||
} from "@/api/custom/ingredient";
|
||||
|
||||
import AutoHideInfo from "@/components/AutoHideInfo";
|
||||
|
||||
import { listPhysicalSigns } from "@/api/custom/physicalSigns";
|
||||
|
||||
export default {
|
||||
name: "Ingredient",
|
||||
components: {
|
||||
autohideinfo: AutoHideInfo,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
@ -314,37 +436,37 @@
|
||||
area: null,
|
||||
notRecIds: null,
|
||||
recIds: null,
|
||||
reviewStatus: null
|
||||
reviewStatus: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {}
|
||||
rules: {},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getDicts("cus_ing_type").then(response => {
|
||||
this.getDicts("cus_ing_type").then((response) => {
|
||||
this.typeOptions = response.data;
|
||||
});
|
||||
this.getDicts("cus_area").then(response => {
|
||||
this.getDicts("cus_area").then((response) => {
|
||||
this.areaOptions = response.data;
|
||||
});
|
||||
this.getDicts("cus_review_status").then(response => {
|
||||
this.getDicts("cus_review_status").then((response) => {
|
||||
this.reviewStatusOptions = response.data;
|
||||
})
|
||||
listPhysicalSigns().then(response => {
|
||||
this.physicalSignsOptions = response.rows.map(obj => ({
|
||||
});
|
||||
listPhysicalSigns().then((response) => {
|
||||
this.physicalSignsOptions = response.rows.map((obj) => ({
|
||||
dictLabel: obj.name,
|
||||
dictValue: obj.id
|
||||
}))
|
||||
})
|
||||
dictValue: obj.id,
|
||||
}));
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
/** 查询食材列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listIngredient(this.queryParams).then(response => {
|
||||
listIngredient(this.queryParams).then((response) => {
|
||||
this.ingredientList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
@ -379,7 +501,7 @@
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
updateBy: null,
|
||||
updateTime: null
|
||||
updateTime: null,
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
@ -395,9 +517,9 @@
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
this.ids = selection.map((item) => item.id);
|
||||
this.single = selection.length !== 1;
|
||||
this.multiple = !selection.length;
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
@ -408,21 +530,39 @@
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const id = row.id || this.ids
|
||||
getIngredient(id).then(response => {
|
||||
const id = row.id || this.ids;
|
||||
getIngredient(id).then((response) => {
|
||||
this.form = response.data;
|
||||
this.form.notRecIds = this.form.rec ? this.form.rec.split(',').map(label => this.physicalSignsOptions.find(pObj => pObj.dictLabel === label).dictValue) : [];
|
||||
this.form.recIds = this.form.notRec ? this.form.notRec.split(',').map(label => this.physicalSignsOptions.find(pObj => pObj.dictLabel === label).dictValue) : [];
|
||||
this.form.notRecIds = this.form.rec
|
||||
? this.form.rec
|
||||
.split(",")
|
||||
.map(
|
||||
(label) =>
|
||||
this.physicalSignsOptions.find(
|
||||
(pObj) => pObj.dictLabel === label
|
||||
).dictValue
|
||||
)
|
||||
: [];
|
||||
this.form.recIds = this.form.notRec
|
||||
? this.form.notRec
|
||||
.split(",")
|
||||
.map(
|
||||
(label) =>
|
||||
this.physicalSignsOptions.find(
|
||||
(pObj) => pObj.dictLabel === label
|
||||
).dictValue
|
||||
)
|
||||
: [];
|
||||
this.open = true;
|
||||
this.title = "修改食材";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
this.$refs["form"].validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.form.id != null) {
|
||||
updateIngredient(this.form).then(response => {
|
||||
updateIngredient(this.form).then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
@ -430,7 +570,7 @@
|
||||
}
|
||||
});
|
||||
} else {
|
||||
addIngredient(this.form).then(response => {
|
||||
addIngredient(this.form).then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
@ -447,29 +587,33 @@
|
||||
this.$confirm('是否确认删除食材编号为"' + ids + '"的数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function () {
|
||||
type: "warning",
|
||||
})
|
||||
.then(function () {
|
||||
return delIngredient(ids);
|
||||
}).then(() => {
|
||||
})
|
||||
.then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("删除成功");
|
||||
}).catch(function () {
|
||||
});
|
||||
})
|
||||
.catch(function () {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const queryParams = this.queryParams;
|
||||
this.$confirm('是否确认导出所有食材数据项?', "警告", {
|
||||
this.$confirm("是否确认导出所有食材数据项?", "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function () {
|
||||
type: "warning",
|
||||
})
|
||||
.then(function () {
|
||||
return exportIngredient(queryParams);
|
||||
}).then(response => {
|
||||
})
|
||||
.then((response) => {
|
||||
this.download(response.msg);
|
||||
}).catch(function () {
|
||||
});
|
||||
})
|
||||
.catch(function () {});
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user