电商后台管理系统订单列表模块

朱雀 2021-07-24 16:58 1248阅读 0赞

一 代码

1 新建 Order.vue 组件

  1. <template>
  2. <div>
  3. <!-- 面包屑导航区 -->
  4. <el-breadcrumb separator-class="el-icon-arrow-right">
  5. <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
  6. <el-breadcrumb-item>订单管理</el-breadcrumb-item>
  7. <el-breadcrumb-item>订单列表</el-breadcrumb-item>
  8. </el-breadcrumb>
  9. <!-- 卡片视图区 -->
  10. <el-card>
  11. <el-row>
  12. <el-col :span="8">
  13. <el-input placeholder="请输入内容">
  14. <el-button slot="append" icon="el-icon-search"></el-button>
  15. </el-input>
  16. </el-col>
  17. </el-row>
  18. <!-- 订单列表数据-->
  19. <el-table :data="orderList" border stripe>
  20. <el-table-column type="index"></el-table-column>
  21. <el-table-column label="订单编号" prop="order_number"></el-table-column>
  22. <el-table-column label="订单价格" prop="order_price"></el-table-column>
  23. <el-table-column label="是否付款" prop="pay_status">
  24. <template slot-scope="scope">
  25. <el-tag type="success" v-if="scope.row.pay_status === '1'">已付款</el-tag>
  26. <el-tag type="danger" v-else>未付款</el-tag>
  27. </template>
  28. </el-table-column>
  29. <el-table-column label="是否发货" prop="is_send"></el-table-column>
  30. <el-table-column label="下单时间" prop="create_time">
  31. <template slot-scope="scope">
  32. {
  33. {scope.row.create_time|dataFormat}}
  34. </template>
  35. </el-table-column>
  36. <el-table-column label="操作">
  37. <template slot-scope="scope">
  38. <el-button type="primary" icon="el-icon-edit" size="mini" @click="showBox"></el-button>
  39. <el-button type="success" icon="el-icon-location" size="mini"
  40. @click="showProgressBox"></el-button>
  41. </template>
  42. </el-table-column>
  43. </el-table>
  44. <!-- 分页区 -->
  45. <el-pagination
  46. @size-change="handleSizeChange"
  47. @current-change="handleCurrentChange"
  48. :current-page="queryInfo.pagenum"
  49. :page-sizes="[5, 10, 15]"
  50. :page-size="queryInfo.pagesize"
  51. layout="total, sizes, prev, pager, next, jumper"
  52. :total="total">
  53. </el-pagination>
  54. </el-card>
  55. <!-- 修改地址对话框-->
  56. <el-dialog
  57. title="修改地址"
  58. :visible.sync="addressVisible"
  59. width="50%"
  60. @close="addressDialogClosed"
  61. >
  62. <el-form :model="addressForm" :rules="addressFormRules" ref="addressFormRef" label-width="100px">
  63. <el-form-item label="省市区/县" prop="address1">
  64. <el-cascader :options="cityData" v-model="addressForm.address1"></el-cascader>
  65. </el-form-item>
  66. <el-form-item label="详细地址" prop="address2">
  67. <el-input v-model="addressForm.address2"></el-input>
  68. </el-form-item>
  69. </el-form>
  70. <span slot="footer" class="dialog-footer">
  71. <el-button @click="addressVisible = false">取 消</el-button>
  72. <el-button type="primary" @click="addressVisible = false">确 定</el-button>
  73. </span>
  74. </el-dialog>
  75. <!-- 物流进度对话框-->
  76. <el-dialog
  77. title="物流进度"
  78. :visible.sync="progressVisible"
  79. width="50%"
  80. >
  81. <!-- 时间线 -->
  82. <el-timeline>
  83. <el-timeline-item
  84. v-for="(activity, index) in this.progressInfo"
  85. :key="index"
  86. :timestamp="activity.time">
  87. {
  88. {activity.context}}
  89. </el-timeline-item>
  90. </el-timeline>
  91. </el-dialog>
  92. </div>
  93. </template>
  94. <script>
  95. /* 导入城市数据 */
  96. import cityData from './citydata'
  97. export default {
  98. name: "Order",
  99. data() {
  100. return {
  101. queryInfo: {
  102. query: '',
  103. pagenum: 1,
  104. pagesize: 10
  105. },
  106. total: 0,
  107. orderList: [],
  108. addressVisible: false,
  109. addressForm: {
  110. address1: [],
  111. address2: ''
  112. },
  113. addressFormRules: {
  114. address1: [
  115. {required: true, message: '请选择省市区县', trigger: 'blur'},
  116. ],
  117. address2: [
  118. {required: true, message: '请填写详细地址', trigger: 'blur'},
  119. ]
  120. },
  121. cityData: cityData,
  122. progressVisible:false,
  123. progressInfo:[]
  124. }
  125. },
  126. created() {
  127. this.getOrderList()
  128. },
  129. methods: {
  130. async getOrderList() {
  131. const {data: res} = await this.$http.get('orders', {params: this.queryInfo})
  132. if (res.meta.status !== 200) {
  133. return this.$message.error('获取订单列表失败')
  134. }
  135. this.total = res.data.total
  136. this.orderList = res.data.goods
  137. },
  138. handleSizeChange(newSize) {
  139. this.queryInfo.pagesize = newSize
  140. this.getOrderList()
  141. },
  142. handleCurrentChange(newPage) {
  143. this.queryInfo.pagenum = newPage
  144. this.getOrderList()
  145. },
  146. // 展示修改地址对话框
  147. showBox() {
  148. this.addressVisible = true
  149. },
  150. addressDialogClosed() {
  151. this.$refs.addressFormRef.resetFields()
  152. },
  153. // 物流进度展示
  154. async showProgressBox() {
  155. const {data: res} = await this.$http.get('/kuaidi/1106975712662')
  156. if (res.meta.status !== 200) {
  157. return this.$message.error("获取物流信息失败!")
  158. }
  159. this.progressInfo = res.data
  160. this.progressVisible = true
  161. console.log(this.progressInfo)
  162. }
  163. }
  164. }
  165. </script>
  166. <style scoped>
  167. .el-cascader {
  168. width: 100%;
  169. }
  170. </style>

