Blogger Information
Blog 46
fans 2
comment 0
visits 19472
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
1、element 安装。 2、后台管理系统首页搭建。 3、后台管理系统 列表页搭建。。 4、后台管理系统 添加和修改、表单搭建
P粉314265155
Original
607 people have browsed it

element 安装

  1. NPM
  2. $ npm install element-plus --save

后台管理系统首页搭建

  1. <template>
  2. <el-container class="layout" style="height: 100%">
  3. <aside style="height: 100%">
  4. <el-menu
  5. default-active="-1"
  6. class="el-menu-vertical-demo"
  7. :collapse="isCollapse"
  8. active-text-color="#ffd04b"
  9. background-color="#545c64"
  10. text-color="#fff"
  11. >
  12. <div class="logo">
  13. <router-link to="/" class="router">
  14. <img src="" alt="logo" />
  15. <h1>phpAdmin</h1>
  16. </router-link>
  17. </div>
  18. <router-link to="/">
  19. <el-menu-item index="-1">
  20. <template #title> 首页</template>
  21. </el-menu-item>
  22. </router-link>
  23. <el-menu-item index="-2">
  24. <template #title>个人中心</template>
  25. </el-menu-item>
  26. <el-sub-menu index="1">
  27. <template #title>
  28. <span>课袋鼠项目</span>
  29. </template>
  30. <router-link to="/ad">
  31. <el-menu-item index="1-1">
  32. <span>广告管理</span>
  33. </el-menu-item>
  34. </router-link>
  35. <router-link to="/course">
  36. <el-menu-item index="1-2">
  37. <span>课程管理</span>
  38. </el-menu-item>
  39. </router-link>
  40. </el-sub-menu>
  41. <el-sub-menu index="2">
  42. <template #title>
  43. <span>后台管理</span>
  44. </template>
  45. <router-link to="/admin_user">
  46. <el-menu-item index="2-1">
  47. <span>用户管理</span>
  48. </el-menu-item>
  49. </router-link>
  50. <router-link to="/course">
  51. <el-menu-item index="2-2">
  52. <span>菜单管理</span>
  53. </el-menu-item>
  54. </router-link>
  55. </el-sub-menu>
  56. </el-menu>
  57. <div class="flexible" @click="isCollapse = !isCollapse">
  58. <el-icon v-if="isCollapse" color="white" :size="40"
  59. ><ArrowRight
  60. /></el-icon>
  61. <el-icon v-else color="white" :size="40"><ArrowLeft /></el-icon>
  62. </div>
  63. </aside>
  64. <el-container>
  65. <el-header style="text-align: right; font-size: 20px">
  66. <div class="toolbar">
  67. <el-dropdown size="large" type="primary">
  68. <span
  69. >{{ name
  70. }}<el-icon style="margin-left: 8px; margin-top: 1px"
  71. ><ArrowDown /></el-icon
  72. ></span>
  73. <template #dropdown>
  74. <el-dropdown-menu>
  75. <el-dropdown-item>个人中心</el-dropdown-item>
  76. <el-dropdown-item>退出</el-dropdown-item>
  77. </el-dropdown-menu>
  78. </template>
  79. </el-dropdown>
  80. </div>
  81. </el-header>
  82. <el-main>
  83. <router-view></router-view>
  84. </el-main>
  85. </el-container>
  86. </el-container>
  87. </template>
  88. <script>
  89. import { reactive, toRefs } from "vue";
  90. export default {
  91. name: "App",
  92. setup() {
  93. // 获取左侧菜单和用户信息
  94. const state = reactive({
  95. isCollapse: false,
  96. name: "欧阳克",
  97. });
  98. return {
  99. ...toRefs(state),
  100. };
  101. },
  102. };
  103. </script>
  104. <style>
  105. a {
  106. text-decoration: none;
  107. }
  108. .layout {
  109. background-color: #f0f2f5;
  110. }
  111. .layout .el-header {
  112. position: relative;
  113. background-color: white;
  114. color: var(--el-text-color-primary);
  115. }
  116. .layout aside {
  117. color: var(--el-text-color-primary);
  118. background: #001529;
  119. }
  120. .layout .el-menu {
  121. border-right: none;
  122. }
  123. .layout .el-main {
  124. margin: 30px 10px;
  125. background-color: white;
  126. }
  127. .layout .toolbar {
  128. display: inline-flex;
  129. align-items: center;
  130. justify-content: center;
  131. height: 100%;
  132. right: 20px;
  133. }
  134. aside {
  135. position: relative;
  136. }
  137. .flexible {
  138. background-color: #002140;
  139. text-align: center;
  140. position: absolute;
  141. bottom: 0px;
  142. left: 0px;
  143. right: 0px;
  144. }
  145. .el-menu-vertical-demo:not(.el-menu--collapse) {
  146. width: 200px;
  147. min-height: 400px;
  148. }
  149. .layout aside .logo .router {
  150. display: flex;
  151. justify-content: space-evenly;
  152. align-items: center;
  153. animation-duration: 0.1s;
  154. overflow: hidden;
  155. text-decoration: none;
  156. padding-left: 1px;
  157. position: relative;
  158. left: 2px;
  159. }
  160. .layout aside .logo .router h1 {
  161. margin-left: 10px;
  162. color: aliceblue;
  163. overflow: hidden;
  164. }
  165. .layout aside .logo .router img {
  166. padding-left: 5px;
  167. width: 48px;
  168. height: 48px;
  169. }
  170. </style>

