2 lines
3.4 KiB
JavaScript
2 lines
3.4 KiB
JavaScript
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-4c39866d"],{"325d":function(t,e,o){},4948:function(t,e,o){"use strict";o("325d")},8966:function(t,e,o){"use strict";o.r(e);var r=function(){var t=this,e=t._self._c;return e("div",[e("el-card",{staticClass:"box-card"},[e("div",{staticClass:"flex justify-between",attrs:{slot:"header"},slot:"header"},[e("span",[t._v("商品信息")]),e("el-button",{staticStyle:{float:"right",padding:"3px 0"},attrs:{type:"text"},on:{click:t._openDownloadHcExcelTemplate}},[e("i",{staticClass:"el-icon-download"}),t._v("模板 ")])],1),e("el-form",{staticClass:"text-left",attrs:{"label-position":"left","label-width":"120px"}},[e("el-form-item",{attrs:{label:"选择文件"}},[e("el-upload",{ref:"upload",staticClass:"upload-demo",attrs:{action:"#","auto-upload":!1,"on-change":t.getExcelTemplate,"file-list":t.fileList,accept:".xls,.xlsx"}},[e("el-button",{attrs:{slot:"trigger",size:"small",type:"primary"},slot:"trigger"},[t._v("选取文件")]),e("div",{staticClass:"el-upload__tip",attrs:{slot:"tip"},slot:"tip"},[t._v(" "+t._s(""===t.productImportInfo.excelTemplate?"必填,请选择数据文件":t.productImportInfo.excelTemplate.name)+" ")])],1)],1),e("el-form-item",{attrs:{label:"备注"}},[e("el-input",{attrs:{type:"textarea",placeholder:"请填写备注信息",rows:3},model:{value:t.productImportInfo.remark,callback:function(e){t.$set(t.productImportInfo,"remark",e)},expression:"productImportInfo.remark"}})],1)],1)],1),e("el-row",[e("el-col",{attrs:{span:22}}),e("el-col",{attrs:{span:2}},[e("el-button",{staticStyle:{"margin-bottom":"10px",float:"right"},attrs:{type:"primary"},on:{click:t._importData}},[e("i",{staticClass:"el-icon-upload"}),t._v("导入 ")])],1)],1)],1)},a=[],s=o("b775");function l(t){return new Promise((e,o)=>{Object(s["a"])({url:"/assetImport",method:"post",data:t,headers:{"Content-Type":"multipart/form-data"}}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t.response.data)})})}var p=o("7323"),c={name:"ProductImport",data(){return{productImportInfo:{shopId:"",excelTemplate:"",remark:""},fileList:[]}},created(){let t=this.getShopId();this.productImportInfo.shopId=t},methods:{productImportValidate(){return this.productImportInfo.excelTemplate?!!this.productImportInfo.shopId||(this.$message.error("还未入驻小区,请先入驻小区"),!1):(this.$message.error("文件不能为空"),!1)},_openDownloadHcExcelTemplate(){window.open("/import/hcmall.xlsx")},getExcelTemplate(t){this.productImportInfo.excelTemplate=t.raw},async _importData(){if(!this.productImportValidate())return;if(!this.checkFileType(this.productImportInfo.excelTemplate.name.split(".")[1]))return void this.$message.error("不是有效的Excel格式");if(!this.checkFileSize(this.productImportInfo.excelTemplate.size))return void this.$message.error("Excel文件大小不能超过2M");const t=new FormData;t.append("uploadFile",this.productImportInfo.excelTemplate),t.append("shopId",this.productImportInfo.shopId),t.append("importAdapt","importProduct");try{const e=await l(t);console.log(e),this.$message.success("处理成功"),this.$router.push("/pages/goods/productManage")}catch(e){this.$message.error(e||"导入失败")}},checkFileType(t){const e=["xls","xlsx"];return e.includes(t)},checkFileSize(t){const e=2097152;return t<=e},getShopId(){return console.log("getShopId"),Object(p["f"])()}}},i=c,n=(o("4948"),o("2877")),d=Object(n["a"])(i,r,a,!1,null,"65a117dd",null);e["default"]=d.exports}}]);
|
|
//# sourceMappingURL=chunk-4c39866d.c18b0185.js.map
|