inleft
2022-08-31 3c71cc74e6dd5f1015329c64e11e8ec1cd7a97c1
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,
3c71cc 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) => {
I 87                     this.$message.info("生成日志成功..")
b505f3 88                     this.visible = false;
I 89                     this.loading = false;
c23efb 90                 });
I 91                 // setTimeout(() => {
92                 //     this.visible = false;
93                 //     this.loading = false;
94                 // }, 3000);
b505f3 95             },
I 96             reset(e) {
fa1bd9 97                 // var res = this.$refs.modalBox.$refs.myForm.resetFields();
af029b 98                 //this.$refs.modalBox.reset();
fa1bd9 99                 this.destroyOnClose = true;
I 100                 this.visible = false;
101                 setTimeout(() => {
102                     this.destroyOnClose = false;
103                 }, 500)
b505f3 104             },
I 105             handleCancel(e) {
106                 this.visible = false;
107             },
108
109         },
110     }
111 </script>
112
113 <style>
114 </style>