edit.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <div class="edit-order-content-container">
  3. <createOrder ref="createOrder" :readonly="readonlyC" />
  4. </div>
  5. </template>
  6. <script>
  7. import createOrder from './create.vue'
  8. import { mapState, mapActions } from 'vuex'
  9. import { pageFormState } from '@/views/create-order/mixins'
  10. import { ajaxGetOrderDetail } from '@/api/modules'
  11. import { showMessage, showNotify } from '@/views/create-order/hooks/toast'
  12. const successMsgMap = {
  13. 1: '订单暂存成功',
  14. 2: '订单修改成功',
  15. }
  16. export default {
  17. name: 'EditOrderContent',
  18. mixins: [pageFormState],
  19. components: {
  20. createOrder,
  21. },
  22. props: {
  23. type: {
  24. type: String,
  25. default: 'edit',
  26. validator(v) {
  27. return ['edit', 'read'].includes(v)
  28. }
  29. },
  30. orderCode: {
  31. type: String,
  32. default: '',
  33. },
  34. readonly: {
  35. type: Boolean,
  36. default: false,
  37. },
  38. autoGetDetail: {
  39. type: Boolean,
  40. default: false,
  41. },
  42. },
  43. computed: {
  44. ...mapState({
  45. pageForm: state => state.order.pageForm,
  46. }),
  47. readonlyC() {
  48. return this.type === 'read' || this.readonly
  49. }
  50. },
  51. watch: {
  52. orderCode: {
  53. immediate: true,
  54. handler(n) {
  55. this.getOrderDetail(n)
  56. }
  57. }
  58. },
  59. methods: {
  60. ...mapActions('order', ['createOrder', 'resetPageInfo', 'restorePageInfo']),
  61. async getOrderDetail(orderCode) {
  62. if (!orderCode) return
  63. this.resetPageInfo()
  64. const { error_code: code, data, error_msg: msg } = await ajaxGetOrderDetail({ orderCode })
  65. if (code === 0) {
  66. if (data) {
  67. this.restorePageInfo(data)
  68. this.emitDetail(data)
  69. } else {
  70. showNotify({ message: '未查询到订单数据' })
  71. }
  72. } else {
  73. if (msg) {
  74. showNotify({ message: msg || '获取订单详情失败' })
  75. }
  76. }
  77. },
  78. emitDetail(order) {
  79. this.$emit('detail', order)
  80. },
  81. getFormRefs() {
  82. return this.$refs.createOrder.getFormRefs()
  83. },
  84. async doSave(save) {
  85. if (!this.orderCode) {
  86. return console.error('未传入orderCode')
  87. }
  88. const id = await this.createOrder({ save, orderCode: this.orderCode })
  89. if (id) {
  90. const msg = successMsgMap[save]
  91. this.$toast(msg)
  92. }
  93. },
  94. async submit() {
  95. // 提交
  96. await this.doSave(2)
  97. this.resetPageInfo()
  98. },
  99. async stash() {
  100. // 暂存
  101. await this.doSave(1)
  102. this.resetPageInfo()
  103. },
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. ::v-deep {
  109. .el-form-item {
  110. margin-bottom: 12px;
  111. }
  112. .el-form-item__label {
  113. color: #686868;
  114. }
  115. .el-form-item__error {
  116. padding-top: 0;
  117. }
  118. .el-select-w100.el-select {
  119. width: 100%;
  120. }
  121. .el-input__inner,
  122. .el-textarea__inner {
  123. color: $gray_10;
  124. // &:focus {
  125. // outline: 0;
  126. // box-shadow: 0 0 0 2px rgba($main,.2);
  127. // }
  128. }
  129. .form-item-container {
  130. font-size: 14px;
  131. line-height: 22px;
  132. .form-item-label {
  133. color: #686868;
  134. }
  135. .form-item-value {
  136. color: $gray_10;
  137. }
  138. }
  139. }
  140. .create-order-content-container {
  141. position: relative;
  142. &.readonly {
  143. // &::after,
  144. .readonly-overlay {
  145. content: '';
  146. position: absolute;
  147. left: 0;
  148. right: 0;
  149. top: 0;
  150. bottom: 0;
  151. z-index: 99999;
  152. /* 遮罩层显示时捕获所有指针事件 */
  153. pointer-events: auto;
  154. }
  155. }
  156. }
  157. .create-order-module {
  158. font-size: 14px;
  159. }
  160. </style>