You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
7.4 KiB
1 lines
7.4 KiB
{"ast":null,"code":"import { createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, createVNode as _createVNode, withCtx as _withCtx, resolveDirective as _resolveDirective, openBlock as _openBlock, createBlock as _createBlock, withDirectives as _withDirectives, createElementBlock as _createElementBlock } from \"vue\";\nconst _hoisted_1 = {\n class: \"user-management\"\n};\nexport function render(_ctx, _cache, $props, $setup, $data, $options) {\n const _component_el_table_column = _resolveComponent(\"el-table-column\");\n const _component_el_option = _resolveComponent(\"el-option\");\n const _component_el_select = _resolveComponent(\"el-select\");\n const _component_el_table = _resolveComponent(\"el-table\");\n const _component_el_card = _resolveComponent(\"el-card\");\n const _directive_loading = _resolveDirective(\"loading\");\n return _openBlock(), _createElementBlock(\"div\", _hoisted_1, [_createVNode(_component_el_card, null, {\n header: _withCtx(() => _cache[0] || (_cache[0] = [_createElementVNode(\"div\", {\n class: \"card-header\"\n }, [_createElementVNode(\"span\", null, \"用户管理\")], -1 /* HOISTED */)])),\n default: _withCtx(() => [_withDirectives((_openBlock(), _createBlock(_component_el_table, {\n data: $setup.userList,\n style: {\n \"width\": \"100%\"\n }\n }, {\n default: _withCtx(() => [_createVNode(_component_el_table_column, {\n prop: \"id\",\n label: \"用户ID\",\n width: \"100\"\n }), _createVNode(_component_el_table_column, {\n prop: \"username\",\n label: \"用户名\"\n }), _createVNode(_component_el_table_column, {\n prop: \"email\",\n label: \"邮箱\"\n }), _createVNode(_component_el_table_column, {\n prop: \"role\",\n label: \"角色\"\n }, {\n default: _withCtx(({\n row\n }) => [_createVNode(_component_el_select, {\n modelValue: row.role,\n \"onUpdate:modelValue\": $event => row.role = $event,\n onChange: $event => $setup.handleRoleChange(row)\n }, {\n default: _withCtx(() => [_createVNode(_component_el_option, {\n label: \"普通用户\",\n value: \"ROLE_USER\"\n }), _createVNode(_component_el_option, {\n label: \"仓库管理员\",\n value: \"ROLE_WAREHOUSE_ADMIN\"\n }), _createVNode(_component_el_option, {\n label: \"物流管理员\",\n value: \"ROLE_LOGISTICS_ADMIN\"\n }), _createVNode(_component_el_option, {\n label: \"系统管理员\",\n value: \"ROLE_ADMIN\"\n })]),\n _: 2 /* DYNAMIC */\n }, 1032 /* PROPS, DYNAMIC_SLOTS */, [\"modelValue\", \"onUpdate:modelValue\", \"onChange\"])]),\n _: 1 /* STABLE */\n }), _createVNode(_component_el_table_column, {\n prop: \"createTime\",\n label: \"创建时间\"\n })]),\n _: 1 /* STABLE */\n }, 8 /* PROPS */, [\"data\"])), [[_directive_loading, $setup.loading]])]),\n _: 1 /* STABLE */\n })]);\n}","map":{"version":3,"names":["class","_createElementBlock","_hoisted_1","_createVNode","_component_el_card","header","_withCtx","_cache","_createElementVNode","default","_createBlock","_component_el_table","data","$setup","userList","style","_component_el_table_column","prop","label","width","row","_component_el_select","modelValue","role","$event","onChange","handleRoleChange","_component_el_option","value","_","loading"],"sources":["D:\\language\\VScode\\Front-end logistics\\src\\views\\admin\\UserManagement.vue"],"sourcesContent":["<template>\r\n <div class=\"user-management\">\r\n <el-card>\r\n <template #header>\r\n <div class=\"card-header\">\r\n <span>用户管理</span>\r\n </div>\r\n </template>\r\n \r\n <el-table\r\n v-loading=\"loading\"\r\n :data=\"userList\"\r\n style=\"width: 100%\"\r\n >\r\n <el-table-column prop=\"id\" label=\"用户ID\" width=\"100\" />\r\n <el-table-column prop=\"username\" label=\"用户名\" />\r\n <el-table-column prop=\"email\" label=\"邮箱\" />\r\n <el-table-column prop=\"role\" label=\"角色\">\r\n <template #default=\"{ row }\">\r\n <el-select \r\n v-model=\"row.role\" \r\n @change=\"handleRoleChange(row)\"\r\n >\r\n <el-option label=\"普通用户\" value=\"ROLE_USER\" />\r\n <el-option label=\"仓库管理员\" value=\"ROLE_WAREHOUSE_ADMIN\" />\r\n <el-option label=\"物流管理员\" value=\"ROLE_LOGISTICS_ADMIN\" />\r\n <el-option label=\"系统管理员\" value=\"ROLE_ADMIN\" />\r\n </el-select>\r\n </template>\r\n </el-table-column>\r\n <el-table-column prop=\"createTime\" label=\"创建时间\" />\r\n </el-table>\r\n </el-card>\r\n </div>\r\n</template>\r\n\r\n<script setup>\r\nimport { ref } from 'vue'\r\nimport { ElMessage, ElMessageBox } from 'element-plus'\r\nimport { updateUserRole } from '@/api/auth'\r\n\r\nconst loading = ref(false)\r\nconst userList = ref([])\r\n\r\nconst handleRoleChange = async (user) => {\r\n try {\r\n await ElMessageBox.confirm(\r\n `确定要将用户 ${user.username} 的角色更改为 ${user.role} 吗?`,\r\n '提示',\r\n {\r\n type: 'warning',\r\n confirmButtonText: '确定',\r\n cancelButtonText: '取消'\r\n }\r\n )\r\n \r\n const res = await updateUserRole(user.id, user.role)\r\n if (res.code === 200) {\r\n ElMessage.success('角色更新成功')\r\n }\r\n } catch (error) {\r\n if (error !== 'cancel') {\r\n console.error('更新角色失败:', error)\r\n ElMessage.error(error.message || '更新角色失败')\r\n // 恢复原来的角色\r\n user.role = user.originalRole\r\n }\r\n }\r\n}\r\n</script>\r\n\r\n<style scoped>\r\n.user-management {\r\n padding: 20px;\r\n}\r\n\r\n.card-header {\r\n display: flex;\r\n justify-content: space-between;\r\n align-items: center;\r\n}\r\n</style> "],"mappings":";;EACOA,KAAK,EAAC;AAAiB;;;;;;;;uBAA5BC,mBAAA,CAgCM,OAhCNC,UAgCM,GA/BJC,YAAA,CA8BUC,kBAAA;IA7BGC,MAAM,EAAAC,QAAA,CACf,MAEMC,MAAA,QAAAA,MAAA,OAFNC,mBAAA,CAEM;MAFDR,KAAK,EAAC;IAAa,IACtBQ,mBAAA,CAAiB,cAAX,MAAI,E;IALpBC,OAAA,EAAAH,QAAA,CASM,MAsBW,C,+BAtBXI,YAAA,CAsBWC,mBAAA;MApBRC,IAAI,EAAEC,MAAA,CAAAC,QAAQ;MACfC,KAAmB,EAAnB;QAAA;MAAA;;MAZRN,OAAA,EAAAH,QAAA,CAcQ,MAAsD,CAAtDH,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