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

规则模块页面开发

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