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