index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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" :key="property.propertyId">
  101. {{property.propertyName}}:{{property.valueName}}</el-tag>
  102. </div>
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="单价(元)/数量" prop="fee" align="center" width="115">
  106. <template slot-scope="{ row }">
  107. <div>¥{{ (row.originalUnitPrice / 100.0).toFixed(2) }}</div>
  108. <div>{{row.count}} 件</div>
  109. </template>
  110. </el-table-column>
  111. <!-- TODO @小程:这里应该是一个订单下,多个商品,只展示订单上的总金额,就是 order.payPrice -->
  112. <el-table-column label="实付金额(元)" prop="amount" align="center" width="100"/>
  113. <!-- TODO @小程:这里应该是一个订单下,多个商品,只展示订单上的收件信息;使用 order.receiverXXX 开头的字段 -->
  114. <el-table-column label="买家/收货人" prop="buyer" header-align="center" width="auto" min-width="300">
  115. <template slot-scope="{ row }">
  116. <!-- TODO @芋艿:以后增加一个会员详情界面 -->
  117. <div>{{row.buyer}}</div>
  118. <div>{{row.receiver}}{{row.tel}}</div>
  119. <div class="ellipsis-2" :title="row.address">{{row.address}}</div>
  120. </template>
  121. </el-table-column>
  122. <!-- TODO @小程:这里应该是一个订单下,多个商品,交易状态是统一的;使用 order.status 字段 -->
  123. <el-table-column label="交易状态" prop="status" align="center" width="100"/>
  124. </el-table>
  125. </template>
  126. </el-table-column>
  127. </el-table>
  128. </el-tab-pane>
  129. </el-tabs>
  130. <!-- 分页组件 -->
  131. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  132. @pagination="getList"/>
  133. </div>
  134. </template>
  135. <script>
  136. import { getOrderPage } from "@/api/mall/trade/order";
  137. import { datePickerOptions } from "@/utils/constants";
  138. import { DICT_TYPE, getDictDatas } from "@/utils/dict";
  139. export default {
  140. name: "index",
  141. data () {
  142. return {
  143. // 遮罩层
  144. loading: true,
  145. // 导出遮罩层
  146. exportLoading: false,
  147. // 显示搜索条件
  148. showSearch: true,
  149. // 总条数
  150. total: 0,
  151. // 交易售后列表
  152. list: [],
  153. queryParams: {
  154. pageNo: 1,
  155. pageSize: 10,
  156. searchType: 'no',
  157. searchValue: '',
  158. type: null,
  159. status: null,
  160. payChannelCode: null,
  161. createTime: [],
  162. },
  163. // Tab 筛选
  164. activeTab: 'all',
  165. statusTabs: [{
  166. label: '全部',
  167. value: 'all'
  168. }],
  169. // 静态变量
  170. datePickerOptions: datePickerOptions,
  171. searchTypes: [
  172. { label: '订单号', value: 'no' },
  173. { label: '会员编号', value: 'userId' },
  174. { label: '会员昵称', value: 'userNickname' },
  175. { label: '会员手机号', value: 'userMobile' },
  176. { label: '收货人姓名', value: 'receiverName' },
  177. { label: '收货人手机号码', value: 'receiverMobile' },
  178. ],
  179. }
  180. },
  181. created() {
  182. this.getList();
  183. // 设置 statuses 过滤
  184. for (const dict of getDictDatas(DICT_TYPE.TRADE_ORDER_STATUS)) {
  185. this.statusTabs.push({
  186. label: dict.label,
  187. value: dict.value
  188. })
  189. }
  190. },
  191. methods: {
  192. /** 查询列表 */
  193. getList() {
  194. this.loading = true;
  195. // 执行查询
  196. getOrderPage({
  197. ...this.queryParams,
  198. searchType: undefined,
  199. searchValue: undefined,
  200. no: this.queryParams.searchType === 'no' ? this.queryParams.searchValue : undefined,
  201. userId: this.queryParams.searchType === 'userId' ? this.queryParams.searchValue : undefined,
  202. userNickname: this.queryParams.searchType === 'userNickname' ? this.queryParams.searchValue : undefined,
  203. userMobile: this.queryParams.searchType === 'userMobile' ? this.queryParams.searchValue : undefined,
  204. receiverName: this.queryParams.searchType === 'receiverName' ? this.queryParams.searchValue : undefined,
  205. receiverMobile: this.queryParams.searchType === 'receiverMobile' ? this.queryParams.searchValue : undefined,
  206. }).then(response => {
  207. this.list = response.data.list;
  208. this.total = response.data.total;
  209. this.loading = false;
  210. });
  211. },
  212. /** 搜索按钮操作 */
  213. handleQuery() {
  214. this.queryParams.pageNo = 1;
  215. this.activeTab = this.queryParams.status ? this.queryParams.status : 'all'; // 处理 tab
  216. this.getList();
  217. },
  218. /** 重置按钮操作 */
  219. resetQuery() {
  220. this.resetForm("queryForm");
  221. this.handleQuery();
  222. },
  223. /** tab 切换 */
  224. tabClick(tab) {
  225. this.queryParams.status = tab.name === 'all' ? undefined : tab.name;
  226. this.getList();
  227. },
  228. goToDetail (row) {
  229. this.$router.push({ path: '/trade/order/detail', query: { id: row.id }})
  230. }
  231. }
  232. }
  233. </script>
  234. <style lang="scss" scoped>
  235. ::v-deep .order-table{
  236. border-bottom: none;
  237. &::before{
  238. height: 0;
  239. }
  240. .el-table__row{
  241. .el-table__cell{
  242. border-bottom: none;
  243. .cell{
  244. .el-table {
  245. .el-table__row{
  246. >.el-table__cell{
  247. .goods-info{
  248. display: flex;
  249. img{
  250. margin-right: 10px;
  251. width: 60px;
  252. height: 60px;
  253. border: 1px solid #e2e2e2;
  254. }
  255. }
  256. .ellipsis-2{
  257. display: -webkit-box;
  258. overflow: hidden;
  259. text-overflow: ellipsis;
  260. white-space: normal;
  261. -webkit-line-clamp: 2; /* 要显示的行数 */
  262. -webkit-box-orient: vertical;
  263. word-break: break-all;
  264. line-height: 22px !important;
  265. max-height: 44px !important;
  266. }
  267. }
  268. }
  269. }
  270. }
  271. }
  272. }
  273. }
  274. </style>