Browse Source

终于差不多做完了

master
dai 3 years ago
parent
commit
785c6a471a
  1. 221
      src/views/modules/communityParty/article/cpts/offline.vue
  2. 2
      src/views/modules/communityParty/article/drafts.vue
  3. 61
      src/views/modules/communityParty/article/index.vue
  4. 82
      src/views/modules/cpts/base/cpts/edit.vue
  5. 14
      src/views/modules/cpts/base/index.vue

221
src/views/modules/communityParty/article/cpts/offline.vue

@ -0,0 +1,221 @@
<template>
<div>
<div class="dialog-h-content scroll-h">
<el-form
ref="ref_form"
:inline="true"
:model="fmData"
:rules="dataRule"
class="form"
>
<el-form-item
label="文章名称"
prop="title"
label-width="150px"
style="display: block"
>
<div style="width: 610px">
{{ fmData.title || "--" }}
</div>
</el-form-item>
<el-form-item
label="下线网格 "
prop="gridIdList"
label-width="150px"
style="display: block"
>
<el-cascader
v-model="fmData.gridIdList"
placeholder="请选择"
:options="gridOptions"
:props="{
multiple: true,
value: 'value',
label: 'label',
children: 'children',
checkStrictly: false,
emitPath: false,
}"
:show-all-levels="false"
size="small"
clearable
class="item-select"
style="width: 500px"
@change="handleChangeCascader"
>
</el-cascader>
</el-form-item>
</el-form>
</div>
<div class="div_btn resi-btns">
<el-button size="small" @click="handleCancle"> </el-button>
<el-button
type="primary"
size="small"
:disabled="btnDisable"
@click="handleComfirm"
> </el-button
>
</div>
</div>
</template>
<script>
import { requestPost } from "@/js/dai/request";
export default {
props: {},
data() {
return {
btnDisable: false,
fmData: {
articleId: "",
title: "",
gridIdList: [],
},
gridOptions: [],
};
},
components: {},
computed: {
dataRule() {
return {
gridIdList: [
{ required: true, message: "下线网格不能为空", trigger: "blur" },
],
};
},
},
watch: {},
async mounted() {},
methods: {
handleChangeCascader(e) {
console.log(e);
},
async initForm({ articleId, title }) {
this.fmData.articleId = articleId;
this.fmData.title = title;
this.fmData.gridIdList = [];
this.gridOptions = [];
this.getGridOpitons(articleId);
},
async getGridOpitons(articleId) {
const url = "/gov/voice/article/publishgridlist";
const params = {
articleId,
};
const { data, code, msg } = await requestPost(url, params);
if (code === 0) {
function poll(list) {
return list.map((item) => {
return {
label: item.agencyName,
value: item.agencyId,
type: "agency",
children: [
...poll(item.subAgencyGridList),
...item.gridList.map((grid) => ({
label: grid.gridName,
value: grid.gridId,
type: "grid",
})),
],
};
});
}
let gridOptions = poll([data.agencyGridList]);
console.log(gridOptions);
this.gridOptions = gridOptions;
} else {
this.$message.error(msg);
}
},
async handleComfirm() {
this.btnDisable = true;
setTimeout(() => {
this.btnDisable = false;
}, 5000);
this.$refs["ref_form"].validate((valid, messageObj) => {
if (!valid) {
app.util.validateRule(messageObj);
this.btnDisable = false;
} else {
this.submit();
}
});
},
async submit() {
let url = "/gov/voice/article/offlinearticle";
let params = { ...this.fmData };
const { data, code, msg } = await requestPost(url, params);
if (code === 0) {
this.$message({
type: "success",
message: "操作成功",
});
this.$emit("afterOffline");
this.btnDisable = false;
} else {
this.btnDisable = false;
this.$message.error(msg);
}
},
handleCancle() {
this.$emit("close");
},
},
};
</script>
<style lang="scss" scoped>
.item_width_1 {
width: 500px;
}
.item_width_2 {
width: 400px;
}
.item_width_3 {
margin-left: 10px;
width: 200px;
}
.item_width_4 {
width: 200px;
}
.div_map {
margin-top: 10px;
}
.div_btn {
// display: flex;
// justify-content: flex-end;
}
.el-tabs {
margin: 0 20px;
}
.el-upload__tip {
color: rgb(155, 155, 155);
margin: 0;
}
.form {
margin-top: 30px;
}
.attachement-list {
}
</style>

