|
@@ -5,11 +5,15 @@
|
|
|
<el-form :model="form" ref="form" :rules="formRules" label-position="left" label-width="120px">
|
|
|
<div class="formDiv">
|
|
|
<div>
|
|
|
- <el-form-item label="课题名称:" prop="cat_arr_id" class="custom-align-right">
|
|
|
- <el-cascader :key="parentKey" v-model="form.cat_arr_id" placeholder="请选择课题名称" :props="parentData" filterable clearable></el-cascader>
|
|
|
+ <el-form-item label="课题分类:" prop="type" class="custom-align-right">
|
|
|
+ <el-select v-model="form.type" placeholder="请选择课题分类..">
|
|
|
+ <!-- <el-option label="科研" value="1"></el-option>
|
|
|
+ <el-option label="维权" value="2"></el-option> -->
|
|
|
+ <el-option :label="item.label" :value="item.value" v-for="item in topicType"></el-option>
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="课题标题:" prop="keyword" class="custom-align-right">
|
|
|
- <el-input v-model="form.keyword" autocomplete="off" placeholder="请输入资讯关键词"></el-input>
|
|
|
+ <el-form-item label="课题标题:" prop="title" class="custom-align-right">
|
|
|
+ <el-input v-model="form.title" autocomplete="off" placeholder="请输入课题标题"></el-input>
|
|
|
</el-form-item>
|
|
|
<div class="QuillTitle">
|
|
|
<span>* </span>课题内容:
|
|
@@ -17,7 +21,7 @@
|
|
|
{{ showHtml ? '切换到编辑模式' : '切换到源码模式' }}
|
|
|
</div>
|
|
|
</div>
|
|
|
- <el-form-item label="" prop="content">
|
|
|
+ <el-form-item label="">
|
|
|
<div class="editor-container">
|
|
|
<div v-if="showHtml">
|
|
|
<textarea v-model="editorHtml" style="width: 100%; height: 400px;"></textarea>
|
|
@@ -29,18 +33,18 @@
|
|
|
<input type="file" ref="multiFileInput" @change="handleMultipleFiles" multiple hidden accept="image/jpeg, image/png" />
|
|
|
</div>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="建立群聊:" prop="is_original" class="custom-align-right">
|
|
|
- <el-radio-group v-model="form.is_original">
|
|
|
- <el-radio :label="1">是</el-radio>
|
|
|
- <el-radio :label="0">否</el-radio>
|
|
|
+ <el-form-item label="建立群聊:" prop="is_group" class="custom-align-right">
|
|
|
+ <el-radio-group v-model="form.is_group" :disabled="groupStatus">
|
|
|
+ <el-radio :label="'1'">是</el-radio>
|
|
|
+ <el-radio :label="'0'">否</el-radio>
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
<div>
|
|
|
- <el-form-item label="群聊名称:" prop="copyfrom" class="custom-align-right">
|
|
|
- <el-input v-model="form.copyfrom" autocomplete="off" placeholder="请输入来源名称"></el-input>
|
|
|
+ <el-form-item label="群聊名称:" prop="group_name" class="custom-align-right" v-if="form.is_group=='1'">
|
|
|
+ <el-input v-model="form.group_name" autocomplete="off" placeholder="请输入群聊名称" :disabled="groupStatus"></el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="作者:" prop="linkurl" class="custom-align-right">
|
|
|
- <el-input v-model="form.linkurl" autocomplete="off" placeholder="请输入来源链接"></el-input>
|
|
|
+ <el-form-item label="作者:" class="custom-align-right">
|
|
|
+ <el-input v-model="form.author" autocomplete="off" placeholder="请输入作者名"></el-input>
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -49,8 +53,8 @@
|
|
|
</div>
|
|
|
<div class="bottomBtnBox">
|
|
|
<el-button type="info" @click="returnPage">返回</el-button>
|
|
|
- <el-button type="primary" @click="editToServe" v-if="editStatus==true">确定</el-button>
|
|
|
- <el-button type="primary" @click="addToServe" v-else>发布</el-button>
|
|
|
+ <el-button type="primary" @click="editToServe" v-if="editStatus==true">修改</el-button>
|
|
|
+ <el-button type="primary" @click="addToServe" v-else>创建</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -96,54 +100,27 @@ export default {
|
|
|
//0.全局操作 end ------------------------------------------------------------>
|
|
|
return {
|
|
|
//1.表单项 start ------------------------------------------------------------>
|
|
|
- editStatus:false,
|
|
|
+ editStatus:false,//是否为编辑状态
|
|
|
+ groupStatus:false,//是否可以编辑群信息
|
|
|
tableDivTitle:"编辑课题",
|
|
|
disclaimer:true,//免责声明
|
|
|
//提交表单
|
|
|
form: {
|
|
|
- //1.1使用了外链
|
|
|
- title: '',//资讯标题
|
|
|
- islink:0,//是否使用外链 0非 1是
|
|
|
- linkurl:"",//外链地址
|
|
|
- //1.2没有使用外链
|
|
|
- cat_arr_id:'',//导航池名称
|
|
|
- level:"",//推荐等级
|
|
|
- imgurl:"",//缩略图
|
|
|
- keyword:"",//关键词
|
|
|
- introduce:"",//描述
|
|
|
+ type:"",//课题分类
|
|
|
+ title:"",//课题标题
|
|
|
content:"",//内容
|
|
|
+ is_group:"0",//是否创建群聊
|
|
|
+ group_name:"",//群聊名称
|
|
|
author:"",//作者
|
|
|
- hits:"",//浏览量
|
|
|
- is_original:0,//是否为原创 0非 1是
|
|
|
- copyfrom:"",//来源名称
|
|
|
- fromurl:"",//来源地址
|
|
|
- status:0//状态 0待发布 1已发布 404已删除
|
|
|
},
|
|
|
+ topicType:[],//课题分类
|
|
|
+ topicStatus:[],//课题状态
|
|
|
//1.2 表单验证规则
|
|
|
formRules: {
|
|
|
- //资讯名称不能为空
|
|
|
title:[{required:true,trigger:'blur',validator:validateEmpty}],
|
|
|
- //如果使用了外链,外链地址不能为空
|
|
|
- linkurl:[{required:true,trigger:'blur',validator:validateEmpty}],
|
|
|
- //导航池名称不能为空
|
|
|
- cat_arr_id:[{required:true,trigger:'blur',validator:validateArray}],
|
|
|
- //推荐等级不能为空
|
|
|
- //level:[{required:true,trigger:'blur',validator:validateEmpty}],
|
|
|
- //关键词不能为空
|
|
|
- keyword:[{required:true,trigger:'blur',validator:validateEmpty}],
|
|
|
- //描述不能为空
|
|
|
- introduce:[{required:true,trigger:'blur',validator:validateEmpty}],
|
|
|
- //内容不能为空
|
|
|
- content:[{required:true,trigger:'blur',validator:validateEmpty}],
|
|
|
- //作者不能为空
|
|
|
- author:[{required:true,trigger:'blur',validator:validateEmpty}],
|
|
|
- //是否原创不能为空
|
|
|
- is_original:[{required:true,trigger:'blur',validator:validateEmpty}],
|
|
|
- //来源名称和地址不能为空
|
|
|
- copyfrom:[{required:true,trigger:'blur',validator:validateEmpty}],
|
|
|
- fromurl:[{required:true,trigger:'blur',validator:validateEmpty}],
|
|
|
- //缩略图不能为空
|
|
|
- imgUrl:[{required:true,trigger:'blur',validator:validateEmpty}]
|
|
|
+ type:[{required:true,trigger:'blur',validator:validateArray}],
|
|
|
+ is_group:[{required:true,trigger:'blur',validator:validateEmpty}],
|
|
|
+ group_name:[{required:true,trigger:'blur',validator:validateEmpty}],
|
|
|
},
|
|
|
//1.3富文本编辑器配置
|
|
|
showHtml: false, //用于保存源码内容
|
|
@@ -187,36 +164,6 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- //1.4图片上传
|
|
|
- imgUrl:"",//在页面上显示缩略图
|
|
|
- //获取父级导航池
|
|
|
- parentKey:0,//获取父级导航
|
|
|
- parentData: {
|
|
|
- checkStrictly: true,
|
|
|
- lazy: true,
|
|
|
- async lazyLoad (node, resolve) {
|
|
|
- const { level, data } = node;
|
|
|
- if (data && data.children && data.children.length !== 0) {
|
|
|
- return resolve(node)
|
|
|
- }
|
|
|
- console.log(level)
|
|
|
- let parentId = level == 0 ? 0 : data.value
|
|
|
- let parames = {
|
|
|
- 'pid':parentId
|
|
|
- }
|
|
|
- self.$store.dispatch('pool/categoryList',parames).then(res=> {
|
|
|
- if (res.data) {
|
|
|
- const nodes = res.data.map(item => ({
|
|
|
- value: item.id,
|
|
|
- label: item.name,
|
|
|
- leaf: level >= 3,
|
|
|
- children: []
|
|
|
- }))
|
|
|
- resolve(nodes)
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
//表单项 end ------------------------------------------------------------>
|
|
|
};
|
|
|
},
|
|
@@ -250,32 +197,22 @@ export default {
|
|
|
message: '网络错误,请重试!'
|
|
|
});
|
|
|
})
|
|
|
-
|
|
|
// 阻止默认的上传行为
|
|
|
return false;
|
|
|
},
|
|
|
//1.2 提交表单
|
|
|
addToServe(){
|
|
|
- //提交之前先判断是否为外链
|
|
|
- //如果使用了外链,清理掉除了外链以外的内容
|
|
|
- if(this.form.islink==true){
|
|
|
- this.form.islink = 1;
|
|
|
- this.cleatForm(1)
|
|
|
- }else{
|
|
|
- this.form.islink = 0;
|
|
|
- }
|
|
|
-
|
|
|
//先进行验证
|
|
|
this.$refs.form.validate(valid => {
|
|
|
if (valid) {
|
|
|
//console.log(this.form)
|
|
|
- this.$store.dispatch('news/addArticle',this.form).then(res=> {
|
|
|
+ this.$store.dispatch('chat/addTopic',this.form).then(res=> {
|
|
|
//汇报结果
|
|
|
this.$message({
|
|
|
type: 'success',
|
|
|
- message: '已成功添加资讯!'
|
|
|
+ message: '已成功创建商圈!'
|
|
|
});
|
|
|
- this.cleatForm(2);
|
|
|
+ this.cleatForm();
|
|
|
//返回列表页
|
|
|
this.returnPage()
|
|
|
}).catch(() => {
|
|
@@ -288,47 +225,38 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
//1.3 清理表单
|
|
|
- cleatForm(type){
|
|
|
- if(type==1){
|
|
|
- //使用了外链,进行部分表单清理
|
|
|
- //this.form.cat_arr_id = "";
|
|
|
- this.form.level = "";
|
|
|
- this.form.imgurl = "";
|
|
|
- this.form.keyword = "";
|
|
|
- this.form.introduce = "";
|
|
|
- this.form.content = "";
|
|
|
- //this.form.author = "";
|
|
|
- this.form.hits = "";
|
|
|
- this.form.is_original = "";
|
|
|
- this.form.copyfrom = "";
|
|
|
- this.form.fromurl = "";
|
|
|
- this.form.status = "";
|
|
|
- }
|
|
|
- if(type==2){
|
|
|
- //完全清理表单
|
|
|
- this.form.title = "";
|
|
|
- this.form.islink = "";
|
|
|
- this.form.linkurl = "";
|
|
|
- this.form.cat_arr_id = "";
|
|
|
- this.form.level = "";
|
|
|
- this.form.imgurl = "";
|
|
|
- this.form.keyword = "";
|
|
|
- this.form.introduce = "";
|
|
|
- this.form.content = "";
|
|
|
- this.form.author = "";
|
|
|
- this.form.hits = "";
|
|
|
- this.form.is_original = "";
|
|
|
- this.form.copyfrom = "";
|
|
|
- this.form.fromurl = "";
|
|
|
- this.form.status = "";
|
|
|
- }
|
|
|
+ cleatForm(){
|
|
|
+ this.form.type = "";
|
|
|
+ this.form.title = "";
|
|
|
+ this.form.content = "";
|
|
|
+ this.form.is_group = "";
|
|
|
+ this.form.group_name = "";
|
|
|
+ this.form.author = "";
|
|
|
+ },
|
|
|
+ //1.4 查询商圈分类
|
|
|
+ getTopicType(){
|
|
|
+ this.$store.dispatch('chat/topicType',this.getApiData).then(res=> {
|
|
|
+ this.topicType = res.data;
|
|
|
+ console.log(this.topicType)
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message.error("查询商圈分类失败!");
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //1.5 查询商圈状态
|
|
|
+ getTopicStatus(){
|
|
|
+ this.$store.dispatch('chat/topicStatus',this.getApiData).then(res=> {
|
|
|
+ this.topicStatus = res.data;
|
|
|
+ console.log(res)
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message.error("查询商圈状态失败!");
|
|
|
+ })
|
|
|
},
|
|
|
//提交表单 end ------------------------------------------------------------>
|
|
|
|
|
|
//2.跳转操作 start ------------------------------------------------------------>
|
|
|
returnPage(){
|
|
|
this.$router.push({
|
|
|
- path: '/articleList',
|
|
|
+ path: '/topic',
|
|
|
});
|
|
|
},
|
|
|
//跳转操作 end ------------------------------------------------------------>
|
|
@@ -337,50 +265,20 @@ export default {
|
|
|
//3.1回显数据
|
|
|
getMainData() {
|
|
|
let data = {
|
|
|
- id: this.$route.query.id
|
|
|
+ id: this.$route.query.id + ""
|
|
|
};
|
|
|
- this.$store.dispatch('news/getArticleInfo', data).then(res => {
|
|
|
+ this.$store.dispatch('chat/getTopicInfo', data).then(res => {
|
|
|
console.log(res);
|
|
|
this.form.title = res.data.title;
|
|
|
- //判断是否使用了外链
|
|
|
- if(res.data.islink==1){
|
|
|
- this.form.islink = true;
|
|
|
- }else{
|
|
|
- this.form.islink = false;
|
|
|
- }
|
|
|
- //不是原创的时候显示来源
|
|
|
- if(res.data.is_original==1){
|
|
|
- this.form.is_original = 1;
|
|
|
- }else{
|
|
|
- this.form.is_original = 0;
|
|
|
- this.$nextTick(() => {
|
|
|
- this.form.is_original = 0;
|
|
|
- console.log('is_original:', this.form.is_original); // 确保值已更新
|
|
|
- });
|
|
|
- // <el-radio v-model="form.is_original" label="1">是</el-radio>
|
|
|
- // <el-radio v-model="form.is_original" label="0">不是</el-radio>
|
|
|
- this.form.linkurl = res.data.linkurl;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- // 回显导航池
|
|
|
- this.form.cat_arr_id = Array.isArray(res.data.cat_arr_id) ? res.data.cat_arr_id : JSON.parse(res.data.cat_arr_id);
|
|
|
- this.parentKey += 1; // 触发级联选择器重新加载
|
|
|
- this.loadCascaderPath(this.form.cat_arr_id); // 加载路径数据
|
|
|
-
|
|
|
- this.form.level = res.data.level;
|
|
|
- this.form.imgurl = res.data.imgurl;
|
|
|
- this.imgUrl = res.data.imgurl;
|
|
|
- this.form.keyword = res.data.keyword;
|
|
|
- this.form.introduce = res.data.introduce;
|
|
|
+ this.form.type = res.data.type;
|
|
|
this.form.content = res.data.content;
|
|
|
- this.form.author = res.data.author;
|
|
|
- this.form.hits = res.data.hits;
|
|
|
- this.form.is_original = res.data.is_original;
|
|
|
- this.form.copyfrom = res.data.copyfrom;
|
|
|
- this.form.fromurl = res.data.fromurl;
|
|
|
- this.form.status = res.data.status;
|
|
|
+ this.form.is_group = res.data.is_group;
|
|
|
+ this.form.group_name = res.data.group_name;
|
|
|
+ this.form.author = res.data.user_name;
|
|
|
+ //如果已经创建了群聊,阻止其修改
|
|
|
+ if(res.data.is_group=="1"){
|
|
|
+ this.groupStatus = true;
|
|
|
+ }
|
|
|
}).catch(() => {
|
|
|
this.$message({
|
|
|
type: 'info',
|
|
@@ -411,24 +309,19 @@ export default {
|
|
|
},
|
|
|
//1.3提交修改
|
|
|
editToServe(){
|
|
|
- //提交之前先判断是否为外链
|
|
|
- //如果使用了外链,清理掉除了外链以外的内容
|
|
|
- if(this.form.islink==1){
|
|
|
- this.cleatForm(1)
|
|
|
- }
|
|
|
//添加要修改的id
|
|
|
- this.form.id = this.editId;
|
|
|
+ this.form.id = this.editId + "";
|
|
|
//先进行验证
|
|
|
this.$refs.form.validate(valid => {
|
|
|
if (valid) {
|
|
|
//console.log(this.form)
|
|
|
- this.$store.dispatch('news/updateArticle',this.form).then(res=> {
|
|
|
+ this.$store.dispatch('chat/updateTopic',this.form).then(res=> {
|
|
|
//汇报结果
|
|
|
this.$message({
|
|
|
type: 'success',
|
|
|
- message: '已成功添加资讯!'
|
|
|
+ message: '已成功修改课题信息!'
|
|
|
});
|
|
|
- this.cleatForm(2);
|
|
|
+ this.cleatForm();
|
|
|
//返回列表页
|
|
|
this.returnPage()
|
|
|
}).catch(() => {
|
|
@@ -549,15 +442,19 @@ export default {
|
|
|
|
|
|
},
|
|
|
mounted(){
|
|
|
+ //查询课题分类
|
|
|
+ this.getTopicType();
|
|
|
+
|
|
|
+ this.form.author = this.$store.state.user.name;
|
|
|
//1.判断是新建还是回显
|
|
|
if(this.$route.query.id!=undefined){
|
|
|
this.editId = this.$route.query.id;
|
|
|
this.editStatus = true;
|
|
|
- console.log("编辑新闻!")
|
|
|
+ console.log("编辑商圈!")
|
|
|
this.getMainData();
|
|
|
}else{
|
|
|
this.editStatus = false;
|
|
|
- console.log("添加新闻!")
|
|
|
+ console.log("新建商圈!")
|
|
|
}
|
|
|
|
|
|
//复制内容到富文本 start ------------------------------------------------------------>
|