yangbifan 2 years ago
parent
commit
6777e18c20
1 changed files with 27 additions and 2 deletions
  1. 27 2
      public/static/views/onlineShareExcel.html

+ 27 - 2
public/static/views/onlineShareExcel.html

@@ -321,9 +321,34 @@
                             cellMousedown: function (a, b, c) {
 
                             },
-                            cellUpdateBefore: function (r, c) {
-
+                            cellUpdateBefore: function (r, c, value, isRefresh) {
+                                // 当用户修改单元格里的值,去掉单引号时
+                                // eslint-disable-next-line no-undef
+                                const data = luckysheet.toJson().data[0].data
+                                if (data[r][c] && data[r][c].qp && data[r][c].qp == 1 && value.indexOf("'") < 0) {
+                                    // eslint-disable-next-line no-undef
+                                    luckysheet.setCellFormat(r, c, 'qp', 0)
+                                }
                             },
+                            updated: function (operate) {
+                                // 当用户清空单元格里的数据时
+                                if (operate.type === 'datachange') {
+                                    const row1 = operate.range[0].row[0]
+                                    const row2 = operate.range[0].row[1]
+                                    const col1 = operate.range[0].column[0]
+                                    const col2 = operate.range[0].column[1]
+                                    for (let r = row1; r <= row2; r++) {
+                                        for (let c = col1; c <= col2; c++) {
+                                            const newValue = operate.curdata[r][c]
+                                            if (newValue && !newValue.v && !newValue.m && newValue.qp && newValue.qp == 1) {
+                                                // eslint-disable-next-line no-undef
+                                                luckysheet.setCellFormat(r, c, 'qp', 0)
+                                            }
+                                        }
+                                    }
+                                }
+                            },
+
                             cellMousedownBefore: function (a, p, s) {
 
                             },