OrderActions.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <div class="order-actions-container">
  3. <div class="order-actions-list">
  4. <div
  5. v-for="(item, index) in actionList"
  6. :key="index"
  7. >
  8. <div
  9. :class="{ 'order-action-item-active': item.active }"
  10. class="order-action-item"
  11. v-if="item.show"
  12. >
  13. <div class="order-action-text" @click="item.action">{{ item.text }}</div>
  14. </div>
  15. </div>
  16. </div>
  17. <el-dialog
  18. class="edit-dialog"
  19. title="编辑订单"
  20. width="90%"
  21. :close-on-click-modal="false"
  22. :visible.sync="editdialogVisible">
  23. <EditOrder ref="editOrderRef" type="edit" :order-code="orderCode"/>
  24. <div class="button-group" slot="footer">
  25. <el-button size="medium" class="submit-button submit" type="primary" :loading="dialogSubmitLoading" @click="doCloseCreateModel('submit')">提交</el-button>
  26. <el-button size="medium" class="submit-button stash" type="primary" plain :loading="dialogSubmitLoading" @click="doCloseCreateModel('stash')">暂存</el-button>
  27. <el-button size="medium" class="submit-button cancel" plain @click="doCloseCreateModel('close')">取消</el-button>
  28. </div>
  29. </el-dialog>
  30. <Dialog
  31. ref="cancelOrderDialog"
  32. customClass="cancel-order-dialog"
  33. title="作废订单"
  34. :visible.sync="cancelOrderVisible"
  35. center
  36. width="360px"
  37. @confirm="cancelOrderConfirm"
  38. @cancel="cancelOrderCancel"
  39. >
  40. <div class="cancel-order-content">
  41. <span>确认作废订单吗?</span>
  42. </div>
  43. </Dialog>
  44. <Dialog
  45. ref="downloadProtocolDialog"
  46. customClass="download-protocol-dialog"
  47. title="不支持下载电子协议"
  48. :visible.sync="downloadProtocolVisible"
  49. :show-cancel-button="false"
  50. confirm-button-text="我知道了"
  51. center
  52. width="360px"
  53. @confirm="downloadProtocolConfirm"
  54. @cancel="downloadProtocolCancel"
  55. >
  56. <div class="cancel-order-content">
  57. <span>该订单不支持下载电子协议</span>
  58. </div>
  59. </Dialog>
  60. <!-- 客户扫码自助开票 -->
  61. <new-set-order-info :show-content="2" :show-dialog="showDialog" :order-info="orderDetail?.orderData" title="客户自助扫码开票"
  62. @close="closeComDialog">
  63. </new-set-order-info>
  64. <!-- 开票二维码 -->
  65. <new-set-order-info ref="invoiceRef" :show-content="4" :show-dialog="showInvoiceDialog" :order-info="orderDetail"
  66. title="开票二维码" @close="closeComDialog">
  67. <div style="display:flex;flex-direction:column;" slot="content">
  68. <span>订单编号:{{selectInvoice.invoice_order_code}}</span>
  69. <span>开票金额合计:{{selectInvoice.invoice_money / 100}}元</span>
  70. </div>
  71. </new-set-order-info>
  72. <new-detail-model v-if="showDetailModel" ref="detailModelRef" :orderDetail="orderDetailInfo"></new-detail-model>
  73. </div>
  74. </template>
  75. <script>
  76. import { mapActions } from 'vuex'
  77. import Dialog from '@/components/Dialog'
  78. import EditOrder from '../edit.vue'
  79. import {
  80. ajaxGetContractPdf,
  81. ajaxOrderCancellation
  82. } from '@/api/modules/'
  83. import newSetOrderInfo from '../newSetOrderInfo.vue'
  84. import newDetailModel from '../nweDetailModel.vue'
  85. export default {
  86. name: 'OrderActions',
  87. components: {
  88. Dialog,
  89. EditOrder,
  90. newSetOrderInfo,
  91. newDetailModel
  92. },
  93. props: {
  94. orderDetail: {
  95. type: Object,
  96. default() {
  97. return {}
  98. }
  99. }
  100. },
  101. data() {
  102. return {
  103. cancelOrderVisible: false,
  104. downloadProtocolVisible: false,
  105. editdialogVisible: false,
  106. dialogSubmitLoading: false,
  107. orderCode: '',
  108. showDialog: false,
  109. showInvoiceDialog: false,
  110. orderDetailInfo: {},
  111. selectInvoice: {}
  112. }
  113. },
  114. created () {
  115. const { id } = this.$route.params
  116. this.orderCode = id
  117. },
  118. watch: {
  119. orderDetail: {
  120. handler(newVal) {
  121. if (newVal && newVal.orderData) {
  122. this.orderDetailInfo = newVal.orderData
  123. }
  124. },
  125. deep: true,
  126. immediate: true
  127. }
  128. },
  129. computed: {
  130. showDetailModel() {
  131. return Object.keys(this.orderDetailInfo).length > 0
  132. },
  133. actionList () {
  134. return [
  135. {
  136. text: '编辑订单',
  137. active: true,
  138. action: () => {
  139. this.editOrder()
  140. },
  141. show: true
  142. },
  143. {
  144. text: '作废订单',
  145. active: false,
  146. action: () => {
  147. this.cancelOrder()
  148. },
  149. show: this.showCancelButton()
  150. },
  151. {
  152. text: '下载电子协议',
  153. active: false,
  154. action: () => {
  155. this.downloadProtocol()
  156. },
  157. show: true
  158. },
  159. {
  160. text: '微信/支付宝付款码',
  161. active: false,
  162. action: () => {
  163. this.wxAliPay()
  164. },
  165. show: this.isShowPayBtn()
  166. },
  167. {
  168. text: '客户自助扫码开票',
  169. active: false,
  170. action: () => {
  171. this.scanCodeInvoice()
  172. },
  173. show: true
  174. },
  175. // {
  176. // text: '协议归档',
  177. // active: false,
  178. // action: () => {
  179. // this.archiveProtocol()
  180. // }
  181. // }
  182. ]
  183. }
  184. },
  185. methods: {
  186. ...mapActions('order', ['resetPageInfo']),
  187. // 编辑订单相关逻辑开始
  188. editOrder() {
  189. this.editdialogVisible = true;
  190. },
  191. doCloseCreateModel(type = 'close') {
  192. switch (type) {
  193. case 'close':
  194. this.editdialogVisible = false;
  195. this.resetPageInfo()
  196. break;
  197. case 'submit':
  198. case 'stash':
  199. this.dialogSubmitLoading = true;
  200. const method = type === 'submit' ? 'submit' : 'stash';
  201. this.$refs.editOrderRef[method]()
  202. .then(() => {
  203. this.editdialogVisible = false;
  204. })
  205. .catch(e => {
  206. console.warn(e);
  207. // 这里可以根据需要处理错误,例如显示错误信息
  208. })
  209. .finally(() => {
  210. this.dialogSubmitLoading = false;
  211. });
  212. break;
  213. }
  214. },
  215. // 编辑订单相关逻辑结束
  216. // 作废订单相关逻辑开始
  217. showCancelButton () {
  218. const status = !this.orderDetailInfo.order_status || this.orderDetailInfo.order_status === 0
  219. const order_channel = this.orderDetailInfo.order_channel === 'xdqd04'
  220. const is_backstage_order = this.orderDetailInfo.is_backstage_order === 1
  221. // 订单状态为未完成且订单渠道为xdqd04或者is_backstage_order为1时显示
  222. const Bool = !status && (order_channel || is_backstage_order)
  223. console.log('showCancelButton', Bool)
  224. return status && (order_channel || is_backstage_order)
  225. },
  226. cancelOrder() {
  227. console.log('cancelOrder')
  228. this.cancelOrderVisible = true
  229. },
  230. async cancelOrderConfirm() {
  231. this.cancelOrderVisible = false
  232. const { error_code: code, error_msg: msg } = await ajaxOrderCancellation({ orderCode: this.orderCode })
  233. if (code === 0) {
  234. this.$message.success('作废订单成功')
  235. this.$emit('refresh')
  236. } else {
  237. this.$message.error(msg)
  238. }
  239. },
  240. cancelOrderCancel() {
  241. this.cancelOrderVisible = false
  242. },
  243. // 作废订单相关逻辑结束
  244. // 下载电子协议相关逻辑开始
  245. async downloadProtocol() {
  246. const { error_code: code, data} = await ajaxGetContractPdf({ orderCode: this.orderCode })
  247. if (code === 0) {
  248. console.log('downloadProtocol', data)
  249. } else {
  250. this.downloadProtocolVisible = true
  251. }
  252. },
  253. downloadProtocolConfirm() {
  254. this.downloadProtocolVisible = false
  255. },
  256. downloadProtocolCancel() {
  257. this.downloadProtocolVisible = false
  258. },
  259. // 下载电子协议相关逻辑结束
  260. // 微信/支付宝付款码相关逻辑开始
  261. wxAliPay() {
  262. this.$refs.detailModelRef.paymentCodeShow = true;
  263. },
  264. // 是否展示微信/支付宝按钮
  265. isShowPayBtn() {
  266. // 后台创建的订单
  267. const backendOrder = this.orderDetailInfo.is_backstage_order === 1
  268. // 汇款状态为不是全部回款的
  269. const returnStatus = this.orderDetailInfo.return_status !== 1
  270. // 订单审核状态为已通过
  271. const auditStatus = this.orderDetailInfo.audit_status === 3
  272. // 订单状态为“未完成”或“已完成”
  273. const orderStatus = this.orderDetailInfo.order_status === 0 || this.orderDetailInfo.order_status === 1
  274. // 有操作订单权限
  275. // const authSttatus = this.orDetails
  276. return backendOrder && returnStatus && auditStatus && orderStatus
  277. },
  278. // 微信/支付宝付款码相关逻辑结束
  279. // 客户扫码自助开票相关逻辑开始
  280. /**
  281. * 扫描发票二维码的方法
  282. */
  283. // 关闭弹框
  284. closeComDialog() {
  285. this.showDialog = false
  286. this.showInvoiceDialog = false
  287. },
  288. scanCodeInvoice() {
  289. console.log('scanCodeInvoice')
  290. this.showDialog = true;
  291. },
  292. // archiveProtocol() {
  293. // console.log('archiveProtocol')
  294. // }
  295. }
  296. }
  297. </script>
  298. <style lang="scss" scoped>
  299. .order-actions-container {
  300. .order-actions-list {
  301. display: flex;
  302. flex-wrap: wrap;
  303. align-items: center;
  304. .order-action-item {
  305. display: flex;
  306. align-items: center;
  307. justify-content: center;
  308. padding: 4px 15px;
  309. margin-right: 12px;
  310. min-width: 90px;
  311. font-size: 14px;
  312. border: 1px solid #E0E0E0;
  313. border-radius: 4px;
  314. cursor: pointer;
  315. background-color: #fff;
  316. &-active {
  317. border: 1px solid #2ABED1;
  318. color: #2ABED1;
  319. }
  320. }
  321. }
  322. .cancel-order-dialog {
  323. .cancel-order-content {
  324. text-align: center;
  325. font-size: 14px;
  326. color: #686868;
  327. }
  328. }
  329. .button-group {
  330. text-align: center;
  331. }
  332. ::v-deep {
  333. .download-protocol-dialog.el-dialog {
  334. .dialog-footer {
  335. display: flex;
  336. justify-content: center;
  337. }
  338. .action-button.confirm {
  339. flex: none;
  340. width: 120px;
  341. }
  342. }
  343. }
  344. }
  345. </style>