提交 764891ea authored 作者: huang's avatar huang

规则模块页面开发

上级 0200698d
...@@ -7,3 +7,11 @@ export function getRecipeType() { ...@@ -7,3 +7,11 @@ export function getRecipeType() {
method: 'get', method: 'get',
}) })
} }
//根据星期获取菜谱
export function getRecipeByWeek(week) {
return request({
url: '/recipeWeek/getRecipeByWeek/'+week,
method: 'get',
})
}
...@@ -16,32 +16,54 @@ ...@@ -16,32 +16,54 @@
<el-table-column label="晚餐" align="center" :show-overflow-tooltip="true" /> <el-table-column label="晚餐" align="center" :show-overflow-tooltip="true" />
</el-table> </el-table>
<el-dialog :title="title" :visible.sync="open" width="420px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <!-- 添加或修改菜谱类型 -->
<el-row> <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
<el-col :span="16" > <el-form :model="breakfastForm" ref="breakfastForm" label-width="100px" class="demo-dynamic" >
<el-form-item label="菜谱类型" prop="recipeTypeName"> <!--早餐-->
<el-input v-model="form.recipeTypeName" placeholder="请输入菜谱类型" maxlength="8" size="small" clearable /> <el-form-item label="早餐">
</el-form-item>
<el-form-item style="display: flex" v-for="(recipe, index) in breakfastForm.recipes" :key="recipe.key" >
<el-select v-model="recipe.recipeType" placeholder="请选择" style="width: 25%">
<el-option v-for="item in recipeType" :key="item.value" :label="item.label" :value="item.value"> </el-option>
</el-select>
<el-input v-model="recipe.content" style="width: 50%"></el-input>
<el-button @click.prevent="removeBfRow(recipe)">删除</el-button>
</el-form-item>
<el-form-item>
<el-button @click="addBfRow">新增菜谱</el-button>
</el-form-item> </el-form-item>
</el-col>
</el-row>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <!--午餐-->
<el-button type="primary" @click="submitForm">确 定</el-button> <el-form :model="lunchForm" ref="lunchForm" label-width="100px" class="demo-dynamic" >
<el-button @click="cancel">取 消</el-button> <el-form-item label="午餐">
</div> </el-form-item>
</el-dialog> <el-form-item style="display: flex" v-for="(recipe, index) in lunchForm.recipes" :key="recipe.key" >
<el-select v-model="value" placeholder="菜谱类型" style="width: 140px"> <el-select v-model="recipe.recipeType" placeholder="请选择" style="width: 25%">
<el-option v-for="item in recipeType" :key="item.value" :label="item.label" :value="item.value"></el-option> <el-option v-for="item in recipeType" :key="item.value" :label="item.label" :value="item.value"> </el-option>
</el-select> </el-select>
<!-- 添加或修改菜谱类型 --> <el-input v-model="recipe.content" style="width: 50%"></el-input>
<el-dialog :title="title" :visible.sync="open" width="520px" append-to-body> <el-button @click.prevent="removeLunchRow(recipe)">删除</el-button>
<div style="display: flex"> </el-form-item>
<el-select v-model="value" placeholder="菜谱类型" style="width: 140px"> <el-form-item>
<el-option v-for="item in recipeType" :key="item.value" :label="item.label" :value="item.value"></el-option> <el-button @click="addLunchRow">新增菜谱</el-button>
</el-form-item>
</el-form>
<!--晚餐-->
<el-form :model="supperForm" ref="supperForm" label-width="100px" class="demo-dynamic" >
<el-form-item label="晚餐">
</el-form-item>
<el-form-item style="display: flex" v-for="(recipe, index) in supperForm.recipes" :key="recipe.key" >
<el-select v-model="recipe.recipeType" placeholder="请选择" style="width: 25%">
<el-option v-for="item in recipeType" :key="item.value" :label="item.label" :value="item.value"> </el-option>
</el-select> </el-select>
<el-input placeholder="请输入菜品" style="margin-left: 20px"></el-input> <el-input v-model="recipe.content" style="width: 50%"></el-input>
</div> <el-button @click.prevent="removeSupperRow(recipe)">删除</el-button>
</el-form-item>
<el-form-item>
<el-button @click="addSupperRow">新增菜谱</el-button>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button> <el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button> <el-button @click="cancel">取 消</el-button>
...@@ -52,42 +74,42 @@ ...@@ -52,42 +74,42 @@
</div> </div>
</template> </template>
<script> <script>
import {getRecipeType } from "@/api/recipe/recipeSetting"; import {getRecipeType,getRecipeByWeek } from "@/api/recipe/recipeSetting";
export default { export default {
//页签缓存页面的name要和路由中的那么要相同,才能缓存, //页签缓存页面的name要和路由中的那么要相同,才能缓存,
//如果是自定义菜单,则页面的name和菜单管理中路由地址要相同,才能页签缓存 //如果是自定义菜单,则页面的name和菜单管理中路由地址要相同,才model能页签缓存
name: "", name: "recipeSetting",
data() { data() {
return { return {
recipeType: [], recipeType: [],
value: '',
// 遮罩层 // 遮罩层
loading: false, loading: false,
ids: [],// 选中数组 weeks: [],// 选中数组
single: true, // 非单个禁用 single: true, // 非单个禁用
multiple: true, // 非多个禁用 multiple: true, // 非多个禁用
total: 0, // 总条数 total: 0, // 总条数
currentWeek:'', //当前选择的星期
recipeWeek: [ recipeWeek: [
{ {
"week":"星期一" "week":"星期一"
}, },
{ {
"week":"星期" "week":"星期"
}, },
{ {
"week":"星期" "week":"星期"
}, },
{ {
"week":"星期" "week":"星期"
}, },
{ {
"week":"星期" "week":"星期"
}, },
{ {
"week":"星期" "week":"星期"
}, },
{ {
"week":"星期" "week":"星期"
} }
],// 所有菜谱类型列表 ],// 所有菜谱类型列表
title: "", // 弹出层标题 title: "", // 弹出层标题
...@@ -101,7 +123,28 @@ ...@@ -101,7 +123,28 @@
content: [ content: [
{ required: true, message: "菜谱类型不能为空", trigger: "blur" } { required: true, message: "菜谱类型不能为空", trigger: "blur" }
] ]
} },
breakfastForm: {
period:'早餐',
recipes: [{
content: '',
recipeType:''
}]
},
lunchForm: {
period:'午餐',
recipes: [{
content: '',
recipeType:''
}]
},
supperForm: {
period:'晚餐',
recipes: [{
content: '',
recipeType:''
}]
},
}; };
}, },
created() { created() {
...@@ -123,26 +166,6 @@ ...@@ -123,26 +166,6 @@
} }
}) })
}, },
addText(){
let length = this.textList.length;
let cope = {
'name': ''
}
this.textList.push(cope);
console.log(this.textList)
},
delText(index){
this.textList.splice(index, 1);
},
/** 获取所有菜谱类型 */
getList() {
this.loading = true;
getRecipeTypeList(this.queryParams).then(response=>{
this.recipeTypeList = response.rows
this.total=response.total
this.loading = false
})
},
// 取消按钮 // 取消按钮
cancel() { cancel() {
this.open = false; this.open = false;
...@@ -155,15 +178,10 @@ ...@@ -155,15 +178,10 @@
}; };
this.resetForm("form"); this.resetForm("form");
}, },
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加菜谱类型";
},
//多选框选中数据 //多选框选中数据
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.id) this.currentWeek=selection[0].week
this.single = selection.length!=1 this.single = selection.length!=1
this.multiple = !selection.length this.multiple = !selection.length
}, },
...@@ -171,56 +189,73 @@ ...@@ -171,56 +189,73 @@
handleUpdate(row) { handleUpdate(row) {
//清空表单 //清空表单
this.reset(); this.reset();
const id = row.id || this.ids[0] const week = this.weeks[0]
getRecipeTypeById(id).then(response => { getRecipeByWeek(week).then(response => {
this.form = response.data; this.form = response.data;
this.open = true; this.open = true;
this.title = "修改菜谱类型"; this.title = "修改菜谱类型";
}); });
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm: function() { submitForm(formName) {
this.$refs["form"].validate(valid => { console.log(this.breakfastForm)
console.log(this.lunchForm)
console.log(this.supperForm)
return
this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
alert('submit!');
if (this.form.id != undefined) {
updateRecipeType(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
} else { } else {
this.msgError("修改失败:"+response.msg); console.log('error submit!!');
return false;
} }
}); });
} else { },
addRecipeType(this.form).then(response => {
if (response.code === 200) { /**删除早餐列表*/
this.msgSuccess("新增成功"); removeBfRow(item) {
this.open = false; var index = this.breakfastForm.recipes.indexOf(item)
this.getList(); if (index !== -1) {
} else { this.breakfastForm.recipes.splice(index, 1)
this.msgError("新增失败:"+response.msg);
} }
},
/**添加早餐列表*/
addBfRow() {
this.breakfastForm.recipes.push({
value: '',
key: Date.now()
}); });
},
/**删除午餐列表*/
removeLunchRow(item) {
var index = this.lunchForm.recipes.indexOf(item)
if (index !== -1) {
this.lunchForm.recipes.splice(index, 1)
} }
} },
/**添加午餐列表*/
addLunchRow() {
this.lunchForm.recipes.push({
value: '',
key: Date.now()
}); });
}, },
/** 删除按钮操作 */
handleDelete(row) { /**删除晚餐列表*/
const ids = row.dictId || this.ids; removeSupperRow(item) {
this.$confirm('是否确认删除已选中的数据项?', "警告", { var index = this.supperForm.recipes.indexOf(item)
confirmButtonText: "确定", if (index !== -1) {
cancelButtonText: "取消", this.supperForm.recipes.splice(index, 1)
type: "warning" }
}).then(function() { },
return delRecipeType(ids); /**添加晚餐列表*/
}).then(() => { addSupperRow() {
this.getList(); this.supperForm.recipes.push({
this.msgSuccess("删除成功"); value: '',
}).catch(function() {}); key: Date.now()
});
} }
} }
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论