index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索工作栏 -->
  4. <!-- TODO: inline 看看是不是需要; v-show= 那块逻辑还是要的 -->
  5. <el-row :gutter="20">
  6. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  7. <el-col :span="6" :xs="24">
  8. <el-form-item label="搜索方式" prop="searchValue">
  9. <el-input v-model="queryParams.searchValue" style="width: 240px">
  10. <el-select v-model="queryParams.searchType" slot="prepend" style="width: 100px">
  11. <el-option v-for="dict in searchTypes" :key="dict.value" :label="dict.label" :value="dict.value"/>
  12. </el-select>
  13. </el-input>
  14. </el-form-item>
  15. </el-col>
  16. <el-col :span="6" :xs="24">
  17. <el-form-item label="订单类型" prop="type">
  18. <el-select v-model="queryParams.type" clearable style="width: 240px">
  19. <el-option v-for="dict in this.getDictDatas(DICT_TYPE.TRADE_ORDER_TYPE)"
  20. :key="dict.value" :label="dict.label" :value="dict.value"/>
  21. </el-select>
  22. </el-form-item>
  23. </el-col>
  24. <el-col :span="6" :xs="24">
  25. <el-form-item label="订单状态" prop="status">
  26. <el-select v-model="queryParams.status" clearable style="width: 240px">
  27. <el-option v-for="dict in this.getDictDatas(DICT_TYPE.TRADE_ORDER_STATUS)"
  28. :key="dict.value" :label="dict.label" :value="dict.value"/>
  29. </el-select>
  30. </el-form-item>
  31. </el-col>
  32. <el-col :span="6" :xs="24">
  33. <el-form-item label="订单来源" prop="terminal">
  34. <el-select v-model="queryParams.terminal" clearable style="width: 240px">
  35. <el-option v-for="dict in this.getDictDatas(DICT_TYPE.TERMINAL)"
  36. :key="dict.value" :label="dict.label" :value="dict.value"/>
  37. </el-select>
  38. </el-form-item>
  39. </el-col>
  40. <el-col :span="6" :xs="24">
  41. <el-form-item label="支付方式" prop="payChannelCode">
  42. <el-select v-model="queryParams.payChannelCode" clearable style="width: 240px">
  43. <el-option v-for="dict in this.getDictDatas(DICT_TYPE.PAY_CHANNEL_CODE_TYPE)"
  44. :key="dict.value" :label="dict.label" :value="dict.value"/>
  45. </el-select>
  46. </el-form-item>
  47. </el-col>
  48. <el-col :span="6" :xs="24">
  49. <el-form-item label="下单时间" prop="createTime">
  50. <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
  51. range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
  52. :picker-options="datePickerOptions" :default-time="['00:00:00', '23:59:59']" />
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span="6" :xs="24" style="line-height: 32px">
  56. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  57. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  58. </el-col>
  59. </el-form>
  60. </el-row>
  61. <!-- 操作工具栏 -->
  62. <el-row :gutter="10" class="mb8">
  63. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  64. </el-row>
  65. <!-- tab切换 -->
  66. <!-- TODO @小程:看看能不能往上挪 -40px,和【隐藏搜索】【刷新】对齐 -->
  67. <el-tabs v-model="activeTab" type="card" @tab-click="tabClick">
  68. <el-tab-pane v-for="tab in statusTabs" :key="tab.value" :label="tab.label" :name="tab.value">
  69. <!-- 列表 -->
  70. <el-table v-loading="loading" :data="list" :show-header="false" class="order-table">
  71. <el-table-column>
  72. <template slot-scope="{ row }">
  73. <el-row type="flex" align="middle">
  74. <el-col :span="5">
  75. 订单号:{{row.no}}
  76. <el-popover title="支付单号:" :content="row.payOrderId + ''" placement="right" width="200" trigger="click">
  77. <el-button slot="reference" type="text">更多</el-button>
  78. </el-popover>
  79. </el-col>
  80. <el-col :span="5">下单时间:{{ parseTime(row.createTime) }}</el-col>
  81. <el-col :span="4">订单来源:
  82. <dict-tag :type="DICT_TYPE.TERMINAL" :value="row.terminal" />
  83. </el-col>
  84. <el-col :span="4">支付方式:
  85. <dict-tag v-if="row.payChannelCode" :type="DICT_TYPE.PAY_CHANNEL_CODE_TYPE" :value="row.payChannelCode" />
  86. <span v-else>未支付</span>
  87. </el-col>
  88. <el-col :span="6" align="right">
  89. <el-button type="text" @click="goToDetail(row)">详情</el-button>
  90. </el-col>
  91. </el-row>
  92. <!-- 订单下的商品 -->
  93. <el-table :data="row.items" border :show-header="true">
  94. <el-table-column label="商品" prop="goods" header-align="center" width="auto" min-width="300">
  95. <template slot-scope="{ row, $index }">
  96. <div class="goods-info">
  97. <img :src="row.picUrl"/>
  98. <span class="ellipsis-2" :title="row.spuName">{{row.spuName}}</span>
  99. <!-- TODO @小程:下面是商品属性,想当度一行,放在商品名下面 -->
  100. <el-tag size="medium" v-for="property in row.properties">{{property.propertyName}}:{{property.valueName}}</el-tag>
  101. </div>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="单价(元)/数量" prop="fee" align="center" width="115">
  105. <template slot-scope="{ row }">
  106. <div>¥{{ (row.originalUnitPrice / 100.0).toFixed(2) }}</div>
  107. <div>{{row.count}} 件</div>
  108. </template>
  109. </el-table-column>
  110. <!-- TODO @小程:这里应该是一个订单下,多个商品,只展示订单上的总金额,就是 order.payPrice -->
  111. <el-table-column label="实付金额(元)" prop="amount" align="center" width="100"/>
  112. <!-- TODO @小程:这里应该是一个订单下,多个商品,只展示订单上的收件信息;使用 order.receiverXXX 开头的字段 -->
  113. <el-table-column label="买家/收货人" prop="buyer" header-align="center" width="auto" min-width="300">
  114. <template slot-scope="{ row }">
  115. <!-- TODO @芋艿:以后增加一个会员详情界面 -->
  116. <div>{{row.buyer}}</div>
  117. <div>{{row.receiver}}{{row.tel}}</div>
  118. <div class="ellipsis-2" :title="row.address">{{row.address}}</div>
  119. </template>
  120. </el-table-column>
  121. <!-- TODO @小程:这里应该是一个订单下,多个商品,交易状态是统一的;使用 order.status 字段 -->
  122. <el-table-column label="交易状态" prop="status" align="center" width="100"/>
  123. </el-table>
  124. </template>
  125. </el-table-column>
  126. </el-table>
  127. </el-tab-pane>
  128. </el-tabs>
  129. <!-- 分页组件 -->
  130. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  131. @pagination="getList"/>
  132. </div>
  133. </template>
  134. <script>
  135. import { getOrderPage } from "@/api/mall/trade/order";
  136. import { datePickerOptions } from "@/utils/constants";
  137. import { DICT_TYPE, getDictDatas } from "@/utils/dict";
  138. export default {
  139. name: "index",
  140. data () {
  141. return {
  142. // 遮罩层
  143. loading: true,
  144. // 导出遮罩层
  145. exportLoading: false,
  146. // 显示搜索条件
  147. showSearch: true,
  148. // 总条数
  149. total: 0,
  150. // 交易售后列表
  151. list: [],
  152. queryParams: {
  153. pageNo: 1,
  154. pageSize: 10,
  155. searchType: 'no',
  156. searchValue: '',
  157. type: null,
  158. status: null,
  159. payChannelCode: null,
  160. createTime: [],
  161. },
  162. // Tab 筛选
  163. activeTab: 'all',
  164. statusTabs: [{
  165. label: '全部',
  166. value: 'all'
  167. }],
  168. // 静态变量
  169. datePickerOptions: datePickerOptions,
  170. searchTypes: [
  171. { label: '订单号', value: 'no' },
  172. { label: '会员编号', value: 'userId' },
  173. { label: '会员昵称', value: 'userNickname' },
  174. { label: '会员手机号', value: 'userMobile' },
  175. { label: '收货人姓名', value: 'receiverName' },
  176. { label: '收货人手机号码', value: 'receiverMobile' },
  177. ],
  178. }
  179. },
  180. created() {
  181. this.getList();
  182. // 设置 statuses 过滤
  183. for (const dict of getDictDatas(DICT_TYPE.TRADE_ORDER_STATUS)) {
  184. this.statusTabs.push({
  185. label: dict.label,
  186. value: dict.value
  187. })
  188. }
  189. },
  190. methods: {
  191. /** 查询列表 */
  192. getList() {
  193. this.loading = true;
  194. // 执行查询
  195. getOrderPage({
  196. ...this.queryParams,
  197. searchType: undefined,
  198. searchValue: undefined,
  199. no: this.queryParams.searchType === 'no' ? this.queryParams.searchValue : undefined,
  200. userId: this.queryParams.searchType === 'userId' ? this.queryParams.searchValue : undefined,
  201. userNickname: this.queryParams.searchType === 'userNickname' ? this.queryParams.searchValue : undefined,
  202. userMobile: this.queryParams.searchType === 'userMobile' ? this.queryParams.searchValue : undefined,
  203. receiverName: this.queryParams.searchType === 'receiverName' ? this.queryParams.searchValue : undefined,
  204. receiverMobile: this.queryParams.searchType === 'receiverMobile' ? this.queryParams.searchValue : undefined,
  205. }).then(response => {
  206. this.list = response.data.list;
  207. this.total = response.data.total;
  208. this.loading = false;
  209. });
  210. },
  211. /** 搜索按钮操作 */
  212. handleQuery() {
  213. this.queryParams.pageNo = 1;
  214. this.activeTab = this.queryParams.status ? this.queryParams.status : 'all'; // 处理 tab
  215. this.getList();
  216. },
  217. /** 重置按钮操作 */
  218. resetQuery() {
  219. this.resetForm("queryForm");
  220. this.handleQuery();
  221. },
  222. /** tab 切换 */
  223. tabClick(tab) {
  224. this.queryParams.status = tab.name === 'all' ? undefined : tab.name;
  225. this.getList();
  226. },
  227. goToDetail (row) {
  228. this.$router.push({ path: '/mall/trade/order/detail', query: { id: row.id }})
  229. }
  230. }
  231. }
  232. </script>
  233. <style lang="scss" scoped>
  234. ::v-deep .order-table{
  235. border-bottom: none;
  236. &::before{
  237. height: 0;
  238. }
  239. .el-table__row{
  240. .el-table__cell{
  241. border-bottom: none;
  242. .cell{
  243. .el-table {
  244. .el-table__row{
  245. >.el-table__cell{
  246. .goods-info{
  247. display: flex;
  248. img{
  249. margin-right: 10px;
  250. width: 60px;
  251. height: 60px;
  252. border: 1px solid #e2e2e2;
  253. }
  254. }
  255. .ellipsis-2{
  256. display: -webkit-box;
  257. overflow: hidden;
  258. text-overflow: ellipsis;
  259. white-space: normal;
  260. -webkit-line-clamp: 2; /* 要显示的行数 */
  261. -webkit-box-orient: vertical;
  262. word-break: break-all;
  263. line-height: 22px !important;
  264. max-height: 44px !important;
  265. }
  266. }
  267. }
  268. }
  269. }
  270. }
  271. }
  272. }
  273. </style>