create.vue 5.21 KB
Newer Older
qiaoyanqi committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
<style  lang="less">
@background-color: #fff;
@title-color: #101317;


// .fullscreen .ivu-modal-body{
//     padding-bottom:0px;
// }
.news-carousel-create {
    .fullscreen .ivu-modal-body {
        padding-bottom:0px;
    }
    .ivu-modal .ivu-modal-content .ivu-modal-footer {
        height: 0px;
    }  
}
</style>
<template>
    <Modal v-model="visible" title="新建图文" fullscreen class="news-carousel-create"
        :mask-closable="false">
        <div slot="close"></div>
        <div slot="footer"></div>
        <div slot="header" style="margin-top:-1px;height:46px">
            <span style="font-size:16px;margin-left:-2px;width:64px;
                height:22px;
                font-size:16px;
                font-family:PingFangSC;
                font-weight:400;
                color:rgba(85,85,85,1);
                line-height:22px;">新建图文</span>
            <i-button style="float:right;height:32px;width:75px;margin-top:-4px;" @click="doCancel">取消</i-button>

            <i-button  style="float:right;height:32px;width:75px;background:#409C9C;margin-top:-4px;margin-right:10px;color:white" @click="doOk" :loading="loading">保存</i-button>

        </div>
       <div style="height: calc(100% + 70px);margin-left:-16px;margin-top:-16px;width:calc(100% + 30px)">
            <Editor  :article="article" v-if="VIF" :fieldList="fieldList" :vision="visible" :topic="topic" ref="editor"></Editor>
        </div>
        
    </Modal>
</template>
<script>

import Editor from './custom-field-editor';

export default {
    data(){
        return {
            article: {
              
            },
            VIF:false,
            loading: false,
            username:"tenant",
        }
    },
    props : {
        value: {
            type: Boolean
        },
        groupId: {
            type: String,
            default:function(){
                return ""
            }
        },
        topic: {
            type: String,
            default:function(){
                return ""
            }
        },
        functionGroup: {
            type: String,
            required:true,
            default:function(){
                return ""
            }
        },
        fieldList:{
            type:Array,
            required:false,
            default:function(){
                return null
            }
        }
    },
    mounted(){
        this.refresh();
        this.getUsername();
    },
    methods:{
        getUsername(){
            // SEDU.Util.getAuthcInfo().then((authcInfo) => {
            //     this.username = authcInfo.username;
            // }).catch((XMLHttpRequest, textStatus, errorThrown) => {
            //     console.log(errorThrown)
            // });
        },
        refresh(){
            let url = "/gms/bill/newed/bill.announcementBillDefine";
            var that = this;
            GMS.$http.get(url).then(response=>
                {
                    that.VIF = true;
                    that.article = response.data.content;
                    that.article.typeName = "article";
                    that.article.functionGroup = that.functionGroup;
                    that.article.params = "";
                    that.article.sticky = false;
                    if(that.groupId&&that.groupId!=""){
                        that.article.group={
                            _type:"com.jiuqi.gov.sedu.news.entity.NewsGroupEntity",
                            id:that.groupId
                        }
                    }
                }).catch(error => {
                    console.log("加载新建页面报错!");
                })
        },
        doOk(){
            this.$refs.editor.validate((valid,content,params) => {
                if (!valid) {
                    return;
                }
                this.loading = true;
                var that = this;
                that.article.content = content;
                that.article.params = JSON.stringify(params);
                that.article.group = that.functionGroup.name;
                let url = "/gms/bill/saved/bill.announcementBillDefine";
                var jsonData = JSON.stringify(that.article)
                GMS.$http.post(url,jsonData,{
                    headers: {
                        post: {
                        'Content-Type': 'application/json',
                        },
                    }
                }).then(response => {
                    that.$Modal.remove();
                    that.$emit('保存成功', that.article);
                    that.$parent.refresh();
                    that.visible = false;
                    that.loading = false;
                }).catch(error =>{
                    console.log("保存报错");
                    that.loading = false;
                })
            })       
        },

        doCancel() {
            this.visible = false;
        },
    },
    components: {
        Editor
    },
    watch : {
        'visible' : function(val){
            if(val){
                this.refresh();
            }
        }
    },
    computed : {
        visible: {
            set : function(val){
                this.$emit('input', val);
            },
            get : function(){
                return this.value;
            }
        }
    }
}
</script>