index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <template>
  2. <div id="file_moddle_manage" v-loading="loading">
  3. <!-- 左边模型文件夹列表 -->
  4. <div class="col_left">
  5. <div class="grid-content grid-left">
  6. <el-card class="box-card" :body-style="{ padding: '0px', height: '100%' }">
  7. <div class="top_hand left_top_hand">
  8. <div class="folder-box">
  9. <el-tooltip class="item" effect="dark" content="新建文件夹" placement="top-start">
  10. <el-button icon="el-icon-folder-add" @click="addFolder" class="icon_font"></el-button>
  11. </el-tooltip>
  12. <el-tooltip class="item" effect="dark" content="删除文件夹" placement="top-start">
  13. <el-button icon="el-icon-folder-remove" class="icon_font" @click="removeFolder"></el-button>
  14. </el-tooltip>
  15. </div>
  16. <div class="file-box">
  17. <el-tooltip class="item" effect="dark" content="编辑文件夹" placement="top-start">
  18. <el-button @click="editFolder" icon="el-icon-edit" class="icon_font"></el-button>
  19. </el-tooltip>
  20. </div>
  21. </div>
  22. <div class="folder-list">
  23. <div class="head">建筑模型文件夹
  24. <span>(建议按建筑模型进行命名)</span>
  25. </div>
  26. <ul class="lists">
  27. <el-scrollbar style="height:100%;">
  28. <li @click="openFolder(index,item)" v-for="(item,index) in navigationModel" :key="index"
  29. :class="[choiceIndex == index + 1 ? 'li-active' : '']">
  30. <i :class="[choiceIndex == index + 1 ? 'el-icon-folder-opened':'el-icon-folder','icon_font']" width="40" height="40"></i>
  31. <span :title="item.Name">{{item.Name}}</span>
  32. </li>
  33. </el-scrollbar>
  34. </ul>
  35. </div>
  36. </el-card>
  37. </div>
  38. </div>
  39. <!-- 右边文件表格 -->
  40. <div class="col_right">
  41. <el-card class="box-card" :body-style="{ padding: '0px', height:'100%' }">
  42. <!-- 顶部操作栏 -->
  43. <div class="top_hand right_top_hand">
  44. <el-button @click="addFloorFile">添加楼层文件</el-button>
  45. <el-button @click="queryFloorFile(currentFolderId)">刷新</el-button>
  46. </div>
  47. <!-- 列表 -->
  48. <floorTable v-loading="tableLoading" ref="floorTable" :tableData="tableData" :modelFolderName="currentFolderName" @openModelLog="queryModelLog"
  49. @replaceModel="repliaceModel" @percentFinish="queryFloorFile(currentFolderId)"
  50. :persentList="persentList"></floorTable>
  51. </el-card>
  52. </div>
  53. <!-- 弹窗 开始-->
  54. <!-- 模型日志弹窗 -->
  55. <modelLog :modelLogVisible="modelLogVisible" :modelFolderName="currentFolderName" @deleteFinish="updataLog"
  56. @CloseModelLogDia="modelLogVisible=false" :logData="logData"></modelLog>
  57. <!-- 替换模型弹窗 -->
  58. <repliceModel :repliceModelVisible="repliceModelVisible" @closeReplaceModelDia="repliceModelVisible=false" :replaceModelItem="replaceModelItem"
  59. @updataModel="updateModelFile"></repliceModel>
  60. <!-- 新增楼层 -->
  61. <addFloorDialog :addFloorFileVisible="addFloorFileVisible" :floorList="tableData" :FolderName="currentFolderName" :FolderId="currentFolderId"
  62. @closeAddFloorDia="addFloorFileVisible=false" @finishCreateFloor="uploadModelFIle"></addFloorDialog>
  63. <!-- 新增文件夹名称 -->
  64. <addFolder :addFolderVisible="addFolderVisible" @closeAddFolderVisible="addFolderVisible=false;folderName=''" :folderName="folderName"
  65. @getfolderModel="queryModel"></addFolder>
  66. <!-- 编辑文件夹名字 -->
  67. <changeFolderName :currentFolderId="currentFolderId" :changeFolderNameVisible="changeFolderNameVisible" :folderName="folderName"
  68. @finishChangeFolderName="queryModel" @closeChangeFolderVisible="changeFolderNameVisible=false;folderName=''"></changeFolderName>
  69. <!-- 弹窗 结束-->
  70. </div>
  71. </template>
  72. <script>
  73. import { mapGetters } from "vuex";
  74. import request from "@/api/model/file.js";
  75. import Bus from '@/utils/bus.js'
  76. import dasBoard from "@/views/dasboard/index";
  77. import modelLog from "@/components/model/file/modelLog"; //模型日志弹窗
  78. import repliceModel from "@/components/model/file/replaceModelDialog"; //替换模型弹窗
  79. import addFloorDialog from "@/components/model/file/addFloorDialog"; //新增楼层弹窗
  80. import addFolder from "@/components/model/file/addFolder"; //新增文件夹
  81. import changeFolderName from "@/components/model/file/changeFolderName"; //编辑名字
  82. import floorTable from "@/components/model/file/floorTable"; //右侧list表
  83. export default {
  84. computed: {
  85. ...mapGetters("layout", ["projectId", "userInfo", "userId", "secret", "uploaderList"])
  86. },
  87. components: {
  88. dasBoard,
  89. modelLog,
  90. repliceModel,
  91. addFloorDialog,
  92. addFolder,
  93. changeFolderName,
  94. floorTable
  95. },
  96. data() {
  97. return {
  98. addFolderVisible: false, //是否显示新增文件夹弹窗
  99. addFloorFileVisible: false, //是否显示增加楼层文件弹窗
  100. repliceModelVisible: false, //是否显示替换楼层模型弹窗
  101. modelLogVisible: false, //是否显示模型日志弹窗
  102. changeFolderNameVisible: false, //是否显示编辑文件夹弹窗
  103. folderName: "", //新建文件夹名称
  104. navigationModel: [
  105. {
  106. Name: ""
  107. }
  108. ], //文件夹模型list
  109. choiceIndex: 0, //当前文件夹index
  110. currentFolderId: "", //当前选择的文件夹id
  111. currentFolderName: "", //当前选择文件夹的Name
  112. currentFloorModelId: "", //当前选择的楼层文件id
  113. tableData: [],
  114. loading: false, //加载loading
  115. tableLoading: false, //表格加载loading
  116. logData: [], //楼层文件对应的模型日志
  117. replaceModelItem: null, //替换文件的item
  118. uploadFloorModelIdList: [], //上传楼层文件得数组,上传完成则为空
  119. //请求头
  120. headers: {
  121. ProjectId: ""
  122. },
  123. updataData: {
  124. model: {}
  125. },
  126. persentList: [], //请求进度列表
  127. isJump: true //是否可以调整页面
  128. };
  129. },
  130. mounted() {
  131. // // 文件选择后的回调
  132. // Bus.$on('fileAdded', () => {
  133. // console.log('文件已选择')
  134. // });
  135. // // 文件上传成功的回调
  136. // Bus.$on('fileSuccess', () => {
  137. // console.log('文件上传成功')
  138. // });
  139. },
  140. destroyed() {
  141. // Bus.$off('fileAdded');
  142. // Bus.$off('fileSuccess');
  143. },
  144. methods: {
  145. // 以下是模型文件夹
  146. // 打开模型文件夹
  147. openFolder(index, item) {
  148. this.choiceIndex = index + 1;
  149. this.currentFolderId = item.Id;
  150. this.currentFolderName = item.Name;
  151. // 获取模型文件夹对应得楼层文件
  152. this.queryFloorFile(this.currentFolderId);
  153. },
  154. //新增模型文件夹
  155. addFolder() {
  156. this.folderName = "";
  157. this.addFolderVisible = true;
  158. },
  159. //删除模型文件夹
  160. removeFolder() {
  161. this.$alert(`确定要删除文件夹 <${this.currentFolderName}> 吗?`, "提示", {
  162. confirmButtonText: "确定",
  163. callback: action => {
  164. if (action == "confirm") {
  165. let params = {
  166. Id: this.currentFolderId,
  167. ProjectId: this.projectId
  168. };
  169. request.deleteModel(params, res => {
  170. this.$message({
  171. message: "删除成功!",
  172. type: "success"
  173. });
  174. this.queryModel();
  175. });
  176. } else {
  177. this.$message({
  178. type: "info",
  179. message: `取消操作`
  180. });
  181. }
  182. }
  183. });
  184. },
  185. //编辑文件夹
  186. editFolder() {
  187. this.folderName = this.currentFolderName;
  188. this.changeFolderNameVisible = true;
  189. },
  190. // 查询所有文件夹模型
  191. queryModel() {
  192. this.loading = true;
  193. request.queryModel("", res => {
  194. this.navigationModel = res.Content;
  195. this.loading = false;
  196. if (this.navigationModel.length) {
  197. //默认选择第一个文件夹
  198. this.choiceIndex = 1;
  199. this.currentFolderName = this.navigationModel[0].Name;
  200. this.currentFolderId = this.navigationModel[0].Id;
  201. this.queryFloorFile(this.currentFolderId);
  202. } else {
  203. this.tableData = []
  204. }
  205. });
  206. },
  207. ///一下是楼层文件
  208. //获取楼层文件
  209. /**
  210. * @param currentFolderId 当前选择的文件夹id
  211. */
  212. queryFloorFile(currentFolderId) {
  213. if(currentFolderId){
  214. this.tableData = [];
  215. this.tableLoading = true;
  216. let data = {
  217. FolderId: currentFolderId,
  218. ProjectId: this.projectId
  219. };
  220. return new Promise((resolve, reject) => {
  221. request.queryFloorList(data, res => {
  222. res.Content.map(item => {
  223. /**
  224. * @info: 状态显示说明
  225. * 0: 上传中(上传的用户可操作:中止)
  226. * 1: 等待检查
  227. * 10: 模型检查中
  228. * 11: 未通过检查
  229. * 2、20、21、3、31: 正常(所有用户可操作:下载、查看历史)
  230. * 4: 正常(所有用户可操作:下载、替换、查看历史)
  231. */
  232. if (item.Status == 2 || item.Status == 20 || item.Status == 21 || item.Status == 3 || item.Status == 31 || item.Status == 4) {
  233. Object.assign(item, { precent: 0 });
  234. } else {
  235. Object.assign(item, { precent: 100 });
  236. if (this.persentList.length != 0) {
  237. this.persentList.forEach(pItem => {
  238. if (item.Id == pItem.Id) {
  239. Object.assign(item, { precent: pItem.precent ? pItem.precent : 0 });
  240. }
  241. });
  242. }
  243. }
  244. //删除错误模型(多人登录会有问题)
  245. /****状态为0,上传人为本人并且上传列表无对应的模型文件 */
  246. // if (item.Status == 0 && item.UserName == this.userInfo.userName && !this.uploaderList.some(file => {return file.modelId == item.CurrentModelId})) {
  247. // request.deleteModelFileList({Id: item.CurrentModelId}, res => {console.log('删除错误模型:',item.CurrentModelId)})
  248. // }
  249. });
  250. this.tableData = res.Content;
  251. this.tableLoading = false;
  252. resolve();
  253. });
  254. });
  255. }
  256. },
  257. //添加楼层文件
  258. addFloorFile() {
  259. this.addFloorFileVisible = true;
  260. },
  261. //以下是文件模型
  262. //打开替换文件模型
  263. repliaceModel(item) {
  264. this.replaceModelItem = item;
  265. this.repliceModelVisible = true;
  266. },
  267. // 上传模型文件
  268. uploadModelFIle(data) {
  269. Bus.$emit('openUploader', {
  270. uploadId: data.uploadId,
  271. modelId: data.modelId,
  272. systemId: 'revit', //系统名称
  273. secret: '63afbef6906c342b', //系统密码
  274. }, data.file.raw)
  275. // 在列表中添加
  276. this.persentList.push({
  277. Id: data.floorId,
  278. precent: 0
  279. });
  280. this.queryFloorFile(this.currentFolderId);
  281. },
  282. //更新模型文件;
  283. updateModelFile(data) {
  284. let params = {
  285. FileName: data.file.name,
  286. FloorName: data.replaceModelItem.FloorName,
  287. FolderId: data.replaceModelItem.FolderId,
  288. Note: data.replaceModelItem.Note,
  289. ProjectId: this.projectId,
  290. ReplaceReason: 0,
  291. Size: data.file.size,
  292. UserName: this.userInfo.userName,
  293. UserId: this.userInfo.userId
  294. };
  295. // 替换模型文件
  296. request.modelFileUpload(params, res => {
  297. // 上传
  298. this.persentList.push({
  299. Id: data.replaceModelItem.Id,
  300. precent: 0
  301. });
  302. // 修改precent得值
  303. this.tableData.map(item => {
  304. if (item.Id == data.replaceModelItem.Id) {
  305. item.precent = 0;
  306. }
  307. });
  308. this.queryFloorFile(this.currentFolderId);
  309. Bus.$emit('openUploader', {
  310. uploadId: res.UploadId,
  311. modelId: res.ModelId,
  312. systemId: 'revit', //系统名称
  313. secret: '63afbef6906c342b', //系统密码
  314. }, data.file.raw)
  315. });
  316. },
  317. //查看模型日志
  318. queryModelLog(item) {
  319. this.FloorModelId = item.Id; //楼层模型文件
  320. request.queryModelFile(this.FloorModelId, res => {
  321. this.logData = res.Content;
  322. this.modelLogVisible = true;
  323. });
  324. },
  325. // 刷新日志
  326. updataLog() {
  327. request.queryModelFile(this.FloorModelId, res => {
  328. this.logData = res.Content;
  329. });
  330. },
  331. },
  332. watch: {
  333. projectId() {
  334. this.queryModel()
  335. }
  336. },
  337. mounted() {
  338. this.queryModel();
  339. Bus.$on('modelStatusChange', message => {
  340. this.queryFloorFile(this.currentFolderId);
  341. })
  342. // 十秒刷新次楼层列表
  343. // setInterval(()=>{
  344. // this.queryFloorFile(this.currentFolderId)
  345. // },10000)
  346. }
  347. };
  348. </script>
  349. <style lang="less" scoped>
  350. #file_moddle_manage {
  351. width: 100%;
  352. height: 100%;
  353. display: flex;
  354. overflow: hidden !important;
  355. .col_left {
  356. width: 280px;
  357. height: 100%;
  358. }
  359. .col_right {
  360. width: calc(100% - 280px);
  361. height: 100%;
  362. }
  363. .grid-content {
  364. height: 100%;
  365. }
  366. .box-card {
  367. height: 100%;
  368. }
  369. .grid-left {
  370. padding-right: 10px;
  371. box-sizing: border-box;
  372. }
  373. // 顶部
  374. .top_hand {
  375. height: 60px;
  376. width: 100%;
  377. padding: 10px;
  378. box-sizing: border-box;
  379. display: flex;
  380. }
  381. .left_top_hand {
  382. align-items: center;
  383. justify-content: space-between;
  384. .folder-box {
  385. display: flex;
  386. height: 40px;
  387. flex-direction: row;
  388. }
  389. .box-icon {
  390. width: 40px;
  391. height: 40px;
  392. font-size: 30px;
  393. display: flex;
  394. justify-content: center;
  395. align-items: center;
  396. float: left;
  397. }
  398. }
  399. // 左侧文件夹列表
  400. .folder-list {
  401. width: 100%;
  402. height: calc(100% - 60px);
  403. .head {
  404. height: 42px;
  405. width: 100%;
  406. padding-left: 10px;
  407. box-sizing: border-box;
  408. background: #d9d9d9;
  409. color: #2b2b2b;
  410. display: flex;
  411. justify-content: left;
  412. align-items: center;
  413. font-weight: bold;
  414. span{
  415. font-weight: normal;
  416. font-size: 12px;
  417. color: #606266;
  418. }
  419. }
  420. .lists {
  421. width: 100%;
  422. margin-top: 10px;
  423. height: calc(100% - 52px);
  424. overflow-y: auto;
  425. li {
  426. height: 42px;
  427. display: flex;
  428. justify-content: left;
  429. align-items: center;
  430. padding-left: 20px;
  431. box-sizing: border-box;
  432. color: #555;
  433. cursor: pointer;
  434. span {
  435. padding-left: 6px;
  436. overflow: hidden;
  437. text-overflow: ellipsis;
  438. white-space: nowrap;
  439. }
  440. }
  441. li:hover {
  442. background-color: #f5f7fa;
  443. color: #000;
  444. }
  445. .li-active {
  446. background-color: #f5f7fa;
  447. color: #000;
  448. }
  449. }
  450. }
  451. .icon_font {
  452. font-size: 18px;
  453. }
  454. }
  455. /deep/ .el-scrollbar__wrap {
  456. overflow-x: hidden;
  457. }
  458. </style>