create.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <div class="create-order-content-container">
  3. <ModuleCard class="create-order-module" title="基本信息">
  4. <BaseInfo ref="moduleBaseInfo" />
  5. </ModuleCard>
  6. <ModuleCard class="create-order-module" title="产品信息">
  7. <ProductInfoModule ref="moduleProductInfo" />
  8. </ModuleCard>
  9. <ModuleCard class="create-order-module" title="协议信息">
  10. <ContractInfoModule ref="moduleContractInfo" />
  11. </ModuleCard>
  12. <!-- 合同金额为0,则不展示回款计划模块 -->
  13. <ModuleCard class="create-order-module" title="回款计划" v-if="totalMoney > 0">
  14. <PaymentPlanModule ref="modulePaymentPlan" :totalMoney="totalMoney" :contractStatus="pageForm.agreeStatus" />
  15. </ModuleCard>
  16. <ModuleCard class="create-order-module" title="业绩归属">
  17. <PerformanceBelongsModule ref="modulePerformanceBelong" setDefaultUser />
  18. </ModuleCard>
  19. <ModuleCard class="create-order-module" title="其他信息">
  20. <OtherInfoModule ref="moduleOtherInfo" />
  21. </ModuleCard>
  22. </div>
  23. </template>
  24. <script>
  25. import ModuleCard from '../ui/ModuleCard.vue'
  26. import BaseInfo from './baseInfoModule.vue'
  27. import PaymentPlanModule from './paymentPlanModule.vue'
  28. import ProductInfoModule from './productInfoModule.vue'
  29. import PerformanceBelongsModule from './performanceBelongsModule.vue'
  30. import OtherInfoModule from './otherInfoModule.vue'
  31. import ContractInfoModule from './contractInfoModule.vue'
  32. import { mapState } from 'vuex'
  33. export default {
  34. name: 'CreateOrderContent',
  35. components: {
  36. ModuleCard,
  37. BaseInfo,
  38. PaymentPlanModule,
  39. ProductInfoModule,
  40. OtherInfoModule,
  41. PerformanceBelongsModule,
  42. ContractInfoModule,
  43. },
  44. data() {
  45. return {
  46. totalMoney: 1
  47. }
  48. },
  49. computed: {
  50. ...mapState({
  51. pageForm: state => state.order.pageForm,
  52. }),
  53. },
  54. created() {
  55. this.$store.dispatch('order/getSelectOptions')
  56. },
  57. methods: {
  58. async validate() {
  59. const refsArr = this.getFormRefs()
  60. const asyncArr = refsArr.map(r => r?.validate())
  61. const allPromise = Promise.all(asyncArr)
  62. try {
  63. await allPromise
  64. console.log('success')
  65. } catch (error) {
  66. console.log('error', error)
  67. } finally {
  68. console.log('finally', allPromise)
  69. }
  70. },
  71. getFormRefs() {
  72. const refs = this.$refs
  73. const refsArr = []
  74. for (const key in refs) {
  75. if (key.startsWith('module')) {
  76. refsArr.push(refs[key])
  77. }
  78. }
  79. return refsArr
  80. },
  81. getState() {
  82. const refsArr = this.getFormRefs()
  83. const result = {}
  84. refsArr.forEach(r => {
  85. const t = r?.getState()
  86. Object.assign(result, t)
  87. })
  88. return result
  89. },
  90. setState() {
  91. const refsArr = this.getFormRefs()
  92. console.log('setState', refsArr)
  93. },
  94. }
  95. }
  96. </script>
  97. <style lang="scss" scoped>
  98. ::v-deep {
  99. .el-form-item {
  100. margin-bottom: 12px;
  101. }
  102. .el-form-item__label {
  103. color: #686868;
  104. }
  105. .el-form-item__error {
  106. padding-top: 0;
  107. }
  108. .el-select-w100.el-select {
  109. width: 100%;
  110. }
  111. }
  112. .create-order-content-container {
  113. padding-top: 20px;
  114. }
  115. .create-order-module {
  116. font-size: 14px;
  117. }
  118. </style>