index.vue 13 KB

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