文章业务

This commit is contained in:
clay
2022-01-10 00:12:45 +08:00
parent 0e62e7e3da
commit f213b292d0
9 changed files with 172 additions and 87 deletions

View File

@@ -56,7 +56,7 @@
</el-form-item>
</el-col>
</el-row>
<el-row v-show="sistArticleTypeOption.length>0">
<el-row v-show="sistArticleTypeOption.length>0 && approveShow.sist">
<el-col :span="6">
<el-form-item label="信息网站">
<el-select v-model="params.sistArticleType" @change="getSistApprove(params.sistArticleType)"
@@ -83,7 +83,7 @@
</el-form-item>
</el-col>
</el-row>
<el-row v-show="labArticleTypeOption.length>0">
<el-row v-show="labArticleTypeOption.length>0 && approveShow.lab">
<el-col :span="6">
<el-form-item label="实验室网站">
<el-select v-model="params.labArticleType" placeholder="请选择文章类型"
@@ -120,7 +120,6 @@
<el-form-item size="large">
<el-button type="success" @click="saveDrafts">保存草稿</el-button>
<el-button type="primary" @click="submitForm">提交审核</el-button>
<el-button @click="resetForm">重置</el-button>
</el-form-item>
</el-col>
</el-row>
@@ -139,6 +138,7 @@ export default {
props: [],
data() {
return {
submit: 1,
formData: {
id: null,
title: null,
@@ -146,6 +146,10 @@ export default {
isEnglish: null,
content: "",
},
approveShow: {
sist: true,
lab: true,
},
params: {
sistArticleType: null,
sistApprove: null,
@@ -198,19 +202,31 @@ export default {
computed: {},
watch: {},
created() {
this.approveShow = {
sist: true,
lab: true
}
this.formData.id = this.$route.params && this.$route.params.articleId;
if (this.formData.id === undefined) {
this.formData.id = null;
this.formData.sitetype
} else {
getArticle(this.formData.id).then(response => {
this.formData = response.data
if (this.formData.siteType === '2') {
this.approveShow.sist = false
this.params.labArticleType = parseInt(this.formData.type)
this.getLabApprove(this.params.labArticleType)
} else if (this.formData.siteType === '1') {
this.approveShow.lab = false
this.params.sistArticleType = parseInt(this.formData.type)
this.getSistApprove(this.params.sistArticleType)
}
})
}
this.getDicts("article_site_type").then(response => {
this.sitetypeOptions = response.data;
});
this.getEncodeDicts("article_type").then(response => {
this.getDicts("article_type").then(response => {
this.articleTypeOptions = response.data;
});
this.getDicts("is_top").then(response => {
@@ -228,6 +244,7 @@ export default {
getArticleType().then(res => {
let dictCodes = res.data
let articleList = this.articleTypeOptions
console.log(articleList, dictCodes);
for (let i = 0; i < articleList.length; i++) {
for (let j = 0; j < dictCodes.length; j++) {
if (articleList[i].dictCode === dictCodes[j]) {
@@ -261,58 +278,76 @@ export default {
if ((this.params.sistArticleType === null || this.params.sistArticleType === "") && (this.params.labArticleType === null || this.params.labArticleType === "")) {
Message({
message: "请至少选择一个网站发布文章",
type: 'error'
type: "error",
})
this.msgSuccess("请至少选择一个网站发布文章")
return
} else if ((this.params.sistArticleType === null || this.params.sistArticleType === "") && (this.params.labArticleType !== null || this.params.labArticleType !== "") && (this.formData.sistApprove === null || this.params.sistApprove === "")) {
this.msgSuccess({
Message({
message: "请选择信息网站的审批人",
type: 'error'
type: "error",
})
return
} else if ((this.params.sistArticleType === null || this.params.sistArticleType === "") && (this.params.labArticleType != null || this.params.labArticleType !== "") && (this.params.labApprove === null || this.params.labApprove === "")) {
this.msgSuccess({
Message({
message: "请选择实验室网站的审批人",
type: 'error'
type: "error",
})
return
}
}
this.formData.params = this.params
if (this.formData.id != null) {
if (this.submit == 0) {
Message({
message: "您操作过快",
type: "error",
})
} else {
this.submit = 0
this.loading = true;
updateArticle(this.formData).then(response => {
this.msgSuccess("提交审批成功");
this.$router.push("/sist/article");
this.loading = false;
if (response.code == 200) {
this.msgSuccess("提交审批成功");
this.submit = 1
this.close();
}
}).catch(e => {
this.submit = 1
});
// } else {
// addArticle(this.formData).then(response => {
// this.msgSuccess("新增成功");
// this.$router.push("/sist/article");
// });
}
// TODO 提交表单
})
},
close() {
this.$store.dispatch("tagsView/delView", this.$route);
this.$router.push({path: "/SIST/article/", query: {t: Date.now()}})
},
saveDrafts() {
let that_ = this
this.$refs['elForm'].validate(valid => {
drafts(this.formData).then(res=>{
if (this.formData.id === null || this.formData.id === ""){
drafts(this.formData).then(res => {
if (this.formData.id == null || this.formData.id == "") {
this.formData.id = res.data
}
this.msgSuccess('保存成功');
if (res.code == 200) {
that_.msgSuccess('保存成功');
} else {
that_.Message({
message: res.code,
type: "error"
})
}
})
})
},
resetForm() {
this.$refs['elForm'].resetFields()
},
}
}
</script>
<style>
.el-select-dropdown{
z-index: 2147483647!important;
.el-select-dropdown, .el-message {
z-index: 2147483647 !important;
}
</style>
<style scoped lang="scss">