提交 0200698d authored 作者: huang's avatar huang

添加模块

上级 b29fb79c
import request from '@/utils/request'
//获取菜谱类型列表
export function getRecipeType() {
return request({
url: '/recipeWeek/getRecipeType',
method: 'get',
})
}
import request from '@/utils/request'
//获取菜谱类型列表
export function getRecipeTypeList() {
return request({
url: '/recipeType/getRecipeTypeList',
method: 'get',
})
}
//添加菜谱类型
export function addRecipeType(data) {
return request({
url: '/recipeType/addRecipeType',
method: 'post',
data: data
})
}
//更新菜谱类型
export function updateRecipeType(data) {
return request({
url: '/recipeType/updateRecipeType',
method: 'put',
data: data
})
}
//删除菜谱类型
export function delRecipeType(ids) {
return request({
url: '/recipeType/delRecipeType/'+ids,
method: 'delete'
})
}
//获取菜谱类型根据id
export function getRecipeTypeById(id) {
return request({
url: '/recipeType/getRecipeTypeById/'+id,
method: 'get'
})
}
......@@ -24,11 +24,12 @@ import Pagination from "@/components/Pagination";
//引入view样式
import 'view-design/dist/styles/iview.css';
//按需引入
import { Button, Table,Card } from 'view-design';
import { Button, Table,Card ,Col,Row } from 'view-design';
Vue.component('Button', Button);
Vue.component('Table', Table);
Vue.component('Card', Card);
Vue.component('Col', Col);
Vue.component('Row', Row);
// 全局方法挂载
Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey
......
......@@ -23,7 +23,7 @@
<el-button type="success" icon="el-icon-delete" size="mini" :disabled="single" @click="handleActivate" v-hasPermi="['system:user:active']" >激活</el-button>
</el-col>
</el-row>
<!--列表-->
<el-table v-loading="loading" :data="announcementList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="40" align="center" :show-overflow-tooltip="true"/>
<el-table-column label="内容" align="center" prop="content" :show-overflow-tooltip="true" />
......@@ -46,7 +46,6 @@
<el-input v-model="form.content" type="textarea" placeholder="请输入公告通知内容" clearable rows="6"/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
......@@ -205,6 +204,7 @@
return delAnnouncement(ids);
}).then(() => {
this.getList();
this.getCurrent();
this.msgSuccess("删除成功");
}).catch(function() {});
}
......
<template>
<div>666</div>
<div class="app-container">
<!--操作按钮组-->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="success" icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['system:user:edit']" >修改</el-button>
</el-col>
</el-row>
<!--列表-->
<el-table v-loading="loading" :data="recipeWeek" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="40" align="center" :show-overflow-tooltip="true"/>
<el-table-column label="日期" align="center" prop="week" :show-overflow-tooltip="true" />
<el-table-column label="早餐" align="center" :show-overflow-tooltip="true" />
<el-table-column label="午饭" align="center" :show-overflow-tooltip="true" />
<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>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {getRecipeType } from "@/api/recipe/recipeSetting";
export default {
//页签缓存页面的name要和路由中的那么要相同,才能缓存,
//如果是自定义菜单,则页面的name和菜单管理中路由地址要相同,才能页签缓存
name: "",
data() {
return {
recipeType: [],
value: '',
// 遮罩层
loading: false,
ids: [],// 选中数组
single: true, // 非单个禁用
multiple: true, // 非多个禁用
total: 0, // 总条数
recipeWeek: [
{
"week":"星期一"
},
{
"week":"星期一"
},
{
"week":"星期一"
},
{
"week":"星期一"
},
{
"week":"星期一"
},
{
"week":"星期一"
},
{
"week":"星期一"
}
],// 所有菜谱类型列表
title: "", // 弹出层标题
open: false,// 是否显示弹出层
queryParams: { // 查询参数
pageNum: 1,
pageSize: 10
},
form: {}, // 表单参数
rules: {// 表单校验
content: [
{ required: true, message: "菜谱类型不能为空", trigger: "blur" }
]
}
};
},
created() {
this.getRecipeType()
//this.getList();
},
methods: {
//获取菜谱类型,并添加到下拉框数据
getRecipeType(){
getRecipeType().then(response=>{
//菜谱类型的数量
let typeCount = response.data.length
for (let i=0;i<typeCount;i++){
let option = {
value:response.data[i].recipeTypeName,
label:response.data[i].recipeTypeName
}
this.recipeType.push(option)
}
})
},
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;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: undefined
};
this.resetForm("form");
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加菜谱类型";
},
//多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!=1
this.multiple = !selection.length
},
/** 修改按钮操作 */
handleUpdate(row) {
//清空表单
this.reset();
const id = row.id || this.ids[0]
getRecipeTypeById(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改菜谱类型";
});
},
/** 提交按钮 */
submitForm: function() {
this.$refs["form"].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);
}
});
}
}
});
},
/** 删除按钮操作 */
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() {});
}
}
};
</script>
<style scoped>
......
<template>
<div>666</div>
<div class="app-container">
<!--操作按钮组-->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:user:add']">新增</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="['system:user: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="['system:user:remove']" >删除</el-button>
</el-col>
</el-row>
<!--列表-->
<el-table v-loading="loading" :data="recipeTypeList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="40" align="center" :show-overflow-tooltip="true"/>
<el-table-column label="菜谱类型" align="center" prop="recipeTypeName" :show-overflow-tooltip="true" />
</el-table>
<!--分页按钮组-->
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"/>
<!-- 添加或修改菜谱类型 -->
<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>
</div>
</template>
<script>
import {getRecipeTypeList,addRecipeType,getRecipeTypeById,updateRecipeType,delRecipeType } from "@/api/recipe/recipeType";
export default {
//页签缓存页面的name要和路由中的那么要相同,才能缓存,
//如果是自定义菜单,则页面的name和菜单管理中路由地址要相同,才能页签缓存
name: "recipeType",
data() {
return {
// 遮罩层
loading: true,
ids: [],// 选中数组
single: true, // 非单个禁用
multiple: true, // 非多个禁用
total: 0, // 总条数
recipeTypeList: [],// 所有菜谱类型列表
title: "", // 弹出层标题
open: false,// 是否显示弹出层
queryParams: { // 查询参数
pageNum: 1,
pageSize: 10
},
form: {}, // 表单参数
rules: {// 表单校验
content: [
{ required: true, message: "菜谱类型不能为空", trigger: "blur" }
]
}
};
},
created() {
this.getList();
},
methods: {
/** 获取所有菜谱类型 */
getList() {
this.loading = true;
getRecipeTypeList(this.queryParams).then(response=>{
this.recipeTypeList = response.rows
this.total=response.total
this.loading = false
})
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: undefined
};
this.resetForm("form");
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加菜谱类型";
},
//多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!=1
this.multiple = !selection.length
},
/** 修改按钮操作 */
handleUpdate(row) {
//清空表单
this.reset();
const id = row.id || this.ids[0]
getRecipeTypeById(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改菜谱类型";
});
},
/** 提交按钮 */
submitForm: function() {
this.$refs["form"].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);
}
});
}
}
});
},
/** 删除按钮操作 */
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() {});
}
}
};
</script>
<style scoped>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论