index.vue 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. <template>
  2. <div class="app-container">
  3. <el-tabs v-model="activeStatus" @tab-click="handleTabClick">
  4. <el-tab-pane label="全部" name="all"></el-tab-pane>
  5. <el-tab-pane label="未审核" name="1"></el-tab-pane>
  6. <el-tab-pane label="审核通过" name="2"></el-tab-pane>
  7. <el-tab-pane label="已发货" name="3"></el-tab-pane>
  8. <el-tab-pane label="已回款" name="4"></el-tab-pane>
  9. <el-tab-pane label="已取消" name="-3"></el-tab-pane>
  10. </el-tabs>
  11. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="88px" size="small">
  12. <el-form-item label="订单编号" prop="orderCode">
  13. <el-input v-model="queryParams.orderCode" placeholder="请输入订单编号" clearable @keyup.enter.native="handleQuery" />
  14. </el-form-item>
  15. <el-form-item label="会员ID" prop="userId">
  16. <el-input v-model="queryParams.userId" placeholder="请输入会员ID" clearable @keyup.enter.native="handleQuery" />
  17. </el-form-item>
  18. <el-form-item label="收货人" prop="userName">
  19. <el-input v-model="queryParams.userName" placeholder="请输入收货人" clearable @keyup.enter.native="handleQuery" />
  20. </el-form-item>
  21. <el-form-item label="收货人电话" prop="userPhone">
  22. <el-input v-model="queryParams.userPhone" placeholder="请输入收货人电话" clearable @keyup.enter.native="handleQuery" />
  23. </el-form-item>
  24. <el-form-item label="工号" prop="companyUserId">
  25. <el-input v-model="queryParams.companyUserId" placeholder="请输入工号" clearable @keyup.enter.native="handleQuery" />
  26. </el-form-item>
  27. <el-form-item label="下单日期" prop="createTime">
  28. <el-date-picker
  29. v-model="createTime"
  30. style="width: 220px"
  31. value-format="yyyy-MM-dd"
  32. type="daterange"
  33. range-separator="-"
  34. start-placeholder="开始日期"
  35. end-placeholder="结束日期"
  36. @change="handleCreateTimeChange"
  37. />
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  41. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  42. </el-form-item>
  43. </el-form>
  44. <el-row :gutter="10" class="mb8">
  45. <el-col :span="1.5">
  46. <el-button
  47. type="primary"
  48. icon="el-icon-plus"
  49. size="mini"
  50. @click="handleAdd"
  51. v-hasPermi="['store:thirdOrder:create']"
  52. >创建订单</el-button>
  53. </el-col>
  54. <el-col :span="1.5">
  55. <el-button
  56. type="success"
  57. plain
  58. icon="el-icon-s-check"
  59. size="mini"
  60. :disabled="selectedRows.length === 0"
  61. :loading="batchAuditLoading"
  62. @click="handleBatchAudit"
  63. v-hasPermi="['store:thirdOrder:audit']"
  64. >批量审核</el-button>
  65. </el-col>
  66. <el-col :span="1.5">
  67. <el-button
  68. type="warning"
  69. plain
  70. icon="el-icon-download"
  71. size="mini"
  72. :loading="exportLoading"
  73. @click="handleExport"
  74. v-hasPermi="['store:thirdOrder:export']"
  75. >导出</el-button>
  76. </el-col>
  77. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  78. </el-row>
  79. <el-table v-loading="loading" border :data="orderList" style="width: 100%" height="500" @selection-change="handleSelectionChange">
  80. <el-table-column type="selection" width="50" align="center" :selectable="checkAuditSelectable" fixed="left" />
  81. <el-table-column label="订单编号" align="center" prop="orderCode" width="170" fixed="left" show-overflow-tooltip />
  82. <el-table-column label="收货人" align="center" prop="userName" width="90" />
  83. <el-table-column label="收货人电话" align="center" prop="userPhone" width="130" />
  84. <el-table-column label="收货地址" align="center" prop="userAddress" width="220" show-overflow-tooltip />
  85. <el-table-column label="商品总额" align="center" prop="totalPrice" width="100">
  86. <template slot-scope="scope">
  87. <span v-if="scope.row.totalPrice != null">{{ Number(scope.row.totalPrice).toFixed(2) }}</span>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="定金" align="center" prop="payPrice" width="100">
  91. <template slot-scope="scope">
  92. <span v-if="scope.row.payPrice != null">{{ Number(scope.row.payPrice).toFixed(2) }}</span>
  93. </template>
  94. </el-table-column>
  95. <el-table-column label="代收金额" align="center" prop="collectionPrice" width="100">
  96. <template slot-scope="scope">
  97. <span v-if="scope.row.collectionPrice != null">{{ Number(scope.row.collectionPrice).toFixed(2) }}</span>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="回款金额" align="center" prop="returnPrice" width="100">
  101. <template slot-scope="scope">
  102. <span v-if="scope.row.returnPrice != null">{{ Number(scope.row.returnPrice).toFixed(2) }}</span>
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="订单状态" align="center" prop="status" width="100">
  106. <template slot-scope="scope">
  107. <el-tag v-if="scope.row.status == 1" type="warning" size="mini">未审核</el-tag>
  108. <el-tag v-else-if="scope.row.status == 2" type="primary" size="mini">审核通过</el-tag>
  109. <el-tag v-else-if="scope.row.status == 3" type="success" size="mini">已发货</el-tag>
  110. <el-tag v-else-if="scope.row.status == 4" type="success" size="mini">已回款</el-tag>
  111. <el-tag v-else-if="scope.row.status == -3" type="danger" size="mini">已取消</el-tag>
  112. <span v-else>-</span>
  113. </template>
  114. </el-table-column>
  115. <el-table-column label="销售" align="center" prop="companyUserName" width="100" />
  116. <el-table-column label="下单时间" align="center" prop="createTime" width="160" />
  117. <el-table-column label="审核人" align="center" prop="auditor" width="90" />
  118. <el-table-column label="审核时间" align="center" prop="auditTime" width="160" />
  119. <el-table-column label="快递单号" align="center" prop="deliverySn" width="150" show-overflow-tooltip />
  120. <el-table-column label="物流状态" align="center" width="90">
  121. <template slot-scope="scope">
  122. <el-tag v-if="scope.row.deliveryStatus == 3" type="success" size="mini">已签收</el-tag>
  123. <el-tag v-else-if="scope.row.deliveryStatus == 1" size="mini">已揽收</el-tag>
  124. <el-tag v-else-if="scope.row.deliveryStatus == 2" type="warning" size="mini">在途</el-tag>
  125. <el-tag v-else-if="scope.row.deliveryStatus == 4" type="danger" size="mini">问题件</el-tag>
  126. <el-tag v-else-if="scope.row.deliveryStatus == 0" type="info" size="mini">暂无轨迹</el-tag>
  127. <span v-else>-</span>
  128. </template>
  129. </el-table-column>
  130. <el-table-column label="发货时间" align="center" prop="deliveryTime" width="160" />
  131. <el-table-column label="备注" align="center" prop="remark" width="150" show-overflow-tooltip />
  132. <el-table-column label="操作" align="center" fixed="right" width="280" class-name="small-padding fixed-width">
  133. <template slot-scope="scope">
  134. <el-button size="mini" type="text" @click="handleView(scope.row)" v-hasPermi="['store:thirdOrder:query']">详情</el-button>
  135. <el-button size="mini" type="text" @click="handleAudit(scope.row)" v-if="scope.row.status == 1" v-hasPermi="['store:thirdOrder:audit']">审核</el-button>
  136. <el-button size="mini" type="text" @click="handleEdit(scope.row)" v-hasPermi="['store:thirdOrder:edit']">订单修改</el-button>
  137. <el-button size="mini" type="text" @click="handleExpress(scope.row)" v-if="scope.row.deliverySn">物流</el-button>
  138. <el-button size="mini" type="text" @click="handleCancel(scope.row)" v-if="scope.row.status != -3" v-hasPermi="['store:thirdOrder:cancel']">取消</el-button>
  139. <el-button size="mini" type="text" @click="handleDelete(scope.row)" v-hasPermi="['store:thirdOrder:remove']">删除</el-button>
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. <pagination
  144. v-show="total > 0"
  145. :total="total"
  146. :page.sync="queryParams.pageNum"
  147. :limit.sync="queryParams.pageSize"
  148. @pagination="getList"
  149. />
  150. <!-- 创建订单弹窗 -->
  151. <el-dialog title="创建第三方订单" v-if="open" :visible.sync="open" width="1100px" append-to-body :close-on-click-modal="false">
  152. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  153. <el-form-item label="会员信息" prop="userId">
  154. <el-row>
  155. <el-col>
  156. <el-input placeholder="请输入会员手机号" style="width:240px;" v-model="phone" clearable @keyup.enter.native="searchUser" />
  157. <el-button plain style="margin-left:10px;" @click="searchUser()">查询</el-button>
  158. </el-col>
  159. </el-row>
  160. <el-radio-group v-model="form.userId" style="width:100%" @change="handleUserChange">
  161. <el-table border style="margin-top:5px;" v-loading="userloading" :data="users">
  162. <el-table-column label="选择" align="center" width="80">
  163. <template slot-scope="scope">
  164. <el-radio :label="scope.row.userId"></el-radio>
  165. </template>
  166. </el-table-column>
  167. <el-table-column label="ID" align="center" prop="userId" width="80" />
  168. <el-table-column label="会员头像" align="center" width="80">
  169. <template slot-scope="scope">
  170. <el-popover v-if="scope.row.avatar" placement="right" title="" trigger="hover">
  171. <img slot="reference" :src="scope.row.avatar" width="50">
  172. <img :src="scope.row.avatar" style="max-width: 120px;">
  173. </el-popover>
  174. <span v-else>-</span>
  175. </template>
  176. </el-table-column>
  177. <el-table-column label="昵称" align="center" prop="nickName" />
  178. <el-table-column label="手机号" align="center" prop="phone" />
  179. <el-table-column label="状态" align="center" prop="status" width="90">
  180. <template slot-scope="scope">
  181. <dict-tag :options="userStatusOptions" :value="scope.row.status"/>
  182. </template>
  183. </el-table-column>
  184. </el-table>
  185. </el-radio-group>
  186. </el-form-item>
  187. <el-form-item label="收货信息" prop="addressId">
  188. <el-row>
  189. <el-col>
  190. <el-button plain type="primary" icon="el-icon-plus" @click="handleAddUserAddress">添加收货地址</el-button>
  191. </el-col>
  192. </el-row>
  193. <el-radio-group v-model="form.addressId" style="width:100%">
  194. <el-table border style="margin-top:5px;" v-loading="addressloading" :data="address">
  195. <el-table-column label="选择" align="center" width="80">
  196. <template slot-scope="scope">
  197. <el-radio :label="scope.row.addressId"></el-radio>
  198. </template>
  199. </el-table-column>
  200. <el-table-column label="收货人姓名" align="center" prop="realName" />
  201. <el-table-column label="收货人电话" align="center" prop="phone" width="130" />
  202. <el-table-column label="收货人所在省" align="center" prop="province" />
  203. <el-table-column label="收货人所在市" align="center" prop="city" />
  204. <el-table-column label="收货人所在区" align="center" prop="district" />
  205. <el-table-column label="收货人详细地址" align="center" prop="detail" show-overflow-tooltip />
  206. </el-table>
  207. </el-radio-group>
  208. </el-form-item>
  209. <el-divider content-position="left">商品选择</el-divider>
  210. <el-row style="margin-bottom: 10px;" :gutter="10">
  211. <el-col :span="8">
  212. <el-select
  213. v-model="productQuery.storeId"
  214. placeholder="请选择店铺"
  215. clearable
  216. filterable
  217. size="small"
  218. style="width: 100%"
  219. @change="handleStoreChange"
  220. >
  221. <el-option
  222. v-for="dict in storeOptions"
  223. :key="dict.dictValue"
  224. :label="dict.dictLabel"
  225. :value="dict.dictValue"
  226. />
  227. </el-select>
  228. </el-col>
  229. <el-col :span="10">
  230. <el-input
  231. v-model="productSearchKeyword"
  232. placeholder="请输入商品名称搜索"
  233. clearable
  234. size="small"
  235. :disabled="!productQuery.storeId"
  236. @keyup.enter.native="searchProduct"
  237. />
  238. </el-col>
  239. <el-col :span="4">
  240. <el-button type="primary" size="small" :disabled="!productQuery.storeId" @click="searchProduct">搜索</el-button>
  241. </el-col>
  242. </el-row>
  243. <el-alert
  244. v-if="!productQuery.storeId"
  245. title="请先选择店铺后再选择商品"
  246. type="info"
  247. :closable="false"
  248. show-icon
  249. style="margin-bottom: 10px;"
  250. />
  251. <el-table border :data="productList" size="small" style="margin-bottom: 10px;">
  252. <el-table-column label="商品图片" align="center" width="90">
  253. <template slot-scope="scope">
  254. <el-popover v-if="scope.row.productImage" placement="right" title="" trigger="hover">
  255. <img slot="reference" :src="scope.row.productImage" width="50">
  256. <img :src="scope.row.productImage" style="max-width: 150px;">
  257. </el-popover>
  258. <span v-else>-</span>
  259. </template>
  260. </el-table-column>
  261. <el-table-column label="商品名称" show-overflow-tooltip align="center" prop="productName" />
  262. <el-table-column label="商品规格" align="center" prop="productSpec" width="140" show-overflow-tooltip />
  263. <el-table-column label="售价" align="center" prop="price" width="100">
  264. <template slot-scope="scope">
  265. <span v-if="scope.row.price != null">{{ Number(scope.row.price).toFixed(2) }}</span>
  266. </template>
  267. </el-table-column>
  268. <el-table-column label="库存" align="center" prop="stock" width="80" />
  269. <el-table-column label="操作" align="center" width="100">
  270. <template slot-scope="scope">
  271. <el-button size="mini" type="primary" plain @click="handleSelectProduct(scope.row)">选择</el-button>
  272. </template>
  273. </el-table-column>
  274. </el-table>
  275. <pagination
  276. v-show="productTotal > 0"
  277. :total="productTotal"
  278. :page.sync="productQuery.pageNum"
  279. :limit.sync="productQuery.pageSize"
  280. @pagination="getProductList"
  281. />
  282. <el-divider content-position="left">已选商品</el-divider>
  283. <el-table border :data="selectedProducts" size="small">
  284. <el-table-column label="商品名称" show-overflow-tooltip align="center" prop="productName" />
  285. <el-table-column label="商品规格" align="center" prop="productSpec" width="140" show-overflow-tooltip />
  286. <el-table-column label="单价" align="center" width="160">
  287. <template slot-scope="scope">
  288. <el-input-number v-model="scope.row.price" @change="calcTotalPrice" size="small" :min="0" :precision="2" controls-position="right" style="width: 140px;" />
  289. </template>
  290. </el-table-column>
  291. <el-table-column label="数量" align="center" width="160">
  292. <template slot-scope="scope">
  293. <el-input-number v-model="scope.row.num" @change="calcTotalPrice" size="small" :min="1" controls-position="right" style="width: 140px;" />
  294. </template>
  295. </el-table-column>
  296. <el-table-column label="小计" align="center" width="120">
  297. <template slot-scope="scope">
  298. <span>{{ (scope.row.price * scope.row.num).toFixed(2) }}</span>
  299. </template>
  300. </el-table-column>
  301. <el-table-column label="操作" align="center" width="80">
  302. <template slot-scope="scope">
  303. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleRemoveProduct(scope.$index)">删除</el-button>
  304. </template>
  305. </el-table-column>
  306. </el-table>
  307. <el-row style="margin-top: 10px;">
  308. <el-col :span="8">
  309. <el-form-item label="商品总额">
  310. <el-input v-model="form.totalPrice" disabled style="width: 200px;" />
  311. </el-form-item>
  312. </el-col>
  313. <el-col :span="8">
  314. <el-form-item label="定金" prop="payPrice">
  315. <el-input-number v-model="form.payPrice" :precision="2" :min="0" controls-position="right" style="width: 200px;" @change="handlePayPriceChange" />
  316. </el-form-item>
  317. </el-col>
  318. <el-col :span="8">
  319. <el-form-item label="代收金额" prop="collectionPrice">
  320. <el-input-number v-model="form.collectionPrice" :precision="2" :min="0" controls-position="right" style="width: 200px;" />
  321. </el-form-item>
  322. </el-col>
  323. </el-row>
  324. <el-form-item label="备注" prop="remark">
  325. <el-input v-model="form.remark" type="textarea" :rows="3" placeholder="请输入备注" style="width: 500px;" />
  326. </el-form-item>
  327. </el-form>
  328. <div slot="footer" class="dialog-footer">
  329. <el-button type="primary" @click="submitForm">确认下单</el-button>
  330. <el-button @click="cancel">取 消</el-button>
  331. </div>
  332. </el-dialog>
  333. <el-dialog :title="userAddress.title" v-if="userAddress.open" :visible.sync="userAddress.open" width="800px" append-to-body>
  334. <add-user-address ref="addUserAddress" @addUserAddress="addUserAddress" />
  335. </el-dialog>
  336. <!-- 订单详情弹窗 -->
  337. <el-dialog title="订单详情" v-if="detailOpen" :visible.sync="detailOpen" width="1000px" append-to-body>
  338. <el-descriptions :column="3" border size="small">
  339. <el-descriptions-item label="订单编号">{{ detailData.orderCode }}</el-descriptions-item>
  340. <el-descriptions-item label="订单状态">
  341. <el-tag v-if="detailData.status == 1" type="warning" size="mini">未审核</el-tag>
  342. <el-tag v-else-if="detailData.status == 2" type="primary" size="mini">审核通过</el-tag>
  343. <el-tag v-else-if="detailData.status == 3" type="success" size="mini">已发货</el-tag>
  344. <el-tag v-else-if="detailData.status == 4" type="success" size="mini">已回款</el-tag>
  345. <el-tag v-else-if="detailData.status == -3" type="danger" size="mini">已取消</el-tag>
  346. <span v-else>-</span>
  347. </el-descriptions-item>
  348. <el-descriptions-item label="会员ID">{{ detailData.userId || '-' }}</el-descriptions-item>
  349. <el-descriptions-item label="收货人">{{ detailData.userName }}</el-descriptions-item>
  350. <el-descriptions-item label="收货人电话">{{ detailData.userPhone }}</el-descriptions-item>
  351. <el-descriptions-item label="收货地址" :span="3">{{ detailData.userAddress }}</el-descriptions-item>
  352. <el-descriptions-item label="商品总额">{{ detailData.totalPrice }}</el-descriptions-item>
  353. <el-descriptions-item label="定金">{{ detailData.payPrice }}</el-descriptions-item>
  354. <el-descriptions-item label="代收金额">{{ detailData.collectionPrice != null ? detailData.collectionPrice : '-' }}</el-descriptions-item>
  355. <el-descriptions-item label="回款金额">{{ detailData.returnPrice != null ? detailData.returnPrice : '-' }}</el-descriptions-item>
  356. <el-descriptions-item label="销售">{{ detailData.companyUserName || '-' }}</el-descriptions-item>
  357. <el-descriptions-item label="工号">{{ detailData.companyUserId || '-' }}</el-descriptions-item>
  358. <el-descriptions-item label="下单时间">{{ detailData.createTime || '-' }}</el-descriptions-item>
  359. <el-descriptions-item label="审核人">{{ detailData.auditor || '-' }}</el-descriptions-item>
  360. <el-descriptions-item label="审核时间">{{ detailData.auditTime || '-' }}</el-descriptions-item>
  361. <el-descriptions-item label="快递单号">{{ detailData.deliverySn || '-' }}</el-descriptions-item>
  362. <el-descriptions-item label="物流状态">
  363. <el-tag v-if="detailData.deliveryStatus == 3" type="success" size="mini">已签收</el-tag>
  364. <el-tag v-else-if="detailData.deliveryStatus == 1" size="mini">已揽收</el-tag>
  365. <el-tag v-else-if="detailData.deliveryStatus == 2" type="warning" size="mini">在途</el-tag>
  366. <el-tag v-else-if="detailData.deliveryStatus == 4" type="danger" size="mini">问题件</el-tag>
  367. <el-tag v-else-if="detailData.deliveryStatus == 0" type="info" size="mini">暂无轨迹</el-tag>
  368. <span v-else>-</span>
  369. </el-descriptions-item>
  370. <el-descriptions-item label="发货时间">{{ detailData.deliveryTime || '-' }}</el-descriptions-item>
  371. <el-descriptions-item label="备注" :span="3">{{ detailData.remark || '-' }}</el-descriptions-item>
  372. </el-descriptions>
  373. <el-divider content-position="left">商品信息</el-divider>
  374. <el-table border :data="orderItems" size="small">
  375. <el-table-column label="商品图片" align="center" width="100">
  376. <template slot-scope="scope">
  377. <el-popover v-if="scope.row.productImage" placement="right" title="" trigger="hover">
  378. <img slot="reference" :src="scope.row.productImage" width="50">
  379. <img :src="scope.row.productImage" style="max-width: 150px;">
  380. </el-popover>
  381. <span v-else>-</span>
  382. </template>
  383. </el-table-column>
  384. <el-table-column label="商品名称" show-overflow-tooltip align="center" prop="productName" />
  385. <el-table-column label="商品规格" align="center" prop="productSpec" width="140" show-overflow-tooltip />
  386. <el-table-column label="数量" align="center" prop="num" width="90" />
  387. <el-table-column label="单价" align="center" prop="price" width="100">
  388. <template slot-scope="scope">
  389. <span v-if="scope.row.price != null">{{ Number(scope.row.price).toFixed(2) }}</span>
  390. </template>
  391. </el-table-column>
  392. <el-table-column label="总价" align="center" width="110">
  393. <template slot-scope="scope">
  394. <span v-if="scope.row.price != null && scope.row.num != null">{{ (scope.row.price * scope.row.num).toFixed(2) }}</span>
  395. </template>
  396. </el-table-column>
  397. </el-table>
  398. <div slot="footer" class="dialog-footer">
  399. <el-button @click="detailOpen = false">关 闭</el-button>
  400. </div>
  401. </el-dialog>
  402. <!-- 物流信息弹窗 -->
  403. <el-dialog title="物流信息" :visible.sync="expressOpen" width="700px" append-to-body>
  404. <div style="margin-bottom: 10px;">
  405. <span style="margin-right: 15px;">快递公司:{{ expressData.deliveryName || '-' }}</span>
  406. <span style="margin-right: 15px;">快递单号:{{ expressData.deliverySn || '-' }}</span>
  407. <el-button
  408. size="mini"
  409. type="primary"
  410. v-hasPermi="['store:thirdOrder:syncExpress']"
  411. v-if="expressData.orderId && expressData.deliverySn"
  412. @click="handleSyncExpress"
  413. >同步快递鸟物流状态</el-button>
  414. </div>
  415. <el-table style="width: 100%" :data="expressTraces" border v-loading="expressLoading">
  416. <el-table-column label="操作时间" width="160" align="center" prop="AcceptTime" />
  417. <el-table-column label="位置" align="center" prop="Location" />
  418. <el-table-column label="描述" align="center" prop="AcceptStation" />
  419. </el-table>
  420. <el-empty v-if="!expressLoading && (!expressTraces || expressTraces.length === 0)" description="暂无物流信息" />
  421. </el-dialog>
  422. <!-- 订单修改弹窗 -->
  423. <el-dialog title="订单修改" :visible.sync="editOpen" width="600px" append-to-body :close-on-click-modal="false">
  424. <el-form ref="editForm" :model="editForm" label-width="120px">
  425. <el-form-item label="订单状态">
  426. <el-select v-model="editForm.status" placeholder="请选择订单状态" clearable size="small" style="width:200px;">
  427. <el-option label="未审核" :value="1" />
  428. <el-option label="审核通过" :value="2" />
  429. <el-option label="已发货" :value="3" />
  430. <el-option label="已回款" :value="4" />
  431. <el-option label="已取消" :value="-3" />
  432. </el-select>
  433. </el-form-item>
  434. <el-form-item label="商品总额">
  435. <el-input-number v-model="editForm.totalPrice" :precision="2" :min="0" size="small" style="width:200px;" />
  436. </el-form-item>
  437. <el-form-item label="定金">
  438. <el-input-number v-model="editForm.payPrice" :precision="2" :min="0" size="small" style="width:200px;" />
  439. </el-form-item>
  440. <el-form-item label="代收金额">
  441. <el-input-number v-model="editForm.collectionPrice" :precision="2" :min="0" size="small" style="width:200px;" />
  442. </el-form-item>
  443. <el-form-item label="回款金额">
  444. <el-input-number v-model="editForm.returnPrice" :precision="2" :min="0" size="small" style="width:200px;" />
  445. </el-form-item>
  446. <el-form-item label="回款时间" v-if="editForm.status == 4" required>
  447. <el-date-picker v-model="editForm.updateTime" type="datetime" placeholder="请选择回款时间" size="small" style="width:200px;" value-format="yyyy-MM-dd HH:mm:ss" />
  448. </el-form-item>
  449. <el-form-item label="快递公司">
  450. <el-input v-model="editForm.deliveryName" placeholder="请输入快递公司" clearable size="small" style="width:200px;" />
  451. </el-form-item>
  452. <el-form-item label="快递公司编号">
  453. <el-input v-model="editForm.deliveryCode" placeholder="请输入快递公司编号" clearable size="small" style="width:200px;" />
  454. </el-form-item>
  455. <el-form-item label="快递单号">
  456. <el-input v-model="editForm.deliverySn" placeholder="请输入快递单号" clearable size="small" style="width:200px;" />
  457. </el-form-item>
  458. <el-form-item label="物流状态">
  459. <el-select v-model="editForm.deliveryStatus" placeholder="请选择物流状态" clearable size="small" style="width:200px;">
  460. <el-option label="暂无轨迹" :value="0" />
  461. <el-option label="已揽收" :value="1" />
  462. <el-option label="在途" :value="2" />
  463. <el-option label="已签收" :value="3" />
  464. <el-option label="问题件" :value="4" />
  465. </el-select>
  466. </el-form-item>
  467. <el-form-item label="备注">
  468. <el-input v-model="editForm.remark" type="textarea" :rows="3" placeholder="请输入备注" style="width:350px;" />
  469. </el-form-item>
  470. </el-form>
  471. <div slot="footer" class="dialog-footer">
  472. <el-button @click="editOpen = false">取 消</el-button>
  473. <el-button type="primary" @click="submitEditConfirm">确 定</el-button>
  474. </div>
  475. </el-dialog>
  476. <el-dialog title="确认修改" :visible.sync="editConfirmOpen" width="360px" append-to-body>
  477. <span>确认修改该订单信息吗?</span>
  478. <div slot="footer" class="dialog-footer">
  479. <el-button @click="editConfirmOpen = false">取 消</el-button>
  480. <el-button type="primary" @click="submitEdit">确 认</el-button>
  481. </div>
  482. </el-dialog>
  483. </div>
  484. </template>
  485. <script>
  486. import { listThirdOrder, getThirdOrder, getThirdOrderItems, createThirdOrder, editThirdOrder, deleteThirdOrder, auditThirdOrder, batchAuditThirdOrder, cancelThirdOrder, exportThirdOrder, listThirdProductForOrder, getExpress, syncExpress } from "@/api/store/thirdOrder";
  487. import { userList } from "@/api/store/user";
  488. import { getAddressList } from "@/api/users/userAddress";
  489. import { listStore } from "@/api/store/storeProduct";
  490. import addUserAddress from "@/views/store/components/addUserAddress.vue";
  491. export default {
  492. name: "ThirdOrder",
  493. components: { addUserAddress },
  494. data() {
  495. return {
  496. // 当前tab
  497. activeStatus: "all",
  498. // 遮罩层
  499. loading: true,
  500. // 显示搜索条件
  501. showSearch: true,
  502. // 总条数
  503. total: 0,
  504. // 订单表格数据
  505. orderList: [],
  506. // 选中数组
  507. selectedRows: [],
  508. // 弹出层标题
  509. title: "",
  510. // 是否显示创建订单弹窗
  511. open: false,
  512. // 是否显示订单详情弹窗
  513. detailOpen: false,
  514. // 订单详情数据
  515. detailData: {},
  516. // 订单明细列表
  517. orderItems: [],
  518. // 导出loading
  519. exportLoading: false,
  520. // 批量审核loading
  521. batchAuditLoading: false,
  522. // 物流信息弹窗
  523. expressOpen: false,
  524. expressLoading: false,
  525. expressData: {},
  526. expressTraces: [],
  527. // 订单修改
  528. editOpen: false,
  529. editConfirmOpen: false,
  530. editForm: {},
  531. // 创建时间范围
  532. createTime: null,
  533. // 商品搜索关键字
  534. productSearchKeyword: null,
  535. // 店铺下拉
  536. storeOptions: [],
  537. // 商品列表
  538. productList: [],
  539. // 商品总数
  540. productTotal: 0,
  541. // 商品查询参数
  542. productQuery: {
  543. pageNum: 1,
  544. pageSize: 10,
  545. storeId: null,
  546. productName: null,
  547. status: 1
  548. },
  549. // 已选商品列表
  550. selectedProducts: [],
  551. // 会员手机号搜索
  552. phone: null,
  553. users: [],
  554. userloading: false,
  555. address: [],
  556. addressloading: false,
  557. userStatusOptions: [],
  558. userAddress: {
  559. open: false,
  560. title: "创建收货地址"
  561. },
  562. // 查询参数
  563. queryParams: {
  564. pageNum: 1,
  565. pageSize: 10,
  566. orderCode: null,
  567. userId: null,
  568. userName: null,
  569. userPhone: null,
  570. companyUserId: null,
  571. status: null,
  572. sTime: null,
  573. eTime: null
  574. },
  575. // 表单参数
  576. form: {
  577. userId: null,
  578. addressId: null,
  579. collectionPrice: 0,
  580. payPrice: 0,
  581. totalPrice: 0,
  582. remark: null
  583. },
  584. // 表单校验
  585. rules: {
  586. userId: [{ required: true, message: "请选择会员", trigger: "change" }],
  587. addressId: [{ required: true, message: "请选择收货地址", trigger: "change" }]
  588. }
  589. };
  590. },
  591. created() {
  592. this.getDicts("sys_company_status").then(response => {
  593. this.userStatusOptions = response.data || [];
  594. });
  595. this.getStoreList();
  596. this.getList();
  597. },
  598. methods: {
  599. /** Tab切换 */
  600. handleTabClick(tab) {
  601. if (tab.name === "all") {
  602. this.queryParams.status = null;
  603. } else {
  604. this.queryParams.status = tab.name;
  605. }
  606. this.handleQuery();
  607. },
  608. /** 查询订单列表 */
  609. getList() {
  610. this.loading = true;
  611. listThirdOrder(this.queryParams).then(response => {
  612. this.orderList = response.rows;
  613. this.total = response.total;
  614. this.loading = false;
  615. }).catch(() => {
  616. this.loading = false;
  617. });
  618. },
  619. /** 搜索按钮操作 */
  620. handleQuery() {
  621. this.queryParams.pageNum = 1;
  622. this.getList();
  623. },
  624. /** 重置按钮操作 */
  625. resetQuery() {
  626. this.resetForm("queryForm");
  627. this.createTime = null;
  628. this.queryParams.sTime = null;
  629. this.queryParams.eTime = null;
  630. this.queryParams.status = null;
  631. this.activeStatus = "all";
  632. this.handleQuery();
  633. },
  634. /** 下单日期范围变化 */
  635. handleCreateTimeChange(val) {
  636. if (val) {
  637. this.queryParams.sTime = val[0];
  638. this.queryParams.eTime = val[1];
  639. } else {
  640. this.queryParams.sTime = null;
  641. this.queryParams.eTime = null;
  642. }
  643. },
  644. /** 多选框选中数据 */
  645. handleSelectionChange(selection) {
  646. this.selectedRows = selection;
  647. },
  648. /** 判断是否可审核(用于禁用选择框) */
  649. checkAuditSelectable(row) {
  650. return row.status == 1;
  651. },
  652. /** 创建订单弹窗 */
  653. handleAdd() {
  654. this.reset();
  655. this.selectedProducts = [];
  656. this.productSearchKeyword = null;
  657. this.productList = [];
  658. this.productTotal = 0;
  659. this.productQuery.pageNum = 1;
  660. this.productQuery.storeId = null;
  661. this.productQuery.productName = null;
  662. this.productQuery.status = 1;
  663. this.open = true;
  664. },
  665. /** 表单重置 */
  666. reset() {
  667. this.phone = null;
  668. this.users = [];
  669. this.address = [];
  670. this.form = {
  671. userId: null,
  672. addressId: null,
  673. collectionPrice: 0,
  674. payPrice: 0,
  675. totalPrice: 0,
  676. remark: null
  677. };
  678. this.resetForm("form");
  679. },
  680. /** 取消按钮 */
  681. cancel() {
  682. this.open = false;
  683. this.reset();
  684. this.selectedProducts = [];
  685. this.productList = [];
  686. this.productTotal = 0;
  687. this.productQuery.storeId = null;
  688. },
  689. getStoreList() {
  690. listStore().then(response => {
  691. this.storeOptions = (response.rows || []).map(item => ({
  692. ...item,
  693. dictValue: item.dictValue != null ? Number(item.dictValue) : item.dictValue
  694. }));
  695. });
  696. },
  697. handleStoreChange(storeId) {
  698. this.selectedProducts = [];
  699. this.calcTotalPrice();
  700. this.productSearchKeyword = null;
  701. this.productQuery.pageNum = 1;
  702. this.productQuery.productName = null;
  703. if (!storeId) {
  704. this.productList = [];
  705. this.productTotal = 0;
  706. return;
  707. }
  708. this.getProductList();
  709. },
  710. /** 按手机号查询正常会员 */
  711. searchUser() {
  712. if (this.phone == null || this.phone === "") {
  713. this.msgError("请输入会员手机号");
  714. return;
  715. }
  716. this.userloading = true;
  717. this.users = [];
  718. this.address = [];
  719. this.form.userId = null;
  720. this.form.addressId = null;
  721. userList({ phone: this.phone }).then(response => {
  722. this.users = response.rows || [];
  723. this.userloading = false;
  724. if (this.users.length === 1) {
  725. this.form.userId = this.users[0].userId;
  726. this.getAddressList(this.form.userId);
  727. }
  728. }).catch(() => {
  729. this.userloading = false;
  730. });
  731. },
  732. handleUserChange(userId) {
  733. this.form.addressId = null;
  734. if (userId != null) {
  735. this.getAddressList(userId);
  736. } else {
  737. this.address = [];
  738. }
  739. },
  740. handleAddUserAddress() {
  741. if (this.form.userId == null) {
  742. this.msgError("请选择会员");
  743. return;
  744. }
  745. this.userAddress.open = true;
  746. setTimeout(() => {
  747. this.$refs.addUserAddress.init(this.form.userId);
  748. }, 500);
  749. },
  750. addUserAddress() {
  751. this.userAddress.open = false;
  752. this.getAddressList(this.form.userId);
  753. },
  754. getAddressList(userId) {
  755. this.addressloading = true;
  756. this.address = [];
  757. getAddressList({ userId: userId }).then(response => {
  758. this.address = response.data || [];
  759. this.addressloading = false;
  760. }).catch(() => {
  761. this.addressloading = false;
  762. });
  763. },
  764. /** 查询商品列表 */
  765. getProductList() {
  766. if (!this.productQuery.storeId) {
  767. this.productList = [];
  768. this.productTotal = 0;
  769. return;
  770. }
  771. this.productQuery.productName = this.productSearchKeyword;
  772. this.productQuery.status = 1;
  773. listThirdProductForOrder(this.productQuery).then(response => {
  774. this.productList = response.rows;
  775. this.productTotal = response.total;
  776. });
  777. },
  778. /** 搜索商品 */
  779. searchProduct() {
  780. if (!this.productQuery.storeId) {
  781. this.msgError("请先选择店铺");
  782. return;
  783. }
  784. this.productQuery.pageNum = 1;
  785. this.getProductList();
  786. },
  787. /** 选择商品 */
  788. handleSelectProduct(row) {
  789. if (!this.productQuery.storeId) {
  790. this.msgError("请先选择店铺");
  791. return;
  792. }
  793. const exists = this.selectedProducts.find(item => item.productId === row.productId);
  794. if (exists) {
  795. this.msgError("该商品已选择");
  796. return;
  797. }
  798. this.selectedProducts.push({
  799. productId: row.productId,
  800. productName: row.productName,
  801. productSpec: row.productSpec,
  802. productImage: row.productImage,
  803. storeId: row.storeId,
  804. price: row.price || 0,
  805. num: 1
  806. });
  807. this.calcTotalPrice();
  808. },
  809. /** 移除已选商品 */
  810. handleRemoveProduct(index) {
  811. this.selectedProducts.splice(index, 1);
  812. this.calcTotalPrice();
  813. },
  814. /** 计算商品总额,并同步代收金额 = 总额 - 定金 */
  815. calcTotalPrice() {
  816. let total = 0;
  817. this.selectedProducts.forEach(item => {
  818. total += (item.price || 0) * (item.num || 0);
  819. });
  820. this.form.totalPrice = Number(total.toFixed(2));
  821. this.syncCollectionPrice();
  822. },
  823. handlePayPriceChange() {
  824. this.syncCollectionPrice();
  825. },
  826. syncCollectionPrice() {
  827. const total = Number(this.form.totalPrice) || 0;
  828. const pay = Number(this.form.payPrice) || 0;
  829. this.form.collectionPrice = Number(Math.max(0, total - pay).toFixed(2));
  830. },
  831. /** 提交创建订单 */
  832. submitForm() {
  833. this.$refs["form"].validate(valid => {
  834. if (valid) {
  835. if (this.selectedProducts.length === 0) {
  836. this.msgError("请至少选择一个商品");
  837. return;
  838. }
  839. const submitData = {
  840. userId: this.form.userId,
  841. addressId: this.form.addressId,
  842. collectionPrice: parseFloat(this.form.collectionPrice) || 0,
  843. freightPrice: 0,
  844. payMoney: parseFloat(this.form.payPrice) || 0,
  845. totalPrice: parseFloat(this.form.totalPrice) || 0,
  846. remark: this.form.remark,
  847. products: this.selectedProducts.map(item => ({
  848. productId: item.productId,
  849. productName: item.productName,
  850. productSpec: item.productSpec,
  851. price: item.price,
  852. num: item.num
  853. }))
  854. };
  855. createThirdOrder(submitData).then(response => {
  856. if (response.code === 200) {
  857. this.msgSuccess("创建成功");
  858. this.open = false;
  859. this.reset();
  860. this.selectedProducts = [];
  861. this.getList();
  862. }
  863. });
  864. }
  865. });
  866. },
  867. /** 查看订单详情 */
  868. handleView(row) {
  869. getThirdOrder(row.orderId).then(response => {
  870. this.detailData = response.data;
  871. this.detailOpen = true;
  872. getThirdOrderItems(row.orderId).then(res => {
  873. this.orderItems = res.data || [];
  874. });
  875. });
  876. },
  877. /** 审核订单 */
  878. handleAudit(row) {
  879. this.$confirm("确认审核该订单?审核后订单将变为审核通过状态", "提示", {
  880. confirmButtonText: "确定",
  881. cancelButtonText: "取消",
  882. type: "warning"
  883. }).then(() => {
  884. auditThirdOrder(row.orderId).then(response => {
  885. if (response.code === 200) {
  886. this.msgSuccess("审核成功");
  887. this.getList();
  888. }
  889. });
  890. }).catch(() => {});
  891. },
  892. /** 批量审核 */
  893. handleBatchAudit() {
  894. if (this.selectedRows.length === 0) {
  895. this.msgError("请至少选择一条未审核订单");
  896. return;
  897. }
  898. const orderIds = this.selectedRows.map(r => r.orderId);
  899. this.$confirm("确认批量审核选中的 " + orderIds.length + " 条订单?审核后将变为审核通过状态", "提示", {
  900. confirmButtonText: "确定",
  901. cancelButtonText: "取消",
  902. type: "warning"
  903. }).then(() => {
  904. this.batchAuditLoading = true;
  905. return batchAuditThirdOrder(orderIds);
  906. }).then(response => {
  907. this.batchAuditLoading = false;
  908. if (response.code === 200) {
  909. this.msgSuccess(response.msg || "批量审核成功");
  910. this.getList();
  911. }
  912. }).catch(() => {
  913. this.batchAuditLoading = false;
  914. });
  915. },
  916. /** 取消订单 */
  917. handleCancel(row) {
  918. this.$confirm("确认取消该订单?取消后订单将变为已取消状态", "警告", {
  919. confirmButtonText: "确定",
  920. cancelButtonText: "取消",
  921. type: "warning"
  922. }).then(() => {
  923. cancelThirdOrder(row.orderId).then(response => {
  924. if (response.code === 200) {
  925. this.msgSuccess("取消订单成功");
  926. this.getList();
  927. }
  928. });
  929. }).catch(() => {});
  930. },
  931. /** 订单修改 */
  932. handleEdit(row) {
  933. getThirdOrder(row.orderId).then(response => {
  934. const d = response.data || {};
  935. this.editForm = {
  936. orderId: d.orderId,
  937. status: d.status,
  938. totalPrice: d.totalPrice != null ? Number(d.totalPrice) : null,
  939. payPrice: d.payPrice != null ? Number(d.payPrice) : null,
  940. collectionPrice: d.collectionPrice != null ? Number(d.collectionPrice) : null,
  941. returnPrice: d.returnPrice != null ? Number(d.returnPrice) : null,
  942. updateTime: d.updateTime || null,
  943. deliveryName: d.deliveryName || null,
  944. deliveryCode: d.deliveryCode || null,
  945. deliverySn: d.deliverySn || null,
  946. deliveryStatus: d.deliveryStatus != null ? Number(d.deliveryStatus) : null,
  947. remark: d.remark || null
  948. };
  949. this.editOpen = true;
  950. });
  951. },
  952. submitEditConfirm() {
  953. if (this.editForm.status == 4 && !this.editForm.updateTime) {
  954. this.msgError("选择已回款时,回款时间不能为空");
  955. return;
  956. }
  957. this.editConfirmOpen = true;
  958. },
  959. submitEdit() {
  960. const payload = {
  961. ...this.editForm,
  962. params: Object.assign({}, this.editForm.params || {}, { allowNull: true })
  963. };
  964. ["deliveryName", "deliveryCode", "deliverySn", "remark"].forEach(key => {
  965. if (payload[key] === "" || payload[key] === undefined) {
  966. payload[key] = null;
  967. }
  968. });
  969. if (payload.deliveryStatus === "" || payload.deliveryStatus === undefined) {
  970. payload.deliveryStatus = null;
  971. }
  972. editThirdOrder(payload).then(response => {
  973. if (response.code === 200) {
  974. this.msgSuccess("修改成功");
  975. this.editConfirmOpen = false;
  976. this.editOpen = false;
  977. this.getList();
  978. } else {
  979. this.msgError(response.msg || "修改失败");
  980. }
  981. }).catch(() => {
  982. this.editConfirmOpen = false;
  983. });
  984. },
  985. /** 删除订单 */
  986. handleDelete(row) {
  987. const orderId = row.orderId;
  988. this.$confirm("是否确认删除该订单?删除后不可恢复", "警告", {
  989. confirmButtonText: "确定",
  990. cancelButtonText: "取消",
  991. type: "warning"
  992. }).then(() => {
  993. return deleteThirdOrder(orderId);
  994. }).then(response => {
  995. if (response.code === 200) {
  996. this.msgSuccess("删除成功");
  997. this.getList();
  998. }
  999. }).catch(() => {});
  1000. },
  1001. /** 导出 */
  1002. handleExport() {
  1003. this.$confirm("是否确认导出第三方订单数据项?", "警告", {
  1004. confirmButtonText: "确定",
  1005. cancelButtonText: "取消",
  1006. type: "warning"
  1007. }).then(() => {
  1008. this.exportLoading = true;
  1009. const params = { ...this.queryParams };
  1010. delete params.pageNum;
  1011. delete params.pageSize;
  1012. return exportThirdOrder(params);
  1013. }).then(response => {
  1014. this.download(response.msg);
  1015. this.exportLoading = false;
  1016. }).catch(() => {
  1017. this.exportLoading = false;
  1018. });
  1019. },
  1020. /** 查看物流信息(快递鸟) */
  1021. handleExpress(row) {
  1022. this.expressData = {
  1023. orderId: row.orderId,
  1024. deliveryName: row.deliveryName,
  1025. deliveryCode: row.deliveryCode,
  1026. deliverySn: row.deliverySn
  1027. };
  1028. this.expressTraces = [];
  1029. this.expressOpen = true;
  1030. this.expressLoading = true;
  1031. getExpress(row.orderId).then(res => {
  1032. this.expressLoading = false;
  1033. this.expressTraces = (res.data && res.data.Traces) ? res.data.Traces : [];
  1034. }).catch(() => {
  1035. this.expressLoading = false;
  1036. this.expressTraces = [];
  1037. });
  1038. },
  1039. /** 同步快递鸟物流状态到订单 */
  1040. handleSyncExpress() {
  1041. if (!this.expressData.orderId) {
  1042. this.msgError("请选择订单");
  1043. return;
  1044. }
  1045. this.$confirm("确定同步物流状态吗?", "警告", {
  1046. confirmButtonText: "确定",
  1047. cancelButtonText: "取消",
  1048. type: "warning"
  1049. }).then(() => {
  1050. return syncExpress(this.expressData.orderId);
  1051. }).then(() => {
  1052. this.msgSuccess("操作成功");
  1053. this.expressOpen = false;
  1054. this.getList();
  1055. }).catch(() => {});
  1056. }
  1057. }
  1058. };
  1059. </script>