inleft
2024-01-10 7319260f31c9a593418ff17b1ca42e0822c3c4eb
commit | author | age
b505f3 1 <template>
fa1bd9 2     <div class="myModal">
I 3         <a-modal v-drag-modal ref="blogAddModal" v-model="visible" title="日志添加" on-ok="handleOk"
4             :bodyStyle="{'overflow':'overlay','maxHeight': '550px'}" :destroyOnClose="destroyOnClose">
b505f3 5             <template slot="footer">
I 6                 <a-button key="reset" @click="reset" type="danger">
7                     擦掉重来
8                 </a-button>
9                 <a-button key="back" @click="handleCancel">
10                     歇会
11                 </a-button>
12                 <a-button key="submit" type="primary" :loading="loading" @click="handleOk">
13                     完事<span style="font-size: 10px;">儿</span>..
14                 </a-button>
15             </template>
16             <box10 ref="modalBox"></box10>
17         </a-modal>
18     </div>
19
20 </template>
21
22 <script>
23     import box10 from "../mini/box10-add.vue"
c23efb 24
63f511 25     import {
I 26         blogAdd
27     } from '../../api/blogArticle.js'
c23efb 28     import md5 from 'js-md5';
b505f3 29     export default {
I 30         components: {
31             box10
32         },
33         data() {
34             return {
35                 visible: false,
36                 loading: false,
fa1bd9 37                 destroyOnClose: false,
b505f3 38             }
I 39         },
40         methods: {
41             getCalendarContainer(trigger) {
42                 return this.$refs.myModal;
43             },
44             showModal() {
45                 this.visible = true;
46             },
47             handleOk(e) {
48                 console.log(this.$refs.modalBox.form);
c23efb 49                 var res;
I 50                 this.$refs.modalBox.$refs.myForm.validate(valid => {
b505f3 51                     if (valid) {
I 52                         this.$message.info("校验通过")
c23efb 53                         res = true;
b505f3 54                     } else {
I 55                         this.$message.info("校验失败")
c23efb 56                         res = false;
b505f3 57                     }
I 58                 });
59
60                 if (!res) return;
61                 this.$message.info("提交表单")
62
c23efb 63                 let tempData = this.$refs.modalBox.form;
I 64                 var param = {
fa1bd9 65                     introduce: tempData.introduce,
731926 66                     secret: tempData.secret == "" ? null : md5(tempData.secret),
c23efb 67                     title: tempData.title,
I 68                     articleTypeId: tempData.class,
69                     isOnline: !tempData.online ? 1 : 0,
70                     articleFileId: tempData.fileId,
71                     content: tempData.content,
72                     articleFileType: tempData.blogType,
73                     coverFileId: tempData.coverFile,
fa1bd9 74                     pictureIds: tempData.pictureIds,
I 75                     videoIds: tempData.videoIds,
c23efb 76                     publishDate: tempData.publishDate,
I 77                     isTop: tempData.top ? 1 : 0,
78                     topValue: tempData.sliderValue,
79                     isLock: tempData.lock ? 1 : 0,
80                     authStatus: tempData.auth,
81                     authPassword: tempData.password == "" ? null : md5(tempData.password),
fa1bd9 82                     editorStatus: !tempData.tempSave ? 1 : 0
c23efb 83                 }
I 84                 console.log(param)
b505f3 85                 this.loading = true;
c23efb 86                 blogAdd(param).then((res) => {
731926 87                     
I 88                     if (res.code == 200) {
89                         this.$message.info("生成日志成功..")
90                         this.visible = false;
91                     } else{
92                         this.$message.error('生成日志失败:' + res.message)
93                     }
b505f3 94                     this.loading = false;
c23efb 95                 });
I 96                 // setTimeout(() => {
97                 //     this.visible = false;
98                 //     this.loading = false;
99                 // }, 3000);
b505f3 100             },
I 101             reset(e) {
fa1bd9 102                 // var res = this.$refs.modalBox.$refs.myForm.resetFields();
af029b 103                 //this.$refs.modalBox.reset();
fa1bd9 104                 this.destroyOnClose = true;
I 105                 this.visible = false;
106                 setTimeout(() => {
107                     this.destroyOnClose = false;
108                 }, 500)
b505f3 109             },
I 110             handleCancel(e) {
111                 this.visible = false;
112             },
113
114         },
115     }
116 </script>
117
118 <style>
119 </style>