guhongwei 4 年之前
父节点
当前提交
12eee0a7c6
共有 1 个文件被更改,包括 26 次插入17 次删除
  1. 26 17
      src/views/kjpdCenter/basicInfo/index.vue

+ 26 - 17
src/views/kjpdCenter/basicInfo/index.vue

@@ -25,7 +25,7 @@
                 </el-col>
                 <el-col :span="24">
                   <el-select v-model="form.type" placeholder="请选择类型">
-                    <el-option v-for="item in options" :key="item.name" :label="item.name" :value="item.name"> </el-option>
+                    <el-option v-for="item in typelist" :key="item.name" :label="item.name" :value="item.id"> </el-option>
                   </el-select>
                 </el-col>
               </el-form-item>
@@ -81,7 +81,7 @@
               </el-form-item>
             </el-col>
             <el-col :span="24" class="btn">
-              <el-button type="primary" @click="onSubmit(form)">提交修改</el-button>
+              <el-button type="primary" @click="onSubmit()">提交修改</el-button>
             </el-col>
           </el-form>
         </el-col>
@@ -93,7 +93,7 @@
 <script>
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: markettype } = createNamespacedHelpers('markettype');
-
+const { mapActions: channel } = createNamespacedHelpers('channel');
 export default {
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -103,31 +103,40 @@ export default {
   components: {},
   data: function() {
     return {
+      // 类型
+      typelist: [],
       form: {},
-      options: [],
     };
   },
   created() {
     this.search();
   },
   methods: {
-    ...markettype(['fetch', 'update', 'query']),
+    ...markettype(['query']),
+    ...channel(['fetch', 'update']),
     async search() {
-      const res1 = await this.query({ category: '04' });
-      if (this.$checkRes(res1)) {
-        this.$set(this, `options`, res1.data);
+      let res = await this.query({ category: '04' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `typelist`, res.data);
+      }
+      let data = this.user;
+      res = await this.fetch(data.id);
+      if (this.$checkRes(res)) {
+        this.$set(this, `form`, res.data);
       }
-      this.form = this.user;
-      const res = await this.fetch(this.user.type);
-      this.$set(this.form, `type`, res.data.name);
     },
     //提交修改
-    onSubmit(form) {
-      if (form) {
-        this.$message({
-          message: '修改成功',
-          type: 'success',
-        });
+    async onSubmit() {
+      let data = this.form;
+      if (data.id) {
+        const res = await this.update(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '修改成功',
+            type: 'success',
+          });
+          this.search();
+        }
       }
     },
   },