1 |
- {"version":3,"sources":["webpack:///src/views/ums/role/allocResource.vue","webpack:///./src/views/ums/role/allocResource.vue?807c","webpack:///./src/views/ums/role/allocResource.vue","webpack:///./src/api/resource.js"],"names":["allocResource","name","data","roleId","allResource","allResourceCate","created","this","$route","query","getAllResourceCateList","methods","getAllResourceList","_this","Object","resource","then","response","i","length","checked","getResourceByRole","_this2","resourceCategory","getResourceByCate","categoryId","cateResource","push","_this3","role","forEach","item","getResourceChecked","id","isAllChecked","$forceUpdate","resourceId","isIndeterminate","cateResources","checkedCount","handleSave","_this4","$confirm","confirmButtonText","cancelButtonText","type","checkedResourceIds","set_default","a","add","obj","resourceIds","from_default","join","$message","message","duration","$router","back","handleClear","handleCheckAllChange","cate","handleCheckChange","_this5","role_allocResource","render","_vm","_h","$createElement","_c","_self","staticClass","attrs","shadow","_l","index","key","class","staticStyle","background","indeterminate","on","change","$event","model","value","callback","$$v","$set","expression","_v","_s","padding","span","margin-top","align","click","staticRenderFns","Component","__webpack_require__","normalizeComponent","ssrContext","__webpack_exports__","params","__WEBPACK_IMPORTED_MODULE_0__utils_request__","url","method"],"mappings":"0LA+BAA,GACAC,KAAA,gBACAC,KAFA,WAGA,OACAC,OAAA,KACAC,YAAA,KACAC,gBAAA,OAGAC,QATA,WAUAC,KAAAJ,OAAAI,KAAAC,OAAAC,MAAAN,OACAI,KAAAG,0BAEAC,SACAC,mBADA,WACA,IAAAC,EAAAN,KACAO,OAAAC,EAAA,EAAAD,GAAAE,KAAA,SAAAC,GACAJ,EAAAT,YAAAa,EAAAf,KACA,QAAAgB,EAAA,EAAAA,EAAAL,EAAAT,YAAAe,OAAAD,IACAL,EAAAT,YAAAc,GAAAE,SAAA,EAEAP,EAAAQ,kBAAAR,EAAAV,WAGAO,uBAVA,WAUA,IAAAY,EAAAf,KACAO,OAAAS,EAAA,EAAAT,GAAAE,KAAA,SAAAC,GACAK,EAAAjB,gBAAAY,EAAAf,KACA,QAAAgB,EAAA,EAAAA,EAAAI,EAAAjB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sECxBO,SAAmBK,GACxB,OAAOzF,OAAA0F,EAAA,EAAA1F,EACL2F,IAAK,iBACLC,OAAQ,MACRH,OAAQA,SAIL,SAAwBrG,GAC7B,OAAOY,OAAA0F,EAAA,EAAA1F,EACL2F,IAAK,mBACLC,OAAQ,OACRxG,KAAMA,SAIH,SAAwB+B,EAAI/B,GACjC,OAAOY,OAAA0F,EAAA,EAAA1F,EACL2F,IAAK,oBAAsBxE,EAC3ByE,OAAQ,OACRxG,KAAMA,SAIH,SAAwB+B,GAC7B,OAAOnB,OAAA0F,EAAA,EAAA1F,EACL2F,IAAK,oBAAsBxE,EAC3ByE,OAAQ,cAIL,WACL,OAAO5F,OAAA0F,EAAA,EAAA1F,EACL2F,IAAK,oBACLC,OAAQ","file":"static/js/21.e8b81fffa1f329a1e2a6.js","sourcesContent":["<template>\n <el-card class=\"form-container\" shadow=\"never\">\n <div v-for=\"(cate,index) in allResourceCate\" :class=\"index===0?'top-line':null\" :key=\"'cate'+cate.id\">\n <el-row class=\"table-layout\" style=\"background: #F2F6FC;\">\n <el-checkbox v-model=\"cate.checked\"\n :indeterminate=\"isIndeterminate(cate.id)\"\n @change=\"handleCheckAllChange(cate)\">\n {{cate.name}}\n </el-checkbox>\n </el-row>\n <el-row class=\"table-layout\">\n <el-col :span=\"8\" v-for=\"resource in getResourceByCate(cate.id)\" :key=\"resource.id\" style=\"padding: 4px 0\">\n <el-checkbox v-model=\"resource.checked\" @change=\"handleCheckChange(resource)\">\n {{resource.name}}\n </el-checkbox>\n </el-col>\n </el-row>\n </div>\n <div style=\"margin-top: 20px\" align=\"center\">\n <el-button type=\"primary\" @click=\"handleSave()\">保存</el-button>\n <el-button @click=\"handleClear()\">清空</el-button>\n </div>\n\n </el-card>\n</template>\n\n<script>\n import {fetchAllResourceList} from '@/api/resource';\n import {listAllCate} from '@/api/resourceCategory';\n import {allocResource,listResourceByRole} from '@/api/role';\n\n export default {\n name: \"allocResource\",\n data() {\n return {\n roleId: null,\n allResource: null,\n allResourceCate: null\n };\n },\n created() {\n this.roleId = this.$route.query.roleId;\n this.getAllResourceCateList();\n },\n methods: {\n getAllResourceList() {\n fetchAllResourceList().then(response => {\n this.allResource = response.data;\n for (let i = 0; i < this.allResource.length; i++) {\n this.allResource[i].checked = false;\n }\n this.getResourceByRole(this.roleId);\n });\n },\n getAllResourceCateList() {\n listAllCate().then(response => {\n this.allResourceCate = response.data;\n for (let i = 0; i < this.allResourceCate.length; i++) {\n this.allResourceCate[i].checked = false;\n }\n this.getAllResourceList();\n });\n },\n getResourceByCate(categoryId) {\n let cateResource = [];\n if (this.allResource == null) return null;\n for (let i = 0; i < this.allResource.length; i++) {\n let resource = this.allResource[i];\n if (resource.categoryId === categoryId) {\n cateResource.push(resource);\n }\n }\n return cateResource;\n },\n getResourceByRole(roleId){\n listResourceByRole(roleId).then(response=>{\n let allocResource = response.data;\n this.allResource.forEach(item=>{\n item.checked = this.getResourceChecked(item.id,allocResource);\n });\n this.allResourceCate.forEach(item=>{\n item.checked = this.isAllChecked(item.id);\n });\n this.$forceUpdate();\n });\n },\n getResourceChecked(resourceId,allocResource){\n if(allocResource==null||allocResource.length===0) return false;\n for(let i=0;i<allocResource.length;i++){\n if(allocResource[i].id===resourceId){\n return true;\n }\n }\n return false;\n },\n isIndeterminate(categoryId) {\n let cateResources = this.getResourceByCate(categoryId);\n if (cateResources == null) return false;\n let checkedCount = 0;\n for (let i = 0; i < cateResources.length; i++) {\n if (cateResources[i].checked === true) {\n checkedCount++;\n }\n }\n return !(checkedCount === 0 || checkedCount === cateResources.length);\n },\n isAllChecked(categoryId) {\n let cateResources = this.getResourceByCate(categoryId);\n if (cateResources == null) return false;\n let checkedCount = 0;\n for (let i = 0; i < cateResources.length; i++) {\n if (cateResources[i].checked === true) {\n checkedCount++;\n }\n }\n if(checkedCount===0){\n return false;\n }\n return checkedCount === cateResources.length;\n },\n handleSave() {\n this.$confirm('是否分配资源?', '提示', {\n confirmButtonText: '确定',\n cancelButtonText: '取消',\n type: 'warning'\n }).then(() => {\n let checkedResourceIds = new Set();\n if (this.allResource != null && this.allResource.length > 0) {\n this.allResource.forEach(item => {\n if (item.checked) {\n checkedResourceIds.add(item.id);\n }\n });\n }\n // let params = new URLSearchParams();\n // params.append(\"roleId\", this.roleId);\n // params.append(\"resourceIds\", Array.from(checkedResourceIds).join(','));\n let obj = {\n roleId:this.roleId,\n resourceIds:Array.from(checkedResourceIds).join(',')\n }\n allocResource(obj).then(response => {\n this.$message({\n message: '分配成功',\n type: 'success',\n duration: 1000\n });\n this.$router.back();\n })\n })\n },\n handleClear() {\n this.allResourceCate.forEach(item => {\n item.checked = false;\n });\n this.allResource.forEach(item => {\n item.checked = false;\n });\n this.$forceUpdate();\n },\n handleCheckAllChange(cate) {\n let cateResources = this.getResourceByCate(cate.id);\n for (let i = 0; i < cateResources.length; i++) {\n cateResources[i].checked = cate.checked;\n }\n this.$forceUpdate();\n },\n handleCheckChange(resource) {\n this.allResourceCate.forEach(item=>{\n if(item.id===resource.categoryId){\n item.checked = this.isAllChecked(resource.categoryId);\n }\n });\n this.$forceUpdate();\n }\n }\n }\n</script>\n\n<style scoped>\n .table-layout {\n padding: 20px;\n border-left: 1px solid #DCDFE6;\n border-right: 1px solid #DCDFE6;\n border-bottom: 1px solid #DCDFE6;\n }\n\n .top-line {\n border-top: 1px solid #DCDFE6;\n }\n</style>\n\n\n\n// WEBPACK FOOTER //\n// src/views/ums/role/allocResource.vue","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('el-card',{staticClass:\"form-container\",attrs:{\"shadow\":\"never\"}},[_vm._l((_vm.allResourceCate),function(cate,index){return _c('div',{key:'cate'+cate.id,class:index===0?'top-line':null},[_c('el-row',{staticClass:\"table-layout\",staticStyle:{\"background\":\"#F2F6FC\"}},[_c('el-checkbox',{attrs:{\"indeterminate\":_vm.isIndeterminate(cate.id)},on:{\"change\":function($event){_vm.handleCheckAllChange(cate)}},model:{value:(cate.checked),callback:function ($$v) {_vm.$set(cate, \"checked\", $$v)},expression:\"cate.checked\"}},[_vm._v(\"\\n \"+_vm._s(cate.name)+\"\\n \")])],1),_vm._v(\" \"),_c('el-row',{staticClass:\"table-layout\"},_vm._l((_vm.getResourceByCate(cate.id)),function(resource){return _c('el-col',{key:resource.id,staticStyle:{\"padding\":\"4px 0\"},attrs:{\"span\":8}},[_c('el-checkbox',{on:{\"change\":function($event){_vm.handleCheckChange(resource)}},model:{value:(resource.checked),callback:function ($$v) {_vm.$set(resource, \"checked\", $$v)},expression:\"resource.checked\"}},[_vm._v(\"\\n \"+_vm._s(resource.name)+\"\\n \")])],1)}))],1)}),_vm._v(\" \"),_c('div',{staticStyle:{\"margin-top\":\"20px\"},attrs:{\"align\":\"center\"}},[_c('el-button',{attrs:{\"type\":\"primary\"},on:{\"click\":function($event){_vm.handleSave()}}},[_vm._v(\"保存\")]),_vm._v(\" \"),_c('el-button',{on:{\"click\":function($event){_vm.handleClear()}}},[_vm._v(\"清空\")])],1)],2)}\nvar staticRenderFns = []\nvar esExports = { render: render, staticRenderFns: staticRenderFns }\nexport default esExports\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/vue-loader/lib/template-compiler?{\"id\":\"data-v-6764bba2\",\"hasScoped\":true,\"transformToRequire\":{\"video\":[\"src\",\"poster\"],\"source\":\"src\",\"img\":\"src\",\"image\":\"xlink:href\"},\"buble\":{\"transforms\":{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./src/views/ums/role/allocResource.vue\n// module id = null\n// module chunks = ","function injectStyle (ssrContext) {\n require(\"!!../../../../node_modules/extract-text-webpack-plugin/dist/loader.js?{\\\"omit\\\":1,\\\"remove\\\":true,\\\"publicPath\\\":\\\"../../\\\"}!vue-style-loader!css-loader?{\\\"sourceMap\\\":true}!../../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"vue\\\":true,\\\"id\\\":\\\"data-v-6764bba2\\\",\\\"scoped\\\":true,\\\"hasInlineConfig\\\":false}!../../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./allocResource.vue\")\n}\nvar normalizeComponent = require(\"!../../../../node_modules/vue-loader/lib/component-normalizer\")\n/* script */\nexport * from \"!!babel-loader!../../../../node_modules/vue-loader/lib/selector?type=script&index=0!./allocResource.vue\"\nimport __vue_script__ from \"!!babel-loader!../../../../node_modules/vue-loader/lib/selector?type=script&index=0!./allocResource.vue\"\n/* template */\nimport __vue_template__ from \"!!../../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-6764bba2\\\",\\\"hasScoped\\\":true,\\\"transformToRequire\\\":{\\\"video\\\":[\\\"src\\\",\\\"poster\\\"],\\\"source\\\":\\\"src\\\",\\\"img\\\":\\\"src\\\",\\\"image\\\":\\\"xlink:href\\\"},\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../../node_modules/vue-loader/lib/selector?type=template&index=0!./allocResource.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = \"data-v-6764bba2\"\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_template__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/views/ums/role/allocResource.vue\n// module id = null\n// module chunks = ","import request from '@/utils/request'\n\nexport function fetchList(params) {\n return request({\n url: '/resource/list',\n method: 'get',\n params: params\n })\n}\n\nexport function createResource(data) {\n return request({\n url: '/resource/create',\n method: 'post',\n data: data\n })\n}\n\nexport function updateResource(id, data) {\n return request({\n url: '/resource/update/' + id,\n method: 'post',\n data: data\n })\n}\n\nexport function deleteResource(id) {\n return request({\n url: '/resource/delete/' + id,\n method: 'post'\n })\n}\n\nexport function fetchAllResourceList() {\n return request({\n url: '/resource/listAll',\n method: 'get'\n })\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/api/resource.js"],"sourceRoot":""}
|