| | |
| | | </span> |
| | | </a-form-model-item> |
| | | |
| | | |
| | | <a-form-model-item label="日志文件" v-show="!form.online"> |
| | | <!-- <a-upload action="https://www.mocky.io/v2/5cc8019d300000980a055e76" |
| | | :default-file-list="form.blogFileList"> |
| | | <a-button> |
| | | <a-icon type="upload" /> 限 markdown/html |
| | | </a-button> |
| | | </a-upload> --> |
| | | |
| | | <a-upload :customRequest="customRequest" name="file" :showUploadList="true" @change="handleChange" |
| | | :default-file-list="form.blogFileList" |
| | | :beforeUpload="beforeUpload" |
| | | > |
| | | |
| | | <a-upload ref="blogFileUpload" :customRequest="customRequest" name="file" :showUploadList="true" |
| | | @change="handleChange" :default-file-list="form.blogFileList" :beforeUpload="beforeUpload" |
| | | :data="{'bucketName':bucketName.bucket_article}" accept=".md,.html,.htm,.txt"> |
| | | <a-button> |
| | | <a-icon type="upload" />限 markdown/html |
| | | </a-button> |
| | | </a-upload> |
| | | </a-form-model-item> |
| | | |
| | | <a-form-model-item label="日志内容" v-show="form.online" prop="content"> |
| | | <a-form-model-item label="日志内容" v-show="form.online"> |
| | | <a-input v-model="form.content" type="textarea" placeholder="限10k字数" /> |
| | | </a-form-model-item> |
| | | |
| | |
| | | </span> |
| | | </a-form-model-item> |
| | | |
| | | <a-form-model-item label=" 日志类型"> |
| | | <a-radio-group v-model="form.blogType"> |
| | | <a-radio value="Markdown"> |
| | | <a-form-model-item label=" 日志主类型"> |
| | | <a-select v-model="form.blogType" mode="default" placeholder="" |
| | | :getPopupContainer="getCalendarContainer()"> |
| | | <a-select-option value="1"> |
| | | markdown |
| | | </a-radio> |
| | | <a-radio value="Html"> |
| | | </a-select-option> |
| | | <a-select-option value="2"> |
| | | html |
| | | </a-radio> |
| | | </a-radio-group> |
| | | </a-select-option> |
| | | <a-select-option value="3"> |
| | | 视频 |
| | | </a-select-option> |
| | | <a-select-option value="4"> |
| | | 音频 |
| | | </a-select-option> |
| | | <a-select-option value="5"> |
| | | 图组 |
| | | </a-select-option> |
| | | <a-select-option value="9"> |
| | | taking |
| | | </a-select-option> |
| | | </a-select> |
| | | </a-form-model-item> |
| | | |
| | | |
| | |
| | | |
| | | |
| | | <a-form-model-item label="封面"> |
| | | <!-- <a-upload action="https://www.mocky.io/v2/5cc8019d300000980a055e76" list-type="picture" |
| | | :default-file-list="form.coverFileList" class="upload-list-inline"> |
| | | <a-button> |
| | | <a-icon type="upload" /> jpg/png/jpeg.. |
| | | </a-button> |
| | | </a-upload> --> |
| | | |
| | | <a-upload :customRequest="customRequest" name="file" :showUploadList="true" list-type="picture" |
| | | :default-file-list="form.coverFileList"> |
| | | :data="{'bucketName':bucketName.bucket_cover}" @change="handleChangeCoverFile" |
| | | :default-file-list="form.coverFileList" :beforeUpload="beforeUploadCover" |
| | | accept=".jpg,.png,.jpeg"> |
| | | <!-- :disabled="form.coverFileList.length>=1" --> |
| | | <a-button> |
| | | <a-icon type="upload" />jpg/png/jpeg.. |
| | | </a-button> |
| | |
| | | <div v-show="form.lock "> |
| | | <a-form-model-item label="阅读权限"> |
| | | <a-radio-group v-model="form.auth"> |
| | | <a-radio value="private"> |
| | | <a-radio value="2"> |
| | | 私人 |
| | | </a-radio> |
| | | <a-radio value="password"> |
| | | <a-radio value="3"> |
| | | 密码授权 |
| | | </a-radio> |
| | | </a-radio-group> |
| | | </a-form-model-item> |
| | | |
| | | <a-form-model-item label="授权密码" v-show="form.auth=='password'"> |
| | | <a-form-model-item label="授权密码" v-show="form.auth==3"> |
| | | <a-input-password v-model="form.password" autocomplete='new-password' type="password" |
| | | placeholder="独立密码"> |
| | | <a-icon slot="prefix" type="lock" style="color:rgba(0,0,0,.25)" /> |
| | |
| | | <script> |
| | | import moment from "moment"; |
| | | import { |
| | | sysFileInfoUpload |
| | | sysFileInfoUpload, |
| | | myFileInfoUpload |
| | | } from '../../api/fileManage.js'; |
| | | |
| | | import { |
| | | queryBlogArticleType |
| | | } from '../../api/blogArticleType.js' |
| | | |
| | | import myConstant from "../../config/myConstant.js" |
| | | import md5 from 'js-md5'; |
| | | |
| | | export default { |
| | | beforeMount() { |
| | | queryBlogArticleType({}).then((res) => { |
| | |
| | | }) |
| | | }, |
| | | data() { |
| | | |
| | | let _this = this; |
| | | let validateContent = (rule, value, callback) => { |
| | | if (this.form.online) { |
| | | console.log("内容未填"); |
| | | this.$refs.myForm.validateField('content') |
| | | if (_this.form.online) { |
| | | //this.$refs.myForm.validateField('content') |
| | | if (_this.form.content == null || _this.form.content == "") { |
| | | callback(new Error('内容未填')); |
| | | } |
| | | } else { |
| | | console.log("文件未传"); |
| | | this.$refs.myForm.validateField('blogFileList') |
| | | //this.$refs.myForm.validateField('blogFileList') |
| | | if (_this.form.fileId == null) { |
| | | callback(new Error('文件未传')); |
| | | } |
| | | } |
| | | callback(); |
| | | }; |
| | | |
| | | return { |
| | | bucketName: myConstant.bucketName, |
| | | blogArticleType: [], |
| | | // blogFileList: [], |
| | | // coverFileList: [ |
| | | // // { |
| | | // // uid: '-1', |
| | | // // name: 'xxx.png', |
| | | // // status: 'done', |
| | | // // url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png', |
| | | // // thumbUrl: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png', |
| | | // // } |
| | | // ], |
| | | tags: [], |
| | | inputVisible: false, |
| | | inputValue: '', |
| | |
| | | content: '', |
| | | class: [], |
| | | tempSave: false, |
| | | blogType: "Markdown", |
| | | blogType: "1", |
| | | publishDate: "", |
| | | lock: false, |
| | | top: false, |
| | | auth: "private", |
| | | sliderValue: 50, |
| | | auth: 1, |
| | | password: "", |
| | | fileId: null, |
| | | coverFile: null, |
| | | blogFileList: [], |
| | | coverFileList: [], |
| | | }, |
| | |
| | | trigger: 'blur' |
| | | }, |
| | | { |
| | | min: 5, |
| | | min: 1, |
| | | max: 50, |
| | | message: '字数限制1~50', |
| | | trigger: 'blur' |
| | |
| | | ], |
| | | secret: [{ |
| | | required: true, |
| | | message: '不正经的人..', |
| | | message: '好像这里错了..', |
| | | trigger: 'blur' |
| | | }], |
| | | common: [{ |
| | | validator: validateContent, |
| | | trigger: [] |
| | | }], |
| | | content: [{ |
| | | max: 10, |
| | | required: true, |
| | | message: '至少填一下上传内容', |
| | | trigger: 'blur' |
| | | }, ], |
| | | blogFileList: [{ |
| | | max: 1, |
| | | required: true, |
| | | message: '文件未上传', |
| | | }], |
| | | // content: [{ |
| | | // max: 10, |
| | | // required: true, |
| | | // message: '至少填一下上传内容', |
| | | // trigger: 'blur' |
| | | // }, ], |
| | | // blogFileList: [{ |
| | | // max: 1, |
| | | // required: true, |
| | | // message: '文件未上传', |
| | | // }], |
| | | class: [{ |
| | | required: true, |
| | | message: '至少选一个分类', |
| | | trigger: 'blur' |
| | | }, ], |
| | | // region: [{ |
| | | // required: true, |
| | | // message: 'Please select Activity zone', |
| | | // trigger: 'change' |
| | | // }], |
| | | // date1: [{ |
| | | // required: true, |
| | | // message: 'Please pick a date', |
| | | // trigger: 'change' |
| | | // }], |
| | | // type: [{ |
| | | // type: 'array', |
| | | // required: true, |
| | | // message: 'Please select at least one activity type', |
| | | // trigger: 'change', |
| | | // }, ], |
| | | // resource: [{ |
| | | // required: true, |
| | | // message: 'Please select activity resource', |
| | | // trigger: 'change' |
| | | // }, ], |
| | | // desc: [{ |
| | | // required: true, |
| | | // message: 'Please input activity form', |
| | | // trigger: 'blur' |
| | | // }], |
| | | |
| | | } |
| | | }; |
| | | }, |
| | | methods: { |
| | | beforeUpload(file, fileList) { |
| | | console.log(333); |
| | | console.log(this.blogFileList); |
| | | reset() { |
| | | // this.form.blogFileList = []; |
| | | // this.form.coverFileList = []; |
| | | }, |
| | | beforeUploadCover(file, fileList) { |
| | | return new Promise((resolve, reject) => { |
| | | if(fileList.length>=2){ |
| | | if (this.form.secret == null || this.form.secret == "") { |
| | | this.$message.error('需要正确的授权码'); |
| | | return reject(false); |
| | | } |
| | | |
| | | if (this.form.coverFileList.length >= 1) { |
| | | this.$message.error('这里最多上传一个文件'); |
| | | return reject(false); |
| | | } |
| | | // var testmsg=/^image\/(jpeg|png|jpg)$/.test(file.type) |
| | | // // var testmsg=/^image\/(md|html|markdown)$/.test(file.type) |
| | | // if (!testmsg) { |
| | | // this.$message.error('上传文件格式不对!'); |
| | | // return reject(false); |
| | | // } |
| | | |
| | | const isLt2M = file.size / 1024 / 1024 <=2//图片大小不超过2MB |
| | | if(!isLt2M) { |
| | | this.$message.error('上传文件大小不能超过 2M!'); |
| | | return reject(false); |
| | | } |
| | | return resolve(true) |
| | | }); |
| | | |
| | | if (file.size > myConstant.uploadFileSizeLimit) { |
| | | this.$message.error('上传文件大小不能超过 2M!'); |
| | | return reject(false); |
| | | } |
| | | return resolve(true) |
| | | }); |
| | | }, |
| | | beforeUpload(file, fileList) { |
| | | return new Promise((resolve, reject) => { |
| | | if (this.form.secret == null || this.form.secret == "") { |
| | | this.$message.error('需要正确的口令..'); |
| | | return reject(false); |
| | | } |
| | | |
| | | if (this.form.blogFileList.length >= 1) { |
| | | this.$message.error('这里最多上传一个文件'); |
| | | return reject(false); |
| | | } |
| | | |
| | | if (file.size > myConstant.uploadFileSizeLimit) { |
| | | this.$message.error('上传文件大小不能超过 2M!'); |
| | | return reject(false); |
| | | } |
| | | return resolve(true) |
| | | }); |
| | | |
| | | }, |
| | | handleChange(info) { |
| | | this.form.blogFileList = info.fileList; |
| | | |
| | | if (info.file.status !== 'uploading') { |
| | | console.log(info.file, info.fileList); |
| | | } |
| | | if (info.file.status === 'done') { |
| | | this.form.fileId = info.file.response.data; |
| | | this.$message.success(`${info.file.name} file uploaded successfully`); |
| | | } else if (info.file.status === 'error') { |
| | | this.$message.error(`${info.file.name} file upload failed.`); |
| | | } |
| | | |
| | | if (this.form.blogFileList == null || this.form.blogFileList.length == 0) { |
| | | this.form.fileId = null |
| | | } |
| | | }, |
| | | handleChangeCoverFile(info) { |
| | | this.form.coverFileList = info.fileList; |
| | | |
| | | if (info.file.status !== 'uploading') { |
| | | console.log(info.file, info.fileList); |
| | | } |
| | | if (info.file.status === 'done') { |
| | | this.form.coverFile = info.file.response.data; |
| | | this.$message.success(`${info.file.name} file uploaded successfully`); |
| | | } else if (info.file.status === 'error') { |
| | | this.$message.error(`${info.file.name} file upload failed.`); |
| | | } |
| | | |
| | | if (this.form.coverFileList == null || this.form.coverFileList.length == 0) { |
| | | this.form.coverFile = null |
| | | } |
| | | }, |
| | | /** |
| | |
| | | customRequest(option) { |
| | | const formData = new FormData() |
| | | formData.append('file', option.file) |
| | | sysFileInfoUpload(formData).then((res) => { |
| | | formData.append('bucketName', option.data.bucketName) |
| | | formData.append('authCode', this.form.secret == "" ? "" : md5(this.form.secret)) |
| | | myFileInfoUpload(formData).then((res) => { |
| | | if (res.success) { |
| | | this.$message.success('上传成功') |
| | | option.onSuccess(res, option.file) |
| | | // 在上传成功后进度条显示为99 |
| | | progress.percent = 100 |
| | | } else { |
| | | this.$message.error('上传失败:' + res.message) |
| | | } |
| | | }) |
| | | |
| | | let progress = { |
| | | percent: 1 |
| | | } |
| | | let speed = 100 / (option.file.size / 65000) //上传速度 |
| | | const intervalId = setInterval(() => { |
| | | // 控制进度条防止在未上传成功时进度条达到100 |
| | | if (progress.percent < 99 && progress.percent + speed < 100) { |
| | | progress.percent += speed //控制进度条速度 |
| | | option.onProgress(progress) //onProgress接收一个对象{ percent: 进度 }在进度条上显示 |
| | | } else if ((progress.percent < 100)) { |
| | | progress.percent++ |
| | | } else if (progress.percent >= 100) { |
| | | clearInterval(intervalId) |
| | | } |
| | | }, 500) |
| | | |
| | | |
| | | }, |
| | | disabledDate(current) { |
| | | return current < moment().subtract(1, "day"); |
| | |
| | | return trigger => trigger.parentNode; |
| | | }, |
| | | handleClose(removedTag) { |
| | | const tags = this.tags.filter(tag => tag !== removedTag); |
| | | // const tags = this.tags.filter(tag => tag !== removedTag); |
| | | //console.log(tags); |
| | | this.tags = tags; |
| | | this.tags = this.tags.filter(tag => tag !== removedTag); |
| | | }, |
| | | |
| | | showInput() { |