index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <div class="flex-count">
  3. <div class="flex-header-count">
  4. <el-popover placement="right-start" width="460" v-model="visible">
  5. <el-form ref="form" :model="form" label-width="80px">
  6. <el-form-item label="文档名称">
  7. <el-input v-model="form.fileName"></el-input>
  8. </el-form-item>
  9. <el-form-item label="文档类型">
  10. <el-select v-model="form.docType" placeholder="请选择文档类型">
  11. <el-option label="word" value="word"></el-option>
  12. <el-option label="cell" value="cell"></el-option>
  13. <el-option label="slide" value="slide"></el-option>
  14. </el-select>
  15. </el-form-item>
  16. </el-form>
  17. <div style="text-align: right; margin: 0">
  18. <el-button type="primary" @click="visible = false">取消</el-button>
  19. <el-button type="primary" @click="clickNewSave">确定</el-button>
  20. </div>
  21. <el-button size="medium" slot="reference" icon="el-icon-circle-plus-outline">新建</el-button>
  22. </el-popover>
  23. <myUpload style="margin-left:20px ;" @uploadBack="uploadBack" :fileInfo="fileInfo"
  24. :fileList="fileInfo.fileList">
  25. </myUpload>
  26. </div>
  27. <fromList @changeNum="changeNum" :list="firstTable" @clickDemand="clickDemand" />
  28. <div>
  29. <el-dialog :modal="false" title="提示" :visible.sync="officeStatus" style="height:100% ;" width="100%"
  30. height="100%" center>
  31. <div id="DocEditor" v-if="officeStatus">
  32. <onlyoffice-editor editorId="DocEditor" :src="src" :config="config" @ready="onReady" />
  33. </div>
  34. </el-dialog>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import fromList from '../../../../src/components/el-form.vue'
  40. import { DocumentEditor } from "@onlyoffice/document-editor-vue";
  41. import myUpload from '../../../components/upload'
  42. import getConfig from '../../../config/dev'
  43. export default {
  44. name: 'ExampleComponent',
  45. components: {
  46. DocumentEditor,
  47. myUpload,
  48. fromList
  49. // DocumentEditor
  50. },
  51. data() {
  52. return {
  53. dataList: [],
  54. page: 1,
  55. searchData: '',
  56. limit: 10,
  57. form: {},
  58. visible: false,
  59. saveStatus: false,
  60. officeStatus: false,
  61. src: '',
  62. config: {},
  63. fileInfo: {
  64. limit: 10,
  65. type: 'btn',
  66. typename: '导入',
  67. urlType: 'office',
  68. url: '/office/restfile/upload',
  69. fileList: []
  70. },
  71. firstTable: {
  72. height: '520',
  73. name: "first",
  74. titledata: [
  75. {
  76. label: "名称",
  77. prop: "fileName",
  78. width: 600,
  79. },
  80. {
  81. label: "最后修改时间",
  82. prop: "lastModifyTimeStr",
  83. width: 400,
  84. },
  85. {
  86. label: "文件大小",
  87. prop: "fileSizeStr",
  88. width: 400,
  89. },
  90. ], //表格头
  91. data: [], //内容数据
  92. loading: true,
  93. pageData: {
  94. total: 100, // 总条数
  95. pageSize: 10, // 每页数量
  96. pageNum: 1, // 页码
  97. },
  98. isSelection: false, // 表格有多选时设置
  99. isOperation: false, // 表格有操作列时设置
  100. isIndex: true, // 列表序号
  101. operation: {
  102. // 表格有操作列时设置
  103. label: "操作", // 列名
  104. width: "50", // 根据实际情况给宽度
  105. data: [
  106. {
  107. label: "操作", // 操作名称
  108. type: "", //按钮类型
  109. handleRow: (e, r, o) => {
  110. }, // 自定义事件
  111. },
  112. ],
  113. },
  114. },
  115. }
  116. },
  117. mounted() {
  118. // this.getListEdit()
  119. this.getLists()
  120. },
  121. methods: {
  122. uploadBack(e) {
  123. this.form = {};
  124. this.getLists();
  125. },
  126. //新建在线编辑xxx
  127. clickNewSave() {
  128. let _this = this;
  129. _this.$util.ajaxJson("正在加载", getConfig().OFFICE_URL + "/office/restfile/create", { data: this.form }, function (res) {
  130. _this.page = 1;
  131. _this.$message.success('新建成功')
  132. _this.form = {}
  133. _this.getLists();
  134. _this.visible = false;
  135. });
  136. // this.saveStatus = true
  137. // this.$http({
  138. // url: "/office/restfile/create",
  139. // method: "post",
  140. // type: 'office',
  141. // headers: {
  142. // "Content-Type": "application/json",
  143. // },
  144. // data: this.form
  145. // }).then((res) => {
  146. // this.page = 1;
  147. // this.$message.success('新建成功')
  148. // this.form = {}
  149. // this.getLists();
  150. // this.visible = false;
  151. // });
  152. },
  153. //点击工单状态跳转需求流程显示页面
  154. clickDemand(e, res) {
  155. if (e == '名称') {
  156. this.getListEdit(res)
  157. }
  158. },
  159. async getListEdit(e) {
  160. let _this = this;
  161. _this.$util.ajaxJson("正在加载", getConfig().OFFICE_URL + "/office/restfile/edit", {
  162. id: e.id,
  163. edit: true,
  164. userId: JSON.parse(window.sessionStorage.userInfo).loginNo,
  165. userName: JSON.parse(window.sessionStorage.userInfo).loginName
  166. }, function (res) {
  167. let { docType, fileType, id, fileName, downloadUrl, userId, userName, configCallback, api } = res.body
  168. _this.src = api;
  169. let config = {
  170. documentType: docType,
  171. height: '100%',
  172. width: '100%',
  173. document: {
  174. fileType: fileType,
  175. key: id,
  176. title: fileName,
  177. url: downloadUrl
  178. },
  179. editorConfig: {
  180. user: {
  181. id: userId,
  182. name: userName
  183. },
  184. callbackUrl: decodeURIComponent(configCallback)
  185. }
  186. }
  187. if (res.code == 0) {
  188. _this.config = config;
  189. _this.officeStatus = true;
  190. console.log(this.config);
  191. }
  192. });
  193. // await this.$http({
  194. // url: "/office/restfile/edit",
  195. // method: "post",
  196. // type: 'office',
  197. // headers: {
  198. // "Content-Type": "application/json",
  199. // },
  200. // data: {
  201. // id: e.id,
  202. // edit: true,
  203. // userId: JSON.parse(window.sessionStorage.userInfo).loginNo,
  204. // userName: JSON.parse(window.sessionStorage.userInfo).loginName
  205. // },
  206. // }).then((res) => {
  207. // // console.log('[ res ] >', res)
  208. // });
  209. },
  210. getLists() {
  211. let _this = this;
  212. _this.$util.ajaxJson("正在加载", getConfig().OFFICE_URL + "/office/restfile/list", {}, function (res) {
  213. console.log(res);
  214. _this.dataList = res.body;
  215. _this.currentPage(res.body)
  216. _this.firstTable.pageData.total = res.body.length;
  217. });
  218. // this.$http({
  219. // url: "/office/restfile/list",
  220. // method: "post",
  221. // type: 'office',
  222. // headers: {
  223. // "Content-Type": "application/json",
  224. // },
  225. // data: {
  226. // },
  227. // }).then((res) => {
  228. // this.dataList = res.data.body;
  229. // this.currentPage(res.data.body)
  230. // this.firstTable.pageData.total = res.data.body.length;
  231. // });
  232. },
  233. onReady(editor) {
  234. console.log('[ editor ] >', editor)
  235. },
  236. currentPage(e) {
  237. console.log(e);
  238. let list = e.filter((item, index) =>
  239. item.fileName.includes(this.searchData)
  240. )
  241. this.firstTable.data = list.filter((item, index) =>
  242. index < this.page * this.limit && index >= this.limit * (this.page - 1)
  243. )
  244. },
  245. changeNum(e) {
  246. this.page = e;
  247. this.currentPage(this.dataList)
  248. }
  249. },
  250. };
  251. </script>
  252. <style lang="scss" scoped>
  253. .flex-header-count {
  254. padding: 20px;
  255. display: flex;
  256. }
  257. .el-dropdown-link {
  258. margin: 20px;
  259. position: relative;
  260. }
  261. ::v-deep .el-dialog--center {
  262. height: 100%;
  263. margin-top: 10px !important;
  264. }
  265. ::v-deep .el-dialog__body {
  266. height: 100%;
  267. }
  268. #DocEditor {
  269. height: 100%;
  270. }
  271. .flex-count {
  272. height: 100%;
  273. background: #fff;
  274. }
  275. ::v-deep .el-pagination {
  276. background-color: #fff !important;
  277. }
  278. </style>