ProjectManagement4.vue 11 KB

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