Commit fbeeb660 authored by erichsieh's avatar erichsieh

feat: 加入下載範例按鈕

parent 85fc24a0
Pipeline #3931 passed with stage
in 12 seconds
{ {
"name": "@purplevin/component", "name": "@purplevin/component",
"version": "0.1.18", "version": "0.1.19",
"private": false, "private": false,
"main": "lib/index.umd.min.js", "main": "lib/index.umd.min.js",
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
"build": "vue-cli-service build", "build": "vue-cli-service build",
"lib": "vue-cli-service build --target lib --name index --dest lib packages/index.js", "lib": "vue-cli-service build --target lib --name index --dest lib packages/index.js",
"publish": "npm publish --registry http://192.168.1.10:4873" "publish": "npm publish --registry http://192.168.1.10:4873"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "4.4.4", "@vue/cli-plugin-babel": "4.4.4",
"@vue/cli-service": "4.4.4", "@vue/cli-service": "4.4.4",
"sass": "1.26.8", "sass": "1.26.8",
"sass-loader": "8.0.2", "sass-loader": "8.0.2",
"vue-template-compiler": "2.6.14" "vue-template-compiler": "2.6.14"
}, },
"dependencies": { "dependencies": {
"axios": "^0.27.2", "axios": "^0.27.2",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"element-ui": "2.15.8", "element-ui": "2.15.8",
"moment": "^2.29.4", "moment": "^2.29.4",
"vue": "2.6.14", "vue": "2.6.14",
"vuex": "^3.4.0", "vuex": "^3.4.0",
"xlsx": "^0.17.5" "xlsx": "^0.17.5"
}, },
"browserslist": [ "browserslist": [
"> 1%", "> 1%",
"last 2 versions", "last 2 versions",
"not dead" "not dead"
] ]
} }
<template> <template>
<div> <div>
<h3>CN稿转成PCT稿</h3> <h3>CN稿转成PCT稿</h3>
<el-alert <el-alert
title="此功能将协助您将CN稿快速转换成PC稿的排版, CN稿中须包含下列几种标题 1.说明书摘要 2.权利要求书 3.说明书 4.说明书附图或摘要附图, 并且标题需设置下框线" title="此功能将协助您将CN稿快速转换成PCT稿的排版, CN稿中须包含下列几种标题 1.说明书摘要 2.权利要求书 3.说明书 4.说明书附图或摘要附图, 并且标题需设置下框线"
type="info" type="info"
/> />
<br> <br>
<el-form ref="searchForm" size="small" label-width="160px"> <el-form ref="searchForm" size="small" label-width="160px">
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="CN稿" prop="business"> <el-form-item label="CN稿" prop="business">
<el-upload <el-upload
ref="upload" ref="upload"
class="upload-demo" class="upload-demo"
drag drag
:limit="1" :limit="1"
:file-list="fileList" :file-list="fileList"
:action="uploadURL" :action="uploadURL"
:on-change="handelFileChange" :on-change="handelFileChange"
:on-remove="handleFileRemove" :on-remove="handleFileRemove"
:on-exceed="handleExceed" :on-exceed="handleExceed"
:auto-upload="false" :auto-upload="false"
accept=".docx, .doc" accept=".docx, .doc"
> >
<i class="el-icon-upload" /> <i class="el-icon-upload" />
<div class="el-upload__text"> <div class="el-upload__text">
将文件拖到此处,或<em>点击上传</em> 将文件拖到此处,或<em>点击上传</em>
</div> </div>
</el-upload> </el-upload>
<el-link target="_blank" type="primary" href="https://essenptl-my.sharepoint.com/personal/service_essenptl_com/_layouts/15/onedrive.aspx?id=%2Fpersonal%2Fservice%5Fessenptl%5Fcom%2FDocuments%2F%E7%B4%AB%E8%97%A4%2Dshare%20folder%2FIT%2FDocument%2F%E4%B8%93%E5%88%A9%E4%BB%A3%E7%90%86%E4%B8%9A%E5%8A%A1%E6%A8%A1%E6%9D%BF2020%2Ezip&parent=%2Fpersonal%2Fservice%5Fessenptl%5Fcom%2FDocuments%2F%E7%B4%AB%E8%97%A4%2Dshare%20folder%2FIT%2FDocument"> <el-link target="_blank" type="primary" href="https://essenptl-my.sharepoint.com/personal/service_essenptl_com/_layouts/15/onedrive.aspx?id=%2Fpersonal%2Fservice%5Fessenptl%5Fcom%2FDocuments%2F%E7%B4%AB%E8%97%A4%2Dshare%20folder%2FIT%2FDocument%2F%E4%B8%93%E5%88%A9%E4%BB%A3%E7%90%86%E4%B8%9A%E5%8A%A1%E6%A8%A1%E6%9D%BF2020%2Ezip&parent=%2Fpersonal%2Fservice%5Fessenptl%5Fcom%2FDocuments%2F%E7%B4%AB%E8%97%A4%2Dshare%20folder%2FIT%2FDocument">
模板下載 模板下載
</el-link> </el-link>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12" :offset="10"> <el-col :span="12" :offset="10">
<el-button <el-button
style="margin-left: 10px" style="margin-left: 10px"
size="small" size="small"
type="success" type="success"
@click="submitUpload" @click="submitUpload"
> >
开始转换 开始转换
</el-button> </el-button>
</el-col> <el-button style="margin-left: 10px"
</el-row> v-if="showDownloadSampleButton"
</el-form> size="small"
</div> type="info"
</template> @click="$emit('on-downloadSampleClick','CN2PCT')">
<script> 下载范例
import {fetchCntToPct,fetchDownloadFile} from "@api/convertApi" </el-button>
export default { </el-col>
name: 'Cn2PctForm', </el-row>
data: function() { </el-form>
return { </div>
uploadURL: 'Word/CN2PCT', </template>
fileList: [] <script>
} import {fetchCntToPct,fetchDownloadFile} from "@api/convertApi"
}, export default {
props:{ name: 'Cn2PctForm',
baseUrl:{ data: function() {
type: String return {
} uploadURL: 'Word/CN2PCT',
}, fileList: []
methods: { }
// 上传到服务器 },
async submitUpload() { props:{
console.log(this.fileList) baseUrl:{
if (this.fileList.length <= 0) { type: String
this.$message.error('请先选择需要上传的文件!') },
return false showDownloadSampleButton:{
} type: Boolean,
const formData = new FormData() default: false
this.fileList.forEach(e => { }
formData.append('file', e.raw) },
}) methods: {
const res = await fetchCntToPct(this.baseUrl,formData) // 上传到服务器
if (res.status === 200) { async submitUpload() {
this.fileList = [] console.log(this.fileList)
this.$refs.upload.clearFiles() if (this.fileList.length <= 0) {
const excelFileName = res.data this.$message.error('请先选择需要上传的文件!')
const response = await fetchDownloadFile(this.baseUrl,{fileName: excelFileName}) return false
const blob = new Blob([response]) }
const downloadElement = document.createElement('a') const formData = new FormData()
const href = window.URL.createObjectURL(blob) this.fileList.forEach(e => {
downloadElement.href = href formData.append('file', e.raw)
downloadElement.download = excelFileName.split('/')[1] })
document.body.appendChild(downloadElement) const res = await fetchCntToPct(this.baseUrl,formData)
downloadElement.click() if (res.status === 200) {
document.body.removeChild(downloadElement) this.fileList = []
window.URL.revokeObjectURL(href) this.$refs.upload.clearFiles()
} else { const excelFileName = res.data
this.$refs.upload.abort() const response = await fetchDownloadFile(this.baseUrl,{fileName: excelFileName})
this.$message.error('下载档案失败!') const blob = new Blob([response])
} const downloadElement = document.createElement('a')
console.log(res.data) const href = window.URL.createObjectURL(blob)
}, downloadElement.href = href
// 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用 downloadElement.download = excelFileName.split('/')[1]
handelFileChange(file, fileList) { document.body.appendChild(downloadElement)
// 存在文件标识 downloadElement.click()
let existsFileFlag = false document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
for (let i = 0; i < this.fileList.length; i++) { } else {
if ( this.$refs.upload.abort()
file.name === this.fileList[i].name && this.$message.error('下载档案失败!')
file.size === this.fileList[i].size }
) { console.log(res.data)
// 如果存在了,赋值true },
existsFileFlag = true // 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用
} handelFileChange(file, fileList) {
} // 存在文件标识
// 遍历的这个文件存在当前列表直接结束 let existsFileFlag = false
if (existsFileFlag) {
// 否则不加入 for (let i = 0; i < this.fileList.length; i++) {
fileList.pop() if (
// console.log(`文件已经存在:${file.name}`) file.name === this.fileList[i].name &&
// this.handleMsg(`文件已经选择过了:${file.name})`); file.size === this.fileList[i].size
this.$message({ ) {
showClose: true, // 如果存在了,赋值true
message: `文件已经选择过了:${file.name})`, existsFileFlag = true
type: 'error' }
}) }
return // 遍历的这个文件存在当前列表直接结束
} if (existsFileFlag) {
this.fileList.push(file) // 否则不加入
}, fileList.pop()
handelDetailFileChange(file, fileList) { // console.log(`文件已经存在:${file.name}`)
// 存在文件标识 // this.handleMsg(`文件已经选择过了:${file.name})`);
let existsFileFlag = false this.$message({
showClose: true,
for (let i = 0; i < this.detailFileList.length; i++) { message: `文件已经选择过了:${file.name})`,
if ( type: 'error'
file.name === this.detailFileList[i].name && })
file.size === this.detailFileList[i].size return
) { }
// 如果存在了,赋值true this.fileList.push(file)
existsFileFlag = true },
} handelDetailFileChange(file, fileList) {
} // 存在文件标识
// 遍历的这个文件存在当前列表直接结束 let existsFileFlag = false
if (existsFileFlag) {
// 否则不加入 for (let i = 0; i < this.detailFileList.length; i++) {
fileList.pop() if (
// console.log(`文件已经存在:${file.name}`) file.name === this.detailFileList[i].name &&
// this.handleMsg(`文件已经选择过了:${file.name})`); file.size === this.detailFileList[i].size
this.$message({ ) {
showClose: true, // 如果存在了,赋值true
message: `文件已经选择过了:${file.name})`, existsFileFlag = true
type: 'error' }
}) }
return // 遍历的这个文件存在当前列表直接结束
} if (existsFileFlag) {
this.detailFileList.push(file) // 否则不加入
}, fileList.pop()
// 文件列表移除文件时的钩子 // console.log(`文件已经存在:${file.name}`)
handleFileRemove(file, fileList) { // this.handleMsg(`文件已经选择过了:${file.name})`);
this.fileList = fileList this.$message({
}, showClose: true,
handleDetailFileRemove(file, fileList) { message: `文件已经选择过了:${file.name})`,
this.detailFileList = fileList type: 'error'
}, })
handleExceed(files, fileList) { return
this.$set(fileList[0], 'raw', files[0]) }
this.$set(fileList[0], 'name', files[0].name) this.detailFileList.push(file)
this.$refs['rebateUpload'].clearFiles()// 清除文件 },
this.$refs['rebateUpload'].handleStart(files[0])// 选择文件后的赋值方法 // 文件列表移除文件时的钩子
} handleFileRemove(file, fileList) {
} this.fileList = fileList
} },
</script> handleDetailFileRemove(file, fileList) {
this.detailFileList = fileList
},
handleExceed(files, fileList) {
this.$set(fileList[0], 'raw', files[0])
this.$set(fileList[0], 'name', files[0].name)
this.$refs['rebateUpload'].clearFiles()// 清除文件
this.$refs['rebateUpload'].handleStart(files[0])// 选择文件后的赋值方法
}
}
}
</script>
<template> <template>
<div> <div>
<h3>PCT槁转CN稿</h3> <h3>PCT槁转CN稿</h3>
<el-alert <el-alert
title="此功能将协助您将PCT稿快速转换成CN稿的排版" title="此功能将协助您将PCT稿快速转换成CN稿的排版"
type="info" type="info"
/> />
<br> <br>
<el-form ref="searchForm" size="small" label-width="160px"> <el-form ref="searchForm" size="small" label-width="160px">
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="PCT稿" prop="business"> <el-form-item label="PCT稿" prop="business">
<el-upload <el-upload
ref="upload" ref="upload"
class="upload-demo" class="upload-demo"
drag drag
:limit="1" :limit="1"
:file-list="fileList" :file-list="fileList"
:action="uploadURL" :action="uploadURL"
:on-change="handelFileChange" :on-change="handelFileChange"
:on-remove="handleFileRemove" :on-remove="handleFileRemove"
:on-exceed="handleExceed" :on-exceed="handleExceed"
:auto-upload="false" :auto-upload="false"
accept=".docx, .doc" accept=".docx, .doc"
> >
<i class="el-icon-upload" /> <i class="el-icon-upload" />
<div class="el-upload__text"> <div class="el-upload__text">
将文件拖到此处,或<em>点击上传</em> 将文件拖到此处,或<em>点击上传</em>
</div> </div>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12" :offset="10"> <el-col :span="12" :offset="10">
<el-button <el-button
style="margin-left: 10px" style="margin-left: 10px"
size="small" size="small"
type="success" type="success"
@click="submitUpload" @click="submitUpload"
> >
开始转换 开始转换
</el-button> </el-button>
</el-col> <el-button style="margin-left: 10px"
</el-row> v-if="showDownloadSampleButton"
</el-form> size="small"
</div> type="info"
</template> @click="$emit('on-downloadSampleClick','PCT2CN')">
<script> 下载范例
import { fetchPctToCn,fetchDownloadFile } from "@api/convertApi" </el-button>
export default { </el-col>
name: 'Cn2CpcForm', </el-row>
data: function() { </el-form>
return { </div>
uploadURL: 'Word/CN2CPC', </template>
fileList: [] <script>
} import { fetchPctToCn,fetchDownloadFile } from "@api/convertApi"
}, export default {
props:{ name: 'Cn2CpcForm',
baseUrl:{ data: function() {
type: String return {
} uploadURL: 'Word/CN2CPC',
}, fileList: []
methods: { }
// 上传到服务器 },
async submitUpload() { props:{
console.log(this.fileList) baseUrl:{
if (this.fileList.length <= 0) { type: String
this.$message.error('请先选择需要上传的文件!') },
return false showDownloadSampleButton:{
} type: Boolean,
const formData = new FormData() default: false
this.fileList.forEach(e => { }
formData.append('file', e.raw) },
}) methods: {
const res = await fetchPctToCn(this.baseUrl,formData) // 上传到服务器
if (res.status === 200) { async submitUpload() {
this.fileList = [] console.log(this.fileList)
this.$refs.upload.clearFiles() if (this.fileList.length <= 0) {
const excelFileName = res.data this.$message.error('请先选择需要上传的文件!')
const response = await fetchDownloadFile(this.baseUrl,{fileName: excelFileName}) return false
const blob = new Blob([response]) }
const downloadElement = document.createElement('a') const formData = new FormData()
const href = window.URL.createObjectURL(blob) this.fileList.forEach(e => {
downloadElement.href = href formData.append('file', e.raw)
downloadElement.download = excelFileName.split('/')[1] })
document.body.appendChild(downloadElement) const res = await fetchPctToCn(this.baseUrl,formData)
downloadElement.click() if (res.status === 200) {
document.body.removeChild(downloadElement) this.fileList = []
window.URL.revokeObjectURL(href) this.$refs.upload.clearFiles()
} else { const excelFileName = res.data
this.$refs.upload.abort() const response = await fetchDownloadFile(this.baseUrl,{fileName: excelFileName})
this.$message.error('下载档案失败!') const blob = new Blob([response])
} const downloadElement = document.createElement('a')
console.log(res.data) const href = window.URL.createObjectURL(blob)
}, downloadElement.href = href
// 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用 downloadElement.download = excelFileName.split('/')[1]
handelFileChange(file, fileList) { document.body.appendChild(downloadElement)
// 存在文件标识 downloadElement.click()
let existsFileFlag = false document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
for (let i = 0; i < this.fileList.length; i++) { } else {
if ( this.$refs.upload.abort()
file.name === this.fileList[i].name && this.$message.error('下载档案失败!')
file.size === this.fileList[i].size }
) { console.log(res.data)
// 如果存在了,赋值true },
existsFileFlag = true // 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用
} handelFileChange(file, fileList) {
} // 存在文件标识
// 遍历的这个文件存在当前列表直接结束 let existsFileFlag = false
if (existsFileFlag) {
// 否则不加入 for (let i = 0; i < this.fileList.length; i++) {
fileList.pop() if (
// console.log(`文件已经存在:${file.name}`) file.name === this.fileList[i].name &&
// this.handleMsg(`文件已经选择过了:${file.name})`); file.size === this.fileList[i].size
this.$message({ ) {
showClose: true, // 如果存在了,赋值true
message: `文件已经选择过了:${file.name})`, existsFileFlag = true
type: 'error' }
}) }
return // 遍历的这个文件存在当前列表直接结束
} if (existsFileFlag) {
this.fileList.push(file) // 否则不加入
}, fileList.pop()
handelDetailFileChange(file, fileList) { // console.log(`文件已经存在:${file.name}`)
// 存在文件标识 // this.handleMsg(`文件已经选择过了:${file.name})`);
let existsFileFlag = false this.$message({
showClose: true,
for (let i = 0; i < this.detailFileList.length; i++) { message: `文件已经选择过了:${file.name})`,
if ( type: 'error'
file.name === this.detailFileList[i].name && })
file.size === this.detailFileList[i].size return
) { }
// 如果存在了,赋值true this.fileList.push(file)
existsFileFlag = true },
} handelDetailFileChange(file, fileList) {
} // 存在文件标识
// 遍历的这个文件存在当前列表直接结束 let existsFileFlag = false
if (existsFileFlag) {
// 否则不加入 for (let i = 0; i < this.detailFileList.length; i++) {
fileList.pop() if (
// console.log(`文件已经存在:${file.name}`) file.name === this.detailFileList[i].name &&
// this.handleMsg(`文件已经选择过了:${file.name})`); file.size === this.detailFileList[i].size
this.$message({ ) {
showClose: true, // 如果存在了,赋值true
message: `文件已经选择过了:${file.name})`, existsFileFlag = true
type: 'error' }
}) }
return // 遍历的这个文件存在当前列表直接结束
} if (existsFileFlag) {
this.detailFileList.push(file) // 否则不加入
}, fileList.pop()
// 文件列表移除文件时的钩子 // console.log(`文件已经存在:${file.name}`)
handleFileRemove(file, fileList) { // this.handleMsg(`文件已经选择过了:${file.name})`);
this.fileList = fileList this.$message({
}, showClose: true,
handleDetailFileRemove(file, fileList) { message: `文件已经选择过了:${file.name})`,
this.detailFileList = fileList type: 'error'
}, })
handleExceed(files, fileList) { return
this.$set(fileList[0], 'raw', files[0]) }
this.$set(fileList[0], 'name', files[0].name) this.detailFileList.push(file)
this.$refs['rebateUpload'].clearFiles()// 清除文件 },
this.$refs['rebateUpload'].handleStart(files[0])// 选择文件后的赋值方法 // 文件列表移除文件时的钩子
} handleFileRemove(file, fileList) {
} this.fileList = fileList
} },
</script> handleDetailFileRemove(file, fileList) {
this.detailFileList = fileList
},
handleExceed(files, fileList) {
this.$set(fileList[0], 'raw', files[0])
this.$set(fileList[0], 'name', files[0].name)
this.$refs['rebateUpload'].clearFiles()// 清除文件
this.$refs['rebateUpload'].handleStart(files[0])// 选择文件后的赋值方法
}
}
}
</script>
<template> <template>
<div> <div>
<el-tabs type="border-card"> <el-tabs type="border-card">
<el-tab-pane label="CN转换PCT"> <el-tab-pane label="CN转换PCT">
<cn-2-pct-form :baseUrl="baseUrl"/> <cn-2-pct-form :baseUrl="baseUrl"
</el-tab-pane> :showDownloadSampleButton="true"
<el-tab-pane label="公式转换图片"> @on-downloadSampleClick="handleDownloadSampleClick" />
<visio-form :baseUrl="baseUrl"/> </el-tab-pane>
</el-tab-pane> <el-tab-pane label="公式转换图片">
<el-tab-pane label="PCT槁转CN稿"> <visio-form :baseUrl="baseUrl"/>
<Pct2CnForm :baseUrl="baseUrl"/> </el-tab-pane>
</el-tab-pane> <el-tab-pane label="PCT槁转CN稿">
</el-tabs> <Pct2CnForm :baseUrl="baseUrl"
</div> :showDownloadSampleButton="true"
</template> @on-downloadSampleClick="handleDownloadSampleClick" />
</el-tab-pane>
<script> </el-tabs>
import Cn2CpcForm from './components/Cn2CpcForm' </div>
import Cn2PctForm from './components/Cn2PctForm' </template>
import VisioForm from './components/VisioForm'
import Pct2CnForm from './components/Pct2CnForm' <script>
export default { import Cn2CpcForm from './components/Cn2CpcForm'
name: 'ConvertTool', import Cn2PctForm from './components/Cn2PctForm'
props:{ import VisioForm from './components/VisioForm'
baseUrl:{ import Pct2CnForm from './components/Pct2CnForm'
type: String, export default {
require: true, name: 'ConvertTool',
default: 'https://dev.essenptl.com/graphAPITest/' props:{
} baseUrl:{
}, type: String,
components: { require: true,
Cn2CpcForm, default: 'https://dev.essenptl.com/graphAPITest/'
Cn2PctForm, }
VisioForm, },
Pct2CnForm components: {
} Cn2CpcForm,
} Cn2PctForm,
</script> VisioForm,
Pct2CnForm
},
methods: {
handleDownloadSampleClick(type){
console.log('download sample', type)
}
},
}
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment