index.vue 15 KB

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