fileCenter.vue 39 KB

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