|
@@ -7,7 +7,9 @@
|
|
|
:signData="signData"
|
|
|
:download="loading"
|
|
|
@getFile="getFile"
|
|
|
+ @getFile2="getFile2"
|
|
|
@fileOption="fileOption"
|
|
|
+ @fileOption2="fileOption2"
|
|
|
@saveFile="saveFile"
|
|
|
/>
|
|
|
<studentProjectWordShow
|
|
@@ -201,6 +203,36 @@
|
|
|
<el-button @click="dialogVisibleUpdateFile = false">取 消</el-button>
|
|
|
<el-button type="primary" @click="updateFileName">确 定</el-button>
|
|
|
</span>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!-- 修改文件名称2-->
|
|
|
+ <el-dialog
|
|
|
+ title="修改名称"
|
|
|
+ :visible.sync="dialogVisibleUpdateFile2"
|
|
|
+ :append-to-body="true"
|
|
|
+ width="500px"
|
|
|
+ class="dialog_diy"
|
|
|
+ >
|
|
|
+ <div
|
|
|
+ style="
|
|
|
+ width: 100%;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ flex-wrap: nowrap;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ "
|
|
|
+ >
|
|
|
+ <div style="min-width: fit-content">文件名称:</div>
|
|
|
+ <el-input
|
|
|
+ v-model="updateFile.fileName"
|
|
|
+ placeholder="请输入要修改的名称"
|
|
|
+ ></el-input>
|
|
|
+ </div>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="dialogVisibleUpdateFile2 = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="updateFileName2">确 定</el-button>
|
|
|
+ </span>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -213,6 +245,82 @@ import studentProjectWordShow from "./studentProjectWordShow.vue";
|
|
|
import { downloadPDF } from "@/components/tool/pdf";
|
|
|
import vpdf from "@/components/vpdf.vue";
|
|
|
import vword from "@/components/vword.vue";
|
|
|
+import "@/components/common/aws-sdk-2.235.1.min.js"
|
|
|
+const getFile = (url) => {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ var credentials = {
|
|
|
+ accessKeyId: "AKIATLPEDU37QV5CHLMH",
|
|
|
+ secretAccessKey: "Q2SQw37HfolS7yeaR1Ndpy9Jl4E2YZKUuuy2muZR",
|
|
|
+ }; //秘钥形式的登录上传
|
|
|
+ window.AWS.config.update(credentials);
|
|
|
+ window.AWS.config.region = "cn-northwest-1"; //设置区域
|
|
|
+ let url2 = url;
|
|
|
+ let _url2 = "";
|
|
|
+ if (
|
|
|
+ url2.indexOf("https://view.officeapps.live.com/op/view.aspx?src=") != -1
|
|
|
+ ) {
|
|
|
+ _url2 = url2.split(
|
|
|
+ "https://view.officeapps.live.com/op/view.aspx?src="
|
|
|
+ )[1];
|
|
|
+ } else {
|
|
|
+ _url2 = url2;
|
|
|
+ }
|
|
|
+ var s3 = new window.AWS.S3({ params: { Bucket: "ccrb" } });
|
|
|
+ let name = decodeURIComponent(_url2.split("https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/")[1])
|
|
|
+ var params = {
|
|
|
+ Bucket: "ccrb",
|
|
|
+ Key: name
|
|
|
+ };
|
|
|
+ s3.getObject(params, function (err, data) {
|
|
|
+ if (err) {
|
|
|
+ console.log(err, err.stack)
|
|
|
+ resolve({ data: 1 });
|
|
|
+ }else {
|
|
|
+ resolve({ data: data.Body });
|
|
|
+ console.log(data);
|
|
|
+ } // sxuccessful response
|
|
|
+
|
|
|
+ });
|
|
|
+ // var credentials = {
|
|
|
+ // accessKeyId: "AKIATLPEDU37QV5CHLMH",
|
|
|
+ // secretAccessKey: "Q2SQw37HfolS7yeaR1Ndpy9Jl4E2YZKUuuy2muZR",
|
|
|
+ // }; //秘钥形式的登录上传
|
|
|
+ // window.AWS.config.update(credentials);
|
|
|
+ // window.AWS.config.region = "cn-northwest-1"; //设置区域
|
|
|
+ // let url2 = url;
|
|
|
+ // let _url2 = "";
|
|
|
+ // if (
|
|
|
+ // url2.indexOf("https://view.officeapps.live.com/op/view.aspx?src=") != -1
|
|
|
+ // ) {
|
|
|
+ // _url2 = url2.split(
|
|
|
+ // "https://view.officeapps.live.com/op/view.aspx?src="
|
|
|
+ // )[1];
|
|
|
+ // } else {
|
|
|
+ // _url2 = url2;
|
|
|
+ // }
|
|
|
+ // let _this = this;
|
|
|
+
|
|
|
+ // var s3 = new window.AWS.S3({ params: { Bucket: "ccrb" } });
|
|
|
+ // let name = decodeURIComponent(_url2.split("https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/")[1])
|
|
|
+ // var params = {
|
|
|
+ // Bucket: "ccrb",
|
|
|
+ // Key: name
|
|
|
+ // };
|
|
|
+ // s3.getObject(params, function (err, data) {
|
|
|
+ // if (err) console.log(err, err.stack); // an error occurred
|
|
|
+ // else {
|
|
|
+ // let url = window.URL.createObjectURL(new Blob([data.Body]));
|
|
|
+ // let a = document.createElement("a");
|
|
|
+ // a.name = name;
|
|
|
+ // a.href = url;
|
|
|
+ // a.download = name;
|
|
|
+ // a.click();
|
|
|
+ // console.log(data);
|
|
|
+ // } // sxuccessful response
|
|
|
+
|
|
|
+ // });
|
|
|
+ });
|
|
|
+};
|
|
|
export default {
|
|
|
components: { studentProjectWord, studentProjectWordShow,vword,vpdf },
|
|
|
data() {
|
|
@@ -225,6 +333,7 @@ export default {
|
|
|
updatedWordDig: false, //立即修改对话框
|
|
|
showFile:false,// 展示文件弹窗
|
|
|
dialogVisibleUpdateFile:false,//修改文件弹窗
|
|
|
+ dialogVisibleUpdateFile2:false,//修改文件弹窗2
|
|
|
downWordData: {
|
|
|
applicationDate: getNowDate(1), //申请日期
|
|
|
projectName: "",
|
|
@@ -325,6 +434,7 @@ export default {
|
|
|
activities: "",
|
|
|
entery: "",
|
|
|
},
|
|
|
+ attachment:[],//附件上传
|
|
|
opinion:[],
|
|
|
},
|
|
|
signData:[],
|
|
@@ -501,6 +611,7 @@ export default {
|
|
|
this.wordData.introduce = JSON.parse(data.chapters);
|
|
|
this.wordData.fund = JSON.parse(data.money);
|
|
|
this.wordData.opinion = data.opinion?JSON.parse(data.opinion):[];
|
|
|
+ this.wordData.attachment = data.attachment?JSON.parse(data.attachment):[];
|
|
|
this.downWordData = {
|
|
|
...this.wordData,
|
|
|
...{ etime: data.eTime, btime: data.bTime, dp: data.className },
|
|
@@ -519,7 +630,9 @@ export default {
|
|
|
pid:this.$route.query['pid']
|
|
|
}
|
|
|
this.ajax.get(this.$store.state.api+'/selectSign',params).then(res=>{
|
|
|
- this.signData = res.data[0]
|
|
|
+ let signData = res.data[0]
|
|
|
+ signData.sort((a,b)=>new Date(b.create_at) - new Date(a.create_at))
|
|
|
+ this.signData = signData
|
|
|
})
|
|
|
},
|
|
|
test() {
|
|
@@ -723,8 +836,8 @@ export default {
|
|
|
mon: encodeURIComponent(JSON.stringify(this.wordData["fund"])), //预算经费
|
|
|
f: this.wordData["total"], //总经费
|
|
|
apply: this.wordData["applicationDate"], //申请日期
|
|
|
- mem:
|
|
|
- this.wordData["teacherS"].filter(i=>i.name!='').length + this.wordData["studentS"].filter(i=>i.name!='').length,
|
|
|
+ mem:this.wordData["teacherS"].filter(i=>i.name!='').length + this.wordData["studentS"].filter(i=>i.name!='').length,
|
|
|
+ attachment:encodeURIComponent(JSON.stringify(this.wordData["attachment"])),//附件上传
|
|
|
};
|
|
|
this.ajax
|
|
|
.post(this.$store.state.api + "/updateStudentProjectData", param)
|
|
@@ -745,12 +858,55 @@ export default {
|
|
|
},
|
|
|
downloadWordFile(){
|
|
|
this.loading = true;
|
|
|
-
|
|
|
- this.$nextTick(()=>{
|
|
|
+ // var credentials = {
|
|
|
+ // accessKeyId: "AKIATLPEDU37QV5CHLMH",
|
|
|
+ // secretAccessKey: "Q2SQw37HfolS7yeaR1Ndpy9Jl4E2YZKUuuy2muZR",
|
|
|
+ // }; //秘钥形式的登录上传
|
|
|
+ // window.AWS.config.update(credentials);
|
|
|
+ // window.AWS.config.region = "cn-northwest-1"; //设置区域
|
|
|
+ // let url2 = "https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/%E6%94%B6%E5%85%A5%E6%A8%A1%E5%BC%8F1712047315470.jpg";
|
|
|
+ // let _url2 = "";
|
|
|
+ // if (
|
|
|
+ // url2.indexOf("https://view.officeapps.live.com/op/view.aspx?src=") != -1
|
|
|
+ // ) {
|
|
|
+ // _url2 = url2.split(
|
|
|
+ // "https://view.officeapps.live.com/op/view.aspx?src="
|
|
|
+ // )[1];
|
|
|
+ // } else {
|
|
|
+ // _url2 = url2;
|
|
|
+ // }
|
|
|
+ // let _this = this;
|
|
|
+
|
|
|
+ // var s3 = new window.AWS.S3({ params: { Bucket: "ccrb" } });
|
|
|
+ // let name = decodeURIComponent(_url2.split("https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/")[1])
|
|
|
+ // var params = {
|
|
|
+ // Bucket: "ccrb",
|
|
|
+ // Key: name
|
|
|
+ // };
|
|
|
+ // s3.getObject(params, function (err, data) {
|
|
|
+
|
|
|
+ // if (err) console.log(err, err.stack); // an error occurred
|
|
|
+ // else {
|
|
|
+ // let url = window.URL.createObjectURL(new Blob([data.Body]));
|
|
|
+ // let a = document.createElement("a");
|
|
|
+ // a.name = name;
|
|
|
+ // a.href = url;
|
|
|
+ // a.download = name;
|
|
|
+ // a.click();
|
|
|
+ // console.log(data);
|
|
|
+ // } // sxuccessful response
|
|
|
+
|
|
|
+ // });
|
|
|
+ // getFile("https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/%E5%9B%BE%E7%89%8711711980299371.jpg").then(res=>{
|
|
|
+ // console.log(res)
|
|
|
+ // })
|
|
|
+ // return
|
|
|
+ this.$nextTick(async ()=>{
|
|
|
this.$message.info("正在下载,请稍等...")
|
|
|
let elementList = this.$refs.myChild.$refs.pdfShow.querySelectorAll('.downImage')
|
|
|
let fontSize = [];
|
|
|
let pFontSize = [];
|
|
|
+ let promises = []
|
|
|
let fontType = {
|
|
|
'1':"13pt",
|
|
|
'2':"16.9pt",
|
|
@@ -763,7 +919,25 @@ export default {
|
|
|
elementList.forEach((el,elIndex) => {
|
|
|
let img = el.getElementsByTagName('img');
|
|
|
for(let i=0;i<img.length;i++){
|
|
|
- img[i].setAttribute("crossOrigin","*");
|
|
|
+ // img[i].setAttribute('crossOrigin',"*")
|
|
|
+ // let src = img[i].getAttribute("src");
|
|
|
+ // promises.push(getFile(src).then(async res=>{
|
|
|
+ // await new Promise(resolve => {
|
|
|
+ // if (res.data != 1) {
|
|
|
+ // let blob = new Blob([res.data]);
|
|
|
+ // // blob = new Blob([res.data],{type:res.headers['content-type']});
|
|
|
+ // let reader = new FileReader();
|
|
|
+ // reader.readAsDataURL(blob);
|
|
|
+ // reader.onload = function(e){
|
|
|
+ // img[i].setAttribute("src",this.result);
|
|
|
+ // resolve();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+
|
|
|
+ // }))
|
|
|
+
|
|
|
+ // img[i].setAttribute("crossOrigin","*");
|
|
|
}
|
|
|
let font = el.getElementsByTagName('font');
|
|
|
for(let i=0;i<font.length;i++){
|
|
@@ -788,37 +962,42 @@ export default {
|
|
|
p[i].setAttribute("style",newStyle)
|
|
|
}
|
|
|
})
|
|
|
- let newData = JSON.parse(JSON.stringify(this.downWordData))
|
|
|
- getWord2({...newData,signData:this.signData,elementList}).then(_=>{
|
|
|
- elementList.forEach((el,elIndex) => {
|
|
|
- let img = el.getElementsByTagName('img');
|
|
|
- for(let i=0;i<img.length;i++){
|
|
|
- img[i].removeAttribute('crossOrigin')
|
|
|
- }
|
|
|
- let font = el.getElementsByTagName('font');
|
|
|
- for(let i=0;i<font.length;i++){
|
|
|
- font[i].removeAttribute("style")
|
|
|
- font[i].setAttribute("size",fontSize[i])
|
|
|
- }
|
|
|
- // 替换p标签的font-size
|
|
|
- let p = el.querySelectorAll("*")
|
|
|
- for(let i=0;i<p.length;i++){
|
|
|
- let oldStyle = pFontSize.find(p=>p.index==`${elIndex}:${i}`)
|
|
|
- if(!oldStyle)continue;
|
|
|
- p[i].setAttribute("style",oldStyle.style)
|
|
|
- // let pStyle = p[i].getAttribute("style")
|
|
|
-
|
|
|
- // if(!pStyle)continue
|
|
|
- // let matchArr = pStyle.match(/font-size: (\d+)px/);
|
|
|
- // console.log(matchArr)
|
|
|
- // if(!matchArr)continue;
|
|
|
- // console.log(pFontSize[i])
|
|
|
- // p[i].setAttribute("style",pFontSize[i])
|
|
|
- }
|
|
|
+ // return
|
|
|
+ // return await Promise.all(promises)
|
|
|
+ Promise.all(promises).then(()=>{
|
|
|
+ let newData = JSON.parse(JSON.stringify(this.downWordData))
|
|
|
+ getWord2({...newData,signData:this.signData,elementList}).then(_=>{
|
|
|
+ elementList.forEach((el,elIndex) => {
|
|
|
+ let img = el.getElementsByTagName('img');
|
|
|
+ for(let i=0;i<img.length;i++){
|
|
|
+ img[i].removeAttribute('crossOrigin')
|
|
|
+ }
|
|
|
+ let font = el.getElementsByTagName('font');
|
|
|
+ for(let i=0;i<font.length;i++){
|
|
|
+ font[i].removeAttribute("style")
|
|
|
+ font[i].setAttribute("size",fontSize[i])
|
|
|
+ }
|
|
|
+ // 替换p标签的font-size
|
|
|
+ let p = el.querySelectorAll("*")
|
|
|
+ for(let i=0;i<p.length;i++){
|
|
|
+ let oldStyle = pFontSize.find(p=>p.index==`${elIndex}:${i}`)
|
|
|
+ if(!oldStyle)continue;
|
|
|
+ p[i].setAttribute("style",oldStyle.style)
|
|
|
+ // let pStyle = p[i].getAttribute("style")
|
|
|
+
|
|
|
+ // if(!pStyle)continue
|
|
|
+ // let matchArr = pStyle.match(/font-size: (\d+)px/);
|
|
|
+ // console.log(matchArr)
|
|
|
+ // if(!matchArr)continue;
|
|
|
+ // console.log(pFontSize[i])
|
|
|
+ // p[i].setAttribute("style",pFontSize[i])
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.downloadWordDig = false;
|
|
|
+ this.loading = false;
|
|
|
})
|
|
|
- this.downloadWordDig = false;
|
|
|
- this.loading = false;
|
|
|
})
|
|
|
+
|
|
|
})
|
|
|
|
|
|
|
|
@@ -885,6 +1064,34 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
+ //上传附件
|
|
|
+ fileOption2(file,index,opt){
|
|
|
+ if(opt=='0'){
|
|
|
+ this.checkFile(file.url)
|
|
|
+ }else if(opt=='1'){
|
|
|
+ if(index==0)return;
|
|
|
+ this.wordData.attachment.splice(index-1,0,this.wordData.attachment.splice(index,1)[0]);
|
|
|
+ }else if(opt=='2'){
|
|
|
+ if(index==this.wordData.attachment.length-1)return;
|
|
|
+ this.wordData.attachment.splice(index+1,0,this.wordData.attachment.splice(index,1)[0]);
|
|
|
+ }else if(opt=='3'){
|
|
|
+ this.updateFile = {...file,index:index}
|
|
|
+ this.dialogVisibleUpdateFile2 = true;
|
|
|
+
|
|
|
+ }else if(opt=='4'){
|
|
|
+ this.$confirm("确定删除该文件?","提示",{
|
|
|
+ type:"error",
|
|
|
+ confirmButtonText:"确定删除",
|
|
|
+ cancelButtonText:"取消",
|
|
|
+ }).then(_=>{
|
|
|
+ this.wordData.attachment.splice(index,1);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 上传专家文件
|
|
|
+ getFile2(file){
|
|
|
+ this.wordData.attachment.push(file);
|
|
|
+ },
|
|
|
// 上传文件函数
|
|
|
saveFile(){
|
|
|
let params = {
|
|
@@ -950,6 +1157,12 @@ export default {
|
|
|
this.wordData.opinion[this.updateFile.index].fileName = this.updateFile.fileName;
|
|
|
this.dialogVisibleUpdateFile = false;
|
|
|
this.saveFile();
|
|
|
+ },
|
|
|
+ // 修改文件名称
|
|
|
+ updateFileName2(){
|
|
|
+ if(!this.updateFile.fileName)return this.$message.error("请输入文件名称");
|
|
|
+ this.wordData.attachment[this.updateFile.index].fileName = this.updateFile.fileName;
|
|
|
+ this.dialogVisibleUpdateFile2 = false;
|
|
|
}
|
|
|
// downloadWord2() {
|
|
|
// // downloadPDF(
|