2 修改路由 index.js

  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. // 导入登录组件
  4. import Login from "../components/Login";
  5. // 导入Home 组件
  6. import Home from "../components/Home";
  7. // 导入Welcome 组件
  8. import Welcome from "../components/Welcome";
  9. // 导入 Users 组件
  10. import Users from "../components/user/Users";
  11. // 导入权限列表 组件
  12. import Rights from "../components/power/Rights";
  13. // 导入角色列表 组件
  14. import Roles from "../components/power/Roles";
  15. // 导入商品分类 组件
  16. import Cate from "../components/goods/Cate";
  17. // 导入商品分类参数 组件
  18. import Params from "../components/goods/Params";
  19. // 导入商品列表组件
  20. import GoodsList from "../components/goods/List";
  21. // 导入增加商品名称组件
  22. import Add from "../components/goods/Add";
  23. // 导入订单组件
  24. import Order from "../components/order/Order";
  25. import {renderThumbStyle} from "element-ui/packages/scrollbar/src/util";
  26. Vue.use(VueRouter)
  27. const routes = [
  28. // 路由重定向,当访问/,就会重定向到/login
  29. {
  30. path: '/',
  31. redirect: '/login'
  32. },
  33. // 定义登录路由规则
  34. {
  35. path: '/login',
  36. component: Login
  37. },
  38. // 定义Home的路由规则
  39. {
  40. path: '/home',
  41. component: Home,
  42. redirect: '/welcome',
  43. children: [
  44. {
  45. path: '/welcome',
  46. component: Welcome
  47. },
  48. /* 用户管理 */
  49. {
  50. path: '/users',
  51. component: Users
  52. },
  53. /* 权限管理 */
  54. {
  55. path: '/rights',
  56. component: Rights
  57. },
  58. /* 角色管理 */
  59. {
  60. path: '/roles',
  61. component: Roles
  62. },
  63. /* 商品分类 */
  64. {
  65. path: '/categories',
  66. component: Cate
  67. },
  68. /* 商品分类参数 */
  69. {
  70. path: '/params',
  71. component: Params
  72. },
  73. /* 商品列表 */
  74. {
  75. path: '/goods',
  76. component: GoodsList
  77. },
  78. /* 增加商品 */
  79. {
  80. path: '/goods/add',
  81. component: Add
  82. },
  83. /* 订单 */
  84. {
  85. path: '/orders',
  86. component: Order
  87. },
  88. ]
  89. }
  90. ]
  91. const router = new VueRouter({
  92. routes
  93. })
  94. // 挂载路由导航守卫
  95. // to 将要访问的路径
  96. // from 代表从哪个路径跳转而来
  97. // next 是个函数,表示放行 next() 放行 next('/login') 强制跳转
  98. router.beforeEach((to, from, next) => {
  99. // 如果用户访问的登录页,直接放行
  100. if (to.path === '/login') return next();
  101. // 从 sessionStorage 中获取到保存的 token 值
  102. const tokenstr = window.sessionStorage.getItem('token')
  103. // 没有 token,强制跳转到登录页
  104. if (!tokenstr) return next('/login')
  105. next()
  106. })
  107. export default router

