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

优化排除区和说明区域

parent 56ef9dd2
...@@ -114,7 +114,7 @@ export function handleRangeTitle(range: any) { ...@@ -114,7 +114,7 @@ export function handleRangeTitle(range: any) {
return titles return titles
} }
export function handleRangeCell(range: any) { export function handleRangeCell(range: any, cb?: any) {
console.log(luckysheet.getRangeValue(), 'range-----') console.log(luckysheet.getRangeValue(), 'range-----')
// return // return
const { beginRow, beginColum, endRow, sheetNum, endColum, columnLen, rowLen } = const { beginRow, beginColum, endRow, sheetNum, endColum, columnLen, rowLen } =
...@@ -151,6 +151,7 @@ export function handleRangeCell(range: any) { ...@@ -151,6 +151,7 @@ export function handleRangeCell(range: any) {
}) })
} }
titles.push(t) titles.push(t)
cb && cb(t)
} catch (e) { } catch (e) {
console.log(r, c, t, e, cell, 'error') console.log(r, c, t, e, cell, 'error')
} }
......
...@@ -41,12 +41,12 @@ ...@@ -41,12 +41,12 @@
</el-form> </el-form>
<el-row :gutter="24" style="margin-bottom: 12px"> <el-row :gutter="24" style="margin-bottom: 12px">
<el-col :span="12" style="margin-bottom: 12px"> <el-col :span="12" style="margin-bottom: 12px">
<!-- excludeArea --> <!-- excludeTitles -->
<p class="table-des">排除区:</p> <p class="table-des">排除区:</p>
<vxe-table <vxe-table
:row-config="{ isCurrent: true }" :row-config="{ isCurrent: true }"
border border
:data="currentForm.excludeArea" :data="currentForm.excludeTitles"
size="mini" size="mini"
max-height="200" max-height="200"
:edit-config="{ trigger: 'click', mode: 'cell' }" :edit-config="{ trigger: 'click', mode: 'cell' }"
...@@ -306,7 +306,7 @@ const delAreaTitle = (index: number) => { ...@@ -306,7 +306,7 @@ const delAreaTitle = (index: number) => {
const delCaptionAndExclude = (row: any, index: number, type: number) => { const delCaptionAndExclude = (row: any, index: number, type: number) => {
delCapAndExc.value.push({ ...row, type }) 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) => { const delGroupAreaTitle = (index: number) => {
attchInfo.areaTitles.splice(index, 1) attchInfo.areaTitles.splice(index, 1)
......
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
import { apiDictList } from '@/api/common' import { apiDictList } from '@/api/common'
import { areaMarksColor } from '@/constants/excelConfig' import { areaMarksColor } from '@/constants/excelConfig'
import type { Recordable } from '@/types/global' 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 { ElMessage, type FormInstance } from 'element-plus'
import { onMounted, reactive, ref, unref, watch } from 'vue' import { onMounted, reactive, ref, unref, watch } from 'vue'
...@@ -227,11 +227,25 @@ const captionArea = ref<Recordable[]>([]) ...@@ -227,11 +227,25 @@ const captionArea = ref<Recordable[]>([])
const excludeArea = ref<Recordable[]>([]) const excludeArea = ref<Recordable[]>([])
// 设置说明区 // 设置说明区
const setCaptionArea = () => { 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 = () => { 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) => { const delCaptionAndExclude = (row: any, index: number, type = 1) => {
...@@ -240,41 +254,18 @@ 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 getRangeCellValue = (type: 'caption' | 'exclude') => {
const position = getRangePosition() return handleRangeCell(luckysheet.getRangeValue(), (c: any) => {
const sheet = luckysheet.getSheet() luckysheet.menuButton.customUpdateFormat(
const rangeValue = luckysheet.getRangeValue() null,
const cells: any = [] 'bg',
rangeValue.forEach((row: any, r: number) => { areaMarksColor[type],
row.forEach((cell: any, c: number) => { c.row,
const p = { c.row,
r: position?.beginRow + r, c.colum,
c: position?.beginColum + c c.colum,
} false
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
})
luckysheet.menuButton.customUpdateFormat(
null,
'bg',
areaMarksColor[type],
p.r,
p.r,
p.c,
p.c,
false
)
}
} catch {}
})
}) })
return cells
} }
const queryDict = async (code: string) => { 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