|
@@ -26,13 +26,14 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="dishesName" label="菜品名称" />
|
|
|
<el-table-column prop="typeName" label="类型" />
|
|
|
+ <el-table-column prop="userName" label="创建人" />
|
|
|
<el-table-column prop="createTime" label="创建时间" />
|
|
|
<el-table-column prop="updateTime" label="更新时间" />
|
|
|
<el-table-column label="操作" width="230">
|
|
|
<template slot-scope="scope">
|
|
|
<el-button class="but" type="primary" @click="openModifyWorkDialog(scope.row)">
|
|
|
编辑</el-button>
|
|
|
- <el-button class="but" type="danger" @click="handleDelete(scope.row.id, scope.$index)">删除
|
|
|
+ <el-button class="but" type="danger" @click="handleDelete(scope.row, scope.$index)">删除
|
|
|
</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -60,14 +61,14 @@
|
|
|
</el-row>
|
|
|
<el-row>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="菜品类型" prop="typeName">
|
|
|
- <el-input v-model="postManagement.typeName" disabled placeholder="请选择菜品类型">
|
|
|
- </el-input>
|
|
|
+ <el-form-item label="菜品类型" prop="typeId">
|
|
|
+ <el-select v-model="postManagement.typeId" style="width: 100%" placeholder="请选择类型">
|
|
|
+ <el-option v-for="item in typeOptions" :key="item.value" :label="item.label"
|
|
|
+ :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="6" style="margin-left: 10px">
|
|
|
- <el-button type="primary" @click="typeInfo">选择类型</el-button>
|
|
|
- </el-col>
|
|
|
</el-form-item>
|
|
|
</el-row>
|
|
|
<el-row>
|
|
@@ -101,42 +102,6 @@
|
|
|
<el-button @click="upload.open = false">取 消</el-button>
|
|
|
</span>
|
|
|
</el-dialog>
|
|
|
- <!--菜品类型-->
|
|
|
- <el-dialog :visible.sync="typeVisible" :show-close="false" :append-to-body="true"
|
|
|
- style="margin: 10px auto!important" width="80%" top="10px">
|
|
|
- <div slot="title">
|
|
|
- <div class="addTitle">菜品类型</div>
|
|
|
- </div>
|
|
|
- <el-button style="float: left" type="primary" @click="typeVisible = false">返回</el-button>
|
|
|
- <div style="float: right;margin-bottom: 10px;margin-right: 10px">
|
|
|
- <el-input v-model.trim="typeSorts.typeName" clearable placeholder="请输入类型名称"
|
|
|
- style="margin: 0 10px;width: 200px" />
|
|
|
- <el-button type="primary" class="search" @click="searchType">搜索</el-button>
|
|
|
- <el-button type="primary" class="search" @click="resetType" style="margin-left: 5px">重置</el-button>
|
|
|
- </div>
|
|
|
- <el-table :data="typeData" border ref='typeTable' stripe height="475px"
|
|
|
- :header-cell-style="{ background: '#e5e8ed', color: '#666', textAlign: 'center' }"
|
|
|
- :cell-style="tableStyle" style="cursor: default">
|
|
|
- <el-table-column width="50" label="序号">
|
|
|
- <template slot-scope="scope">
|
|
|
- {{ (sorts.page - 1) * sorts.limit + scope.$index + 1 }}
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column prop="typeName" label="类型名称" />
|
|
|
- <el-table-column prop="typeSort" :show-overflow-tooltip="true" label="类型排序号" />
|
|
|
- <el-table-column label="操作" width="100px">
|
|
|
- <template slot-scope="scope">
|
|
|
- <el-button class="but" type="primary" @click="chooseType(scope.row)">选择</el-button>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
- <div>
|
|
|
- <el-pagination @size-change="typeSizeChange" @current-change="typeCurrentChange"
|
|
|
- :current-page="typeSorts.page" :page-sizes="[10, 20, 30, 40, 50]" :page-size="typeSorts.limit"
|
|
|
- layout="prev, pager,next,jumper,total,sizes" :total="typeTotal">
|
|
|
- </el-pagination>
|
|
|
- </div>
|
|
|
- </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -159,14 +124,12 @@
|
|
|
query: {
|
|
|
dishesName: ''
|
|
|
},
|
|
|
+ // 菜品类型
|
|
|
+ typeOptions: [],
|
|
|
// 列表数据
|
|
|
tableData: [],
|
|
|
- // 菜品类型数据
|
|
|
- typeData: [],
|
|
|
// 总数
|
|
|
total: 0,
|
|
|
- // 菜品类型总数
|
|
|
- typeTotal: 0,
|
|
|
// 上传相关
|
|
|
upload: {
|
|
|
open: false,
|
|
@@ -178,8 +141,6 @@
|
|
|
picList: [],
|
|
|
//新增/编辑界面
|
|
|
workDialog: false,
|
|
|
- // 菜品类型界面
|
|
|
- typeVisible: false,
|
|
|
//新增/编辑标题
|
|
|
workTitle: '新增菜品',
|
|
|
// 新增/编辑表单
|
|
@@ -194,17 +155,15 @@
|
|
|
page: 1,
|
|
|
limit: 10,
|
|
|
},
|
|
|
- // 菜品类型分页
|
|
|
- typeSorts: {
|
|
|
- page: 1,
|
|
|
- limit: 10,
|
|
|
- typeName: ''
|
|
|
- },
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
//打开新增界面
|
|
|
openAddWork() {
|
|
|
+ // 获取类型数据
|
|
|
+ if (this.typeOptions.length <= 0) {
|
|
|
+ this.getTypeData();
|
|
|
+ }
|
|
|
this.postManagement = {
|
|
|
dishesName: '',
|
|
|
typeId: '',
|
|
@@ -217,6 +176,10 @@
|
|
|
},
|
|
|
//打开修改界面
|
|
|
openModifyWorkDialog(data) {
|
|
|
+ // 获取类型数据
|
|
|
+ if (this.typeOptions.length <= 0) {
|
|
|
+ this.getTypeData();
|
|
|
+ }
|
|
|
this.workTitle = '编辑菜品';
|
|
|
this.postManagement = JSON.parse(JSON.stringify(data));
|
|
|
this.postManagement.pic = [];
|
|
@@ -229,7 +192,8 @@
|
|
|
if (res.data.result) {
|
|
|
this.picList = res.data.data.map(item => {
|
|
|
return {
|
|
|
- url: item.path
|
|
|
+ url: item.path,
|
|
|
+ name: item.id
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -238,8 +202,6 @@
|
|
|
},
|
|
|
//保存
|
|
|
saveWork() {
|
|
|
- console.log(this.postManagement);
|
|
|
- console.log(this.picList);
|
|
|
if (!this.postManagement.dishesName) {
|
|
|
this.$message.error('请输入菜品名称!');
|
|
|
return;
|
|
@@ -248,7 +210,7 @@
|
|
|
this.$message.error('请选择菜品类型!');
|
|
|
return;
|
|
|
}
|
|
|
- if (this.postManagement.pic.length <= 0) {
|
|
|
+ if (this.postManagement.pic.length <= 0 && !this.postManagement.dishesPhotoPath) {
|
|
|
this.$message.error('请上传菜品图片!');
|
|
|
return;
|
|
|
}
|
|
@@ -307,7 +269,7 @@
|
|
|
this.getData();
|
|
|
},
|
|
|
//删除
|
|
|
- handleDelete(id, index) {
|
|
|
+ handleDelete(data, index) {
|
|
|
this.$confirm("您确定要删除该数据吗?", "提示", {
|
|
|
cancelButtonClass: "btn-custom-cancel",
|
|
|
confirmButtonText: "确定",
|
|
@@ -315,8 +277,9 @@
|
|
|
type: "warning"
|
|
|
}).then(() => {
|
|
|
let fd = new FormData();
|
|
|
- fd.append('id', id);
|
|
|
- api.deleteArticleById(fd).then(res => {
|
|
|
+ fd.append('id', data.id);
|
|
|
+ fd.append('picId', data.dishesPhotoPath);
|
|
|
+ api.deleteFoodById(fd).then(res => {
|
|
|
if (res.data.result) {
|
|
|
this.$message({
|
|
|
type: 'success',
|
|
@@ -418,57 +381,17 @@
|
|
|
] // 表头中文名
|
|
|
this.exportExcel('example', titleArr, 'sheet1')
|
|
|
},
|
|
|
- // 查看菜品类型信息
|
|
|
- typeInfo() {
|
|
|
- this.typeVisible = true;
|
|
|
- this.typeSorts.page = 1;
|
|
|
- this.typeSorts.limit = 10;
|
|
|
- this.typeSorts.typeName = '';
|
|
|
- this.getTypeData();
|
|
|
- },
|
|
|
// 获取菜品类型信息数据
|
|
|
getTypeData() {
|
|
|
- let params = {
|
|
|
- page: this.typeSorts.page,
|
|
|
- limit: this.typeSorts.limit,
|
|
|
- typeName: this.typeSorts.typeName
|
|
|
- }
|
|
|
- api.getFoodTypePage({
|
|
|
- params
|
|
|
- }).then(r => {
|
|
|
- this.typeTotal = r.data.count;
|
|
|
- this.typeData = r.data.data;
|
|
|
+ api.getAllFoodType().then(r => {
|
|
|
+ this.typeOptions = r.data.data.map(item => {
|
|
|
+ return {
|
|
|
+ value: item.id,
|
|
|
+ label: item.typeName
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
},
|
|
|
- //切换菜品类型条数
|
|
|
- typeSizeChange(pageSize) {
|
|
|
- this.typeSorts.limit = pageSize
|
|
|
- this.typeSorts.page = 1;
|
|
|
- this.getTypeData();
|
|
|
- },
|
|
|
- //切换菜品类型页码
|
|
|
- typeCurrentChange(currentPage) {
|
|
|
- this.$refs.typeTable.bodyWrapper.scrollTop = 0;
|
|
|
- this.typeSorts.page = currentPage;
|
|
|
- this.getTypeData();
|
|
|
- },
|
|
|
- // 选择菜品类型
|
|
|
- chooseType(data) {
|
|
|
- this.postManagement.typeId = data.id;
|
|
|
- this.postManagement.typeName = data.typeName;
|
|
|
- this.typeVisible = false;
|
|
|
- },
|
|
|
- // 搜索菜品类型信息
|
|
|
- searchType() {
|
|
|
- this.typeSorts.page = 1;
|
|
|
- this.getTypeData();
|
|
|
- },
|
|
|
- // 清空菜品类型输入框
|
|
|
- resetType() {
|
|
|
- this.typeSorts.typeName = '';
|
|
|
- this.typeSorts.page = 1;
|
|
|
- this.getTypeData()
|
|
|
- },
|
|
|
//上传文件
|
|
|
picChange(file, fileList) {
|
|
|
if (file.raw.type === 'image/png' || file.raw.type === 'image/jpg' || file.raw.type ===
|
|
@@ -482,10 +405,16 @@
|
|
|
},
|
|
|
//删除文件
|
|
|
picRemove(file, fileList) {
|
|
|
- console.log(file);
|
|
|
- console.log(fileList);
|
|
|
- console.log(this.postManagement.pic);
|
|
|
- console.log(this.picList);
|
|
|
+ if (this.postManagement.dishesPhotoPath) {
|
|
|
+ let temp = this.postManagement.dishesPhotoPath.split(",");
|
|
|
+ for (let i = 0; i < temp.length; i++) {
|
|
|
+ if (temp[i] == file.name) {
|
|
|
+ temp[i] = temp[i] + "x";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.postManagement.dishesPhotoPath = temp.join(",");
|
|
|
+ }
|
|
|
},
|
|
|
},
|
|
|
}
|