| 1 |
- {"remainingRequest":"D:\\HTC\\program\\善行少年\\security-enterprise-admin\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\HTC\\program\\善行少年\\security-enterprise-admin\\src\\views\\modules\\demo\\news-add-or-update.vue?vue&type=script&lang=js","dependencies":[{"path":"D:\\HTC\\program\\善行少年\\security-enterprise-admin\\src\\views\\modules\\demo\\news-add-or-update.vue","mtime":1581948666000},{"path":"D:\\HTC\\program\\善行少年\\security-enterprise-admin\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\HTC\\program\\善行少年\\security-enterprise-admin\\node_modules\\babel-loader\\lib\\index.js","mtime":456789000000},{"path":"D:\\HTC\\program\\善行少年\\security-enterprise-admin\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\HTC\\program\\善行少年\\security-enterprise-admin\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["\r\nimport Cookies from 'js-cookie'\r\nimport debounce from 'lodash/debounce'\r\nimport 'quill/dist/quill.snow.css'\r\nimport Quill from 'quill'\r\nexport default {\r\n data () {\r\n return {\r\n visible: false,\r\n quillEditor: null,\r\n quillEditorToolbarOptions: [\r\n ['bold', 'italic', 'underline', 'strike'],\r\n ['blockquote', 'code-block', 'image'],\r\n [{ 'header': 1 }, { 'header': 2 }],\r\n [{ 'list': 'ordered' }, { 'list': 'bullet' }],\r\n [{ 'script': 'sub' }, { 'script': 'super' }],\r\n [{ 'indent': '-1' }, { 'indent': '+1' }],\r\n [{ 'direction': 'rtl' }],\r\n [{ 'size': ['small', false, 'large', 'huge'] }],\r\n [{ 'header': [1, 2, 3, 4, 5, 6, false] }],\r\n [{ 'color': [] }, { 'background': [] }],\r\n [{ 'font': [] }],\r\n [{ 'align': [] }],\r\n ['clean']\r\n ],\r\n uploadUrl: '',\r\n dataForm: {\r\n id: '',\r\n title: '',\r\n content: '',\r\n pubDate: ''\r\n }\r\n }\r\n },\r\n computed: {\r\n dataRule () {\r\n var validateContent = (rule, value, callback) => {\r\n if (this.quillEditor.getLength() <= 1) {\r\n return callback(new Error(this.$t('validate.required')))\r\n }\r\n callback()\r\n }\r\n return {\r\n title: [\r\n { required: true, message: this.$t('validate.required'), trigger: 'blur' }\r\n ],\r\n content: [\r\n { required: true, message: this.$t('validate.required'), trigger: 'blur' },\r\n { validator: validateContent, trigger: 'blur' }\r\n ],\r\n pubDate: [\r\n { required: true, message: this.$t('validate.required'), trigger: 'blur' }\r\n ]\r\n }\r\n }\r\n },\r\n methods: {\r\n init () {\r\n this.visible = true\r\n this.$nextTick(() => {\r\n if (this.quillEditor) {\r\n this.quillEditor.deleteText(0, this.quillEditor.getLength())\r\n } else {\r\n this.quillEditorHandle()\r\n }\r\n this.$refs['dataForm'].resetFields()\r\n if (this.dataForm.id) {\r\n this.getInfo()\r\n }\r\n })\r\n },\r\n // 富文本编辑器\r\n quillEditorHandle () {\r\n this.quillEditor = new Quill('#J_quillEditor', {\r\n modules: {\r\n toolbar: this.quillEditorToolbarOptions\r\n },\r\n theme: 'snow'\r\n })\r\n // 自定义上传图片功能 (使用element upload组件)\r\n this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/sys/oss/upload?token=${Cookies.get('token')}`\r\n this.quillEditor.getModule('toolbar').addHandler('image', () => {\r\n this.$refs.uploadBtn.$el.click()\r\n })\r\n // 监听内容变化,动态赋值\r\n this.quillEditor.on('text-change', () => {\r\n this.dataForm.content = this.quillEditor.root.innerHTML\r\n })\r\n },\r\n // 上传图片之前\r\n uploadBeforeUploadHandle (file) {\r\n if (file.type !== 'image/jpg' && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') {\r\n this.$message.error('只支持jpg、png、gif格式的图片!')\r\n return false\r\n }\r\n },\r\n // 上传图片成功\r\n uploadSuccessHandle (res, file, fileList) {\r\n if (res.code !== 0) {\r\n return this.$message.error(res.msg)\r\n }\r\n this.quillEditor.insertEmbed(this.quillEditor.getSelection().index, 'image', res.data.src)\r\n },\r\n // 获取信息\r\n getInfo () {\r\n this.$http.get(`/demo/news/${this.dataForm.id}`).then(({ data: res }) => {\r\n if (res.code !== 0) {\r\n return this.$message.error(res.msg)\r\n }\r\n this.dataForm = res.data\r\n this.quillEditor.root.innerHTML = this.dataForm.content\r\n }).catch(() => {})\r\n },\r\n // 表单提交\r\n dataFormSubmitHandle: debounce(function () {\r\n this.$refs['dataForm'].validate((valid) => {\r\n if (!valid) {\r\n return false\r\n }\r\n this.$http[!this.dataForm.id ? 'post' : 'put'](\r\n '/demo/news',\r\n this.dataForm,\r\n { headers: { 'content-type': 'application/x-www-form-urlencoded' } }\r\n ).then(({ data: res }) => {\r\n if (res.code !== 0) {\r\n return this.$message.error(res.msg)\r\n }\r\n this.$message({\r\n message: this.$t('prompt.success'),\r\n type: 'success',\r\n duration: 500,\r\n onClose: () => {\r\n this.visible = false\r\n this.$emit('refreshDataList')\r\n }\r\n })\r\n }).catch(() => {})\r\n })\r\n }, 1000, { 'leading': true, 'trailing': false })\r\n }\r\n}\r\n",{"version":3,"sources":["news-add-or-update.vue"],"names":[],"mappings":";AA+BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"news-add-or-update.vue","sourceRoot":"src/views/modules/demo","sourcesContent":["<template>\r\n <el-dialog :visible.sync=\"visible\" :title=\"!dataForm.id ? $t('add') : $t('update')\" :close-on-click-modal=\"false\" :close-on-press-escape=\"false\">\r\n <el-form :model=\"dataForm\" :rules=\"dataRule\" ref=\"dataForm\" @keyup.enter.native=\"dataFormSubmitHandle()\" label-width=\"120px\">\r\n <el-form-item prop=\"title\" :label=\"$t('news.title')\">\r\n <el-input v-model=\"dataForm.title\" :placeholder=\"$t('news.title')\"></el-input>\r\n </el-form-item>\r\n <el-form-item prop=\"content\" :label=\"$t('news.content')\">\r\n <!-- 富文本编辑器, 容器 -->\r\n <div id=\"J_quillEditor\"></div>\r\n <!-- 自定义上传图片功能 (使用element upload组件) -->\r\n <el-upload\r\n :action=\"uploadUrl\"\r\n :show-file-list=\"false\"\r\n :before-upload=\"uploadBeforeUploadHandle\"\r\n :on-success=\"uploadSuccessHandle\"\r\n style=\"display: none;\">\r\n <el-button ref=\"uploadBtn\" type=\"primary\" size=\"small\">{{ $t('upload.button') }}</el-button>\r\n </el-upload>\r\n </el-form-item>\r\n <el-form-item prop=\"pubDate\" :label=\"$t('news.pubDate')\">\r\n <el-date-picker v-model=\"dataForm.pubDate\" type=\"datetime\" value-format=\"yyyy-MM-dd HH:mm:ss\" :placeholder=\"$t('news.pubDate')\"></el-date-picker>\r\n </el-form-item>\r\n </el-form>\r\n <template slot=\"footer\">\r\n <el-button @click=\"visible = false\">{{ $t('cancel') }}</el-button>\r\n <el-button type=\"primary\" @click=\"dataFormSubmitHandle()\">{{ $t('confirm') }}</el-button>\r\n </template>\r\n </el-dialog>\r\n</template>\r\n\r\n<script>\r\nimport Cookies from 'js-cookie'\r\nimport debounce from 'lodash/debounce'\r\nimport 'quill/dist/quill.snow.css'\r\nimport Quill from 'quill'\r\nexport default {\r\n data () {\r\n return {\r\n visible: false,\r\n quillEditor: null,\r\n quillEditorToolbarOptions: [\r\n ['bold', 'italic', 'underline', 'strike'],\r\n ['blockquote', 'code-block', 'image'],\r\n [{ 'header': 1 }, { 'header': 2 }],\r\n [{ 'list': 'ordered' }, { 'list': 'bullet' }],\r\n [{ 'script': 'sub' }, { 'script': 'super' }],\r\n [{ 'indent': '-1' }, { 'indent': '+1' }],\r\n [{ 'direction': 'rtl' }],\r\n [{ 'size': ['small', false, 'large', 'huge'] }],\r\n [{ 'header': [1, 2, 3, 4, 5, 6, false] }],\r\n [{ 'color': [] }, { 'background': [] }],\r\n [{ 'font': [] }],\r\n [{ 'align': [] }],\r\n ['clean']\r\n ],\r\n uploadUrl: '',\r\n dataForm: {\r\n id: '',\r\n title: '',\r\n content: '',\r\n pubDate: ''\r\n }\r\n }\r\n },\r\n computed: {\r\n dataRule () {\r\n var validateContent = (rule, value, callback) => {\r\n if (this.quillEditor.getLength() <= 1) {\r\n return callback(new Error(this.$t('validate.required')))\r\n }\r\n callback()\r\n }\r\n return {\r\n title: [\r\n { required: true, message: this.$t('validate.required'), trigger: 'blur' }\r\n ],\r\n content: [\r\n { required: true, message: this.$t('validate.required'), trigger: 'blur' },\r\n { validator: validateContent, trigger: 'blur' }\r\n ],\r\n pubDate: [\r\n { required: true, message: this.$t('validate.required'), trigger: 'blur' }\r\n ]\r\n }\r\n }\r\n },\r\n methods: {\r\n init () {\r\n this.visible = true\r\n this.$nextTick(() => {\r\n if (this.quillEditor) {\r\n this.quillEditor.deleteText(0, this.quillEditor.getLength())\r\n } else {\r\n this.quillEditorHandle()\r\n }\r\n this.$refs['dataForm'].resetFields()\r\n if (this.dataForm.id) {\r\n this.getInfo()\r\n }\r\n })\r\n },\r\n // 富文本编辑器\r\n quillEditorHandle () {\r\n this.quillEditor = new Quill('#J_quillEditor', {\r\n modules: {\r\n toolbar: this.quillEditorToolbarOptions\r\n },\r\n theme: 'snow'\r\n })\r\n // 自定义上传图片功能 (使用element upload组件)\r\n this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/sys/oss/upload?token=${Cookies.get('token')}`\r\n this.quillEditor.getModule('toolbar').addHandler('image', () => {\r\n this.$refs.uploadBtn.$el.click()\r\n })\r\n // 监听内容变化,动态赋值\r\n this.quillEditor.on('text-change', () => {\r\n this.dataForm.content = this.quillEditor.root.innerHTML\r\n })\r\n },\r\n // 上传图片之前\r\n uploadBeforeUploadHandle (file) {\r\n if (file.type !== 'image/jpg' && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') {\r\n this.$message.error('只支持jpg、png、gif格式的图片!')\r\n return false\r\n }\r\n },\r\n // 上传图片成功\r\n uploadSuccessHandle (res, file, fileList) {\r\n if (res.code !== 0) {\r\n return this.$message.error(res.msg)\r\n }\r\n this.quillEditor.insertEmbed(this.quillEditor.getSelection().index, 'image', res.data.src)\r\n },\r\n // 获取信息\r\n getInfo () {\r\n this.$http.get(`/demo/news/${this.dataForm.id}`).then(({ data: res }) => {\r\n if (res.code !== 0) {\r\n return this.$message.error(res.msg)\r\n }\r\n this.dataForm = res.data\r\n this.quillEditor.root.innerHTML = this.dataForm.content\r\n }).catch(() => {})\r\n },\r\n // 表单提交\r\n dataFormSubmitHandle: debounce(function () {\r\n this.$refs['dataForm'].validate((valid) => {\r\n if (!valid) {\r\n return false\r\n }\r\n this.$http[!this.dataForm.id ? 'post' : 'put'](\r\n '/demo/news',\r\n this.dataForm,\r\n { headers: { 'content-type': 'application/x-www-form-urlencoded' } }\r\n ).then(({ data: res }) => {\r\n if (res.code !== 0) {\r\n return this.$message.error(res.msg)\r\n }\r\n this.$message({\r\n message: this.$t('prompt.success'),\r\n type: 'success',\r\n duration: 500,\r\n onClose: () => {\r\n this.visible = false\r\n this.$emit('refreshDataList')\r\n }\r\n })\r\n }).catch(() => {})\r\n })\r\n }, 1000, { 'leading': true, 'trailing': false })\r\n }\r\n}\r\n</script>\r\n"]}]}
|