1 line
15 KiB
JSON
1 line
15 KiB
JSON
|
{"ast":null,"code":"import \"core-js/modules/es.json.stringify.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//\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: \"Goods\",\n data: function data() {\n return {\n baseApi: this.$store.state.baseApi,\n fileList: [],\n options: [],\n searchText: '',\n user: {},\n tableData: [],\n pageNum: 1,\n pageSize: 5,\n entity: {},\n total: 0,\n dialogFormVisible: false\n };\n },\n created: function created() {\n this.user = localStorage.getItem(\"user\") ? JSON.parse(localStorage.getItem(\"user\")) : {};\n this.load();\n },\n methods: {\n handleSizeChange: function handleSizeChange(pageSize) {\n this.pageSize = pageSize;\n this.load();\n },\n handleCurrentChange: function handleCurrentChange(pageNum) {\n this.pageNum = pageNum;\n this.load();\n },\n handleRecommend: function handleRecommend(good) {\n var _this = this;\n\n API.get(url + \"recommend\", {\n params: {\n id: good.id,\n isRecommend: good.recommend\n }\n }).then(function (res) {\n if (res.code === '200') {\n _this.$message.success(\"修改成功\");\n } else {\n _this.$message.error(res.msg);\n }\n });\n },\n load: function load() {\n var _this2 = this;\n\n API.get(url + \"fullPage\", {\n params: {\n pageNum: this.pageNum,\n pageSize: this.pageSize,\n searchText: this.searchText\n }\n }).then(function (res) {\n _this2.tableData = res.data.records;\n _this2.total = res.data.total;\n });\n },\n reset: function reset() {\n this.searchText = '';\n this.load();\n },\n add: function add() {\n // this.entity = {}\n // this.fileList = []\n // this.dialogFormVisible = true\n this.$router.push(\"goodInfo\");\n },\n edit: function edit(obj) {\n this.entity = JSON.parse(JSON.stringify(obj));\n this.$router.push({\n name: 'goodInfo',\n query: {\n good: JSON.stringify(this.entity)\n }\n });\n },\n handleImgSuccess: function handleImgSuccess(res) {\n var _this3 = this;\n\n this.entity.imgs = res.data;\n API.post(url, this.entity).then(function (res2) {\n if (res2.code === '200') {\n _this3.$message({\n type: \"success\",\n message: \"操作成功\"\n });\n } else {\n _this3.$message({\n type: \"error\",\n message: res2.msg\n });\n }\n\n _this3.load();\n\n _this3.dialogFormVisible = false;\n });\n },\n save: function save() {\n var _this4 = this;\n\n console.log(this.fileList); //上传图片\n\n if (this.fileList.length !== 0) {\n console.log('上传中');\n this.$refs.upload.submit();\n } else {\n //不上传图片\n console.log(this.entity);\n API.post(url, this.entity).then(function (res2) {\n if (res2.code === '200') {\n _this4.$message({\n type: \"success\",\n message: \"操作成功\"\n });\n } else {\n _this4.$message({\n type: \"error\",\n message: res2.msg\n });\n }\n\n _this4.load();\n\n _this4.dialogFormVisible = false;\n });\n }\n },\n del: function del(id) {\n var _this5 = this;\n\n
|