1 line
12 KiB
JSON
1 line
12 KiB
JSON
{"ast":null,"code":"import \"core-js/modules/es.array.splice.js\";\nimport \"core-js/modules/es.array.slice.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//\nimport API from \"@/utils/request\";\nvar url = \"/api/good\";\nexport default {\n name: \"GoodInfo\",\n data: function data() {\n return {\n good: {},\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 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.fileList.length === 0) {\n this.$confirm(\"请上传图片\");\n return false;\n } // 先上传图片再保存数据\n\n\n if (this.fileList[0].status === 'ready') {\n console.log('上传中');\n console.log(this.fileList);\n this.$refs.upload.submit();\n } //没有修改初始的图片。直接保存数据\n else if (this.fileList[0].status === 'success') {\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA;AACA;AACA;AACAA,kBADA;AAEAC,MAFA,kBAEA;AACA;AACAC,cADA;AAEAC,mBAFA;AAGAC,cAHA;AAIAC,kBAJA;AAKAC,kBALA;AAMAC,8BANA;AAOAC,uBAPA;AAQAC;AARA;AAUA,GAbA;AAcAC,SAdA,qBAcA;AAAA;;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AAAAV;AAAAW;AAAA;AACA,2EAHA,CAIA;;AACA;AACA;AACA;AACA;AACA,WAHA,MAGA,CACA;AACA;AACA,SAPA;AAQA;AACA,KAlBA;AAsBA,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;AACA;AACA,KAjBA;AAkBAC,eAlBA,uBAkBAX,QAlBA,EAkBA;AACA;AACA,KApBA;;AAqBA;AACA;AACA;AACAY,oBAxBA,4BAwBAC,GAxBA,EAwBA;AACA;AACA;AACA,KA3BA;AA4BAC,gBA5BA,wBA4BAC,IA5BA,EA4BAd,QA5BA,EA4BA;AACA;AACA,KA9BA;AA+BAe,gBA/BA,0BA+BA;AACA;AACA,KAjCA;;AAkCA;AACA;AACA;AACA;AACAC,UAtCA,oBAsCA;AACA;AACA;AACA;AACA,OAJA,CAKA;;;AACA;AACAC;AACAA;AACA;AACA,OAJA,CAKA;AALA,WAMA;AACA;AACA;AACA,KArDA;AAsDA;AACAC,QAvDA,kBAuDA;AAAA;;AACAC;AACA;AACA;;AACA;AACA;AACA;AACAC,+BADA;AAEAC,+BAFA;AAGAC;AAHA;;AAKA;AACA,aAPA,MAOA;AACA;AACAF,6BADA;AAEAC,+BAFA;AAGAC;AAHA;AAKA;AACA,WAfA;AAgBA,SAlBA,MAkBA;AACA;AACAF,yBADA;AAEAC;AAFA;AAIA;AACA,OAzBA;AA0BA;AAlFA;AAtCA","names":["name","data","good","standards","index","standard","fileList","dialogFormVisible","categoryItems","checkedCategory","created","url","methods","editStandard","addStandard","saveStandard","handleClose","handleImgSuccess","res","handleChange","file","handleRemove","submit","console","save","API","type","message","showClose"],"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 v-model=\"good.name\" autocomplete=\"off\" style=\"width: 80%\"></el-input>\r\n </el-form-item>\r\n <el-form-item label=\"商品描述\" label-width=\"150px\">\r\n <el-input v-model=\"good.description\" autocomplete=\"off\" style=\"width: 80%\"></el-input>\r\n </el-form-item>\r\n <el-form-item label=\"规格\" label-width=\"150px\">\r\n <el-tag 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)\">{{standard.value}}</el-tag>\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 v-model=\"good.discount\" autocomplete=\"off\" style=\"width: 80%\"></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 </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=\"http://localhost:8888/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 <el-button slot=\"trigger\" size=\"small\" type=\"primary\">选取文件</el-button>\r\n <div slot=\"tip\" class=\"el-upload__tip\">只能上传一个jpg/png文件,且不超过500kb</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 title=\"规格信息\" :visible.sync=\"dialogFormVisible\" width=\"30%\"\r\n :close-on-click-modal=\"false\">\r\n <el-form :model=\"standard\">\r\n <el-form-item label=\"规格名称\" label-width=\"150px\">\r\n <el-input v-model=\"standard.value\" autocomplete=\"off\" style=\"width: 80%\"></el-input>\r\n </el-form-item>\r\n <el-form-item label=\"价格\" label-width=\"150px\">\r\n <el-input v-model=\"standard.price\" autocomplete=\"off\" style=\"width: 80%\"></el-input>\r\n </el-form-item>\r\n <el-form-item label=\"库存\" label-width=\"150px\">\r\n <el-input v-model=\"standard.store\" autocomplete=\"off\" style=\"width: 80%\"></el-input>\r\n </el-form-item>\r\n\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\r\n\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 good:{},\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\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 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.fileList.length===0){\r\n this.$confirm(\"请上传图片\");\r\n return false;\r\n }\r\n // 先上传图片再保存数据\r\n if(this.fileList[0].status==='ready') {\r\n console.log('上传中')\r\n console.log(this.fileList)\r\n this.$refs.upload.submit();\r\n }\r\n //没有修改初始的图片。直接保存数据\r\n else if(this.fileList[0].status==='success'){\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.post(url+\"/standard?goodId=\"+this.good.id,this.standards).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\r\n</style>"]},"metadata":{},"sourceType":"module"} |