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
12 KiB
2 lines
12 KiB
"use strict";(self["webpackChunkeatwhat_admin"]=self["webpackChunkeatwhat_admin"]||[]).push([[462],{1603:function(e,t,i){i.r(t),i.d(t,{default:function(){return g}});var r=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("el-card",[i("div",{staticClass:"ingredient"},[i("div",{staticClass:"title"},[i("el-alert",{attrs:{title:"食材管理界面",type:"success",center:"",closable:!1}})],1),i("div",{staticClass:"btn"},[i("el-button",{attrs:{type:"primary",size:"small",round:"",icon:"el-icon-plus"},on:{click:function(t){e.addIngredientDialogVisible=!0}}},[e._v("添加新食材")])],1),i("div",{staticClass:"table"},[i("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":"🥶正在努力加载中..."}},[i("el-table-column",{attrs:{label:"食材名称",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.ingreName||"未知")+" ")]}}])}),i("el-table-column",{attrs:{label:"图片",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[i("el-image",{staticStyle:{width:"100px",height:"100px"},attrs:{src:t.row.ingrePut,"preview-src-list":e.ingredientImgs}},[i("div",{staticClass:"image-slot",attrs:{slot:"error"},slot:"error"},[i("i",{staticClass:"el-icon-picture-outline"})])])]}}])}),i("el-table-column",{attrs:{label:"产地",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.ingreAdd||"未知")+" ")]}}])}),i("el-table-column",{attrs:{label:"属性",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.ingreAttr||"未知")+" ")]}}])}),i("el-table-column",{attrs:{label:"价格",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.ingrePrice||"0")+" 元 ")]}}])}),i("el-table-column",{attrs:{align:"center"},scopedSlots:e._u([{key:"header",fn:function(t){return[i("el-input",{attrs:{size:"mini",placeholder:"输入食材名称搜索"},model:{value:e.ingredientSearch,callback:function(t){e.ingredientSearch=t},expression:"ingredientSearch"}})]}},{key:"default",fn:function(t){return[i("el-button",{attrs:{type:"primary",size:"mini",plain:""},on:{click:function(i){return e.showUpdateIngredient(t.row.ingreId)}}},[e._v("编辑")]),i("el-popconfirm",{staticStyle:{"margin-left":"5px"},attrs:{title:"确定删除该食材?此操作不可逆"},on:{confirm:function(i){return e.deleteIngredient(t.row.ingreId)}}},[i("el-button",{attrs:{slot:"reference",type:"danger",size:"mini",plain:""},slot:"reference"},[e._v("删除")])],1)]}}])})],1)],1)]),i("el-dialog",{attrs:{title:"添加食材",visible:e.addIngredientDialogVisible,width:"40%",center:!0},on:{"update:visible":function(t){e.addIngredientDialogVisible=t},close:e.addIngredientDialogClosed}},[i("el-form",{ref:"addIngredientFormRef",attrs:{model:e.addIngredientForm,"label-width":"80px",size:"small",rules:e.addIngredientFormRules}},[i("el-form-item",{attrs:{label:"食材名称",prop:"ingreName"}},[i("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),i("el-form-item",{attrs:{label:"食材产地",prop:"ingreAdd"}},[i("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),i("el-form-item",{attrs:{label:"食材属性",prop:"ingreAttr"}},[i("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 i("el-option",{key:e.value,attrs:{label:e.label,value:e.value}})})),1)],1),i("el-form-item",{attrs:{label:"食材图片"}},[i("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}},[i("el-button",{directives:[{name:"show",rawName:"v-show",value:!e.uploadImgBtnVisible,expression:"!uploadImgBtnVisible"}],attrs:{size:"small",type:"primary",plain:"",round:""}},[e._v("选择图片")])],1)],1),i("el-form-item",{attrs:{label:"预估价格",prop:"ingrePrice"}},[i("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"}},[i("i",{attrs:{slot:"suffix"},slot:"suffix"},[e._v("元")])])],1)],1),i("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[i("el-button",{attrs:{round:"",plain:"",size:"small",type:"info"},on:{click:function(t){e.addIngredientDialogVisible=!1}}},[e._v("取 消")]),i("el-button",{attrs:{type:"primary",round:"",plain:"",size:"small"},on:{click:e.addIngredient}},[e._v("确 定")])],1)],1),i("el-dialog",{attrs:{title:"更新食材信息",visible:e.updateIngredientDialogVisible,width:"40%",center:!0},on:{"update:visible":function(t){e.updateIngredientDialogVisible=t}}},[i("el-form",{ref:"updateIngredientFormRef",attrs:{model:e.updateIngredientForm,"label-width":"80px",size:"small",rules:e.addIngredientFormRules}},[i("el-form-item",{attrs:{label:"食材名称",prop:"ingreName"}},[i("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),i("el-form-item",{attrs:{label:"食材产地",prop:"ingreAdd"}},[i("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),i("el-form-item",{attrs:{label:"食材属性",prop:"ingreAttr"}},[i("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 i("el-option",{key:e.value,attrs:{label:e.label,value:e.value}})})),1)],1),i("el-form-item",{attrs:{label:"食材图片"}},[i("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}},[i("el-button",{directives:[{name:"show",rawName:"v-show",value:!e.uploadImgBtnVisible,expression:"!uploadImgBtnVisible"}],attrs:{size:"small",type:"primary",plain:"",round:""}},[e._v("选择图片")])],1)],1),i("el-form-item",{attrs:{label:"预估价格",prop:"ingrePrice"}},[i("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"}},[i("i",{attrs:{slot:"suffix"},slot:"suffix"},[e._v("元")])])],1)],1),i("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[i("el-button",{attrs:{round:"",plain:"",size:"small",type:"info"},on:{click:function(t){e.updateIngredientDialogVisible=!1}}},[e._v("取 消")]),i("el-button",{attrs:{type:"primary",round:"",plain:"",size:"small"},on:{click:e.updateIngredient}},[e._v("确 定")])],1)],1)],1)},n=[],a=i(3325),l={name:"Ingredient",data(){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:a.Z,ingreAttrs:[{value:"热性",label:"热性"},{value:"温性",label:"温性"},{value:"平性",label:"平性"},{value:"凉性",label:"凉性"},{value:"寒性",label:"寒性"}]}},methods:{async getIngredient(){const{data:e}=await this.$http.get("ingredient");this.ingredient=e,e.forEach((e=>{this.ingredientImgs.push(e.ingrePut)}))},addIngredientDialogClosed(){this.$refs.addIngredientFormRef.resetFields(),this.addIngredientForm.ingrePut="",this.uploadImgBtnVisible=!1},addIngredient(){this.$refs.addIngredientFormRef.validate((async e=>{if(!e)return void this.$message.error("添加新食材验证失败");this.addIngredientForm.ingreId=this.guid().slice(1,10),this.addIngredientForm.ingreAdd=this.getLocationTransform(this.addIngredientForm.ingreAdd);const{data:t}=await this.$http.post("ingredient",this.addIngredientForm);1===t.status?(this.getIngredient(),this.$message.success("添加新食材成功!")):this.$message.error("添加新食材失败")})),this.addIngredientDialogVisible=!1,this.uploadImgBtnVisible=!1,this.$refs.upload.uploadFiles=[]},async deleteIngredient(e){const{data:t}=await this.$http.delete("ingredient/"+e);1===t.status?(this.getIngredient(),this.$message.success("删除食材成功")):this.$message.error("删除食材失败")},async showUpdateIngredient(e){const{data:t}=await this.$http.get("ingredient/"+e);this.updateIngredientForm=t[0],this.updateIngredientDialogVisible=!0},async updateIngredient(){this.$refs.updateIngredientFormRef.validate((async e=>{e?(this.updateIngredientForm.ingreAdd=this.getLocationTransform(this.updateIngredientForm.ingreAdd),await this.$http.put("ingredient",this.updateIngredientForm),this.getIngredient(),this.$message.success("更新食材信息成功")):this.$message.error("更新食材信息验证失败")})),this.updateIngredientDialogVisible=!1,this.$refs.updateUpload.uploadFiles=[],this.uploadImgBtnVisible=!1},uploadImg(e,t){if("ready"===e.status){const i="jpeg"===e.raw.type||"png",r=e.size/1024/1024<2;if(!i)return this.$message.warning("上传文件只能是图片格式!"),void t.pop();if(!r)return this.$message.warning("上传文件大小不能超过 2MB!"),void t.pop();this.uploadImgBtnVisible=!0}},uploadImgSuccess(e,t,i){this.addIngredientForm.ingrePut=e.data,this.$message.success("图片上传成功,请填写完成后点击确定按钮")},updateImgSuccess(e,t,i){this.updateIngredientForm.ingrePut=e.data,this.$message.success("图片上传成功,请填写完成后点击确定按钮")},guid(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0,i="x"==e?t:3&t|8;return i.toString(16)}))},getLocationTransform(e){const t=e,i=t[0],r=t[1],n=t[2];var a=[],l=(e=[],"");return this.citys.forEach((e=>{e.value===i&&(l+=e.label,a=e.children)})),a.forEach((t=>{t.value===r&&(l=l+"/"+t.label,e=t.children)})),e.forEach((e=>{e.value===n&&(l=l+"/"+e.label)})),l}},created(){this.getIngredient()}},s=l,d=i(1001),o=(0,d.Z)(s,r,n,!1,null,null,null),g=o.exports}}]);
|
|
//# sourceMappingURL=462.76d402db.js.map
|