fileCenter.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  1. <template>
  2. <section >
  3. <div :style="'background:#f7f7f7;padding:10px 50px;height:'+tableHeight+'px;'">
  4. <!--工具条-->
  5. <div style="padding: 20px;background:#fff;border-bottom:1px solid #ddd;font-weight:500;font-size:15px;">
  6. <span @click="viewFolder(null)" style="color: #409EFF;cursor: pointer;">{{ $t('library') }}</span>
  7. <span v-for="path in pathList" :key="path.id" @click="viewFolder(path)" class="mianbaoxie"> <i class="el-icon-arrow-right jianto"></i> {{path.documentName}}</span>
  8. <span style="float:right;">
  9. <!-- <el-link type="primary" :underline="false" v-if="list.length
  10. > 0"><i class="el-icon-setting"></i><span style="margin-right:5px;" @click="templatedialingClick('设为模板')">设为模板</span></el-link> -->
  11. <el-link type="primary" :underline="false" @click="createFolder"><i class="el-icon-folder-add"></i><span style="margin-left:5px;">{{ $t('createafolder') }}</span></el-link>
  12. <el-upload ref="upload" action="#" :http-request="uploadFile" :show-file-list="false" :limit="1" style="display:inline-block;">
  13. <el-link type="primary" :underline="false" style="margin-left:10px;"><i class="iconfont firerock-iconshangchuan"></i><span style="margin-left:5px;">{{ $t('fileupload') }}</span></el-link>
  14. </el-upload>
  15. </span>
  16. </div>
  17. <div>
  18. <el-col :span="6" style="border-right: 1px solid #EBEEF5;">
  19. <el-table :data="recentFiles" highlight-current-row :height="tableHeight">
  20. <el-table-column prop="documentName" :label="$t('recentdocuments')" sortable="true">
  21. <template slot-scope="scope">
  22. <!-- <el-link @click.stop.native="viewOnline(scope.row)"> -->
  23. <i v-if="scope.row.documentType == -1" class="iconfont firerock-iconfile fileTypeIcon"></i>
  24. <i v-if="scope.row.documentType != -1" :class="docTypeList[scope.row.documentType]+' fileTypeIcon'" ></i>
  25. <span style="margin-left:8px;color:#262626;" >{{scope.row.documentName}}</span>
  26. <!-- <span style="margin-left:8px;color:#262626;" @click="viewOnline(scope.row)">{{scope.row.documentName}}</span> -->
  27. <!-- </el-link> -->
  28. </template>
  29. </el-table-column>
  30. <el-table-column width="60">
  31. <template slot-scope="scope">
  32. <el-button icon="el-icon-download" circle size="mini" style="margin-left:10px;" @click.stop.native="downloadByA(scope.row)"></el-button>
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. </el-col>
  37. <el-col :span="18" >
  38. <el-table :data="list" highlight-current-row :height="tableHeight" style="width: 100%;" @row-click="rowClick" @cell-mouse-enter="cursorOver" >
  39. <!-- <el-table-column prop="folder" ></el-table-column> -->
  40. <el-table-column prop="documentName" :label="$t('names')" >
  41. <template slot-scope="scope" >
  42. <div v-if="scope.row.isFolder==1">
  43. <i class="el-icon-folder fileTypeIcon"></i><span style="margin-left:8px;color:#262626;" >{{scope.row.documentName}}</span>
  44. </div>
  45. <div v-if="scope.row.isFolder==0">
  46. <!-- <el-link @click.stop.native="viewOnline(scope.row)"> -->
  47. <i v-if="scope.row.documentType == -1" class="iconfont firerock-iconfile fileTypeIcon"></i>
  48. <i v-if="scope.row.documentType != -1" :class="docTypeList[scope.row.documentType]+' fileTypeIcon'"></i>
  49. <span style="margin-left:8px;color:#262626;" >{{scope.row.documentName}}</span>
  50. <!-- </el-link> -->
  51. </div>
  52. </template>
  53. </el-table-column>
  54. <el-table-column prop="size" :label="$t('da-xiao')" width="100">
  55. <template slot-scope="scope">
  56. {{scope.row.isFolder==0?scope.row.size:"-"}}
  57. </template>
  58. </el-table-column>
  59. <el-table-column prop="creatorName" :label="$t('creator')" width="100">
  60. <template slot-scope="scope">
  61. <div>
  62. <span v-if="user.userNameNeedTranslate != 1">{{scope.row.creatorName}}</span>
  63. <span v-else><ww-open-data type='userName' :openid='scope.row.creatorName'></ww-open-data></span>
  64. </div>
  65. </template>
  66. </el-table-column>
  67. <el-table-column prop="indate" :label="$t('creationtime')" sortable="true" width="100"></el-table-column>
  68. <el-table-column width="140">
  69. <template slot-scope="scope" >
  70. <div v-show="currentDataId == scope.row.id">
  71. <el-button v-if="scope.row.isFolder == 0" icon="el-icon-download" circle size="mini" @click.stop.native="downloadByA(scope.row)"></el-button>
  72. <el-button icon="el-icon-edit" circle size="mini" style="margin-left:10px;" @click.stop.native="showEditName(scope.row)"></el-button>
  73. <el-button icon="el-icon-delete" circle size="mini" style="margin-left:10px;" @click.stop.native="deleteItem(scope.row)"></el-button>
  74. </div>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. </el-col>
  79. </div>
  80. <!--新增界面-->
  81. <el-dialog :title="$t('fileupload')" v-if="addFormVisible" :visible.sync="addFormVisible" :close-on-click-modal="false" customClass="customWidth" width="600px">
  82. <el-form ref="form1" :model="addForm" :rules="rules" label-width="120px">
  83. <el-form-item :label="$t('expirationdate')" prop="planEndDate">
  84. <el-date-picker v-model="addForm.planEndDate" v-if="user.company.packageProject==1"
  85. :editable="false"
  86. format="yyyy-MM-dd"
  87. value-format="yyyy-MM-dd"
  88. :clearable="false" type="date"
  89. :placeholder="$t('optiondate')"></el-date-picker>
  90. </el-form-item>
  91. </el-form>
  92. <div slot="footer" class="dialog-footer">
  93. <el-button @click.native="addFormVisible = false">{{ $t('btn.cancel') }}</el-button>
  94. <el-button type="primary" @click="submitInsert" :loading="addLoading">{{ $t('btn.submit') }}</el-button>
  95. </div>
  96. </el-dialog>
  97. <!-- 文件夹弹出框 -->
  98. <!-- <el-dialog :title="$t('modifyingFolder')" v-if="addFolderDialog" :visible.sync="addFolderDialog" :close-on-click-modal="false" customClass="customWidth" width="300px">
  99. <el-form ref="form2" :model="folderForm" :rules="rules" >
  100. <el-form-item prop="documentName">
  101. <el-input v-model="folderForm.documentName" :placeholder="$t('pleaseenterfoldername')" maxlength="25"
  102. show-word-limit clearable></el-input>
  103. </el-form-item>
  104. </el-form>
  105. <div slot="footer" class="dialog-footer">
  106. <el-button type="primary" @click="addFolder" style="width:100%;" >{{ $t('save') }}</el-button>
  107. </div>
  108. </el-dialog> -->
  109. <el-dialog :title="$t('modifyingFolder')" v-if="addFolderDialog" :visible.sync="addFolderDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
  110. <div class="titleBox">
  111. <el-tabs v-model="activeName" @tab-click="handleClick" v-if="!addFolderDialogTwo">
  112. <el-tab-pane label="自定义名称" name="one">
  113. <el-form ref="form2" :model="folderForm" :rules="rules" style="margin-top: 10px">
  114. <el-form-item prop="documentName">
  115. <el-input v-model="folderForm.documentName" :placeholder="$t('pleaseenterfoldername')" maxlength="25"
  116. show-word-limit clearable></el-input>
  117. </el-form-item>
  118. </el-form>
  119. </el-tab-pane>
  120. <!-- <el-tab-pane label="从模板中创建" name="two">
  121. <div v-for="(item,index) in templateList" :key="index" @click="cardClick(index)">
  122. <el-card :class="`box-card ${templateIndex == index ? 'cardOn' : ''}`">
  123. <div class="text item">
  124. <div>{{ item.name }}</div>
  125. <div>
  126. <el-link :underline="false" @click="editTemplate(item)"><i class="el-icon-edit"></i></el-link>
  127. <el-link :underline="false" @click="removeTemplate(item)"><i class="el-icon-delete" style="margin-left: 10px"></i></el-link>
  128. <div class="cardIcon">
  129. <i class="el-icon-check" v-if="templateIndex == index"></i>
  130. </div>
  131. </div>
  132. </div>
  133. </el-card>
  134. </div>
  135. </el-tab-pane> -->
  136. </el-tabs>
  137. <el-form ref="form2" :model="folderForm" :rules="rules" v-if="addFolderDialogTwo">
  138. <el-form-item prop="documentName">
  139. <el-input v-model="folderForm.documentName" :placeholder="$t('pleaseenterfoldername')" maxlength="25"
  140. show-word-limit clearable></el-input>
  141. </el-form-item>
  142. <el-form-item >
  143. <el-checkbox v-model="folderForm.syncChange">同步修改其他项目中的同名文件夹</el-checkbox>
  144. </el-form-item>
  145. </el-form>
  146. </div>
  147. <div slot="footer" class="dialog-footer">
  148. <el-button v-if="activeName == 'one'" type="primary" @click="addFolder" style="width:100%;" >{{ $t('save') }}</el-button>
  149. <el-button v-if="activeName == 'two'" type="primary" @click="addFolderTemplate" style="width:100%;" >{{ $t('save') }}</el-button>
  150. </div>
  151. </el-dialog>
  152. <!-- 设为模板 -->
  153. <el-dialog :title="'编辑模板'" v-if="templatedialing" :visible.sync="templatedialing" :close-on-click-modal="false" customClass="customWidth" width="500px">
  154. <div>
  155. <el-form :model="templateForm" ref="templateForm" label-width="80px">
  156. <el-form-item label="模板名称" prop="name" :rules="[
  157. { required: true, message: '请输入模板名称'}
  158. ]">
  159. <el-input v-model="templateForm.name" :placeholder="'请输入模板名称'" maxlength="25" show-word-limit clearable ></el-input>
  160. </el-form-item>
  161. <el-form-item>
  162. <el-checkbox v-model="templateForm.creWithPro">随项目自动创建</el-checkbox>
  163. </el-form-item>
  164. </el-form>
  165. <div class="fileCenter">文件中心结构</div>
  166. <div class="filrTree">
  167. <el-tree
  168. :data="templateDataTree"
  169. node-key="id"
  170. default-expand-all
  171. :expand-on-click-node="false">
  172. <span class="custom-tree-node tree_node" slot-scope="{ node, data }">
  173. <span>{{ node.label }}</span>
  174. <span class="tree_node_btn">
  175. <i class="el-icon-circle-plus-outline" @click="addtemplateNodeDailoing = true, excessiveNodeData = data, nodeForm.name = ''"></i>
  176. <i class="el-icon-delete" style="margin-left: 20px" @click="removeNode(node, data)"></i>
  177. </span>
  178. </span>
  179. </el-tree>
  180. </div>
  181. </div>
  182. <div slot="footer" class="dialog-footer">
  183. <!-- <el-button v-if="templateFlg" type="primary" style="width:100%;" :loading="templateDataTreeDaylong" @click="addTemplate('templateForm')">{{ $t('save') }}</el-button>
  184. <el-button v-if="!templateFlg" type="primary" style="width:100%;" :loading="templateDataTreeDaylong" @click="uploadTemplate('templateForm')">{{ $t('save') }}</el-button> -->
  185. <el-button type="primary" style="width:100%;" :loading="templateDataTreeDaylong" @click="addTemplate('templateForm')">{{ $t('save') }}</el-button>
  186. </div>
  187. </el-dialog>
  188. <!-- 添加子节点 -->
  189. <el-dialog :title="'新增节点'" v-if="addtemplateNodeDailoing" :visible.sync="addtemplateNodeDailoing" :close-on-click-modal="false" customClass="customWidth" width="500px">
  190. <div>
  191. <el-form :model="nodeForm" ref="nodeForm" label-width="100px" class="demo-ruleForm">
  192. <el-form-item label="节点名称" prop="name"
  193. :rules="[
  194. { required: true, message: '请输入节点名称'}
  195. ]"
  196. >
  197. <el-input v-model="nodeForm.name"></el-input>
  198. </el-form-item>
  199. </el-form>
  200. </div>
  201. <div slot="footer" class="dialog-footer">
  202. <el-button type="primary" style="width:100%;" @click="addtemplateNode('nodeForm')">确定</el-button>
  203. </div>
  204. </el-dialog>
  205. </div>
  206. </section>
  207. </template>
  208. <style scoped>
  209. .fileTypeIcon {
  210. color:#20a0ff;font-size:20px;
  211. }
  212. .mianbaoxie {
  213. color: #909399;
  214. }
  215. .mianbaoxie:hover {
  216. color: #409EFF;
  217. cursor: pointer;
  218. }
  219. .mianbaoxie:hover .jianto {
  220. color: #909399;
  221. }
  222. .custom-tree-node {
  223. flex: 1;
  224. display: flex;
  225. align-items: center;
  226. justify-content: space-between;
  227. font-size: 14px;
  228. padding-right: 8px;
  229. }
  230. .fileCenter {
  231. margin-bottom: 10px;
  232. }
  233. .filrTree {
  234. width: 100%;
  235. max-height: 280px;
  236. overflow: auto;
  237. margin-bottom: 10px;
  238. }
  239. .titleBox {
  240. width: 100%;
  241. max-height: 340px;
  242. overflow: auto;
  243. margin-bottom: 10px;
  244. padding: 0 10px;
  245. box-sizing: border-box;
  246. }
  247. .text {
  248. font-size: 14px;
  249. }
  250. .item {
  251. margin-bottom: 10px;
  252. display: flex;
  253. justify-content: space-between;
  254. }
  255. .clearfix:before,
  256. .clearfix:after {
  257. display: table;
  258. content: "";
  259. }
  260. .clearfix:after {
  261. clear: both
  262. }
  263. .box-card {
  264. width: 100%;
  265. box-sizing: border-box;
  266. margin: 10px 0;
  267. }
  268. .cardOn {
  269. border: 1px solid #409EFF;
  270. }
  271. .cardIcon {
  272. display: inline-block;
  273. margin-left: 10px;
  274. width: 20px;
  275. color: #409EFF;
  276. font-size: 16px;
  277. font-weight: bold;
  278. }
  279. </style>
  280. <script>
  281. import util from "../../common/js/util";
  282. export default {
  283. data() {
  284. return {
  285. pathList:[],
  286. currentDataId: null,
  287. docTypeList:["iconfont firerock-iconJPG","iconfont firerock-iconword","iconfont firerock-icontxt"
  288. ,"iconfont firerock-iconex","iconfont firerock-iconZip","iconfont firerock-iconvideo"
  289. ,"iconfont firerock-iconaudio","iconfont firerock-iconPDF"],
  290. rules: {
  291. documentName: [{ required: true, message: this.$t('pleaseenterfoldername'), trigger: "blur" }],
  292. },
  293. folderForm:{},
  294. addFolderDialog: false,
  295. moveToTrashDialog:false,
  296. list:[],
  297. parentFid:null,
  298. upLoading:false,
  299. keyword:null,
  300. user: JSON.parse(sessionStorage.getItem("user")),
  301. recentFiles: [],
  302. addFormVisible: false,
  303. addLoading: false,
  304. curProjectId:null,
  305. title: "",
  306. addForm: {
  307. },
  308. templateTitle: '',
  309. templatedialing: false,
  310. templateForm: {
  311. name: ''
  312. },
  313. templateDataTree: [],
  314. addtemplateNodeDailoing: false,
  315. nodeForm: {
  316. name: ''
  317. },
  318. excessiveNodeData: null,
  319. templateDataTreeDaylong: false,
  320. activeName: 'one',
  321. templateList: [],
  322. templateFlg: false,
  323. templateIndex: '0',
  324. addFolderDialogTwo: false
  325. };
  326. },
  327. methods: {
  328. addFolderTemplate() {
  329. let obj = {
  330. templateId: this.templateList[this.templateIndex].id,
  331. projectId: this.curProjectId,
  332. }
  333. this.parentFid ? obj.parentFid = this.parentFid : ''
  334. console.log('obj', obj)
  335. // return
  336. this.http.post('/document/buildWithTemplate', obj,
  337. res => {
  338. if (res.code == "ok") {
  339. this.addFolderDialog = false
  340. this.getList()
  341. } else {
  342. this.$message({message: res.msg,type: 'error'});
  343. }
  344. }, error => {
  345. this.$message({message: error,type: 'error'});
  346. })
  347. },
  348. cardClick(index) {
  349. this.templateIndex = index
  350. },
  351. editTemplate(data) {
  352. this.templateForm.name = data.name
  353. this.templateForm.creWithPro = data.creWithPro ? true : false
  354. this.templateForm.id = data.id
  355. this.templateDataTree = data.proDocumentTemDetailList
  356. this.templateFlg = false
  357. this.templatedialing = true
  358. },
  359. removeTemplate(data) {
  360. this.$confirm(`确定删除【${data.name}】模板吗?`, '提示', {
  361. confirmButtonText: '确定',
  362. cancelButtonText: '取消',
  363. type: 'warning'
  364. }).then(() => {
  365. this.http.post('/project-document-template/delete', {id: data.id},
  366. res => {
  367. if (res.code == "ok") {
  368. this.$message({
  369. message: `删除成功`,
  370. type: 'success'
  371. });
  372. this.getTemplateList()
  373. } else {
  374. this.$message({message: res.msg,type: 'error'});
  375. }
  376. }, error => {
  377. this.$message({message: error,type: 'error'});
  378. })
  379. }).catch(() => {});
  380. },
  381. uploadTemplate(formName) {
  382. this.$refs[formName].validate((valid) => {
  383. if (valid) {
  384. this.templateDataTreeDaylong = true
  385. this.http.post('/project-document-template/update', {
  386. proDocumentTemDetailList: JSON.stringify(this.templateDataTree),
  387. name: this.templateForm.name,
  388. creWithPro: this.templateForm.creWithPro ? '1' : '0',
  389. id: this.templateForm.id,
  390. companyId: this.user.companyId
  391. },
  392. res => {
  393. this.templateDataTreeDaylong = false
  394. if (res.code == "ok") {
  395. this.$message({
  396. message: `操作成功`,
  397. type: 'success'
  398. });
  399. } else {this.$message({message: res.msg,type: 'error'});}
  400. }, error => {
  401. this.templateDataTreeDaylong = false
  402. this.$message({message: error,type: 'error'});
  403. })
  404. } else {
  405. console.log('error submit!!');
  406. return false;
  407. }
  408. });
  409. },
  410. addTemplate(formName) {
  411. this.$refs[formName].validate((valid) => {
  412. if (valid) {
  413. let obj = {}
  414. if(this.templateFlg) {
  415. obj = {
  416. documentString: JSON.stringify(this.templateDataTree),
  417. name: this.templateForm.name,
  418. creWithPro: this.templateForm.creWithPro ? '1' : '0',
  419. companyId: this.user.companyId
  420. }
  421. } else {
  422. obj = {
  423. documentString: JSON.stringify(this.templateDataTree),
  424. name: this.templateForm.name,
  425. creWithPro: this.templateForm.creWithPro ? '1' : '0',
  426. id: this.templateForm.id,
  427. companyId: this.user.companyId
  428. }
  429. }
  430. this.templateDataTreeDaylong = true
  431. // this.http.post('/project-document-template/addTemplate', {
  432. this.http.post('/project-document-template/addTemplate', obj,
  433. res => {
  434. this.templateDataTreeDaylong = false
  435. if (res.code == "ok") {
  436. this.$message({
  437. message: `(${this.templateForm.name}) 模板添加成功,可在创建文件夹中查看`,
  438. type: 'success'
  439. });
  440. this.templatedialing = false
  441. } else {
  442. this.$message({
  443. message: res.msg,
  444. type: 'error'
  445. });
  446. }
  447. }, error => {
  448. this.templateDataTreeDaylong = false
  449. this.$message({
  450. message: error,
  451. type: 'error'
  452. });
  453. })
  454. } else {
  455. console.log('error submit!!');
  456. return false;
  457. }
  458. });
  459. },
  460. addtemplateNode(formName) {
  461. this.$refs[formName].validate((valid) => {
  462. if (valid) {
  463. console.log('excessiveNodeData',this.excessiveNodeData)
  464. let data = this.excessiveNodeData
  465. const newChild = { label: this.nodeForm.name, children: [], folderId: this.excessiveNodeData.id || ''};
  466. if (!data.children) {
  467. this.$set(data, 'children', []);
  468. }
  469. data.children.push(newChild);
  470. this.addtemplateNodeDailoing = false
  471. } else {
  472. console.log('error submit!!');
  473. return false;
  474. }
  475. });
  476. },
  477. removeNode(node, data) {
  478. this.$confirm(`确定删除(${data.label})节点?`, '提示', {
  479. confirmButtonText: '确定',
  480. cancelButtonText: '取消',
  481. type: 'warning'
  482. }).then(() => {
  483. const parent = node.parent;
  484. const children = parent.data.children || parent.data;
  485. const index = children.findIndex(d => d.id === data.id);
  486. children.splice(index, 1);
  487. }).catch(() => {});
  488. },
  489. templatedialingClick(title) {
  490. this.templateTitle = title
  491. this.templateForm = {name: ''}
  492. this.templatedialing = true
  493. this.templateFlg = true
  494. this.getTemplateDataTree()
  495. },
  496. getTemplateDataTree() {
  497. this.http.post('/document/getSubList', {
  498. projectId: this.curProjectId,
  499. parentFid: this.parentFid
  500. },
  501. res => {
  502. if (res.code == "ok") {
  503. this.templateDataTree = []
  504. this.templateDataTree = res.data
  505. } else {
  506. this.$message({
  507. message: res.msg,
  508. type: 'error'
  509. });
  510. }
  511. }, error => {
  512. this.$message({
  513. message: error,
  514. type: 'error'
  515. });
  516. })
  517. },
  518. cursorOver(row, column, cell, event) {
  519. this.currentDataId = row.id;
  520. },
  521. viewOnline(row) {
  522. this.http.post('/pdf-file/getProjectFile', {fileId: row.id},
  523. res => {
  524. if (res.code == "ok") {
  525. console.log(res.data+'----'+row.documentName);
  526. let routeUrl = this.$router.resolve({
  527. path: "/viewonline",
  528. params: {serverFname:res.data, fileName:row.documentName}
  529. });
  530. sessionStorage.setItem("serverFname",res.data);
  531. sessionStorage.setItem("fileName",row.documentName);
  532. console.log(routeUrl.href);
  533. window.open(routeUrl.href, '_blank');
  534. } else {
  535. this.$message({
  536. message: res.msg,
  537. type: 'error'
  538. });
  539. }
  540. }, error => {
  541. this.$message({
  542. message: error,
  543. type: 'error'
  544. });
  545. })
  546. },
  547. deleteItem(row) {
  548. this.$confirm(this.$t('wanttomove'), this.$t('other.prompts'), {
  549. //type: 'warning'
  550. }).then(() => {
  551. this.http.post('/document/delete', row,
  552. res => {
  553. if (res.code == "ok") {
  554. this.addFolderDialog = false;
  555. this.getRecentList();
  556. this.getList();
  557. } else {
  558. this.$message({
  559. message: res.msg,
  560. type: "error"
  561. });
  562. }
  563. },
  564. error => {
  565. this.$message({
  566. message: error,
  567. type: "error"
  568. });
  569. });
  570. });
  571. },
  572. viewFolder(item) {
  573. var list = [];
  574. if (item == null) {
  575. //查看根目录
  576. this.parentFid = null;
  577. } else {
  578. this.parentFid = item.id;
  579. for (var i=0;i<this.pathList.length; i++) {
  580. list.push(this.pathList[i]);
  581. if (this.pathList[i].id == item.id) {
  582. break;
  583. }
  584. }
  585. }
  586. console.log('list=view folder==='+list);
  587. this.pathList = list;
  588. this.getList();
  589. },
  590. clearPathList() {
  591. console.log('111')
  592. this.pathList = []
  593. this.viewFolder(null)
  594. },
  595. rowClick(row, column, event) {
  596. if (row.isFolder==1) {
  597. //进入子目录
  598. this.parentFid = row.id;
  599. this.pathList.push(row);
  600. this.getList();
  601. } else {
  602. //直接查看,在线打开
  603. }
  604. },
  605. addFolder() {
  606. this.$refs.form2.validate(valid => {
  607. if (valid) {
  608. this.http.post('/document/createDocument', this.folderForm,
  609. res => {
  610. if (res.code == "ok") {
  611. this.addFolderDialog = false;
  612. this.getRecentList();
  613. this.getList();
  614. } else {
  615. this.$message({
  616. message: res.msg,
  617. type: "error"
  618. });
  619. }
  620. },
  621. error => {
  622. this.$message({
  623. message: error,
  624. type: "error"
  625. });
  626. });
  627. }
  628. });
  629. },
  630. showEditName(row) {
  631. this.addFolderDialog = true;
  632. this.addFolderDialogTwo = true
  633. this.folderForm = JSON.parse(JSON.stringify(row));
  634. },
  635. createFolder(){
  636. this.addFolderDialog = true;
  637. this.addFolderDialogTwo = false
  638. this.folderForm = {projectId: this.curProjectId, folderId: this.parentFid,isFolder: 1};
  639. this.activeName = 'one'
  640. this.getTemplateList()
  641. },
  642. getTemplateList() {
  643. this.http.post('/project-document-template/list ', {},
  644. res => {
  645. if (res.code == "ok") {
  646. this.templateList = res.data
  647. } else {
  648. this.$message({message: res.msg,type: 'error'});
  649. }
  650. }, error => {
  651. this.$message({message: error,type: 'error'});
  652. })
  653. },
  654. openWin(url) {
  655. var el = document.createElement("a");
  656. document.body.appendChild(el);
  657. el.href = encodeURI(url);
  658. el.target = '_blank';
  659. el.click();
  660. document.body.removeChild(el);
  661. },
  662. downloadByA(row) {
  663. const a = document.createElement('a'); // 创建a标签
  664. a.setAttribute('download', row.documentName);// download属性
  665. a.setAttribute('href', row.url);// href链接
  666. a.click();// 自执行点击事件
  667. a.remove();
  668. },
  669. //上传
  670. uploadFile(params) {
  671. this.upLoading = true;
  672. var fileObj = params.file;
  673. var form = new FormData();
  674. form.append("projectId",this.curProjectId);
  675. form.append("file", fileObj);
  676. if (this.parentFid != null) {
  677. form.append("folderId", this.parentFid);
  678. }
  679. this.http.uploadFile('/document/uploadDocument', form , res => {
  680. this.upLoading = false;
  681. this.$refs.upload.clearFiles();
  682. if (res.code == "ok") {
  683. this.$message({
  684. message: this.$t('uploadedsuccessfully'),
  685. type: 'success'
  686. });
  687. this.getList();
  688. this.getRecentList();
  689. } else {
  690. this.$message({
  691. message: res.msg,
  692. type: 'error'
  693. });
  694. }
  695. }, error => {
  696. this.upLoading = false;
  697. this.$refs.upload.clearFiles();
  698. this.$message({
  699. message: error,
  700. type: 'error'
  701. });
  702. })
  703. },
  704. //下载
  705. dowloadFile(row) {
  706. this.http.post(this.port.project.dowloadFile, {
  707. id: row.id
  708. } , res => {
  709. this.getOperList();
  710. }, error => {
  711. })
  712. },
  713. //获取近期文件
  714. getRecentList() {
  715. this.http.post('/document/recentlyList', {
  716. projectId: this.curProjectId,
  717. },
  718. res => {
  719. if (res.code == "ok") {
  720. this.recentFiles = res.data;
  721. } else {
  722. this.$message({
  723. message: res.msg,
  724. type: "error"
  725. });
  726. }
  727. },
  728. error => {
  729. this.$message({
  730. message: error,
  731. type: "error"
  732. });
  733. });
  734. },
  735. getUsers() {
  736. // this.http.post(this.port.manage.list, {
  737. // departmentId: -1,
  738. // pageIndex: 1,
  739. // // pageSize: 99999
  740. // pageSize: -1
  741. // },
  742. this.http.post('/user/getSimpleActiveUserList', {},
  743. res => {
  744. if (res.code == "ok") {
  745. this.users = res.data;
  746. } else {
  747. this.$message({
  748. message: res.msg,
  749. type: "error"
  750. });
  751. }
  752. },
  753. error => {
  754. this.$message({
  755. message: error,
  756. type: "error"
  757. });
  758. });
  759. },
  760. //获取列表
  761. getList() {
  762. this.listLoading = true;
  763. this.http.post('/document/allList', {
  764. projectId: this.curProjectId,
  765. parentFid: this.parentFid
  766. },
  767. res => {
  768. this.listLoading = false;
  769. if (res.code == "ok") {
  770. this.list = res.data;
  771. this.$forceUpdate();
  772. } else {
  773. this.$message({
  774. message: res.msg,
  775. type: "error"
  776. });
  777. }
  778. },
  779. error => {
  780. this.listLoading = false;
  781. this.$message({
  782. message: error,
  783. type: "error"
  784. });
  785. });
  786. },
  787. refreshPage() {
  788. this.curProjectId = parseInt(this.$route.params.id);
  789. this.getRecentList();
  790. this.clearPathList();
  791. }
  792. },
  793. created() {
  794. console.log('created===');
  795. let height = window.innerHeight;
  796. this.tableHeight = height - 190;
  797. const that = this;
  798. window.onresize = function temp() {
  799. that.tableHeight = window.innerHeight - 190;
  800. };
  801. },
  802. mounted() {
  803. console.log('mounted===');
  804. this.curProjectId = parseInt(this.$route.params.id);
  805. this.getRecentList();
  806. this.getList();
  807. this.getUsers();
  808. }
  809. };
  810. </script>