123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- <template>
- <!-- 项目管理 项目附件 -->
- <div class="ProjectManagement4" v-loading="loading">
- <div class="pmInp">
- <!-- <el-button type="primary" class="btn" size="mini">上传文件</el-button> -->
- <beUpload @getFile="getFile" v-show="state==2 || state==3" :navName="'上传文件'" :accept="accept" :progress="progress"></beUpload>
- <!-- <beUpload @getFile="getFile" v-show="state==1" :navName="'上传文件'" :accept="accept" :progress="progress"></beUpload> -->
- <el-button v-show="state==4" style="background: #ccc !important;cursor: no-drop;color: #fff !important;border: 0;font-size: 16px;height: 40px;">上传文件</el-button>
- </div>
- <el-progress v-show="progress.show" :percentage="progress.value" :format="ProgressFormat"></el-progress>
- <!-- 表格开始 -->
- <el-table
- :data="tableData"
- tooltip-effect="dark"
- stripe
- class="fontSize"
- :header-cell-style="{ background: '#f2f2f2',color:'#000' }"
- >
-
- <!-- <el-table-column
- prop="title"
- label="活动名称"
- align="center"
- >
- </el-table-column> -->
- <el-table-column
- prop="fileName"
- label="活动中期报告"
- align="center"
- >
- </el-table-column>
-
- <el-table-column
- prop="size"
- label="大小"
- align="center"
- >
- </el-table-column>
-
- <el-table-column
- prop="uploadTime"
- label="时间"
- align="center"
- >
- </el-table-column>
- <el-table-column
- prop="operation"
- align="center"
- label="操作"
- >
- <template #default="scope">
- <div class="operations">
- <el-button type="primary" class="bt1" size="mini" @click="checkFile(scope.row.url)" style="background: #477edd">详情查看</el-button>
- <el-button type="primary" class="bt1" size="mini" @click="DelFile(scope.$index)" style="background: #477edd">删除</el-button>
- </div>
- </template>
- </el-table-column>
- </el-table>
- <!-- 表格结束 -->
- <!-- 展示文档开始 -->
- <el-dialog
- title="展示文件"
- :visible.sync="showFile"
- width="80vw"
- class="addDialog showDialog"
- >
- <div class="addDialogLogo">LOGO</div>
- <div class="showFileArea">
- <!-- <vpdf v-if="/^\s*$/g.test(showFileUrl)&&showFileUrl.split('.')[showFileUrl.split('.').length-1]=='pdf'" :pdfUrl="showFileUrl"></vpdf> -->
- <vword
- style="width: 100%; height: 100%; overflow: auto"
- class="fullStyle"
- v-if="Wordss['type']!='pdf' && Wordss['name']!='图片'"
- :pdfUrl="'https://view.officeapps.live.com/op/view.aspx?src='+showFileUrl"
- ></vword>
- <vpdf
- style="width: 100%; height: 100%; overflow: auto"
- class="fullStyle"
- :pdfUrl="showFileUrl"
- v-if="Wordss['type']=='pdf'"
- ></vpdf>
- <img :src="showFileUrl" alt="图片哦" v-if="Wordss['name']=='图片'" style="width: auto;height: auto;max-width: 100%;max-height: 100%;">
- </div>
- </el-dialog>
- <!-- 展示文档结束 -->
- <!-- 分页 -->
- <!-- <el-pagination
- @current-change="handleCurrentChange"
- :current-page="table.currentPage"
- :page-size="table.packageSize"
- layout=" prev, pager, next"
- background
- class="paginations"
- :total="table.total">
- </el-pagination> -->
- <!-- 分页结束 -->
- </div>
- </template>
-
- <script>
- import beUpload from '@/components/tool/beUpload'
- import vpdf from "@/components/vpdf.vue";
- import vword from "@/components/vword.vue";
- export default {
- components: { beUpload, vpdf, vword },
- data() {
- return {
- accept:"*",
- // table:{ // 分页数据
- // total:0,
- // packageSize:2,
- // currentPage:1
- // },
- loading:false,
- state:'',
- showFile:false,
- showFileType: 0,
- showFileUrl: "",
- Wordss:{type:"",name:""},
- canonical:{
- Image:/^https?:\/\/(.+\/)+.+(\.(gif|png|jpg|jpeg|webp|svg|psd|bmp|tif))$/i,
- File:/^https?:\/\/(.+\/)+.+(\.(docx|xlsx|ppt|pdf))$/i
- },
- tableData:[],
- progress:{
- value:0,
- show:false
- },
- }
- },
- methods:{
- DelFile(index){
- this.$confirm("你确定要删除该文件吗?",'删除文件确认').then(res=>{
- this.tableData.splice(index,1)
- this.ajax.post(this.$store.state.api+"/AddProjectFile",{
- uid:this.$store.state.userInfo.userid,
- cid:this.$route.query['pid'],
- file:JSON.stringify(this.tableData)
- }).then(res=>{
- if(res.data==1){
- this.$message.success("删除成功")
- }else{
- this.$message.error("删除失败")
- }
- this.getData();
- }).catch(err=>{
- console.log(err)
- })
- }).catch(err=>{
- console.log("取消删除文件")
- })
-
- },
- ProgressFormat(value){ //进度条
- return value ==100?'100%':`${value}%`
- },
- //展示文件
- checkFile(url) {
- this.showFileUrl = url;
- this.showFile = true;
- // console.log(url);
- if(typeof url=='undefined')return {type:"",name:""};
- let urlSplit = url.split(".");
- const type = urlSplit[urlSplit.length-1]
- if(this.canonical.Image.test(url)){
-
- this.Wordss={type:type,name:"图片"}
- return console.log(this.Wordss);
- }
- if(this.canonical.File.test(url)){
- this.Wordss={type:type,name:"文档"}
- return console.log(this.Wordss);
- }
- else return this.Wordss={type:type,name:type}
- },
- getFile(val) { //上传文件
- console.log(val);
- this.file = val;
- let oldData = [];
- if (this.tableData!=null) {
- this.tableData.forEach(item=>oldData.push(item))
- oldData.push(val)
- }else{
- oldData.push(val)
- }
-
- let param={
- uid:this.$store.state.userInfo.userid,
- cid:this.$route.query['pid'],
- projectFile:JSON.stringify(oldData)
- }
- this.ajax
- .post(this.$store.state.api+'/AddProjectFile',param)
- .then(res=>{
- // console.log(res);
- if (res.data==1) {
- this.$message.success('上传成功')
- this.getData()
- this.progress.show = false;
- }else{
- this.$message.error('上传失败')
- }
-
- },err=>{
- console.log(err);
- })
- },
- // handleCurrentChange(val) { //当页数发生改变的时候调用获取列表数据请求
- // // console.log(`当前页: ${val}`);
- // this.table.currentPage=val
- // this.getData()
- // },
- getData(){ //获取基础信息
- this.loading = true;
- let param={
- uid:this.$store.state.userInfo.userid,
- pid:this.$route.query['pid'],
- // page:this.table.currentPage,
- // lim:this.table.packageSize
- }
- // console.log(param);
- this.ajax
- .get(this.$store.state.api+'/SelectProjectFile',param)
- .then(res=>{
- console.log(res.data[0][0]);
- this.state=res.data[0][0].isupload;
- let k=[]
- res.data[0].forEach((e,i) => {
- let { projectFile: l } = e;
- k=JSON.parse(l)
- });
- this.tableData=k
- this.loading = false;
- },err=>{
- console.log(err);
- })
- },
- content(){
- this.$router.push('/ProjectManagement1')
- },
- remark(){
- this.$router.push('/ProjectManagement2')
- },
- remark2(){
- this.$router.push('/ProjectManagement3')
- },
-
- remark5(){
- this.$router.push('/ProjectManagement5')
- },
-
- backBtn2(){
- this.$router.push('/ProjectManagement1')
- },
- lookDetails(){
- console.log(111);
- },
- back(){
- this.$router.push('/ProjectManagement')
- },
- },
- mounted(){
- this.getData()
- }
- }
- </script>
-
- <style lang="less">
- .ProjectManagement4{
- .pagination{
- float: right;
- margin: 20px 55px 10px;
- }
-
- .addDialog {
- font-size: 18px;
- .el-dialog {
- border-radius: 5px;
- overflow: hidden;
- }
- .deleteContent {
- width: 100%;
- margin: 30px 0;
- font-size: 22px;
- color: #000;
- }
- .addDialogLogo {
- width: 60px;
- height: 30px;
- display: flex;
- justify-content: center;
- line-height: 30px;
- border-radius: 5px;
- background: #f2f2f2;
- position: absolute;
- left: 20px; top: 15px;
- }
- .el-dialog__header {
- display: flex;
- justify-content: center;
- background: #32455b;
- }
- .el-dialog__title {
- color:#fff;
- display: flex;
- justify-content: center;
- font-size: 18px;
- position: relative;
- top: -2px;
- }
- .addDialogMid {
- box-sizing: border-box;
- padding: 0 60px 0 10px;
- .addDialogTit {
- display: flex;
- span {
- width: 80px;
- font-size: 16px;
- line-height: 40px;
- text-align: left;
- }
- }
- .addDialogTit1 {
- display: flex;
- justify-content: space-between;
- margin-bottom: 15px;
- }
- .addDialogTit2 {
- margin-top: 10px;
- font-size: 16px;
- color: #000;
- text-indent: 2em;
- }
- .addDialogCon {
- margin-top: 20px;
- }
- }
- .dialog-footer {
- display: flex;
- justify-content: center;
- box-sizing: border-box;
-
- }
- }
-
-
- .pmInp{
- width: 100%;
- display: flex;
- margin: 10px 0 10px 0;
- justify-content: flex-end;
- // .btn{
- // width: 120px !important;
- // height: 40px !important;
- // font-size: 16px !important;
- // margin-left: 10px;
- // }
- }
-
- }
-
- </style>
|