OrderInfoMingtou.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <template>
  2. <el-card>
  3. <div
  4. slot="header"
  5. class="card-title">
  6. <span>订单明细</span>
  7. <el-link
  8. type="primary"
  9. @click="$emit('clear')">
  10. 清空订单
  11. </el-link>
  12. </div>
  13. <div>
  14. <div class="pay-channel-wrap">
  15. <label class="text">支付方式:</label>
  16. <el-radio-group
  17. fill="#379143"
  18. class="tags-btn"
  19. @change="$localStore.set('group_payment',$event)"
  20. v-model="payChannel"
  21. border>
  22. <el-radio
  23. border
  24. v-for="val in payChannelOptions"
  25. :key="val"
  26. :value="val"
  27. :label="val"></el-radio>
  28. </el-radio-group>
  29. </div>
  30. <div class="btn-wrap">
  31. <div>
  32. <span class="item">实付金额:
  33. <el-input-number
  34. :min="0"
  35. :precision="2"
  36. :controls="false"
  37. v-model.number="actualMoney"></el-input-number>
  38. </span>
  39. <span class="item">备注:
  40. <el-input
  41. clearable
  42. v-model="remark"
  43. style="width:200px"></el-input>
  44. </span>
  45. <span class="item">图片备注:
  46. <el-button
  47. type="primary"
  48. size="small"
  49. icon="el-icon-edit"
  50. @click="showUploadImgDialog"
  51. >
  52. 编辑查看
  53. </el-button>
  54. </span>
  55. </div>
  56. <el-button
  57. type="primary"
  58. class="warn-btn item"
  59. :disabled="value.length===0"
  60. @click="handleConfirm">
  61. 确认出票
  62. </el-button>
  63. </div>
  64. <div class="btn-wrap">
  65. <span class="item price">总数:<b>{{ totalCount }}</b> 张</span>
  66. <span class="item price">总价:<b>{{ orderPrice }}</b> 元</span>
  67. <span class="item price">折扣:<b>{{ discount }}</b> 折</span>
  68. <span class="item price">折后总价:<b>{{ finalPrice }}</b> 元</span>
  69. <span class="item price">{{ payBack>0?'找零':'还需支付' }}:<b>{{ Math.abs(payBack) }}</b> 元</span>
  70. <span class="item">
  71. <PrintSmallTicketCheckbox v-model="autoPrintSmallTicket"></PrintSmallTicketCheckbox>
  72. <el-checkbox
  73. v-model="autoPrint"
  74. style="margin:10px"
  75. @change="handleAutoPrintChange"
  76. >
  77. 自动打印
  78. </el-checkbox>
  79. </span>
  80. </div>
  81. </div>
  82. <el-table
  83. border
  84. :data="value">
  85. <el-table-column
  86. prop="ticketName"
  87. label="票种名称"
  88. width="180">
  89. </el-table-column>
  90. <el-table-column label="游玩日期">
  91. <template slot-scope="scope">
  92. {{ scope.row.payDateBegin | formatDate }}
  93. </template>
  94. </el-table-column>
  95. <el-table-column
  96. prop="count"
  97. label="数量">
  98. </el-table-column>
  99. <el-table-column
  100. prop="price"
  101. label="单价">
  102. </el-table-column>
  103. <!-- <el-table-column
  104. prop="total"
  105. label="小计">
  106. </el-table-column> -->
  107. <el-table-column
  108. label="操作"
  109. width="140">
  110. <template slot-scope="scope">
  111. <el-button
  112. @click="handleDelete(scope.row)"
  113. type="text">
  114. 删除
  115. </el-button>
  116. <el-button
  117. @click="showTouristList(scope.row)"
  118. type="text">
  119. 门票列表
  120. </el-button>
  121. </template>
  122. </el-table-column>
  123. </el-table>
  124. <ConfirmMingtou
  125. :discount="discount"
  126. :remark="remark"
  127. :tickets="tickets"
  128. :order-items="value"
  129. :form-data="formData"
  130. :order-price="orderPrice"
  131. :final-price="finalPrice"
  132. :total-count="totalCount"
  133. :pay-channel="payChannel"
  134. @complete="handleComplete"
  135. ref="confirm"></ConfirmMingtou>
  136. <!-- 图片备注 -->
  137. <UploadImgList
  138. :picture-remarks="pictureRemarks"
  139. :update-remarks="updateRemarks"
  140. ref="uploadImgDialog">
  141. </UploadImgList>
  142. <!-- 游客列表 -->
  143. <TouristList
  144. :check-face="formData.checkWay === 4"
  145. :check-id="formData.checkWay === 3"
  146. :check-ticket-no="formData.checkWay === 5"
  147. :tourist-list="touristList"
  148. :update-tourist="updateTourist"
  149. ref="touristList"></TouristList>
  150. </el-card>
  151. </template>
  152. <script>
  153. import mixin from './mixin'
  154. import { randomString } from '@/utils'
  155. import ConfirmMingtou from './ConfirmMingtou'
  156. import PrintSmallTicketCheckbox from '../common/PrintSmallTicketCheckbox'
  157. import UploadImgList from '../common/uploadImgList'
  158. import orderItemMixin from '../common/orderItemMixin'
  159. export default {
  160. mixins: [mixin, orderItemMixin],
  161. props: {
  162. value: {
  163. type: Array,
  164. default: () => []
  165. }
  166. },
  167. components: {
  168. ConfirmMingtou,
  169. PrintSmallTicketCheckbox,
  170. UploadImgList
  171. },
  172. computed: {
  173. payBack () {
  174. if (this.actualMoney === undefined) {
  175. return -this.finalPrice
  176. } else {
  177. return (this.actualMoney - this.finalPrice).toFixed(2)
  178. }
  179. },
  180. totalCount () {
  181. return this.value.reduce((init, item) => {
  182. return init + item.count
  183. }, 0)
  184. },
  185. orderPrice () {
  186. return this.value.reduce((init, item) => {
  187. let price = this.$NP.times(item.count, item.originalPrice)
  188. return this.$NP.plus(init, price)
  189. }, 0)
  190. },
  191. finalPrice () {
  192. let price = this.tickets.reduce((init, item) => {
  193. return this.$NP.plus(init, item.discountPrice)
  194. }, 0)
  195. return this.$NP.round(price, 2)
  196. },
  197. tickets () {
  198. return this.value.reduce((init, item) => {
  199. item.tickets.forEach(t => {
  200. t.discountPrice = this.$NP.times(item.price, this.$NP.divide(this.discount, 10))
  201. })
  202. return init.concat(item.tickets)
  203. }, [])
  204. }
  205. },
  206. data () {
  207. return {
  208. payChannel: '',
  209. remark: '',
  210. actualMoney: 0,
  211. formData: {},
  212. pictureRemarks: [{
  213. idKey: randomString(),
  214. url: '',
  215. remark: ''
  216. }],
  217. discount: 0,
  218. autoPrint: this.$localStore.get('autoPrint') || false,
  219. autoPrintSmallTicket: this.$localStore.get('autoPrintSmallTicket')
  220. }
  221. },
  222. methods: {
  223. // 更新图片备注列表
  224. updateRemarks (data) {
  225. this.pictureRemarks = data
  226. },
  227. // 显示图片备注弹窗
  228. showUploadImgDialog () {
  229. this.$refs.uploadImgDialog.show()
  230. },
  231. changePayChannel (n) {
  232. if (this.confirmVisible) return
  233. let i = this.payChannelOptions.findIndex(channel => channel === this.payChannel)
  234. let l = this.payChannelOptions.length
  235. let j = (i - n + l) % l
  236. this.payChannel = this.payChannelOptions[j]
  237. },
  238. PageUp () {
  239. this.changePayChannel(1)
  240. },
  241. PageDown () {
  242. this.changePayChannel(-1)
  243. },
  244. handleDelete (item) {
  245. this.$confirm('确定删除吗?', '提示', {
  246. confirmButtonText: '确定',
  247. cancelButtonText: '取消',
  248. type: 'warning'
  249. }).then(() => {
  250. this.$message({
  251. type: 'success',
  252. message: '删除成功!'
  253. })
  254. const idx = this.value.findIndex(i => i.keyId === item.keyId)
  255. this.value.splice(idx, 1)
  256. })
  257. },
  258. handleAutoPrintChange (val) {
  259. this.$localStore.set('autoPrint', val)
  260. },
  261. handleComplete () {
  262. this.$emit('clear')
  263. this.remark = ''
  264. this.$localStore.get('defaultPayWay') && this.setPayWay()
  265. this.$parent.$parent.$refs.orderRecord.getOrderList()
  266. },
  267. setPayWay () {
  268. const payment = this.$localStore.get('defaultPayWay') || this.payChannelOptions[0]
  269. this.payChannel = this.payChannelOptions.indexOf(payment) < 0 ? this.payChannelOptions[0] : payment
  270. }
  271. },
  272. watch: {
  273. finalPrice (val) {
  274. this.actualMoney = val
  275. },
  276. payChannelOptions: {
  277. handler (val) {
  278. if (val.length) {
  279. this.setPayWay()
  280. }
  281. },
  282. immediate: true
  283. }
  284. },
  285. mounted () {
  286. this.payChannel = this.$localStore.get('defaultPayWay') || this.$localStore.get('group_payment') || this.payChannelOptions[0]
  287. }
  288. }
  289. </script>
  290. <style lang="scss" scoped>
  291. .item {
  292. margin-left: 20px;
  293. }
  294. .price-info {
  295. padding: 10px 0; text-align: right; background: #fff;
  296. }
  297. .btn-wrap {
  298. display: flex; width: 100%; margin-bottom: 10px; font-size: 14px; justify-content: space-between; align-items: center;
  299. .el-input {
  300. display: inline-block; width: 100px;
  301. }
  302. }
  303. </style>