panhui vor 4 Jahren
Ursprung
Commit
6f84fcee6c

+ 18 - 14
src/main/vue/src/components/PackageEdit.vue

@@ -346,7 +346,9 @@
                 </div>
             </el-form-item> -->
             <el-form-item>
-                <el-button @click="onSave" :loading="saving" type="primary">保存</el-button>
+                <el-button @click="onSave" :loading="saving" type="primary">{{
+                    packageId ? '保存' : '新建'
+                }}</el-button>
                 <!-- <el-button @click="onSave" :loading="saving" type="primary" v-else>下一步</el-button> -->
                 <el-button @click="onDelete" :loading="saving" type="danger" v-if="formData.id">删除 </el-button>
                 <el-button @click="$router.go(-1)">取消</el-button>
@@ -571,6 +573,7 @@ export default {
             if (typeof data.note === 'undefined') {
                 data.note = this.note;
             }
+            let first = !data.id;
             this.saving = true;
             this.$http
                 .post('/package/save', data, { body: 'json' })
@@ -578,21 +581,22 @@ export default {
                     this.saving = false;
                     // this.$message.success('成功');
                     this.packageId = res.id;
+                    let attractionsId = res.attractionsId;
                     this.$nextTick(() => {
-                        this.$http.post('/stock/batchSave', {
-                            stocks: this.saveOtherJson
-                        });
-                        this.$message.success('成功');
-                        this.$router.go(-1);
-                    });
-                    this.$emit('next', 'second');
-                    this.$router.replace({
-                        name: 'PackageEdit',
-                        query: {
-                            id: res.id,
-                            attractionsId: res.attractionsId
-                        }
+                        this.$http
+                            .post('/stock/batchSave', {
+                                stocks: this.saveOtherJson
+                            })
+                            .then(res => {
+                                if (first) {
+                                    this.$message.success('成功');
+                                    this.$router.go(-1);
+                                } else {
+                                    this.$emit('save', 'page1');
+                                }
+                            });
                     });
+                    // this.$emit('next', 'second');
                 })
                 .catch(e => {
                     console.log(e);

+ 38 - 31
src/main/vue/src/components/PackageEdit2.vue

@@ -53,22 +53,7 @@
 export default {
     name: 'PackageEdit',
     created() {
-        if (this.$route.query.id) {
-            this.packageId = this.$route.query.id;
-            this.$http
-                .get('package/get/' + this.$route.query.id)
-                .then(res => {
-                    this.formData = res;
-                    this.list = JSON.parse(res.workflow) || [];
-                })
-                .catch(e => {
-                    console.log(e);
-                    this.$message.error(e.error);
-                });
-            // this.$http.get('/stock/byPackageId', { packageId: this.$route.query.id }).then(res => {
-            //     this.stockList = res;
-            // });
-        }
+        this.init();
         // this.$http
         //     .post('/attractions/all', { size: 1000, query: { del: false, brand: false } }, { body: 'json' })
         //     .then(res => {
@@ -181,6 +166,24 @@ export default {
         }
     },
     methods: {
+        init() {
+            if (this.$route.query.id) {
+                this.packageId = this.$route.query.id;
+                this.$http
+                    .get('package/get/' + this.$route.query.id)
+                    .then(res => {
+                        this.formData = res;
+                        this.list = JSON.parse(res.workflow) || [];
+                    })
+                    .catch(e => {
+                        console.log(e);
+                        this.$message.error(e.error);
+                    });
+                // this.$http.get('/stock/byPackageId', { packageId: this.$route.query.id }).then(res => {
+                //     this.stockList = res;
+                // });
+            }
+        },
         onSave() {
             if (this.list.length <= 0) {
                 this.$refs.form.validate(valid => {
@@ -204,6 +207,9 @@ export default {
         },
         submit() {
             let data = { ...this.formData };
+            if (this.packageId) {
+                data.id = this.packageId;
+            }
             data.workflow = JSON.stringify(this.list);
             this.saving = true;
             this.$http
@@ -212,21 +218,22 @@ export default {
                     this.saving = false;
                     // this.$message.success('成功');
                     this.packageId = res.id;
-                    this.$nextTick(() => {
-                        // this.$http.post('/stock/batchSave', {
-                        //     stocks: this.saveOtherJson
-                        // });
-                        this.$message.success('成功');
-                        this.$router.go(-1);
-                    });
-                    this.$emit('next', 'second');
-                    this.$router.replace({
-                        name: 'PackageEdit',
-                        query: {
-                            id: res.id,
-                            attractionsId: res.attractionsId
-                        }
-                    });
+                    this.$emit('save', 'page2');
+                    // this.$nextTick(() => {
+                    //     // this.$http.post('/stock/batchSave', {
+                    //     //     stocks: this.saveOtherJson
+                    //     // });
+                    //     this.$message.success('成功');
+                    //     this.$router.go(-1);
+                    // });
+                    // this.$emit('next', 'second');
+                    // this.$router.replace({
+                    //     name: 'PackageEdit',
+                    //     query: {
+                    //         id: res.id,
+                    //         attractionsId: res.attractionsId
+                    //     }
+                    // });
                 })
                 .catch(e => {
                     console.log(e);

+ 34 - 30
src/main/vue/src/components/PackageEdit3.vue

@@ -47,21 +47,7 @@
 export default {
     name: 'PackageEdit',
     created() {
-        if (this.$route.query.id) {
-            this.packageId = this.$route.query.id;
-            this.$http
-                .get('package/get/' + this.$route.query.id)
-                .then(res => {
-                    this.formData = res;
-                })
-                .catch(e => {
-                    console.log(e);
-                    this.$message.error(e.error);
-                });
-            // this.$http.get('/stock/byPackageId', { packageId: this.$route.query.id }).then(res => {
-            //     this.stockList = res;
-            // });
-        }
+        this.init();
         // this.$http
         //     .post('/attractions/all', { size: 1000, query: { del: false, brand: false } }, { body: 'json' })
         //     .then(res => {
@@ -194,6 +180,23 @@ export default {
         }
     },
     methods: {
+        init() {
+            if (this.$route.query.id) {
+                this.packageId = this.$route.query.id;
+                this.$http
+                    .get('package/get/' + this.$route.query.id)
+                    .then(res => {
+                        this.formData = res;
+                    })
+                    .catch(e => {
+                        console.log(e);
+                        this.$message.error(e.error);
+                    });
+                // this.$http.get('/stock/byPackageId', { packageId: this.$route.query.id }).then(res => {
+                //     this.stockList = res;
+                // });
+            }
+        },
         onSave() {
             this.$refs.form.validate(valid => {
                 if (valid) {
@@ -221,21 +224,22 @@ export default {
                     this.saving = false;
                     // this.$message.success('成功');
                     this.packageId = res.id;
-                    this.$nextTick(() => {
-                        // this.$http.post('/stock/batchSave', {
-                        //     stocks: this.saveOtherJson
-                        // });
-                        this.$message.success('成功');
-                        this.$router.go(-1);
-                    });
-                    this.$emit('next', 'second');
-                    this.$router.replace({
-                        name: 'PackageEdit',
-                        query: {
-                            id: res.id,
-                            attractionsId: res.attractionsId
-                        }
-                    });
+                    this.$emit('save', 'page3');
+                    // this.$nextTick(() => {
+                    //     // this.$http.post('/stock/batchSave', {
+                    //     //     stocks: this.saveOtherJson
+                    //     // });
+                    //     this.$message.success('成功');
+                    //     this.$router.go(-1);
+                    // });
+                    // this.$emit('next', 'second');
+                    // this.$router.replace({
+                    //     name: 'PackageEdit',
+                    //     query: {
+                    //         id: res.id,
+                    //         attractionsId: res.attractionsId
+                    //     }
+                    // });
                 })
                 .catch(e => {
                     console.log(e);

+ 21 - 6
src/main/vue/src/views/PackageEdit.vue

@@ -2,13 +2,13 @@
     <div class="edit-view">
         <el-tabs class="my-tabs" v-model="active">
             <el-tab-pane label="基本信息" name="first">
-                <PackageEdit @next="goNext" />
+                <PackageEdit ref="page1" @next="goNext" @save="save" />
             </el-tab-pane>
-            <el-tab-pane label="详细页" name="second">
-                <PackageEdit2 @next="goNext" />
+            <el-tab-pane label="详细页" name="second" v-if="id">
+                <PackageEdit2 ref="page2" @next="goNext" @save="save" />
             </el-tab-pane>
-            <el-tab-pane label="分享素材" name="third">
-                <PackageEdit3 />
+            <el-tab-pane label="分享素材" name="third" v-if="id">
+                <PackageEdit3 ref="page3" @save="save" />
             </el-tab-pane>
             <!-- <el-tab-pane label="套餐内容" :disabled="!id" name="second">
                 <PackageGoodsTable ref="setGoodsList" />
@@ -61,15 +61,30 @@ export default {
             id: 0,
             formData: {},
             stockList: [],
-            saving: false
+            saving: false,
+            saveList: []
         };
     },
     // mounted() {
     //     this.updateType();
     // },
     methods: {
+        save(page) {
+            this.saveList.push(page);
+            let pageName = ['page1', 'page2', 'page3'].find(item => {
+                return !this.saveList.includes(item);
+            });
+            if (pageName) {
+                this.$refs[pageName].onSave();
+            } else {
+                this.$message.success('成功');
+                this.$router.go(-1);
+            }
+        },
         goNext(page) {
             this.active = page;
+            this.$refs.page2.init();
+            this.$refs.page3.init();
         },
         updateType() {
             let type = this.$route.query.type;