文章
This commit is contained in:
@@ -16,84 +16,103 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="文章类型" prop="type">
|
||||
<el-select v-model="formData.type" placeholder="请选择文章类型" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="dict in articleTypeOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<!-- <el-col :span="6">-->
|
||||
<!-- <el-form-item label="文章类型" prop="type">-->
|
||||
<!-- <el-select v-model="formData.type" placeholder="请选择文章类型" clearable :style="{width: '100%'}">-->
|
||||
<!-- <el-option-->
|
||||
<!-- v-for="dict in articleTypeOptions"-->
|
||||
<!-- :key="dict.dictValue"-->
|
||||
<!-- :label="dict.dictLabel"-->
|
||||
<!-- :value="dict.dictValue"-->
|
||||
<!-- />-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- </el-col>-->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="是否顶置" prop="isTop">
|
||||
<el-select v-model="formData.isTop" placeholder="请选择是否顶置" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="dict in isTopOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="是否显示" prop="isView">
|
||||
<el-select v-model="formData.isView" placeholder="请选择是否英语" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="dict in isViewOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="是否英语" prop="isEnglish">
|
||||
<el-select v-model="formData.isEnglish" placeholder="请选择是否英语" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="dict in isEnglishOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="发布网站" prop="sitetype">
|
||||
<el-radio-group v-model="formData.sitetype">
|
||||
<el-radio-button v-for="(item, index) in sitetypeOptions" :key="index"
|
||||
<el-radio-group v-model="formData.isTop">
|
||||
<el-radio-button v-for="(item, index) in isTopOptions" :key="index"
|
||||
:label="item.dictValue">{{ item.dictLabel }}
|
||||
</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="是否显示" prop="isView">
|
||||
<el-radio-group v-model="formData.isView">
|
||||
<el-radio-button v-for="(item, index) in isViewOptions" :key="index"
|
||||
:label="item.dictValue">{{ item.dictLabel }}
|
||||
</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="是否英语" prop="isEnglish">
|
||||
<el-radio-group v-model="formData.isEnglish">
|
||||
<el-radio-button v-for="(item, index) in isEnglishOptions" :key="index"
|
||||
:label="item.dictValue">{{ item.dictLabel }}
|
||||
</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!--发布时间 为审批时间-->
|
||||
<!-- <el-col :span="12">-->
|
||||
<!-- <el-form-item label="发布时间" prop="publishTime">-->
|
||||
<!-- <el-date-picker-->
|
||||
<!-- v-model="formData.publishTime"-->
|
||||
<!-- type="datetime"-->
|
||||
<!-- placeholder="选择日期时间"-->
|
||||
<!-- align="right"-->
|
||||
<!-- :picker-options="pickerOptions">-->
|
||||
<!-- </el-date-picker>-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- </el-col>-->
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :offset="1" :span="16">
|
||||
<Editor v-model="formData.content" :min-height="500"/>
|
||||
<el-row v-show="sistArticleTypeOption.length>0">
|
||||
<el-col :span="6">
|
||||
<el-form-item label="信息网站">
|
||||
<el-select v-model="params.sistArticleType" @change="getSistApprove(params.sistArticleType)"
|
||||
placeholder="请选择文章类型" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="dict in sistArticleTypeOption"
|
||||
:key="dict.dictCode"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictCode"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
选择菜单或者文章类型
|
||||
<el-form-item label="审批人">
|
||||
<el-select v-model="params.sistApprove" placeholder="请选择文章类型" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="dict in sistApproveOption"
|
||||
:key="dict.user_id"
|
||||
:label="dict.user_name"
|
||||
:value="dict.user_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row v-show="labArticleTypeOption.length>0">
|
||||
<el-col :span="6">
|
||||
<el-form-item label="实验室网站">
|
||||
<el-select v-model="params.labArticleType" placeholder="请选择文章类型"
|
||||
@change="getLabApprove(params.labArticleType)" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="dict in labArticleTypeOption"
|
||||
:key="dict.dictCode"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictCode"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="审批人">
|
||||
<el-select v-model="params.labApprove" placeholder="请选择文章类型" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="dict in labApproveOption"
|
||||
:key="dict.user_id"
|
||||
:label="dict.user_name"
|
||||
:value="dict.user_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :offset="1" :span="22">
|
||||
<Editor v-model="formData.content" :min-height="500"/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
@@ -109,7 +128,8 @@
|
||||
</template>
|
||||
<script>
|
||||
import Editor from '@/components/Editor';
|
||||
import {updateArticle, getArticle, addArticle} from "@/api/sist/article";
|
||||
import {updateArticle, getArticle, addArticle, getArticleType, getArticleApprove} from "@/api/sist/article";
|
||||
import {Message} from "element-ui";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -121,49 +141,20 @@ export default {
|
||||
formData: {
|
||||
id: null,
|
||||
title: null,
|
||||
type: null,
|
||||
isTop: null,
|
||||
isEnglish: null,
|
||||
sitetype: "",
|
||||
content: "",
|
||||
},
|
||||
rules: {
|
||||
title: [{
|
||||
required: true,
|
||||
message: '请输入文章标题',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
type: [{
|
||||
required: true,
|
||||
message: '请选择文章类型',
|
||||
trigger: 'change'
|
||||
}],
|
||||
isTop: [{
|
||||
required: true,
|
||||
message: '请选择是否顶置',
|
||||
trigger: 'change'
|
||||
}],
|
||||
isEnglish: [{
|
||||
required: true,
|
||||
message: '请选择是否英语',
|
||||
trigger: 'change'
|
||||
}],
|
||||
isView: [{
|
||||
required: true,
|
||||
message: '请选择是否显示',
|
||||
trigger: 'change'
|
||||
}],
|
||||
sitetype: [{
|
||||
required: true,
|
||||
message: '单选框组不能为空',
|
||||
trigger: 'change'
|
||||
}],
|
||||
publishTime: [{
|
||||
required: true,
|
||||
message: '请选择发布日期',
|
||||
trigger: 'change'
|
||||
}],
|
||||
params: {
|
||||
sistArticleType: null,
|
||||
sistApprove: null,
|
||||
labArticleType: null,
|
||||
labApprove: null,
|
||||
},
|
||||
sistArticleTypeOption: [],
|
||||
labArticleTypeOption: [],
|
||||
sistApproveOption: [],
|
||||
labApproveOption: [],
|
||||
articleTypeOptions: [],
|
||||
isTopOptions: [],
|
||||
isViewOptions: [],
|
||||
@@ -191,6 +182,38 @@ export default {
|
||||
}
|
||||
}]
|
||||
},
|
||||
rules: {
|
||||
title: [{
|
||||
required: true,
|
||||
message: '请输入文章标题',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
isTop: [{
|
||||
required: true,
|
||||
message: '请选择是否顶置',
|
||||
trigger: 'change'
|
||||
}],
|
||||
isEnglish: [{
|
||||
required: true,
|
||||
message: '请选择是否英语',
|
||||
trigger: 'change'
|
||||
}],
|
||||
isView: [{
|
||||
required: true,
|
||||
message: '请选择是否显示',
|
||||
trigger: 'change'
|
||||
}],
|
||||
sitetype: [{
|
||||
required: true,
|
||||
message: '单选框组不能为空',
|
||||
trigger: 'change'
|
||||
}],
|
||||
publishTime: [{
|
||||
required: true,
|
||||
message: '请选择发布日期',
|
||||
trigger: 'change'
|
||||
}],
|
||||
},
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
@@ -223,25 +246,73 @@ export default {
|
||||
this.getDicts("article_status").then(response => {
|
||||
this.statusOptions = response.data;
|
||||
});
|
||||
getArticleType().then(res => {
|
||||
let dictCodes = res.data
|
||||
let articleList = this.articleTypeOptions
|
||||
for (let i = 0; i < articleList.length; i++) {
|
||||
for (let j = 0; j < dictCodes.length; j++) {
|
||||
if (articleList[i].dictCode === dictCodes[j]) {
|
||||
if (articleList[i].attribute2 === 1) {
|
||||
this.sistArticleTypeOption.push(articleList[i])
|
||||
} else if (articleList[i].attribute2 === 2) {
|
||||
this.labArticleTypeOption.push(articleList[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
methods: {
|
||||
getSistApprove(dictCode) {
|
||||
getArticleApprove(dictCode).then(res => {
|
||||
this.sistApproveOption = res.data
|
||||
})
|
||||
|
||||
},
|
||||
getLabApprove(dictCode) {
|
||||
getArticleApprove(dictCode).then(res => {
|
||||
this.labApproveOption = res.data
|
||||
})
|
||||
},
|
||||
|
||||
submitForm() {
|
||||
console.log(this.formData);
|
||||
this.$refs['elForm'].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.formData.id != null) {
|
||||
updateArticle(this.formData).then(response => {
|
||||
this.msgSuccess("修改成功");
|
||||
this.$router.push("/sist/article");
|
||||
});
|
||||
} else {
|
||||
addArticle(this.formData).then(response => {
|
||||
this.msgSuccess("新增成功");
|
||||
this.$router.push("/sist/article");
|
||||
});
|
||||
if ((this.params.sistArticleType === null || this.params.sistArticleType === "") && (this.params.labArticleType === null || this.params.labArticleType === "")) {
|
||||
Message({
|
||||
message: "请至少选择一个网站发布文章",
|
||||
type: 'error'
|
||||
})
|
||||
return
|
||||
} else if ((this.params.sistArticleType === null || this.params.sistArticleType === "") && (this.params.labArticleType !== null || this.params.labArticleType !== "") && (this.formData.sistApprove === null || this.params.sistApprove === "")) {
|
||||
Message({
|
||||
message: "请选择信息网站的审批人",
|
||||
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 === "")) {
|
||||
Message({
|
||||
message: "请选择实验室网站的审批人",
|
||||
type: 'error'
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
this.formData.params = this.params
|
||||
if (this.formData.id != null) {
|
||||
updateArticle(this.formData).then(response => {
|
||||
this.msgSuccess("修改成功");
|
||||
this.$router.push("/sist/article");
|
||||
});
|
||||
} else {
|
||||
addArticle(this.formData).then(response => {
|
||||
this.msgSuccess("新增成功");
|
||||
this.$router.push("/sist/article");
|
||||
});
|
||||
}
|
||||
// TODO 提交表单
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user