Commit fbeeb660 authored by erichsieh's avatar erichsieh

feat: 加入下載範例按鈕

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