Browse Source

党建声音文章

feature
dai 3 years ago
parent
commit
28c653677a
  1. 314
      src/views/modules/communityParty/article/index.vue
  2. 11
      src/views/modules/cpts/base/index.vue

314
src/views/modules/communityParty/article/index.vue

@ -1,121 +1,141 @@
<template> <template>
<div> <div>
<base-page ref="basePage" <base-page
:searchParams="searchParams" ref="basePage"
:tableParams="tableParams" :searchParams="searchParams"
:tableUrl="tableUrl" :tableParams="tableParams"
:addUrl="addUrl" :tableUrl="tableUrl"
:editUrl="editUrl" :addUrl="addUrl"
:delUrl="delUrl" :editUrl="editUrl"
:editAuth="editAuth" :delUrl="delUrl"
:delAuth="delAuth" :editAuth="editAuth"
:infoUrl="infoUrl" :delAuth="delAuth"
:exportUrl="exportUrl" :infoUrl="infoUrl"
:importUrl="importUrl" :exportUrl="exportUrl"
:mubanUrl="mubanUrl" :importUrl="importUrl"
:editParams="editParams" :mubanUrl="mubanUrl"
:editFixedParams="editFixedParams" :editParams="editParams"
:editElseRules="editElseRules" :editFixedParams="editFixedParams"
:editConfig="editConfig" :editElseRules="editElseRules"
:editParamsDiv="5" :editConfig="editConfig"
:editBtnName="(item) => (!item.latitude ? '待完善' : '修改')" :editParamsDiv="5"
:formBtnFixed="true" :editBtnName="(item) => '修改'"
idName="articleId"> :formBtnFixed="true"
idName="articleId"
>
<template v-slot:editOperateSup="{ id, formType, info }"> <template v-slot:editOperateSup="{ id, formType, info }">
<el-button v-if="formType != 'watch'" <el-button
type="warning" v-if="formType == 'add'"
size="small" type="warning"
:disabled="draftBtnDisable" size="small"
@click="handleClickDraft(info)">存草稿</el-button> :disabled="draftBtnDisable"
@click="handleClickDraft(info)"
>存草稿</el-button
>
</template> </template>
<template v-slot:listBtnSup="{ item }"> <template v-slot:listBtnSup="{ item }">
<el-button v-if=" <el-button
v-if="
item.statusFlag == 'published' && item.statusFlag == 'published' &&
item.agencyId == $store.state.user.agencyId item.agencyId == $store.state.user.agencyId
" "
@click="handleOfflineShow(item)" @click="handleOfflineShow(item)"
type="text" type="text"
size="small" size="small"
style="color: #666">下线</el-button> style="color: #666"
>下线</el-button
>
</template> </template>
<template v-slot:listBtnbefore="{ item }"> <template v-slot:listBtnbefore="{ item }">
<el-button v-if="item.isTop == '1'" <el-button
@click="handleCancleTopArticle(item,'cancel_top')" v-if="item.isTop == '1'"
type="text" @click="handleCancleTopArticle(item, 'cancel_top')"
size="small" type="text"
style="color: #fe6252">取消置顶</el-button> size="small"
<el-button v-else style="color: #fe6252"
@click="handleTopArticle(item,'top')" >取消置顶</el-button
type="text" >
size="small" <el-button
style="color: #22c1c3">置顶</el-button> v-else
@click="handleTopArticle(item, 'top')"
type="text"
size="small"
style="color: #22c1c3"
>置顶</el-button
>
</template> </template>
</base-page> </base-page>
<el-dialog :visible.sync="offlineShowed" <el-dialog
:close-on-click-modal="false" :visible.sync="offlineShowed"
:close-on-press-escape="false" :close-on-click-modal="false"
title="下线" :close-on-press-escape="false"
width="850px" title="下线"
top="5vh" width="850px"
class="dialog-h" top="5vh"
@closed="offlineShowed = false"> class="dialog-h"
<offline ref="offlineForm" @closed="offlineShowed = false"
@close="offlineShowed = false" >
@afterOffline="handleOfflineSuccess"></offline> <offline
ref="offlineForm"
@close="offlineShowed = false"
@afterOffline="handleOfflineSuccess"
></offline>
</el-dialog> </el-dialog>
<el-dialog :visible.sync="showAddImage" <el-dialog
:close-on-click-modal="false" :visible.sync="showAddImage"
:close-on-press-escape="false" :close-on-click-modal="false"
title="上传封面图片" :close-on-press-escape="false"
width="650px" title="上传封面图片"
top="5vh" width="650px"
class="dialog-h" top="5vh"
@closed="showAddImage = false"> class="dialog-h"
@closed="showAddImage = false"
>
<div class="dialog-h-content scroll-h"> <div class="dialog-h-content scroll-h">
<!-- <span>请先上 传封面图片</span> --> <!-- <span>请先上 传封面图片</span> -->
<el-form ref="ref_form" <el-form
:inline="true" ref="ref_form"
:model="formData" :inline="true"
class="div_form"> :model="formData"
class="div_form"
>
<div class="form_flex"> <div class="form_flex">
<div class="form_item"> <div class="form_item">
<el-form-item
<el-form-item label="" label=""
prop="selImgUrl" prop="selImgUrl"
label-width="150px" label-width="150px"
style="display: block"> style="display: block"
<el-upload :headers="$getElUploadHeaders()" >
:class="['avatar-uploader', { hide: hideUploadBtn }]" <el-upload
ref="uploadPic" :headers="$getElUploadHeaders()"
:action="uploadUlr" :class="['avatar-uploader', { hide: hideUploadBtn }]"
list-type="picture-card" ref="uploadPic"
:on-exceed="exceedPic" :action="uploadUlr"
:before-upload="beforeAvatarUpload" list-type="picture-card"
:on-remove="removePic" :on-exceed="exceedPic"
:file-list="replayImgList" :before-upload="beforeAvatarUpload"
:on-change="handleEditChange" :on-remove="removePic"
:on-success="handleSuccess" :file-list="replayImgList"
:limit="1"> :on-change="handleEditChange"
:on-success="handleSuccess"
:limit="1"
>
<span class="font-14">选择图片</span> <span class="font-14">选择图片</span>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
</div> </div>
</div> </div>
</el-form> </el-form>
</div> </div>
<div class="div_btn"> <div class="div_btn">
<el-button size="small" <el-button size="small" @click="showAddImage = false"> </el-button>
@click="showAddImage = false"> </el-button> <el-button size="small" type="primary" @click="handleAddImage"
<el-button size="small" > </el-button
type="primary" >
@click="handleAddImage"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
@ -132,7 +152,7 @@ import nextTick from "dai-js/tools/nextTick";
export default { export default {
props: {}, props: {},
data () { data() {
return { return {
offlineShowed: false, offlineShowed: false,
@ -148,7 +168,7 @@ export default {
optionUrl: "/gov/voice/tag/taglist", optionUrl: "/gov/voice/tag/taglist",
optionUrlParams: {}, optionUrlParams: {},
optionList: [], optionList: [],
optionCook (list) { optionCook(list) {
return list.map((item) => ({ return list.map((item) => ({
label: item.tagName, label: item.tagName,
value: item.tagId, value: item.tagId,
@ -189,12 +209,12 @@ export default {
children: "subAgencyList", children: "subAgencyList",
checkStrictly: true, checkStrictly: true,
}, },
optionCook (obj) { optionCook(obj) {
return [obj]; return [obj];
}, },
supKeys: ["publishRangeId", "publishRangeType"], supKeys: ["publishRangeId", "publishRangeType"],
supValues: ["", ""], supValues: ["", ""],
handleChangeFn (vals, item) { handleChangeFn(vals, item) {
const { optionList } = item; const { optionList } = item;
if (vals.length > 0) { if (vals.length > 0) {
item["supValues"][0] = vals[vals.length - 1]; item["supValues"][0] = vals[vals.length - 1];
@ -246,14 +266,14 @@ export default {
exportUrl: "", exportUrl: "",
addUrl: "/gov/voice/article/addOrSaveDraft", addUrl: "/gov/voice/article/addOrSaveDraft",
editUrl: "", editUrl: "/gov/voice/article/updateArticle",
infoUrl: "/gov/voice/article/detailV2", infoUrl: "/gov/voice/article/detailV2",
delUrl: "", delUrl: "/gov/voice/article/delete批量",
editAuth (item) { editAuth(item) {
return false; return item.statusFlagName == "已发布";
}, },
delAuth (item) { delAuth(item) {
return false; return item.statusFlagName == "已下线";
}, },
editParams: [ editParams: [
@ -283,7 +303,7 @@ export default {
uploadUrl: window.SITE_CONFIG["apiURL"] + "/oss/file/article/upload", uploadUrl: window.SITE_CONFIG["apiURL"] + "/oss/file/article/upload",
supKeys: ["imgUrlArr", "imgUrl"], supKeys: ["imgUrlArr", "imgUrl"],
supValues: [() => [], ""], supValues: [() => [], ""],
beforeImgUpload (file, item, that) { beforeImgUpload(file, item, that) {
console.log(file); console.log(file);
const isLt1M = file.size / 1024 / 1024 < 10; const isLt1M = file.size / 1024 / 1024 < 10;
const srcType = file.type; const srcType = file.type;
@ -319,10 +339,10 @@ export default {
checkStrictly: false, checkStrictly: false,
emitPath: false, emitPath: false,
}, },
optionCook (obj) { optionCook(obj) {
return [obj]; return [obj];
}, },
handleChangeFn (vals, item, that) { handleChangeFn(vals, item, that) {
console.log("handleChangeFn", vals); console.log("handleChangeFn", vals);
const { optionList } = item; const { optionList } = item;
const optionPlaneList = collapse(optionList, "subAgencyList"); const optionPlaneList = collapse(optionList, "subAgencyList");
@ -363,7 +383,7 @@ export default {
type: "date", type: "date",
value: dateFormat(new Date(), "yyyy-MM-dd"), value: dateFormat(new Date(), "yyyy-MM-dd"),
pickerOptions: { pickerOptions: {
disabledDate (time) { disabledDate(time) {
return time.getTime() > Date.now(); return time.getTime() > Date.now();
}, },
}, },
@ -384,7 +404,7 @@ export default {
optionType: "group", optionType: "group",
supKeys: ["publisherName", "publisherType"], supKeys: ["publisherName", "publisherType"],
supValues: ["", ""], supValues: ["", ""],
optionCook (data) { optionCook(data) {
let ret = []; let ret = [];
const { agencyDeptList, agencyGridList, agencyId, agencyName } = const { agencyDeptList, agencyGridList, agencyId, agencyName } =
data; data;
@ -426,7 +446,7 @@ export default {
} }
return ret; return ret;
}, },
handleChangeFn (vals, item, that) { handleChangeFn(vals, item, that) {
const { optionList } = item; const { optionList } = item;
let opts = []; let opts = [];
optionList.forEach((g) => { optionList.forEach((g) => {
@ -454,7 +474,7 @@ export default {
optionUrl: "/gov/voice/tag/taglist", optionUrl: "/gov/voice/tag/taglist",
optionUrlParams: {}, optionUrlParams: {},
optionList: [], optionList: [],
optionCook (list) { optionCook(list) {
return list.map((item) => ({ return list.map((item) => ({
label: item.tagName, label: item.tagName,
value: item.tagName, value: item.tagName,
@ -487,7 +507,7 @@ export default {
editElseRules: {}, editElseRules: {},
editConfig: { editConfig: {
confirmBtnName: "发布", confirmBtnName: "发布",
cookInfoFn (data) { cookInfoFn(data) {
if (data.richTextFlag == "0") { if (data.richTextFlag == "0") {
data.content = data.contentList data.content = data.contentList
.map((item) => { .map((item) => {
@ -518,7 +538,7 @@ export default {
return data; return data;
}, },
beforeSubmit (formType, fmData, that) { beforeSubmit(formType, fmData, that) {
if (fmData.isTop == "1" && !fmData.imgUrl) { if (fmData.isTop == "1" && !fmData.imgUrl) {
that.$message.error("请上传封面图片"); that.$message.error("请上传封面图片");
return false; return false;
@ -532,109 +552,105 @@ export default {
uploadUlr: window.SITE_CONFIG["apiURL"] + "/oss/file/uploadvariedfile", uploadUlr: window.SITE_CONFIG["apiURL"] + "/oss/file/uploadvariedfile",
replayImgList: [], replayImgList: [],
hideUploadBtn: false, hideUploadBtn: false,
selType: 'top', selType: "top",
selArticleId: '', selArticleId: "",
selImgUrl: '' selImgUrl: "",
}; };
}, },
components: { basePage, offline }, components: { basePage, offline },
computed: {}, computed: {},
watch: {}, watch: {},
async mounted () { }, async mounted() {},
methods: { methods: {
async handleOfflineShow (item) { async handleOfflineShow(item) {
console.log(item); console.log(item);
this.offlineShowed = true; this.offlineShowed = true;
await nextTick(100); await nextTick(100);
this.$refs.offlineForm.initForm(item); this.$refs.offlineForm.initForm(item);
}, },
async handleAddImage () { async handleAddImage() {
console.log('formData', this.formData) console.log("formData", this.formData);
this.topArticle() this.topArticle();
}, },
async handleCancleTopArticle (item, type) { async handleCancleTopArticle(item, type) {
this.selType = type this.selType = type;
this.selArticleId = item.articleId this.selArticleId = item.articleId;
await this.topArticle() await this.topArticle();
}, },
async handleTopArticle (item, type) { async handleTopArticle(item, type) {
this.selType = type;
this.selType = type this.selArticleId = item.articleId;
this.selArticleId = item.articleId
let hasImage = await this.isHasImage() let hasImage = await this.isHasImage();
if (hasImage === 'refrsh') { if (hasImage === "refrsh") {
this.$message.error("请求失败,请重新尝试"); this.$message.error("请求失败,请重新尝试");
} else if (hasImage === "no") {
} else if (hasImage === 'no') {
// this.$message.info(""); // this.$message.info("");
this.showAddImage = true this.showAddImage = true;
} else { } else {
await this.topArticle() await this.topArticle();
} }
}, },
async isHasImage () { async isHasImage() {
const url = "/gov/voice/article/detailV2"; const url = "/gov/voice/article/detailV2";
const { tableData } = this; const { tableData } = this;
const { data, code, msg } = await requestPost(url, { const { data, code, msg } = await requestPost(url, {
articleId: this.selArticleId, articleId: this.selArticleId,
}); });
if (code === 0) { if (code === 0) {
// this.formData = data // this.formData = data
if (data.imgUrl) { if (data.imgUrl) {
return 'has' return "has";
} else { } else {
return 'no' return "no";
} }
} else { } else {
return 'refrsh' return "refrsh";
} }
}, },
async topArticle () { async topArticle() {
const url = "/gov/voice/article/topArticle"; const url = "/gov/voice/article/topArticle";
const { tableData } = this; const { tableData } = this;
let params = { let params = {
articleId: this.selArticleId, articleId: this.selArticleId,
type: this.selType type: this.selType,
} };
if (this.selImgUrl) { if (this.selImgUrl) {
params.imgUrl = this.selImgUrl params.imgUrl = this.selImgUrl;
} }
const { data, code, msg } = await requestPost(url, params); const { data, code, msg } = await requestPost(url, params);
if (code === 0) { if (code === 0) {
this.$message.success("操作成功!"); this.$message.success("操作成功!");
this.showAddImage = false this.showAddImage = false;
this.$refs.basePage.refresh(); this.$refs.basePage.refresh();
} else { } else {
this.$message.success("操作失败!"); this.$message.success("操作失败!");
} }
}, },
removePic (file, fileList) { removePic(file, fileList) {
this.selImgUrl = ""; this.selImgUrl = "";
this.replayImgList = []; this.replayImgList = [];
this.hideUploadBtn = fileList.length >= 1; this.hideUploadBtn = fileList.length >= 1;
}, },
// 3 // 3
handleEditChange (file, fileList) { handleEditChange(file, fileList) {
this.hideUploadBtn = fileList.length >= 1; this.hideUploadBtn = fileList.length >= 1;
}, },
exceedPic () { exceedPic() {
this.$message.warning("只能上传1张封面图"); this.$message.warning("只能上传1张封面图");
}, },
beforeAvatarUpload (file) { beforeAvatarUpload(file) {
const isJPG = file.type === "image/jpeg"; const isJPG = file.type === "image/jpeg";
const isLt2M = file.size / 1024 / 1024 < 10; const isLt2M = file.size / 1024 / 1024 < 10;
@ -643,17 +659,17 @@ export default {
} }
return isLt2M; return isLt2M;
}, },
handleSuccess (response, file, fileList) { handleSuccess(response, file, fileList) {
this.replayImgList.push(file); this.replayImgList.push(file);
this.selImgUrl = response.data.url; this.selImgUrl = response.data.url;
}, },
handleOfflineSuccess () { handleOfflineSuccess() {
this.$refs.basePage.refresh(); this.$refs.basePage.refresh();
this.offlineShowed = false; this.offlineShowed = false;
}, },
async handleClickDraft (fmData) { async handleClickDraft(fmData) {
let url = this.addUrl; let url = this.addUrl;
let params = { let params = {
...fmData, ...fmData,

11
src/views/modules/cpts/base/index.vue

@ -720,13 +720,18 @@ export default {
const { tableData, idName } = this; const { tableData, idName } = this;
const idValue = tableData[rowIndex][idName]; const idValue = tableData[rowIndex][idName];
let param = {
[idName]: idValue,
};
if (url.endsWith("/")) { if (url.endsWith("/")) {
url += idValue; url += idValue;
} }
if (url.endsWith("批量")) {
url = url.slice(0, -2);
param = [idValue];
}
const { data, code, msg } = await requestPost(url, { const { data, code, msg } = await requestPost(url, param);
[idName]: idValue,
});
if (code === 0) { if (code === 0) {
this.$message.success("删除成功!"); this.$message.success("删除成功!");

Loading…
Cancel
Save