Browse Source

创建文章

aaa 4 years ago
parent
commit
c187517d9d
1 changed files with 30 additions and 27 deletions
  1. 30 27
      src/views/articleManagement/articleCreate.vue

+ 30 - 27
src/views/articleManagement/articleCreate.vue

@@ -116,9 +116,9 @@
 </template>
 
 <script>
-import { formatePathParams } from '@/filters';
+import { formatePathParams } from "@/filters";
 export default {
-  name: 'articleCreate',
+  name: "articleCreate",
   props: {},
   components: {
     // components: (reslove) => {
@@ -127,17 +127,17 @@ export default {
   },
   data() {
     return {
-      content: '输入内容',
+      content: "输入内容",
       //   展示预览
       previewVisible: false,
-      form: this.$form.createForm(this, { name: 'articleCreate' }),
+      form: this.$form.createForm(this, { name: "articleCreate" }),
       articleParentClassArr: [],
       articleChildClassArr: [],
       engineerTypeArray: [],
       articleParentClass: {},
       articleChildClass: {},
-      engineerType: '',
-      learnDate: '',
+      engineerType: "",
+      learnDate: ""
     };
   },
   created() {
@@ -157,8 +157,8 @@ export default {
     getArticleParentClass() {
       this.$_http
         .get(this.$_API.INTERFACE_GET_CATEGORIES)
-        .then((res) => {
-          console.log('--parent--' + JSON.stringify(res));
+        .then(res => {
+          console.log("--parent--" + JSON.stringify(res));
           this.articleParentClassArr = res.data;
           this.loading = false;
         })
@@ -176,8 +176,11 @@ export default {
             pathParamsData
           )
         )
-        .then((res) => {
-          this.articleChildClassArr = res.data;
+        .then(res => {
+          if (res && res.data.length !== 0) {
+            res.data.shift();
+            this.articleChildClassArr = res.data;
+          }
           this.loading = false;
         })
         .catch(() => {
@@ -188,7 +191,7 @@ export default {
     getEngineersWork() {
       this.$_http
         .get(this.$_API.INTERFACE_GET_ENGINEERINGWORK_LIST)
-        .then((res) => {
+        .then(res => {
           this.engineerTypeArray = res.data;
         });
     },
@@ -199,7 +202,7 @@ export default {
       // 子类选项清空
       this.articleChildClassArr = [];
       this.form.setFieldsValue({
-        articleChildClass: '',
+        articleChildClass: ""
       });
       // 获取子类的值
       this.getArticleChildClass();
@@ -221,44 +224,44 @@ export default {
       e.preventDefault();
 
       this.form.setFieldsValue({
-        articleParentClass: this.articleParentClass.name,
+        articleParentClass: this.articleParentClass.name
       });
       this.form.setFieldsValue({
-        articleChildClass: this.articleChildClass.name,
+        articleChildClass: this.articleChildClass.name
       });
       this.form.setFieldsValue({
-        engineerType: this.engineerType.name,
+        engineerType: this.engineerType.name
       });
 
       this.form.validateFields((err, values) => {
         if (!err) {
           // 新建文章
-          console.log('--submit--' + JSON.stringify(values));
+          console.log("--submit--" + JSON.stringify(values));
           let that = this;
           that.$confirm({
-            title: '新建文章',
+            title: "新建文章",
             content: `确认新建文章吗?`,
-            okText: '确认',
-            cancelText: '取消',
+            okText: "确认",
+            cancelText: "取消",
             onOk() {
               that.loading = true;
               let params = {
                 name: values.name,
                 description: values.description,
-                type: 'ARTICLE',
+                type: "ARTICLE",
                 contents: that.content,
                 tages: [that.learnDate],
                 engineerTypes: [that.engineerType],
-                links: [],
+                links: []
               };
               that.$_http
                 .post(that.$_API.INTERFACE_POST_ADMIN_MATERIALS, params)
-                .then((res) => {
-                  that.$message.success('新建文章成功');
-                  console.log('---上传文章----' + JSON.stringify(res));
+                .then(res => {
+                  that.$message.success("新建文章成功");
+                  console.log("---上传文章----" + JSON.stringify(res));
                 });
             },
-            onCancel() {},
+            onCancel() {}
           });
         }
       });
@@ -270,8 +273,8 @@ export default {
     // 关闭预览
     closepreview() {
       this.previewVisible = false;
-    },
-  },
+    }
+  }
 };
 </script>