detail_orderDetail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <div id="form-1">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__backInRight">
  5. <el-col class="top-btn">
  6. <el-button type="primary" size="mini" @click="toBack()">返回</el-button>
  7. </el-col>
  8. <el-col :span="9" class="one">
  9. <el-col :span="24" class="add">
  10. <el-col :span="2">
  11. <i class="el-icon-location"></i>
  12. </el-col>
  13. <el-col :span="22">
  14. <p>{{ address.name }},{{ address.phone }}</p>
  15. <p>{{ address.province }} , {{ address.city }} , {{ address.area }} , {{ address.address }}</p>
  16. </el-col>
  17. </el-col>
  18. <el-col :span="24" class="shop"> <i class="el-icon-s-shop"></i>{{ shop.name }}</el-col>
  19. <el-col :span="24" v-for="(item, index) in list" :key="index">
  20. <el-col :span="24" class="goods">
  21. <el-col :span="6"><el-image :src="item.goods.file[0].url"></el-image></el-col>
  22. <el-col :span="18">
  23. <el-col :span="12">
  24. <p>{{ item.goods.name }}</p>
  25. <p>规格:{{ item.name }}</p>
  26. </el-col>
  27. <el-col :span="12" class="money">
  28. <p>¥{{ item.sell_money }}</p>
  29. <p>X{{ item.buy_num }}</p>
  30. </el-col>
  31. </el-col>
  32. </el-col>
  33. <el-col :span="24">
  34. <el-col :span="6">运费</el-col>
  35. <el-col :span="18" class="other" v-if="!item.goods.freight == '0'">{{ item.goods.freight }}</el-col>
  36. <el-col :span="18" class="other" v-else>包邮</el-col>
  37. </el-col>
  38. </el-col>
  39. <el-col :span="24">
  40. <el-col :span="6">订单备注</el-col>
  41. <el-col :span="18" class="other" v-if="form.remarks">{{ form.remarks }}</el-col>
  42. <el-col :span="18" class="other" v-else>暂无备注</el-col>
  43. </el-col>
  44. <el-col :span="24">
  45. <el-col :span="6">配送方式</el-col>
  46. <el-col :span="18" class="other">快递配送</el-col>
  47. </el-col>
  48. <el-col :span="24" class="goods_total">
  49. <el-col :span="6">商品金额</el-col>
  50. <el-col :span="18" class="other">
  51. <p>¥{{ total_detail.goods_total }}</p>
  52. </el-col>
  53. </el-col>
  54. <el-col :span="24" class="goods_total">
  55. <el-col :span="6">快递费</el-col>
  56. <el-col :span="18" class="other">
  57. <p>¥{{ total_detail.freight_total }}</p>
  58. </el-col>
  59. </el-col>
  60. <el-col :span="24" class="goods_total">
  61. <el-col :span="8">优惠后实付金额</el-col>
  62. <el-col :span="16" class="other">
  63. <p>¥{{ pay.pay_money }}</p>
  64. </el-col>
  65. </el-col>
  66. <el-col :span="24">
  67. <el-col :span="6">下单时间</el-col>
  68. <el-col :span="18" class="other">{{ form.buy_time }}</el-col>
  69. </el-col>
  70. <el-col :span="24">
  71. <el-col :span="6">支付时间</el-col>
  72. <el-col :span="18" class="other">{{ form.pay_time }}</el-col>
  73. </el-col>
  74. <el-col :span="24">
  75. <el-col :span="6">寄出运单号</el-col>
  76. <el-col :span="18" class="other">{{ transport.shop_transport_no || '暂无单号' }}</el-col>
  77. </el-col>
  78. <el-col :span="24">
  79. <el-col :span="6">寄出快递类型</el-col>
  80. <el-col :span="18" class="other">{{ transport.shop_transport_name || '暂无快递信息' }}</el-col>
  81. </el-col>
  82. <el-col :span="24">
  83. <el-form :model="form" ref="form" label-width="100px" class="demo-ruleForm">
  84. <el-form-item
  85. label="寄出运单号"
  86. prop="shop_transport_no"
  87. v-if="(form.status == '1' || form.status == '2') && (!transport.shop_transport_no || !transport.shop_transport_name)"
  88. >
  89. <el-input v-model="form.shop_transport_no" placeholder="请输入运单号,快递类型,同时填入" size="small"></el-input>
  90. </el-form-item>
  91. <el-form-item
  92. label="快递类型"
  93. prop="shop_transport_type"
  94. v-if="(form.status == '1' || form.status == '2') && (!transport.shop_transport_no || !transport.shop_transport_name)"
  95. >
  96. <el-select
  97. v-model="form.shop_transport_type"
  98. clearable
  99. filterable
  100. placeholder="请选择快递类型,运单号,同时填入"
  101. size="small"
  102. style="width: 100%"
  103. >
  104. <el-option v-for="i in shop_transport_typeList" :key="i._id" :label="i.label" :value="i.value"> </el-option>
  105. </el-select>
  106. </el-form-item>
  107. <el-form-item label="订单状态" prop="status">
  108. <el-select v-model="form.status" clearable filterable placeholder="请选择订单状态" size="small" style="width: 100%">
  109. <el-option v-for="i in order_processList" :key="i.label" :label="i.label" :value="i.value"> </el-option>
  110. </el-select>
  111. </el-form-item>
  112. <el-form-item>
  113. <el-button type="primary" @click="onSubmit()">保存</el-button>
  114. </el-form-item>
  115. </el-form>
  116. </el-col>
  117. </el-col>
  118. <el-col :span="9" class="one" v-if="transport.shop_transport_no">
  119. <el-col :span="24">{{ activit.is_check || '暂无快递信息' }}</el-col>
  120. <el-col :span="24">{{ transport.shop_transport_name || '暂无快递信息' }}: {{ activit.no || '暂无快递信息' }}</el-col>
  121. <el-col :span="24">
  122. <p>订单编号:{{ form.id }}</p>
  123. <p>收货地址:{{ address.province }} , {{ address.city }} , {{ address.area }} , {{ address.address }}</p>
  124. </el-col>
  125. <el-col :span="24">
  126. <el-timeline :reverse="reverse">
  127. <el-timeline-item v-for="(activity, index) in activities" :key="index" :timestamp="activity.time" :color="activity.color">
  128. {{ activity.context }}
  129. </el-timeline-item>
  130. </el-timeline>
  131. </el-col>
  132. </el-col>
  133. </el-col>
  134. </el-row>
  135. </div>
  136. </template>
  137. <script>
  138. const _ = require('lodash');
  139. const moment = require('moment');
  140. import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
  141. const { mapActions } = createNamespacedHelpers('orderDetail');
  142. const { mapActions: dictData } = createNamespacedHelpers('dictData');
  143. const { mapActions: sot } = createNamespacedHelpers('sot');
  144. export default {
  145. name: 'form-1',
  146. props: {},
  147. components: {},
  148. data: function () {
  149. return {
  150. form: {},
  151. // 地址
  152. address: {},
  153. // 实付金额
  154. total_detail: {},
  155. // 商铺
  156. shop: {},
  157. // 运单号
  158. transport: {},
  159. pay: {},
  160. // 商品列表
  161. list: [],
  162. // 物流
  163. reverse: false,
  164. activities: [],
  165. activit: {},
  166. // 订单状态
  167. order_processList: [],
  168. // 快递类型
  169. shop_transport_typeList: [],
  170. };
  171. },
  172. async created() {
  173. await this.searchOther();
  174. await this.search();
  175. },
  176. methods: {
  177. ...dictData({ dictQuery: 'query' }),
  178. ...sot({ sotFetch: 'fetch' }),
  179. ...mapActions(['query', 'fetch', 'create', 'update']),
  180. // 查询
  181. async search() {
  182. let res;
  183. res = await this.fetch(this.id);
  184. if (this.$checkRes(res)) {
  185. this.$set(this, `form`, res.data);
  186. // 地址
  187. this.$set(this, `address`, res.data.address);
  188. this.$set(this, `shop`, res.data.shop);
  189. // 商品
  190. this.$set(this, `list`, res.data.goods);
  191. // 应付金额
  192. this.$set(this, `total_detail`, res.data.total_detail);
  193. this.$set(this, `pay`, res.data.order.pay);
  194. if (res.data.transport) {
  195. let type = this.shop_transport_typeList.find((i) => i.value == res.data.transport.shop_transport_type);
  196. if (type) res.data.transport.shop_transport_name = type.label;
  197. this.$set(this, `transport`, res.data.transport);
  198. res = await this.sotFetch(this.id);
  199. if (this.$checkRes(res)) {
  200. let activities = res.data.list;
  201. activities[0].color = '#0bbd87';
  202. this.$set(this, `activities`, activities);
  203. this.$set(this, `activit`, res.data);
  204. }
  205. }
  206. }
  207. },
  208. // 提交
  209. async onSubmit() {
  210. let form = this.form;
  211. let transport = {};
  212. let res;
  213. if (form.shop_transport_no && form.shop_transport_type) {
  214. transport.shop_transport_no = form.shop_transport_no;
  215. transport.shop_transport_type = form.shop_transport_type;
  216. form.transport = transport;
  217. }
  218. if (form.id) res = await this.update(form);
  219. if (this.$checkRes(res)) {
  220. this.$message({ type: `success`, message: `维护信息成功` });
  221. this.toBack();
  222. }
  223. },
  224. // 返回
  225. toBack() {
  226. window.history.go('-1');
  227. },
  228. // 查询其他信息
  229. async searchOther() {
  230. let res;
  231. // 减免方式
  232. res = await this.dictQuery({ code: 'order_process' });
  233. if (this.$checkRes(res)) {
  234. this.$set(this, `order_processList`, res.data);
  235. }
  236. // 减免方式
  237. res = await this.dictQuery({ code: 'transport_type' });
  238. if (this.$checkRes(res)) {
  239. this.$set(this, `shop_transport_typeList`, res.data);
  240. }
  241. },
  242. },
  243. computed: {
  244. id() {
  245. return this.$route.query.id;
  246. },
  247. },
  248. metaform() {
  249. return { title: this.$route.meta.title };
  250. },
  251. watch: {
  252. test: {
  253. deep: true,
  254. immediate: true,
  255. handler(val) {},
  256. },
  257. },
  258. };
  259. </script>
  260. <style lang="less" scoped>
  261. .main {
  262. .one {
  263. margin: 10px 0 0 5%;
  264. padding: 5px;
  265. .add {
  266. border-bottom: 2px dashed #ccc;
  267. margin: 0 0 5px 0;
  268. padding: 5px 0;
  269. }
  270. .shop {
  271. padding: 4px 0;
  272. font-size: 18px;
  273. border-bottom: 1px solid #ccc;
  274. }
  275. .goods {
  276. padding: 10px 0;
  277. .money {
  278. text-align: right;
  279. }
  280. }
  281. .other {
  282. text-align: right;
  283. p {
  284. color: red;
  285. }
  286. }
  287. .el-col {
  288. margin: 4px 0;
  289. }
  290. }
  291. }
  292. /deep/.el-timeline {
  293. margin: 20px 0 0 0;
  294. font-size: 16px;
  295. }
  296. /deep/.el-timeline-item__node:nth-child(1) {
  297. background-color: green;
  298. }
  299. </style>