qauMaWeb/node_modules/.cache/babel-loader/5cfe3aa6950b9b8ea4f48b7fb34...

1 line
18 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{"ast":null,"code":"import \"core-js/modules/es.array.splice.js\";\nimport \"core-js/modules/es.array.slice.js\";\nimport \"core-js/modules/es.function.name.js\";\nimport \"core-js/modules/es.string.trim.js\";\nimport \"core-js/modules/es.symbol.js\";\nimport \"core-js/modules/es.symbol.description.js\";\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\nimport API from \"@/utils/request\";\nvar url = \"/api/good\";\nexport default {\n name: \"GoodInfo\",\n data: function data() {\n return {\n baseApi: this.$store.state.baseApi,\n good: {\n discount: \"1\"\n },\n standards: [],\n index: 0,\n standard: {},\n fileList: [],\n dialogFormVisible: false,\n categoryItems: [],\n checkedCategory: {}\n };\n },\n created: function created() {\n var _this = this;\n\n this.request.get(\"/api/category\").then(function (res) {\n if (res.code === \"200\") {\n _this.categoryItems = res.data;\n }\n\n if (_this.$route.query.good) {\n _this.good = JSON.parse(_this.$route.query.good);\n _this.fileList = [{\n name: \"原始图片\",\n url: _this.good.imgs\n }];\n _this.checkedCategory = _this.categoryItems[_this.good.categoryId]; //从服务器获取商品规格信息\n\n _this.request.get(url + \"/standard/\" + _this.good.id).then(function (res) {\n if (res.code === \"200\") {\n var standards = JSON.parse(res.data);\n _this.standards = standards;\n } else {//没有规格\n }\n });\n }\n });\n },\n methods: {\n /*\r\n 规格操作\r\n */\n editStandard: function editStandard(index) {\n this.standard = this.standards[index];\n this.index = index;\n this.dialogFormVisible = true;\n },\n addStandard: function addStandard() {\n this.standard = {};\n this.index = this.standards.length;\n this.dialogFormVisible = true;\n },\n saveStandard: function saveStandard() {\n if (this.standard.value == undefined || this.standard.value == \"\") {\n this.$message({\n type: \"error\",\n message: \"请输入规格名称\",\n showClose: true\n });\n return;\n }\n\n if (this.standard.price == undefined || this.standard.price == \"\") {\n this.$message({\n type: \"error\",\n message: \"请输入价格\",\n showClose: true\n });\n return;\n }\n\n if (this.standard.store == undefined || this.standard.store == \"\") {\n this.$message({\n type: \"error\",\n message: \"请输入库存\",\n showClose: true\n });\n return;\n }\n\n this.standards[this.index] = this.standard;\n this.dialogFormVisible = false;\n },\n handleClose: function handleClose(standard) {\n this.standards.splice(this.standards.indexOf(standard), 1);\n },\n\n /*\r\n 文件上传操作\r\n */\n handleImgSuccess: function handleImgSuccess(res) {\n this.good.imgs = res.data;\n this.save();\n },\n handleChange: function handleChange(file, fileList) {\n this.fileList = fileList.slice(-3);\n },\n handleRemove: function handleRemove() {\n this.fileList.pop();\n },\n\n /*\r\n 保存数据操作\r\n */\n //点击提交按钮\n submit: function submit() {\n if (this.good.name == undefined || this.good.name.trim() == \"\") {\n this.$message({\n type: \"error\",\n message: \"请输入商品名称\",\n showClose: true\n });\n return false;\n }\n\n if (this.good.description == undefined || this.good.description.trim() == \"\") {\n this.$message({\n type: \"error\",\n message: \"请输入商品描述\",\n showClose: true\n });\n return false;\n }\n\n if (this.standards.length === 0) {\n this.$message({\n type: \"error\",\n message: \"请至少添加一个规格\",\n showClose: true\n });\n return false;\n }\n\n console.log(this.good.discount);\n\n if (this.good.discount == undefined || this.good.discount.trim() == \"\") {\n this.$message({\n type: \"error\",\n message: \"请输入商品折扣\",\n showClose: true\n });\n return false;\n }\n\n if (this.good.categoryId == undefined) {\n this.$message({\n type: \"error\",\n message: \"请选择商品分类\",\n showClose: true\n });\n return false;\n }\n\n if (this.fileList.length === 0) {\n this.$message({\n type: \"error\",\n message: \"请上传图片\",\n showClose: true\n });\n return false;\n } // 先上传图片再保存数据\n\n\n if (this.fileList[0].status === \"ready\") {\n this.$refs.upload.submit();\n } else if (this.fileList[0].status === \"success\") {\n //没有修改初始的图片。直接保存数据\n this.save();\n }\n },\n //保存数据\n save: function save() {\n var _this2 = this;\n\n API.post(url, this.good).then(function (res2) {\n if (res2.code === \"200\") {\n _this2.good.id = res2.data;\n\n _this2.request.post(url + \"/standard?goodId=\" + _this2.good.id, _this2.standards).then(function (res) {\n if (res.code === \"200\") {\n _this2.$message({\n type: \"success\",\n message: \"操作成功\",\n showClose: true\n });\n\n _this2.$router.go(-1);\n } else {\n _this2.$message({\n type: \"error\",\n message: \"操作失败\",\n showClose: true\n });\n }\n });\n } else {\n _this2.$message({\n type: \"error\",\n message: res2.msg\n });\n }\n });\n }\n }\n};","map":{"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiHA;AACA;AACA;AACAA,kBADA;AAEAC,MAFA,kBAEA;AACA;AACAC,wCADA;AAEAC;AACAC;AADA,OAFA;AAKAC,mBALA;AAMAC,cANA;AAOAC,kBAPA;AAQAC,kBARA;AASAC,8BATA;AAUAC,uBAVA;AAWAC;AAXA;AAaA,GAhBA;AAiBAC,SAjBA,qBAiBA;AAAA;;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AAAAZ;AAAAa;AAAA;AACA,2EAHA,CAIA;;AACA;AACA;AACA;AACA;AACA,WAHA,MAGA,CACA;AACA;AACA,SAPA;AAQA;AACA,KAlBA;AAmBA,GArCA;AAsCAC;AACA;AACA;AACA;AACAC,gBAJA,wBAIAT,KAJA,EAIA;AACA;AACA;AACA;AACA,KARA;AASAU,eATA,yBASA;AACA;AACA;AACA;AACA,KAbA;AAcAC,gBAdA,0BAcA;AACA;AAEA;AACAC,uBADA;AAEAC,4BAFA;AAGAC;AAHA;AAKA;AACA;;AACA;AACA;AACAF,uBADA;AAEAC,0BAFA;AAGAC;AAHA;AAKA;AACA;;AACA;AACA;AACAF,uBADA;AAEAC,0BAFA;AAGAC;AAHA;AAKA;AACA;;AACA;AACA;AACA,KA1CA;AA2CAC,eA3CA,uBA2CAd,QA3CA,EA2CA;AACA;AACA,KA7CA;;AA8CA;AACA;AACA;AACAe,oBAjDA,4BAiDAC,GAjDA,EAiDA;AACA;AACA;AACA,KApDA;AAqDAC,gBArDA,wBAqDAC,IArDA,EAqDAjB,QArDA,EAqDA;AACA;AACA,KAvDA;AAwDAkB,gBAxDA,0BAwDA;AACA;AACA,KA1DA;;AA2DA;AACA;AACA;AACA;AACAC,UA/DA,oBA+DA;AACA;AACA;AACAT,uBADA;AAEAC,4BAFA;AAGAC;AAHA;AAKA;AACA;;AACA,UACA,sCACA,kCAFA,EAGA;AACA;AACAF,uBADA;AAEAC,4BAFA;AAGAC;AAHA;AAKA;AACA;;AACA;AACA;AACAF,uBADA;AAEAC,8BAFA;AAGAC;AAHA;AAKA;AACA;;AACAQ;;AACA;AACA;AACAV,uBADA;AAEAC,4BAFA;AAGAC;AAHA;AAKA;AACA;;AACA,UACA,iCADA,EAEA;AACA;AACAF,uBADA;AAEAC,4BAFA;AAGAC;AAHA;AAKA;AACA;;AACA;AACA;AACAF,uBADA;AAEAC,0BAFA;AAGAC;AAHA;AAKA;AACA,OAtDA,CAuDA;;;AACA;AACA;AACA,OAFA,MAEA;AACA;AACA;AACA;AACA,KA7HA;AA8HA;AACAS,QA/HA,kBA+HA;AAAA;;AACAC;AACA;AACA;;AACA,yBACAC,IADA,CACAlB,0CADA,EACA,gBADA,EAEAmB,IAFA,CAEA;AACA;AACA;AACAd,+BADA;AAEAC,+BAFA;AAGAC;AAHA;;AAKA;AACA,aAPA,MAOA;AACA;AACAF,6BADA;AAEAC,+BAFA;AAGAC;AAHA;AAKA;AACA,WAjBA;AAkBA,SApBA,MAoBA;AACA;AACAF,yBADA;AAEAC;AAFA;AAIA;AACA,OA3BA;AA4BA;AA5JA;AAtCA","names":["name","data","baseApi","good","discount","standards","index","standard","fileList","dialogFormVisible","categoryItems","checkedCategory","created","url","methods","editStandard","addStandard","saveStandard","type","message","showClose","handleClose","handleImgSuccess","res","handleChange","file","handleRemove","submit","console","save","API","post","then"],"sourceRoot":"src/views/manage/good","sources":["GoodInfo.vue"],"sourcesContent":["<template>\r\n <div style=\"width: 1000px; margin: 50px auto\">\r\n <el-form :model=\"good\">\r\n <el-form-item label=\"商品名称\" label-width=\"150px\">\r\n <el-input\r\n v-model=\"good.name\"\r\n autocomplete=\"off\"\r\n style=\"width: 80%\"\r\n ></el-input>\r\n </el-form-item>\r\n <el-form-item label=\"商品描述\" label-width=\"150px\">\r\n <el-input\r\n v-model=\"good.description\"\r\n autocomplete=\"off\"\r\n style=\"width: 80%\"\r\n ></el-input>\r\n </el-form-item>\r\n <el-form-item label=\"规格\" label-width=\"150px\">\r\n <el-tag\r\n closable\r\n @close=\"handleClose(standard)\"\r\n :disable-transitions=\"true\"\r\n style=\"margin-right: 10px\"\r\n v-for=\"(standard, index) in standards\"\r\n :key=\"index\"\r\n @click=\"editStandard(index)\"\r\n >{{ standard.value }}</el-tag\r\n >\r\n <el-button icon=\"el-icon-plus\" circle @click=\"addStandard\"></el-button>\r\n </el-form-item>\r\n\r\n <el-form-item label=\"折扣\" label-width=\"150px\">\r\n <el-input\r\n v-model=\"good.discount\"\r\n autocomplete=\"off\"\r\n style=\"width: 80%\"\r\n ></el-input>\r\n </el-form-item>\r\n\r\n <el-form-item label=\"分类\" label-width=\"150px\">\r\n <el-select v-model=\"good.categoryId\" placeholder=\"请选择\">\r\n <el-option\r\n v-for=\"item in categoryItems\"\r\n :key=\"item.id\"\r\n :label=\"item.name\"\r\n :value=\"item.id\"\r\n >\r\n </el-option>\r\n </el-select>\r\n </el-form-item>\r\n <el-form-item label=\"商品图片\" label-width=\"150px\">\r\n <el-upload\r\n class=\"upload-demo\"\r\n ref=\"upload\"\r\n :action=\"baseApi + '/file/upload'\"\r\n :file-list=\"fileList\"\r\n :on-change=\"handleChange\"\r\n :limit=\"1\"\r\n :on-remove=\"handleRemove\"\r\n :on-success=\"handleImgSuccess\"\r\n :auto-upload=\"false\"\r\n >\r\n <el-button slot=\"trigger\" size=\"small\" type=\"primary\"\r\n >选取文件</el-button\r\n >\r\n <div slot=\"tip\" class=\"el-upload__tip\">\r\n 只能上传一个jpg/png文件且不超过500kb\r\n </div>\r\n </el-upload>\r\n </el-form-item>\r\n <el-form-item label-width=\"150px\">\r\n <el-button type=\"success\" @click=\"submit\">提交</el-button>\r\n </el-form-item>\r\n </el-form>\r\n <!-- 弹窗 -->\r\n <el-dialog\r\n title=\"规格信息\"\r\n :visible.sync=\"dialogFormVisible\"\r\n width=\"30%\"\r\n :close-on-click-modal=\"false\"\r\n >\r\n <el-form :model=\"standard\">\r\n <el-form-item label=\"规格名称\" label-width=\"150px\">\r\n <el-input\r\n v-model=\"standard.value\"\r\n autocomplete=\"off\"\r\n style=\"width: 80%\"\r\n ></el-input>\r\n </el-form-item>\r\n <el-form-item label=\"价格\" label-width=\"150px\">\r\n <el-input\r\n v-model=\"standard.price\"\r\n autocomplete=\"off\"\r\n style=\"width: 80%\"\r\n ></el-input>\r\n </el-form-item>\r\n <el-form-item label=\"库存\" label-width=\"150px\">\r\n <el-input\r\n v-model=\"standard.store\"\r\n autocomplete=\"off\"\r\n style=\"width: 80%\"\r\n ></el-input>\r\n </el-form-item>\r\n </el-form>\r\n <div slot=\"footer\" class=\"dialog-footer\">\r\n <el-button @click=\"dialogFormVisible = false\">取 消</el-button>\r\n <el-button type=\"primary\" @click=\"saveStandard\">确 定</el-button>\r\n </div>\r\n </el-dialog>\r\n </div>\r\n</template>\r\n\r\n<script>\r\nimport API from \"@/utils/request\";\r\nconst url = \"/api/good\";\r\nexport default {\r\n name: \"GoodInfo\",\r\n data() {\r\n return {\r\n baseApi: this.$store.state.baseApi,\r\n good: {\r\n discount: \"1\",\r\n },\r\n standards: [],\r\n index: 0,\r\n standard: {},\r\n fileList: [],\r\n dialogFormVisible: false,\r\n categoryItems: [],\r\n checkedCategory: {},\r\n };\r\n },\r\n created() {\r\n this.request.get(\"/api/category\").then((res) => {\r\n if (res.code === \"200\") {\r\n this.categoryItems = res.data;\r\n }\r\n if (this.$route.query.good) {\r\n this.good = JSON.parse(this.$route.query.good);\r\n this.fileList = [{ name: \"原始图片\", url: this.good.imgs }];\r\n this.checkedCategory = this.categoryItems[this.good.categoryId];\r\n //从服务器获取商品规格信息\r\n this.request.get(url + \"/standard/\" + this.good.id).then((res) => {\r\n if (res.code === \"200\") {\r\n let standards = JSON.parse(res.data);\r\n this.standards = standards;\r\n } else {\r\n //没有规格\r\n }\r\n });\r\n }\r\n });\r\n },\r\n methods: {\r\n /*\r\n 规格操作\r\n */\r\n editStandard(index) {\r\n this.standard = this.standards[index];\r\n this.index = index;\r\n this.dialogFormVisible = true;\r\n },\r\n addStandard() {\r\n this.standard = {};\r\n this.index = this.standards.length;\r\n this.dialogFormVisible = true;\r\n },\r\n saveStandard() {\r\n if (this.standard.value == undefined || this.standard.value == \"\") {\r\n \r\n this.$message({\r\n type: \"error\",\r\n message: \"请输入规格名称\",\r\n showClose: true,\r\n });\r\n return;\r\n }\r\n if (this.standard.price == undefined || this.standard.price == \"\") {\r\n this.$message({\r\n type: \"error\",\r\n message: \"请输入价格\",\r\n showClose: true,\r\n });\r\n return;\r\n }\r\n if (this.standard.store == undefined || this.standard.store == \"\") {\r\n this.$message({\r\n type: \"error\",\r\n message: \"请输入库存\",\r\n showClose: true,\r\n });\r\n return;\r\n }\r\n this.standards[this.index] = this.standard;\r\n this.dialogFormVisible = false;\r\n },\r\n handleClose(standard) {\r\n this.standards.splice(this.standards.indexOf(standard), 1);\r\n },\r\n /*\r\n 文件上传操作\r\n */\r\n handleImgSuccess(res) {\r\n this.good.imgs = res.data;\r\n this.save();\r\n },\r\n handleChange(file, fileList) {\r\n this.fileList = fileList.slice(-3);\r\n },\r\n handleRemove() {\r\n this.fileList.pop();\r\n },\r\n /*\r\n 保存数据操作\r\n */\r\n //点击提交按钮\r\n submit() {\r\n if (this.good.name == undefined || this.good.name.trim() == \"\") {\r\n this.$message({\r\n type: \"error\",\r\n message: \"请输入商品名称\",\r\n showClose: true,\r\n });\r\n return false;\r\n }\r\n if (\r\n this.good.description == undefined ||\r\n this.good.description.trim() == \"\"\r\n ) {\r\n this.$message({\r\n type: \"error\",\r\n message: \"请输入商品描述\",\r\n showClose: true,\r\n });\r\n return false;\r\n }\r\n if (this.standards.length === 0) {\r\n this.$message({\r\n type: \"error\",\r\n message: \"请至少添加一个规格\",\r\n showClose: true,\r\n });\r\n return false;\r\n }\r\n console.log(this.good.discount)\r\n if (this.good.discount == undefined || this.good.discount.trim() == \"\") {\r\n this.$message({\r\n type: \"error\",\r\n message: \"请输入商品折扣\",\r\n showClose: true,\r\n });\r\n return false;\r\n }\r\n if (\r\n this.good.categoryId == undefined\r\n ) {\r\n this.$message({\r\n type: \"error\",\r\n message: \"请选择商品分类\",\r\n showClose: true,\r\n });\r\n return false;\r\n }\r\n if (this.fileList.length === 0) {\r\n this.$message({\r\n type: \"error\",\r\n message: \"请上传图片\",\r\n showClose: true,\r\n });\r\n return false;\r\n }\r\n // 先上传图片再保存数据\r\n if (this.fileList[0].status === \"ready\") {\r\n this.$refs.upload.submit();\r\n } else if (this.fileList[0].status === \"success\") {\r\n //没有修改初始的图片。直接保存数据\r\n this.save();\r\n }\r\n },\r\n //保存数据\r\n save() {\r\n API.post(url, this.good).then((res2) => {\r\n if (res2.code === \"200\") {\r\n this.good.id = res2.data;\r\n this.request\r\n .post(url + \"/standard?goodId=\" + this.good.id, this.standards)\r\n .then((res) => {\r\n if (res.code === \"200\") {\r\n this.$message({\r\n type: \"success\",\r\n message: \"操作成功\",\r\n showClose: true,\r\n });\r\n this.$router.go(-1);\r\n } else {\r\n this.$message({\r\n type: \"error\",\r\n message: \"操作失败\",\r\n showClose: true,\r\n });\r\n }\r\n });\r\n } else {\r\n this.$message({\r\n type: \"error\",\r\n message: res2.msg,\r\n });\r\n }\r\n });\r\n },\r\n },\r\n};\r\n</script>\r\n\r\n<style scoped>\r\n</style>"]},"metadata":{},"sourceType":"module"}