diff --git a/config/index.js b/config/index.js index a8f8fa9..da5cab6 100644 --- a/config/index.js +++ b/config/index.js @@ -23,7 +23,7 @@ module.exports = { }, // Various Dev Server settings - host: '192.168.110.160', // can be overwritten by process.env.HOST + host: '192.168.110.159', // can be overwritten by process.env.HOST port: 8001, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined autoOpenBrowser: true, errorOverlay: true, diff --git a/index.html b/index.html index 781c2a9..9e266ad 100644 --- a/index.html +++ b/index.html @@ -17,6 +17,7 @@ + <% } %>
diff --git a/package.json b/package.json index c44dd69..9de7829 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "gulp-replace": "1.0.0", "gulp-shell": "0.8.0", "lodash": "4.17.5", + "mammoth": "^1.9.1", "node-sass": "^4.0.0", "npm": "^6.9.0", "quill-image-resize-module": "^3.0.0", diff --git a/src/assets/img/word-iocn.png b/src/assets/img/word-iocn.png new file mode 100644 index 0000000..208d503 Binary files /dev/null and b/src/assets/img/word-iocn.png differ diff --git a/src/main.js b/src/main.js index fe7fcaa..2838736 100644 --- a/src/main.js +++ b/src/main.js @@ -12,6 +12,7 @@ import '@/element-ui-theme' import '@/assets/scss/index.scss' import '@/assets/css/time-line.less' // 引入时间线样式 import Bus from '@/assets/js/eventBus.js' +import commonJS from '@/views/common/js/commonJS' import httpRequest from '@/utils/httpRequest' // api: https://github.com/axios/axios import { isAuth } from '@/utils' import cloneDeep from 'lodash/cloneDeep' @@ -38,10 +39,11 @@ if (process.env.NODE_ENV !== 'production') { } // 挂载全局 + Vue.prototype.$http = httpRequest // ajax请求方法 Vue.prototype.isAuth = isAuth // 权限方法 Vue.prototype.$bus = Bus - +Vue.prototype.$commonJS = commonJS // // 保存整站vuex本地储存初始状态 window.SITE_CONFIG['storeState'] = cloneDeep(store.state) diff --git a/src/views/common/js/commonJS.js b/src/views/common/js/commonJS.js new file mode 100644 index 0000000..3bf5470 --- /dev/null +++ b/src/views/common/js/commonJS.js @@ -0,0 +1,88 @@ +import Vue from 'vue'; + +import mammoth from "mammoth"; +export default { + handleUpload(event, callback) { + const file = event.target.files[0] + if (!file) return + + const reader = new FileReader() + reader.onload = (e) => { + const arrayBuffer = e.target.result + mammoth.extractRawText({ arrayBuffer }) + .then((result) => { + const rawText = result.value.trim(); + +// 1. 按“[医案]”分割,生成数组 +const caseList = rawText + .split(/[医案]/) + .filter(Boolean); + +// 2. 每个医案内判断是否有“相关课程”,有则去掉后面部分 +const cleanedCases = caseList.map(item => { + let content = item.trim(); + + if (content.includes('相关课程')) { + content = content.split('相关课程')[0].trim(); + } + + return content; // 补回前缀 +}); + + + // 如果你只是要显示全部文字,也可以合并 + // this.content = fullCases.join('\n\n'); + callback(cleanedCases) + }) + .catch((err) => { + console.error('提取失败:', err); + }); + // mammoth.extractRawText({ arrayBuffer }) + // .then((result) => { + // this.content = result.value // 设置到 textarea 中 + // console.log('提取内容:', result.value) + // }) + // .catch((err) => { + // console.error('提取失败:', err) + // }) + } + + reader.readAsArrayBuffer(file) + + } + // handleUpload(event, callback) { + // const file = event.target.files[0] + // if (!file) return + + // const reader = new FileReader() + // reader.onload = (e) => { + // const arrayBuffer = e.target.result + // mammoth.convertToHtml({ + // arrayBuffer: arrayBuffer + // }, { + // convertImage: mammoth.images.inline(function (element) { + // return element.read("base64").then(function (imageBuffer) { + // return { + // src: "data:" + element.contentType + ";base64," + imageBuffer + // }; + // }); + // }) + // }).then(function (result) { + // callback(result.value); + + // }) + // // mammoth.extractRawText({ arrayBuffer }) + // // .then((result) => { + // // this.content = result.value // 设置到 textarea 中 + // // console.log('提取内容:', result.value) + // // }) + // // .catch((err) => { + // // console.error('提取失败:', err) + // // }) + // } + + // reader.readAsArrayBuffer(file) + + // } + +} \ No newline at end of file diff --git a/src/views/components/commonBookTags/shopproduct.vue b/src/views/components/commonBookTags/shopproduct.vue index b8d045d..6e2ec71 100644 --- a/src/views/components/commonBookTags/shopproduct.vue +++ b/src/views/components/commonBookTags/shopproduct.vue @@ -55,21 +55,21 @@
+ 上传 Word
+
+
+
+ 清空
+
+