ProjectManagementEndProjectFile.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <!-- 项目管理 项目结题附件 -->
  3. <div class="ProjectManagement5" v-loading="loading">
  4. <div class="pmInp">
  5. <beUpload @getFile="getFile" v-show="state!==4" :navName="'上传文件'" :accept="accept" :progress="progress"></beUpload>
  6. <el-button v-show="state==4" style="background: #ccc !important;cursor: no-drop;color: #fff !important;border: 0;font-size: 16px;">上传文件</el-button>
  7. </div>
  8. <el-progress v-show="progress.show" :percentage="progress.value" :format="ProgressFormat"></el-progress>
  9. <!-- 表格部分开始 -->
  10. <el-table
  11. :data="tableData"
  12. tooltip-effect="dark"
  13. stripe
  14. class="fontSize"
  15. :header-cell-style="{ background: '#f2f2f2',color:'#000' }"
  16. >
  17. <!-- <el-table-column
  18. prop="projectTitle"
  19. label="项目名称"
  20. align="center"
  21. >
  22. <template>
  23. <span>{{ title }}</span>
  24. </template>
  25. </el-table-column> -->
  26. <el-table-column
  27. prop="fileName"
  28. label="项目中期报告"
  29. align="center"
  30. >
  31. </el-table-column>
  32. <el-table-column
  33. prop="size"
  34. label="大小"
  35. align="center"
  36. >
  37. </el-table-column>
  38. <el-table-column
  39. prop="uploadTime"
  40. label="时间"
  41. align="center"
  42. >
  43. </el-table-column>
  44. <el-table-column
  45. prop="operation"
  46. align="center"
  47. label="操作"
  48. width="200"
  49. >
  50. <template #default="scope">
  51. <div class="operations">
  52. <el-button type="primary" size="mini" @click="checkFile(scope.row.url)" style="background: #477edd">明细查看</el-button>
  53. <el-button type="primary" v-show="state!=4" size="mini" @click="DelFile(scope.$index)" style="background: #477edd">删除</el-button>
  54. </div>
  55. </template>
  56. </el-table-column>
  57. </el-table>
  58. <!-- 展示文档开始 -->
  59. <el-dialog
  60. title="展示文件"
  61. :visible.sync="showFile"
  62. width="80vw"
  63. class="addDialog showDialog"
  64. >
  65. <div class="showFileArea">
  66. <!-- <vpdf v-if="/^\s*$/g.test(showFileUrl)&&showFileUrl.split('.')[showFileUrl.split('.').length-1]=='pdf'" :pdfUrl="showFileUrl"></vpdf> -->
  67. <vword
  68. style="width: 100%; height: 100%; overflow: auto"
  69. class="fullStyle"
  70. v-if="Wordss['type']!='pdf' && Wordss['name']!='图片'"
  71. :pdfUrl="'https://view.officeapps.live.com/op/view.aspx?src='+showFileUrl"
  72. ></vword>
  73. <vpdf
  74. style="width: 100%; height: 100%; overflow: auto"
  75. class="fullStyle"
  76. :pdfUrl="showFileUrl"
  77. v-if="Wordss['type']=='pdf'"
  78. ></vpdf>
  79. <img :src="showFileUrl" alt="图片哦" v-if="Wordss['name']=='图片'" style="width: auto;height: auto;max-width: 100%;max-height: 100%;">
  80. </div>
  81. </el-dialog>
  82. <!-- 分页 -->
  83. <!-- <el-pagination
  84. @current-change="handleCurrentChange"
  85. :current-page="table.currentPage"
  86. :page-size="table.packageSize"
  87. layout=" prev, pager, next"
  88. background
  89. class="paginations"
  90. :total="table.total">
  91. </el-pagination> -->
  92. <!-- 分页结束 -->
  93. </div>
  94. </template>
  95. <script>
  96. import beUpload from '@/components/tool/beUpload'
  97. import vpdf from "@/components/vpdf.vue";
  98. import vword from "@/components/vword.vue";
  99. export default {
  100. components: { beUpload, vpdf, vword },
  101. data() {
  102. return {
  103. accept:"*",
  104. // table:{ // 分页数据
  105. // total:0,
  106. // packageSize:8,
  107. // currentPage:1
  108. // },
  109. loading:false,
  110. state:0,
  111. showFile:false,
  112. showFileType: 0,
  113. showFileUrl: "",
  114. Wordss:{type:"",name:""},
  115. canonical:{
  116. Image:/^https?:\/\/(.+\/)+.+(\.(gif|png|jpg|jpeg|webp|svg|psd|bmp|tif))$/i,
  117. File:/^https?:\/\/(.+\/)+.+(\.(docx|xlsx|ppt|pdf))$/i
  118. },
  119. title:"",
  120. tableData:[], //附件列表
  121. file:'',
  122. progress:{
  123. value:0,
  124. show:false
  125. },
  126. }
  127. },
  128. methods:{
  129. DelFile(index){
  130. this.$confirm("你确定要删除该文件吗?",'确定文件删除').then(res=>{
  131. this.tableData.splice(index,1);
  132. this.ajax.post(this.$store.state.api+"/UpdateProjectEndFile",{
  133. uid:this.$store.state.userInfo.userid,
  134. pid:this.$route.query['pid'],
  135. file:JSON.stringify(this.tableData)
  136. }).then(res=>{
  137. console.log(res)
  138. if(res.data==1){
  139. this.$message.success("删除文件成功")
  140. }else{
  141. this.$message.error("删除文件失败")
  142. }
  143. this.getData();
  144. })
  145. }).catch(err=>{
  146. console.log("取消删除文件")
  147. })
  148. },
  149. ProgressFormat(value){ //进度条
  150. return value ==100?'100%':`${value}%`
  151. },
  152. //展示文件
  153. checkFile(url) {
  154. this.showFileUrl = url;
  155. this.showFile = true;
  156. if(typeof url=='undefined')return {type:"",name:""};
  157. let urlSplit = url.split(".");
  158. const type = urlSplit[urlSplit.length-1]
  159. if(this.canonical.Image.test(url)){
  160. this.Wordss={type:type,name:"图片"}
  161. return console.log(this.Wordss);
  162. }
  163. if(this.canonical.File.test(url)){
  164. this.Wordss={type:type,name:"文档"}
  165. return console.log(this.Wordss);
  166. }
  167. else return this.Wordss={type:type,name:type}
  168. },
  169. getFile(val) { //上传文件
  170. this.file = val;
  171. let oldData = [];
  172. if (this.tableData!=null) {
  173. this.tableData.forEach(item=>oldData.push(item))
  174. oldData.push(val)
  175. }else{
  176. oldData.push(val)
  177. }
  178. let param={
  179. uid:this.$store.state.userInfo.userid,
  180. cid:this.$route.query['pid'],
  181. projectFile:JSON.stringify(oldData)
  182. }
  183. this.ajax
  184. .post(this.$store.state.api+'/AddProjectManageFile',param)
  185. .then(res=>{
  186. if (res.data==1) {
  187. this.getData()
  188. this.$message.success('上传成功')
  189. this.progress.show = false;
  190. }else{
  191. this.$message.error('上传失败')
  192. }
  193. },err=>{
  194. console.log(err);
  195. })
  196. },
  197. // handleCurrentChange(val) { //当页数发生改变的时候调用获取列表数据请求
  198. // // console.log(`当前页: ${val}`);
  199. // this.table.currentPage=val
  200. // this.getData()
  201. // },
  202. getData(){ //获取基础信息
  203. this.loading = true;
  204. let param={
  205. uid:this.$store.state.userInfo.userid,
  206. pid:this.$route.query['pid'],
  207. }
  208. // console.log(param);
  209. this.ajax
  210. .get(this.$store.state.api+'/SelectProjectManageFile',param)
  211. .then(res=>{
  212. console.log(res);
  213. this.state=res.data[0][0].isupload;
  214. let file = JSON.parse(res.data[0][0]['endFile']);
  215. this.tableData=file
  216. this.loading = false;
  217. },err=>{
  218. console.log(err);
  219. })
  220. },
  221. // content(){
  222. // this.$router.push('/ProjectManagement1')
  223. // },
  224. // remark(){
  225. // this.$router.push('/ProjectManagement2')
  226. // },
  227. // remark2(){
  228. // this.$router.push('/ProjectManagement3')
  229. // },
  230. // remark4(){
  231. // this.$router.push('/ProjectManagement4')
  232. // },
  233. // remark5(){
  234. // this.$router.push('/ProjectManagement5')
  235. // },
  236. // backBtn2(){
  237. // this.$router.push('/ProjectManagement1')
  238. // },
  239. // detail(){
  240. // },
  241. back(){
  242. this.$router.push('/ProjectManagement')
  243. },
  244. },
  245. mounted(){
  246. this.getData()
  247. console.log(111);
  248. }
  249. }
  250. </script>
  251. <style lang="less">
  252. .ProjectManagement5{
  253. .pagination{
  254. float: right;
  255. margin: 20px 55px 10px;
  256. }
  257. .addDialog {
  258. font-size: 18px;
  259. .el-dialog {
  260. border-radius: 5px;
  261. overflow: hidden;
  262. }
  263. .deleteContent {
  264. width: 100%;
  265. margin: 30px 0;
  266. font-size: 22px;
  267. color: #000;
  268. }
  269. .addDialogLogo {
  270. width: 60px;
  271. height: 30px;
  272. display: flex;
  273. justify-content: center;
  274. line-height: 30px;
  275. border-radius: 5px;
  276. background: #f2f2f2;
  277. position: absolute;
  278. left: 20px; top: 15px;
  279. }
  280. .el-dialog__header {
  281. display: flex;
  282. justify-content: center;
  283. background: #32455b;
  284. }
  285. .el-dialog__title {
  286. color:#fff;
  287. display: flex;
  288. justify-content: center;
  289. font-size: 18px;
  290. position: relative;
  291. top: -2px;
  292. }
  293. .addDialogMid {
  294. box-sizing: border-box;
  295. padding: 0 60px 0 10px;
  296. .addDialogTit {
  297. display: flex;
  298. span {
  299. width: 80px;
  300. font-size: 16px;
  301. line-height: 40px;
  302. text-align: left;
  303. }
  304. }
  305. .addDialogTit1 {
  306. display: flex;
  307. justify-content: space-between;
  308. margin-bottom: 15px;
  309. }
  310. .addDialogTit2 {
  311. margin-top: 10px;
  312. font-size: 16px;
  313. color: #000;
  314. text-indent: 2em;
  315. }
  316. .addDialogCon {
  317. margin-top: 20px;
  318. }
  319. }
  320. .dialog-footer {
  321. display: flex;
  322. justify-content: center;
  323. box-sizing: border-box;
  324. // .btn5 {
  325. // font-size: 16px;
  326. // }
  327. }
  328. }
  329. .pm5footer{
  330. float: right;
  331. margin-top: 30px;
  332. .backBtn{
  333. background: #169bd5;
  334. float: right;
  335. width: 100px;
  336. }
  337. }
  338. .pm1Tit{
  339. display: flex;
  340. margin-left: 20px;
  341. div{
  342. width: 130px;
  343. cursor: pointer;
  344. font-weight: 550;
  345. }
  346. .pr1TitBass{
  347. height: 2px;
  348. width: 100%;
  349. background: #3D67BC;
  350. }
  351. }
  352. .pmInp{
  353. width: 100%;
  354. margin: 10px 0 10px 0;
  355. display: flex;
  356. justify-content: flex-end;
  357. // .btn{
  358. // width: 120px;
  359. // font-size: 16px;
  360. // border: none;
  361. // // margin-left: 10px;
  362. // }
  363. }
  364. }
  365. </style>