fileCenter.vue 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907
  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)" class="themeFontColor" style="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 lang="scss">
  234. @import "../../assets/scss/handle";
  235. .themeFontColor {
  236. @include font_color("color");
  237. }
  238. .fileTypeIcon {
  239. @include font_color("color");
  240. font-size:20px;
  241. }
  242. .mianbaoxie {
  243. color: #909399;
  244. }
  245. .mianbaoxie:hover {
  246. @include font_color("color");
  247. cursor: pointer;
  248. }
  249. .mianbaoxie:hover .jianto {
  250. color: #909399;
  251. }
  252. .custom-tree-node {
  253. flex: 1;
  254. display: flex;
  255. align-items: center;
  256. justify-content: space-between;
  257. font-size: 14px;
  258. padding-right: 8px;
  259. }
  260. .fileCenter {
  261. margin-bottom: 10px;
  262. }
  263. .filrTree {
  264. width: 100%;
  265. max-height: 280px;
  266. overflow: auto;
  267. margin-bottom: 10px;
  268. }
  269. .titleBox {
  270. width: 100%;
  271. max-height: 340px;
  272. overflow: auto;
  273. margin-bottom: 10px;
  274. padding: 0 10px;
  275. box-sizing: border-box;
  276. }
  277. .text {
  278. font-size: 14px;
  279. }
  280. .item {
  281. margin-bottom: 10px;
  282. display: flex;
  283. justify-content: space-between;
  284. }
  285. .clearfix:before,
  286. .clearfix:after {
  287. display: table;
  288. content: "";
  289. }
  290. .clearfix:after {
  291. clear: both
  292. }
  293. .box-card {
  294. width: 100%;
  295. box-sizing: border-box;
  296. margin: 10px 0;
  297. }
  298. .cardOn {
  299. border: 1px solid;
  300. @include border_color("border_color");
  301. }
  302. .cardIcon {
  303. display: inline-block;
  304. margin-left: 10px;
  305. width: 20px;
  306. @include font_color("color");
  307. font-size: 16px;
  308. font-weight: bold;
  309. }
  310. .treeAdd {
  311. padding: 0 10px;
  312. font-size: 20px;
  313. }
  314. </style>
  315. <script>
  316. import util from "../../common/js/util";
  317. export default {
  318. data() {
  319. return {
  320. pathList:[],
  321. currentDataId: null,
  322. docTypeList:["iconfont firerock-iconJPG","iconfont firerock-iconword","iconfont firerock-icontxt"
  323. ,"iconfont firerock-iconex","iconfont firerock-iconZip","iconfont firerock-iconvideo"
  324. ,"iconfont firerock-iconaudio","iconfont firerock-iconPDF"],
  325. rules: {
  326. documentName: [{ required: true, message: this.$t('pleaseenterfoldername'), trigger: "blur" }],
  327. },
  328. folderForm:{},
  329. addFolderDialog: false,
  330. moveToTrashDialog:false,
  331. list:[],
  332. parentFid:null,
  333. upLoading:false,
  334. keyword:null,
  335. user: JSON.parse(sessionStorage.getItem("user")),
  336. permissions: JSON.parse(sessionStorage.getItem("permissions")),
  337. recentFiles: [],
  338. addFormVisible: false,
  339. addLoading: false,
  340. curProjectId:null,
  341. title: "",
  342. addForm: {
  343. },
  344. templateTitle: '',
  345. templatedialing: false,
  346. templateForm: {
  347. name: ''
  348. },
  349. templateDataTree: [],
  350. addtemplateNodeDailoing: false,
  351. nodeForm: {
  352. name: ''
  353. },
  354. excessiveNodeData: null,
  355. templateDataTreeDaylong: false,
  356. activeName: 'one',
  357. templateList: [],
  358. templateFlg: false,
  359. templateIndex: '0',
  360. addFolderDialogTwo: false,
  361. addtemplateTwoNodeDailoing: false,
  362. addtemplateNodeNameDailoing: false
  363. };
  364. },
  365. methods: {
  366. addFolderTemplate() {
  367. let obj = {
  368. templateId: this.templateList[this.templateIndex].id,
  369. projectId: this.curProjectId,
  370. }
  371. this.parentFid ? obj.parentFid = this.parentFid : ''
  372. console.log('obj', obj)
  373. // return
  374. this.http.post('/document/buildWithTemplate', obj,
  375. res => {
  376. if (res.code == "ok") {
  377. this.addFolderDialog = false
  378. this.getList()
  379. } else {
  380. this.$message({message: res.msg,type: 'error'});
  381. }
  382. }, error => {
  383. this.$message({message: error,type: 'error'});
  384. })
  385. },
  386. cardClick(index) {
  387. this.templateIndex = index
  388. },
  389. editTemplate(data) {
  390. console.log('触发')
  391. // this.templateForm.name = data.name
  392. // this.templateForm.creWithPro = data.creWithPro ? true : false
  393. this.templateForm.id = data.id
  394. this.templateDataTree = data.proDocumentTemDetailList
  395. // this.templateFlg = false
  396. this.templatedialing = true
  397. },
  398. newNode(data) {
  399. if(data) {
  400. this.excessiveNodeData = data
  401. this.addtemplateNodeDailoing = true
  402. } else {
  403. this.addtemplateTwoNodeDailoing = true
  404. }
  405. this.nodeForm.name = ''
  406. },
  407. editNode(data) {
  408. this.excessiveNodeData = data
  409. this.addtemplateNodeNameDailoing = true
  410. this.nodeForm.name = data.label
  411. },
  412. removeTemplate(data) {
  413. this.$confirm(`${this.$t('queDingShanChu')}【${data.name}】${this.$t('moBanMa')}?`, this.$t('other.prompts'), {
  414. confirmButtonText: this.$t('btn.determine'),
  415. cancelButtonText: this.$t('btn.cancel'),
  416. type: 'warning'
  417. }).then(() => {
  418. this.http.post('/project-document-template/delete', {id: data.id},
  419. res => {
  420. if (res.code == "ok") {
  421. this.$message({
  422. message: this.$t('message.successfullyDeleted'),
  423. type: 'success'
  424. });
  425. this.getTemplateList()
  426. } else {
  427. this.$message({message: res.msg,type: 'error'});
  428. }
  429. }, error => {
  430. this.$message({message: error,type: 'error'});
  431. })
  432. }).catch(() => {});
  433. },
  434. uploadTemplate(formName) {
  435. this.$refs[formName].validate((valid) => {
  436. if (valid) {
  437. this.templateDataTreeDaylong = true
  438. this.http.post('/project-document-template/update', {
  439. proDocumentTemDetailList: JSON.stringify(this.templateDataTree),
  440. name: this.templateForm.name,
  441. creWithPro: this.templateForm.creWithPro ? '1' : '0',
  442. id: this.templateForm.id,
  443. companyId: this.user.companyId
  444. },
  445. res => {
  446. this.templateDataTreeDaylong = false
  447. if (res.code == "ok") {
  448. this.$message({
  449. message: this.$t('operationissuccessful'),
  450. type: 'success'
  451. });
  452. } else {this.$message({message: res.msg,type: 'error'});}
  453. }, error => {
  454. this.templateDataTreeDaylong = false
  455. this.$message({message: error,type: 'error'});
  456. })
  457. } else {
  458. console.log('error submit!!');
  459. return false;
  460. }
  461. });
  462. },
  463. addTemplate() {
  464. let obj = {}
  465. if(this.templateFlg) {
  466. obj = {
  467. documentString: JSON.stringify(this.templateDataTree),
  468. companyId: this.user.companyId
  469. }
  470. } else {
  471. obj = {
  472. documentString: JSON.stringify(this.templateDataTree),
  473. id: this.templateForm.id,
  474. companyId: this.user.companyId
  475. }
  476. }
  477. this.templateDataTreeDaylong = true
  478. this.http.post('/project-document-template/addTemplate', obj,
  479. res => {
  480. this.templateDataTreeDaylong = false
  481. if (res.code == "ok") {
  482. this.$message({
  483. message: this.$t('operationissuccessful'),
  484. type: 'success'
  485. });
  486. this.templatedialing = false
  487. } else {
  488. this.$message({
  489. message: res.msg,
  490. type: 'error'
  491. });
  492. }
  493. }, error => {
  494. this.templateDataTreeDaylong = false
  495. this.$message({
  496. message: error,
  497. type: 'error'
  498. });
  499. })
  500. },
  501. addtemplateNode(formName) {
  502. this.$refs[formName].validate((valid) => {
  503. if (valid) {
  504. console.log('excessiveNodeData',this.excessiveNodeData)
  505. let data = this.excessiveNodeData
  506. const newChild = { label: this.nodeForm.name, children: [], folderId: this.excessiveNodeData.id || ''};
  507. if (!data.children) {
  508. this.$set(data, 'children', []);
  509. }
  510. data.children.push(newChild);
  511. this.addtemplateNodeDailoing = false
  512. } else {
  513. console.log('error submit!!');
  514. return false;
  515. }
  516. });
  517. },
  518. addtemplateTwoNode(formName) {
  519. this.$refs[formName].validate((valid) => {
  520. if (valid) {
  521. let obj = {
  522. children: [],
  523. id: new Date().getTime()/ 1000,
  524. label: this.nodeForm.name
  525. }
  526. this.templateDataTree.push(obj)
  527. this.addtemplateTwoNodeDailoing = false
  528. } else {
  529. console.log('error submit!!');
  530. return false;
  531. }
  532. });
  533. },
  534. editTemplateNodeName(formName) {
  535. this.$refs[formName].validate((valid) => {
  536. if (valid) {
  537. console.log('excessiveNodeData',this.excessiveNodeData)
  538. let data = this.excessiveNodeData
  539. data.label = this.nodeForm.name
  540. data.name = this.nodeForm.name
  541. this.addtemplateNodeNameDailoing = false
  542. } else {
  543. console.log('error submit!!');
  544. return false;
  545. }
  546. });
  547. },
  548. removeNode(node, data) {
  549. this.$confirm(`${this.$t('queDingShanChu')}(${data.label})${this.$t('jieDian')}?`, this.$t('other.prompts'), {
  550. confirmButtonText: this.$t('btn.determine'),
  551. cancelButtonText: this.$t('btn.cancel'),
  552. type: 'warning'
  553. }).then(() => {
  554. const parent = node.parent;
  555. const children = parent.data.children || parent.data;
  556. const index = children.findIndex(d => d.id === data.id);
  557. children.splice(index, 1);
  558. }).catch(() => {});
  559. },
  560. templatedialingClick(title) {
  561. this.templateTitle = title
  562. this.templateForm = {name: ''}
  563. this.templatedialing = true
  564. this.templateFlg = true
  565. this.getTemplateDataTree()
  566. },
  567. getTemplateDataTree() {
  568. this.http.post('/document/getSubList', {
  569. projectId: this.curProjectId,
  570. parentFid: this.parentFid
  571. },
  572. res => {
  573. if (res.code == "ok") {
  574. this.templateDataTree = []
  575. this.templateDataTree = res.data
  576. } else {
  577. this.$message({
  578. message: res.msg,
  579. type: 'error'
  580. });
  581. }
  582. }, error => {
  583. this.$message({
  584. message: error,
  585. type: 'error'
  586. });
  587. })
  588. },
  589. cursorOver(row, column, cell, event) {
  590. this.currentDataId = row.id;
  591. },
  592. viewOnline(row) {
  593. this.http.post('/pdf-file/getProjectFile', {fileId: row.id},
  594. res => {
  595. if (res.code == "ok") {
  596. console.log(res.data+'----'+row.documentName);
  597. let routeUrl = this.$router.resolve({
  598. path: "/viewonline",
  599. params: {serverFname:res.data, fileName:row.documentName}
  600. });
  601. sessionStorage.setItem("serverFname",res.data);
  602. sessionStorage.setItem("fileName",row.documentName);
  603. console.log(routeUrl.href);
  604. window.open(routeUrl.href, '_blank');
  605. } else {
  606. this.$message({
  607. message: res.msg,
  608. type: 'error'
  609. });
  610. }
  611. }, error => {
  612. this.$message({
  613. message: error,
  614. type: 'error'
  615. });
  616. })
  617. },
  618. deleteItem(row) {
  619. this.$confirm(this.$t('wanttomove'), this.$t('other.prompts'), {
  620. //type: 'warning'
  621. }).then(() => {
  622. this.http.post('/document/delete', row,
  623. res => {
  624. if (res.code == "ok") {
  625. this.addFolderDialog = false;
  626. this.getRecentList();
  627. this.getList();
  628. } else {
  629. this.$message({
  630. message: res.msg,
  631. type: "error"
  632. });
  633. }
  634. },
  635. error => {
  636. this.$message({
  637. message: error,
  638. type: "error"
  639. });
  640. });
  641. });
  642. },
  643. viewFolder(item) {
  644. var list = [];
  645. if (item == null) {
  646. //查看根目录
  647. this.parentFid = null;
  648. } else {
  649. this.parentFid = item.id;
  650. for (var i=0;i<this.pathList.length; i++) {
  651. list.push(this.pathList[i]);
  652. if (this.pathList[i].id == item.id) {
  653. break;
  654. }
  655. }
  656. }
  657. console.log('list=view folder==='+list);
  658. this.pathList = list;
  659. this.getList();
  660. },
  661. clearPathList() {
  662. console.log('111')
  663. this.pathList = []
  664. this.viewFolder(null)
  665. },
  666. rowClick(row, column, event) {
  667. if (row.isFolder==1) {
  668. //进入子目录
  669. this.parentFid = row.id;
  670. this.pathList.push(row);
  671. this.getList();
  672. } else {
  673. //直接查看,在线打开
  674. }
  675. },
  676. addFolder() {
  677. this.$refs.form2.validate(valid => {
  678. if (valid) {
  679. this.http.post('/document/createDocument', this.folderForm,
  680. res => {
  681. if (res.code == "ok") {
  682. this.addFolderDialog = false;
  683. this.getRecentList();
  684. this.getList();
  685. } else {
  686. this.$message({
  687. message: res.msg,
  688. type: "error"
  689. });
  690. }
  691. },
  692. error => {
  693. this.$message({
  694. message: error,
  695. type: "error"
  696. });
  697. });
  698. }
  699. });
  700. },
  701. showEditName(row) {
  702. this.addFolderDialog = true;
  703. this.addFolderDialogTwo = true
  704. this.folderForm = JSON.parse(JSON.stringify(row));
  705. },
  706. createFolder(){
  707. this.addFolderDialog = true;
  708. this.addFolderDialogTwo = false
  709. this.folderForm = {projectId: this.curProjectId, folderId: this.parentFid,isFolder: 1};
  710. this.activeName = 'one'
  711. // this.getTemplateList()
  712. },
  713. defaultTemplate() {
  714. this.getTemplateList()
  715. },
  716. getTemplateList() {
  717. this.http.post('/project-document-template/list ', {},
  718. res => {
  719. if (res.code == "ok") {
  720. this.templateList = res.data
  721. this.editTemplate(res.data[0])
  722. } else {
  723. this.$message({message: res.msg,type: 'error'});
  724. }
  725. }, error => {
  726. this.$message({message: error,type: 'error'});
  727. })
  728. },
  729. openWin(url) {
  730. var el = document.createElement("a");
  731. document.body.appendChild(el);
  732. el.href = encodeURI(url);
  733. el.target = '_blank';
  734. el.click();
  735. document.body.removeChild(el);
  736. },
  737. downloadByA(row) {
  738. const a = document.createElement('a'); // 创建a标签
  739. a.setAttribute('download', row.documentName);// download属性
  740. a.setAttribute('href', row.url);// href链接
  741. a.click();// 自执行点击事件
  742. a.remove();
  743. },
  744. //上传
  745. uploadFile(params) {
  746. this.upLoading = true;
  747. var fileObj = params.file;
  748. var form = new FormData();
  749. form.append("projectId",this.curProjectId);
  750. form.append("file", fileObj);
  751. if (this.parentFid != null) {
  752. form.append("folderId", this.parentFid);
  753. }
  754. this.http.uploadFile('/document/uploadDocument', form , res => {
  755. this.upLoading = false;
  756. this.$refs.upload.clearFiles();
  757. if (res.code == "ok") {
  758. this.$message({
  759. message: this.$t('uploadedsuccessfully'),
  760. type: 'success'
  761. });
  762. this.getList();
  763. this.getRecentList();
  764. } else {
  765. this.$message({
  766. message: res.msg,
  767. type: 'error'
  768. });
  769. }
  770. }, error => {
  771. this.upLoading = false;
  772. this.$refs.upload.clearFiles();
  773. this.$message({
  774. message: error,
  775. type: 'error'
  776. });
  777. })
  778. },
  779. //下载
  780. dowloadFile(row) {
  781. this.http.post(this.port.project.dowloadFile, {
  782. id: row.id
  783. } , res => {
  784. this.getOperList();
  785. }, error => {
  786. })
  787. },
  788. //获取近期文件
  789. getRecentList() {
  790. this.http.post('/document/recentlyList', {
  791. projectId: this.curProjectId,
  792. },
  793. res => {
  794. if (res.code == "ok") {
  795. this.recentFiles = res.data;
  796. } else {
  797. this.$message({
  798. message: res.msg,
  799. type: "error"
  800. });
  801. }
  802. },
  803. error => {
  804. this.$message({
  805. message: error,
  806. type: "error"
  807. });
  808. });
  809. },
  810. getUsers() {
  811. // this.http.post(this.port.manage.list, {
  812. // departmentId: -1,
  813. // pageIndex: 1,
  814. // // pageSize: 99999
  815. // pageSize: -1
  816. // },
  817. this.http.post('/user/getSimpleActiveUserList', {},
  818. res => {
  819. if (res.code == "ok") {
  820. this.users = res.data;
  821. } else {
  822. this.$message({
  823. message: res.msg,
  824. type: "error"
  825. });
  826. }
  827. },
  828. error => {
  829. this.$message({
  830. message: error,
  831. type: "error"
  832. });
  833. });
  834. },
  835. //获取列表
  836. getList() {
  837. this.listLoading = true;
  838. this.http.post('/document/allList', {
  839. projectId: this.curProjectId,
  840. parentFid: this.parentFid
  841. },
  842. res => {
  843. this.listLoading = false;
  844. if (res.code == "ok") {
  845. this.list = res.data;
  846. this.$forceUpdate();
  847. } else {
  848. this.$message({
  849. message: res.msg,
  850. type: "error"
  851. });
  852. }
  853. },
  854. error => {
  855. this.listLoading = false;
  856. this.$message({
  857. message: error,
  858. type: "error"
  859. });
  860. });
  861. },
  862. refreshPage() {
  863. this.curProjectId = parseInt(this.$route.params.id);
  864. this.getRecentList();
  865. this.clearPathList();
  866. }
  867. },
  868. created() {
  869. console.log('created===');
  870. let height = window.innerHeight;
  871. this.tableHeight = height - 190;
  872. const that = this;
  873. window.onresize = function temp() {
  874. that.tableHeight = window.innerHeight - 190;
  875. };
  876. },
  877. mounted() {
  878. console.log('mounted===');
  879. this.curProjectId = parseInt(this.$route.params.id);
  880. this.getRecentList();
  881. this.getList();
  882. this.getUsers();
  883. }
  884. };
  885. </script>