index.vue 12 KB

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