2
src/views/modules/communityParty/article/drafts.vue

@ -314,7 +314,7 @@ export default {
} else if (item.contentType == "img") { } else if (item.contentType == "img") {
return `<img src="${item.content}" style="max-width:100%"></img>`; return `<img src="${item.content}" style="max-width:100%"></img>`;
} else if (item.contentType == "video") { } else if (item.contentType == "video") {
return `<video src="${item.content}" style="max-width:100%"></video>`; return `<video src="${item.content}" style="max-width:100%" controls></video>`;
} else if (item.contentType == "file") { } else if (item.contentType == "file") {
return `<a src="${item.content}" target="_blank">附件:${item.fileName}</a>`; return `<a src="${item.content}" target="_blank">附件:${item.fileName}</a>`;
} }

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

@ -33,7 +33,38 @@
>存草稿</el-button >存草稿</el-button
> >
</template> </template>
<template v-slot:listBtnSup="{ item }">
<el-button
v-if="
item.statusFlag == 'published' &&
item.agencyId == $store.state.user.agencyId
"
@click="handleOfflineShow(item)"
type="text"
size="small"
style="color: #666"
>下线</el-button
>
</template>
</base-page> </base-page>
<el-dialog
:visible.sync="offlineShowed"
:close-on-click-modal="false"
:close-on-press-escape="false"
title="下线"
width="850px"
top="5vh"
class="dialog-h"
@closed="offlineShowed = false"
>
<offline
ref="offlineForm"
@close="offlineShowed = false"
@afterOffline="handleOfflineSuccess"
></offline>
</el-dialog>
</div> </div>
</template> </template>
@ -42,12 +73,16 @@ import basePage from "@/views/modules/cpts/base/index";
import { getItemByIdInCascader, collapse } from "@/utils/cascader"; import { getItemByIdInCascader, collapse } from "@/utils/cascader";
import { requestPost } from "@/js/dai/request"; import { requestPost } from "@/js/dai/request";
import dateFormat from "dai-js/tools/dateFormat.js"; import dateFormat from "dai-js/tools/dateFormat.js";
import offline from "./cpts/offline";
import nextTick from "dai-js/tools/nextTick";
export default { export default {
props: {}, props: {},
data() { data() {
return { return {
offlineShowed: false,
draftBtnDisable: false, draftBtnDisable: false,
searchParams: [ searchParams: [
@ -144,7 +179,7 @@ export default {
type: "array", type: "array",
arrayDiv: "、", arrayDiv: "、",
}, },
{ field: "状态", keyName: "statusFlag", type: "text" }, { field: "状态", keyName: "statusFlagName", type: "text" },
{ field: "发布单位", keyName: "publisherName", type: "text" }, { field: "发布单位", keyName: "publisherName", type: "text" },
{ field: "发布时间", keyName: "publishDate", type: "text" }, { field: "发布时间", keyName: "publishDate", type: "text" },
{ {
@ -192,9 +227,9 @@ export default {
limit: 1, limit: 1,
editDisabled: true, editDisabled: true,
rules: [], rules: [],
value: [], value: () => [],
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;
@ -215,9 +250,9 @@ export default {
field: "发布范围", field: "发布范围",
keyName: "gridIdList", keyName: "gridIdList",
type: "cascader", type: "cascader",
value: [], value: () => [],
supKeys: ["publishRangeDesc"], supKeys: ["publishRangeDesc"],
supValues: [[]], supValues: [() => []],
optionUrl: "/gov/org/customeragency/agencygridtree", optionUrl: "/gov/org/customeragency/agencygridtree",
optionUrlParams: { optionUrlParams: {
agencyId: this.$store.state.user.agencyId, agencyId: this.$store.state.user.agencyId,
@ -402,7 +437,7 @@ export default {
} else if (item.contentType == "img") { } else if (item.contentType == "img") {
return `<img src="${item.content}" style="max-width:100%"></img>`; return `<img src="${item.content}" style="max-width:100%"></img>`;
} else if (item.contentType == "video") { } else if (item.contentType == "video") {
return `<video src="${item.content}" style="max-width:100%"></video>`; return `<video src="${item.content}" style="max-width:100%" controls></video>`;
} else if (item.contentType == "file") { } else if (item.contentType == "file") {
return `<a src="${item.content}" target="_blank">附件:${item.fileName}</a>`; return `<a src="${item.content}" target="_blank">附件:${item.fileName}</a>`;
} }
@ -426,13 +461,25 @@ export default {
}, },
}; };
}, },
components: { basePage }, components: { basePage, offline },
computed: {}, computed: {},
watch: {}, watch: {},
async mounted() {}, async mounted() {},
methods: { methods: {
async handleOfflineShow(item) {
console.log(item);
this.offlineShowed = true;
await nextTick(100);
this.$refs.offlineForm.initForm(item);
},
handleOfflineSuccess() {
this.$refs.basePage.refresh();
this.offlineShowed = false;
},
async handleClickDraft(fmData) { async handleClickDraft(fmData) {
let url = this.addUrl; let url = this.addUrl;
let params = { let params = {

82
src/views/modules/cpts/base/cpts/edit.vue

@ -85,7 +85,7 @@
size="small" size="small"
clearable clearable
show-word-limit show-word-limit
:format="item.format || 'yyyy-MM-dd'" :value-format="item.format || 'yyyy-MM-dd'"
:placeholder="item.placeholder || '请输入'" :placeholder="item.placeholder || '请输入'"
> >
</el-date-picker> </el-date-picker>
@ -163,9 +163,14 @@
v-model="fmData[item.keyName]" v-model="fmData[item.keyName]"
:customerId="customerId" :customerId="customerId"
:placeholder="item.placeholder || '请输入'" :placeholder="item.placeholder || '请输入'"
:height="500"
/> />
</div> </div>
<div v-else class="item-show" @click="handleClickHtmlNode"> <div
v-else
class="item-rich-text z-show"
@click="handleClickHtmlNode"
>
<div v-html="fmData[item.keyName]"></div> <div v-html="fmData[item.keyName]"></div>
</div> </div>
</template> </template>
@ -187,6 +192,10 @@
<template v-else-if="item.type == 'upload'"> <template v-else-if="item.type == 'upload'">
<el-upload <el-upload
v-if="
formType == 'add' || (formType == 'edit' && !item.editDisable)
"
ref="upload"
class="avatar-uploader" class="avatar-uploader"
:action="uploadUrl" :action="uploadUrl"
:data="{ customerId: customerId }" :data="{ customerId: customerId }"
@ -196,12 +205,21 @@
:file-list="fmData[item.keyName]" :file-list="fmData[item.keyName]"
:on-success="(res, file) => handleImgSuccess(res, file, item)" :on-success="(res, file) => handleImgSuccess(res, file, item)"
:on-remove="(res) => handleImgRemove(res, item)" :on-remove="(res) => handleImgRemove(res, item)"
:on-exceed="(res) => handleImgExceed(res, item)"
:before-upload="(file) => beforeImgUpload(file, item)" :before-upload="(file) => beforeImgUpload(file, item)"
> >
<a <a
><i class="el-icon-plus avatar-uploader-icon"></i> 点击上传</a ><i class="el-icon-plus avatar-uploader-icon"></i> 点击上传</a
> >
</el-upload> </el-upload>
<el-image
v-else-if="fmData[item.keyName].length > 0"
style="width: 100px; height: 50px"
:src="fmData[item.keyName][0].url"
fit="cover"
:preview-src-list="fmData[item.keyName].map((item) => item.url)"
></el-image>
<span v-else>--</span>
</template> </template>
<template v-else-if="item.type == 'address'"> <template v-else-if="item.type == 'address'">
@ -212,6 +230,7 @@
v-model="fmData[item.keyName]" v-model="fmData[item.keyName]"
:maxlength="item.maxlength || ''" :maxlength="item.maxlength || ''"
show-word-limit show-word-limit
size="small"
> >
</el-input> </el-input>
<el-button <el-button
@ -409,10 +428,12 @@ export default {
iniFmData() { iniFmData() {
const { editParams, fmData, editParamsDiv } = this; const { editParams, fmData, editParamsDiv } = this;
editParams.forEach((item, index) => { editParams.forEach((item, index) => {
fmData[item.keyName] = item.value || ""; fmData[item.keyName] =
typeof item.value == "function" ? item.value() : "";
if (item.supValues) { if (item.supValues) {
item.supValues.forEach((value, index) => { item.supValues.forEach((value, index) => {
fmData[item.supKeys[index]] = value; fmData[item.supKeys[index]] =
typeof value == "function" ? value() : "";
}); });
} }
@ -509,17 +530,29 @@ export default {
} }
}, },
handleImgExceed(res, item) {
console.log(e);
// this.$message({
// type: "warning",
// message: "",
// });
},
handleImgSuccess(res, file, item) { handleImgSuccess(res, file, item) {
console.log("handleImgSuccess", res); console.log("handleImgSuccess", res);
if (res.code === 0 && res.msg === "success") { if (res.code === 0 && res.msg === "success") {
let { fmData } = this; let { fmData } = this;
let picItem = { // let picItem = {
url: res.data.url, // url: res.data.url,
name: file.name, // name: file.name,
size: file.size, // size: file.size,
type: file.type, // type: file.type,
format: file.name.split(".").pop(), // format: file.name.split(".").pop(),
}; // };
let picItem = file;
picItem.url = res.data.url;
picItem.format = file.name.split(".").pop();
if (Array.isArray(this.fmData[item.keyName])) { if (Array.isArray(this.fmData[item.keyName])) {
this.fmData[item.keyName].push(picItem); this.fmData[item.keyName].push(picItem);
} else { } else {
@ -760,6 +793,7 @@ export default {
type: "success", type: "success",
message: "操作成功", message: "操作成功",
}); });
this.handleCancle();
this.$emit("afterEdit"); this.$emit("afterEdit");
this.btnDisable = false; this.btnDisable = false;
} else { } else {
@ -785,29 +819,39 @@ export default {
flex-wrap: wrap; flex-wrap: wrap;
.item { .item {
width: 50%; min-width: 45%;
.item-rich-text {
width: 817px;
&.z-show {
box-sizing: border-box;
padding: 15px;
border: 1px solid #eee;
height: auto;
}
}
} }
} }
.item-show { .item-show {
width: 225px; width: 324px;
} }
.item-input { .item-input {
width: 225px; width: 324px;
} }
.item-select { .item-select {
width: 225px; width: 324px;
} }
.item-number { .item-number {
width: 125px; width: 180px;
} }
.address-item { .address-item {
width: 450px; width: 350px;
.address-item-input { .address-item-input {
width: 85%; width: 74%;
} }
.address-item-input2 { .address-item-input2 {
margin-left: 5px; margin-left: 5px;
@ -818,7 +862,7 @@ export default {
.item-rich-text { .item-rich-text {
width: 600px; width: 600px;
height: 450px; height: 500px;
img { img {
max-width: 100%; max-width: 100%;
} }

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

@ -58,7 +58,7 @@
type="date" type="date"
placeholder="开始时间" placeholder="开始时间"
style="width: 150px" style="width: 150px"
format="yyyy-MM-dd" value-format="yyyy-MM-dd"
clearable clearable
> >
</el-date-picker> </el-date-picker>
@ -68,7 +68,7 @@
type="date" type="date"
placeholder="结束时间" placeholder="结束时间"
style="width: 150px" style="width: 150px"
format="yyyy-MM-dd" value-format="yyyy-MM-dd"
clearable clearable
> >
</el-date-picker> </el-date-picker>
@ -221,6 +221,8 @@
>删除</el-button >删除</el-button
> >
</el-popconfirm> </el-popconfirm>
<slot name="listBtnSup" v-bind:item="scope.row"></slot>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -253,6 +255,7 @@
@closed="handleClose" @closed="handleClose"
> >
<edit-form <edit-form
v-if="formShow"
ref="editForm" ref="editForm"
:idName="idName" :idName="idName"
:formId="formId" :formId="formId"
@ -440,6 +443,7 @@ export default {
await nextTick(100); await nextTick(100);
this.computeSearchHeight(); this.computeSearchHeight();
}, },
methods: { methods: {
computeSearchHeight() { computeSearchHeight() {
this.ref_search_height = this.$refs["ref_search"].clientHeight; this.ref_search_height = this.$refs["ref_search"].clientHeight;
@ -677,8 +681,12 @@ export default {
return fmData; return fmData;
}, },
refresh() {
this.getTableData();
},
async getTableData() { async getTableData() {
const { tableUrl: url, searchParams } = this; const { tableUrl: url } = this;
if (!url) return; if (!url) return;
const { pageSize, pageNo } = this; const { pageSize, pageNo } = this;

Loading…
Cancel
Save