1 line
16 KiB
JSON
1 line
16 KiB
JSON
{"ast":null,"code":"import \"core-js/modules/es.string.trim.js\";\nimport \"core-js/modules/es.function.name.js\";\nimport \"core-js/modules/es.json.stringify.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//\nimport API from \"../../../utils/request\";\nimport icons from \"@/utils/icons\";\nexport default {\n name: \"Category\",\n data: function data() {\n return {\n options: [],\n searchText: \"\",\n user: {},\n //从icons.js中引入常量iconStore\n iconStore: icons.iconStore,\n icons: [],\n icon: {},\n addIcon: {},\n pageNum: 1,\n pageSize: 5,\n entity: {},\n total: 0,\n dialogFormVisible: false,\n addDialogFormVisible: false\n };\n },\n created: function created() {\n this.user = localStorage.getItem(\"user\") ? JSON.parse(sessionStorage.getItem(\"user\")) : {};\n this.load();\n console.log(this.iconStore);\n },\n methods: {\n load: function load() {\n var _this = this;\n\n this.request.get(\"/api/icon\").then(function (res) {\n _this.icons = res.data;\n });\n },\n handleEditCategory: function handleEditCategory(category) {\n var _this2 = this;\n\n this.$prompt(\"请输入修改后的名称\", \"提示\", {\n confirmButtonText: \"确定\",\n cancelButtonText: \"取消\"\n }).then(function (_ref) {\n var value = _ref.value;\n\n if (value == null || value == undefined || value.trim() == \"\") {\n _this2.$message.error(\"请输入名称\");\n\n return;\n }\n\n category.name = value;\n\n _this2.request.post(\"/api/category\", category).then(function (res) {\n if (res.code === \"200\") {\n _this2.$message.success(\"修改成功\");\n } else {\n _this2.$message.error(\"修改失败\");\n }\n });\n }).catch(function () {});\n },\n handleAddCategory: function handleAddCategory(icon) {\n var _this3 = this;\n\n this.$prompt(\"请输入新增的下级分类名称\", \"提示\", {\n confirmButtonText: \"确定\",\n cancelButtonText: \"取消\"\n }).then(function (_ref2) {\n var value = _ref2.value;\n\n if (value == null || value == undefined || value.trim() == \"\") {\n _this3.$message.error(\"请输入名称\");\n\n return;\n }\n\n _this3.request.post(\"/api/category/add\", {\n name: value,\n iconId: icon.id\n }).then(function (res) {\n if (res.code === \"200\") {\n _this3.$message.success(\"新增成功\");\n\n _this3.load();\n } else {\n _this3.$message.error(\"新增失败\");\n }\n });\n }).catch(function () {});\n },\n handleEditIcon: function handleEditIcon(icon) {\n this.icon = JSON.parse(JSON.stringify(icon));\n this.dialogFormVisible = true;\n },\n editIcon: function editIcon() {\n var _this4 = this;\n\n //删除无用的属性\n delete this.icon.categories;\n this.request.post(\"/api/icon\", this.icon).then(function (res) {\n if (res.code === \"200\") {\n _this4.$message.success(\"修改成功\");\n\n _this4.dialogFormVisible = false;\n } else {\n _this4.$message.error(\"修改失败\");\n }\n });\n },\n saveIcon: function saveIcon() {\n var _this5 = this;\n\n // 新增上级分类\n if (this.addIcon.value == undefined) {\n this.$message.error(\"请选择上级分类图标\");\n return;\n }\n\n this.request.post(\"/api/icon\", this.addIcon).then(function (res) {\n console.log(res);\n\n if (res.code === \"200\") {\n _this5.$message.success(\"新增成功\");\n\n _this5.addDialogFormVisible = false;\n\n _this5.load();\n } else {\n _this5.$message.error(\"新增失败\");\n }\n });\n },\n deleteIcon: function deleteIcon(iconId) {\n var _this6 = this;\n\n // 删除上级分类\n this.request.get(\"/api/icon/delete?id=\" + iconId).then(function (res) {\n if (res.code == \"200\") {\n _this6.$message.success(\"删除成功\");\n\n _this6.load();\n } else {\n _this6.$message.error(res.msg);\n }\n });\n },\n deleteCategory: function deleteCategory(category) {\n var _this7 = this;\n\n // 删除下级分类\n this.request.get(\"/api/category/delete?id=\" + category.id).then(function (res) {\n if (res.code == \"200\") {\n _this7.$message.success(\"删除成功\");\n\n _this7.load();\n } else {\n _this7.$message.error(res.msg);\n }\n });\n }\n }\n};","map":{"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4FA;AACA;AACA;AACAA,kBADA;AAEAC,MAFA,kBAEA;AACA;AACAC,iBADA;AAEAC,oBAFA;AAGAC,cAHA;AAIA;AACAC,gCALA;AAMAC,eANA;AAOAC,cAPA;AAQAC,iBARA;AASAC,gBATA;AAUAC,iBAVA;AAWAC,gBAXA;AAYAC,cAZA;AAaAC,8BAbA;AAcAC;AAdA;AAgBA,GAnBA;AAoBAC,SApBA,qBAoBA;AACA,+CACAC,0CADA,GAEA,EAFA;AAGA;AACAC;AACA,GA1BA;AA2BAC;AACAC,QADA,kBACA;AAAA;;AACA;AACA;AACA,OAFA;AAGA,KALA;AAOAC,sBAPA,8BAOAC,QAPA,EAOA;AAAA;;AACA;AACAC,+BADA;AAEAC;AAFA,SAGAC,IAHA,CAGA;AAAA;;AACA;AACA;;AACA;AACA;;AACAH;;AACA;AACA;AACA;AACA,WAFA,MAEA;AACA;AACA;AACA,SANA;AAOA,OAhBA,EAgBAI,KAhBA,CAgBA,aAEA,CAlBA;AAmBA,KA3BA;AA4BAC,qBA5BA,6BA4BAnB,IA5BA,EA4BA;AAAA;;AACA;AACAe,+BADA;AAEAC;AAFA,SAGAC,IAHA,CAGA;AAAA;;AAEA;AACA;;AACA;AACA;;AACA,uBACAG,IADA,CACA,mBADA,EACA;AAAA3B;AAAA4B;AAAA,SADA,EAEAJ,IAFA,CAEA;AACA;AACA;;AACA;AACA,WAHA,MAGA;AACA;AACA;AACA,SATA;AAUA,OAnBA,EAmBAC,KAnBA,CAmBA,aAEA,CArBA;AAsBA,KAnDA;AAoDAI,kBApDA,0BAoDAtB,IApDA,EAoDA;AACA;AACA;AACA,KAvDA;AAwDAuB,YAxDA,sBAwDA;AAAA;;AACA;AACA;AACA;AACA;AACA;;AACA;AACA,SAHA,MAGA;AACA;AACA;AACA,OAPA;AAQA,KAnEA;AAoEAC,YApEA,sBAoEA;AAAA;;AACA;AACA;AACA;AACA;AACA;;AACA;AACAd;;AACA;AACA;;AACA;;AACA;AACA,SAJA,MAIA;AACA;AACA;AACA,OATA;AAUA,KApFA;AAqFAe,cArFA,sBAqFAJ,MArFA,EAqFA;AAAA;;AACA;AACA;AACA;AACA;;AACA;AACA,SAHA,MAGA;AACA;AACA;AACA,OAPA;AAQA,KA/FA;AAgGAK,kBAhGA,0BAgGAZ,QAhGA,EAgGA;AAAA;;AACA;AACA;AACA;AACA;;AACA;AACA,SAHA,MAGA;AACA;AACA;AACA,OAPA;AAQA;AA1GA;AA3BA","names":["name","data","options","searchText","user","iconStore","icons","icon","addIcon","pageNum","pageSize","entity","total","dialogFormVisible","addDialogFormVisible","created","JSON","console","methods","load","handleEditCategory","category","confirmButtonText","cancelButtonText","then","catch","handleAddCategory","post","iconId","handleEditIcon","editIcon","saveIcon","deleteIcon","deleteCategory"],"sourceRoot":"src/views/manage/good","sources":["Category.vue"],"sourcesContent":["<template>\r\n <div>\r\n <div style=\"width: 60%; margin: 30px auto\">\r\n <el-button type=\"success\" icon=\"iconfont icon-r-add\" style=\"font-size: 20px;\"\r\n @click=\"addDialogFormVisible = true\"> 新增</el-button>\r\n <el-table :data=\"icons\" stripe>\r\n <!-- 下级分类表-->\r\n <el-table-column type=\"expand\" label=\"下级分类\" width=\"100px\">\r\n <template slot-scope=\"scope\">\r\n <el-table :data=\"scope.row.categories\" :header-cell-style=\"{ background: '#cbefea', color: 'black' }\">\r\n <el-table-column label=\"分类id\" prop=\"id\"></el-table-column>\r\n <el-table-column label=\"分类名称\" prop=\"name\"></el-table-column>\r\n <el-table-column label=\"操作\" width=\"240\">\r\n <template slot-scope=\"scope\">\r\n <el-button type=\"primary\" @click=\"handleEditCategory(scope.row)\"> 修改</el-button>\r\n\r\n <el-popconfirm @confirm=\"deleteCategory(scope.row)\" title=\"确定删除?\">\r\n <el-button type=\"danger\" slot=\"reference\"> 删除</el-button>\r\n </el-popconfirm>\r\n </template>\r\n </el-table-column>\r\n </el-table>\r\n </template>\r\n <!---->\r\n </el-table-column>\r\n <el-table-column label=\"id\" prop=\"id\" width=\"60px\"></el-table-column>\r\n <el-table-column label=\"icon\">\r\n <template slot-scope=\"scope\">\r\n <i class=\"iconfont\" v-html=\"scope.row.value\"></i>\r\n </template>\r\n </el-table-column>\r\n\r\n <el-table-column fixed=\"right\" label=\"操作\" width=\"200\">\r\n <template slot-scope=\"scope\">\r\n <el-button type=\"primary\" style=\"font-size: 18px;\" icon=\"el-icon-a-032\" circle\r\n @click=\"handleEditIcon(scope.row)\"></el-button>\r\n <el-button type=\"success\" icon=\"iconfont icon-r-add\" style=\"font-size: 18px;\" circle\r\n @click=\"handleAddCategory(scope.row)\"></el-button>\r\n\r\n <el-popconfirm @confirm=\"deleteIcon(scope.row.id)\" title=\"确定删除?\">\r\n <el-button type=\"danger\" icon=\"iconfont icon-r-delete\" style=\"font-size: 18px;margin-left: 10px;\" circle\r\n slot=\"reference\"></el-button>\r\n </el-popconfirm>\r\n </template>\r\n </el-table-column>\r\n </el-table>\r\n </div>\r\n\r\n <!--icon修改弹窗-->\r\n <el-dialog title=\"修改上级分类\" :visible.sync=\"dialogFormVisible\">\r\n <el-form :model=\"icon\">\r\n <el-form-item label=\"图标\" label-width=\"100px\">\r\n <i class=\"iconfont\" v-html=\"icon.value\"></i>\r\n </el-form-item>\r\n <el-form-item label=\"更改图标\" label-width=\"100px\">\r\n <el-select placeholder=\"请选择图标\" v-model=\"icon.value\">\r\n <el-option v-for=\"item in iconStore\" :value=\"item\" :key=\"item\">\r\n <i class=\"iconfont\" v-html=\"item\"></i>\r\n </el-option>\r\n </el-select>\r\n </el-form-item>\r\n </el-form>\r\n <div slot=\"footer\" class=\"dialog-footer\">\r\n <el-button @click=\"dialogFormVisible = false\" style=\"font-size: 20px;\"> 取消</el-button>\r\n <el-button type=\"primary\" @click=\"editIcon\" style=\"font-size: 20px;\"><i class=\"iconfont icon-r-yes\"\r\n style=\"font-size: 22px;\"></i> 确定</el-button>\r\n </div>\r\n </el-dialog>\r\n\r\n <el-dialog title=\"新增上级分类\" :visible.sync=\"addDialogFormVisible\">\r\n <el-form :model=\"addIcon\">\r\n <el-form-item label=\"图标\" label-width=\"100px\">\r\n <i class=\"iconfont\" v-html=\"addIcon.value\"></i>\r\n </el-form-item>\r\n <el-form-item label=\"更改图标\" label-width=\"100px\">\r\n <el-select placeholder=\"请选择图标\" v-model=\"addIcon.value\">\r\n <el-option v-for=\"item in iconStore\" :value=\"item\" :key=\"item\">\r\n <i class=\"iconfont\" v-html=\"item\"></i>\r\n </el-option>\r\n </el-select>\r\n </el-form-item>\r\n </el-form>\r\n <div slot=\"footer\" class=\"dialog-footer\">\r\n <el-button @click=\"addDialogFormVisible = false\" style=\"font-size: 20px;\"> 取消</el-button>\r\n <el-button type=\"primary\" @click=\"saveIcon\" style=\"font-size: 20px;\"><i class=\"iconfont icon-r-yes\"\r\n style=\"font-size: 22px;\"></i> 确定</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\nimport icons from \"@/utils/icons\";\r\nexport default {\r\n name: \"Category\",\r\n data() {\r\n return {\r\n options: [],\r\n searchText: \"\",\r\n user: {},\r\n //从icons.js中引入常量iconStore\r\n iconStore: icons.iconStore,\r\n icons: [],\r\n icon: {},\r\n addIcon: {},\r\n pageNum: 1,\r\n pageSize: 5,\r\n entity: {},\r\n total: 0,\r\n dialogFormVisible: false,\r\n addDialogFormVisible: false,\r\n };\r\n },\r\n created() {\r\n this.user = localStorage.getItem(\"user\")\r\n ? JSON.parse(sessionStorage.getItem(\"user\"))\r\n : {};\r\n this.load();\r\n console.log(this.iconStore);\r\n },\r\n methods: {\r\n load() {\r\n this.request.get(\"/api/icon\").then((res) => {\r\n this.icons = res.data;\r\n });\r\n },\r\n\r\n handleEditCategory(category) {\r\n this.$prompt(\"请输入修改后的名称\", \"提示\", {\r\n confirmButtonText: \"确定\",\r\n cancelButtonText: \"取消\",\r\n }).then(({ value }) => {\r\n if (value == null || value == undefined || value.trim() == \"\") {\r\n this.$message.error(\"请输入名称\");\r\n return\r\n }\r\n category.name = value;\r\n this.request.post(\"/api/category\", category).then((res) => {\r\n if (res.code === \"200\") {\r\n this.$message.success(\"修改成功\");\r\n } else {\r\n this.$message.error(\"修改失败\");\r\n }\r\n });\r\n }).catch(() => {\r\n\r\n });\r\n },\r\n handleAddCategory(icon) {\r\n this.$prompt(\"请输入新增的下级分类名称\", \"提示\", {\r\n confirmButtonText: \"确定\",\r\n cancelButtonText: \"取消\",\r\n }).then(({ value }) => {\r\n\r\n if (value == null || value == undefined || value.trim() == \"\") {\r\n this.$message.error(\"请输入名称\");\r\n return\r\n }\r\n this.request\r\n .post(\"/api/category/add\", { name: value, iconId: icon.id })\r\n .then((res) => {\r\n if (res.code === \"200\") {\r\n this.$message.success(\"新增成功\");\r\n this.load();\r\n } else {\r\n this.$message.error(\"新增失败\");\r\n }\r\n });\r\n }).catch(() => {\r\n\r\n });\r\n },\r\n handleEditIcon(icon) {\r\n this.icon = JSON.parse(JSON.stringify(icon));\r\n this.dialogFormVisible = true;\r\n },\r\n editIcon() {\r\n //删除无用的属性\r\n delete this.icon.categories;\r\n this.request.post(\"/api/icon\", this.icon).then((res) => {\r\n if (res.code === \"200\") {\r\n this.$message.success(\"修改成功\");\r\n this.dialogFormVisible = false;\r\n } else {\r\n this.$message.error(\"修改失败\");\r\n }\r\n });\r\n },\r\n saveIcon() {\r\n // 新增上级分类\r\n if (this.addIcon.value == undefined) {\r\n this.$message.error(\"请选择上级分类图标\");\r\n return;\r\n }\r\n this.request.post(\"/api/icon\", this.addIcon).then((res) => {\r\n console.log(res);\r\n if (res.code === \"200\") {\r\n this.$message.success(\"新增成功\");\r\n this.addDialogFormVisible = false;\r\n this.load();\r\n } else {\r\n this.$message.error(\"新增失败\");\r\n }\r\n });\r\n },\r\n deleteIcon(iconId) {\r\n // 删除上级分类\r\n this.request.get(\"/api/icon/delete?id=\" + iconId).then((res) => {\r\n if (res.code == \"200\") {\r\n this.$message.success(\"删除成功\");\r\n this.load();\r\n } else {\r\n this.$message.error(res.msg);\r\n }\r\n });\r\n },\r\n deleteCategory(category) {\r\n // 删除下级分类\r\n this.request.get(\"/api/category/delete?id=\" + category.id).then((res) => {\r\n if (res.code == \"200\") {\r\n this.$message.success(\"删除成功\");\r\n this.load();\r\n } else {\r\n this.$message.error(res.msg);\r\n }\r\n });\r\n },\r\n },\r\n};\r\n</script>\r\n\r\n<style scoped>\r\n@import \"../../../resource/css/icon.css\";\r\n</style>\r\n"]},"metadata":{},"sourceType":"module"} |