提交 7d901a45 编写于 作者: 麦嘉得's avatar 麦嘉得

①修复新增操作附件列表,删除bug问题v230116

上级 a66ba487
......@@ -10,7 +10,7 @@ import Vconsole from 'vconsole';
//let vConsole = new Vconsole();
let vConsole = new Vconsole();
Vue.prototype.$api = api.commonUrl
Vue.config.productionTip = false;
......
......@@ -19,7 +19,7 @@ export default {
methods: {
SSO(code, sign, timestamp) {
//测试阶段
//TestSSO({ card: "asc666" }).then((resp) => {
//TestSSO({ card: "syjs381" }).then((resp) => {
//部署阶段
wxSSO({ code: code, sign: sign, timestamp: timestamp }).then((resp) => {
this.UTIL.setCookie(
......
......@@ -27,48 +27,132 @@
fixed
style="border-bottom: 1px solid #dedede"
/>
<van-form @submit="onSubmit" style="margin-top: 60px;padding-bottom: 20px">
<van-form @submit="onSubmit" style="margin-top: 60px; padding-bottom: 20px">
<div class="centre">
<van-cell-group>
<van-field label="一级栏目:" v-model="form.column" placeholder="请选择一级栏目" label-width="5.2em"
required readonly right-icon="arrow-down"
@click="init.column.showFlag=true"
:rules="[{ required: true, message: '请选择一级栏目' }]" />
<van-field v-model="form.title" label="标题:" placeholder="请输入标题" label-width="5.2em" required :rules="[{ required: true, message: '请输入标题' }]"/>
<van-field
label="一级栏目:"
v-model="form.column"
placeholder="请选择一级栏目"
label-width="5.2em"
required
readonly
right-icon="arrow-down"
@click="init.column.showFlag = true"
:rules="[{ required: true, message: '请选择一级栏目' }]"
/>
<van-field
v-model="form.title"
label="标题:"
placeholder="请输入标题"
label-width="5.2em"
required
:rules="[{ required: true, message: '请输入标题' }]"
/>
<van-field label="选择人员:" label-width="5.2em" required>
<template #input>
<van-radio-group v-model="form.radio">
<van-radio name="1" class="radio-style" @click="ChangeValue(1)">所有人员</van-radio>
<van-radio name="2" class="radio-style" @click="ChangeValue(2)">指定部门</van-radio>
<van-radio name="3" class="radio-style" @click="ChangeValue(3)">指定人员</van-radio>
<van-radio name="4" class="radio-style" @click="ChangeValue(4)">指定群组</van-radio>
<van-radio name="1" class="radio-style" @click="ChangeValue(1)"
>所有人员</van-radio
>
<van-radio name="2" class="radio-style" @click="ChangeValue(2)"
>指定部门</van-radio
>
<van-radio name="3" class="radio-style" @click="ChangeValue(3)"
>指定人员</van-radio
>
<van-radio name="4" class="radio-style" @click="ChangeValue(4)"
>指定群组</van-radio
>
</van-radio-group>
</template>
</van-field>
<van-field label="已选:" placeholder="请输入摘要" label-width="5.2em" type="textarea" rows="3" autosize>
<van-field
label="已选:"
placeholder="请输入摘要"
label-width="5.2em"
type="textarea"
rows="3"
autosize
>
<template #input>
<div>
<van-tag plain type="primary" class="space" v-for="(item,index) in openData" :key="index">{{item.label}}</van-tag>
<van-tag
plain
type="primary"
class="space"
v-for="(item, index) in openData"
:key="index"
>{{ item.label }}</van-tag
>
</div>
</template>
</van-field>
<!-- 附件上传 -->
<a-upload :customRequest="handleAction" :showUploadList="false" :disabled="disabled">
<van-field label="附件:" placeholder="点击上传附件" label-width="5.2em" type="textarea" rows="1" autosize readonly>
<a-upload
:customRequest="handleAction"
:showUploadList="false"
:disabled="disabled"
>
<van-field
label="附件:"
placeholder="点击上传附件"
label-width="5.2em"
type="textarea"
rows="1"
autosize
readonly
>
<template #right-icon>
<van-icon name="add-o" color="#1890ff" style="line-height: 25px; font-weight: 600" />
<van-icon
name="add-o"
color="#1890ff"
style="line-height: 25px; font-weight: 600"
/>
</template>
</van-field>
</a-upload>
<!-- 附件列表 -->
<a-spin tip="上传文件中..." :spinning="disabled" >
<a-spin tip="上传文件中..." :spinning="disabled">
<div></div>
<div class="file-content" style="padding: 10px;border-top: 2px dotted #dedede" v-if="file_list.length>0">
<van-row style="margin: 8px 0px 10px;display: flex;align-items: center;" v-for="(item,index) in file_list" :key="index">
<van-col span="2"><van-image :src="require('@/assets/images/icon/image.png')" width="18" height="20"/></van-col>
<van-col span="16" style="color: #1890ff;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;" @click="onUrlFile(item.附件地址)">{{item.附件名}}</van-col>
<van-col span="6" style="color: #1890ff;position: relative">
<a @click="onDelFile(item.id)" style="margin: 0 5px;position: absolute;top: -10px;right: 0;">删除</a>
<div
class="file-content"
style="padding: 10px; border-top: 2px dotted #dedede"
v-if="file_list.length > 0"
>
<van-row
style="margin: 8px 0px 10px; display: flex; align-items: center"
v-for="(item, index) in file_list"
:key="index"
>
<van-col span="2"
><van-image
:src="require('@/assets/images/icon/image.png')"
width="18"
height="20"
/></van-col>
<van-col
span="16"
style="
color: #1890ff;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
"
@click="onUrlFile(item.附件地址)"
>{{ item.附件名 }}</van-col
>
<van-col span="6" style="color: #1890ff; position: relative">
<a
@click="onDelFile(item.id)"
style="
margin: 0 5px;
position: absolute;
top: -10px;
right: 0;
"
>删除</a
>
</van-col>
</van-row>
</div>
......@@ -85,8 +169,18 @@
label-width="5.2em"
:rules="[{ required: true, message: '请输入内容' }]"
/> -->
<div style="height:14px;background: #f2f3f5;"></div>
<wangeditor v-model="details" :isClear="isClear" @change="changeEditor" style="margin-top: 10px;padding: 10px;position: relative;z-index: 1;"></wangeditor>
<div style="height: 14px; background: #f2f3f5"></div>
<wangeditor
v-model="details"
:isClear="isClear"
@change="changeEditor"
style="
margin-top: 10px;
padding: 10px;
position: relative;
z-index: 1;
"
></wangeditor>
</van-cell-group>
</div>
<div class="bottom-btn">
......@@ -95,13 +189,18 @@
<van-button type="info" plain round style="width: 100%;" @click="onUpdate">保存</van-button>
</van-col> -->
<van-col span="24">
<van-button type="info" round style="width: 90%;" native-type="submit">保存</van-button>
<van-button
type="info"
round
style="width: 90%"
native-type="submit"
>保存</van-button
>
</van-col>
</van-row>
</div>
</van-form>
<!-- 人员选择器 -->
<van-popup
v-model="init.name.showFlag"
......@@ -134,186 +233,197 @@
<script>
import openvalue from "./open-value.vue";
import wangeditor from '@/components/wang-editor'
import { FirstColumn,DeptList,TeacherList,GroupList,addNews,EditNews,GetNewsInfo } from "@/common/api/myBaseInfo";
import {news_upfile} from "@/common/api/common"
import wangeditor from "@/components/wang-editor";
import {
FirstColumn,
DeptList,
TeacherList,
GroupList,
addNews,
EditNews,
GetNewsInfo,
} from "@/common/api/myBaseInfo";
import { news_upfile } from "@/common/api/common";
export default {
components: {
openvalue,
wangeditor
wangeditor,
},
data(){
return{
init:{
data() {
return {
init: {
name: {
showFlag: false,
nowList: [],
},
column:{
column: {
showFlag: false,
data:[],
data_sum:[],
data: [],
data_sum: [],
},
dept:{
data:[],
dept: {
data: [],
},
people:{
data:[],
people: {
data: [],
},
group:{
data:[],
}
group: {
data: [],
},
form:{
column:"",
title:"",
radio:"1",
selected:"",
content:"",
},
openData:[],
userInfo:{},
groupList:[],//群组list
form: {
column: "",
title: "",
radio: "1",
selected: "",
content: "",
},
openData: [],
userInfo: {},
groupList: [], //群组list
//富文本
details:'',
isClear:false,
details: "",
isClear: false,
//附件
disabled:false,
file_list:[],
disabled: false,
file_list: [],
//status
status:'',
newId:'',
}
status: "",
newId: "",
};
},
created(){
this.userInfo=JSON.parse(window.localStorage.getItem("userInfo"));
this.status = this.$route.query.status
created() {
this.userInfo = JSON.parse(window.localStorage.getItem("userInfo"));
this.status = this.$route.query.status;
//获取一级栏目
FirstColumn().then((resp) => {
this.init.column.data = [];
this.init.column.data_sum=resp;
resp.filter(item=>{
this.init.column.data_sum = resp;
resp.filter((item) => {
this.init.column.data.push(item.field_02);
})
if(this.$route.query.status == 'edit'){
});
if (this.$route.query.status == "edit") {
this.$toast.loading({
message: "加载中...",
forbidClick: true,
duration: 0,
});
//获取详情
GetNewsInfo({id:this.$route.query.id}).then((resp) => {
GetNewsInfo({ id: this.$route.query.id }).then((resp) => {
this.$toast.clear();
this.form.newId = resp.news[0].id;
this.form.column = resp.news[0].一级栏目名;
this.form.title = resp.news[0].标题;
this.form.radio = resp.news[0].查看限制类型
this.details= resp.news[0].新闻内容_html;
this.form.radio = resp.news[0].查看限制类型;
this.details = resp.news[0].新闻内容_html;
//附件
this.file_list = resp.files;
//人员状态
this.openData = [];
switch(this.form.radio) {
switch (this.form.radio) {
case "1":
break;
case "2":
var dept = resp.news[0].可查看部门集合
var str = dept.split(",")
str.filter(item=>{
var dept = resp.news[0].可查看部门集合;
var str = dept.split(",");
str.filter((item) => {
this.openData.push({
label:item,
value:item
label: item,
value: item,
});
});
})
break;
case "3":
var people = resp.news[0].可查看人集合
var str = people.split(",")
str.filter(item=>{
var people = resp.news[0].可查看人集合;
var str = people.split(",");
str.filter((item) => {
this.openData.push({
label:item,
value:item
label: item,
value: item,
});
});
})
break;
case "4":
var group = resp.news[0].可查看人集合
var str = group.split(",")
str.filter(item=>{
var group = resp.news[0].可查看人集合;
var str = group.split(",");
str.filter((item) => {
this.openData.push({
label:item,
value:item
label: item,
value: item,
});
});
})
break;
}
})
});
}
});
//获取部门
DeptList().then((resp) => {
this.init.dept.data = [];
resp.filter(item=>{
resp.filter((item) => {
this.init.dept.data.push({
id:item.id,
label:item.部门名称
id: item.id,
label: item.部门名称,
});
});
})
});
//获取人员
TeacherList().then((resp) => {
resp.filter(item=>{
resp.filter((item) => {
this.init.people.data.push({
id:item.卡号,
label:item.姓名
id: item.卡号,
label: item.姓名,
});
});
})
});
//获取群组
GroupList().then((resp) => {
this.groupList = resp;
resp.filter(item=>{
resp.filter((item) => {
this.init.group.data.push({
id:item.group_card_list,
label:item.group_name
id: item.group_card_list,
label: item.group_name,
});
});
})
});
},
methods:{
methods: {
//附件地址
onUrlFile(data){
onUrlFile(data) {
//window.location.href = '/News/UploadFile/' + data
},
//删除附件
onDelFile(id){
this.file_list = this.file_list.filter(item=>{
onDelFile(id) {
this.file_list = this.file_list.filter((item) => {
return item.id != id;
})
});
},
//提交
onSubmit(){
onSubmit() {
//console.log(this.details);
this.$dialog.confirm({
title: '提示',
message: '您确认要保存此新闻吗?',
}).then(() => {
this.$dialog
.confirm({
title: "提示",
message: "您确认要保存此新闻吗?",
})
.then(() => {
// on confirm
this.handleSubmit();
}).catch(() => {
})
.catch(() => {
// on cancel
});
},
handleSubmit(){
var columnId="";
handleSubmit() {
var columnId = "";
//栏目id
this.init.column.data_sum.filter((item,i)=>{
if(item.field_02==this.form.column){
columnId=item.field_01;
this.init.column.data_sum.filter((item, i) => {
if (item.field_02 == this.form.column) {
columnId = item.field_01;
}
})
var json={
});
var json = {
一级栏目表id: columnId,
一级栏目名: this.form.column,
查看限制类型: this.form.radio,
......@@ -322,59 +432,60 @@ export default {
新闻内容text: this.form.content,
发布状态标识: "0",
新闻内容html: this.details,
可查看人集合:"",
可查看部门集合:"",
可查看人集合: "",
可查看部门集合: "",
次数: 0,
files:this.file_list,
}
var dept_Str="";
var people_Str="";
var group_Str="";
switch(this.form.radio) {
files: this.file_list,
};
var dept_Str = "";
var people_Str = "";
var group_Str = "";
switch (this.form.radio) {
case "1":
break;
case "2":
this.openData.filter((item,i)=>{
if(i==0){
dept_Str=item.label;
}else{
dept_Str+=","+item.label;
this.openData.filter((item, i) => {
if (i == 0) {
dept_Str = item.label;
} else {
dept_Str += "," + item.label;
}
})
json.可查看人集合="";
json.可查看部门集合=dept_Str;
});
json.可查看人集合 = "";
json.可查看部门集合 = dept_Str;
break;
case "3":
this.openData.filter((item,i)=>{
if(i==0){
people_Str=item.value;
}else{
people_Str+=","+item.value;
this.openData.filter((item, i) => {
if (i == 0) {
people_Str = item.value;
} else {
people_Str += "," + item.value;
}
})
json.可查看人集合=people_Str;
json.可查看部门集合="";
});
json.可查看人集合 = people_Str;
json.可查看部门集合 = "";
break;
case "4":
this.openData.filter((item,i)=>{
if(i==0){
group_Str=item.value;
}else{
group_Str+=","+item.value;
this.openData.filter((item, i) => {
if (i == 0) {
group_Str = item.value;
} else {
group_Str += "," + item.value;
}
})
var str=group_Str.split(",");
var array=this.arrayUnique1(str);
json.可查看人集合=array.toString();
json.可查看部门集合="";
});
var str = group_Str.split(",");
var array = this.arrayUnique1(str);
json.可查看人集合 = array.toString();
json.可查看部门集合 = "";
break;
}
console.log('json',json);
console.log("json", json);
this.saveApi(json);
},
//去重数组
arrayUnique1(arr) {
var result = [], hash = {};
var result = [],
hash = {};
for (var i = 0, elem; (elem = arr[i]) != null; i++) {
if (!hash[elem]) {
result.push(elem);
......@@ -384,23 +495,23 @@ export default {
return result;
},
//保存
saveApi(json){
saveApi(json) {
this.$toast.loading({
message: "保存中...",
forbidClick: true,
duration: 0,
});
switch(this.status) {
switch (this.status) {
case "add":
//新增
addNews(json).then((resp) => {
this.$router.push({
path: "/list",
query: { status: "",},
query: { status: "" },
});
this.$toast.clear();
this.$toast('保存成功');
})
this.$toast("保存成功");
});
break;
case "edit":
json.id = this.form.newId;
......@@ -408,115 +519,125 @@ export default {
EditNews(json).then((resp) => {
this.$router.push({
path: "/list",
query: { status: "",},
query: { status: "" },
});
this.$toast.clear();
this.$toast('保存成功');
})
this.$toast("保存成功");
});
break;
}
},
back(){
back() {
this.$router.push({
path: "/",
});
},
close_mode(){
this.init.name.showFlag=false;
close_mode() {
this.init.name.showFlag = false;
},
//回调人员选择器
onchecked(data){
onchecked(data) {
var arr = [];
this.openData=[]
if(this.form.radio == '4'){
this.openData = [];
if (this.form.radio == "4") {
//群组逻辑
data.filter(item=>{
arr.push(item.split("`")[0])
})
data.filter((item) => {
arr.push(item.split("`")[0]);
});
arr = arr.toString().split(",");
var new_arr = this.arrayUnique1(arr)
new_arr.filter((res,i)=>{
var new_arr = this.arrayUnique1(arr);
new_arr.filter((res, i) => {
this.openData.push({
label:res,
value:res,
})
})
}else{
data.filter((item,i)=>{
label: res,
value: res,
});
});
} else {
data.filter((item, i) => {
this.openData.push({
label:item.split("`")[1],
value:item.split("`")[0],
})
})
label: item.split("`")[1],
value: item.split("`")[0],
});
});
}
this.init.name.showFlag=false;
this.init.name.showFlag = false;
},
//监听选择器
ChangeValue(type){
this.openData=[];
this.init.name.nowList=[];
if(type>1) this.init.name.showFlag=true;
console.log(1111)
ChangeValue(type) {
this.openData = [];
this.init.name.nowList = [];
if (type > 1) this.init.name.showFlag = true;
console.log(1111);
this.$nextTick(() => {
console.log(22222)
if(type==1) this.init.name.nowList = [];
if(type==2) this.init.name.nowList = this.init.dept.data;
if(type==3) {
console.log(22222);
if (type == 1) this.init.name.nowList = [];
if (type == 2) this.init.name.nowList = this.init.dept.data;
if (type == 3) {
this.init.name.nowList = this.init.people.data;
}
if(type==4) this.init.name.nowList = this.init.group.data;
if(type>1) this.$refs.name_ref.init.name.keyword = "";
if(type>1) this.$refs.name_ref.init.name.checked=[];
if (type == 4) this.init.name.nowList = this.init.group.data;
if (type > 1) this.$refs.name_ref.init.name.keyword = "";
if (type > 1) this.$refs.name_ref.init.name.checked = [];
});
},
//栏目
onConfirm_column(value){
this.form.column=value;
this.init.column.showFlag=false;
onConfirm_column(value) {
this.form.column = value;
this.init.column.showFlag = false;
},
/////////////富文本///////////
//子组件编辑器的值改变同步赋值
changeEditor(val) {
// console.log(val)
this.details = val
this.details = val;
},
/////////////上传附件/////////
//上传附件
handleAction(e) {
this.disabled = true;
console.log("file", e.file);
var json={
fileType:"file",
uploadFile:e.file
}
var json = {
fileType: "file",
uploadFile: e.file,
};
news_upfile(json).then((resp) => {
console.log('file',resp);
console.log("file", resp);
this.file_list.push({
id: this.newGuid(),
附件地址: resp,
附件名: e.file.name,
})
});
this.disabled = false;
});
},
newGuid() {
var guid = "";
for (var i = 1; i <= 32; i++) {
var n = Math.floor(Math.random() * 16.0).toString(16);
guid += n;
if (i == 8 || i == 12 || i == 16 || i == 20) guid += "-";
}
}
return guid;
},
},
};
</script>
<style lang="less" scoped>
.centre{
.centre {
margin-bottom: 70px;
}
.space{
.space {
margin: 0px 2px;
}
.radio-style{
.radio-style {
margin-top: 5px;
margin-bottom: 15px;
}
.centre{
.centre {
margin-top: 10px;
}
.bottom-btn{
.bottom-btn {
//margin: 20px;
border-top: 1px solid rgb(222, 222, 222);
z-index: 10;
......@@ -535,7 +656,7 @@ export default {
height: 100%;
}
}
/deep/.ant-upload-select-text{
/deep/.ant-upload-select-text {
width: 100%;
}
</style>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 人 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册 或