3 修改 element.js

  1. import Vue from 'vue'
  2. // 按需分配各个组件
  3. import {
  4. Button,
  5. Form,
  6. FormItem,
  7. Input,
  8. Message,
  9. Container,
  10. Header,
  11. Aside,
  12. Main,
  13. Menu,
  14. Submenu,
  15. MenuItem,
  16. Breadcrumb,
  17. BreadcrumbItem,
  18. Card,
  19. Row,
  20. Col,
  21. Table,
  22. TableColumn,
  23. Switch,
  24. Tooltip,
  25. Pagination,
  26. Dialog,
  27. MessageBox,
  28. Tag,
  29. Tree,
  30. Select,
  31. Option,
  32. Cascader,
  33. Alert,
  34. Tabs,
  35. TabPane,
  36. Steps,
  37. Step,
  38. CheckboxGroup,
  39. Checkbox,
  40. Upload,
  41. Timeline,
  42. TimelineItem
  43. } from 'element-ui'
  44. Vue.use(Button)
  45. Vue.use(Form)
  46. Vue.use(FormItem)
  47. Vue.use(Input)
  48. Vue.use(Container)
  49. Vue.use(Header)
  50. Vue.use(Aside)
  51. Vue.use(Main)
  52. Vue.use(Menu)
  53. Vue.use(Submenu)
  54. Vue.use(MenuItem)
  55. Vue.use(Breadcrumb)
  56. Vue.use(BreadcrumbItem)
  57. Vue.use(Card)
  58. Vue.use(Row)
  59. Vue.use(Col)
  60. Vue.use(Table)
  61. Vue.use(TableColumn)
  62. Vue.use(Switch)
  63. Vue.use(Tooltip)
  64. Vue.use(Pagination)
  65. Vue.use(Dialog)
  66. Vue.use(Tag)
  67. Vue.use(Tree)
  68. Vue.use(Select)
  69. Vue.use(Option)
  70. Vue.use(Cascader)
  71. Vue.use(Alert)
  72. Vue.use(Tabs)
  73. Vue.use(TabPane)
  74. Vue.use(Step)
  75. Vue.use(Steps)
  76. Vue.use(CheckboxGroup)
  77. Vue.use(Checkbox)
  78. Vue.use(Upload)
  79. Vue.use(Timeline)
  80. Vue.use(TimelineItem)
  81. // 这里和其他组件不一样,需要通过 prototype 全局挂载 Message
  82. Vue.prototype.$message = Message
  83. Vue.prototype.$confirm = MessageBox.confirm

二 效果

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2NoZW5ncWl1bWluZw_size_16_color_FFFFFF_t_70

发表评论

表情:
评论列表 (有 0 条评论,1248人围观)

还没有评论,来说两句吧...

相关阅读