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
13 KiB

"use strict";(self["webpackChunkeatwhat_admin"]=self["webpackChunkeatwhat_admin"]||[]).push([[462],{1603:function(e,t,r){r.r(t),r.d(t,{default:function(){return c}});var n=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("el-card",[r("div",{staticClass:"ingredient"},[r("div",{staticClass:"title"},[r("el-alert",{attrs:{title:"食材管理界面",type:"success",center:"",closable:!1}})],1),r("div",{staticClass:"btn"},[r("el-button",{attrs:{type:"primary",size:"small",round:"",icon:"el-icon-plus"},on:{click:function(t){e.addIngredientDialogVisible=!0}}},[e._v("添加新食材")])],1),r("div",{staticClass:"table"},[r("el-table",{staticStyle:{width:"100%"},attrs:{data:e.ingredient.filter((function(t){return!e.ingredientSearch||t.ingreName.toLowerCase().includes(e.ingredientSearch.toLowerCase())})),fit:"",lazy:"",stripe:!0,border:!0,"highlight-current-row":!0,"empty-text":"🥶正在努力加载中..."}},[r("el-table-column",{attrs:{label:"食材名称",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.ingreName||"未知")+" ")]}}])}),r("el-table-column",{attrs:{label:"图片",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[r("el-image",{staticStyle:{width:"100px",height:"100px"},attrs:{src:t.row.ingrePut,"preview-src-list":e.ingredientImgs}},[r("div",{staticClass:"image-slot",attrs:{slot:"error"},slot:"error"},[r("i",{staticClass:"el-icon-picture-outline"})])])]}}])}),r("el-table-column",{attrs:{label:"产地",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.ingreAdd||"未知")+" ")]}}])}),r("el-table-column",{attrs:{label:"属性",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.ingreAttr||"未知")+" ")]}}])}),r("el-table-column",{attrs:{label:"价格",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.ingrePrice||"0")+" 元 ")]}}])}),r("el-table-column",{attrs:{align:"center"},scopedSlots:e._u([{key:"header",fn:function(t){return[r("el-input",{attrs:{size:"mini",placeholder:"输入食材名称搜索"},model:{value:e.ingredientSearch,callback:function(t){e.ingredientSearch=t},expression:"ingredientSearch"}})]}},{key:"default",fn:function(t){return[r("el-button",{attrs:{type:"primary",size:"mini",plain:""},on:{click:function(r){return e.showUpdateIngredient(t.row.ingreId)}}},[e._v("编辑")]),r("el-popconfirm",{staticStyle:{"margin-left":"5px"},attrs:{title:"确定删除该食材?此操作不可逆"},on:{confirm:function(r){return e.deleteIngredient(t.row.ingreId)}}},[r("el-button",{attrs:{slot:"reference",type:"danger",size:"mini",plain:""},slot:"reference"},[e._v("删除")])],1)]}}])})],1)],1)]),r("el-dialog",{attrs:{title:"添加食材",visible:e.addIngredientDialogVisible,width:"40%",center:!0},on:{"update:visible":function(t){e.addIngredientDialogVisible=t},close:e.addIngredientDialogClosed}},[r("el-form",{ref:"addIngredientFormRef",attrs:{model:e.addIngredientForm,"label-width":"80px",size:"small",rules:e.addIngredientFormRules}},[r("el-form-item",{attrs:{label:"食材名称",prop:"ingreName"}},[r("el-input",{attrs:{"prefix-icon":"el-icon-watermelon",autocomplete:"off",maxlength:"50",clearable:!0},model:{value:e.addIngredientForm.ingreName,callback:function(t){e.$set(e.addIngredientForm,"ingreName",t)},expression:"addIngredientForm.ingreName"}})],1),r("el-form-item",{attrs:{label:"食材产地",prop:"ingreAdd"}},[r("el-cascader",{staticStyle:{width:"100%"},attrs:{options:e.citys,filterable:"",clearable:"",props:{expandTrigger:"hover"}},model:{value:e.addIngredientForm.ingreAdd,callback:function(t){e.$set(e.addIngredientForm,"ingreAdd",t)},expression:"addIngredientForm.ingreAdd"}})],1),r("el-form-item",{attrs:{label:"食材属性",prop:"ingreAttr"}},[r("el-select",{attrs:{filterable:"",clearable:"",placeholder:"请选择食材属性"},model:{value:e.addIngredientForm.ingreAttr,callback:function(t){e.$set(e.addIngredientForm,"ingreAttr",t)},expression:"addIngredientForm.ingreAttr"}},e._l(e.ingreAttrs,(function(e){return r("el-option",{key:e.value,attrs:{label:e.label,value:e.value}})})),1)],1),r("el-form-item",{attrs:{label:"食材图片"}},[r("el-upload",{ref:"upload",attrs:{action:"http://121.37.102.50:3006/ingredient/upload","on-change":e.uploadImg,"on-success":e.uploadImgSuccess,accept:".jpeg,.png,.jpg,.bmp,.gif","list-type":"picture",limit:1,disabled:e.uploadImgBtnVisible}},[r("el-button",{directives:[{name:"show",rawName:"v-show",value:!e.uploadImgBtnVisible,expression:"!uploadImgBtnVisible"}],attrs:{size:"small",type:"primary",plain:"",round:""}},[e._v("选择图片")])],1)],1),r("el-form-item",{attrs:{label:"预估价格",prop:"ingrePrice"}},[r("el-input",{attrs:{autocomplete:"off","prefix-icon":"el-icon-coin",clearable:!0,minlength:"1",maxlength:"10"},model:{value:e.addIngredientForm.ingrePrice,callback:function(t){e.$set(e.addIngredientForm,"ingrePrice",e._n(t))},expression:"addIngredientForm.ingrePrice"}},[r("i",{attrs:{slot:"suffix"},slot:"suffix"},[e._v("元")])])],1)],1),r("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[r("el-button",{attrs:{round:"",plain:"",size:"small",type:"info"},on:{click:function(t){e.addIngredientDialogVisible=!1}}},[e._v("取 消")]),r("el-button",{attrs:{type:"primary",round:"",plain:"",size:"small"},on:{click:e.addIngredient}},[e._v("确 定")])],1)],1),r("el-dialog",{attrs:{title:"更新食材信息",visible:e.updateIngredientDialogVisible,width:"40%",center:!0},on:{"update:visible":function(t){e.updateIngredientDialogVisible=t}}},[r("el-form",{ref:"updateIngredientFormRef",attrs:{model:e.updateIngredientForm,"label-width":"80px",size:"small",rules:e.addIngredientFormRules}},[r("el-form-item",{attrs:{label:"食材名称",prop:"ingreName"}},[r("el-input",{attrs:{"prefix-icon":"el-icon-watermelon",autocomplete:"off",maxlength:"50",clearable:!0},model:{value:e.updateIngredientForm.ingreName,callback:function(t){e.$set(e.updateIngredientForm,"ingreName",t)},expression:"updateIngredientForm.ingreName"}})],1),r("el-form-item",{attrs:{label:"食材产地",prop:"ingreAdd"}},[r("el-cascader",{staticStyle:{width:"100%"},attrs:{options:e.citys,filterable:"",clearable:"",props:{expandTrigger:"hover"}},model:{value:e.updateIngredientForm.ingreAdd,callback:function(t){e.$set(e.updateIngredientForm,"ingreAdd",t)},expression:"updateIngredientForm.ingreAdd"}})],1),r("el-form-item",{attrs:{label:"食材属性",prop:"ingreAttr"}},[r("el-select",{attrs:{filterable:"",clearable:"",placeholder:"请选择食材属性"},model:{value:e.updateIngredientForm.ingreAttr,callback:function(t){e.$set(e.updateIngredientForm,"ingreAttr",t)},expression:"updateIngredientForm.ingreAttr"}},e._l(e.ingreAttrs,(function(e){return r("el-option",{key:e.value,attrs:{label:e.label,value:e.value}})})),1)],1),r("el-form-item",{attrs:{label:"食材图片"}},[r("el-upload",{ref:"updateUpload",attrs:{action:"http://121.37.102.50:3006/ingredient/upload","on-change":e.uploadImg,"on-success":e.updateImgSuccess,accept:".jpeg,.png,.jpg,.bmp,.gif","list-type":"picture",limit:1,disabled:e.uploadImgBtnVisible}},[r("el-button",{directives:[{name:"show",rawName:"v-show",value:!e.uploadImgBtnVisible,expression:"!uploadImgBtnVisible"}],attrs:{size:"small",type:"primary",plain:"",round:""}},[e._v("选择图片")])],1)],1),r("el-form-item",{attrs:{label:"预估价格",prop:"ingrePrice"}},[r("el-input",{attrs:{autocomplete:"off","prefix-icon":"el-icon-coin",clearable:!0,minlength:"1",maxlength:"10"},model:{value:e.updateIngredientForm.ingrePrice,callback:function(t){e.$set(e.updateIngredientForm,"ingrePrice",e._n(t))},expression:"updateIngredientForm.ingrePrice"}},[r("i",{attrs:{slot:"suffix"},slot:"suffix"},[e._v("元")])])],1)],1),r("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[r("el-button",{attrs:{round:"",plain:"",size:"small",type:"info"},on:{click:function(t){e.updateIngredientDialogVisible=!1}}},[e._v("取 消")]),r("el-button",{attrs:{type:"primary",round:"",plain:"",size:"small"},on:{click:e.updateIngredient}},[e._v("确 定")])],1)],1)],1)},i=[],a=r(7906),l=r(6198),s=(r(1539),r(4747),r(7042),r(4916),r(5306),r(9714),r(3325)),o={name:"Ingredient",data:function(){return{ingredient:[],ingredientSearch:"",ingredientImgs:[],addIngredientDialogVisible:!1,updateIngredientDialogVisible:!1,uploadImgBtnVisible:!1,addIngredientForm:{ingreName:"",ingreId:"",ingreAdd:"",ingreAttr:"",ingrePut:"",ingrePrice:""},updateIngredientForm:{ingreName:"",ingreId:"",ingreAdd:"",ingreAttr:"",ingrePut:"",ingrePrice:""},addIngredientFormRules:{ingreName:[{required:!0,message:"请输入食材名称",trigger:"blur"},{min:1,max:50,message:"长度在 1 到 50 个字符",trigger:"blur"}],ingreAdd:[{required:!0,message:"请输入食材产地",trigger:"blur"}],ingreAttr:[{required:!0,message:"请输入食材属性",trigger:"blur"},{min:1,max:50,message:"长度在 1 到 50 个字符",trigger:"blur"}],ingrePrice:[{required:!0,message:"请输入食材价格",trigger:"blur"},{min:1,max:1e3,type:"number",message:"价格低于1000元",trigger:"blur"}]},citys:s.Z,ingreAttrs:[{value:"热性",label:"热性"},{value:"温性",label:"温性"},{value:"平性",label:"平性"},{value:"凉性",label:"凉性"},{value:"寒性",label:"寒性"}]}},methods:{getIngredient:function(){var e=this;return(0,l.Z)((0,a.Z)().mark((function t(){var r,n;return(0,a.Z)().wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,e.$http.get("ingredient");case 2:r=t.sent,n=r.data,e.ingredient=n,n.forEach((function(t){e.ingredientImgs.push(t.ingrePut)}));case 6:case"end":return t.stop()}}),t)})))()},addIngredientDialogClosed:function(){this.$refs.addIngredientFormRef.resetFields(),this.addIngredientForm.ingrePut="",this.uploadImgBtnVisible=!1},addIngredient:function(){var e=this;this.$refs.addIngredientFormRef.validate(function(){var t=(0,l.Z)((0,a.Z)().mark((function t(r){var n,i;return(0,a.Z)().wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(r){t.next=3;break}return e.$message.error("添加新食材验证失败"),t.abrupt("return");case 3:return e.addIngredientForm.ingreId=e.guid().slice(1,10),e.addIngredientForm.ingreAdd=e.getLocationTransform(e.addIngredientForm.ingreAdd),t.next=7,e.$http.post("ingredient",e.addIngredientForm);case 7:if(n=t.sent,i=n.data,1===i.status){t.next=12;break}return e.$message.error("添加新食材失败"),t.abrupt("return");case 12:e.getIngredient(),e.$message.success("添加新食材成功!");case 14:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),this.addIngredientDialogVisible=!1,this.uploadImgBtnVisible=!1,this.$refs.upload.uploadFiles=[]},deleteIngredient:function(e){var t=this;return(0,l.Z)((0,a.Z)().mark((function r(){var n,i;return(0,a.Z)().wrap((function(r){while(1)switch(r.prev=r.next){case 0:return r.next=2,t.$http.delete("ingredient/"+e);case 2:if(n=r.sent,i=n.data,1===i.status){r.next=7;break}return t.$message.error("删除食材失败"),r.abrupt("return");case 7:t.getIngredient(),t.$message.success("删除食材成功");case 9:case"end":return r.stop()}}),r)})))()},showUpdateIngredient:function(e){var t=this;return(0,l.Z)((0,a.Z)().mark((function r(){var n,i;return(0,a.Z)().wrap((function(r){while(1)switch(r.prev=r.next){case 0:return r.next=2,t.$http.get("ingredient/"+e);case 2:n=r.sent,i=n.data,t.updateIngredientForm=i[0],t.updateIngredientDialogVisible=!0;case 6:case"end":return r.stop()}}),r)})))()},updateIngredient:function(){var e=this;return(0,l.Z)((0,a.Z)().mark((function t(){return(0,a.Z)().wrap((function(t){while(1)switch(t.prev=t.next){case 0:e.$refs.updateIngredientFormRef.validate(function(){var t=(0,l.Z)((0,a.Z)().mark((function t(r){return(0,a.Z)().wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(r){t.next=3;break}return e.$message.error("更新食材信息验证失败"),t.abrupt("return");case 3:return e.updateIngredientForm.ingreAdd=e.getLocationTransform(e.updateIngredientForm.ingreAdd),t.next=6,e.$http.put("ingredient",e.updateIngredientForm);case 6:e.getIngredient(),e.$message.success("更新食材信息成功");case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),e.updateIngredientDialogVisible=!1,e.$refs.updateUpload.uploadFiles=[],e.uploadImgBtnVisible=!1;case 4:case"end":return t.stop()}}),t)})))()},uploadImg:function(e,t){if("ready"===e.status){var r="jpeg"===e.raw.type||"png",n=e.size/1024/1024<2;if(!r)return this.$message.warning("上传文件只能是图片格式!"),void t.pop();if(!n)return this.$message.warning("上传文件大小不能超过 2MB!"),void t.pop();this.uploadImgBtnVisible=!0}},uploadImgSuccess:function(e,t,r){this.addIngredientForm.ingrePut=e.data,this.$message.success("图片上传成功,请填写完成后点击确定按钮")},updateImgSuccess:function(e,t,r){this.updateIngredientForm.ingrePut=e.data,this.$message.success("图片上传成功,请填写完成后点击确定按钮")},guid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0,r="x"==e?t:3&t|8;return r.toString(16)}))},getLocationTransform:function(e){var t=e,r=t[0],n=t[1],i=t[2],a=[],l=(e=[],"");return this.citys.forEach((function(e){e.value===r&&(l+=e.label,a=e.children)})),a.forEach((function(t){t.value===n&&(l=l+"/"+t.label,e=t.children)})),e.forEach((function(e){e.value===i&&(l=l+"/"+e.label)})),l}},created:function(){this.getIngredient()}},d=o,u=r(1001),g=(0,u.Z)(d,n,i,!1,null,null,null),c=g.exports}}]);
//# sourceMappingURL=462-legacy.187cab03.js.map