index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <div>
  3. <div v-for="(item, index) in optionsExcel" :key="index">
  4. <div @click="clickSee(item)">{{ item.name }}</div>
  5. </div>
  6. <el-button @click="newExcle">新建</el-button>
  7. <div
  8. id="luckysheet"
  9. v-show="excelStatus"
  10. style="
  11. margin: 0px;
  12. padding: 0px;
  13. position: absolute;
  14. width: 100%;
  15. height: 100%;
  16. left: 0px;
  17. top: 0px;
  18. "
  19. ></div>
  20. </div>
  21. </template>
  22. <script>
  23. import axios from 'axios'
  24. import luckyexcel from "luckyexcel";
  25. export default {
  26. data() {
  27. return {
  28. excelStatus: false,
  29. optionsExcel: [],
  30. ids: "",
  31. };
  32. },
  33. created() {
  34. console.log(window.location.protocol);
  35. console.log(window.location.host);
  36. this.getAllExcel();
  37. // var options = {
  38. // container: "luckysheet", // 设定DOM容器的id
  39. // // title: "123123", // 设定表格名称
  40. // // lang: "zh",
  41. // // allowUpdate: true,
  42. // // localUrl:'123',
  43. // // loadUrl: window.location.protocol + localurl + "/load/${wb.id}",
  44. // // loadSheetUrl: window.location.protocol + localurl + "/loadSheet/${wb.id}",
  45. // // updateUrl:
  46. // // "ws://" +
  47. // // localurl +
  48. // // "/ws/" +
  49. // // Math.round(Math.random() * 100) +
  50. // // "/${wb.id}",
  51. // // 更多其他设置...
  52. // };
  53. // window.luckysheet.create({
  54. // container: "luckysheet",
  55. // });
  56. },
  57. mounted() {
  58. // In some cases, you need to use $nextTick
  59. // this.$nextTick(() => {
  60. // $(function () {
  61. // luckysheet.create({
  62. // localUrl: "123",
  63. // // loadUrl: window.location.protocol + localurl + "/load/${wb.id}",
  64. // // loadSheetUrl: window.location.protocol + localurl + "/loadSheet/${wb.id}",
  65. // // updateUrl:
  66. // // "ws://" +
  67. // // localurl +
  68. // // "/ws/" +
  69. // // Math.round(Math.random() * 100) +
  70. // // "/${wb.id}",
  71. // container: "luckysheet", // 设定DOM容器的id
  72. // allowUpdate: true,
  73. // functionButton:
  74. // '<button id="" class="btn btn-primary btn-danger" style=" padding:3px 6px; font-size: 12px; margin-right: 5px;" onclick="exportHandle()">保存</button><button id="" class="btn btn-primary btn-danger" style=" padding:3px 6px; font-size: 12px; margin-right: 85px;" onclick="exportHandles()">在线导出</button>',
  75. // title: "Luckysheet Demo", // 设定表格名称
  76. // lang: "zh", // 设定表格语言
  77. // // plugins:['chart'],
  78. // data: [
  79. // {
  80. // name: "Cell", //工作表名称
  81. // color: "", //工作表颜色
  82. // index: 0, //工作表索引
  83. // status: 1, //激活状态
  84. // order: 0, //工作表的下标
  85. // hide: 0, //是否隐藏
  86. // row: 36, //行数
  87. // column: 18, //列数
  88. // defaultRowHeight: 19, //自定义行高
  89. // defaultColWidth: 73, //自定义列宽
  90. // celldata: [], //初始化使用的单元格数据
  91. // config: {
  92. // merge: {}, //合并单元格
  93. // rowlen: {}, //表格行高
  94. // columnlen: {}, //表格列宽
  95. // rowhidden: {}, //隐藏行
  96. // colhidden: {}, //隐藏列
  97. // borderInfo: {}, //边框
  98. // authority: {}, //工作表保护
  99. // },
  100. // scrollLeft: 0, //左右滚动条位置
  101. // scrollTop: 315, //上下滚动条位置
  102. // luckysheet_select_save: [], //选中的区域
  103. // calcChain: [], //公式链
  104. // isPivotTable: false, //是否数据透视表
  105. // pivotTable: {}, //数据透视表设置
  106. // filter_select: {}, //筛选范围
  107. // filter: null, //筛选配置
  108. // luckysheet_alternateformat_save: [], //交替颜色
  109. // luckysheet_alternateformat_save_modelCustom: [], //自定义交替颜色
  110. // luckysheet_conditionformat_save: {}, //条件格式
  111. // frozen: {}, //冻结行列配置
  112. // chart: [], //图表配置
  113. // zoomRatio: 1, // 缩放比例
  114. // image: [], //图片
  115. // showGridLines: 1, //是否显示网格线
  116. // dataVerification: {}, //数据验证配置
  117. // },
  118. // {
  119. // name: "Sheet2",
  120. // color: "",
  121. // index: 1,
  122. // status: 0,
  123. // order: 1,
  124. // celldata: [],
  125. // config: {},
  126. // },
  127. // {
  128. // name: "Sheet3",
  129. // color: "",
  130. // index: 2,
  131. // status: 0,
  132. // order: 2,
  133. // celldata: [],
  134. // config: {},
  135. // },
  136. // ],
  137. // });
  138. // });
  139. // });
  140. },
  141. methods: {
  142. clickSee(e) {
  143. console.log(e);
  144. this.$http({
  145. url: "/api/sheet/workbook/" + e.id,
  146. method: "post",
  147. headers: {
  148. "Content-Type": "application/json",
  149. },
  150. data: {},
  151. }).then((res) => {
  152. this.ids = e.id;
  153. // this.optionsExcel = res.data;
  154. let options = {
  155. container: "luckysheet",
  156. title: "123123",
  157. allowUpdate: true,
  158. lang: "zh",
  159. loadUrl:
  160. window.location.protocol +
  161. "//43.138.50.94:7777" +
  162. "/sheet/worksheet/" +
  163. this.ids,
  164. loadSheetUrl:
  165. window.location.protocol +
  166. "//43.138.50.94:7777" +
  167. "/sheet/loadsheet/" +
  168. this.ids,
  169. updateUrl:
  170. "ws://" +
  171. "//43.138.50.94:7777" +
  172. "/ws/" +
  173. JSON.parse(window.sessionStorage.userInfo).loginName +
  174. "/" +
  175. this.ids,
  176. };
  177. window.luckysheet.create(options);
  178. this.excelStatus = true;
  179. });
  180. },
  181. //获取所有
  182. getAllExcel() {
  183. let data = {};
  184. axios.post("http://43.138.50.94:7777/sheet/allSheet", data).then((res) => {
  185. console.log(res);
  186. this.optionsExcel = res.data;
  187. });
  188. // this.$http({
  189. // url: "/api/sheet/allSheet",
  190. // method: "post",
  191. // headers: {
  192. // "Content-Type": "application/json",
  193. // },
  194. // data: {},
  195. // }).then((res) => {
  196. // console.log(res);
  197. // this.optionsExcel = res.data;
  198. // });
  199. },
  200. newExcle() {
  201. let data = {};
  202. axios.post("http://43.138.50.94:7777/sheet/create", data).then((res) => {
  203. console.log(res);
  204. let list = {
  205. name:res.data.name,
  206. id:res.data.id
  207. }
  208. this.optionsExcel.push(list)
  209. // this.optionsExcel = res.data;
  210. });
  211. // this.excelStatus = true
  212. // this.$http({
  213. // url: "/api/sheet/create",
  214. // method: "post",
  215. // headers: {
  216. // "Content-Type": "application/json",
  217. // },
  218. // data: {},
  219. // }).then((res) => {
  220. // console.log(res);
  221. // });
  222. },
  223. },
  224. };
  225. </script>
  226. <style>
  227. </style>