后台管理系统 列表页搭建

  1. <template>
  2. <el-table :data="tableData" border style="width: 100%" size="large">
  3. <el-table-column prop="date" label="ID" width="180" />
  4. <el-table-column prop="name" label="课程名称" width="180" />
  5. <el-table-column prop="address" label="课程图片" />
  6. <el-table-column prop="ylprice" label="课程原价格" />
  7. <el-table-column prop="xzprice" label="课程现价格" />
  8. </el-table>
  9. </template>
  10. <script setup>
  11. const tableData = [
  12. {
  13. date: '1',
  14. name: '小狗',
  15. address: 'http://www.baidu.com',
  16. ylprice:5000,
  17. xzprice:6000
  18. },
  19. {
  20. date: '2',
  21. name: '小猫',
  22. address: 'http://www.baidu.com',
  23. ylprice:5000,
  24. xzprice:6000
  25. },
  26. {
  27. date: '3',
  28. name: '小狗牛',
  29. address: 'http://www.baidu.com',
  30. ylprice:5000,
  31. xzprice:6000
  32. },
  33. ]
  34. </script>

后台管理系统 添加和修改、表单搭建

  1. <template>
  2. <div style="margin: 0 0 20px 10px">
  3. <!-- 增加点击事件,打开表单 -->
  4. <el-button type="success" size="large" @click="add(0)">添加</el-button>
  5. </div>
  6. <el-table :data="tableData" border style="width: 100%" size="large">
  7. <el-table-column prop="uid" label="ID" />
  8. <el-table-column prop="account" label="用户账户" />
  9. <el-table-column prop="name" label="姓名" />
  10. <el-table-column prop="phone" label="手机号" />
  11. <el-table-column prop="status" label="状态" />
  12. <el-table-column prop="add_time" label="添加时间" />
  13. <el-table-column prop="last_time" label="最后登录时间" />
  14. <el-table-column label="操作">
  15. <!-- default 这个是默认的插槽 -->
  16. <!-- scope 是传值给这个插槽,这个值是什么呢?就是当前这条数据 -->
  17. <!-- 当数据有多条时,放el-table 这个标签里,它会自动循环,每次循环都会把当前的循环值给到el-table-column -->
  18. <template #default="scope">
  19. <!-- @click="handleEdit(scope.$index, scope.row)" -->
  20. <!-- <el-button size="small" type="primary" @click ="add(1)">修改1</el-button> -->
  21. <!-- <el-button size="small" type="primary" @click="add(scope.$index, scope.row)>修改2</el-button> -->
  22. <el-button size="small" type="primary" @click="add(scope.row)">修改</el-button>
  23. <el-button size="small" type="danger" >删除</el-button>
  24. </template>
  25. </el-table-column>
  26. </el-table>
  27. <!-- 增加 弹框 默认不显示 点击添加事件显示 -->
  28. <el-dialog
  29. v-model="xsfrom.is_from"
  30. :title="xsfrom.title"
  31. width="70%">
  32. <!-- 添加 页面表单 填写数据双向绑定 与添加按钮关联,判断是否显示 -->
  33. <el-form :model="fromData" label-width="120px" size="large" >
  34. <el-form-item label="账户">
  35. <!-- 填写数据双向绑定 -->
  36. <el-input v-model="fromData.account" />
  37. </el-form-item>
  38. <el-form-item label="姓名">
  39. <el-input v-model="fromData.name" />
  40. </el-form-item>
  41. <el-form-item label="手机号">
  42. <el-input v-model="fromData.phone" />
  43. </el-form-item>
  44. <el-form-item label="入职时间">
  45. <el-date-picker
  46. v-model="fromData.add_time"
  47. type="date"
  48. placeholder="请选择日期"
  49. :size="size"
  50. />
  51. </el-form-item>
  52. <el-button type="success" size="large" @click="fun">确定</el-button>
  53. </el-form>
  54. </el-dialog>
  55. </template>
  56. <script setup>
  57. import { reactive } from 'vue'
  58. const xsfrom= reactive({
  59. is_from : false,
  60. title : "添加",
  61. }) ;
  62. const fromData= reactive( {
  63. account :'',
  64. name : '',
  65. phone : '',
  66. add_time : '',
  67. });
  68. const tableData = [
  69. {
  70. uid: "1",
  71. account:'xiaogou',
  72. name: '小狗',
  73. phone:'18963300000',
  74. status: '在职',
  75. add_time: '2022年09月1日',
  76. last_time: '2022年09月2日',
  77. },
  78. ];
  79. const fun = () =>{
  80. console.log(fromData);
  81. xsfrom.is_from = false;
  82. };
  83. // const add = (e,ee) =>{
  84. const add = (e) =>{
  85. xsfrom.is_from = true;
  86. console.log(e);
  87. // console.log(ee);
  88. if (e !=0){
  89. xsfrom.title ="修改";
  90. fromData.account = e.account;
  91. fromData.phone = e.phone;
  92. fromData.name = e.name;
  93. fromData.status = e.status;
  94. fromData.add_time = e.add_time;
  95. }else{
  96. xsfrom.title ="添加";
  97. fromData.account = '';
  98. fromData.phone ='';
  99. fromData.name = '';
  100. }
  101. };
  102. </script>
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!