Commit 78cd7861 authored by 何远江's avatar 何远江

优化排除区和说明区域

parent 56ef9dd2
......@@ -114,7 +114,7 @@ export function handleRangeTitle(range: any) {
return titles
}
export function handleRangeCell(range: any) {
export function handleRangeCell(range: any, cb?: any) {
console.log(luckysheet.getRangeValue(), 'range-----')
// return
const { beginRow, beginColum, endRow, sheetNum, endColum, columnLen, rowLen } =
......@@ -151,6 +151,7 @@ export function handleRangeCell(range: any) {
})
}
titles.push(t)
cb && cb(t)
} catch (e) {
console.log(r, c, t, e, cell, 'error')
}
......
......@@ -41,12 +41,12 @@
</el-form>
<el-row :gutter="24" style="margin-bottom: 12px">
<el-col :span="12" style="margin-bottom: 12px">
<!-- excludeArea -->
<!-- excludeTitles -->
<p class="table-des">排除区:</p>
<vxe-table
:row-config="{ isCurrent: true }"
border
:data="currentForm.excludeArea"
:data="currentForm.excludeTitles"
size="mini"
max-height="200"
:edit-config="{ trigger: 'click', mode: 'cell' }"
......@@ -306,7 +306,7 @@ const delAreaTitle = (index: number) => {
const delCaptionAndExclude = (row: any, index: number, type: number) => {
delCapAndExc.value.push({ ...row, type })
// 删除本行
;(type == 1 ? currentForm.dataTitles : currentForm.excludeArea).splice(index, 1)
;(type == 1 ? currentForm.dataTitles : currentForm.excludeTitles).splice(index, 1)
}
const delGroupAreaTitle = (index: number) => {
attchInfo.areaTitles.splice(index, 1)
......
......@@ -134,7 +134,7 @@
import { apiDictList } from '@/api/common'
import { areaMarksColor } from '@/constants/excelConfig'
import type { Recordable } from '@/types/global'
import { getRangePosition, getRangetxt, setRangeBackground } from '@/utils/excel'
import { getRangePosition, getRangetxt, handleRangeCell, setRangeBackground } from '@/utils/excel'
import { ElMessage, type FormInstance } from 'element-plus'
import { onMounted, reactive, ref, unref, watch } from 'vue'
......@@ -227,11 +227,25 @@ const captionArea = ref<Recordable[]>([])
const excludeArea = ref<Recordable[]>([])
// 设置说明区
const setCaptionArea = () => {
captionArea.value = getRangeCellValue('caption')
const cells = getRangeCellValue('caption')
// 去除重复单元格
captionArea.value.push(
...cells.filter(
(cell) => captionArea.value.findIndex((v) => v.row == cell.row && v.colum == cell.colum) == -1
)
)
}
// 设置排除区
const setExcludeArea = () => {
excludeArea.value = getRangeCellValue('exclude')
const cells = getRangeCellValue('exclude')
// 去除重复单元格
excludeArea.value.push(
...cells.filter(
(cell) => excludeArea.value.findIndex((v) => v.row == cell.row && v.colum == cell.colum) == -1
)
)
}
const delCaptionAndExclude = (row: any, index: number, type = 1) => {
......@@ -240,41 +254,18 @@ const delCaptionAndExclude = (row: any, index: number, type = 1) => {
}
// 获取有值的单元格
const getRangeCellValue = (type: 'caption' | 'exclude') => {
const position = getRangePosition()
const sheet = luckysheet.getSheet()
const rangeValue = luckysheet.getRangeValue()
const cells: any = []
rangeValue.forEach((row: any, r: number) => {
row.forEach((cell: any, c: number) => {
const p = {
r: position?.beginRow + r,
c: position?.beginColum + c
}
let v = ''
try {
v = cell.v || cell?.ct?.s.map((itm) => itm.v).join('')
if (v) {
cells.push({
title: v,
row: p.r,
colum: p.c,
sheet: sheet.order
})
return handleRangeCell(luckysheet.getRangeValue(), (c: any) => {
luckysheet.menuButton.customUpdateFormat(
null,
'bg',
areaMarksColor[type],
p.r,
p.r,
p.c,
p.c,
c.row,
c.row,
c.colum,
c.colum,
false
)
}
} catch {}
})
})
return cells
}
const queryDict = async (code: string) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment