/
home
/
maktab
/
admin
/
js
/
File Upload :
llllll
Current File: /home/maktab/admin/js/chunk-fb1cb640.f0003f9d.js
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-fb1cb640"],{"3fab":function(e,t,n){},"444b":function(e,t,n){"use strict";n.r(t);var i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("a-spin",{attrs:{spinning:e.loading}},[n("vx-card",{attrs:{title:"گالری تصاویر"}},[n("div",{staticClass:"grid md:grid-cols-2 gap-5"},[n("a-form-item",{attrs:{label:"موضوع"}},[n("a-input",{attrs:{placeholder:"موضوع"},model:{value:e.title,callback:function(t){e.title=t},expression:"title"}})],1),n("ImageList",{staticClass:"mt-5",on:{ok:e.addId,remove:e.removeId}})],1),n("a-button",{staticClass:"mt-10",attrs:{type:"primary"},on:{click:e.submit}},[n("div",{staticClass:"px-10"},[e._v("\n ثبت\n ")])])],1)],1)},r=[],a=(n("20d6"),n("96cf"),n("1da1")),s=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"clearfix"},[n("a-upload",{attrs:{action:e.url,headers:e.headers,"list-type":"picture-card","file-list":e.fileList,data:e.getData,remove:e.handleRemove},on:{preview:e.handlePreview,change:e.handleChange}},[e.fileList.length<10?n("div",[n("a-icon",{attrs:{type:"plus"}}),n("div",{staticClass:"ant-upload-text"},[e._v("\n بارگذاری\n ")])],1):e._e()]),n("a-modal",{attrs:{visible:e.previewVisible,footer:null},on:{cancel:e.handleCancel}},[n("img",{staticStyle:{width:"100%"},attrs:{alt:"example",src:e.previewImage}})])],1)},c=[],o=n("bb36");function l(e){return new Promise((function(t,n){var i=new FileReader;i.readAsDataURL(e),i.onload=function(){return t(i.result)},i.onerror=function(e){return n(e)}}))}var u={data:function(){return{url:"".concat(o["a"],"site/file"),previewVisible:!1,previewImage:"",fileList:[]}},computed:{headers:function(){return{Authorization:"Bearer "+localStorage.getItem("accessToken")||!1}}},methods:{handleCancel:function(){this.previewVisible=!1},handlePreview:function(){var e=Object(a["a"])(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(t.url||t.preview){e.next=4;break}return e.next=3,l(t.originFileObj);case 3:t.preview=e.sent;case 4:this.previewImage=t.url||t.preview,this.previewVisible=!0;case 6:case"end":return e.stop()}}),e,this)})));function t(t){return e.apply(this,arguments)}return t}(),handleChange:function(e){var t=e.fileList,n=e.file;"done"===n.status&&n.response&&n.response.id&&this.$emit("ok",n.response.id),this.fileList=t},handleRemove:function(e){console.log("remove",e.response.id),this.$emit("remove",e.response.id)},getData:function(){return{has_thumb:1,has_watermark:0,subject:1,title:1,type:3}}}},d=u,h=(n("cdc1"),n("2877")),p=Object(h["a"])(d,s,c,!1,null,null,null),f=p.exports,m={name:"index",components:{ImageList:f},data:function(){return{ids:[],title:"",loading:!1}},mounted:function(){var e=Object(a["a"])(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(!this.id){e.next=5;break}return this.loading=!0,e.next=4,this.fetchInf(this.id);case 4:this.loading=!1;case 5:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}(),computed:{id:function(){return this.$route.params.id}},methods:{addId:function(e){this.ids.push(e)},removeId:function(e){this.ids.splice(this.ids.findIndex((function(t){return t===e})),1)},fetchInf:function(){var e=Object(a["a"])(regeneratorRuntime.mark((function e(t){var n,i;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,o["b"].get("/api/gallery/".concat(t));case 3:n=e.sent,i=n.data,console.log(i),this.title=i.title,e.next=12;break;case 9:e.prev=9,e.t0=e["catch"](0),this.$message.error("خطا در دریافت اطلاعات");case 12:case"end":return e.stop()}}),e,this,[[0,9]])})));function t(t){return e.apply(this,arguments)}return t}(),submit:function(){var e=Object(a["a"])(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(e.prev=0,""===this.title||0===this.ids.length){e.next=9;break}return this.loading=!0,e.next=5,o["b"].post("/api/gallery",{title:this.title,files:this.ids});case 5:e.sent,this.$message.success("اطلاعات با موفقیت ذخیره شد"),e.next=11;break;case 9:""===this.title&&this.$message.error("لطفا موضوع را وارد کنید"),0===this.ids.length&&this.$message.error("لطفا تصاویر را آپلود کنید");case 11:e.next=16;break;case 13:e.prev=13,e.t0=e["catch"](0),this.$message.error("خطا در ثبت اطلاعات");case 16:return e.prev=16,this.loading=!1,e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[0,13,16,19]])})));function t(){return e.apply(this,arguments)}return t}()}},v=m,g=Object(h["a"])(v,i,r,!1,null,"5e1789d4",null);t["default"]=g.exports},cdc1:function(e,t,n){"use strict";n("3fab")}}]); //# sourceMappingURL=chunk-fb1cb640.f0003f9d.js.map
Copyright ©2k19 -
Hexid
|
Tex7ure