|
@@ -1,430 +1,740 @@
|
|
|
<template>
|
|
|
- <div class="yxnaContent">
|
|
|
- <!--操作栏-->
|
|
|
- <div style="display: flex;justify-content: space-between;margin-bottom: 10px">
|
|
|
- <div>
|
|
|
- <el-button type="primary" class="add" @click="openAddWork">新增</el-button>
|
|
|
- </div>
|
|
|
- <div style="display: flex">
|
|
|
- <el-input v-model.trim="query.canteenName" clearable placeholder="请输入食堂名称"
|
|
|
- style="margin: 0 10px;width: 200px" />
|
|
|
- <el-button type="primary" class="search" @click="searchData">搜索</el-button>
|
|
|
- <el-button type="primary" class="search" @click="reset" style="margin-left: 5px">重置</el-button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <!--表格-->
|
|
|
- <el-table :data="tableData" border ref='multipleTable' :height="tableH" stripe
|
|
|
- :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="canteenName" label="食堂名称" />
|
|
|
- <el-table-column prop="canteenPhotoPath" :show-overflow-tooltip="true" label="照片" />
|
|
|
- <el-table-column prop="supplyTimeId" :show-overflow-tooltip="true" label="供应时间ID" />
|
|
|
- <el-table-column prop="founder" label="创建人" />
|
|
|
- <el-table-column prop="createTime" 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>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
- <div class="block">
|
|
|
- <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
|
|
|
- :current-page="sorts.page" :page-sizes="[10, 20, 30, 40, 50]" :page-size="sorts.limit"
|
|
|
- layout="prev, pager,next,jumper,total,sizes" :total="total">
|
|
|
- </el-pagination>
|
|
|
- </div>
|
|
|
- <!-- 新增/编辑食堂 -->
|
|
|
- <el-dialog :visible.sync="workDialog" width="60%" class="detailDialog" :close-on-click-modal="false" top="40px">
|
|
|
- <div slot="title">
|
|
|
- <div class="addTitle">{{workTitle}}</div>
|
|
|
- </div>
|
|
|
- <div style="height:65vh;overflow: auto;padding-right: 20px">
|
|
|
- <el-form :model="postManagement" label-width="140px">
|
|
|
- <el-row>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="食堂名称" prop="canteenName">
|
|
|
- <el-input v-model="postManagement.canteenName" placeholder="请输入食堂名称">
|
|
|
- </el-input>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-row>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="供应时间" prop="url">
|
|
|
- <el-input v-model="postManagement.supplyTimeId" placeholder="供应时间id">
|
|
|
- </el-input>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-row>
|
|
|
- <el-col :span="24">
|
|
|
- <el-form-item label="食堂图片" prop="url">
|
|
|
- </el-form-item>
|
|
|
- <el-upload
|
|
|
- element-loading-text="数据上传中请等待..."
|
|
|
- action=""
|
|
|
- class="upload-demo"
|
|
|
- :on-change="handleChange"
|
|
|
- :multiple="false"
|
|
|
- :auto-upload="false"
|
|
|
- :http-request="saveWork"
|
|
|
- list-type="picture-card"
|
|
|
- accept=".jpg,.png"
|
|
|
- :show-file-list="true"
|
|
|
- :file-list="fileList"
|
|
|
- >
|
|
|
- <i class="el-icon-plus"></i>
|
|
|
- <div slot="tip" class="el-upload__tip">只能上传jps或png文件</div>
|
|
|
- </el-upload>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- </el-form>
|
|
|
- </div>
|
|
|
- <div slot="footer" class="dialog-footer">
|
|
|
- <el-button type="primary" size="mini" @click="saveWork">提交</el-button>
|
|
|
- <el-button @click="workDialog = false" size="mini">返回</el-button>
|
|
|
- </div>
|
|
|
- </el-dialog>
|
|
|
+ <div class="yxnaContent">
|
|
|
+ <!--操作栏-->
|
|
|
+ <div
|
|
|
+ style="display: flex; justify-content: space-between; margin-bottom: 10px"
|
|
|
+ >
|
|
|
+ <div>
|
|
|
+ <el-button type="primary" class="add" @click="openAddWork"
|
|
|
+ >新增</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ <div style="display: flex">
|
|
|
+ <el-input
|
|
|
+ v-model.trim="query.canteenName"
|
|
|
+ clearable
|
|
|
+ placeholder="请输入食堂名称"
|
|
|
+ style="margin: 0 10px; width: 200px"
|
|
|
+ />
|
|
|
+ <el-button type="primary" class="search" @click="searchData"
|
|
|
+ >搜索</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ class="search"
|
|
|
+ @click="reset"
|
|
|
+ style="margin-left: 5px"
|
|
|
+ >重置</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
</div>
|
|
|
+ <!--表格-->
|
|
|
+ <el-table
|
|
|
+ :data="tableData"
|
|
|
+ border
|
|
|
+ ref="multipleTable"
|
|
|
+ :height="tableH"
|
|
|
+ stripe
|
|
|
+ :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="canteenName" label="食堂名称" />
|
|
|
+ <!-- <el-table-column
|
|
|
+ prop="canteenPhotoPath"
|
|
|
+ :show-overflow-tooltip="true"
|
|
|
+ label="照片"
|
|
|
+ />
|
|
|
+ <el-table-column
|
|
|
+ prop="supplyTimeId"
|
|
|
+ :show-overflow-tooltip="true"
|
|
|
+ label="供应时间ID"
|
|
|
+ /> -->
|
|
|
+ <el-table-column prop="founder" label="创建人" />
|
|
|
+ <el-table-column prop="createTime" 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>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <div class="block">
|
|
|
+ <el-pagination
|
|
|
+ @size-change="handleSizeChange"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ :current-page="sorts.page"
|
|
|
+ :page-sizes="[10, 20, 30, 40, 50]"
|
|
|
+ :page-size="sorts.limit"
|
|
|
+ layout="prev, pager,next,jumper,total,sizes"
|
|
|
+ :total="total"
|
|
|
+ >
|
|
|
+ </el-pagination>
|
|
|
+ </div>
|
|
|
+ <!-- 新增/编辑食堂 -->
|
|
|
+ <el-dialog
|
|
|
+ :visible.sync="workDialog"
|
|
|
+ width="60%"
|
|
|
+ class="detailDialog"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ top="40px"
|
|
|
+ >
|
|
|
+ <div slot="title">
|
|
|
+ <div class="addTitle">{{ workTitle }}</div>
|
|
|
+ </div>
|
|
|
+ <div style="height: 65vh; overflow: auto; padding-right: 20px">
|
|
|
+ <el-form :model="postManagement" label-width="140px">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="食堂名称" prop="canteenName">
|
|
|
+ <el-input
|
|
|
+ v-model="postManagement.canteenName"
|
|
|
+ placeholder="请输入食堂名称"
|
|
|
+ style="width: 55%"
|
|
|
+ >
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="供应时间" prop="url">
|
|
|
+ <el-select
|
|
|
+ v-model="postManagement.supplyTimeId"
|
|
|
+ @change="timeNodeChange"
|
|
|
+ @remove-tag="timeNodeChange"
|
|
|
+ @visible-change="timeNodeChange"
|
|
|
+ multiple
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 55%; height: 110%"
|
|
|
+ >
|
|
|
+ <el-option-group
|
|
|
+ v-for="group in timeNodeOptions"
|
|
|
+ :key="group.label"
|
|
|
+ :label="group.label"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in group.options"
|
|
|
+ :key="item.id"
|
|
|
+ :label="
|
|
|
+ item.supplyStartTime + ' —— ' + item.supplyEndTime
|
|
|
+ "
|
|
|
+ :value="item.id"
|
|
|
+ :disabled="item.disabled"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-option-group>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="食堂图片" prop="url"> </el-form-item>
|
|
|
+ <el-upload
|
|
|
+ element-loading-text="数据上传中请等待..."
|
|
|
+ action=""
|
|
|
+ class="upload-demo"
|
|
|
+ :on-change="handleChange"
|
|
|
+ :multiple="false"
|
|
|
+ :auto-upload="false"
|
|
|
+ :http-request="saveWork"
|
|
|
+ list-type="picture-card"
|
|
|
+ accept="image/png,image/jpg,image/jpeg,image/bmp"
|
|
|
+ :show-file-list="true"
|
|
|
+ :file-list="fileList"
|
|
|
+ :on-remove="picRemove"
|
|
|
+ >
|
|
|
+ <i class="el-icon-plus"></i>
|
|
|
+ </el-upload>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" size="mini" @click="saveWork">提交</el-button>
|
|
|
+ <el-button @click="workDialog = false" size="mini">返回</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import api from '../../api/index'
|
|
|
+import api from "../../api/index";
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "CanteenManage",
|
|
|
+ created() {
|
|
|
+ this.getData();
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ tableStyle: {
|
|
|
+ textAlign: "center",
|
|
|
+ },
|
|
|
+ tableH: "calc(100vh - 230px)",
|
|
|
+ // 搜索参数
|
|
|
+ query: {
|
|
|
+ canteenName: "",
|
|
|
+ },
|
|
|
+ timeNodeList: [],
|
|
|
+ // 整体分组
|
|
|
+ timeNodeOptions: [],
|
|
|
+ timeNodeOption1: {
|
|
|
+ label: "早餐",
|
|
|
+ options: [],
|
|
|
+ },
|
|
|
+ timeNodeOption2: {
|
|
|
+ label: "中餐",
|
|
|
+ options: [],
|
|
|
+ },
|
|
|
+ timeNodeOption3: {
|
|
|
+ label: "晚餐",
|
|
|
+ options: [],
|
|
|
+ },
|
|
|
+ timeNodeOption4: {
|
|
|
+ label: "外卖",
|
|
|
+ options: [],
|
|
|
+ },
|
|
|
|
|
|
- export default {
|
|
|
- name: 'CanteenManage',
|
|
|
- created() {
|
|
|
- this.getData()
|
|
|
- },
|
|
|
- data() {
|
|
|
- return {
|
|
|
- tableStyle: {
|
|
|
- textAlign: 'center',
|
|
|
- },
|
|
|
- tableH: 'calc(100vh - 230px)',
|
|
|
- // 搜索参数
|
|
|
- query: {
|
|
|
- canteenName: ''
|
|
|
- },
|
|
|
- // 列表数据
|
|
|
- tableData: [],
|
|
|
- // 总数
|
|
|
- total: 0,
|
|
|
- //新增/编辑食堂界面
|
|
|
- workDialog: false,
|
|
|
- //新增/编辑食堂标题
|
|
|
- workTitle: '新增食堂',
|
|
|
- // 新增/编辑表单
|
|
|
- postManagement: {
|
|
|
- canteenName: '',
|
|
|
- canteenPhotoPath: '',
|
|
|
- supplyTimeId: ''
|
|
|
- },
|
|
|
- // 分页
|
|
|
- sorts: {
|
|
|
- page: 1,
|
|
|
- limit: 10,
|
|
|
- },
|
|
|
- uploadFiles: [],
|
|
|
- fileList: []
|
|
|
+ // 早餐列表
|
|
|
+ timeNodeList1: [],
|
|
|
+ // 中餐列表
|
|
|
+ timeNodeList2: [],
|
|
|
+ timeNodeList3: [],
|
|
|
+ timeNodeList4: [],
|
|
|
+ // 列表数据
|
|
|
+ tableData: [],
|
|
|
+ // 总数
|
|
|
+ total: 0,
|
|
|
+ //新增/编辑食堂界面
|
|
|
+ workDialog: false,
|
|
|
+ //新增/编辑食堂标题
|
|
|
+ workTitle: "新增食堂",
|
|
|
+ // 新增/编辑表单
|
|
|
+ postManagement: {
|
|
|
+ canteenName: "",
|
|
|
+ canteenPhotoPath: "",
|
|
|
+ supplyTimeId: [],
|
|
|
+ },
|
|
|
+ // 分页
|
|
|
+ sorts: {
|
|
|
+ page: 1,
|
|
|
+ limit: 10,
|
|
|
+ },
|
|
|
+ uploadFiles: [],
|
|
|
+ fileList: [],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ //删除文件
|
|
|
+ picRemove(file, fileList) {
|
|
|
+ if (this.postManagement.canteenPhotoPath) {
|
|
|
+ let temp = this.postManagement.canteenPhotoPath.split(",");
|
|
|
+ for (let i = 0; i < temp.length; i++) {
|
|
|
+ if (temp[i] == file.name) {
|
|
|
+ temp[i] = temp[i] + "x";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.postManagement.canteenPhotoPath = temp.join(",");
|
|
|
+ }
|
|
|
+ this.uploadFiles = fileList;
|
|
|
+ },
|
|
|
+ // 根据选择的时间节点,禁用相同类型的选项
|
|
|
+ timeNodeChange() {
|
|
|
+ // 分别代表早中晚快递选择的数量
|
|
|
+ let timeNodeNum1 = 0;
|
|
|
+ let timeNodeNum2 = 0;
|
|
|
+ let timeNodeNum3 = 0;
|
|
|
+ let timeNodeNum4 = 0;
|
|
|
+ if (
|
|
|
+ this.postManagement.supplyTimeId &&
|
|
|
+ this.postManagement.supplyTimeId.length > 0
|
|
|
+ ) {
|
|
|
+ // 遍历已选择的选项
|
|
|
+ this.postManagement.supplyTimeId.forEach((item) => {
|
|
|
+ let index = this.timeNodeList.findIndex(function (node) {
|
|
|
+ return item === node.id;
|
|
|
+ });
|
|
|
+ // 找到时间节点类型
|
|
|
+ if (index !== -1) {
|
|
|
+ let nodeType = this.timeNodeList[index].timeNode;
|
|
|
+ switch (nodeType) {
|
|
|
+ case 1:
|
|
|
+ timeNodeNum1++;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ timeNodeNum2++;
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ timeNodeNum3++;
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ timeNodeNum4++;
|
|
|
+ break;
|
|
|
}
|
|
|
- },
|
|
|
- methods: {
|
|
|
- handleChange(file, fileList) {
|
|
|
- // 文件改变
|
|
|
- this.uploadFiles = fileList
|
|
|
- },
|
|
|
- //打开新增食堂界面
|
|
|
- openAddWork() {
|
|
|
- this.postManagement = {
|
|
|
- canteenName: '',
|
|
|
- canteenPhotoPath: '',
|
|
|
- supplyTimeId: ''
|
|
|
- };
|
|
|
- this.workTitle = '新增食堂'
|
|
|
- this.workDialog = true;
|
|
|
- },
|
|
|
- //打开修改食堂界面
|
|
|
- openModifyWorkDialog(data) {
|
|
|
- this.workTitle = '编辑食堂';
|
|
|
- this.postManagement = JSON.parse(JSON.stringify(data));
|
|
|
- this.workDialog = true;
|
|
|
- },
|
|
|
- //保存
|
|
|
- saveWork() {
|
|
|
- if (!this.postManagement.canteenName) {
|
|
|
- this.$message.error('请输入食堂名称!');
|
|
|
- return;
|
|
|
- }
|
|
|
- if (this.workTitle == '编辑食堂') {
|
|
|
- api.updateCanteen(this.postManagement).then(r => {
|
|
|
- if (r.data.result) {
|
|
|
- this.$message.success('编辑成功');
|
|
|
- this.getData();
|
|
|
- this.workDialog = false;
|
|
|
- } else {
|
|
|
- this.$message.error("编辑失败");
|
|
|
- }
|
|
|
- }).catch(() => {
|
|
|
- this.$message.error("编辑失败");
|
|
|
- })
|
|
|
- } else {
|
|
|
- let files = []
|
|
|
- console.log('uploadFiles', this.uploadFiles)
|
|
|
- this.uploadFiles.forEach((item) => {
|
|
|
- console.log(item)
|
|
|
- files.push(item.raw)
|
|
|
- })
|
|
|
- var params = new FormData()
|
|
|
- this.postManagement.founder = sessionStorage.getItem('pid')
|
|
|
- console.log(files)
|
|
|
- console.log(this.postManagement)
|
|
|
- params.append('files', files)
|
|
|
- params.append('canteenName', this.postManagement.canteenName)
|
|
|
- console.log('params', params)
|
|
|
- api.addCanteen(params).then(r => {
|
|
|
- if (r.data.result) {
|
|
|
- this.$message.success('新增成功');
|
|
|
- this.getData();
|
|
|
- this.workDialog = false;
|
|
|
- } else {
|
|
|
- this.$message.error("新增失败");
|
|
|
- }
|
|
|
- }).catch(() => {
|
|
|
- this.$message.error("新增失败");
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- //切换列表条数
|
|
|
- handleSizeChange(pageSize) {
|
|
|
- this.sorts.limit = pageSize
|
|
|
- this.sorts.page = 1;
|
|
|
- this.getData();
|
|
|
- },
|
|
|
- //切换页码
|
|
|
- handleCurrentChange(currentPage) {
|
|
|
- this.$refs.multipleTable.bodyWrapper.scrollTop = 0;
|
|
|
- this.sorts.page = currentPage;
|
|
|
- this.getData();
|
|
|
- },
|
|
|
- //删除
|
|
|
- handleDelete(id, index) {
|
|
|
- this.$confirm("您确定要删除该数据吗?", "提示", {
|
|
|
- cancelButtonClass: "btn-custom-cancel",
|
|
|
- confirmButtonText: "确定",
|
|
|
- cancelButtonText: "取消",
|
|
|
- type: "warning"
|
|
|
- }).then(() => {
|
|
|
- let fd = new FormData();
|
|
|
- fd.append('id', id);
|
|
|
- api.deleteCanteenById(fd).then(res => {
|
|
|
- if (res.data.result) {
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '删除成功!'
|
|
|
- });
|
|
|
- this.tableData.splice(index, 1);
|
|
|
- this.getData();
|
|
|
- } else {
|
|
|
- this.$message({
|
|
|
- type: 'info',
|
|
|
- message: '删除失败!'
|
|
|
- });
|
|
|
- }
|
|
|
- })
|
|
|
- }).catch(() => {
|
|
|
- this.$message({
|
|
|
- type: 'info',
|
|
|
- message: '已取消删除'
|
|
|
- });
|
|
|
- })
|
|
|
- },
|
|
|
- // 获取列表数据
|
|
|
- getData() {
|
|
|
- let params = {
|
|
|
- page: this.sorts.page,
|
|
|
- limit: this.sorts.limit,
|
|
|
- canteenName: this.query.canteenName
|
|
|
- }
|
|
|
- api.canteenPage({
|
|
|
- params
|
|
|
- }).then(r => {
|
|
|
- this.total = r.data.count
|
|
|
- this.tableData = r.data.data
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (timeNodeNum1 > 0) {
|
|
|
+ this.timeNodeList1.forEach((node1) => {
|
|
|
+ node1.disabled = true;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.timeNodeList1.forEach((node1) => {
|
|
|
+ node1.disabled = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (timeNodeNum2 > 0) {
|
|
|
+ this.timeNodeList2.forEach((node1) => {
|
|
|
+ node1.disabled = true;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.timeNodeList2.forEach((node1) => {
|
|
|
+ node1.disabled = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (timeNodeNum3 > 0) {
|
|
|
+ this.timeNodeList3.forEach((node1) => {
|
|
|
+ node1.disabled = true;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.timeNodeList3.forEach((node1) => {
|
|
|
+ node1.disabled = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (timeNodeNum4 > 0) {
|
|
|
+ this.timeNodeList4.forEach((node1) => {
|
|
|
+ node1.disabled = true;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.timeNodeList4.forEach((node1) => {
|
|
|
+ node1.disabled = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleChange(file, fileList) {
|
|
|
+ // 文件改变
|
|
|
+ this.uploadFiles = fileList;
|
|
|
+ },
|
|
|
+ //打开新增食堂界面
|
|
|
+ openAddWork() {
|
|
|
+ api
|
|
|
+ .supplyTimeList()
|
|
|
+ .then((r) => {
|
|
|
+ if (r.data.result) {
|
|
|
+ // 拿到时间节点,并分组
|
|
|
+ this.timeNodeList = r.data.data;
|
|
|
+ this.timeNodeList1 = this.timeNodeList.filter((item) => {
|
|
|
+ return item.timeNode === 1;
|
|
|
+ });
|
|
|
+ this.timeNodeList2 = this.timeNodeList.filter((item) => {
|
|
|
+ return item.timeNode === 2;
|
|
|
+ });
|
|
|
+ this.timeNodeList3 = this.timeNodeList.filter((item) => {
|
|
|
+ return item.timeNode === 3;
|
|
|
+ });
|
|
|
+ this.timeNodeList4 = this.timeNodeList.filter((item) => {
|
|
|
+ return item.timeNode === 4;
|
|
|
+ });
|
|
|
+ this.timeNodeOption1.options = this.timeNodeList1;
|
|
|
+ this.timeNodeOption2.options = this.timeNodeList2;
|
|
|
+ this.timeNodeOption3.options = this.timeNodeList3;
|
|
|
+ this.timeNodeOption4.options = this.timeNodeList4;
|
|
|
+ this.timeNodeOptions = [];
|
|
|
+ this.timeNodeOptions.push(
|
|
|
+ this.timeNodeOption1,
|
|
|
+ this.timeNodeOption2,
|
|
|
+ this.timeNodeOption3,
|
|
|
+ this.timeNodeOption4
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ this.$message.error("获取时间节点列表失败");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.$message.error("获取时间节点列表失败");
|
|
|
+ });
|
|
|
+ this.postManagement = {
|
|
|
+ canteenName: "",
|
|
|
+ canteenPhotoPath: "",
|
|
|
+ supplyTimeId: [],
|
|
|
+ };
|
|
|
+ this.fileList = [];
|
|
|
+ this.workTitle = "新增食堂";
|
|
|
+ this.workDialog = true;
|
|
|
+ },
|
|
|
+ //打开修改食堂界面
|
|
|
+ openModifyWorkDialog(data) {
|
|
|
+ api
|
|
|
+ .supplyTimeList()
|
|
|
+ .then((r) => {
|
|
|
+ if (r.data.result) {
|
|
|
+ // 拿到时间节点列表,并分组
|
|
|
+ this.timeNodeList = r.data.data;
|
|
|
+ this.timeNodeList1 = this.timeNodeList.filter((item) => {
|
|
|
+ return item.timeNode === 1;
|
|
|
+ });
|
|
|
+ this.timeNodeList2 = this.timeNodeList.filter((item) => {
|
|
|
+ return item.timeNode === 2;
|
|
|
+ });
|
|
|
+ this.timeNodeList3 = this.timeNodeList.filter((item) => {
|
|
|
+ return item.timeNode === 3;
|
|
|
+ });
|
|
|
+ this.timeNodeList4 = this.timeNodeList.filter((item) => {
|
|
|
+ return item.timeNode === 4;
|
|
|
+ });
|
|
|
+ this.timeNodeOption1.options = this.timeNodeList1;
|
|
|
+ this.timeNodeOption2.options = this.timeNodeList2;
|
|
|
+ this.timeNodeOption3.options = this.timeNodeList3;
|
|
|
+ this.timeNodeOption4.options = this.timeNodeList4;
|
|
|
+ this.timeNodeOptions = [];
|
|
|
+ this.timeNodeOptions.push(
|
|
|
+ this.timeNodeOption1,
|
|
|
+ this.timeNodeOption2,
|
|
|
+ this.timeNodeOption3,
|
|
|
+ this.timeNodeOption4
|
|
|
+ );
|
|
|
+ this.postManagement = JSON.parse(JSON.stringify(data));
|
|
|
+ if (this.postManagement.supplyTimeId && this.postManagement.supplyTimeId !== '') {
|
|
|
+ this.postManagement.supplyTimeId =
|
|
|
+ this.postManagement.supplyTimeId.split(",");
|
|
|
+ }
|
|
|
+ this.timeNodeChange();
|
|
|
+ this.fileList = [];
|
|
|
+ let params = {
|
|
|
+ picId: this.postManagement.canteenPhotoPath,
|
|
|
+ };
|
|
|
+ if (params.picId && params.picId !== "") {
|
|
|
+ api
|
|
|
+ .getFoodPicByPicId({
|
|
|
+ params,
|
|
|
})
|
|
|
- },
|
|
|
- // 搜索
|
|
|
- searchData() {
|
|
|
- this.sorts.page = 1;
|
|
|
- this.getData()
|
|
|
- },
|
|
|
- // 清空输入框
|
|
|
- reset() {
|
|
|
- this.query.canteenName = ''
|
|
|
- this.sorts.page = 1
|
|
|
- this.getData()
|
|
|
+ .then((res) => {
|
|
|
+ if (res.data.result) {
|
|
|
+ this.fileList = res.data.data.map((item) => {
|
|
|
+ return {
|
|
|
+ url: item.path,
|
|
|
+ name: item.id,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$message.error("获取时间节点列表失败");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.$message.error("获取时间节点列表失败");
|
|
|
+ });
|
|
|
+ this.workTitle = "编辑食堂";
|
|
|
+ this.postManagement = JSON.parse(JSON.stringify(data));
|
|
|
+ this.workDialog = true;
|
|
|
+ },
|
|
|
+ //保存
|
|
|
+ saveWork() {
|
|
|
+ if (!this.postManagement.canteenName) {
|
|
|
+ this.$message.error("请输入食堂名称!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let params = new FormData();
|
|
|
+ this.uploadFiles.forEach((item) => {
|
|
|
+ params.append("files", item.raw);
|
|
|
+ });
|
|
|
+ params.append("id", this.postManagement.id);
|
|
|
+ if (this.postManagement.supplyTimeId) {
|
|
|
+ params.append("supplyTimeId", this.postManagement.supplyTimeId);
|
|
|
+ }
|
|
|
+ params.append("canteenName", this.postManagement.canteenName);
|
|
|
+ if (this.postManagement.canteenPhotoPath) {
|
|
|
+ params.append("canteenPhotoPath", this.postManagement.canteenPhotoPath);
|
|
|
+ }
|
|
|
+ if (this.workTitle == "编辑食堂") {
|
|
|
+ api
|
|
|
+ .updateCanteen(params)
|
|
|
+ .then((r) => {
|
|
|
+ if (r.data.result) {
|
|
|
+ this.$message.success("编辑成功");
|
|
|
+ this.getData();
|
|
|
+ this.workDialog = false;
|
|
|
+ } else {
|
|
|
+ this.$message.error(r.data.msg);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.$message.error(r.data.msg);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ let params = new FormData();
|
|
|
+ this.uploadFiles.forEach((item) => {
|
|
|
+ params.append("files", item.raw);
|
|
|
+ });
|
|
|
+ params.append("founder", sessionStorage.getItem("pid"));
|
|
|
+ params.append("supplyTimeId", this.postManagement.supplyTimeId);
|
|
|
+ params.append("canteenName", this.postManagement.canteenName);
|
|
|
+ api
|
|
|
+ .addCanteen(params)
|
|
|
+ .then((r) => {
|
|
|
+ if (r.data.result) {
|
|
|
+ this.$message.success("新增成功");
|
|
|
+ this.getData();
|
|
|
+ this.workDialog = false;
|
|
|
+ } else {
|
|
|
+ this.$message.error(r.data.msg);
|
|
|
}
|
|
|
- },
|
|
|
- }
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.$message.error(r.data.msg);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //切换列表条数
|
|
|
+ handleSizeChange(pageSize) {
|
|
|
+ this.sorts.limit = pageSize;
|
|
|
+ this.sorts.page = 1;
|
|
|
+ this.getData();
|
|
|
+ },
|
|
|
+ //切换页码
|
|
|
+ handleCurrentChange(currentPage) {
|
|
|
+ this.$refs.multipleTable.bodyWrapper.scrollTop = 0;
|
|
|
+ this.sorts.page = currentPage;
|
|
|
+ this.getData();
|
|
|
+ },
|
|
|
+ //删除
|
|
|
+ handleDelete(id, index) {
|
|
|
+ this.$confirm("您确定要删除该数据吗?", "提示", {
|
|
|
+ cancelButtonClass: "btn-custom-cancel",
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ let fd = new FormData();
|
|
|
+ fd.append("id", id);
|
|
|
+ api.deleteCanteenById(fd).then((res) => {
|
|
|
+ if (res.data.result) {
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "删除成功!",
|
|
|
+ });
|
|
|
+ this.tableData.splice(index, 1);
|
|
|
+ this.getData();
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ type: "info",
|
|
|
+ message: "删除失败!",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: "info",
|
|
|
+ message: "已取消删除",
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 获取列表数据
|
|
|
+ getData() {
|
|
|
+ let params = {
|
|
|
+ page: this.sorts.page,
|
|
|
+ limit: this.sorts.limit,
|
|
|
+ canteenName: this.query.canteenName,
|
|
|
+ };
|
|
|
+ api
|
|
|
+ .canteenPage({
|
|
|
+ params,
|
|
|
+ })
|
|
|
+ .then((r) => {
|
|
|
+ this.total = r.data.count;
|
|
|
+ this.tableData = r.data.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 搜索
|
|
|
+ searchData() {
|
|
|
+ this.sorts.page = 1;
|
|
|
+ this.getData();
|
|
|
+ },
|
|
|
+ // 清空输入框
|
|
|
+ reset() {
|
|
|
+ this.query.canteenName = "";
|
|
|
+ this.sorts.page = 1;
|
|
|
+ this.getData();
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style>
|
|
|
- /* 全局取消按钮 */
|
|
|
- .btn-custom-cancel {
|
|
|
- margin-left: 10px !important;
|
|
|
- float: right;
|
|
|
- }
|
|
|
+/* 全局取消按钮 */
|
|
|
+.btn-custom-cancel {
|
|
|
+ margin-left: 10px !important;
|
|
|
+ float: right;
|
|
|
+}
|
|
|
</style>
|
|
|
|
|
|
<style scoped lang="less">
|
|
|
- /* 禁用后的勾选*/
|
|
|
- /deep/ .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after {
|
|
|
- border-color: #def5cb;
|
|
|
- }
|
|
|
-
|
|
|
- /deep/ .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
|
|
|
- background-color: #157de9;
|
|
|
- border-color: #DCDFE6;
|
|
|
- }
|
|
|
+/* 禁用后的勾选*/
|
|
|
+/deep/ .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after {
|
|
|
+ border-color: #def5cb;
|
|
|
+}
|
|
|
|
|
|
- /deep/ .el-dialog__body {
|
|
|
- padding: 0 0 30px 20px;
|
|
|
- color: #606266;
|
|
|
- font-size: 14px;
|
|
|
- word-break: break-all;
|
|
|
- }
|
|
|
+/deep/ .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
|
|
|
+ background-color: #157de9;
|
|
|
+ border-color: #dcdfe6;
|
|
|
+}
|
|
|
|
|
|
- /deep/ .el-dialog {
|
|
|
- margin: 0 auto 0;
|
|
|
- }
|
|
|
+/deep/ .el-dialog__body {
|
|
|
+ padding: 0 0 30px 20px;
|
|
|
+ color: #606266;
|
|
|
+ font-size: 14px;
|
|
|
+ word-break: break-all;
|
|
|
+}
|
|
|
|
|
|
- /deep/ .el-form-item__label {
|
|
|
- padding: 0;
|
|
|
- }
|
|
|
+/deep/ .el-dialog {
|
|
|
+ margin: 0 auto 0;
|
|
|
+}
|
|
|
|
|
|
- .yxnaContent {
|
|
|
- padding: 10px;
|
|
|
- }
|
|
|
+/deep/ .el-form-item__label {
|
|
|
+ padding: 0;
|
|
|
+}
|
|
|
|
|
|
- .addTitle {
|
|
|
- font-size: 18px;
|
|
|
- font-weight: bold;
|
|
|
- margin-bottom: 10px;
|
|
|
- }
|
|
|
+.yxnaContent {
|
|
|
+ padding: 10px;
|
|
|
+}
|
|
|
|
|
|
- .add {
|
|
|
- width: 66px;
|
|
|
- height: 38px;
|
|
|
- margin-left: 0;
|
|
|
- }
|
|
|
+.addTitle {
|
|
|
+ font-size: 18px;
|
|
|
+ font-weight: bold;
|
|
|
+ margin-bottom: 10px;
|
|
|
+}
|
|
|
|
|
|
- /deep/ .el-col-12 {
|
|
|
- width: 50%;
|
|
|
- text-align: left;
|
|
|
- }
|
|
|
+.add {
|
|
|
+ width: 66px;
|
|
|
+ height: 38px;
|
|
|
+ margin-left: 0;
|
|
|
+}
|
|
|
|
|
|
- .search {
|
|
|
- width: 66px;
|
|
|
- height: 38px;
|
|
|
- margin-left: 0;
|
|
|
- }
|
|
|
+/deep/ .el-col-12 {
|
|
|
+ width: 50%;
|
|
|
+ text-align: left;
|
|
|
+}
|
|
|
|
|
|
- /deep/ .el-form-item__label {
|
|
|
- height: 40px;
|
|
|
- width: 110px;
|
|
|
- background-color: #FAFAFA;
|
|
|
- text-align: center;
|
|
|
- border: 1px solid #DCDFE6;
|
|
|
- border-radius: 2px 0 0 2px;
|
|
|
- }
|
|
|
+.search {
|
|
|
+ width: 66px;
|
|
|
+ height: 38px;
|
|
|
+ margin-left: 0;
|
|
|
+}
|
|
|
|
|
|
- /deep/ .el-button.is-disabled {
|
|
|
- color: #C0C4CC !important;
|
|
|
- }
|
|
|
+/deep/ .el-form-item__label {
|
|
|
+ height: 40px;
|
|
|
+ width: 110px;
|
|
|
+ background-color: #fafafa;
|
|
|
+ text-align: center;
|
|
|
+ border: 1px solid #dcdfe6;
|
|
|
+ border-radius: 2px 0 0 2px;
|
|
|
+}
|
|
|
|
|
|
- /deep/.el-button--primary.is-disabled {
|
|
|
- color: #FFF !important;
|
|
|
- }
|
|
|
+/deep/ .el-button.is-disabled {
|
|
|
+ color: #c0c4cc !important;
|
|
|
+}
|
|
|
|
|
|
- /deep/ .el-input__inner {
|
|
|
- border-radius: 2px 0 0 2px;
|
|
|
- }
|
|
|
+/deep/.el-button--primary.is-disabled {
|
|
|
+ color: #fff !important;
|
|
|
+}
|
|
|
|
|
|
- .el-select>.el-input {
|
|
|
- width: 200px;
|
|
|
- }
|
|
|
+/deep/ .el-input__inner {
|
|
|
+ border-radius: 2px 0 0 2px;
|
|
|
+}
|
|
|
|
|
|
- /deep/ .el-textarea__inner {
|
|
|
- height: 100px;
|
|
|
- }
|
|
|
+.el-select > .el-input {
|
|
|
+ width: 200px;
|
|
|
+}
|
|
|
|
|
|
+/deep/ .el-textarea__inner {
|
|
|
+ height: 100px;
|
|
|
+}
|
|
|
|
|
|
- /deep/ .el-dialog__title {
|
|
|
- font-size: 14px;
|
|
|
- }
|
|
|
+/deep/ .el-dialog__title {
|
|
|
+ font-size: 14px;
|
|
|
+}
|
|
|
|
|
|
- /deep/ .el-pagination__total {
|
|
|
- margin-left: 10px !important;
|
|
|
- }
|
|
|
+/deep/ .el-pagination__total {
|
|
|
+ margin-left: 10px !important;
|
|
|
+}
|
|
|
|
|
|
- .el-pagination {
|
|
|
- margin: 0;
|
|
|
- margin-top: 10px;
|
|
|
- /* position: fixed;
|
|
|
+.el-pagination {
|
|
|
+ margin: 0;
|
|
|
+ margin-top: 10px;
|
|
|
+ /* position: fixed;
|
|
|
left: 13rem; */
|
|
|
- }
|
|
|
+}
|
|
|
|
|
|
- /deep/ .el-table--scrollable-x .el-table__body-wrapper {
|
|
|
- z-index: 2;
|
|
|
- }
|
|
|
+/deep/ .el-table--scrollable-x .el-table__body-wrapper {
|
|
|
+ z-index: 2;
|
|
|
+}
|
|
|
|
|
|
- .imgBox {
|
|
|
- width: 100%;
|
|
|
- /*height: 55vh;*/
|
|
|
- height: 100%;
|
|
|
- }
|
|
|
+.imgBox {
|
|
|
+ width: 100%;
|
|
|
+ /*height: 55vh;*/
|
|
|
+ height: 100%;
|
|
|
+}
|
|
|
|
|
|
- .but {
|
|
|
- width: 36px;
|
|
|
- height: 22px;
|
|
|
- padding: 0;
|
|
|
- font-size: 12px;
|
|
|
- }
|
|
|
+.but {
|
|
|
+ width: 36px;
|
|
|
+ height: 22px;
|
|
|
+ padding: 0;
|
|
|
+ font-size: 12px;
|
|
|
+}
|
|
|
|
|
|
- .el-checkbox {
|
|
|
- margin: 0;
|
|
|
- margin-right: 10px;
|
|
|
- }
|
|
|
+.el-checkbox {
|
|
|
+ margin: 0;
|
|
|
+ margin-right: 10px;
|
|
|
+}
|
|
|
|
|
|
- /deep/ .bewrite>.el-form-item__label {
|
|
|
- width: 100%;
|
|
|
- text-align: left;
|
|
|
- padding-left: 21px;
|
|
|
- }
|
|
|
+/deep/ .bewrite > .el-form-item__label {
|
|
|
+ width: 100%;
|
|
|
+ text-align: left;
|
|
|
+ padding-left: 21px;
|
|
|
+}
|
|
|
|
|
|
- /deep/ .el-form--inline .el-form-item {
|
|
|
- margin-right: 0px;
|
|
|
- }
|
|
|
+/deep/ .el-form--inline .el-form-item {
|
|
|
+ margin-right: 0px;
|
|
|
+}
|
|
|
|
|
|
- /deep/ [data-v-2cde7735] .el-form-item__label {
|
|
|
- border: 1px solid #DCDFE6;
|
|
|
- /*border-right: transparent;*/
|
|
|
- }
|
|
|
+/deep/ [data-v-2cde7735] .el-form-item__label {
|
|
|
+ border: 1px solid #dcdfe6;
|
|
|
+ /*border-right: transparent;*/
|
|
|
+}
|
|
|
|
|
|
- /* 空白框*/
|
|
|
- /deep/ .formTempBox {
|
|
|
- height: 38px;
|
|
|
- border: 1px solid #DCDFE6;
|
|
|
- width: 100%;
|
|
|
- border-left: transparent;
|
|
|
- background-color: #FAFAFA;
|
|
|
- }
|
|
|
+/* 空白框*/
|
|
|
+/deep/ .formTempBox {
|
|
|
+ height: 38px;
|
|
|
+ border: 1px solid #dcdfe6;
|
|
|
+ width: 100%;
|
|
|
+ border-left: transparent;
|
|
|
+ background-color: #fafafa;
|
|
|
+}
|
|
|
</style>
|