Browse Source

修改文章

aaa 3 years ago
parent
commit
256849f66f

+ 1 - 1
src/components/tinymce/TinymceEditor.vue

@@ -193,7 +193,7 @@ export default {
           format: {
             title: "Format",
             items:
-              "bold italic underline strikethrough superscript subscript | formats | removeformat"
+              "bold italic underline strikethrough superscript subscript | removeformat"
           },
 
           table: {

+ 68 - 62
src/views/articleManagement/articleCreate.vue

@@ -7,7 +7,7 @@
           :form="form"
           :label-col="{ span: 6 }"
           :wrapper-col="{ span: 18 }"
-          style="width: 515px;"
+          style="width: 515px"
           @submit="handleSubmit"
         >
           <a-form-item label="文章标题">
@@ -118,7 +118,7 @@
                   initialValue: learnDate,
                 },
               ]"
-              style="width:100%;"
+              style="width: 100%"
             />
           </a-form-item>
           <a-form-item v-show="false" :wrapper-col="{ span: 20, offset: 10 }">
@@ -162,30 +162,30 @@
 import {
   formatePathParams,
   formateStringDate,
-  formateDateToString,
-} from '@/filters';
-import TinymceEditor from '@/components/tinymce/TinymceEditor'; // 富文本编辑组件
+  formateDateToString
+} from "@/filters";
+import TinymceEditor from "@/components/tinymce/TinymceEditor"; // 富文本编辑组件
 export default {
-  name: 'articleCreate',
+  name: "articleCreate",
   props: {},
   components: {
-    TinymceEditor,
+    TinymceEditor
   },
   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: '',
-      optionType: '',
-      description: '',
+      engineerType: "",
+      learnDate: "",
+      optionType: "",
+      description: ""
     };
   },
   created() {
@@ -201,20 +201,20 @@ export default {
       await this.getArticleParentClass();
       await this.getEngineersWork();
       let type = this.$route.query.type;
-      this.optionType = type ? type : 'create';
+      this.optionType = type ? type : "create";
       // 判断是新增文章还是编辑文章
-      if ('edit' === type) {
-        console.log('---edit---');
+      if ("edit" === type) {
+        console.log("---edit---");
         await this.getArticleContent();
-      } else if ('create' === type) {
-        console.log('---create---');
+      } else if ("create" === type) {
+        console.log("---create---");
       }
     },
     // 查询文章分类父级
     getArticleParentClass() {
       this.$_http
         .get(this.$_API.INTERFACE_GET_CATEGORIES)
-        .then((res) => {
+        .then(res => {
           this.articleParentClassArr = res.data;
           this.loading = false;
         })
@@ -235,12 +235,12 @@ export default {
             pathParamsData
           )
         )
-        .then((res) => {
+        .then(res => {
           if (res && res.data.length !== 0) {
             this.articleChildClassArr = res.data;
             this.articleChildClass = this.articleChildClassArr[0];
             this.form.setFieldsValue({
-              articleChildClass: this.articleChildClass.name,
+              articleChildClass: this.articleChildClass.name
             });
           }
           this.loading = false;
@@ -253,8 +253,8 @@ export default {
     async getEngineersWork() {
       await this.$_http
         .get(this.$_API.INTERFACE_GET_ENGINEERINGWORK_LIST)
-        .then((res) => {
-          this.engineerTypeArray = [{ name: '不限', id: '' }, ...res.data];
+        .then(res => {
+          this.engineerTypeArray = [{ name: "不限", id: "" }, ...res.data];
           this.engineerType = this.engineerTypeArray[0];
         });
     },
@@ -265,7 +265,7 @@ export default {
       // 子类选项清空
       this.articleChildClassArr = [];
       this.form.setFieldsValue({
-        articleChildClass: '',
+        articleChildClass: ""
       });
       // 获取子类的值
       this.getArticleChildClass();
@@ -283,7 +283,7 @@ export default {
       this.learnDate = dateString;
     },
     handleSubmitBtnFun() {
-      document.getElementById('articleCreateSubmit').click();
+      document.getElementById("articleCreateSubmit").click();
     },
     // 查询文章内容
     getArticleContent() {
@@ -292,8 +292,8 @@ export default {
         .get(
           formatePathParams(this.$_API.INTERFACE_GET_MATERIALS, pathParamsData)
         )
-        .then((res) => {
-          console.log('----' + JSON.stringify(res));
+        .then(res => {
+          console.log("----" + JSON.stringify(res));
           this.initEditArticleForm(res.data);
           this.loading = false;
         })
@@ -302,13 +302,13 @@ export default {
         });
     },
     initEditArticleForm(item) {
-      console.log('--------' + JSON.stringify(item));
+      console.log("--------" + JSON.stringify(item));
       //   文章标题
       this.form.setFieldsValue({
-        name: item.name,
+        name: item.name
       });
       //   文章描述
-      this.description = item.description ? item.description : '';
+      this.description = item.description ? item.description : "";
       // 文章分类-父类:
       this.articleParentClass = item.rootMaterialCategory;
       this.getArticleChildClass(); // 获取子类列表的值
@@ -324,64 +324,67 @@ export default {
           }
         }
       }
-      let learnDate = item.tags.length > 0 ? item.tags[0] : '';
+      let learnDate = item.tags.length > 0 ? item.tags[0] : "";
       // 必学日期
-      this.learnDate = learnDate ? formateStringDate(learnDate) : '';
-      console.log('编辑初始化时间为YYYY-MM-DD', this.learnDate, learnDate);
+      this.learnDate = learnDate ? formateStringDate(learnDate) : "";
+      console.log("编辑初始化时间为YYYY-MM-DD", this.learnDate, learnDate);
       // 文章内容
       this.content = item.contents;
     },
     // 提交表单
     handleSubmit(e) {
       e.preventDefault();
-      if ('create' === this.optionType) {
-        console.log('创建文章');
+      if ("create" === this.optionType) {
+        console.log("创建文章");
         this.createArtical();
-      } else if ('edit' === this.optionType) {
-        console.log('更新文章');
+      } else if ("edit" === this.optionType) {
+        console.log("更新文章");
         this.updateArtical();
       }
     },
     createArtical() {
       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) {
           // 新建文章
           let that = this;
           that.$confirm({
-            title: '新建文章',
+            title: "新建文章",
             content: `确认新建文章吗?`,
-            okText: '确认',
-            cancelText: '取消',
+            okText: "确认",
+            cancelText: "取消",
             onOk() {
               that.loading = true;
-              let params = { categoryid: that.articleChildClass.id };
+              let params = {
+                categoryid: that.articleChildClass.id,
+                engineertypeid: that.engineerType.id
+              };
               let bodyParams = {
                 name: values.name,
                 description: values.description,
-                type: 'ARTICLE',
+                type: "ARTICLE",
                 contents: that.content,
                 tags: [formateDateToString(that.learnDate)],
                 engineerTypes: [that.engineerType.id],
-                links: [],
+                links: []
               };
               that.$_http
                 .post(that.$_API.INTERFACE_POST_ADMIN_MATERIALS, bodyParams, {
-                  params,
+                  params
                 })
                 .then(() => {
-                  that.$message.success('新建文章成功');
+                  that.$message.success("新建文章成功");
                 });
             },
-            onCancel() {},
+            onCancel() {}
           });
         }
       });
@@ -393,25 +396,28 @@ export default {
           // 更新文章
           let that = this;
           that.$confirm({
-            title: '更新文章',
+            title: "更新文章",
             content: `确认更新文章吗?`,
-            okText: '确认',
-            cancelText: '取消',
+            okText: "确认",
+            cancelText: "取消",
             onOk() {
               that.loading = true;
-              let params = { categoryid: that.articleChildClass.id };
+              let params = {
+                categoryid: that.articleChildClass.id,
+                engineertypeid: that.engineerType.id
+              };
               let bodyParams = {
                 id: that.$route.query.id,
                 name: values.name,
                 description: values.description,
-                type: 'ARTICLE',
+                type: "ARTICLE",
                 contents: that.content,
                 tags: [formateDateToString(that.learnDate)],
                 engineerTypes: [that.engineerType.id],
-                links: [],
+                links: []
               };
               console.log(
-                '保存修改日期格式为YYYYMMDD',
+                "保存修改日期格式为YYYYMMDD",
                 bodyParams.tags,
                 that.learnDate
               );
@@ -423,14 +429,14 @@ export default {
                   ),
                   bodyParams,
                   {
-                    params,
+                    params
                   }
                 )
                 .then(() => {
-                  that.$message.success('更新文章成功');
+                  that.$message.success("更新文章成功");
                 });
             },
-            onCancel() {},
+            onCancel() {}
           });
         }
       });
@@ -442,15 +448,15 @@ export default {
     // 关闭预览
     closepreview() {
       this.previewVisible = false;
-    },
-  },
+    }
+  }
 };
 </script>
 
 <style lang="less"></style>
 
 <style lang="less" scoped>
-@import '~@/styles/common/variable.less';
+@import "~@/styles/common/variable.less";
 .app-container {
   .information-title {
     font-size: 18px;