You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
16 KiB
2 lines
16 KiB
"use strict";(self["webpackChunkeatwhat_admin"]=self["webpackChunkeatwhat_admin"]||[]).push([[339],{7339:function(e,t,a){a.r(t),a.d(t,{default:function(){return o}});var n=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("el-card",[a("div",{staticClass:"menu"},[a("div",{staticClass:"title"},[a("el-alert",{attrs:{title:"菜谱管理界面",type:"success",center:"",closable:!1}})],1),a("div",{staticClass:"btn"},[a("el-button",{attrs:{type:"primary",size:"small",round:"",icon:"el-icon-plus"},on:{click:e.addMenuClick}},[e._v("添加新菜谱")])],1),a("div",{staticClass:"table"},[a("el-table",{staticStyle:{width:"100%"},attrs:{data:e.menu.filter((function(t){return!e.menuSearch||t.menuName.toLowerCase().includes(e.menuSearch.toLowerCase())})),fit:"",lazy:"",stripe:!0,border:!0,"highlight-current-row":!0,"empty-text":"🥶正在努力加载中..."}},[a("el-table-column",{attrs:{type:"expand"},scopedSlots:e._u([{key:"default",fn:function(t){return[a("div",{staticClass:"desc"},[a("div",{staticClass:"desc-title"},[a("span",[e._v("描述信息:")])]),a("div",{staticClass:"brief"},[e._v(e._s(t.row.menuBrief||"暂无"))])])]}}])}),a("el-table-column",{attrs:{label:"菜谱名称",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.menuName||"未知")+" ")]}}])}),a("el-table-column",{attrs:{label:"图片",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[a("el-image",{staticStyle:{width:"100px",height:"100px"},attrs:{src:t.row.menuPut,"preview-src-list":e.menuImgs}},[a("div",{staticClass:"image-slot",attrs:{slot:"error"},slot:"error"},[a("i",{staticClass:"el-icon-picture-outline"})])])]}}])}),a("el-table-column",{attrs:{label:"组成",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.menuEle||"未知")+" ")]}}])}),a("el-table-column",{attrs:{label:"口味",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.menuTaste||"未知")+" ")]}}])}),a("el-table-column",{attrs:{label:"菜系",align:"center",width:"100"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.menuCuis||"未知")+" ")]}}])}),a("el-table-column",{attrs:{label:"难度",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[a("el-rate",{attrs:{disabled:"","text-color":"#ff9900"},model:{value:t.row.menuLevel,callback:function(a){e.$set(t.row,"menuLevel",a)},expression:"scope.row.menuLevel"}})]}}])}),a("el-table-column",{attrs:{label:"价格",align:"center",width:"100"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.menuPrice)+" 元 ")]}}])}),a("el-table-column",{attrs:{align:"center"},scopedSlots:e._u([{key:"header",fn:function(t){return[a("el-input",{attrs:{size:"mini",placeholder:"输入菜谱名称搜索"},model:{value:e.menuSearch,callback:function(t){e.menuSearch=t},expression:"menuSearch"}})]}},{key:"default",fn:function(t){return[a("el-button",{attrs:{type:"primary",size:"mini",plain:""},on:{click:function(a){return e.showUpdateMenu(t.row.menuId)}}},[e._v("编辑")]),a("el-popconfirm",{staticStyle:{"margin-left":"5px"},attrs:{title:"确定删除该菜谱?此操作不可逆"},on:{confirm:function(a){return e.deleteMenu(t.row.menuId)}}},[a("el-button",{attrs:{slot:"reference",type:"danger",size:"mini",plain:""},slot:"reference"},[e._v("删除")])],1)]}}])})],1)],1)]),a("el-dialog",{attrs:{title:"添加菜谱",visible:e.addMenuDialogVisible,width:"40%",center:!0},on:{"update:visible":function(t){e.addMenuDialogVisible=t},close:e.addMenuDialogClosed}},[a("el-form",{ref:"addMenuFormRef",attrs:{model:e.addMenuForm,"label-width":"80px",size:"small",rules:e.addMenuFormRules}},[a("el-form-item",{attrs:{label:"菜谱名称",prop:"menuName"}},[a("el-input",{attrs:{"prefix-icon":"el-icon-food",autocomplete:"off",maxlength:"50",clearable:!0},model:{value:e.addMenuForm.menuName,callback:function(t){e.$set(e.addMenuForm,"menuName",t)},expression:"addMenuForm.menuName"}})],1),a("el-form-item",{attrs:{label:"菜谱组成"}},[e._l(e.dynamicIngredientTags,(function(t){return a("el-tag",{key:t,staticStyle:{margin:"5px"},attrs:{closable:"","disable-transitions":!1},on:{close:function(a){return e.handleIngredientClose(t)}}},[e._v(" "+e._s(t)+" ")])})),e.inputIngredientVisible?a("el-input",{ref:"saveTagInput",staticClass:"input-new-tag",attrs:{size:"small"},on:{blur:e.handleInputConfirm},nativeOn:{keyup:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.handleInputConfirm.apply(null,arguments)}},model:{value:e.inputIngredientValue,callback:function(t){e.inputIngredientValue=t},expression:"inputIngredientValue"}}):a("el-button",{staticClass:"button-new-tag",attrs:{size:"small"},on:{click:e.showInput}},[e._v("+ 原料")])],2),a("el-form-item",{attrs:{label:"预估价格",prop:"menuPrice"}},[a("el-input",{attrs:{autocomplete:"off","prefix-icon":"el-icon-wallet",clearable:!0,maxlength:"5"},model:{value:e.addMenuForm.menuPrice,callback:function(t){e.$set(e.addMenuForm,"menuPrice",e._n(t))},expression:"addMenuForm.menuPrice"}},[a("i",{attrs:{slot:"suffix"},slot:"suffix"},[e._v("元")])])],1),a("el-form-item",{attrs:{label:"菜谱口味",prop:"menuTaste"}},[a("el-select",{attrs:{filterable:"",clearable:"",placeholder:"请选择菜谱口味"},model:{value:e.addMenuForm.menuTaste,callback:function(t){e.$set(e.addMenuForm,"menuTaste",t)},expression:"addMenuForm.menuTaste"}},e._l(e.menuTastes,(function(e){return a("el-option",{key:e.value,attrs:{label:e.label,value:e.value}})})),1)],1),a("el-form-item",{attrs:{label:"菜谱图片"}},[a("el-upload",{ref:"upload",attrs:{action:"http://121.37.102.50:3006/menu/upload","on-change":e.uploadImg,"on-success":e.uploadImgSuccess,accept:".jpeg,.png,.jpg,.bmp,.gif","list-type":"picture",limit:1,disabled:e.uploadImgBtnVisible}},[a("el-button",{directives:[{name:"show",rawName:"v-show",value:!e.uploadImgBtnVisible,expression:"!uploadImgBtnVisible"}],attrs:{size:"small",type:"primary",plain:"",round:""}},[e._v("选择图片")])],1)],1),a("el-form-item",{attrs:{label:"菜谱菜系",prop:"menuCuis"}},[a("el-select",{attrs:{filterable:"",clearable:"",placeholder:"请选择菜谱菜系"},model:{value:e.addMenuForm.menuCuis,callback:function(t){e.$set(e.addMenuForm,"menuCuis",t)},expression:"addMenuForm.menuCuis"}},e._l(e.menuCuis,(function(e){return a("el-option",{key:e.value,attrs:{label:e.label,value:e.value}})})),1)],1),a("el-form-item",{attrs:{label:"上手难度",prop:"menuLevel"}},[a("el-input",{attrs:{autocomplete:"off","prefix-icon":"el-icon-star-off",clearable:!0,maxlength:"1"},model:{value:e.addMenuForm.menuLevel,callback:function(t){e.$set(e.addMenuForm,"menuLevel",e._n(t))},expression:"addMenuForm.menuLevel"}})],1),a("el-form-item",{attrs:{label:"菜谱简介"}},[a("el-input",{attrs:{type:"textarea",rows:4,autocomplete:"off","prefix-icon":"el-icon-star-off",clearable:!0,minlength:"1",maxlength:"255","show-word-limit":""},model:{value:e.addMenuForm.menuBrief,callback:function(t){e.$set(e.addMenuForm,"menuBrief",e._n(t))},expression:"addMenuForm.menuBrief"}})],1)],1),a("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{attrs:{round:"",plain:"",size:"small",type:"info"},on:{click:function(t){e.addMenuDialogVisible=!1}}},[e._v("取 消")]),a("el-button",{attrs:{type:"primary",round:"",plain:"",size:"small"},on:{click:e.addMenu}},[e._v("确 定")])],1)],1),a("el-dialog",{attrs:{title:"添加菜谱",visible:e.updateMenuDialogVisible,width:"40%",center:!0},on:{"update:visible":function(t){e.updateMenuDialogVisible=t}}},[a("el-form",{ref:"updateMenuFormRef",attrs:{model:e.updateMenuForm,"label-width":"80px",size:"small",rules:e.addMenuFormRules}},[a("el-form-item",{attrs:{label:"菜谱名称",prop:"menuName"}},[a("el-input",{attrs:{"prefix-icon":"el-icon-food",autocomplete:"off",maxlength:"50",clearable:!0},model:{value:e.updateMenuForm.menuName,callback:function(t){e.$set(e.updateMenuForm,"menuName",t)},expression:"updateMenuForm.menuName"}})],1),a("el-form-item",{attrs:{label:"菜谱组成"}},[e._l(e.dynamicIngredientTags,(function(t){return a("el-tag",{key:t,staticStyle:{margin:"5px"},attrs:{closable:"","disable-transitions":!1},on:{close:function(a){return e.handleIngredientClose(t)}}},[e._v(" "+e._s(t)+" ")])})),e.inputIngredientVisible?a("el-input",{ref:"saveTagInput",staticClass:"input-new-tag",attrs:{size:"small"},on:{blur:e.handleInputConfirm},nativeOn:{keyup:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.handleInputConfirm.apply(null,arguments)}},model:{value:e.inputIngredientValue,callback:function(t){e.inputIngredientValue=t},expression:"inputIngredientValue"}}):a("el-button",{staticClass:"button-new-tag",attrs:{size:"small"},on:{click:e.showInput}},[e._v("+ 原料")])],2),a("el-form-item",{attrs:{label:"预估价格",prop:"menuPrice"}},[a("el-input",{attrs:{autocomplete:"off","prefix-icon":"el-icon-wallet",clearable:!0,maxlength:"5"},model:{value:e.updateMenuForm.menuPrice,callback:function(t){e.$set(e.updateMenuForm,"menuPrice",e._n(t))},expression:"updateMenuForm.menuPrice"}},[a("i",{attrs:{slot:"suffix"},slot:"suffix"},[e._v("元")])])],1),a("el-form-item",{attrs:{label:"菜谱口味",prop:"menuTaste"}},[a("el-select",{attrs:{filterable:"",clearable:"",placeholder:"请选择菜谱口味"},model:{value:e.updateMenuForm.menuTaste,callback:function(t){e.$set(e.updateMenuForm,"menuTaste",t)},expression:"updateMenuForm.menuTaste"}},e._l(e.menuTastes,(function(e){return a("el-option",{key:e.value,attrs:{label:e.label,value:e.value}})})),1)],1),a("el-form-item",{attrs:{label:"菜谱图片"}},[a("el-upload",{ref:"updateUpload",attrs:{action:"http://121.37.102.50:3006/menu/upload","on-change":e.uploadImg,"on-success":e.updateImgSuccess,accept:".jpeg,.png,.jpg,.bmp,.gif","list-type":"picture",limit:1,disabled:e.uploadImgBtnVisible}},[a("el-button",{directives:[{name:"show",rawName:"v-show",value:!e.uploadImgBtnVisible,expression:"!uploadImgBtnVisible"}],attrs:{size:"small",type:"primary",plain:"",round:""}},[e._v("选择图片")])],1)],1),a("el-form-item",{attrs:{label:"菜谱菜系",prop:"menuCuis"}},[a("el-select",{attrs:{filterable:"",clearable:"",placeholder:"请选择菜谱菜系"},model:{value:e.updateMenuForm.menuCuis,callback:function(t){e.$set(e.updateMenuForm,"menuCuis",t)},expression:"updateMenuForm.menuCuis"}},e._l(e.menuCuis,(function(e){return a("el-option",{key:e.value,attrs:{label:e.label,value:e.value}})})),1)],1),a("el-form-item",{attrs:{label:"上手难度",prop:"menuLevel"}},[a("el-input",{attrs:{autocomplete:"off","prefix-icon":"el-icon-star-off",clearable:!0,maxlength:"1"},model:{value:e.updateMenuForm.menuLevel,callback:function(t){e.$set(e.updateMenuForm,"menuLevel",e._n(t))},expression:"updateMenuForm.menuLevel"}})],1),a("el-form-item",{attrs:{label:"菜谱简介"}},[a("el-input",{attrs:{type:"textarea",rows:4,autocomplete:"off","prefix-icon":"el-icon-star-off",clearable:!0,minlength:"1",maxlength:"255","show-word-limit":""},model:{value:e.updateMenuForm.menuBrief,callback:function(t){e.$set(e.updateMenuForm,"menuBrief",e._n(t))},expression:"updateMenuForm.menuBrief"}})],1)],1),a("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{attrs:{round:"",plain:"",size:"small",type:"info"},on:{click:function(t){e.updateMenuDialogVisible=!1}}},[e._v("取 消")]),a("el-button",{attrs:{type:"primary",round:"",plain:"",size:"small"},on:{click:e.updateMenu}},[e._v("确 定")])],1)],1)],1)},l=[],u={name:"Menu",data(){return{menu:[],menuSearch:"",menuImgs:[],addMenuDialogVisible:!1,updateMenuDialogVisible:!1,inputIngredientVisible:!1,uploadImgBtnVisible:!1,addMenuForm:{menuName:"",menuId:"",menuEle:"",menuTaste:"",menuCuis:"",menuBrief:"",menuLevel:"",menuPut:"",menuPrice:""},updateMenuForm:{menuName:"",menuId:"",menuEle:"",menuTaste:"",menuCuis:"",menuBrief:"",menuLevel:"",menuPut:"",menuPrice:""},addMenuFormRules:{menuName:[{required:!0,message:"请输入菜谱名称",trigger:"blur"},{min:1,max:50,message:"长度在 1 到 50 个字符",trigger:"blur"}],menuTaste:[{required:!0,message:"请输入菜谱口味",trigger:"blur"},{min:1,max:50,message:"长度在 1 到 50 个字符",trigger:"blur"}],menuCuis:[{required:!0,message:"请输入菜谱菜系",trigger:"blur"},{min:1,max:10,message:"长度在 1 到 10 个字符",trigger:"blur"}],menuLevel:[{required:!0,message:"请填写上手难度",trigger:"blur"},{min:1,max:5,type:"number",message:"难度在1-5颗⭐",trigger:"blur"}],menuPrice:[{required:!0,message:"请填写菜谱预估价格",trigger:"blur"},{min:1,max:1e4,type:"number",message:"价格在1万元以下",trigger:"blur"}]},dynamicIngredientTags:[],inputIngredientValue:"",menuTastes:[{label:"甜",value:"甜"},{label:"酸",value:"酸"},{label:"辣",value:"辣"},{label:"咸",value:"咸"},{label:"酸",value:"酸"},{label:"酸辣",value:"酸辣"},{label:"酸甜",value:"酸甜"},{label:"清淡",value:"清淡"},{label:"苦涩",value:"苦涩"},{label:"鲜香",value:"鲜香"}],menuCuis:[{label:"川湘菜",value:"川湘菜"},{label:"鲁菜",value:"鲁菜"},{label:"东北菜",value:"东北菜"},{label:"西北菜",value:"西北菜"},{label:"粤菜",value:"粤菜"},{label:"徽菜",value:"徽菜"},{label:"西餐",value:"西餐"},{label:"主食",value:"主食"}]}},methods:{async getMenu(){const{data:e}=await this.$http.get("menu");this.menu=e,e.forEach((e=>{this.menuImgs.push(e.ingrePut)}))},addMenuDialogClosed(){this.$refs.addMenuFormRef.resetFields(),this.addMenuForm.menuPut="",this.uploadImgBtnVisible=!1},handleIngredientClose(e){this.dynamicIngredientTags.splice(this.dynamicIngredientTags.indexOf(e),1)},handleInputConfirm(){let e=this.inputIngredientValue;e&&this.dynamicIngredientTags.push(e),this.inputIngredientVisible=!1,this.inputIngredientValue=""},showInput(){this.inputIngredientVisible=!0,this.$nextTick((e=>{this.$refs.saveTagInput.$refs.input.focus()}))},uploadImg(e,t){if("ready"===e.status){const a="jpeg"===e.raw.type||"png",n=e.size/1024/1024<2;if(!a)return this.$message.warning("上传文件只能是图片格式!"),void t.pop();if(!n)return this.$message.warning("上传文件大小不能超过 2MB!"),void t.pop();this.uploadImgBtnVisible=!0}},uploadImgSuccess(e,t,a){this.addMenuForm.menuPut=e.data,this.$message.success("图片上传成功,请填写完成后点击确定按钮")},updateImgSuccess(e,t,a){this.updateMenuForm.menuPut=e.data,this.$message.success("图片上传成功,请填写完成后点击确定按钮")},addMenu(){this.$refs.addMenuFormRef.validate((async e=>{if(!e)return void this.$message.error("添加新菜谱验证失败");this.addMenuForm.menuId=this.guid().slice(1,10),this.addMenuForm.menuEle=this.dynamicIngredientTags.join("|");const{data:t}=await this.$http.post("menu",this.addMenuForm);1===t.status?(this.getMenu(),this.$message.success("添加菜谱成功!"),this.dynamicIngredientTags=[]):this.$message.error("添加菜谱失败")})),this.addMenuDialogVisible=!1,this.$refs.upload.uploadFiles=[],this.uploadImgBtnVisible=!1},async deleteMenu(e){const{data:t}=await this.$http.delete("menu/"+e);1===t.status?(this.getMenu(),this.$message.success("删除菜谱成功")):this.$message.error("删除菜谱失败")},async showUpdateMenu(e){const{data:t}=await this.$http.get("menu/"+e);this.updateMenuForm=t[0],this.dynamicIngredientTags=t[0].menuEle.split("|"),this.updateMenuDialogVisible=!0},updateMenu(){this.$refs.updateMenuFormRef.validate((async e=>{e?(this.updateMenuForm.menuEle=this.dynamicIngredientTags.join("|"),await this.$http.put("menu",this.updateMenuForm),this.getMenu(),this.$message.success("更新菜谱信息成功")):this.$message.error("更新菜谱信息验证失败")})),this.updateMenuDialogVisible=!1,this.$refs.updateUpload.uploadFiles=[],this.uploadImgBtnVisible=!1},guid(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0,a="x"==e?t:3&t|8;return a.toString(16)}))},addMenuClick(){this.addMenuDialogVisible=!0,this.dynamicIngredientTags=[]}},created(){this.getMenu()}},i=u,s=a(1001),r=(0,s.Z)(i,n,l,!1,null,"9610d47e",null),o=r.exports}}]);
|
|
//# sourceMappingURL=339.f2522571.js.map
|