sone-ui-component-3.2.4 2.1.50 → 2.1.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sone-ui-component-3.2.4",
3
- "version": "2.1.50",
3
+ "version": "2.1.51",
4
4
  "private": false,
5
5
  "main": "lib/sone-ui.common.js",
6
6
  "files": [
@@ -0,0 +1,15 @@
1
+ /*
2
+ * @Descripttion: your project
3
+ * @version: 1.0
4
+ * @Author: lw
5
+ * @Date: 2025-02-28 10:22:13
6
+ * @LastEditors: lw
7
+ * @LastEditTime: 2025-02-28 10:23:12
8
+ */
9
+ import LuckySheet from './src/main';
10
+
11
+ LuckySheet.install = function (Vue) {
12
+ Vue.component(LuckySheet.name, LuckySheet);
13
+ };
14
+
15
+ export default LuckySheet;
@@ -0,0 +1,93 @@
1
+ <template>
2
+ <div>
3
+ <iframe
4
+ ref="luckysheet"
5
+ src="/luckySheet/index.html"
6
+ frameborder="0"
7
+ style="width: 100%"
8
+ :style="{ height: height }"
9
+ />
10
+ </div>
11
+ </template>
12
+ <script>
13
+ import { deepClone, throttle } from "sone-ui-component/src/utils/util";
14
+
15
+ const initialData = [
16
+ {
17
+ name: "sheet1", //工作表名称
18
+ index: 0, //工作表索引
19
+ status: 1, //激活状态
20
+ order: 0, //工作表的下标
21
+ celldata: [], //初始化使用的单元格数据
22
+ config: {},
23
+ calcChain: [],
24
+ },
25
+ ];
26
+ export default {
27
+ name: "SoneLuckySheet",
28
+ props: {
29
+ disabled: {
30
+ type: Boolean,
31
+ default: false,
32
+ },
33
+ height: {
34
+ type: String,
35
+ default: "700px",
36
+ },
37
+ value: {
38
+ type: Array,
39
+ default: () => initialData,
40
+ },
41
+ },
42
+ data() {
43
+ return {};
44
+ },
45
+ watch: {
46
+ disabled: {
47
+ immediate: true,
48
+ handler: "intEditor",
49
+ },
50
+ value: {
51
+ immediate: true,
52
+ deep: true,
53
+ handler: "intEditor",
54
+ },
55
+ },
56
+ methods: {
57
+ getData() {
58
+ return this.$refs.luckysheet?.contentWindow?.getData();
59
+ },
60
+ exitEditMode() {
61
+ this.$refs.luckysheet?.contentWindow?.exitEditMode();
62
+ },
63
+ // 获取坐标值
64
+ getCellIndex() {
65
+ return this.$refs.luckysheet?.contentWindow?.getCellIndex();
66
+ },
67
+ // 设置单元格的值
68
+ setCellValue() {
69
+ this.$refs.luckysheet?.contentWindow?.setCellValue();
70
+ },
71
+ intEditor: throttle(async function() {
72
+ await this.$nextTick();
73
+ if (
74
+ typeof this.$refs.luckysheet.contentWindow.createEditor === "function"
75
+ ) {
76
+ this.$refs.luckysheet.contentWindow.createEditor(
77
+ deepClone(this.value) || deepClone(initialData),
78
+ this.disabled
79
+ );
80
+ } else {
81
+ setTimeout(() => {
82
+ this.intEditor();
83
+ }, 500);
84
+ }
85
+ }, 200),
86
+
87
+ getRangeHtml() {
88
+ const html = this.$refs.luckysheet.contentWindow.getRangeHtml();
89
+ return html;
90
+ },
91
+ },
92
+ };
93
+ </script>
package/src/index.js CHANGED
@@ -57,7 +57,7 @@ if (typeof window !== 'undefined' && window.Vue) {
57
57
  }
58
58
 
59
59
  export default {
60
- version: '2.1.50',
60
+ version: '2.1.51',
61
61
  locale: locale.use,
62
62
  i18n: locale.i18n,
63
63
  install,
package/src/utils/util.js CHANGED
@@ -284,3 +284,18 @@ export const deepClone = data => {
284
284
  }
285
285
  return obj
286
286
  }
287
+
288
+ export function throttle(fn, time) {
289
+ let timer = null
290
+ time = time || 1000
291
+ return function (...args) {
292
+ if (timer) {
293
+ return
294
+ }
295
+ const _this = this
296
+ timer = setTimeout(() => {
297
+ timer = null
298
+ }, time)
299
+ fn.apply(_this, args)
300
+ }
301
+ }