|
@@ -134,12 +134,7 @@ export default {
|
|
}
|
|
}
|
|
],
|
|
],
|
|
hook:{},
|
|
hook:{},
|
|
- showsheetbar:false,
|
|
|
|
- // cellRightClickConfig:{
|
|
|
|
- // insertColumn:false,
|
|
|
|
- // deleteRow:false,
|
|
|
|
- // deleteColumn:false
|
|
|
|
- // }
|
|
|
|
|
|
+ showsheetbar:false
|
|
}
|
|
}
|
|
|
|
|
|
return {
|
|
return {
|
|
@@ -223,7 +218,6 @@ created() {
|
|
})
|
|
})
|
|
if(res.Ret == 200){
|
|
if(res.Ret == 200){
|
|
dataList = res.Data.List || []
|
|
dataList = res.Data.List || []
|
|
- // if(res.Data.FrequencyList) this.dataForm.frequency = res.Data.FrequencyList[0]
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -231,7 +225,6 @@ created() {
|
|
// 处理复制粘贴造成的漏洞 - 记录数据
|
|
// 处理复制粘贴造成的漏洞 - 记录数据
|
|
this.options.hook.cellAllRenderBefore=(data,sheet)=>{
|
|
this.options.hook.cellAllRenderBefore=(data,sheet)=>{
|
|
if(this.haveSaveProtected) return
|
|
if(this.haveSaveProtected) return
|
|
- // console.log("全部刷新");
|
|
|
|
if(!this.protectedData.length>0){
|
|
if(!this.protectedData.length>0){
|
|
for (let i = 0; i < 5; i++) {
|
|
for (let i = 0; i < 5; i++) {
|
|
if([0,1,2].includes(i)){
|
|
if([0,1,2].includes(i)){
|
|
@@ -252,16 +245,19 @@ created() {
|
|
this.haveSaveProtected=true
|
|
this.haveSaveProtected=true
|
|
}
|
|
}
|
|
this.options.hook.cellUpdateBefore=(r,c)=>{
|
|
this.options.hook.cellUpdateBefore=(r,c)=>{
|
|
|
|
+ let edbNameEle = luckysheet.getSheetData()[3][c]
|
|
// 禁止更新的单元格 已经有的指标名称和单位不允许更新
|
|
// 禁止更新的单元格 已经有的指标名称和单位不允许更新
|
|
- if(([0,1,2].includes(r) && c==0) || ([3,4].includes(r) && c<=dataList.length)){
|
|
|
|
|
|
+ if(([0,1,2].includes(r) && c==0)
|
|
|
|
+ || ([3,4].includes(r) && edbNameEle && this.protectedData[3].some(data => data.v == edbNameEle.v))){
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
this.options.hook.cellMousedownBefore=(e,position)=>{
|
|
this.options.hook.cellMousedownBefore=(e,position)=>{
|
|
- // console.log(e,position);
|
|
|
|
|
|
+ let edbNameEle = luckysheet.getSheetData()[3][position.c]
|
|
// 禁止鼠标选中的单元格
|
|
// 禁止鼠标选中的单元格
|
|
- if([0,1,2].includes(position.r) || ([3,4].includes(position.r) && position.c<=dataList.length)){
|
|
|
|
|
|
+ if([0,1,2].includes(position.r)
|
|
|
|
+ || ([3,4].includes(position.r) && edbNameEle && this.protectedData[3].some(data => data.v == edbNameEle.v))){
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -285,23 +281,23 @@ created() {
|
|
|
|
|
|
// 是否更改了受保护的数据
|
|
// 是否更改了受保护的数据
|
|
let haveUpdatedProtectedData=false
|
|
let haveUpdatedProtectedData=false
|
|
- if([3,4].includes(position.r) && position.c>=0 && position.c<=dataList.length){
|
|
|
|
|
|
+ if([3,4].includes(position.r)){
|
|
if(!cell) return
|
|
if(!cell) return
|
|
- Object.keys(this.protectedData[position.r][position.c]).forEach(key => {
|
|
|
|
- // console.log(_.isEqual(cell[key], this.protectedData[position.r][position.c][key]),'lodash');
|
|
|
|
- if(!_.isEqual(cell[key], this.protectedData[position.r][position.c][key])){
|
|
|
|
|
|
+ let index = this.protectedData[3].findIndex((pd,ind) => pd && ind==position.c)
|
|
|
|
+ if(index ==-1) return
|
|
|
|
+ Object.keys(this.protectedData[position.r][index]).forEach(key => {
|
|
|
|
+ if(!_.isEqual(cell[key], this.protectedData[position.r][index][key])){
|
|
haveUpdatedProtectedData=true
|
|
haveUpdatedProtectedData=true
|
|
- cell[key] = this.protectedData[position.r][position.c][key]
|
|
|
|
|
|
+ cell[key] = this.protectedData[position.r][index][key]
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}else if([0,1,2].includes(position.r)){
|
|
}else if([0,1,2].includes(position.r)){
|
|
let cindex = position.c>1?1:position.c
|
|
let cindex = position.c>1?1:position.c
|
|
- // console.log(position.c,position.r,cell);
|
|
|
|
if(!cell){
|
|
if(!cell){
|
|
if(cindex<1){
|
|
if(cindex<1){
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- luckysheet.getSheet().data[position.r][position.c] = this.protectedData[position.r][cindex]
|
|
|
|
|
|
+ sheet.data[position.r][position.c] = this.protectedData[position.r][1]
|
|
}else{
|
|
}else{
|
|
Object.keys(this.protectedData[position.r][cindex]).forEach(key => {
|
|
Object.keys(this.protectedData[position.r][cindex]).forEach(key => {
|
|
if(!_.isEqual(cell[key], this.protectedData[position.r][cindex][key])){
|
|
if(!_.isEqual(cell[key], this.protectedData[position.r][cindex][key])){
|
|
@@ -309,7 +305,7 @@ created() {
|
|
cell[key] = this.protectedData[position.r][cindex][key]
|
|
cell[key] = this.protectedData[position.r][cindex][key]
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- if([0,1,2].includes(position.r) && position.c>0){
|
|
|
|
|
|
+ if(position.c>0){
|
|
if(position.r==0){
|
|
if(position.r==0){
|
|
if(cell.m !==this.firstClassName || cell.v !== this.firstClassName){
|
|
if(cell.m !==this.firstClassName || cell.v !== this.firstClassName){
|
|
haveUpdatedProtectedData=true
|
|
haveUpdatedProtectedData=true
|
|
@@ -328,13 +324,67 @@ created() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // console.log(cindex,position.r,'cindex,position.r',this.protectedData[position.r][cindex]);
|
|
|
|
}
|
|
}
|
|
if(haveUpdatedProtectedData){
|
|
if(haveUpdatedProtectedData){
|
|
// 还原数据后的手动刷新
|
|
// 还原数据后的手动刷新
|
|
this.refreshManual()
|
|
this.refreshManual()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ this.options.hook.updated=(operation)=>{
|
|
|
|
+ // 维护 protectedData数据
|
|
|
|
+ if(operation.type == 'delRC'){
|
|
|
|
+ // 删除列
|
|
|
|
+ if(operation.ctrlValue.rc == 'c'){
|
|
|
|
+ // console.log('删除列',`第${operation.ctrlValue.index+1}列开始`,`删除了${operation.ctrlValue.len}列`);
|
|
|
|
+ if(!operation.data){
|
|
|
|
+ // 没有data为撤销 恢复他
|
|
|
|
+ for (let i = operation.ctrlValue.index; i < operation.ctrlValue.index+operation.ctrlValue.len; i++) {
|
|
|
|
+ // 在celldata初始数据里面找,有找到说明不是新加的
|
|
|
|
+ let isFind = luckysheet.getSheet().celldata.some(cd => {
|
|
|
|
+ return cd.r==3 && cd.c < operation.ctrlValue.index+operation.ctrlValue.len+1 &&
|
|
|
|
+ cd.v && cd.v.v == operation.curdata[3][i].v
|
|
|
|
+ })
|
|
|
|
+ this.protectedData[3].splice(i,0,isFind?operation.curdata[3][i]:false)
|
|
|
|
+ this.protectedData[4].splice(i,0,isFind?operation.curdata[4][i]:false)
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ for (let i = operation.ctrlValue.index; i < operation.ctrlValue.index+operation.ctrlValue.len; i++) {
|
|
|
|
+ if(operation.ctrlValue.index > this.protectedData[3].length){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ this.protectedData[3].splice(operation.ctrlValue.index,1)
|
|
|
|
+ this.protectedData[4].splice(operation.ctrlValue.index,1)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else if(operation.type == 'addRC' && operation.ctrlValue.rc == 'c'){
|
|
|
|
+ // 增加列
|
|
|
|
+ let addIndex = operation.ctrlValue.index
|
|
|
|
+ if(operation.ctrlValue.direction=='lefttop'){
|
|
|
|
+ // 向左加
|
|
|
|
+ addIndex--
|
|
|
|
+ }
|
|
|
|
+ // 比原本的protectedData数组长度大,就不会对protectedData造成形象 就return
|
|
|
|
+ if(!(addIndex < this.protectedData[3].length)) return
|
|
|
|
+ // console.log('增加列',`第${addIndex+1}列开始向右`,`增加了${operation.ctrlValue.len}列,${operation.data?"正向操作":"撤销"}`);
|
|
|
|
+
|
|
|
|
+ if(!operation.data){
|
|
|
|
+ // 没有data为撤销 删除它
|
|
|
|
+ for (let i = addIndex; i < addIndex+operation.ctrlValue.len; i++) {
|
|
|
|
+ this.protectedData[3].splice(addIndex+1,1)
|
|
|
|
+ this.protectedData[4].splice(addIndex+1,1)
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ for (let i = addIndex; i < addIndex+operation.ctrlValue.len; i++) {
|
|
|
|
+ // 新加的列,只占个位置,保持索引相对,不需要保护,置为false
|
|
|
|
+ this.protectedData[3].splice(i+1,0,false)
|
|
|
|
+ this.protectedData[4].splice(i+1,0,false)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
// 拿出所有数组
|
|
// 拿出所有数组
|
|
let arr = dataList.map((item => item.DataList)).flat()
|
|
let arr = dataList.map((item => item.DataList)).flat()
|
|
// 拿出所有数组的日期并展平排序
|
|
// 拿出所有数组的日期并展平排序
|
|
@@ -384,7 +434,6 @@ created() {
|
|
})
|
|
})
|
|
})
|
|
})
|
|
for (let i = 0; i < col; i++) {
|
|
for (let i = 0; i < col; i++) {
|
|
- // let item =dataList[0]
|
|
|
|
this.options.data[0].celldata.push(
|
|
this.options.data[0].celldata.push(
|
|
{
|
|
{
|
|
"r":0,
|
|
"r":0,
|
|
@@ -474,8 +523,6 @@ created() {
|
|
"value1": this.unitList.join(','),
|
|
"value1": this.unitList.join(','),
|
|
"value2": "",
|
|
"value2": "",
|
|
"prohibitInput": false,
|
|
"prohibitInput": false,
|
|
- // "hintShow": false,
|
|
|
|
- // "hintText": ""
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.$nextTick(()=>{
|
|
this.$nextTick(()=>{
|