Order.vue 6.9 KB

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