Преглед на файлове

feat: 订单创建组件提供内部方法

cuiyalong преди 3 месеца
родител
ревизия
c7aa982ce2
променени са 1 файла, в които са добавени 14 реда и са изтрити 12 реда
  1. 14 12
      src/views/create-order/components/create.vue

+ 14 - 12
src/views/create-order/components/create.vue

@@ -30,7 +30,7 @@ import ProductInfoModule from './productInfoModule.vue'
 import PerformanceBelongsModule from './performanceBelongsModule.vue'
 import OtherInfoModule from './otherInfoModule.vue'
 import ContractInfoModule from './contractInfoModule.vue'
-import { mapState, mapGetters } from 'vuex'
+import { mapState, mapGetters, mapActions } from 'vuex'
 
 export default {
   name: 'CreateOrderContent',
@@ -61,6 +61,7 @@ export default {
     this.$store.dispatch('order/getConfigWithReq')
   },
   methods: {
+    ...mapActions('order', ['createOrder']),
     async validate() {
       const refsArr = this.getFormRefs()
       const asyncArr = refsArr.map(r => r?.validate())
@@ -84,18 +85,19 @@ export default {
       }
       return refsArr
     },
-    getState() {
-      const refsArr = this.getFormRefs()
-      const result = {}
-      refsArr.forEach(r => {
-        const t = r?.getState()
-        Object.assign(result, t)
-      })
-      return result
+    async doSave(save) {
+      const id = await this.createOrder({ save })
+      if (id) {
+        this.$toast('订单创建成功')
+      }
     },
-    setState() {
-      const refsArr = this.getFormRefs()
-      console.log('setState', refsArr)
+    async submit() {
+      // 提交
+      await this.doSave(2)
+    },
+    async stash() {
+      // 暂存
+      await this.doSave(1)
     },
   }
 }