{"remainingRequest":"/Users/admin/projects/dms/src/dealer_admin/node_modules/thread-loader/dist/cjs.js!/Users/admin/projects/dms/src/dealer_admin/node_modules/babel-loader/lib/index.js!/Users/admin/projects/dms/src/dealer_admin/node_modules/cache-loader/dist/cjs.js??ref--0-0!/Users/admin/projects/dms/src/dealer_admin/node_modules/vue-loader/lib/index.js??vue-loader-options!/Users/admin/projects/dms/src/dealer_admin/src/views/system/role/components/menuList.vue?vue&type=script&lang=js","dependencies":[{"path":"/Users/admin/projects/dms/src/dealer_admin/src/views/system/role/components/menuList.vue","mtime":1713161556000},{"path":"/Users/admin/projects/dms/src/dealer_admin/babel.config.js","mtime":1713161556000},{"path":"/Users/admin/projects/dms/src/dealer_admin/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/Users/admin/projects/dms/src/dealer_admin/node_modules/thread-loader/dist/cjs.js","mtime":499162500000},{"path":"/Users/admin/projects/dms/src/dealer_admin/node_modules/babel-loader/lib/index.js","mtime":456789000000},{"path":"/Users/admin/projects/dms/src/dealer_admin/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/Users/admin/projects/dms/src/dealer_admin/node_modules/vue-loader/lib/index.js","mtime":499162500000}],"contextDependencies":[],"result":["import \"core-js/modules/es6.function.name\";\nimport \"core-js/modules/web.dom.iterable\";\nimport _regeneratorRuntime from \"/Users/admin/projects/dms/src/dealer_admin/node_modules/@babel/runtime-corejs2/helpers/esm/regeneratorRuntime.js\";\nimport \"regenerator-runtime/runtime\";\nimport _asyncToGenerator from \"/Users/admin/projects/dms/src/dealer_admin/node_modules/@babel/runtime-corejs2/helpers/esm/asyncToGenerator.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\nimport * as API from \"@/api/role\";\nexport default {\n  name: 'MenuList',\n  components: {},\n  data: function data() {\n    return {\n      dialogFormVisible: false,\n      list: [],\n      menuList: [],\n      roleId: '',\n      defaultCheckKey: []\n    };\n  },\n  computed: {},\n  created: function created() {},\n  methods: {\n    init: function () {\n      var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(id) {\n        return _regeneratorRuntime().wrap(function _callee$(_context) {\n          while (1) switch (_context.prev = _context.next) {\n            case 0:\n              this.roleId = id;\n              this.getRoleMenuList(id);\n            case 2:\n            case \"end\":\n              return _context.stop();\n          }\n        }, _callee, this);\n      }));\n      function init(_x) {\n        return _init.apply(this, arguments);\n      }\n      return init;\n    }(),\n    /** 处理更新 */getRoleMenuList: function () {\n      var _getRoleMenuList = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_id) {\n        var _this = this;\n        var resData, __error, msg, result, defaultCheckKey, list;\n        return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n          while (1) switch (_context2.prev = _context2.next) {\n            case 0:\n              _context2.next = 2;\n              return API.getRoleMenuList({\n                'role': _id\n              });\n            case 2:\n              resData = _context2.sent;\n              __error = resData.__error, msg = resData.msg, result = resData.result;\n              if (!(__error != 0)) {\n                _context2.next = 7;\n                break;\n              }\n              this.$message({\n                message: \"\".concat(msg),\n                type: \"warning\",\n                duration: 1501,\n                onClose: function onClose() {}\n              });\n              return _context2.abrupt(\"return\");\n            case 7:\n              console.log(result.list);\n              this.menuList = [];\n              this.menuList = result.list;\n              defaultCheckKey = [];\n              this.menuList.map(function (v) {\n                if (v.select == 1) {\n                  var pass = true;\n                  if (v.parent_code == \"\") {\n                    for (var i = 0, l = _this.menuList.length; i < l; i++) {\n                      var item = _this.menuList[i];\n                      if (item.parent_code == v.code && item.select != 1) {\n                        pass = false;\n                        i = l;\n                      }\n                    }\n                  }\n                  if (pass) defaultCheckKey.push(v._id);\n                }\n              });\n              this.defaultCheckKey = [];\n              this.defaultCheckKey = defaultCheckKey;\n              console.log(\"defaultCheckKey:\", defaultCheckKey);\n              list = this.menu_merge(result.list);\n              console.log(\"list:\", list);\n              this.list = list;\n              this.dialogFormVisible = true;\n            case 19:\n            case \"end\":\n              return _context2.stop();\n          }\n        }, _callee2, this);\n      }));\n      function getRoleMenuList(_x2) {\n        return _getRoleMenuList.apply(this, arguments);\n      }\n      return getRoleMenuList;\n    }(),\n    menu_merge: function menu_merge(node) {\n      var _this2 = this;\n      var pid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';\n      var arr = [];\n      node.forEach(function (v, index) {\n        v['label'] = v.name;\n        v['style'] = v.style;\n        v['id'] = v._id;\n        if (v['parent_code'] == pid) {\n          v['children'] = _this2.menu_merge(node, v['code']);\n          arr.push(v);\n        }\n      });\n      if (arr.length <= 0) return null;else return arr;\n    },\n    handleSelectionChange: function handleSelectionChange(val) {\n      console.log('val:', val);\n    },\n    handleCheckChange: function handleCheckChange(data, checked, indeterminate) {\n      // console.log(\"data:\",data);\n      console.log(\"checked:\", checked);\n      // console.log(\"indeterminate:\",indeterminate);\n      for (var i = 0, l = this.menuList.length; i < l; i++) {\n        var item = this.menuList[i];\n        if (data.code == item.code) {\n          item.select = checked ? 1 : 0;\n          this.menuList[i] = item;\n          i = l;\n          console.log(\"item:\", item);\n        }\n      }\n      if (checked) {\n        for (var i = 0, l = this.menuList.length; i < l; i++) {\n          var _item = this.menuList[i];\n          if (data.parent_code == _item.code) {\n            _item.select = 1;\n            this.menuList[i] = _item;\n            i = l;\n            console.log(\"item:\", _item);\n          }\n        }\n      } else {\n        var child_menu_list = [];\n        for (var i = 0, l = this.menuList.length; i < l; i++) {\n          var _item2 = this.menuList[i];\n          if (data.parent_code == _item2.parent_code && _item2.select == 1) {\n            child_menu_list.push(_item2);\n          }\n        }\n        if (child_menu_list.length <= 0) {\n          for (var i = 0, l = this.menuList.length; i < l; i++) {\n            var _item3 = this.menuList[i];\n            if (data.parent_code == _item3.code) {\n              _item3.select = 0;\n              this.menuList[i] = _item3;\n              i = l;\n            }\n          }\n        }\n      }\n    },\n    /** 表单提交，区分好 是 新增 、 更新 */dataFormSubmit: function () {\n      var _dataFormSubmit = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n        var menuIdList, menuList, postData, res;\n        return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n          while (1) switch (_context3.prev = _context3.next) {\n            case 0:\n              _context3.next = 2;\n              return this.$confirm(\"\\u786E\\u8BA4\\uFF1F\", \"提示\", {\n                type: \"warning\"\n              });\n            case 2:\n              menuIdList = [];\n              menuList = this.menuList;\n              menuList.map(function (v) {\n                if (v.select == 1) menuIdList.push(v._id);\n              });\n              //console.log(\"menuList:\",menuList);\n              console.log(\"menuIdList:\", menuIdList);\n              //return false;\n              menuIdList = JSON.stringify(menuIdList);\n              postData = {\n                role: this.roleId,\n                menuIdList: menuIdList\n              };\n              _context3.next = 10;\n              return API.setRoleMenu(postData);\n            case 10:\n              res = _context3.sent;\n              this.dialogFormVisible = false;\n              this.$message({\n                message: \"\\u7F16\\u8F91\\u6210\\u529F\",\n                type: \"success\",\n                duration: 1501,\n                onClose: function onClose() {}\n              });\n              // this.$refs[\"dataForm\"].validate(async valid => {\n              //   if (valid) {\n              //     const tempData = _.cloneDeep(this.form);\n              //     tempData.time=this.value1\n              //     console.log(\"input info :------------------------ \", tempData);\n              //     let res;\n              //     if (this.dialogStatus === \"update\") {\n              //       tempData.id = this.form._id;\n              //       res = await API.update(tempData);\n              //     } else if (this.dialogStatus === \"add\") {\n              //       res = await API.create(tempData);\n              //     }\n              //     console.log(\"res: \", res);\n\n              //     this.dialogFormVisible = false;\n\n              //     this.$message({\n              //       message: `${this.textMap[this.dialogStatus]}成功`,\n              //       type: \"success\",\n              //       duration: 1501,\n              //       onClose: () => {\n              //       }\n              //     });\n\n              //     setTimeout(() => {\n              //       this.$emit(\"refreshDataList\");\n              //     }, 500);\n              //   }\n              // });\n            case 13:\n            case \"end\":\n              return _context3.stop();\n          }\n        }, _callee3, this);\n      }));\n      function dataFormSubmit() {\n        return _dataFormSubmit.apply(this, arguments);\n      }\n      return dataFormSubmit;\n    }()\n  }\n};",null]}