提交 12b89e58 authored 作者: kxjia's avatar kxjia

完善功能

上级 574734b0
...@@ -33,7 +33,7 @@ export const tableFormData = [ ...@@ -33,7 +33,7 @@ export const tableFormData = [
{ type: 'text', value: '<strong>网络安全责任制建立情况</strong>' }, { type: 'text', value: '<strong>网络安全责任制建立情况</strong>' },
{ type: 'br' }, { type: 'br' },
{ type: 'text', value: '建立并落实网络安全工作责任制' }, { type: 'text', value: '建立并落实网络安全工作责任制' },
{ type: 'radio-group', field: 'C23A001', options: ['是', '否'] }, { type: 'radio-group', field: 'C23A001', options: ['是', '否'] ,value:''},
{ type: 'br' }, { type: 'br' },
{ type: 'text', value: '网络安全第一责任人:' }, { type: 'text', value: '网络安全第一责任人:' },
{ type: 'text', value: '姓名' }, { type: 'text', value: '姓名' },
......
...@@ -652,7 +652,6 @@ const collectVxeTableData = async () => { ...@@ -652,7 +652,6 @@ const collectVxeTableData = async () => {
} }
} }
if (formData.footer) { if (formData.footer) {
alert(formData.footerPcode)
for (const [code, value] of Object.entries(formData.footer)) { for (const [code, value] of Object.entries(formData.footer)) {
await addFormValue(formData.footerPcode, code, value, 1) await addFormValue(formData.footerPcode, code, value, 1)
} }
......
<template> <template>
<div class="bank-report-table" style="height:80vh" @click="closeAllTooltips"> <div
class="bank-report-table"
style="height:80vh"
@click="closeAllTooltips"
>
<!-- 加载遮罩层 --> <!-- 加载遮罩层 -->
<div v-if="loading" class="loading-overlay"> <div v-if="loading" class="loading-overlay">
<div class="loading-spinner"> <div class="loading-spinner">
...@@ -8,77 +12,115 @@ ...@@ -8,77 +12,115 @@
</div> </div>
</div> </div>
<!-- 工具栏 -->
<vxe-toolbar> <vxe-toolbar>
<template #button> <template #buttons>
<div class="toolbar-info"> <div style="margin:10px">
<span class="info-label">填报任务:{{ queryParam?.taskName }}</span> <span class="table-info-text">填报任务:{{ queryParam.taskName }}</span>
<span class="info-label">表格:{{ queryParam?.tplCode }} {{ queryParam?.tplName }}</span> <span class="table-info-text" style="margin-left:20px">
表格:{{ queryParam.tplCode }} {{ queryParam.tplName }}
</span>
</div> </div>
</template> </template>
<template #tools v-if="!queryParam.comfrom"> <template #tools v-if="!queryParam.comfrom">
<vxe-button status="primary" icon="vxe-icon-edit" @click="handleOpenHistoryDrawer()" :disabled="loading">近5年数据填报</vxe-button> <vxe-button
<vxe-button status="primary" icon="vxe-icon-save" @click="checkData()">校验</vxe-button> status="primary"
<vxe-button status="primary" icon="vxe-icon-save" @click="saveBatch">保存</vxe-button> icon="vxe-icon-edit"
@click="handleOpenHistoryDrawer"
:disabled="loading"
>
近5年数据填报
</vxe-button>
<vxe-button
status="primary"
icon="vxe-icon-save"
@click="validateData"
>
校验
</vxe-button>
<vxe-button
status="primary"
icon="vxe-icon-save"
@click="saveBatch"
>
保存
</vxe-button>
</template> </template>
</vxe-toolbar> </vxe-toolbar>
<!-- 校验抽屉 --> <!-- 主表格 -->
<ValidationDrawer
ref="validationDrawerRef"
v-model="drawerVisible"
:tableFormData="tableFormData"
@validationResultClick="handleValidationResultClick"
/>
<vxe-table <vxe-table
border border
ref="tableRef" ref="tableRef"
height="auto"
show-header-overflow show-header-overflow
:data="tableFormData" :data="tableFormData"
:column-config="{ resizable: true }" :column-config="{ resizable: true }"
:row-config="{ resizable: true }" :row-config="{ resizable: true }"
class="custom-table" class="custom-table"
height="auto"
:merge-cells="mergeCells"
> >
<vxe-column field="serialNumber" title="序号" width="80"></vxe-column> <vxe-column field="serialNumber" title="序号" width="50"></vxe-column>
<vxe-column field="project" title="项目" width="50">
<template #default="{ row }"> <vxe-column field="project" title="项目" width="100">
<span class="project-title">{{ row.project }}</span>
</template>
</vxe-column>
<vxe-column field="project2" title="" width="50">
<template #default="{ row }"> <template #default="{ row }">
<span class="project-title">{{ row.project2 }}</span> <span class="project-name">{{ row.project }}</span>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="content" title="内容" row-resize>
<vxe-column field="content" title="内容">
<template #default="{ row }"> <template #default="{ row }">
<div class="content-cell"> <div class="content-cell">
<!-- 多列表格 -->
<template v-if="row.type === 'MultiColumnTable'"> <template v-if="row.type === 'MultiColumnTable'">
<MultiColumnTable <MultiColumnTable
:title="row.project" :title="row.project"
:columnsPerRow="6"
:records="[]" :records="[]"
:fields="row.content" :fields="row.content"
:ref="(el) => setMultiColumnTableRef(el, row.code)" :ref="(el) => setMultiColumnTableRef(el, row.code)"
class="embedded-table" style="margin:0px;padding:0px"
/> />
</template> </template>
<!-- 附件表格 -->
<template v-else-if="row.type === 'AttachTable'"> <template v-else-if="row.type === 'AttachTable'">
<AttachTable <AttachTable
:title="row.project" :title="row.project"
:records="row.datas" :records="row.datas"
:fields="row.content" :fields="row.content"
:pcode="row.code" :pcode="row.code"
:calcSum="row.calcSum"
:showFooter="row.showFooter"
:ref="(el) => setAttachTableRef(el, row.code)" :ref="(el) => setAttachTableRef(el, row.code)"
class="embedded-table" :disabled="!row.hasRight"
style="margin:0px;padding:0px"
/>
</template>
<!-- Vxe表格 -->
<template v-else-if="row.type === 'VxeTable'">
<MyVxeTable1
:title="row.project"
:data="row.data"
:columns="row.columns"
:pcode="row.code"
:footerData="row.footerData"
:showFooter="row.showFooter"
:ref="(el) => setMyVxeTableRef(el, row.code)"
:disabled="!row.hasRight"
style="margin:0px;padding:0px"
/> />
</template> </template>
<!-- 普通字段渲染 -->
<template v-else> <template v-else>
<template v-for="(item, index) in row.content" :key="index"> <template v-for="(item, index) in row.content" :key="index">
<!-- 文本类型 -->
<span v-if="item.type === 'text'" v-html="item.value"></span> <span v-if="item.type === 'text'" v-html="item.value"></span>
<!-- 换行 -->
<span v-else-if="item.type === 'br'"><br></span> <span v-else-if="item.type === 'br'"><br></span>
<!-- 带缩进的换行 -->
<span v-else-if="item.type === 'brspace'"> <span v-else-if="item.type === 'brspace'">
<br> <br>
<template v-for="i in (item.value || 1)" :key="i"> <template v-for="i in (item.value || 1)" :key="i">
...@@ -86,152 +128,117 @@ ...@@ -86,152 +128,117 @@
</template> </template>
</span> </span>
<template v-else-if="item.type === 'AttachTable'"> <!-- 单选组 -->
<AttachTable
:title="item.project"
:records="item.datas"
:fields="item.content"
:pcode="item.code"
:ref="(el) => setAttachTableRef(el, item.code)"
class="embedded-table"
/>
</template>
<template v-else-if="item.type === 'MultiColumnTable'">
<MultiColumnTable
:title="item.project"
:records="[]"
:fields="item.content"
:ref="(el) => setMultiColumnTableRef(el, item.code)"
class="embedded-table"
/>
</template>
<template v-else-if="item.type === 'yesno'">
<vxe-radio-group v-model="formData[getFieldKey(row.code, item.field)]">
<vxe-radio label="是" content="是"></vxe-radio>
<vxe-radio label="否" content="否"></vxe-radio>
</vxe-radio-group>
<template v-if="item.extraField || item.extraFields">
<div v-if="formData[getFieldKey(row.code, item.field)] === '是'" class="extra-fields-container">
如是,
<template v-if="item.extraField">
{{ item.extraLabel }}
<vxe-input v-model="formData[getFieldKey(row.code, item.extraField)]" class="extra-input"></vxe-input>
<span class="unit">{{ item.unit }}</span>
</template>
<template v-else-if="item.extraFields">
<template v-for="(ccopt, ccind) in item.extraFields" :key="ccind">
<span>{{ ccopt.label }}: </span>
<template v-if="ccopt.formType === 'input'">
<vxe-input v-model="formData[getFieldKey(row.code, ccopt.field)]" class="extra-input"></vxe-input>
</template>
<template v-else-if="ccopt.formType === 'number'">
<vxe-input v-model="formData[getFieldKey(row.code, ccopt.field)]" type="number" class="extra-input"></vxe-input>
<span class="unit">{{ ccopt.unit }}</span>
</template>
<template v-else-if="ccopt.formType === 'checkbox'">
<vxe-checkbox-group v-model="formData[getFieldKey(row.code, ccopt.field)]">
<vxe-checkbox v-for="(opt, optIndex) in ccopt.options" :key="optIndex" :label="opt" :content="opt"></vxe-checkbox>
</vxe-checkbox-group>
</template>
<template v-else-if="ccopt.formType === 'radio'">
<vxe-radio-group v-model="formData[getFieldKey(row.code, ccopt.field)]" :options="ccopt.options">
<vxe-radio v-for="(opt, optIndex) in ccopt.options" :key="optIndex" :label="opt" :content="opt"></vxe-radio>
</vxe-radio-group>
</template>
<template v-else>
<vxe-input v-model="formData[getFieldKey(row.code, ccopt.field)]" :type="ccopt.formType" class="extra-input"></vxe-input>
</template>
<br>
<template v-if="ccopt.otherOption">
其他:<vxe-input v-model="formData[getFieldKey(row.code, ccopt.otherField)]" class="extra-input"></vxe-input>
</template>
<br>
</template>
</template>
</div>
</template>
</template>
<span v-else-if="item.type === 'radio-group'" class="radio-group"> <span v-else-if="item.type === 'radio-group'" class="radio-group">
<vxe-radio-group v-model="formData[getFieldKey(row.code, item.field)]" style="margin-left: 20px;"> <vxe-radio-group
<vxe-radio v-for="(opt, optIndex) in item.options" :key="optIndex" :label="opt" style="width:100%">{{ opt }}</vxe-radio> v-model="formData[getFieldKey(row.code, item.field)]"
</vxe-radio-group> :disabled="!item.hasRight || isRadioDisabled(row.code, item)"
</span> >
<span v-else-if="item.type === 'radio-group-extraFields'" class="radio-group"> <vxe-radio
<vxe-radio-group v-model="formData[getFieldKey(row.code, item.field)]"> v-for="(opt, optIndex) in item.options"
<vxe-radio v-for="(opt, optIndex) in item.options" :key="optIndex" :label="opt.label"> :key="optIndex"
{{ opt.label }} :label="opt"
<template v-if="opt.extraField && formData[getFieldKey(row.code, item.field)] === opt.label"> >
<span>{{ opt.extraLabel }}</span> {{ opt }}
<vxe-input v-model="formData[getFieldKey(row.code, opt.extraField)]" class="extra-input"></vxe-input>
</template>
<template v-if="opt.extraFields && formData[getFieldKey(row.code, item.field)] === opt.label">
<template v-for="(ccopt, ccind) in opt.extraFields" :key="ccind">
<span>{{ ccopt.label }}: </span>
<vxe-input v-model="formData[getFieldKey(row.code, ccopt.field)]" class="extra-input"></vxe-input>
</template>
</template>
</vxe-radio> </vxe-radio>
</vxe-radio-group> </vxe-radio-group>
</span> </span>
<!-- 多选组(带其他选项) -->
<div v-else-if="item.type === 'checkbox-group'"> <div v-else-if="item.type === 'checkbox-group'">
<div style="width:400px;margin-left:30px"> <span class="checkbox-group">
<vxe-checkbox-group v-model="formData[getFieldKey(row.code, item.field)]"> <vxe-checkbox-group
<vxe-checkbox v-for="(opt, optIndex) in item.options" :key="optIndex" :label="opt"> v-model="formData[getFieldKey(row.code, item.field)]"
:disabled="!item.hasRight"
>
<vxe-checkbox
v-for="(opt, optIndex) in item.options"
:key="optIndex"
:label="opt"
>
{{ opt }} {{ opt }}
</vxe-checkbox> </vxe-checkbox>
<template v-if="item.otherOption" > <template v-if="item.otherField">
<vxe-checkbox label="其他"> <div style="width:100%">
<vxe-checkbox label="其他" :disabled="!item.hasRight">
其他: 其他:
<vxe-input v-model="formData[getFieldKey(row.code, item.otherField)]" class="extra-input"
:disabled="!(formData[row.code+'_'+item.field]?.indexOf('其他')>-1)"
></vxe-input>
</vxe-checkbox> </vxe-checkbox>
<vxe-input
v-model="formData[getFieldKey(row.code, item.otherField)]"
:disabled="!isOtherFieldEnabled(row.code, item) || !item.hasRight"
style="width: 50%"
@blur="handleInputBlur(row.code, item.otherField, item.matchedFormula?.formula)"
/>
</div>
</template> </template>
</vxe-checkbox-group> </vxe-checkbox-group>
<!-- 其他选项 -->
</span>
</div> </div>
<!-- 多选带输入框 -->
<div v-else-if="item.type === 'checkboxAndInput'">
<span style="margin-left:20px">
<vxe-checkbox-group
v-model="formData[getFieldKey(row.code, item.field)]"
:disabled="!item.hasRight"
>
<vxe-checkbox
v-for="(opt, optIndex) in item.options"
:key="optIndex"
:label="opt"
:disabled="!item.hasRight"
style="margin-left: 0px;display: block;"
>
{{ opt }}
<vxe-input
type="number"
v-model="formData[getFieldKey(row.code, item.optionItemField[optIndex])]"
:disabled="!item.hasRight"
style="width: 100px;margin: 0px;"
@blur="handleInputBlur(row.code, item.optionItemField[optIndex], item.matchedFormula?.formula)"
/>
<span class="unit"> {{ item.optionItemUint }}</span>
</vxe-checkbox>
</vxe-checkbox-group>
</span>
</div> </div>
<template v-else-if="item.type === 'textarea'">
<vxe-textarea v-model="formData[getFieldKey(row.code, item.field)]" :rows="item.rows" :style="{ width: item.width }"></vxe-textarea> <!-- 普通输入框 -->
</template>
<template v-else> <template v-else>
<div class="input-wrapper"> <div class="input-wrapper">
<vxe-input <vxe-input
:disabled="!item.hasRight || isInputDisabled(row.code, item)"
:type="item.type" :type="item.type"
v-model="formData[getFieldKey(row.code, item.field)]" v-model="formData[getFieldKey(row.code, item.field)]"
size="mini" size="mini"
class="table-input" class="table-input"
:style="item.style"
@blur="handleInputBlur(row.code, item.field, item.matchedFormula?.formula)" @blur="handleInputBlur(row.code, item.field, item.matchedFormula?.formula)"
/> />
<span v-if="item.unit" class="unit">{{ item.unit }}</span> <span class="unit">{{ item.unit }}</span>
<!-- 帮助图标 -->
<span <span
v-if="showHelpIcon(row.code, item.field, item)" v-if="item.hasValidFormula"
class="help-icon" class="help-icon"
@click.stop="toggleTooltip(row.code, item.field)" @click.stop="toggleTooltip(row.code, item.field)"
title="点击查看校验规则"
> >
? ?
</span> </span>
<!-- 错误图标 -->
<span <span
v-if="inputErrors[getFieldKey(row.code, item.field)]" v-if="inputErrors[getFieldKey(row.code, item.field)]"
class="error-icon" class="error-icon"
@click.stop="toggleErrorTooltip(row.code, item.field)" @click.stop="toggleErrorTooltip(row.code, item.field)"
title="点击查看错误详情"
> >
<i class="vxe-icon-error"></i> <i class="vxe-icon-error"></i>
</span> </span>
<div <!-- 错误提示 -->
v-if="showTooltip && hoveredKey === getFieldKey(row.code, item.field)"
class="tooltip"
@click.stop
>
{{ item.matchedFormula?.des || '暂无校验规则' }}
</div>
<div <div
v-if="showErrorTooltip && hoveredErrorKey === getFieldKey(row.code, item.field)" v-if="showErrorTooltip && hoveredErrorKey === getFieldKey(row.code, item.field)"
class="error-tooltip" class="error-tooltip"
...@@ -249,6 +256,15 @@ ...@@ -249,6 +256,15 @@
</span> </span>
</template> </template>
</div> </div>
<!-- 校验规则提示 -->
<div
v-if="showTooltip && hoveredKey === getFieldKey(row.code, item.field)"
class="tooltip"
@click.stop
>
{{ item.matchedFormula?.des || '暂无校验规则' }}
</div>
</div> </div>
</template> </template>
</template> </template>
...@@ -256,34 +272,75 @@ ...@@ -256,34 +272,75 @@
</div> </div>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="remarks" title="备注" width="100">
<!-- 备注列 -->
<vxe-column field="remarks" title="备注" width="60">
<template #default="{ row }"> <template #default="{ row }">
<vxe-textarea :rows="row.remarks.rows" v-model="formData[row.code+'_'+row.remarks.field]" style="height:100%;"> <vxe-textarea
</vxe-textarea> :rows="row.remarks.rows"
v-model="formData[getFieldKey(row.code, row.remarks.field)]"
/>
</template> </template>
</vxe-column> </vxe-column>
</vxe-table> </vxe-table>
<!-- 历史填报检查组件 --> <!-- 校验抽屉 -->
<HistoryFillCheck ref="historyFillCheckRef" v-model="historyDrawerVisible" @closeDrawer="closeHistoryDrawer"/> <ValidationDrawer
ref="validationDrawerRef"
v-model="drawerVisible"
:tableFormData="tableFormData"
@validationResultClick="handleValidationResultClick"
/>
<!-- 历史填报抽屉 -->
<HistoryFillCheck
ref="historyFillCheckRef"
v-model="historyDrawerVisible"
@closeDrawer="closeHistoryDrawer"
/>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, reactive, onMounted, computed } from 'vue'
import { VxeUI, VxeTableInstance } from 'vxe-table'
import 'vxe-table/lib/style.css'
import { useRoute } from 'vue-router'
// 组件导入
import MultiColumnTable from '../tableComponents/MultiColumnTable.vue' import MultiColumnTable from '../tableComponents/MultiColumnTable.vue'
import AttachTable from '../tableComponents/AttachTable.vue' import AttachTable from '../tableComponents/AttachTable.vue'
import HistoryFillCheck from './check/historyFillCheck.vue' import MyVxeTable1 from '../tableComponents/MyVxeTable.vue'
import HistoryFillCheck from './check/HistoryFillCheck.vue'
import ValidationDrawer from './check/ValidationDrawer.vue' import ValidationDrawer from './check/ValidationDrawer.vue'
// 数据导入
import { tableFormData } from '../../data/tb10.data' import { tableFormData } from '../../data/tb10.data'
import { ref, reactive, nextTick, onMounted } from 'vue'
import { VxeUI,VxeTablePropTypes } from 'vxe-table' // API 导入
import { batchSaveOrUpdateBeforeDelete, queryRecord } from '../../record/BaosongTaskRecord.api' import {
import { queryAllTplItemForUser, findUserRightForTplItem } from '../../alloc/BaosongTaskAlloc.api' batchSaveOrUpdate,
queryRecord,
batchSaveOrUpdateBeforeDelete
} from '../../record/BaosongTaskRecord.api'
import {
queryAllTplItemForUser,
findUserRightForTplItem
} from '../../alloc/BaosongTaskAlloc.api'
import { allTplItems } from '../../tpl/BaosongTplItem.api' import { allTplItems } from '../../tpl/BaosongTplItem.api'
import { getTblvalidFormula } from '../../tpl/BaosongDataValid.api' import { getTblvalidFormula } from '../../tpl/BaosongDataValid.api'
import { useRoute } from 'vue-router'
interface FormData { // 类型定义
interface QueryParam {
taskId: number
taskName: string
tplId: number
tplName: string
tplCode: string
comfrom: string
}
interface FormDataItem {
id: number | null id: number | null
taskid: number taskid: number
tplid: number tplid: number
...@@ -294,18 +351,65 @@ interface FormData { ...@@ -294,18 +351,65 @@ interface FormData {
rind: number rind: number
} }
interface FormulaItem {
formula: string
des: string
[key: string]: any
}
interface ContentItem {
type: string
field: string
value?: any
hasRight?: boolean
hasValidFormula?: boolean
matchedFormula?: FormulaItem
relatedFiled?: string
otherField?: string
optionItemField?: string[]
[key: string]: any
}
interface TableRow {
code: string
project: string
type?: string
content: ContentItem[] | any
remarks: { rows: number; field: string }
hasRight?: boolean
[key: string]: any
}
interface InputError {
message: string
formula: string
error?: string
}
interface TplItemMapValue {
pid: number
itemid: number
formTp: string
code: string
}
// 路由和组件引用
const route = useRoute() const route = useRoute()
const tableRef = ref() const tableRef = ref<VxeTableInstance>()
const tplItemMap = ref<Record<string, any>>({}) const historyFillCheckRef = ref()
const historyFillCheckRef = ref<any>(null)
const validationDrawerRef = ref() const validationDrawerRef = ref()
const loading = ref(false)
const formData = reactive<Record<string, any>>({})
const formValues = ref<FormData[]>([])
const childMultiTableRefs = ref<Record<string, any>>({})
const childAttachTableRefs = ref<Record<string, any>>({})
const queryParam = ref({ // 响应式状态
const loading = ref(true)
const historyDrawerVisible = ref(false)
const drawerVisible = ref(false)
const showTooltip = ref(false)
const hoveredKey = ref('')
const showErrorTooltip = ref(false)
const hoveredErrorKey = ref('')
// 数据状态
const queryParam = ref<QueryParam>({
taskId: -1, taskId: -1,
taskName: '', taskName: '',
tplId: -1, tplId: -1,
...@@ -314,483 +418,584 @@ const queryParam = ref({ ...@@ -314,483 +418,584 @@ const queryParam = ref({
comfrom: '' comfrom: ''
}) })
// 权限相关状态 const formData = reactive<Record<string, any>>({})
const formValues = ref<FormDataItem[]>([])
const inputErrors = ref<Record<string, InputError>>({})
const userAllocItems = ref<string[]>([]) const userAllocItems = ref<string[]>([])
const validFormula = ref<any[]>([]) const validFormula = ref<FormulaItem[]>([])
const drawerVisible = ref(false) const tplItemMap = ref<Record<string, TplItemMapValue>>({})
const historyDrawerVisible = ref(false)
const showTooltip = ref(false)
const hoveredKey = ref('')
const showErrorTooltip = ref(false)
const hoveredErrorKey = ref('')
const inputErrors = ref<Record<string, any>>({})
const isInitialized = ref(false)
interface FormulaItem { // 子组件引用
formula: string const childMultiTableRefs = ref<Record<string, any>>({})
des: string const childAttachTableRefs = ref<Record<string, any>>({})
[key: string]: any const childMyVexTableRefs = ref<Record<string, any>>({})
// 计算属性
const fieldKeys = computed(() => Object.keys(formData))
// 工具函数
const getFieldKey = (rowCode: string, field: string): string => {
return `${rowCode}_${field}`
} }
interface InputError { const isRadioDisabled = (rowCode: string, item: ContentItem): boolean => {
message: string if (!item.relatedFiled) return false
formula: string const relatedKey = getFieldKey(rowCode, item.relatedFiled)
error?: string return formData[relatedKey] !== '是'
}
const isInputDisabled = (rowCode: string, item: ContentItem): boolean => {
if (!item.relatedFiled) return false
const relatedKey = getFieldKey(rowCode, item.relatedFiled)
return formData[relatedKey] !== '是'
}
const isOtherFieldEnabled = (rowCode: string, item: ContentItem): boolean => {
const checkboxKey = getFieldKey(rowCode, item.field)
const checkboxValue = formData[checkboxKey] || []
return checkboxValue.includes('其他')
} }
// 初始化
onMounted(async () => { onMounted(async () => {
if (route.query.taskId) { await initPage()
queryParam.value.taskId = Number(route.query.taskId) })
}
if (route.query.taskName) { const initPage = async () => {
queryParam.value.taskName = String(route.query.taskName) try {
} loading.value = true
if (route.query.tplId) { await initQueryParams()
queryParam.value.tplId = Number(route.query.tplId) await Promise.all([
} loadUserRights(),
if (route.query.tplName) { loadValidationFormulas(),
queryParam.value.tplName = String(route.query.tplName) loadTemplateItems()
} ])
if (route.query.tplCode) { await setFormItemRight()
queryParam.value.tplCode = String(route.query.tplCode) await loadTableData()
} } catch (error: any) {
if (route.query.comfrom) { showErrorMessage(`初始化页面失败: ${error.message}`)
queryParam.value.comfrom = String(route.query.comfrom) } finally {
loading.value = false
} }
}
// 设置查询参数 const initQueryParams = () => {
setQueryParams(); const { taskId, taskName, tplId, tplName, tplCode,comfrom } = route.query
// 获取权限和验证公式 if (taskId) queryParam.value.taskId = Number(taskId)
try { if (taskName) queryParam.value.taskName = String(taskName)
if (tplId) queryParam.value.tplId = Number(tplId)
if (tplName) queryParam.value.tplName = String(tplName)
if (tplCode) queryParam.value.tplCode = String(tplCode)
if (comfrom) queryParam.value.comfrom = String(comfrom)
}
const loadUserRights = async () => {
userAllocItems.value = await findUserRightForTplItem({ userAllocItems.value = await findUserRightForTplItem({
tplid: queryParam.value.tplId, tplid: queryParam.value.tplId,
taskid: queryParam.value.taskId taskid: queryParam.value.taskId
}) })
}
const loadValidationFormulas = async () => {
validFormula.value = await getTblvalidFormula({ validFormula.value = await getTblvalidFormula({
tplid: queryParam.value.tplId, tplid: queryParam.value.tplId
}) })
} catch (error) { }
console.error('获取权限或验证公式失败:', error)
}
await setTplItemMap() const loadTemplateItems = async () => {
setFormItemRight() const items = await allTplItems({
await setData() tplid: queryParam.value.tplId
})
isInitialized.value = true tplItemMap.value = items.reduce((acc: Record<string, TplItemMapValue>, item) => {
const key = `${item.pcode}_${item.xmlcode}`
acc[key] = {
pid: item.pid,
itemid: item.id,
formTp: item.formTp,
code: item.xmlcode
}
return acc
}, {})
}
setTimeout(() => { const setFormItemRight = () => {
refreshHelpIcons() tableFormData.forEach((row: TableRow) => {
}, 300) if (row.content && Array.isArray(row.content)) {
}) row.content.forEach((item: ContentItem) => {
if (item.field) {
const key = getFieldKey(row.code, item.field)
item.hasRight = userAllocItems.value.includes(key)
const getFieldKey = (pcode: string | undefined, field: string): string => { if (item.hasRight) {
return pcode ? `${pcode}_${field}` : field const { formula } = findEarliestFormulaForField(validFormula.value, item.field)
item.hasValidFormula = !!formula
item.matchedFormula = formula
}
}
})
}
})
} }
// 保存相关
const saveBatch = async () => { const saveBatch = async () => {
try { try {
loading.value = true if (!await validateForm()) return
formValues.value = []
await prepareFormData()
// Process main form data if (formValues.value.length === 0) {
for (const strKey in formData) { showWarningMessage('没有需要保存的数据')
const valData = formData[strKey] return
if (valData) {
const [pcode, code] = strKey.split('_')
await setFormValues(pcode, code, valData, 1)
} }
await batchSaveOrUpdateBeforeDelete(formValues.value)
showSuccessMessage('保存成功')
} catch (error: any) {
showErrorMessage(`保存失败: ${error.message}`)
} }
}
const validateForm = async (): Promise<boolean> => {
const $table = tableRef.value
if (!$table) return true
const checkResult = $table.validate()
if (!checkResult) {
showErrorMessage('表单验证失败,请检查填写内容')
return false
}
return true
}
await getAttachTableFormData() const prepareFormData = async () => {
await getAllMultiTableFormData() formValues.value = []
if (formValues.value.length > 0) { // 处理主表单数据
await batchSaveOrUpdateBeforeDelete(formValues.value) for (const [key, value] of Object.entries(formData)) {
VxeUI.modal.message({ content: '保存成功', status: 'success' }) if (value !== undefined && value !== null && value !== '') {
} else { const [pcode, code] = key.split('_')
VxeUI.modal.message({ content: '没有需要保存的数据', status: 'warning' }) await addFormValue(pcode, code, value, 1)
} }
} catch (error) {
console.error('保存失败:', error)
VxeUI.modal.message({ content: `保存失败: ${error instanceof Error ? error.message : String(error)}`, status: 'error' })
} finally {
loading.value = false
} }
// 处理子表格数据
await Promise.all([
collectAttachTableData(),
collectMultiTableData(),
collectVxeTableData()
])
} }
const setMultiColumnTableRef = (el: any, code: string) => { const addFormValue = async (pcode: string, code: string, value: any, rind: number) => {
if (el) { if (!value) return
childMultiTableRefs.value[code] = el
const stringValue = Array.isArray(value) ? value.join(',') : String(value)
const key = getFieldKey(pcode, code)
const item = tplItemMap.value[key]
if (!item) return
const formItem: FormDataItem = {
id: null,
rind,
taskid: queryParam.value.taskId,
tplid: queryParam.value.tplId,
tplcode: code,
itemid: item.itemid,
itempid: item.pid,
content: stringValue
} }
formValues.value.push(formItem)
} }
const setAttachTableRef = (el: any, code: string) => { // 数据收集函数
if (el) { const collectAttachTableData = async () => {
childAttachTableRefs.value[code] = el for (const [pcode, child] of Object.entries(childAttachTableRefs.value)) {
if (child) {
const datas = await child.getFormData()
for (const [code, value] of Object.entries(datas)) {
await addFormValue(pcode, code, value, 1)
}
}
} }
} }
const getAllMultiTableFormData = async () => { const collectMultiTableData = async () => {
for (const pcode in childMultiTableRefs.value) { for (const [pcode, child] of Object.entries(childMultiTableRefs.value)) {
const child = childMultiTableRefs.value[pcode]
if (child) { if (child) {
const datas = child.getFormData() const datas = await child.getFormData()
let rind = 0 let rind = 0
for (const obj of datas) { for (const obj of datas) {
rind++ rind++
Object.keys(obj).forEach(code => { for (const [code, value] of Object.entries(obj)) {
setFormValues(pcode, code, obj[code], rind) await addFormValue(pcode, code, value, rind)
}) }
} }
} }
} }
} }
const getAttachTableFormData = async () => { const collectVxeTableData = async () => {
for (const pcode in childAttachTableRefs.value) { for (const [pcode, child] of Object.entries(childMyVexTableRefs.value)) {
const child = childAttachTableRefs.value[pcode]
if (child) { if (child) {
const datas = child.getFormData() const formData = await child.getFormData()
for (const code in datas) { let rind = 0
await setFormValues(pcode, code, datas[code], 1) // 表格数据
for (const obj of formData.datas) {
rind++
for (const [code, value] of Object.entries(obj)) {
await addFormValue(pcode, code, value, rind)
}
}
if (formData.footer) {
for (const [code, value] of Object.entries(formData.footer)) {
await addFormValue(formData.footerPcode, code, value, 1)
}
} }
} }
} }
} }
const setFormValues = async (pcode: string, code: string, valData: any, rind: number) => { // 数据加载
if (!valData) return const loadTableData = async () => {
try {
if(Array.isArray(valData)&& valData.length==0) return loading.value = true
const vals = Array.isArray(valData) ? valData.join(',') : valData // 清空现有数据
const strKey = `${pcode}_${code}` Object.keys(formData).forEach(key => delete formData[key])
const item = tplItemMap.value[strKey]
const { pid, itemid } = item ?? {}
const tempForm: FormData = { const recordData = await queryRecord({
id: null,
rind: rind,
taskid: queryParam.value.taskId, taskid: queryParam.value.taskId,
tplid: queryParam.value.tplId, tplid: queryParam.value.tplId
tplcode: code, })
itemid: itemid,
itempid: pid, // 转换记录数据为便于查找的结构
content: vals const valueMap = recordData.reduce((acc: Record<string, string>, data) => {
const key = `${data.itempid}_${data.itemid}_${data.rind}`
acc[key] = data.content
return acc
}, {})
// 填充表格数据
await fillTableData(valueMap)
} catch (error: any) {
showErrorMessage(`加载数据失败: ${error.message}`)
} finally {
loading.value = false
} }
}
formValues.value.push(tempForm) const fillTableData = async (valueMap: Record<string, string>) => {
for (const row of tableFormData) {
if (!row.type && row.content) {
await fillSimpleFields(row, valueMap)
} else if (row.type === 'AttachTable' && row.datas) {
await fillAttachTable(row, valueMap)
} else if (row.type === 'MultiColumnTable' && row.content) {
await fillMultiColumnTable(row, valueMap)
} else if (row.type === 'VxeTable' && row.columns) {
await fillVxeTable(row, valueMap)
}
}
} }
async function setData() { const fillSimpleFields = async (row: TableRow, valueMap: Record<string, string>) => {
try { if (!row.content || !Array.isArray(row.content)) return
loading.value = true;
const taskId = queryParam.value.taskId; for (const item of row.content) {
const tplid = queryParam.value.tplId; if (!item.field) continue
const key = getFieldKey(row.code, item.field)
const tplItem = tplItemMap.value[key]
if (!tplItem) continue
Object.keys(formData).forEach(key => delete formData[key]); const { pid, itemid, formTp } = tplItem
const valueKey = `${pid}_${itemid}_1`
const dataVal = valueMap[valueKey]
await setTplItemMap(); if (dataVal === undefined) continue
const recordData = await queryRecord({ taskid: taskId, tplid: tplid });
const valueObj = {}; if (formTp === 'checkbox') {
for (const data of recordData) { formData[key] = dataVal.split(',').filter(Boolean)
const key = `${data.itempid}_${data.itemid}_${data.rind}`; } else {
valueObj[key] = data.content; formData[key] = dataVal
} }
const shouldSkip = (key) => {
const refsToCheck = [
childMultiTableRefs.value,
childAttachTableRefs.value,
];
for (const refs of refsToCheck) { // 处理特殊字段类型
for (const pcode of Object.keys(refs)) { if (item.type === 'checkboxAndInput' && item.optionItemField) {
if (key.startsWith(pcode + '_')) { await fillCheckboxInputFields(row, item, valueMap)
return true;
} }
if (item.otherField) {
await fillOtherField(row, item, valueMap)
} }
} }
return false; }
};
for (const strKey of Object.keys(tplItemMap.value)) { const fillCheckboxInputFields = async (
if (shouldSkip(strKey)) { row: TableRow,
continue; item: ContentItem,
valueMap: Record<string, string>
) => {
for (const field of item.optionItemField || []) {
const key = getFieldKey(row.code, field)
const tplItem = tplItemMap.value[key]
if (!tplItem) continue
const { pid, itemid } = tplItem
const valueKey = `${pid}_${itemid}_1`
const dataVal = valueMap[valueKey]
if (dataVal !== undefined) {
formData[key] = dataVal
} }
const item = tplItemMap.value[strKey];
if (!item) continue;
const { pid, itemid, formTp } = item;
const dataVal = valueObj[`${pid}_${itemid}_1`];
if (!dataVal) continue;
if (formTp === 'checkbox') {
formData[strKey] = dataVal?.split(",") || [];
} else {
formData[strKey] = dataVal || "";
} }
}
const fillOtherField = async (
row: TableRow,
item: ContentItem,
valueMap: Record<string, string>
) => {
const key = getFieldKey(row.code, item.otherField!)
const tplItem = tplItemMap.value[key]
if (!tplItem) return
const { pid, itemid } = tplItem
const valueKey = `${pid}_${itemid}_1`
const dataVal = valueMap[valueKey]
if (dataVal !== undefined) {
formData[key] = dataVal
} }
}
for (const pcode of Object.keys(childAttachTableRefs.value)) { const fillAttachTable = async (row: TableRow, valueMap: Record<string, string>) => {
const child = childAttachTableRefs.value[pcode]; const child = childAttachTableRefs.value[row.code]
const matchingKeys = Object.keys(tplItemMap.value).filter(key => if (!child) return
key.startsWith(pcode + '_')
);
const attachTableData = {}; const tableData: Record<string, any> = {}
for (const key of matchingKeys) {
const tmpData = tplItemMap.value[key];
if (!tmpData) continue;
const { pid, itemid, formTp, code } = tmpData; for (const data of row.datas || []) {
const valueKey = `${pid}_${itemid}_1`; for (const [key, value] of Object.entries(data)) {
if (typeof value === 'object' && value.field) {
const fieldKey = getFieldKey(row.code, value.field)
const tplItem = tplItemMap.value[fieldKey]
if (!tplItem) continue
if (formTp === 'checkbox') { const { pid, itemid, formTp, code } = tplItem
attachTableData[code] = valueObj[valueKey]?.split(",") || []; const valueKey = `${pid}_${itemid}_1`
} else { const dataVal = valueMap[valueKey]
attachTableData[code] = valueObj[valueKey] || "";
if (dataVal) {
tableData[code] = formTp === 'checkbox' ? dataVal.split(',') : dataVal
}
} }
} }
child.setFormData(attachTableData);
} }
for (const pcode of Object.keys(childMultiTableRefs.value)) { child.setFormData(tableData)
const child = childMultiTableRefs.value[pcode]; }
const matchingKeys = Object.keys(tplItemMap.value).filter(key =>
key.startsWith(pcode + '_')
);
const rowsMap = {}; const fillMultiColumnTable = async (row: TableRow, valueMap: Record<string, string>) => {
for (const key of matchingKeys) { const child = childMultiTableRefs.value[row.code]
const tmpData = tplItemMap.value[key]; if (!child || !Array.isArray(row.content)) return
if (!tmpData) continue;
const { pid, itemid, code } = tmpData; const rowsMap: Record<string, Record<string, string>> = {}
const valKeys = Object.keys(valueObj).filter(k =>
k.startsWith(`${pid}_${itemid}_`)
);
for (const valKey of valKeys) { for (const item of row.content) {
const parts = valKey.split('_'); if (!item.field) continue
const rind = parts[2];
if (!rowsMap[rind]) { const key = getFieldKey(row.code, item.field)
rowsMap[rind] = {}; const tplItem = tplItemMap.value[key]
} if (!tplItem) continue
rowsMap[rind][code] = valueObj[valKey]; const { pid, itemid, code } = tplItem
const valueKeys = Object.keys(valueMap).filter(k =>
k.startsWith(`${pid}_${itemid}_`)
)
for (const valueKey of valueKeys) {
const [, , rind] = valueKey.split('_')
if (!rowsMap[rind]) {
rowsMap[rind] = {}
} }
rowsMap[rind][code] = valueMap[valueKey]
} }
const tableDatas = Object.values(rowsMap);
nextTick();
child.setFormData(tableDatas);
} }
} catch (error) { const tableDatas = Object.values(rowsMap)
VxeUI.modal.message({ child.setFormData(tableDatas)
content: `加载数据失败: ${error.message}`,
status: 'error'
});
} finally {
loading.value = false;
}
} }
const fillVxeTable = async (row: TableRow, valueMap: Record<string, string>) => {
const child = childMyVexTableRefs.value[row.code]
if (!child || !Array.isArray(row.columns)) return
async function setTplItemMap() { const rowsMap: Record<string, Record<string, string>> = {}
try {
const taskId = queryParam.value.taskId
const tplid = queryParam.value.tplId
const tplItem = await allTplItems({
tplid: tplid
})
tplItemMap.value = tplItem.reduce((acc, item) => { for (const column of row.columns) {
const strKey = `${item.pcode}_${item.xmlcode}` if (!column.field) continue
acc[strKey] = {
pid: item.pid, const key = getFieldKey(row.code, column.field)
itemid: item.id, const tplItem = tplItemMap.value[key]
formTp: item.formTp, if (!tplItem || Object.keys(tplItem).length === 0) continue
code: item.xmlcode
const { pid, itemid, code } = tplItem
const valueKeys = Object.keys(valueMap).filter(k =>
k.startsWith(`${pid}_${itemid}_`)
)
for (const valueKey of valueKeys) {
const [, , rind] = valueKey.split('_')
if (!rowsMap[rind]) {
rowsMap[rind] = {}
} }
return acc rowsMap[rind][code] = valueMap[valueKey]
}, {} as Record<string, any>)
} catch (error) {
console.error('加载数据失败:', error)
VxeUI.modal.message({ content: `加载数据失败: ${error instanceof Error ? error.message : String(error)}`, status: 'error' })
} }
}
const tableDatas = Object.values(rowsMap)
child.setFormData(tableDatas)
} }
// 校验数据 // 校验相关
const checkData = () => { const validateData = () => {
drawerVisible.value = true drawerVisible.value = true
validationDrawerRef.value.setValidateData(validFormula.value, formData) validationDrawerRef.value.setValidateData(validFormula.value,formData);
} }
const handleInputBlur = (rowCode: string, field: string, formula?: string) => { const handleInputBlur = (rowCode: string, field: string, formula?: string) => {
if (!formula) return; if (!formula) return
const key = getFieldKey(rowCode, field); const key = getFieldKey(rowCode, field)
const value = formData[key]; const value = formData[key]
if (!value || value === '') { if (!value || value === '') {
delete inputErrors.value[key]; delete inputErrors.value[key]
return; return
} }
validateFieldFormula(rowCode, field, formula); validateFieldFormula(rowCode, field, formula)
}; }
const validateFieldFormula = (rowCode: string, field: string, formula: string) => { const validateFieldFormula = (rowCode: string, field: string, formula: string) => {
const key = getFieldKey(rowCode, field); const key = getFieldKey(rowCode, field)
try { try {
const expression = buildExpression(formula, rowCode); const expression = buildExpression(formula, rowCode)
const isValid = eval(expression); const isValid = eval(expression)
if (!isValid) { if (!isValid) {
inputErrors.value[key] = { inputErrors.value[key] = {
message: "公式校验失败,请检查填写内容", message: "公式校验失败,请检查填写内容",
formula formula
}; }
} else { } else {
delete inputErrors.value[key]; delete inputErrors.value[key]
} }
} catch (error: any) { } catch (error: any) {
inputErrors.value[key] = { inputErrors.value[key] = {
message: "公式校验失败,请检查填写内容", message: "公式校验失败,请检查填写内容",
formula, formula,
error: error.message error: error.message
};
} }
}; }
}
const buildExpression = (formula: string, rowCode: string): string => { const buildExpression = (formula: string, rowCode: string): string => {
const fieldNames = formula.match(/\b[A-Za-z][A-Za-z0-9_]*\b/g) || []; const fieldNames = formula.match(/\b[A-Za-z][A-Za-z0-9_]*\b/g) || []
const uniqueFields = [...new Set(fieldNames.filter(f => const uniqueFields = [...new Set(fieldNames.filter(f =>
!['and', 'or', 'not', 'equal', 'less', 'greater', 'if', 'else', 'true', 'false'] !['and', 'or', 'not', 'equal', 'less', 'greater', 'if', 'else', 'true', 'false']
.includes(f.toLowerCase()) .includes(f.toLowerCase())
))]; ))]
uniqueFields.sort((a, b) => b.length - a.length); uniqueFields.sort((a, b) => b.length - a.length)
let expression = formula; let expression = formula
for (const fieldName of uniqueFields) { for (const fieldName of uniqueFields) {
const key = getFieldKey(rowCode, fieldName); const key = getFieldKey(rowCode, fieldName)
const value = formData[key]; const value = formData[key]
if (value !== undefined) { if (value !== undefined) {
// 检查字段类型,如果是日期类型,转换为时间戳进行比较
const row = tableFormData.find((r: TableRow) => r.code === rowCode)
let processedValue = value
if (row && row.content && Array.isArray(row.content)) {
const fieldItem = row.content.find((c: ContentItem) => c.field === fieldName)
if (fieldItem && fieldItem.type === 'date') {
// 将日期字符串转换为时间戳(毫秒)
const date = new Date(value)
if (!isNaN(date.getTime())) {
processedValue = date.getTime()
}
}
}
expression = expression.replace( expression = expression.replace(
new RegExp(`\\b${fieldName}\\b`, 'g'), new RegExp(`\\b${fieldName}\\b`, 'g'),
`Number(${value})` `Number(${processedValue})`
); )
} }
} }
return expression; return expression
}; }
// 提示工具相关
const toggleTooltip = (rowCode: string, field: string) => { const toggleTooltip = (rowCode: string, field: string) => {
const key = getFieldKey(rowCode, field); const key = getFieldKey(rowCode, field)
if (hoveredKey.value === key) { if (hoveredKey.value === key) {
showTooltip.value = false; showTooltip.value = false
hoveredKey.value = ''; hoveredKey.value = ''
} else { } else {
showTooltip.value = true; showTooltip.value = true
hoveredKey.value = key; hoveredKey.value = key
} }
}; }
const toggleErrorTooltip = (rowCode: string, field: string) => { const toggleErrorTooltip = (rowCode: string, field: string) => {
const key = getFieldKey(rowCode, field); const key = getFieldKey(rowCode, field)
if (hoveredErrorKey.value === key) { if (hoveredErrorKey.value === key) {
showErrorTooltip.value = false; showErrorTooltip.value = false
hoveredErrorKey.value = ''; hoveredErrorKey.value = ''
} else { } else {
showErrorTooltip.value = true; showErrorTooltip.value = true
hoveredErrorKey.value = key; hoveredErrorKey.value = key
} }
}; }
const closeAllTooltips = () => { const closeAllTooltips = () => {
showTooltip.value = false; showTooltip.value = false
hoveredKey.value = ''; hoveredKey.value = ''
showErrorTooltip.value = false; showErrorTooltip.value = false
hoveredErrorKey.value = ''; hoveredErrorKey.value = ''
};
const showHelpIcon = (rowCode: string, field: string, item: any): boolean => {
if (item.hasValidFormula !== undefined) {
return item.hasValidFormula === true;
}
const key = getFieldKey(rowCode, field);
const hasRight = userAllocItems.value.includes(key);
if (!hasRight) return false;
const formulaResult = findEarliestFormulaForField(validFormula.value, field);
return !!formulaResult.formula;
};
// 处理校验结果点击
const handleValidationResultClick = (result: any) => {
const message = `字段 ${result.field} 的校验结果: ${result.isValid ? '通过' : '失败'}`
const status = result.isValid ? 'success' : 'error'
VxeUI.modal.message({ content: message, status })
} }
// 打开历史填报抽屉 // 历史填报
const handleOpenHistoryDrawer = () => { const handleOpenHistoryDrawer = () => {
historyFillCheckRef.value?.onDrawerShow(queryParam.value.tplId)
historyDrawerVisible.value = true historyDrawerVisible.value = true
} }
// 关闭历史填报抽屉
const closeHistoryDrawer = () => { const closeHistoryDrawer = () => {
historyDrawerVisible.value = false historyDrawerVisible.value = false
}
const setFormItemRight = () => {
console.log('开始设置表单权限...')
console.log('userAllocItems 数量:', userAllocItems.value.length)
console.log('validFormula 数量:', validFormula.value.length)
tableFormData.forEach((row: any) => {
if (row.content && Array.isArray(row.content)) {
row.content.forEach((item: any) => {
if (item.field) {
const key = getFieldKey(row.code, item.field)
item.hasRight = userAllocItems.value.includes(key)
console.log(`字段 ${key}: hasRight = ${item.hasRight}`) }
if (item.hasRight) {
const formulaResult = findEarliestFormulaForField(validFormula.value, item.field)
item.hasValidFormula = !!formulaResult.formula
item.matchedFormula = formulaResult.formula || null
console.log(`字段 ${key}: hasValidFormula = ${item.hasValidFormula}`) // 校验结果处理
} else { const handleValidationResultClick = (result: any) => {
item.hasValidFormula = false const message = `字段 ${result.field} 的校验结果: ${result.isValid ? '通过' : '失败'}`
item.matchedFormula = null const status = result.isValid ? 'success' : 'error'
}
}
})
}
})
console.log('表单权限设置完成') VxeUI.modal.message({ content: message, status })
} }
// 工具函数
const findEarliestFormulaForField = ( const findEarliestFormulaForField = (
formulas: FormulaItem[], formulas: FormulaItem[],
field: string field: string
...@@ -811,185 +1016,129 @@ const findEarliestFormulaForField = ( ...@@ -811,185 +1016,129 @@ const findEarliestFormulaForField = (
return result return result
} }
const refreshHelpIcons = () => { // 消息提示
console.log('刷新帮助图标...') const showSuccessMessage = (message: string) => {
tableFormData.forEach((row: any) => { VxeUI.modal.message({ content: message, status: 'success' })
if (row.content && Array.isArray(row.content)) { }
row.content.forEach((item: any) => {
if (item.field) {
const key = getFieldKey(row.code, item.field)
const hasRight = userAllocItems.value.includes(key)
if (hasRight) { const showWarningMessage = (message: string) => {
const formulaResult = findEarliestFormulaForField(validFormula.value, item.field) VxeUI.modal.message({ content: message, status: 'warning' })
item.hasValidFormula = !!formulaResult.formula }
item.matchedFormula = formulaResult.formula || null
} else {
item.hasValidFormula = false
item.matchedFormula = null
}
}
})
}
})
nextTick(() => { const showErrorMessage = (message: string) => {
}) VxeUI.modal.message({ content: message, status: 'error' })
} }
const mergeCells = ref<VxeTablePropTypes.MergeCells>([ // 子组件引用设置
{ row: 0, col: 1, rowspan: 1, colspan: 2 }, const setMultiColumnTableRef = (el: any, code: string) => {
{ row: 1, col: 1, rowspan: 1, colspan: 2 }, if (el) childMultiTableRefs.value[code] = el
{ row: 2, col: 1, rowspan: 1, colspan: 2 }, }
{ row: 3, col: 1, rowspan: 6, colspan: 1 },
const setAttachTableRef = (el: any, code: string) => {
if (el) childAttachTableRefs.value[code] = el
}
{ row: 9, col: 1, rowspan: 1, colspan: 2}, const setMyVxeTableRef = (el: any, code: string) => {
{ row: 10, col: 1, rowspan: 1, colspan: 2}, if (el) childMyVexTableRefs.value[code] = el
]) }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
// Base table styles
.bank-report-table { .bank-report-table {
font-family: "SimSun", "宋体", serif; font-family: "SimSun", "宋体", serif;
font-size: 12px; font-size: 12px;
color: #000;
margin: 5px auto; margin: 5px auto;
width: 90%; width: 90%;
} position: relative;
.toolbar-info {
margin: 10px;
.info-label {
font-weight: bold;
margin-left: 20px;
&:first-child {
margin-left: 0;
}
}
}
.custom-table { // Shared table styles
.custom-table, .attachment-table {
width: 100%; width: 100%;
border: 1px solid #000; border: 1px solid #000;
border-collapse: collapse;
:deep(.vxe-header--column), .vxe-header--column,
:deep(.vxe-body--column) { .vxe-body--column {
border-right: 1px solid #000; border-right: 1px solid #000;
border-bottom: 1px solid #000; border-bottom: 1px solid #000;
padding: 5px; padding: 5px;
} }
}
} }
/* 加载遮罩层样式 */ // 表格信息文本
.loading-overlay { .table-info-text {
position: absolute; font-weight: bold;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.8);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
}
.loading-spinner {
display: flex;
flex-direction: column;
align-items: center;
}
.spinner {
width: 40px;
height: 40px;
border: 3px solid #f3f3f3;
border-top: 3px solid #3498db;
border-radius: 50%;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
} }
.loading-text { // 项目名称
margin-top: 10px; .project-name {
color: #666; font-weight: bold;
font-size: 14px; font-size: 14px;
} }
// Cell styles
.content-cell { .content-cell {
line-height: 1.8; line-height: 1.8;
padding: 5px;
} }
.project-title { // 表单控件组
font-weight: bold; .radio-group, .checkbox-group {
font-size: 14px; display: inline-block;
} margin-left: 10px;
.table-input,
.vxe-input {
height: 24px;
line-height: 24px;
min-width: 150px;
margin: 0 2px;
padding: 0 5px;
border: none;
border-bottom: 1px solid #333;
background: transparent;
text-align: center;
}
.extra-input { .vxe-radio, .vxe-checkbox {
width: 200px; margin-left: 0px;
margin-left: 5px; white-space: nowrap;
} line-height: 30px;
padding: 0px 10px;
.extra-fields-container { &--label {
margin-left: 40px; font-size: 12px;
margin-top: 5px; }
}
.vxe-radio-group, &--icon {
.vxe-checkbox-group { font-size: 12px;
display: inline-block; }
margin-right: 5px; }
max-width: 99%;
} }
.radio-group, // VXE specific overrides
.checkbox-group { .vxe {
&-radio-group, &-checkbox-group {
display: inline-block; display: inline-block;
max-width: 99%; }
}
.vxe-radio,
.vxe-checkbox {
margin: 10px;
white-space: nowrap;
}
.unit { &-cell {
margin-left: 3px; padding: 5px;
color: #666; }
} }
.embedded-table { .vxe-input {
margin: 0; border-bottom: 1px solid #333;
text-align: center;
margin: 5px 3px;
padding: 0; padding: 0;
border: none; border-top: none;
border-left: none;
border-right: none;
background: transparent;
} }
// 输入框包装器
.input-wrapper { .input-wrapper {
position: relative; position: relative;
display: inline-block; display: inline-block;
} }
// 单位文本
.unit {
margin-left: 5px;
font-size: 12px;
}
// 帮助图标
.help-icon { .help-icon {
margin-left: 5px; margin-left: 5px;
cursor: pointer; cursor: pointer;
...@@ -1004,27 +1153,13 @@ const mergeCells = ref<VxeTablePropTypes.MergeCells>([ ...@@ -1004,27 +1153,13 @@ const mergeCells = ref<VxeTablePropTypes.MergeCells>([
background: #e6f7ff; background: #e6f7ff;
border-radius: 50%; border-radius: 50%;
transition: all 0.3s; transition: all 0.3s;
opacity: 0;
animation: fadeIn 0.5s forwards;
animation-delay: 0.3s;
&:hover { &:hover {
background: #bae7ff; background: #bae7ff;
transform: scale(1.1);
}
}
@keyframes fadeIn {
from {
opacity: 0;
transform: scale(0.8);
}
to {
opacity: 1;
transform: scale(1);
} }
} }
// 错误图标
.error-icon { .error-icon {
margin-left: 5px; margin-left: 5px;
cursor: pointer; cursor: pointer;
...@@ -1042,6 +1177,7 @@ const mergeCells = ref<VxeTablePropTypes.MergeCells>([ ...@@ -1042,6 +1177,7 @@ const mergeCells = ref<VxeTablePropTypes.MergeCells>([
} }
} }
// 提示框
.tooltip, .error-tooltip { .tooltip, .error-tooltip {
position: absolute; position: absolute;
top: 100%; top: 100%;
...@@ -1074,15 +1210,54 @@ const mergeCells = ref<VxeTablePropTypes.MergeCells>([ ...@@ -1074,15 +1210,54 @@ const mergeCells = ref<VxeTablePropTypes.MergeCells>([
.error-tooltip { .error-tooltip {
background: #8b0000; background: #8b0000;
color: #fff; color: #fff;
border: 1px solid #ff4d4f;
&::before { &::before {
content: ''; content: '';
position: absolute; position: absolute;
bottom: 100%; bottom: 100%;
left: 10px; left: 5px;
border-width: 5px; border-width: 5px;
border-style: solid; border-style: solid;
border-color: transparent transparent #8b0000 transparent; border-color: transparent transparent #8b0000 transparent;
} }
} }
// 加载遮罩
.loading-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(255, 255, 255, 0.8);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
}
.loading-spinner {
text-align: center;
}
.spinner {
width: 40px;
height: 40px;
border: 3px solid #f3f3f3;
border-top: 3px solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
margin: 0 auto 10px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.loading-text {
font-size: 14px;
color: #666;
}
</style> </style>
\ No newline at end of file
<template> <template>
<div class="bank-report-table" style="height: 80vh" @click="closeAllTooltips"> <div
class="bank-report-table"
style="height:80vh"
@click="closeAllTooltips"
>
<!-- 加载遮罩层 --> <!-- 加载遮罩层 -->
<div v-if="loading" class="loading-overlay"> <div v-if="loading" class="loading-overlay">
<div class="loading-spinner"> <div class="loading-spinner">
...@@ -8,6 +12,7 @@ ...@@ -8,6 +12,7 @@
</div> </div>
</div> </div>
<!-- 工具栏 -->
<vxe-toolbar> <vxe-toolbar>
<template #buttons> <template #buttons>
<div style="margin:10px"> <div style="margin:10px">
...@@ -43,14 +48,7 @@ ...@@ -43,14 +48,7 @@
</template> </template>
</vxe-toolbar> </vxe-toolbar>
<!-- 校验抽屉 --> <!-- 主表格 -->
<ValidationDrawer
ref="validationDrawerRef"
v-model="drawerVisible"
:tableFormData="tableFormData"
@validationResultClick="handleValidationResultClick"
/>
<vxe-table <vxe-table
border border
ref="tableRef" ref="tableRef"
...@@ -72,15 +70,18 @@ ...@@ -72,15 +70,18 @@
<vxe-column field="content" title="内容"> <vxe-column field="content" title="内容">
<template #default="{ row }"> <template #default="{ row }">
<div class="content-cell"> <div class="content-cell">
<!-- 多列表格 -->
<template v-if="row.type === 'MultiColumnTable'"> <template v-if="row.type === 'MultiColumnTable'">
<MultiColumnTable <MultiColumnTable
:title="row.project" :title="row.project"
:records="[]" :records="[]"
:fields="row.content" :fields="row.content"
:ref="(el) => setMultiColumnTableRef(el, row.code)" :ref="(el) => setMultiColumnTableRef(el, row.code)"
style="margin: 0px; padding: 0px" style="margin:0px;padding:0px"
/> />
</template> </template>
<!-- 附件表格 -->
<template v-else-if="row.type === 'AttachTable'"> <template v-else-if="row.type === 'AttachTable'">
<AttachTable <AttachTable
:title="row.project" :title="row.project"
...@@ -109,162 +110,107 @@ ...@@ -109,162 +110,107 @@
style="margin:0px;padding:0px" style="margin:0px;padding:0px"
/> />
</template> </template>
<!-- 普通字段渲染 -->
<template v-else> <template v-else>
<template v-for="(item, index) in row.content" :key="index"> <template v-for="(item, index) in row.content" :key="index">
<span v-if="item.type === 'text'" v-html="item.value" style="margin-right: 10px"></span> <!-- 文本类型 -->
<span v-else-if="item.type === 'br'"><br /></span> <span v-if="item.type === 'text'" v-html="item.value"></span>
<span v-else-if="item.type === 'brspace'">
<br />
<template v-for="i in item.value || 1" :key="i"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </template>
</span>
<template v-else-if="item.type === 'MultiColumnTable'"> <!-- 换行 -->
<MultiColumnTable <span v-else-if="item.type === 'br'"><br></span>
:title="item.project"
:records="[]"
:fields="item.content"
:ref="(el) => setMultiColumnTableRef(el, item.code)"
style="margin: 0px; padding: 0px"
/>
</template>
<template v-else-if="item.type === 'AttachTable'"> <!-- 带缩进的换行 -->
<AttachTable <span v-else-if="item.type === 'brspace'">
:title="item.project" <br>
:records="item.datas" <template v-for="i in (item.value || 1)" :key="i">
:fields="item.content" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
:pcode="item.code"
:calcSum="item.calcSum"
:showFooter="item.showFooter"
:ref="(el) => setAttachTableRef(el, item.code)"
style="margin: 0px; padding: 0px"
/>
</template> </template>
</span>
<!-- 单选组 -->
<span v-else-if="item.type === 'radio-group'" class="radio-group"> <span v-else-if="item.type === 'radio-group'" class="radio-group">
<vxe-radio-group v-model="formData[row.code + '_' + item.field]"> <vxe-radio-group
<vxe-radio v-for="(opt, optIndex) in item.options" :key="optIndex" :label="opt">{{ opt }}</vxe-radio> v-model="formData[getFieldKey(row.code, item.field)]"
:disabled="!item.hasRight || isRadioDisabled(row.code, item)"
>
<vxe-radio
v-for="(opt, optIndex) in item.options"
:key="optIndex"
:label="opt"
>
{{ opt }}
</vxe-radio>
</vxe-radio-group> </vxe-radio-group>
</span> </span>
<div v-else-if="item.type === 'radio-group-extraFields'" class="radio-group">
<vxe-radio-group v-model="formData[row.code + '_' + item.field]"> <!-- 多选组(带其他选项) -->
<vxe-radio v-for="(opt, optIndex) in item.options" :key="optIndex" :label="opt.value">{{ opt.label }}</vxe-radio> <div v-else-if="item.type === 'checkbox-group'">
</vxe-radio-group> <span class="checkbox-group">
<div v-if="formData[row.code + '_' + item.field]" class="extra-fields"> <vxe-checkbox-group
<template v-for="(option, optIndex) in item.options" :key="optIndex"> v-model="formData[getFieldKey(row.code, item.field)]"
<template v-if="option.value === formData[row.code + '_' + item.field] && option.extraFields"> :disabled="!item.hasRight"
<template v-for="(ccopt, ccind) in option.extraFields" :key="ccind"> >
<span>{{ ccopt.label }}: </span> <vxe-checkbox
<template v-if="ccopt.formType === 'number'"> v-for="(opt, optIndex) in item.options"
<vxe-input v-model="formData[row.code + '_' + ccopt.field]" type="number" style="width: 80px"></vxe-input> :key="optIndex"
</template> :label="opt"
<template v-else-if="ccopt.formType === 'input'"> >
<vxe-input v-model="formData[row.code + '_' + ccopt.field]" style="width: 250px"></vxe-input>
</template>
<template v-else>
<vxe-input v-model="formData[row.code + '_' + ccopt.field]" :type="ccopt.formType" style="width: 100px"></vxe-input>
</template>
<span class="unit"> {{ ccopt.unit }}</span>
</template>
</template>
</template>
</div>
</div>
<div v-else-if="item.type === 'checkbox-group'" class="checkbox-group">
<span class="checkbox-group" style="max-width: 800px; margin-left: 20px">
<vxe-checkbox-group v-model="formData[row.code + '_' + item.field]">
<vxe-checkbox v-for="(opt, optIndex) in item.options" :key="optIndex" :label="opt" style="line-height: 30px; margin-left: 0px">
{{ opt }} {{ opt }}
</vxe-checkbox> </vxe-checkbox>
<template v-if="item.otherOption"> <template v-if="item.otherField">
<vxe-checkbox label="其他" style="margin: 0px"> 其他: </vxe-checkbox> <div style="width:100%">
<vxe-checkbox label="其他" :disabled="!item.hasRight">
其他:
</vxe-checkbox>
<vxe-input <vxe-input
v-model="formData[row.code + '_' + item.otherField]" v-model="formData[getFieldKey(row.code, item.otherField)]"
:disabled="!(formData[row.code + '_' + item.field]?.indexOf('其他') > -1)" :disabled="!isOtherFieldEnabled(row.code, item) || !item.hasRight"
style="width: 300px" style="width: 50%"
> @blur="handleInputBlur(row.code, item.otherField, item.matchedFormula?.formula)"
</vxe-input> />
</div>
</template> </template>
</vxe-checkbox-group> </vxe-checkbox-group>
<!-- 其他选项 -->
</span> </span>
</div> </div>
<!-- 多选带输入框 -->
<div v-else-if="item.type === 'checkboxAndInput'"> <div v-else-if="item.type === 'checkboxAndInput'">
<span class="checkbox-group"> <span style="margin-left:20px">
<vxe-checkbox-group v-model="formData[row.code + '_' + item.field]"> <vxe-checkbox-group
<vxe-checkbox v-for="(opt, optIndex) in item.options" :key="optIndex" :label="opt" style="display: block; margin: 0px 0px"> v-model="formData[getFieldKey(row.code, item.field)]"
:disabled="!item.hasRight"
>
<vxe-checkbox
v-for="(opt, optIndex) in item.options"
:key="optIndex"
:label="opt"
:disabled="!item.hasRight"
style="margin-left: 0px;display: block;"
>
{{ opt }} {{ opt }}
<vxe-input <vxe-input
type="number" type="number"
v-model="formData[row.code + '_' + item.optionItemField[optIndex]]" v-model="formData[getFieldKey(row.code, item.optionItemField[optIndex])]"
style="width: 100px; margin: 0px" :disabled="!item.hasRight"
> style="width: 100px;margin: 0px;"
</vxe-input> @blur="handleInputBlur(row.code, item.optionItemField[optIndex], item.matchedFormula?.formula)"
/>
<span class="unit"> {{ item.optionItemUint }}</span> <span class="unit"> {{ item.optionItemUint }}</span>
</vxe-checkbox> </vxe-checkbox>
</vxe-checkbox-group> </vxe-checkbox-group>
</span> </span>
</div> </div>
<div v-else-if="item.type === 'yesno'" class="yesno-group">
<vxe-radio-group v-model="formData[row.code + '_' + item.field]"> <!-- 普通输入框 -->
<vxe-radio label="是"></vxe-radio>
<vxe-radio label="否"></vxe-radio>
</vxe-radio-group>
<div v-if="formData[row.code + '_' + item.field] === '是'" class="extra-fields">
<!-- 处理单个extraField的情况 -->
<template v-if="item.extraField">
<div style="margin-top: 5px">
<span>{{ item.extraLabel || '' }}: </span>
<vxe-input v-model="formData[row.code + '_' + item.extraField]" style="width: 100px"></vxe-input>
<span v-if="item.unit" class="unit"> {{ item.unit }}</span>
</div>
</template>
<!-- 处理extraFields数组的情况 -->
<template v-else-if="item.extraFields">
<template v-for="(ccopt, ccind) in item.extraFields" :key="ccind">
<div style="margin-top: 5px">
<span>{{ ccopt.label }}: </span>
<template v-if="ccopt.formType === 'input'">
<vxe-input v-model="formData[row.code + '_' + ccopt.field]" style="width: 250px"></vxe-input>
</template>
<template v-else-if="ccopt.formType === 'checkbox'">
<vxe-checkbox-group v-model="formData[row.code + '_' + ccopt.field]">
<vxe-checkbox v-for="(opt, optIndex) in ccopt.options" :key="optIndex" :label="opt">{{ opt }}</vxe-checkbox>
</vxe-checkbox-group>
<template v-if="ccopt.otherOption">
<div style="margin-top: 5px; margin-left: 20px">
其他:<vxe-input
v-model="formData[row.code + '_' + ccopt.otherField]"
:disabled="
!(
Array.isArray(formData[row.code + '_' + ccopt.field]) &&
formData[row.code + '_' + ccopt.field].indexOf('其他') > -1
)
"
style="width: 200px"
>
</vxe-input>
</div>
</template>
</template>
<template v-else-if="ccopt.formType === 'radio'">
<vxe-radio-group v-model="formData[row.code + '_' + ccopt.field]">
<vxe-radio v-for="(opt, optIndex) in ccopt.options" :key="optIndex" :label="opt">{{ opt }}</vxe-radio>
</vxe-radio-group>
<template v-if="ccopt.otherOption && formData[row.code + '_' + ccopt.field] === '其他'">
<div style="margin-top: 5px; margin-left: 20px">
其他:<vxe-input v-model="formData[row.code + '_' + ccopt.otherField]" style="width: 200px"></vxe-input>
</div>
</template>
</template>
</div>
</template>
</template>
</div>
</div>
<template v-else> <template v-else>
<div class="input-wrapper"> <div class="input-wrapper">
<vxe-input <vxe-input
:disabled="!item.hasRight || isInputDisabled(row.code, item)"
:type="item.type" :type="item.type"
v-model="formData[getFieldKey(row.code, item.field)]" v-model="formData[getFieldKey(row.code, item.field)]"
size="mini" size="mini"
...@@ -272,14 +218,13 @@ ...@@ -272,14 +218,13 @@
:style="item.style" :style="item.style"
@blur="handleInputBlur(row.code, item.field, item.matchedFormula?.formula)" @blur="handleInputBlur(row.code, item.field, item.matchedFormula?.formula)"
/> />
<span class="unit"> {{ item.unit }}</span> <span class="unit">{{ item.unit }}</span>
<!-- 帮助图标 - 修改这里 --> <!-- 帮助图标 -->
<span <span
v-if="showHelpIcon(row.code, item.field, item)" v-if="item.hasValidFormula"
class="help-icon" class="help-icon"
@click.stop="toggleTooltip(row.code, item.field)" @click.stop="toggleTooltip(row.code, item.field)"
title="点击查看校验规则"
> >
? ?
</span> </span>
...@@ -289,7 +234,6 @@ ...@@ -289,7 +234,6 @@
v-if="inputErrors[getFieldKey(row.code, item.field)]" v-if="inputErrors[getFieldKey(row.code, item.field)]"
class="error-icon" class="error-icon"
@click.stop="toggleErrorTooltip(row.code, item.field)" @click.stop="toggleErrorTooltip(row.code, item.field)"
title="点击查看错误详情"
> >
<i class="vxe-icon-error"></i> <i class="vxe-icon-error"></i>
</span> </span>
...@@ -315,7 +259,7 @@ ...@@ -315,7 +259,7 @@
<!-- 校验规则提示 --> <!-- 校验规则提示 -->
<div <div
v-if="showTooltip && hoveredKey === getFieldKey(row.code, item.field) && item.matchedFormula" v-if="showTooltip && hoveredKey === getFieldKey(row.code, item.field)"
class="tooltip" class="tooltip"
@click.stop @click.stop
> >
...@@ -328,812 +272,841 @@ ...@@ -328,812 +272,841 @@
</div> </div>
</template> </template>
</vxe-column> </vxe-column>
</vxe-table> </vxe-table>
<!-- 历史填报检查组件 --> <!-- 校验抽屉 -->
<HistoryFillCheck ref="historyFillCheckRef" v-model="historyDrawerVisible" @close-drawer="closeHistoryDrawer" /> <ValidationDrawer
<!-- 原有检查组件 --> ref="validationDrawerRef"
<CheckTbData ref="refCheckTbData"></CheckTbData> v-model="drawerVisible"
:tableFormData="tableFormData"
@validationResultClick="handleValidationResultClick"
/>
<!-- 历史填报抽屉 -->
<HistoryFillCheck
ref="historyFillCheckRef"
v-model="historyDrawerVisible"
@closeDrawer="closeHistoryDrawer"
/>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import MultiColumnTable from '../tableComponents/MultiColumnTable.vue'; import { ref, reactive, onMounted, computed } from 'vue'
import AttachTable from '../tableComponents/AttachTable.vue'; import { VxeUI, VxeTableInstance } from 'vxe-table'
import MyVxeTable1 from '../tableComponents/MyVxeTable.vue';
import CheckTbData from './CheckTbData.vue'; import 'vxe-table/lib/style.css'
import HistoryFillCheck from './check/historyFillCheck.vue'; import { useRoute } from 'vue-router'
import ValidationDrawer from './check/ValidationDrawer.vue'; // 组件导入
import { tableFormData } from '../../data/tb6.data'; import MultiColumnTable from '../tableComponents/MultiColumnTable.vue'
import { ref, reactive, nextTick, onMounted, toRaw, computed, watch } from 'vue'; import AttachTable from '../tableComponents/AttachTable.vue'
import { VxeUI, VxeToolbarInstance, VxeToolbarPropTypes } from 'vxe-table'; import MyVxeTable1 from '../tableComponents/MyVxeTable.vue'
import { batchSaveOrUpdate, queryRecord, batchSaveOrUpdateBeforeDelete } from '../../record/BaosongTaskRecord.api'; import HistoryFillCheck from './check/HistoryFillCheck.vue'
import { queryAllTplItemForUser, findUserRightForTplItem } from '../../alloc/BaosongTaskAlloc.api'; import ValidationDrawer from './check/ValidationDrawer.vue'
import { allTplItems } from '../../tpl/BaosongTplItem.api';
import { getTblvalidFormula } from '../../tpl/BaosongDataValid.api'; // 数据导入
import { useRoute } from 'vue-router'; import { tableFormData } from '../../data/tb6.data'
const refCheckTbData = ref(); // API 导入
const historyFillCheckRef = ref<any>(null); import {
const validationDrawerRef = ref(); batchSaveOrUpdate,
queryRecord,
const route = useRoute(); batchSaveOrUpdateBeforeDelete
const tableRef = ref(); } from '../../record/BaosongTaskRecord.api'
const tplItemMap = ref({}); import {
const queryParam = ref({ queryAllTplItemForUser,
findUserRightForTplItem
} from '../../alloc/BaosongTaskAlloc.api'
import { allTplItems } from '../../tpl/BaosongTplItem.api'
import { getTblvalidFormula } from '../../tpl/BaosongDataValid.api'
// 类型定义
interface QueryParam {
taskId: number
taskName: string
tplId: number
tplName: string
tplCode: string
comfrom: string
}
interface FormDataItem {
id: number | null
taskid: number
tplid: number
itemid?: number
itempid?: number
content: string
tplcode: string
rind: number
}
interface FormulaItem {
formula: string
des: string
[key: string]: any
}
interface ContentItem {
type: string
field: string
value?: any
hasRight?: boolean
hasValidFormula?: boolean
matchedFormula?: FormulaItem
relatedFiled?: string
otherField?: string
optionItemField?: string[]
[key: string]: any
}
interface TableRow {
code: string
project: string
type?: string
content: ContentItem[] | any
remarks: { rows: number; field: string }
hasRight?: boolean
[key: string]: any
}
interface InputError {
message: string
formula: string
error?: string
}
interface TplItemMapValue {
pid: number
itemid: number
formTp: string
code: string
}
// 路由和组件引用
const route = useRoute()
const tableRef = ref<VxeTableInstance>()
const historyFillCheckRef = ref()
const validationDrawerRef = ref()
// 响应式状态
const loading = ref(true)
const historyDrawerVisible = ref(false)
const drawerVisible = ref(false)
const showTooltip = ref(false)
const hoveredKey = ref('')
const showErrorTooltip = ref(false)
const hoveredErrorKey = ref('')
// 数据状态
const queryParam = ref<QueryParam>({
taskId: -1, taskId: -1,
taskName: '', taskName: '',
tplId: -1, tplId: -1,
tplName: '', tplName: '',
tplCode: '', tplCode: '',
comfrom: '' comfrom: ''
}); })
const formData = reactive<Record<string, any>>({})
const formValues = ref<FormDataItem[]>([])
const inputErrors = ref<Record<string, InputError>>({})
const userAllocItems = ref<string[]>([])
const validFormula = ref<FormulaItem[]>([])
const tplItemMap = ref<Record<string, TplItemMapValue>>({})
// 子组件引用
const childMultiTableRefs = ref<Record<string, any>>({})
const childAttachTableRefs = ref<Record<string, any>>({})
const childMyVexTableRefs = ref<Record<string, any>>({})
// 计算属性
const fieldKeys = computed(() => Object.keys(formData))
// 工具函数
const getFieldKey = (rowCode: string, field: string): string => {
return `${rowCode}_${field}`
}
const isRadioDisabled = (rowCode: string, item: ContentItem): boolean => {
if (!item.relatedFiled) return false
const relatedKey = getFieldKey(rowCode, item.relatedFiled)
return formData[relatedKey] !== '是'
}
const isInputDisabled = (rowCode: string, item: ContentItem): boolean => {
if (!item.relatedFiled) return false
const relatedKey = getFieldKey(rowCode, item.relatedFiled)
return formData[relatedKey] !== '是'
}
const isOtherFieldEnabled = (rowCode: string, item: ContentItem): boolean => {
const checkboxKey = getFieldKey(rowCode, item.field)
const checkboxValue = formData[checkboxKey] || []
return checkboxValue.includes('其他')
}
// 初始化
onMounted(async () => {
await initPage()
})
const initPage = async () => {
try {
loading.value = true
await initQueryParams()
await Promise.all([
loadUserRights(),
loadValidationFormulas(),
loadTemplateItems()
])
await setFormItemRight()
await loadTableData()
} catch (error: any) {
showErrorMessage(`初始化页面失败: ${error.message}`)
} finally {
loading.value = false
}
}
// 权限相关状态 const initQueryParams = () => {
const userAllocItems = ref<string[]>([]); const { taskId, taskName, tplId, tplName, tplCode,comfrom } = route.query
const validFormula = ref<any[]>([]);
const drawerVisible = ref(false);
const historyDrawerVisible = ref(false);
const showTooltip = ref(false);
const hoveredKey = ref('');
const showErrorTooltip = ref(false);
const hoveredErrorKey = ref('');
const isInitialized = ref(false);
interface FormData { if (taskId) queryParam.value.taskId = Number(taskId)
id: number | null; if (taskName) queryParam.value.taskName = String(taskName)
taskid: number; if (tplId) queryParam.value.tplId = Number(tplId)
tplid: number; if (tplName) queryParam.value.tplName = String(tplName)
itemid?: number; if (tplCode) queryParam.value.tplCode = String(tplCode)
itempid?: number; if (comfrom) queryParam.value.comfrom = String(comfrom)
content: string; }
tplcode: string;
rind: number;
}
interface FormulaItem { const loadUserRights = async () => {
formula: string; userAllocItems.value = await findUserRightForTplItem({
des: string; tplid: queryParam.value.tplId,
[key: string]: any; taskid: queryParam.value.taskId
} })
}
interface InputError { const loadValidationFormulas = async () => {
message: string; validFormula.value = await getTblvalidFormula({
formula: string; tplid: queryParam.value.tplId
error?: string; })
} }
const loadTemplateItems = async () => {
const items = await allTplItems({
tplid: queryParam.value.tplId
})
tplItemMap.value = items.reduce((acc: Record<string, TplItemMapValue>, item) => {
const key = `${item.pcode}_${item.xmlcode}`
acc[key] = {
pid: item.pid,
itemid: item.id,
formTp: item.formTp,
code: item.xmlcode
}
return acc
}, {})
}
const setFormItemRight = () => {
tableFormData.forEach((row: TableRow) => {
if (row.content && Array.isArray(row.content)) {
row.content.forEach((item: ContentItem) => {
if (item.field) {
const key = getFieldKey(row.code, item.field)
item.hasRight = userAllocItems.value.includes(key)
onMounted(async () => { if (item.hasRight) {
if (route.query.taskId) { const { formula } = findEarliestFormulaForField(validFormula.value, item.field)
queryParam.value.taskId = Number(route.query.taskId); item.hasValidFormula = !!formula
} item.matchedFormula = formula
if (route.query.taskName) {
queryParam.value.taskName = String(route.query.taskName);
}
if (route.query.tplId) {
queryParam.value.tplId = Number(route.query.tplId);
}
if (route.query.tplName) {
queryParam.value.tplName = String(route.query.tplName);
} }
if (route.query.tplCode) {
queryParam.value.tplCode = String(route.query.tplCode);
} }
if (route.query.comfrom) { })
queryParam.value.comfrom = String(route.query.comfrom);
} }
})
}
// 初始化数据 // 保存相关
await refCheckTbData.value.initData(); const saveBatch = async () => {
// 获取权限和验证公式
try { try {
userAllocItems.value = await findUserRightForTplItem({ if (!await validateForm()) return
tplid: queryParam.value.tplId,
taskid: queryParam.value.taskId,
});
validFormula.value = await getTblvalidFormula({ await prepareFormData()
tplid: queryParam.value.tplId,
});
console.log('获取到的权限:', userAllocItems.value.length); if (formValues.value.length === 0) {
console.log('获取到的公式:', validFormula.value.length); showWarningMessage('没有需要保存的数据')
} catch (error) { return
console.error('获取权限或验证公式失败:', error);
} }
await setTplItemMap(); await batchSaveOrUpdateBeforeDelete(formValues.value)
await setFormItemRight(); showSuccessMessage('保存成功')
await setData(); } catch (error: any) {
showErrorMessage(`保存失败: ${error.message}`)
// 标记初始化完成 }
isInitialized.value = true; }
// 延迟刷新一次,确保问号图标显示
setTimeout(() => {
refreshHelpIcons();
}, 300);
});
const loading = ref(false); const validateForm = async (): Promise<boolean> => {
const formData = reactive({}); const $table = tableRef.value
const formValues = ref<FormData[]>([]); if (!$table) return true
const inputErrors = ref<Record<string, InputError>>({});
const fieldKeys = computed(() => Object.keys(formData)); const checkResult = $table.validate()
if (!checkResult) {
showErrorMessage('表单验证失败,请检查填写内容')
return false
}
return true
}
const getFieldKey = (rowCode: string, field: string): string => { const prepareFormData = async () => {
return `${rowCode}_${field}`; formValues.value = []
};
// 添加帮助图标显示条件计算 // 处理主表单数据
const showHelpIcon = (rowCode: string, field: string, item: any): boolean => { for (const [key, value] of Object.entries(formData)) {
// 如果已经有 hasValidFormula 属性,直接使用 if (value !== undefined && value !== null && value !== '') {
if (item.hasValidFormula !== undefined) { const [pcode, code] = key.split('_')
return item.hasValidFormula === true; await addFormValue(pcode, code, value, 1)
}
} }
// 否则重新计算 // 处理子表格数据
const key = getFieldKey(rowCode, field); await Promise.all([
const hasRight = userAllocItems.value.includes(key); collectAttachTableData(),
collectMultiTableData(),
collectVxeTableData()
])
}
if (!hasRight) return false; const addFormValue = async (pcode: string, code: string, value: any, rind: number) => {
if (!value) return
const formulaResult = findEarliestFormulaForField(validFormula.value, field); const stringValue = Array.isArray(value) ? value.join(',') : String(value)
return !!formulaResult.formula; const key = getFieldKey(pcode, code)
}; const item = tplItemMap.value[key]
const saveBatch = async () => { if (!item) return
try {
formValues.value = [];
await getFillDatas();
if (formValues.value.length > 0) {
await batchSaveOrUpdateBeforeDelete(formValues.value);
VxeUI.modal.message({ content: '保存成功', status: 'success' });
} else {
VxeUI.modal.message({ content: '没有需要保存的数据', status: 'warning' });
}
} catch (error: any) {
VxeUI.modal.message({ content: `保存失败: ${error.message}`, status: 'error' });
} finally {
loading.value = false;
}
};
const getFillDatas = async () => { const formItem: FormDataItem = {
try { id: null,
formValues.value = []; rind,
taskid: queryParam.value.taskId,
for (const strKey in formData) { tplid: queryParam.value.tplId,
const valData = formData[strKey]; tplcode: code,
if (valData !== undefined && valData !== '') { itemid: item.itemid,
let tmpAry = strKey.split('_'); itempid: item.pid,
await setFormValues(tmpAry[0], tmpAry[1], valData, 1); content: stringValue
}
}
await getAttachTableFormData();
await getAllMultiTableFormData();
await getVxeTableFormData();
} catch (error) {
console.log(error);
} finally {
} }
};
const childMultiTableRefs = ref({}); formValues.value.push(formItem)
const setMultiColumnTableRef = (el: any, index: string) => { }
if (el) {
childMultiTableRefs.value[index] = el;
}
};
const getAllMultiTableFormData = async () => { // 数据收集函数
for (const pcode in childMultiTableRefs.value) { const collectAttachTableData = async () => {
const child = childMultiTableRefs.value[pcode]; for (const [pcode, child] of Object.entries(childAttachTableRefs.value)) {
if (child) { if (child) {
const datas = await child.getFormData(); const datas = await child.getFormData()
let rind = 0; for (const [code, value] of Object.entries(datas)) {
for (const obj of datas) { await addFormValue(pcode, code, value, 1)
rind++;
Object.keys(obj).forEach((code) => {
setFormValues(pcode, code, obj[code], rind);
});
}
} }
} }
};
const childAttachTableRefs = ref({});
const setAttachTableRef = (el: any, index: string) => {
if (el) {
childAttachTableRefs.value[index] = el; // 保存子组件实例
}
};
const childMyVexTableRefs = ref({});
const setMyVxeTableRef = (el: any, index: string) => {
if (el) {
childMyVexTableRefs.value[index] = el; // 保存子组件实例
} }
}; }
const getAttachTableFormData = async () => { const collectMultiTableData = async () => {
for (const pcode in childAttachTableRefs.value) { for (const [pcode, child] of Object.entries(childMultiTableRefs.value)) {
const child = childAttachTableRefs.value[pcode];
if (child) { if (child) {
const datas = await child.getFormData(); const datas = await child.getFormData()
for (const code in datas) { let rind = 0
await setFormValues(pcode, code, datas[code], 1); for (const obj of datas) {
rind++
for (const [code, value] of Object.entries(obj)) {
await addFormValue(pcode, code, value, rind)
}
} }
} }
} }
}; }
const getVxeTableFormData = async () => { const collectVxeTableData = async () => {
for (const pcode in childMyVexTableRefs.value) { for (const [pcode, child] of Object.entries(childMyVexTableRefs.value)) {
const child = childMyVexTableRefs.value[pcode];
if (child) { if (child) {
const formData = await child.getFormData(); const formData = await child.getFormData()
console.log('formData', formData); let rind = 0
let rind = 0; // 表格数据
for (const obj of formData.datas) { for (const obj of formData.datas) {
rind++; rind++
Object.keys(obj).forEach((code) => { for (const [code, value] of Object.entries(obj)) {
setFormValues(pcode, code, obj[code], rind); await addFormValue(pcode, code, value, rind)
}); }
} }
if (formData.footer) { if (formData.footer) {
Object.keys(formData.footer).forEach((code) => { for (const [code, value] of Object.entries(formData.footer)) {
setFormValues(pcode, code, formData.footer[code], 1); await addFormValue(formData.footerPcode, code, value, 1)
});
} }
} }
} }
}; }
}
const setFormValues = async (pcode, code, valData, rind) => { // 数据加载
if (!valData) return; const loadTableData = async () => {
let vals = Array.isArray(valData) ? valData.join(',') : valData; try {
let strKey = pcode + '_' + code; loading.value = true
const item = tplItemMap.value[strKey];
const { pid, itemid } = item ?? {};
let tempForm: FormData = { // 清空现有数据
id: null, Object.keys(formData).forEach(key => delete formData[key])
rind: rind,
const recordData = await queryRecord({
taskid: queryParam.value.taskId, taskid: queryParam.value.taskId,
tplid: queryParam.value.tplId, tplid: queryParam.value.tplId
tplcode: code, })
itemid: itemid,
itempid: pid, // 转换记录数据为便于查找的结构
content: vals, const valueMap = recordData.reduce((acc: Record<string, string>, data) => {
}; const key = `${data.itempid}_${data.itemid}_${data.rind}`
formValues.value.push(tempForm); acc[key] = data.content
}; return acc
}, {})
// 校验数据
const validateData = () => { // 填充表格数据
drawerVisible.value = true; await fillTableData(valueMap)
validationDrawerRef.value.setValidateData(validFormula.value,formData); } catch (error: any) {
}; showErrorMessage(`加载数据失败: ${error.message}`)
} finally {
loading.value = false
}
}
const handleInputBlur = (rowCode: string, field: string, formula?: string) => { const fillTableData = async (valueMap: Record<string, string>) => {
if (!formula) return; for (const row of tableFormData) {
if (!row.type && row.content) {
await fillSimpleFields(row, valueMap)
} else if (row.type === 'AttachTable' && row.datas) {
await fillAttachTable(row, valueMap)
} else if (row.type === 'MultiColumnTable' && row.content) {
await fillMultiColumnTable(row, valueMap)
} else if (row.type === 'VxeTable' && row.columns) {
await fillVxeTable(row, valueMap)
}
}
}
const key = getFieldKey(rowCode, field); const fillSimpleFields = async (row: TableRow, valueMap: Record<string, string>) => {
const value = formData[key]; if (!row.content || !Array.isArray(row.content)) return
if (!value || value === '') { for (const item of row.content) {
delete inputErrors.value[key]; if (!item.field) continue
return;
}
validateFieldFormula(rowCode, field, formula); const key = getFieldKey(row.code, item.field)
}; const tplItem = tplItemMap.value[key]
if (!tplItem) continue
const validateFieldFormula = (rowCode: string, field: string, formula: string) => { const { pid, itemid, formTp } = tplItem
const key = getFieldKey(rowCode, field); const valueKey = `${pid}_${itemid}_1`
const dataVal = valueMap[valueKey]
try { if (dataVal === undefined) continue
const expression = buildExpression(formula, rowCode);
const isValid = eval(expression); if (formTp === 'checkbox') {
if (!isValid) { formData[key] = dataVal.split(',').filter(Boolean)
inputErrors.value[key] = {
message: "公式校验失败,请检查填写内容",
formula
};
} else { } else {
delete inputErrors.value[key]; formData[key] = dataVal
}
} catch (error: any) {
inputErrors.value[key] = {
message: "公式校验失败,请检查填写内容",
formula,
error: error.message
};
} }
};
const buildExpression = (formula: string, rowCode: string): string => {
const fieldNames = formula.match(/\b[A-Za-z][A-Za-z0-9_]*\b/g) || [];
const uniqueFields = [...new Set(fieldNames.filter(f =>
!['and', 'or', 'not', 'equal', 'less', 'greater', 'if', 'else', 'true', 'false']
.includes(f.toLowerCase())
))];
uniqueFields.sort((a, b) => b.length - a.length); // 处理特殊字段类型
if (item.type === 'checkboxAndInput' && item.optionItemField) {
await fillCheckboxInputFields(row, item, valueMap)
}
let expression = formula; if (item.otherField) {
for (const fieldName of uniqueFields) { await fillOtherField(row, item, valueMap)
const key = getFieldKey(rowCode, fieldName);
const value = formData[key];
if (value !== undefined) {
expression = expression.replace(
new RegExp(`\\b${fieldName}\\b`, 'g'),
`Number(${value})`
);
} }
} }
}
return expression; const fillCheckboxInputFields = async (
}; row: TableRow,
item: ContentItem,
valueMap: Record<string, string>
) => {
for (const field of item.optionItemField || []) {
const key = getFieldKey(row.code, field)
const tplItem = tplItemMap.value[key]
if (!tplItem) continue
const toggleTooltip = (rowCode: string, field: string) => { const { pid, itemid } = tplItem
const key = getFieldKey(rowCode, field); const valueKey = `${pid}_${itemid}_1`
if (hoveredKey.value === key) { const dataVal = valueMap[valueKey]
showTooltip.value = false;
hoveredKey.value = '';
} else {
showTooltip.value = true;
hoveredKey.value = key;
}
};
const toggleErrorTooltip = (rowCode: string, field: string) => { if (dataVal !== undefined) {
const key = getFieldKey(rowCode, field); formData[key] = dataVal
if (hoveredErrorKey.value === key) { }
showErrorTooltip.value = false;
hoveredErrorKey.value = '';
} else {
showErrorTooltip.value = true;
hoveredErrorKey.value = key;
} }
}; }
const closeAllTooltips = () => { const fillOtherField = async (
showTooltip.value = false; row: TableRow,
hoveredKey.value = ''; item: ContentItem,
showErrorTooltip.value = false; valueMap: Record<string, string>
hoveredErrorKey.value = ''; ) => {
}; const key = getFieldKey(row.code, item.otherField!)
const tplItem = tplItemMap.value[key]
if (!tplItem) return
const setFormItemRight = () => { const { pid, itemid } = tplItem
console.log('开始设置表单权限...'); const valueKey = `${pid}_${itemid}_1`
console.log('userAllocItems 数量:', userAllocItems.value.length); const dataVal = valueMap[valueKey]
console.log('validFormula 数量:', validFormula.value.length);
tableFormData.forEach((row: any) => { if (dataVal !== undefined) {
if (row.content && Array.isArray(row.content)) { formData[key] = dataVal
row.content.forEach((item: any) => { }
if (item.field) { }
const key = getFieldKey(row.code, item.field);
item.hasRight = userAllocItems.value.includes(key);
console.log(`字段 ${key}: hasRight = ${item.hasRight}`); const fillAttachTable = async (row: TableRow, valueMap: Record<string, string>) => {
const child = childAttachTableRefs.value[row.code]
if (!child) return
if (item.hasRight) { const tableData: Record<string, any> = {}
const formulaResult = findEarliestFormulaForField(validFormula.value, item.field);
item.hasValidFormula = !!formulaResult.formula; for (const data of row.datas || []) {
item.matchedFormula = formulaResult.formula || null; for (const [key, value] of Object.entries(data)) {
if (typeof value === 'object' && value.field) {
const fieldKey = getFieldKey(row.code, value.field)
const tplItem = tplItemMap.value[fieldKey]
if (!tplItem) continue
console.log(`字段 ${key}: hasValidFormula = ${item.hasValidFormula}`); const { pid, itemid, formTp, code } = tplItem
} else { const valueKey = `${pid}_${itemid}_1`
item.hasValidFormula = false; const dataVal = valueMap[valueKey]
item.matchedFormula = null;
if (dataVal) {
tableData[code] = formTp === 'checkbox' ? dataVal.split(',') : dataVal
} }
} }
});
} }
});
console.log('表单权限设置完成');
};
const findEarliestFormulaForField = (
formulas: FormulaItem[],
field: string
): { formula: FormulaItem | null, index: number } => {
let result = { formula: null, index: Infinity };
formulas?.forEach((f: FormulaItem) => {
const text = f.formula || '';
const escapedField = field.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const regex = new RegExp(`\\b${escapedField}\\b(?!\\w)`, 'g');
const match = regex.exec(text);
if (match && match.index < result.index) {
result = { formula: f, index: match.index };
} }
});
return result; child.setFormData(tableData)
}; }
// 处理校验结果点击 const fillMultiColumnTable = async (row: TableRow, valueMap: Record<string, string>) => {
const handleValidationResultClick = (result: any) => { const child = childMultiTableRefs.value[row.code]
const message = `字段 ${result.field} 的校验结果: ${result.isValid ? '通过' : '失败'}`; if (!child || !Array.isArray(row.content)) return
const status = result.isValid ? 'success' : 'error';
VxeUI.modal.message({ content: message, status }); const rowsMap: Record<string, Record<string, string>> = {}
};
// 打开历史填报抽屉 for (const item of row.content) {
const handleOpenHistoryDrawer = () => { if (!item.field) continue
historyDrawerVisible.value = true;
};
// 关闭历史填报抽屉 const key = getFieldKey(row.code, item.field)
const closeHistoryDrawer = () => { const tplItem = tplItemMap.value[key]
historyDrawerVisible.value = false; if (!tplItem) continue
};
// 添加刷新帮助图标的方法 const { pid, itemid, code } = tplItem
const refreshHelpIcons = () => { const valueKeys = Object.keys(valueMap).filter(k =>
console.log('刷新帮助图标...'); k.startsWith(`${pid}_${itemid}_`)
tableFormData.forEach((row: any) => { )
if (row.content && Array.isArray(row.content)) {
row.content.forEach((item: any) => {
if (item.field) {
const key = getFieldKey(row.code, item.field);
const hasRight = userAllocItems.value.includes(key);
if (hasRight) { for (const valueKey of valueKeys) {
const formulaResult = findEarliestFormulaForField(validFormula.value, item.field); const [, , rind] = valueKey.split('_')
item.hasValidFormula = !!formulaResult.formula; if (!rowsMap[rind]) {
item.matchedFormula = formulaResult.formula || null; rowsMap[rind] = {}
} else {
item.hasValidFormula = false;
item.matchedFormula = null;
} }
rowsMap[rind][code] = valueMap[valueKey]
} }
});
} }
});
// 强制更新视图 const tableDatas = Object.values(rowsMap)
nextTick(() => { child.setFormData(tableDatas)
console.log('帮助图标刷新完成'); }
});
};
// 原有检查方法 const fillVxeTable = async (row: TableRow, valueMap: Record<string, string>) => {
async function checkDataOrig() { const child = childMyVexTableRefs.value[row.code]
let tplName = queryParam.value.tplName; if (!child || !Array.isArray(row.columns)) return
await getFillDatas();
if (formValues.value.length > 0) {
refCheckTbData.value.setIniData(tplName, formValues.value);
}
}
async function setData() { const rowsMap: Record<string, Record<string, string>> = {}
try {
loading.value = true;
const taskId = queryParam.value.taskId;
const tplid = queryParam.value.tplId;
Object.keys(formData).forEach((key) => delete formData[key]); for (const column of row.columns) {
if (!column.field) continue
await setTplItemMap(); const key = getFieldKey(row.code, column.field)
const recordData = await queryRecord({ taskid: taskId, tplid: tplid }); const tplItem = tplItemMap.value[key]
if (!tplItem || Object.keys(tplItem).length === 0) continue
const valueObj = {}; const { pid, itemid, code } = tplItem
for (const data of recordData) { const valueKeys = Object.keys(valueMap).filter(k =>
const key = `${data.itempid}_${data.itemid}_${data.rind}`; k.startsWith(`${pid}_${itemid}_`)
valueObj[key] = data.content; )
}
const shouldSkip = (key) => {
const refsToCheck = [childMultiTableRefs.value, childAttachTableRefs.value];
for (const refs of refsToCheck) { for (const valueKey of valueKeys) {
for (const pcode of Object.keys(refs)) { const [, , rind] = valueKey.split('_')
if (key.startsWith(pcode + '_')) { if (!rowsMap[rind]) {
return true; rowsMap[rind] = {}
} }
rowsMap[rind][code] = valueMap[valueKey]
} }
} }
return false;
};
for (const strKey of Object.keys(tplItemMap.value)) { const tableDatas = Object.values(rowsMap)
if (shouldSkip(strKey)) { child.setFormData(tableDatas)
continue; }
}
const item = tplItemMap.value[strKey]; // 校验相关
if (!item) continue; const validateData = () => {
drawerVisible.value = true
validationDrawerRef.value.setValidateData(validFormula.value,formData);
}
const { pid, itemid, formTp } = item; const handleInputBlur = (rowCode: string, field: string, formula?: string) => {
const dataVal = valueObj[`${pid}_${itemid}_1`]; if (!formula) return
if (!dataVal) continue; const key = getFieldKey(rowCode, field)
const value = formData[key]
if (formTp === 'checkbox') { if (!value || value === '') {
formData[strKey] = dataVal?.split(',') || []; delete inputErrors.value[key]
} else { return
formData[strKey] = dataVal || '';
}
} }
for (const pcode of Object.keys(childAttachTableRefs.value)) { validateFieldFormula(rowCode, field, formula)
const child = childAttachTableRefs.value[pcode]; }
const matchingKeys = Object.keys(tplItemMap.value).filter((key) => key.startsWith(pcode + '_'));
const attachTableData = {};
for (const key of matchingKeys) {
const tmpData = tplItemMap.value[key];
if (!tmpData) continue;
const { pid, itemid, formTp, code } = tmpData; const validateFieldFormula = (rowCode: string, field: string, formula: string) => {
const valueKey = `${pid}_${itemid}_1`; const key = getFieldKey(rowCode, field)
if (formTp === 'checkbox') { try {
attachTableData[code] = valueObj[valueKey]?.split(',') || []; const expression = buildExpression(formula, rowCode)
const isValid = eval(expression)
if (!isValid) {
inputErrors.value[key] = {
message: "公式校验失败,请检查填写内容",
formula
}
} else { } else {
attachTableData[code] = valueObj[valueKey] || ''; delete inputErrors.value[key]
} }
} catch (error: any) {
inputErrors.value[key] = {
message: "公式校验失败,请检查填写内容",
formula,
error: error.message
} }
child.setFormData(attachTableData);
} }
}
for (const pcode of Object.keys(childMultiTableRefs.value)) { const buildExpression = (formula: string, rowCode: string): string => {
const child = childMultiTableRefs.value[pcode]; const fieldNames = formula.match(/\b[A-Za-z][A-Za-z0-9_]*\b/g) || []
const matchingKeys = Object.keys(tplItemMap.value).filter((key) => key.startsWith(pcode + '_')); const uniqueFields = [...new Set(fieldNames.filter(f =>
!['and', 'or', 'not', 'equal', 'less', 'greater', 'if', 'else', 'true', 'false']
const rowsMap = {}; .includes(f.toLowerCase())
for (const key of matchingKeys) { ))]
const tmpData = tplItemMap.value[key];
if (!tmpData) continue;
const { pid, itemid, code } = tmpData;
const valKeys = Object.keys(valueObj).filter((k) => k.startsWith(`${pid}_${itemid}_`));
for (const valKey of valKeys) { uniqueFields.sort((a, b) => b.length - a.length)
const parts = valKey.split('_');
const rind = parts[2];
if (!rowsMap[rind]) { let expression = formula
rowsMap[rind] = {}; for (const fieldName of uniqueFields) {
} const key = getFieldKey(rowCode, fieldName)
const value = formData[key]
rowsMap[rind][code] = valueObj[valKey]; if (value !== undefined) {
} // 检查字段类型,如果是日期类型,转换为时间戳进行比较
} const row = tableFormData.find((r: TableRow) => r.code === rowCode)
let processedValue = value
const tableDatas = Object.values(rowsMap); if (row && row.content && Array.isArray(row.content)) {
nextTick(); const fieldItem = row.content.find((c: ContentItem) => c.field === fieldName)
child.setFormData(tableDatas); if (fieldItem && fieldItem.type === 'date') {
// 将日期字符串转换为时间戳(毫秒)
const date = new Date(value)
if (!isNaN(date.getTime())) {
processedValue = date.getTime()
} }
} catch (error: any) {
VxeUI.modal.message({
content: `加载数据失败: ${error.message}`,
status: 'error',
});
} finally {
loading.value = false;
} }
} }
async function setTplItemMap() { expression = expression.replace(
try { new RegExp(`\\b${fieldName}\\b`, 'g'),
const tplid = queryParam.value.tplId; `Number(${processedValue})`
const tplItem = await allTplItems({ )
tplid: tplid,
});
tplItemMap.value = {};
tplItem.forEach((item) => {
let strKey = item.pcode + '_' + item.xmlcode;
tplItemMap.value[strKey] = { pid: item.pid, itemid: item.id, formTp: item.formTp, code: item.xmlcode };
});
} catch (error: any) {
VxeUI.modal.message({ content: `加载数据失败: ${error.message}`, status: 'error' });
} finally {
} }
} }
</script>
<style lang="less" scoped> return expression
.bank-report-table { }
font-family: 'SimSun', '宋体', serif;
font-size: 12px;
color: #000;
margin: 5px auto;
width: 60%;
}
/* 加载遮罩层样式 */ // 提示工具相关
.loading-overlay { const toggleTooltip = (rowCode: string, field: string) => {
position: absolute; const key = getFieldKey(rowCode, field)
top: 0; if (hoveredKey.value === key) {
left: 0; showTooltip.value = false
width: 100%; hoveredKey.value = ''
height: 100%; } else {
background-color: rgba(255, 255, 255, 0.8); showTooltip.value = true
display: flex; hoveredKey.value = key
justify-content: center;
align-items: center;
z-index: 1000;
} }
}
.loading-spinner { const toggleErrorTooltip = (rowCode: string, field: string) => {
display: flex; const key = getFieldKey(rowCode, field)
flex-direction: column; if (hoveredErrorKey.value === key) {
align-items: center; showErrorTooltip.value = false
hoveredErrorKey.value = ''
} else {
showErrorTooltip.value = true
hoveredErrorKey.value = key
} }
}
.spinner { const closeAllTooltips = () => {
width: 40px; showTooltip.value = false
height: 40px; hoveredKey.value = ''
border: 3px solid #f3f3f3; showErrorTooltip.value = false
border-top: 3px solid #3498db; hoveredErrorKey.value = ''
border-radius: 50%; }
animation: spin 2s linear infinite;
}
@keyframes spin { // 历史填报
0% { const handleOpenHistoryDrawer = () => {
transform: rotate(0deg); historyFillCheckRef.value?.onDrawerShow(queryParam.value.tplId)
} historyDrawerVisible.value = true
100% { }
transform: rotate(360deg);
}
}
.loading-text { const closeHistoryDrawer = () => {
margin-top: 10px; historyDrawerVisible.value = false
color: #666;
font-size: 14px;
}
}
// 校验结果处理
const handleValidationResultClick = (result: any) => {
const message = `字段 ${result.field} 的校验结果: ${result.isValid ? '通过' : '失败'}`
const status = result.isValid ? 'success' : 'error'
VxeUI.modal.message({ content: message, status })
}
.custom-table { // 工具函数
width: 100%; const findEarliestFormulaForField = (
border: 1px solid #000; formulas: FormulaItem[],
} field: string
): { formula: FormulaItem | null, index: number } => {
.custom-table .vxe-header--column, let result = { formula: null, index: Infinity }
.custom-table .vxe-body--column {
border-right: 1px solid #000;
border-bottom: 1px solid #000;
padding: 5px;
}
.custom-table .vxe-cell {
padding: 5px;
}
.content-cell { formulas?.forEach((f: FormulaItem) => {
line-height: 1.8; const text = f.formula || ''
} const escapedField = field.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
const regex = new RegExp(`\\b${escapedField}\\b(?!\\w)`, 'g')
const match = regex.exec(text)
.table-input { if (match && match.index < result.index) {
width: 80px; result = { formula: f, index: match.index }
margin: 0 2px;
} }
})
.radio-group { return result
display: inline-block; }
margin-right: 10px;
}
.checkbox-group { // 消息提示
display: inline-block; const showSuccessMessage = (message: string) => {
margin-right: 10px; VxeUI.modal.message({ content: message, status: 'success' })
} }
.vxe-radio, const showWarningMessage = (message: string) => {
.vxe-checkbox { VxeUI.modal.message({ content: message, status: 'warning' })
margin-right: 4px; }
white-space: nowrap;
}
.vxe-input--inner { const showErrorMessage = (message: string) => {
height: 24px; VxeUI.modal.message({ content: message, status: 'error' })
line-height: 24px; }
padding: 0 5px;
}
.vxe-radio--label, // 子组件引用设置
.vxe-checkbox--label { const setMultiColumnTableRef = (el: any, code: string) => {
font-size: 12px; if (el) childMultiTableRefs.value[code] = el
} }
.vxe-radio--icon, const setAttachTableRef = (el: any, code: string) => {
.vxe-checkbox--icon { if (el) childAttachTableRefs.value[code] = el
font-size: 12px; }
}
.vxe-radio-group, const setMyVxeTableRef = (el: any, code: string) => {
.vxe-checkbox-group { if (el) childMyVexTableRefs.value[code] = el
display: inline-block; }
} </script>
.bank-report-table { <style lang="less" scoped>
font-family: 'SimSun', '宋体', serif; // Base table styles
.bank-report-table {
font-family: "SimSun", "宋体", serif;
font-size: 12px; font-size: 12px;
color: #000; color: #000;
margin: 5px auto; margin: 5px auto;
width: 90%; width: 90%;
} position: relative;
.custom-table { // Shared table styles
.custom-table, .attachment-table {
width: 100%; width: 100%;
border: 1px solid #000; border: 1px solid #000;
}
.custom-table .vxe-header--column, .vxe-header--column,
.custom-table .vxe-body--column { .vxe-body--column {
border-right: 1px solid #000; border-right: 1px solid #000;
border-bottom: 1px solid #000; border-bottom: 1px solid #000;
padding: 5px; padding: 5px;
} }
.content-cell {
line-height: 1.8;
} }
}
.table-input { // 表格信息文本
width: 150px; .table-info-text {
margin: 0 2px; font-weight: bold;
} }
.radio-group { // 项目名称
display: inline-block; .project-name {
margin-right: 10px; font-weight: bold;
} font-size: 14px;
}
.checkbox-group { // Cell styles
display: inline-block; .content-cell {
margin-right: 10px; line-height: 1.8;
} }
.vxe-radio, // 表单控件组
.vxe-checkbox { .radio-group, .checkbox-group {
margin-right: 8px; display: inline-block;
margin-left: 10px;
.vxe-radio, .vxe-checkbox {
margin-left: 0px;
white-space: nowrap; white-space: nowrap;
} line-height: 30px;
padding: 0px 10px;
/* 附件样式 */ &--label {
.attachments { font-size: 12px;
margin-top: 20px;
width: 100%;
} }
.attachments h4 { &--icon {
font-size: 14px; font-size: 12px;
font-weight: bold; }
margin-bottom: 10px;
} }
}
.attachment-table { // VXE specific overrides
width: 100%; .vxe {
border: 1px solid #000; &-radio-group, &-checkbox-group {
display: inline-block;
} }
.attachment-table .vxe-header--column, &-cell {
.attachment-table .vxe-body--column {
border-right: 1px solid #000;
border-bottom: 1px solid #000;
padding: 5px; padding: 5px;
} }
}
.vxe-input { .vxe-input {
border-bottom: 1px solid #333; border-bottom: 1px solid #333;
text-align: center; text-align: center;
margin: 5px 3px; margin: 5px 3px;
...@@ -1142,28 +1115,22 @@ ...@@ -1142,28 +1115,22 @@
border-left: none; border-left: none;
border-right: none; border-right: none;
background: transparent; background: transparent;
} }
blockquote { // 输入框包装器
padding: 0px 5px; .input-wrapper {
color: black;
cursor: pointer;
}
// 输入框包装器
.input-wrapper {
position: relative; position: relative;
display: inline-block; display: inline-block;
} }
// 单位文本 // 单位文本
.unit { .unit {
margin-left: 5px; margin-left: 5px;
font-size: 12px; font-size: 12px;
} }
// 帮助图标 // 帮助图标
.help-icon { .help-icon {
margin-left: 5px; margin-left: 5px;
cursor: pointer; cursor: pointer;
color: #1890ff; color: #1890ff;
...@@ -1177,29 +1144,14 @@ ...@@ -1177,29 +1144,14 @@
background: #e6f7ff; background: #e6f7ff;
border-radius: 50%; border-radius: 50%;
transition: all 0.3s; transition: all 0.3s;
opacity: 0;
animation: fadeIn 0.5s forwards;
animation-delay: 0.3s;
&:hover { &:hover {
background: #bae7ff; background: #bae7ff;
transform: scale(1.1);
}
} }
}
@keyframes fadeIn { // 错误图标
from { .error-icon {
opacity: 0;
transform: scale(0.8);
}
to {
opacity: 1;
transform: scale(1);
}
}
// 错误图标
.error-icon {
margin-left: 5px; margin-left: 5px;
cursor: pointer; cursor: pointer;
color: #ff4d4f; color: #ff4d4f;
...@@ -1214,10 +1166,10 @@ ...@@ -1214,10 +1166,10 @@
&:hover { &:hover {
transform: scale(1.1); transform: scale(1.1);
} }
} }
// 提示框 // 提示框
.tooltip, .error-tooltip { .tooltip, .error-tooltip {
position: absolute; position: absolute;
top: 100%; top: 100%;
left: 0; left: 0;
...@@ -1229,9 +1181,9 @@ ...@@ -1229,9 +1181,9 @@
white-space: pre-wrap; white-space: pre-wrap;
max-width: 300px; max-width: 300px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
} }
.tooltip { .tooltip {
background: #333; background: #333;
color: #fff; color: #fff;
...@@ -1244,9 +1196,9 @@ ...@@ -1244,9 +1196,9 @@
border-style: solid; border-style: solid;
border-color: transparent transparent #333 transparent; border-color: transparent transparent #333 transparent;
} }
} }
.error-tooltip { .error-tooltip {
background: #8b0000; background: #8b0000;
color: #fff; color: #fff;
border: 1px solid #ff4d4f; border: 1px solid #ff4d4f;
...@@ -1260,5 +1212,43 @@ ...@@ -1260,5 +1212,43 @@
border-style: solid; border-style: solid;
border-color: transparent transparent #8b0000 transparent; border-color: transparent transparent #8b0000 transparent;
} }
} }
// 加载遮罩
.loading-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(255, 255, 255, 0.8);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
}
.loading-spinner {
text-align: center;
}
.spinner {
width: 40px;
height: 40px;
border: 3px solid #f3f3f3;
border-top: 3px solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
margin: 0 auto 10px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.loading-text {
font-size: 14px;
color: #666;
}
</style> </style>
\ No newline at end of file
<template> <template>
<div class="bank-report-table" style="height: 80vh;" @click="closeAllTooltips"> <div
class="bank-report-table"
style="height:80vh"
@click="closeAllTooltips"
>
<!-- 加载遮罩层 --> <!-- 加载遮罩层 -->
<div v-if="loading" class="loading-overlay"> <div v-if="loading" class="loading-overlay">
<div class="loading-spinner"> <div class="loading-spinner">
...@@ -8,87 +12,68 @@ ...@@ -8,87 +12,68 @@
</div> </div>
</div> </div>
<!-- 工具栏 -->
<vxe-toolbar> <vxe-toolbar>
<template #button> <template #buttons>
<div style="margin:10px"> <div style="margin:10px">
<span style="font-weight: bold"> 填报任务:{{ queryParam?.taskName }} </span> <span class="table-info-text">填报任务:{{ queryParam.taskName }}</span>
<span style="font-weight: bold;margin-left:20px"> 表格:{{ queryParam?.tplCode }} {{ queryParam?.tplName }}</span> <span class="table-info-text" style="margin-left:20px">
表格:{{ queryParam.tplCode }} {{ queryParam.tplName }}
</span>
</div> </div>
</template> </template>
<template #tools v-if="!queryParam.comfrom"> <template #tools v-if="!queryParam.comfrom">
<vxe-button status="primary" icon="vxe-icon-edit" @click="handleOpenHistoryDrawer" :disabled="loading">近5年数据填报</vxe-button> <vxe-button
<vxe-button status="primary" icon="vxe-icon-save" @click="validateData">校验</vxe-button> status="primary"
<vxe-button status="primary" icon="vxe-icon-save" @click="saveBatch">保存</vxe-button> icon="vxe-icon-edit"
</template> @click="handleOpenHistoryDrawer"
</vxe-toolbar> :disabled="loading"
<!-- 校验结果抽屉 -->
<vxe-drawer
v-model="drawerVisible"
placement="right"
@show="handleValidationDrawerShow"
title="校验结果"
width="40%"
:footer="{ show: true }"
> >
<template #default> 近5年数据填报
<div class="validation-results"> </vxe-button>
<div class="result-summary"> <vxe-button
<div class="summary-item"> status="primary"
<span class="summary-label">校验字段数:</span> icon="vxe-icon-save"
<span class="summary-value">{{ validationResultsList.length }}</span> @click="validateData"
</div>
<div class="summary-item">
<span class="summary-label">通过:</span>
<span class="summary-value success">{{ validationResultsList.filter(item => item.isValid).length }}</span>
</div>
<div class="summary-item">
<span class="summary-label">失败:</span>
<span class="summary-value error">{{ validationResultsList.filter(item => !item.isValid).length }}</span>
</div>
</div>
<div class="results-list">
<div
v-for="(result, index) in validationResultsList"
:key="index"
class="result-item"
:class="{ success: result.isValid, error: !result.isValid }"
@click="handleValidationResultClick(result)"
> >
<div class="result-field">{{ result.field }}</div> 校验
<div class="result-desc">{{ result.description }}</div> </vxe-button>
<div class="result-value">值:{{ result.fieldValue || '空' }}</div> <vxe-button
<div v-if="!result.isValid" class="result-error">失败原因:{{ result.description }}</div> status="primary"
</div> icon="vxe-icon-save"
</div> @click="saveBatch"
</div> >
保存
</vxe-button>
</template> </template>
</vxe-drawer> </vxe-toolbar>
<!-- 主表格 -->
<vxe-table <vxe-table
border border
ref="tableRef" ref="tableRef"
height="auto"
show-header-overflow show-header-overflow
:data="tableFormData" :data="tableFormData"
:column-config="{ resizable: true }" :column-config="{ resizable: true }"
:row-config="{ resizable: true }" :row-config="{ resizable: true }"
class="custom-table" class="custom-table"
height="auto"
> >
<vxe-column field="serialNumber" title="序号" width="80"></vxe-column> <vxe-column field="serialNumber" title="序号" width="50"></vxe-column>
<vxe-column field="project" title="项目" width="200">
<vxe-column field="project" title="项目" width="100">
<template #default="{ row }"> <template #default="{ row }">
<span style="font-weight: bold;size:20px">{{ row.project }}</span> <span class="project-name">{{ row.project }}</span>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="content" title="内容" row-resize>
<vxe-column field="content" title="内容">
<template #default="{ row }"> <template #default="{ row }">
<div class="content-cell"> <div class="content-cell">
<!-- MultiColumnTable 类型 --> <!-- 多列表格 -->
<template v-if="row.type === 'MultiColumnTable'"> <template v-if="row.type === 'MultiColumnTable'">
<MultiColumnTable <MultiColumnTable
:title="row.project" :title="row.project"
:columnsPerRow="6"
:records="[]" :records="[]"
:fields="row.content" :fields="row.content"
:ref="(el) => setMultiColumnTableRef(el, row.code)" :ref="(el) => setMultiColumnTableRef(el, row.code)"
...@@ -96,203 +81,190 @@ ...@@ -96,203 +81,190 @@
/> />
</template> </template>
<!-- AttachTable 类型 --> <!-- 附件表格 -->
<template v-else-if="row.type === 'AttachTable'"> <template v-else-if="row.type === 'AttachTable'">
<AttachTable <AttachTable
:title="row.project" :title="row.project"
:records="row.datas" :records="row.datas"
:fields="row.content" :fields="row.content"
:pcode="row.code" :pcode="row.code"
:calcSum="row.calcSum"
:showFooter="row.showFooter"
:ref="(el) => setAttachTableRef(el, row.code)" :ref="(el) => setAttachTableRef(el, row.code)"
:disabled="!row.hasRight"
style="margin:0px;padding:0px"
/>
</template>
<!-- Vxe表格 -->
<template v-else-if="row.type === 'VxeTable'">
<MyVxeTable1
:title="row.project"
:data="row.data"
:columns="row.columns"
:pcode="row.code"
:footerData="row.footerData"
:showFooter="row.showFooter"
:ref="(el) => setMyVxeTableRef(el, row.code)"
:disabled="!row.hasRight"
style="margin:0px;padding:0px" style="margin:0px;padding:0px"
/> />
</template> </template>
<!-- 其他类型 --> <!-- 普通字段渲染 -->
<template v-else> <template v-else>
<template v-for="(item, index) in row.content" :key="index"> <template v-for="(item, index) in row.content" :key="index">
<!-- 文本类型 -->
<span v-if="item.type === 'text'" v-html="item.value"></span> <span v-if="item.type === 'text'" v-html="item.value"></span>
<!-- 换行 -->
<span v-else-if="item.type === 'br'"><br></span> <span v-else-if="item.type === 'br'"><br></span>
<!-- 带缩进的换行 -->
<span v-else-if="item.type === 'brspace'"> <span v-else-if="item.type === 'brspace'">
<br> <br>
<template v-for="i in item.value||1" :key="i"> <template v-for="i in (item.value || 1)" :key="i">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</template> </template>
</span> </span>
<template v-else-if="item.type === 'AttachTable'"> <!-- 单选组 -->
<AttachTable
:title="item.project"
:records="item.datas"
:fields="item.content"
:pcode="item.code"
:ref="(el) => setAttachTableRef(el, item.code)"
style="margin:0px;padding:0px"
/>
</template>
<template v-else-if="item.type === 'MultiColumnTable'">
<MultiColumnTable
:title="item.project"
:records="[]"
:fields="item.content"
:ref="(el) => setMultiColumnTableRef(el, item.code)"
style="margin:0px;padding:0px"
/>
</template>
<template v-else-if="item.type === 'yesno'">
<vxe-radio-group v-model="formData[getFieldKey(row.code, item.field)]">
<vxe-radio label="是" content="是">
</vxe-radio>
<vxe-radio label="否" content="否"></vxe-radio>
</vxe-radio-group>
<template v-if="item.extraField||item.extraFields">
<div v-if="formData[getFieldKey(row.code, item.field)]=='是'" style="margin-left:40px">
如是,
<template v-if="item.extraField">
{{item.extraLabel }}
<vxe-input v-model="formData[getFieldKey(row.code, item.extraField)]" style="width: 300px;"></vxe-input>
<span class="unit"> {{ item.unit }}</span>
</template>
<template v-else-if="item.extraFields">
<template v-for="(ccopt,ccind) in item.extraFields" :key="ccind">
<span>{{ ccopt.label }}: </span>
<template v-if="ccopt.formType=='input'">
<vxe-input v-model="formData[getFieldKey(row.code, ccopt.field)]" style="width:250px"></vxe-input>
</template>
<template v-else-if="ccopt.formType=='number'">
<vxe-input v-model="formData[getFieldKey(row.code, ccopt.field)]" type="number" style="width:250px"></vxe-input>
<span class="unit"> {{ ccopt.unit }}</span>
</template>
<template v-else-if="ccopt.formType=='checkbox'">
<vxe-checkbox-group v-model="formData[getFieldKey(row.code, ccopt.field)]">
<vxe-checkbox v-for="(opt, optIndex) in ccopt.options" :key="optIndex" :label="opt" :content="opt">
</vxe-checkbox>
</vxe-checkbox-group>
</template>
<template v-else-if="ccopt.formType=='radio'">
<vxe-radio-group v-model="formData[getFieldKey(row.code, ccopt.field)]" :options="ccopt.options">
<vxe-radio v-for="(opt, optIndex) in ccopt.options" :key="optIndex" :label="opt" :content="opt">
</vxe-radio>
</vxe-radio-group>
</template>
<template v-else>
<vxe-input v-model="formData[getFieldKey(row.code, ccopt.field)]" :type="ccopt.formType" style="width:100px"></vxe-input>
</template>
<br>
<template v-if="ccopt.otherOption">
其他:<vxe-input v-model="formData[getFieldKey(row.code, ccopt.otherField)]" style="width: 300px;"></vxe-input>
</template>
<br>
</template>
</template>
</div>
</template>
</template>
<span v-else-if="item.type === 'radio-group'" class="radio-group"> <span v-else-if="item.type === 'radio-group'" class="radio-group">
<vxe-radio-group v-model="formData[getFieldKey(row.code, item.field)]"> <vxe-radio-group
<vxe-radio v-for="(opt, optIndex) in item.options" :key="optIndex" :label="opt">{{ opt }}</vxe-radio> v-model="formData[getFieldKey(row.code, item.field)]"
</vxe-radio-group> :disabled="!item.hasRight || isRadioDisabled(row.code, item)"
</span> >
<vxe-radio
<span v-else-if="item.type === 'radio-group-extraFields'" class="radio-group" style="width:100%"> v-for="(opt, optIndex) in item.options"
<vxe-radio-group v-model="formData[getFieldKey(row.code, item.field)]"> :key="optIndex"
<vxe-radio v-for="(opt, optIndex) in item.options" :key="optIndex" :label="opt.label"> :label="opt"
{{ opt.label }} >
<template v-if="opt.extraField&&formData[getFieldKey(row.code, item.field)]==opt.label"> {{ opt }}
<span>{{ opt.extraFieldLabel }}</span>
<vxe-input v-model="formData[getFieldKey(row.code, opt.otherField)]" style="width: 200px;"></vxe-input>
</template>
<template v-if="opt.extraFields&&formData[getFieldKey(row.code, item.field)]==opt.label">
<template v-for="(ccopt,ccind) in opt.extraFields" :key="ccind">
<span>{{ ccopt.label }}: </span>
<vxe-input v-model="formData[getFieldKey(row.code, ccopt.field)]" style="width: 200px;"></vxe-input>
</template>
</template>
</vxe-radio> </vxe-radio>
</vxe-radio-group> </vxe-radio-group>
</span> </span>
<!-- 多选组(带其他选项) -->
<div v-else-if="item.type === 'checkbox-group'"> <div v-else-if="item.type === 'checkbox-group'">
<span> <span class="checkbox-group">
<vxe-checkbox-group v-model="formData[getFieldKey(row.code, item.field)]"> <vxe-checkbox-group
<vxe-checkbox v-for="(opt, optIndex) in item.options" :key="optIndex" :label="opt"> v-model="formData[getFieldKey(row.code, item.field)]"
:disabled="!item.hasRight"
>
<vxe-checkbox
v-for="(opt, optIndex) in item.options"
:key="optIndex"
:label="opt"
>
{{ opt }} {{ opt }}
</vxe-checkbox> </vxe-checkbox>
<template v-if="item.otherOption"> <template v-if="item.otherField">
<vxe-checkbox label="其他"> <div style="width:100%">
<vxe-checkbox label="其他" :disabled="!item.hasRight">
其他: 其他:
<vxe-input v-model="formData[getFieldKey(row.code, item.otherField)]" style="width: 200px;"
:disabled="!(formData[getFieldKey(row.code, item.field)]?.indexOf('其他')>-1)">
</vxe-input>
</vxe-checkbox> </vxe-checkbox>
<vxe-input
v-model="formData[getFieldKey(row.code, item.otherField)]"
:disabled="!isOtherFieldEnabled(row.code, item) || !item.hasRight"
style="width: 50%"
@blur="handleInputBlur(row.code, item.otherField, item.matchedFormula?.formula)"
/>
</div>
</template> </template>
</vxe-checkbox-group> </vxe-checkbox-group>
<!-- 其他选项 -->
</span> </span>
</div> </div>
<template v-else-if="item.type=='textarea'"> <!-- 多选带输入框 -->
<vxe-textarea v-model="formData[getFieldKey(row.code, item.field)]" :rows="item.rows" :style="{width:item.width}"> <div v-else-if="item.type === 'checkboxAndInput'">
</vxe-textarea> <span style="margin-left:20px">
</template> <vxe-checkbox-group
v-model="formData[getFieldKey(row.code, item.field)]"
:disabled="!item.hasRight"
>
<vxe-checkbox
v-for="(opt, optIndex) in item.options"
:key="optIndex"
:label="opt"
:disabled="!item.hasRight"
style="margin-left: 0px;display: block;"
>
{{ opt }}
<vxe-input
type="number"
v-model="formData[getFieldKey(row.code, item.optionItemField[optIndex])]"
:disabled="!item.hasRight"
style="width: 100px;margin: 0px;"
@blur="handleInputBlur(row.code, item.optionItemField[optIndex], item.matchedFormula?.formula)"
/>
<span class="unit"> {{ item.optionItemUint }}</span>
</vxe-checkbox>
</vxe-checkbox-group>
</span>
</div>
<!-- 普通输入框 -->
<template v-else> <template v-else>
<div class="input-wrapper"> <div class="input-wrapper">
<vxe-input <vxe-input
:disabled="!item.hasRight || isInputDisabled(row.code, item)"
:type="item.type" :type="item.type"
v-model="formData[getFieldKey(row.code, item.field)]" v-model="formData[getFieldKey(row.code, item.field)]"
size="mini" size="mini"
class="table-input" class="table-input"
:disabled="!item.hasRight" :style="item.style"
@blur="handleInputBlur(row.code, item.field, item.matchedFormula?.formula)" @blur="handleInputBlur(row.code, item.field, item.matchedFormula?.formula)"
/> />
<span v-if="item.unit" class="unit"> {{ item.unit }}</span> <span class="unit">{{ item.unit }}</span>
<!-- 帮助图标 -->
<span <span
v-if="showHelpIcon(row.code, item.field, item)" v-if="item.hasValidFormula"
class="help-icon" class="help-icon"
@click.stop="toggleTooltip(row.code, item.field)" @click.stop="toggleTooltip(row.code, item.field)"
title="点击查看校验规则"
> >
? ?
</span> </span>
<!-- 错误图标 -->
<span <span
v-if="inputErrors[getFieldKey(row.code, item.field)]" v-if="inputErrors[getFieldKey(row.code, item.field)]"
class="error-icon" class="error-icon"
@click.stop="toggleErrorTooltip(row.code, item.field)" @click.stop="toggleErrorTooltip(row.code, item.field)"
title="点击查看错误详情"
> >
<i class="vxe-icon-error"></i> <i class="vxe-icon-error"></i>
</span> </span>
<div <!-- 错误提示 -->
v-if="showTooltip && hoveredKey === getFieldKey(row.code, item.field)"
class="tooltip"
@click.stop
>
{{ item.matchedFormula?.des || '暂无校验规则' }}
</div>
<div <div
v-if="showErrorTooltip && hoveredErrorKey === getFieldKey(row.code, item.field)" v-if="showErrorTooltip && hoveredErrorKey === getFieldKey(row.code, item.field)"
class="error-tooltip" class="error-tooltip"
@click.stop @click.stop
> >
{{ inputErrors[getFieldKey(row.code, item.field)]?.message }} {{ inputErrors[getFieldKey(row.code, item.field)].message }}
<br> <br>
<span style="color: #ffcccc;"> <span style="color: #ffcccc;">
公式: {{ inputErrors[getFieldKey(row.code, item.field)]?.formula }} 公式: {{ inputErrors[getFieldKey(row.code, item.field)].formula }}
</span> </span>
<template v-if="inputErrors[getFieldKey(row.code, item.field)]?.error"> <template v-if="inputErrors[getFieldKey(row.code, item.field)].error">
<br> <br>
<span style="color: #ff9999; font-size: 11px;"> <span style="color: #ff9999; font-size: 11px;">
错误: {{ inputErrors[getFieldKey(row.code, item.field)]?.error }} 错误: {{ inputErrors[getFieldKey(row.code, item.field)].error }}
</span> </span>
</template> </template>
</div> </div>
<!-- 校验规则提示 -->
<div
v-if="showTooltip && hoveredKey === getFieldKey(row.code, item.field)"
class="tooltip"
@click.stop
>
{{ item.matchedFormula?.des || '暂无校验规则' }}
</div>
</div> </div>
</template> </template>
</template> </template>
...@@ -301,72 +273,74 @@ ...@@ -301,72 +273,74 @@
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="remarks" title="备注" width="150"> <!-- 备注列 -->
<vxe-column field="remarks" title="备注" width="60">
<template #default="{ row }"> <template #default="{ row }">
<vxe-textarea :rows="row.remarks.rows" v-model="formData[getFieldKey(row.code, row.remarks.field)]" style="height:100%;"> <vxe-textarea
</vxe-textarea> :rows="row.remarks.rows"
v-model="formData[getFieldKey(row.code, row.remarks.field)]"
/>
</template> </template>
</vxe-column> </vxe-column>
</vxe-table> </vxe-table>
<!-- 历史填报检查组件 --> <!-- 校验抽屉 -->
<HistoryFillCheck ref="historyFillCheckRef" v-model="historyDrawerVisible" @close-drawer="closeHistoryDrawer"/> <ValidationDrawer
ref="validationDrawerRef"
v-model="drawerVisible"
:tableFormData="tableFormData"
@validationResultClick="handleValidationResultClick"
/>
<!-- 验证公式帮助提示 --> <!-- 历史填报抽屉 -->
<div <HistoryFillCheck
v-if="validationTooltipVisible" ref="historyFillCheckRef"
class="validation-tooltip" v-model="historyDrawerVisible"
:style="{ left: validationTooltipPosition.left + 'px', top: validationTooltipPosition.top + 'px' }" @closeDrawer="closeHistoryDrawer"
> />
<pre class="tooltip-content">{{ validationTooltipContent }}</pre>
</div>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, reactive, onMounted, computed } from 'vue'
import { VxeUI, VxeTableInstance } from 'vxe-table'
import 'vxe-table/lib/style.css'
import { useRoute } from 'vue-router'
// 组件导入
import MultiColumnTable from '../tableComponents/MultiColumnTable.vue' import MultiColumnTable from '../tableComponents/MultiColumnTable.vue'
import AttachTable from '../tableComponents/AttachTable.vue' import AttachTable from '../tableComponents/AttachTable.vue'
import HistoryFillCheck from './check/historyFillCheck.vue' import MyVxeTable1 from '../tableComponents/MyVxeTable.vue'
import HistoryFillCheck from './check/HistoryFillCheck.vue'
import { tableFormData } from '../../data/tb9.data'; import ValidationDrawer from './check/ValidationDrawer.vue'
import { ref, reactive, nextTick, onMounted, computed } from 'vue'
import { VxeUI } from 'vxe-table' // 数据导入
import { queryRecord, batchSaveOrUpdateBeforeDelete } from '../../record/BaosongTaskRecord.api' import { tableFormData } from '../../data/tb9.data'
import { findUserRightForTplItem } from '../../alloc/BaosongTaskAlloc.api'
// API 导入
import {
batchSaveOrUpdate,
queryRecord,
batchSaveOrUpdateBeforeDelete
} from '../../record/BaosongTaskRecord.api'
import {
queryAllTplItemForUser,
findUserRightForTplItem
} from '../../alloc/BaosongTaskAlloc.api'
import { allTplItems } from '../../tpl/BaosongTplItem.api' import { allTplItems } from '../../tpl/BaosongTplItem.api'
import { getTblvalidFormula } from '../../tpl/BaosongDataValid.api' import { getTblvalidFormula } from '../../tpl/BaosongDataValid.api'
import { useRoute } from 'vue-router';
const route = useRoute();
const tableRef = ref();
const tplItemMap = ref<Record<string, any>>({});
const historyFillCheckRef = ref<any>(null);
const queryParam = ref({
taskId: -1,
taskName: '',
tplId: -1,
tplName: '',
tplCode: '',
comfrom: ''
})
// 权限相关状态 // 类型定义
const userAllocItems = ref<string[]>([]) interface QueryParam {
const validFormula = ref<any[]>([]) taskId: number
const validationResultsList = ref<any[]>([]) taskName: string
const drawerVisible = ref(false) tplId: number
const historyDrawerVisible = ref(false) tplName: string
const showTooltip = ref(false) tplCode: string
const hoveredKey = ref('') comfrom: string
const showErrorTooltip = ref(false) }
const hoveredErrorKey = ref('')
const inputErrors = ref<Record<string, any>>({})
const isInitialized = ref(false)
const validationTooltipVisible = ref(false)
const validationTooltipPosition = ref({ left: 0, top: 0 })
const validationTooltipContent = ref('')
interface FormData { interface FormDataItem {
id: number | null id: number | null
taskid: number taskid: number
tplid: number tplid: number
...@@ -377,515 +351,522 @@ interface FormData { ...@@ -377,515 +351,522 @@ interface FormData {
rind: number rind: number
} }
onMounted(async () => { interface FormulaItem {
if (route.query.taskId) { formula: string
queryParam.value.taskId = Number(route.query.taskId); des: string
} [key: string]: any
if (route.query.taskName) { }
queryParam.value.taskName = String(route.query.taskName);
}
if (route.query.tplId) {
queryParam.value.tplId = Number(route.query.tplId);
}
if (route.query.tplName) {
queryParam.value.tplName = String(route.query.tplName);
}
if (route.query.tplCode) {
queryParam.value.tplCode = String(route.query.tplCode);
}
if (route.query.comfrom) {
queryParam.value.comfrom = String(route.query.comfrom);
}
// 设置查询参数 interface ContentItem {
setQueryParams(); type: string
field: string
value?: any
hasRight?: boolean
hasValidFormula?: boolean
matchedFormula?: FormulaItem
relatedFiled?: string
otherField?: string
optionItemField?: string[]
[key: string]: any
}
// 获取权限和验证公式 interface TableRow {
try { code: string
userAllocItems.value = await findUserRightForTplItem({ project: string
tplid: queryParam.value.tplId, type?: string
taskid: queryParam.value.taskId content: ContentItem[] | any
}) remarks: { rows: number; field: string }
hasRight?: boolean
[key: string]: any
}
validFormula.value = await getTblvalidFormula({ interface InputError {
tplid: queryParam.value.tplId, message: string
}) formula: string
error?: string
}
console.log('获取到的权限:', userAllocItems.value.length); interface TplItemMapValue {
console.log('获取到的公式:', validFormula.value.length); pid: number
} catch (error) { itemid: number
console.error('获取权限或验证公式失败:', error) formTp: string
} code: string
}
await setTplItemMap() // 路由和组件引用
setFormItemRight() const route = useRoute()
await setData() const tableRef = ref<VxeTableInstance>()
const historyFillCheckRef = ref()
const validationDrawerRef = ref()
isInitialized.value = true // 响应式状态
const loading = ref(true)
const historyDrawerVisible = ref(false)
const drawerVisible = ref(false)
const showTooltip = ref(false)
const hoveredKey = ref('')
const showErrorTooltip = ref(false)
const hoveredErrorKey = ref('')
setTimeout(() => { // 数据状态
refreshHelpIcons() const queryParam = ref<QueryParam>({
}, 300) taskId: -1,
taskName: '',
tplId: -1,
tplName: '',
tplCode: '',
comfrom: ''
}) })
const loading = ref(false) const formData = reactive<Record<string, any>>({})
const formData = reactive<Record<string, any>>({}); const formValues = ref<FormDataItem[]>([])
const inputErrors = ref<Record<string, InputError>>({})
const userAllocItems = ref<string[]>([])
const validFormula = ref<FormulaItem[]>([])
const tplItemMap = ref<Record<string, TplItemMapValue>>({})
// 子组件引用
const childMultiTableRefs = ref<Record<string, any>>({})
const childAttachTableRefs = ref<Record<string, any>>({})
const childMyVexTableRefs = ref<Record<string, any>>({})
const formValues = ref<FormData[]>([]) // 计算属性
const fieldKeys = computed(() => Object.keys(formData))
// 获取字段key的统一方法 // 工具函数
const getFieldKey = (rowCode: string, field: string): string => { const getFieldKey = (rowCode: string, field: string): string => {
return `${rowCode}_${field}` return `${rowCode}_${field}`
} }
const saveBatch = async () => { const isRadioDisabled = (rowCode: string, item: ContentItem): boolean => {
try { if (!item.relatedFiled) return false
loading.value = true const relatedKey = getFieldKey(rowCode, item.relatedFiled)
formValues.value = [] return formData[relatedKey] !== '是'
}
for (const strKey in formData) { const isInputDisabled = (rowCode: string, item: ContentItem): boolean => {
const valData = formData[strKey] if (!item.relatedFiled) return false
if (valData) { const relatedKey = getFieldKey(rowCode, item.relatedFiled)
let tmpAry = strKey.split("_") return formData[relatedKey] !== '是'
await setFormValues(tmpAry[0], tmpAry[1], valData, 1) }
}
}
await getAttachTableFormData(); const isOtherFieldEnabled = (rowCode: string, item: ContentItem): boolean => {
await getAllMultiTableFormData() const checkboxKey = getFieldKey(rowCode, item.field)
const checkboxValue = formData[checkboxKey] || []
return checkboxValue.includes('其他')
}
if (formValues.value.length > 0) { // 初始化
await batchSaveOrUpdateBeforeDelete(formValues.value) onMounted(async () => {
VxeUI.modal.message({ content: '保存成功', status: 'success' }) await initPage()
} else { })
VxeUI.modal.message({ content: '没有需要保存的数据', status: 'warning' })
} const initPage = async () => {
try {
loading.value = true
await initQueryParams()
await Promise.all([
loadUserRights(),
loadValidationFormulas(),
loadTemplateItems()
])
await setFormItemRight()
await loadTableData()
} catch (error: any) { } catch (error: any) {
VxeUI.modal.message({ content: `保存失败: ${error.message}`, status: 'error' }) showErrorMessage(`初始化页面失败: ${error.message}`)
} finally { } finally {
loading.value = false loading.value = false
} }
} }
const childMultiTableRefs = ref<Record<string, any>>({}) const initQueryParams = () => {
const setMultiColumnTableRef = (el: any, index: string) => { const { taskId, taskName, tplId, tplName, tplCode,comfrom } = route.query
if (el) {
childMultiTableRefs.value[index] = el;
}
};
const getAllMultiTableFormData = async () => { if (taskId) queryParam.value.taskId = Number(taskId)
for (const pcode in childMultiTableRefs.value) { if (taskName) queryParam.value.taskName = String(taskName)
const child = childMultiTableRefs.value[pcode]; if (tplId) queryParam.value.tplId = Number(tplId)
if (child) { if (tplName) queryParam.value.tplName = String(tplName)
const datas = child.getFormData() if (tplCode) queryParam.value.tplCode = String(tplCode)
let rind = 0 if (comfrom) queryParam.value.comfrom = String(comfrom)
for (const obj of datas) { }
rind++
Object.keys(obj).forEach(code => {
setFormValues(pcode, code, obj[code], rind)
});
}
}
}
};
const childAttachTableRefs = ref<Record<string, any>>({}) const loadUserRights = async () => {
const setAttachTableRef = (el: any, index: string) => { userAllocItems.value = await findUserRightForTplItem({
if (el) { tplid: queryParam.value.tplId,
childAttachTableRefs.value[index] = el; taskid: queryParam.value.taskId
})
}
const loadValidationFormulas = async () => {
validFormula.value = await getTblvalidFormula({
tplid: queryParam.value.tplId
})
}
const loadTemplateItems = async () => {
const items = await allTplItems({
tplid: queryParam.value.tplId
})
tplItemMap.value = items.reduce((acc: Record<string, TplItemMapValue>, item) => {
const key = `${item.pcode}_${item.xmlcode}`
acc[key] = {
pid: item.pid,
itemid: item.id,
formTp: item.formTp,
code: item.xmlcode
} }
}; return acc
}, {})
}
const getAttachTableFormData = async () => { const setFormItemRight = () => {
for (const pcode in childAttachTableRefs.value) { tableFormData.forEach((row: TableRow) => {
const child = childAttachTableRefs.value[pcode]; if (row.content && Array.isArray(row.content)) {
if (child) { row.content.forEach((item: ContentItem) => {
const datas = child.getFormData() if (item.field) {
const key = getFieldKey(row.code, item.field)
item.hasRight = userAllocItems.value.includes(key)
for (const code in datas) { if (item.hasRight) {
await setFormValues(pcode, code, datas[code], 1) const { formula } = findEarliestFormulaForField(validFormula.value, item.field)
item.hasValidFormula = !!formula
item.matchedFormula = formula
} }
} }
})
} }
}; })
const setFormValues = async (pcode: string, code: string, valData: any, rind: number) => {
if (!valData) return;
let vals = Array.isArray(valData) ? valData.join(',') : valData
let strKey = getFieldKey(pcode, code)
const item = tplItemMap.value[strKey];
const { pid, itemid } = item ?? {};
let tempForm: FormData = {
id: null,
rind: rind,
taskid: queryParam.value.taskId,
tplid: queryParam.value.tplId,
tplcode: code,
itemid: itemid,
itempid: pid,
content: vals
};
formValues.value.push(tempForm)
} }
async function setData() { // 保存相关
const saveBatch = async () => {
try { try {
loading.value = true; if (!await validateForm()) return
const taskId = queryParam.value.taskId;
const tplid = queryParam.value.tplId;
Object.keys(formData).forEach(key => delete formData[key]); await prepareFormData()
await setTplItemMap(); if (formValues.value.length === 0) {
const recordData = await queryRecord({ taskid: taskId, tplid: tplid }); showWarningMessage('没有需要保存的数据')
return
}
const valueObj: Record<string, any> = {}; await batchSaveOrUpdateBeforeDelete(formValues.value)
for (const data of recordData) { showSuccessMessage('保存成功')
const key = `${data.itempid}_${data.itemid}_${data.rind}`; } catch (error: any) {
valueObj[key] = data.content; showErrorMessage(`保存失败: ${error.message}`)
} }
}
const shouldSkip = (key: string) => { const validateForm = async (): Promise<boolean> => {
const refsToCheck = [ const $table = tableRef.value
childMultiTableRefs.value, if (!$table) return true
childAttachTableRefs.value,
];
for (const refs of refsToCheck) { const checkResult = $table.validate()
for (const pcode of Object.keys(refs)) { if (!checkResult) {
if (key.startsWith(pcode + '_')) { showErrorMessage('表单验证失败,请检查填写内容')
if (key === "TB9006_COL64") { return false
return false;
}
return true;
} }
return true
}
const prepareFormData = async () => {
formValues.value = []
// 处理主表单数据
for (const [key, value] of Object.entries(formData)) {
if (value !== undefined && value !== null && value !== '') {
const [pcode, code] = key.split('_')
await addFormValue(pcode, code, value, 1)
} }
} }
return false;
};
for (const strKey of Object.keys(tplItemMap.value)) { // 处理子表格数据
if (shouldSkip(strKey)) { await Promise.all([
continue; collectAttachTableData(),
} collectMultiTableData(),
collectVxeTableData()
])
}
const item = tplItemMap.value[strKey]; const addFormValue = async (pcode: string, code: string, value: any, rind: number) => {
if (!item) continue; if (!value) return
const { pid, itemid, formTp } = item; const stringValue = Array.isArray(value) ? value.join(',') : String(value)
const dataVal = valueObj[`${pid}_${itemid}_1`]; const key = getFieldKey(pcode, code)
const item = tplItemMap.value[key]
if (!dataVal) continue; if (!item) return
if (formTp === 'checkbox') { const formItem: FormDataItem = {
formData[strKey] = dataVal?.split(",") || []; id: null,
} else { rind,
formData[strKey] = dataVal || ""; taskid: queryParam.value.taskId,
} tplid: queryParam.value.tplId,
tplcode: code,
itemid: item.itemid,
itempid: item.pid,
content: stringValue
} }
for (const pcode of Object.keys(childAttachTableRefs.value)) { formValues.value.push(formItem)
const child = childAttachTableRefs.value[pcode]; }
const matchingKeys = Object.keys(tplItemMap.value).filter(key =>
key.startsWith(pcode + '_')
);
const attachTableData: Record<string, any> = {};
for (const key of matchingKeys) {
const tmpData = tplItemMap.value[key];
if (!tmpData) continue;
const { pid, itemid, formTp, code } = tmpData;
const valueKey = `${pid}_${itemid}_1`;
if (formTp === 'checkbox') { // 数据收集函数
attachTableData[code] = valueObj[valueKey]?.split(",") || []; const collectAttachTableData = async () => {
} else { for (const [pcode, child] of Object.entries(childAttachTableRefs.value)) {
attachTableData[code] = valueObj[valueKey] || ""; if (child) {
const datas = await child.getFormData()
for (const [code, value] of Object.entries(datas)) {
await addFormValue(pcode, code, value, 1)
} }
} }
child.setFormData(attachTableData);
} }
}
for (const pcode of Object.keys(childMultiTableRefs.value)) { const collectMultiTableData = async () => {
const child = childMultiTableRefs.value[pcode]; for (const [pcode, child] of Object.entries(childMultiTableRefs.value)) {
const matchingKeys = Object.keys(tplItemMap.value).filter(key => if (child) {
key.startsWith(pcode + '_') const datas = await child.getFormData()
); let rind = 0
for (const obj of datas) {
const rowsMap: Record<string, Record<string, any>> = {}; rind++
for (const key of matchingKeys) { for (const [code, value] of Object.entries(obj)) {
const tmpData = tplItemMap.value[key]; await addFormValue(pcode, code, value, rind)
if (!tmpData) continue;
const { pid, itemid, code } = tmpData;
const valKeys = Object.keys(valueObj).filter(k =>
k.startsWith(`${pid}_${itemid}_`)
);
for (const valKey of valKeys) {
const parts = valKey.split('_');
const rind = parts[2];
if (!rowsMap[rind]) {
rowsMap[rind] = {};
} }
rowsMap[rind][code] = valueObj[valKey];
} }
} }
const tableDatas = Object.values(rowsMap);
nextTick();
child.setFormData(tableDatas);
} }
}
} catch (error: any) { const collectVxeTableData = async () => {
VxeUI.modal.message({ for (const [pcode, child] of Object.entries(childMyVexTableRefs.value)) {
content: `加载数据失败: ${error.message}`, if (child) {
status: 'error' const formData = await child.getFormData()
}); let rind = 0
} finally { // 表格数据
loading.value = false; for (const obj of formData.datas) {
rind++
for (const [code, value] of Object.entries(obj)) {
await addFormValue(pcode, code, value, rind)
}
}
if (formData.footer) {
for (const [code, value] of Object.entries(formData.footer)) {
await addFormValue(formData.footerPcode, code, value, 1)
}
}
}
} }
} }
async function setTplItemMap() { // 数据加载
const loadTableData = async () => {
try { try {
const tplid = queryParam.value.tplId loading.value = true
const tplItem = await allTplItems({
tplid: tplid,
})
tplItemMap.value = {} // 清空现有数据
tplItem.forEach((item: any) => { Object.keys(formData).forEach(key => delete formData[key])
let strKey = getFieldKey(item.pcode, item.xmlcode)
tplItemMap.value[strKey] = { pid: item.pid, itemid: item.id, formTp: item.formTp, code: item.xmlcode } const recordData = await queryRecord({
taskid: queryParam.value.taskId,
tplid: queryParam.value.tplId
}) })
} catch (error: any) {
VxeUI.modal.message({ content: `加载数据失败: ${error.message}`, status: 'error' })
}
}
// 校验数据 // 转换记录数据为便于查找的结构
const validateData = () => { const valueMap = recordData.reduce((acc: Record<string, string>, data) => {
drawerVisible.value = true const key = `${data.itempid}_${data.itemid}_${data.rind}`
} acc[key] = data.content
return acc
}, {})
// 校验结果抽屉显示时触发 // 填充表格数据
const handleValidationDrawerShow = () => { await fillTableData(valueMap)
performValidation() } catch (error: any) {
showErrorMessage(`加载数据失败: ${error.message}`)
} finally {
loading.value = false
}
} }
// 执行校验 const fillTableData = async (valueMap: Record<string, string>) => {
const performValidation = () => { for (const row of tableFormData) {
validationResultsList.value = [] if (!row.type && row.content) {
const process: string[] = [] await fillSimpleFields(row, valueMap)
process.push('开始校验') } else if (row.type === 'AttachTable' && row.datas) {
process.push(`找到 ${validFormula.value.length} 个验证公式`) await fillAttachTable(row, valueMap)
} else if (row.type === 'MultiColumnTable' && row.content) {
validFormula.value.forEach((formulaItem: any) => { await fillMultiColumnTable(row, valueMap)
process.push(`开始校验公式: ${formulaItem.des}`) } else if (row.type === 'VxeTable' && row.columns) {
const result = evaluateFormula(formulaItem.formula, formulaItem.des, process) await fillVxeTable(row, valueMap)
if (result) { }
validationResultsList.value.push(result)
} }
})
process.push('校验完成')
} }
// 解析和执行验证公式 const fillSimpleFields = async (row: TableRow, valueMap: Record<string, string>) => {
const evaluateFormula = (formula: string, description: string, process: string[]): any => { if (!row.content || !Array.isArray(row.content)) return
try {
const fieldMatch = formula.match(/\[(\w+)\]/)
if (!fieldMatch) {
process.push(`跳过: 无法解析公式字段 ${formula}`)
return null
}
const fieldName = fieldMatch[1] for (const item of row.content) {
const row = tableFormData.find((r: any) => r.content?.some((c: any) => c.field === fieldName)) if (!item.field) continue
if (!row) {
process.push(`跳过: 未找到字段 ${fieldName}`)
return null
}
const fieldItem = row.content.find((c: any) => c.field === fieldName) const key = getFieldKey(row.code, item.field)
if (!fieldItem) { const tplItem = tplItemMap.value[key]
process.push(`跳过: 未找到字段 ${fieldName}`) if (!tplItem) continue
return null
}
const strKey = getFieldKey(row.code, fieldName) const { pid, itemid, formTp } = tplItem
const fieldValue = formData[strKey] const valueKey = `${pid}_${itemid}_1`
const dataVal = valueMap[valueKey]
// 检查是否有空字段规则 if (dataVal === undefined) continue
const emptyFieldRule = validFormula.value.find((f: any) =>
f.formula.includes(fieldName) && f.des.includes('空字段')
)
if (emptyFieldRule && (!fieldValue || fieldValue === '')) { if (formTp === 'checkbox') {
process.push(`跳过: 字段 ${fieldName} 为空,跳过空字段规则`) formData[key] = dataVal.split(',').filter(Boolean)
return null } else {
formData[key] = dataVal
} }
const expression = formula.replace(/\[(\w+)\]/g, (_, field) => { // 处理特殊字段类型
const value = formData[getFieldKey(row.code, field)] if (item.type === 'checkboxAndInput' && item.optionItemField) {
return value !== undefined ? `Number(${value})` : '0' await fillCheckboxInputFields(row, item, valueMap)
}) }
process.push(`执行公式: ${expression}`)
const isValid = eval(expression)
return { if (item.otherField) {
field: fieldName, await fillOtherField(row, item, valueMap)
description: description,
formula: formula,
isValid: isValid,
fieldValue: fieldValue,
rowCode: row.code
} }
} catch (error) {
process.push(`公式执行错误: ${error instanceof Error ? error.message : String(error)}`)
return null
} }
} }
// 显示验证公式帮助 const fillCheckboxInputFields = async (
const showValidationHelp = (formulaItem: any, event: MouseEvent) => { row: TableRow,
const rect = (event.target as HTMLElement).getBoundingClientRect() item: ContentItem,
validationTooltipPosition.value = { valueMap: Record<string, string>
left: rect.left + rect.width / 2, ) => {
top: rect.top - 10 for (const field of item.optionItemField || []) {
} const key = getFieldKey(row.code, field)
validationTooltipContent.value = `验证公式: ${formulaItem.formula}\n说明: ${formulaItem.des}` const tplItem = tplItemMap.value[key]
validationTooltipVisible.value = true if (!tplItem) continue
}
// 关闭验证公式帮助 const { pid, itemid } = tplItem
const closeTooltip = () => { const valueKey = `${pid}_${itemid}_1`
validationTooltipVisible.value = false const dataVal = valueMap[valueKey]
}
// 打开历史填报抽屉 if (dataVal !== undefined) {
const handleOpenHistoryDrawer = () => { formData[key] = dataVal
historyDrawerVisible.value = true }
}
} }
// 关闭历史填报抽屉 const fillOtherField = async (
const closeHistoryDrawer = () => { row: TableRow,
historyDrawerVisible.value = false item: ContentItem,
} valueMap: Record<string, string>
) => {
const key = getFieldKey(row.code, item.otherField!)
const tplItem = tplItemMap.value[key]
if (!tplItem) return
interface FormulaItem { const { pid, itemid } = tplItem
formula: string const valueKey = `${pid}_${itemid}_1`
des: string const dataVal = valueMap[valueKey]
[key: string]: any
}
interface InputError { if (dataVal !== undefined) {
message: string formData[key] = dataVal
formula: string }
error?: string
} }
const fieldKeys = computed(() => Object.keys(formData)) const fillAttachTable = async (row: TableRow, valueMap: Record<string, string>) => {
const child = childAttachTableRefs.value[row.code]
if (!child) return
const showHelpIcon = (rowCode: string, field: string, item: any): boolean => { const tableData: Record<string, any> = {}
if (item.hasValidFormula !== undefined) {
return item.hasValidFormula === true for (const data of row.datas || []) {
} for (const [key, value] of Object.entries(data)) {
if (typeof value === 'object' && value.field) {
const fieldKey = getFieldKey(row.code, value.field)
const tplItem = tplItemMap.value[fieldKey]
if (!tplItem) continue
const key = getFieldKey(rowCode, field) const { pid, itemid, formTp, code } = tplItem
const hasRight = userAllocItems.value.includes(key) const valueKey = `${pid}_${itemid}_1`
const dataVal = valueMap[valueKey]
if (!hasRight) return false if (dataVal) {
tableData[code] = formTp === 'checkbox' ? dataVal.split(',') : dataVal
}
}
}
}
const formulaResult = findEarliestFormulaForField(validFormula.value, field) child.setFormData(tableData)
return !!formulaResult.formula
} }
const setFormItemRight = () => { const fillMultiColumnTable = async (row: TableRow, valueMap: Record<string, string>) => {
console.log('开始设置表单权限...') const child = childMultiTableRefs.value[row.code]
console.log('userAllocItems 数量:', userAllocItems.value.length) if (!child || !Array.isArray(row.content)) return
console.log('validFormula 数量:', validFormula.value.length)
tableFormData.forEach((row: any) => { const rowsMap: Record<string, Record<string, string>> = {}
if (row.content && Array.isArray(row.content)) {
row.content.forEach((item: any) => {
if (item.field) {
const key = getFieldKey(row.code, item.field)
item.hasRight = userAllocItems.value.includes(key)
console.log(`字段 ${key}: hasRight = ${item.hasRight}`) for (const item of row.content) {
if (!item.field) continue
if (item.hasRight) { const key = getFieldKey(row.code, item.field)
const formulaResult = findEarliestFormulaForField(validFormula.value, item.field) const tplItem = tplItemMap.value[key]
if (!tplItem) continue
item.hasValidFormula = !!formulaResult.formula const { pid, itemid, code } = tplItem
item.matchedFormula = formulaResult.formula || null const valueKeys = Object.keys(valueMap).filter(k =>
k.startsWith(`${pid}_${itemid}_`)
)
console.log(`字段 ${key}: hasValidFormula = ${item.hasValidFormula}`) for (const valueKey of valueKeys) {
} else { const [, , rind] = valueKey.split('_')
item.hasValidFormula = false if (!rowsMap[rind]) {
item.matchedFormula = null rowsMap[rind] = {}
} }
rowsMap[rind][code] = valueMap[valueKey]
} }
})
} }
})
console.log('表单权限设置完成') const tableDatas = Object.values(rowsMap)
child.setFormData(tableDatas)
} }
const findEarliestFormulaForField = ( const fillVxeTable = async (row: TableRow, valueMap: Record<string, string>) => {
formulas: FormulaItem[], const child = childMyVexTableRefs.value[row.code]
field: string if (!child || !Array.isArray(row.columns)) return
): { formula: FormulaItem | null, index: number } => {
let result = { formula: null, index: Infinity }
formulas?.forEach((f: FormulaItem) => { const rowsMap: Record<string, Record<string, string>> = {}
const text = f.formula || ''
const escapedField = field.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
const regex = new RegExp(`\\b${escapedField}\\b(?!\\w)`, 'g')
const match = regex.exec(text)
if (match && match.index < result.index) { for (const column of row.columns) {
result = { formula: f, index: match.index } if (!column.field) continue
}
})
return result const key = getFieldKey(row.code, column.field)
} const tplItem = tplItemMap.value[key]
if (!tplItem || Object.keys(tplItem).length === 0) continue
const refreshHelpIcons = () => { const { pid, itemid, code } = tplItem
console.log('刷新帮助图标...') const valueKeys = Object.keys(valueMap).filter(k =>
tableFormData.forEach((row: any) => { k.startsWith(`${pid}_${itemid}_`)
if (row.content && Array.isArray(row.content)) { )
row.content.forEach((item: any) => {
if (item.field) {
const key = getFieldKey(row.code, item.field)
const hasRight = userAllocItems.value.includes(key)
if (hasRight) { for (const valueKey of valueKeys) {
const formulaResult = findEarliestFormulaForField(validFormula.value, item.field) const [, , rind] = valueKey.split('_')
item.hasValidFormula = !!formulaResult.formula if (!rowsMap[rind]) {
item.matchedFormula = formulaResult.formula || null rowsMap[rind] = {}
} else {
item.hasValidFormula = false
item.matchedFormula = null
} }
rowsMap[rind][code] = valueMap[valueKey]
} }
})
} }
})
nextTick(() => { const tableDatas = Object.values(rowsMap)
console.log('帮助图标刷新完成') child.setFormData(tableDatas)
}) }
// 校验相关
const validateData = () => {
drawerVisible.value = true
validationDrawerRef.value.setValidateData(validFormula.value,formData);
} }
const handleInputBlur = (rowCode: string, field: string, formula?: string) => { const handleInputBlur = (rowCode: string, field: string, formula?: string) => {
...@@ -938,10 +919,26 @@ const buildExpression = (formula: string, rowCode: string): string => { ...@@ -938,10 +919,26 @@ const buildExpression = (formula: string, rowCode: string): string => {
for (const fieldName of uniqueFields) { for (const fieldName of uniqueFields) {
const key = getFieldKey(rowCode, fieldName) const key = getFieldKey(rowCode, fieldName)
const value = formData[key] const value = formData[key]
if (value !== undefined) { if (value !== undefined) {
// 检查字段类型,如果是日期类型,转换为时间戳进行比较
const row = tableFormData.find((r: TableRow) => r.code === rowCode)
let processedValue = value
if (row && row.content && Array.isArray(row.content)) {
const fieldItem = row.content.find((c: ContentItem) => c.field === fieldName)
if (fieldItem && fieldItem.type === 'date') {
// 将日期字符串转换为时间戳(毫秒)
const date = new Date(value)
if (!isNaN(date.getTime())) {
processedValue = date.getTime()
}
}
}
expression = expression.replace( expression = expression.replace(
new RegExp(`\\b${fieldName}\\b`, 'g'), new RegExp(`\\b${fieldName}\\b`, 'g'),
`Number(${value})` `Number(${processedValue})`
) )
} }
} }
...@@ -949,6 +946,7 @@ const buildExpression = (formula: string, rowCode: string): string => { ...@@ -949,6 +946,7 @@ const buildExpression = (formula: string, rowCode: string): string => {
return expression return expression
} }
// 提示工具相关
const toggleTooltip = (rowCode: string, field: string) => { const toggleTooltip = (rowCode: string, field: string) => {
const key = getFieldKey(rowCode, field) const key = getFieldKey(rowCode, field)
if (hoveredKey.value === key) { if (hoveredKey.value === key) {
...@@ -976,285 +974,171 @@ const closeAllTooltips = () => { ...@@ -976,285 +974,171 @@ const closeAllTooltips = () => {
hoveredKey.value = '' hoveredKey.value = ''
showErrorTooltip.value = false showErrorTooltip.value = false
hoveredErrorKey.value = '' hoveredErrorKey.value = ''
validationTooltipVisible.value = false
} }
const handleValidationResultClick = (result: any) => { // 历史填报
const message = `字段 ${result.field} 的校验结果: ${result.isValid ? '通过' : '失败'}` const handleOpenHistoryDrawer = () => {
const status = result.isValid ? 'success' : 'error' historyFillCheckRef.value?.onDrawerShow(queryParam.value.tplId)
historyDrawerVisible.value = true
VxeUI.modal.message({ content: message, status })
} }
</script> const closeHistoryDrawer = () => {
<style lang="less" scoped> historyDrawerVisible.value = false
/* 基础字体和排版 */
.bank-report-table {
font-family: "SimSun", "宋体", serif;
font-size: 12px;
color: #000;
margin: 5px auto;
width: 90%;
}
/* 表格样式 */
.custom-table,
.attachment-table {
width: 100%;
border: 1px solid #000;
border-collapse: collapse;
} }
/* 加载遮罩层样式 */ // 校验结果处理
.loading-overlay { const handleValidationResultClick = (result: any) => {
position: absolute; const message = `字段 ${result.field} 的校验结果: ${result.isValid ? '通过' : '失败'}`
top: 0; const status = result.isValid ? 'success' : 'error'
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.8);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
}
.loading-spinner { VxeUI.modal.message({ content: message, status })
display: flex;
flex-direction: column;
align-items: center;
} }
.spinner { // 工具函数
width: 40px; const findEarliestFormulaForField = (
height: 40px; formulas: FormulaItem[],
border: 3px solid #f3f3f3; field: string
border-top: 3px solid #3498db; ): { formula: FormulaItem | null, index: number } => {
border-radius: 50%; let result = { formula: null, index: Infinity }
animation: spin 2s linear infinite;
}
@keyframes spin { formulas?.forEach((f: FormulaItem) => {
0% { const text = f.formula || ''
transform: rotate(0deg); const escapedField = field.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
} const regex = new RegExp(`\\b${escapedField}\\b(?!\\w)`, 'g')
const match = regex.exec(text)
100% { if (match && match.index < result.index) {
transform: rotate(360deg); result = { formula: f, index: match.index }
} }
} })
.loading-text {
margin-top: 10px;
color: #666;
font-size: 14px;
}
/* 校验结果样式 */
.validation-results {
padding: 20px;
height: 600px;
overflow-y: auto;
}
.result-summary {
display: flex;
gap: 20px;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 1px solid #eee;
}
.summary-item {
display: flex;
flex-direction: column;
}
.summary-label {
font-size: 12px;
color: #666;
}
.summary-value {
font-size: 16px;
font-weight: bold;
color: #333;
}
.summary-value.success {
color: #52c41a;
}
.summary-value.error {
color: #ff4d4f;
}
.results-list { return result
margin-top: 10px;
} }
.result-item { // 消息提示
padding: 10px; const showSuccessMessage = (message: string) => {
margin-bottom: 8px; VxeUI.modal.message({ content: message, status: 'success' })
border-radius: 4px;
cursor: pointer;
transition: background-color 0.2s;
} }
.result-item:hover { const showWarningMessage = (message: string) => {
background-color: #f5f5f5; VxeUI.modal.message({ content: message, status: 'warning' })
} }
.result-item.success { const showErrorMessage = (message: string) => {
background-color: #f6ffed; VxeUI.modal.message({ content: message, status: 'error' })
border-left: 4px solid #52c41a;
} }
.result-item.error { // 子组件引用设置
background-color: #fff2f0; const setMultiColumnTableRef = (el: any, code: string) => {
border-left: 4px solid #ff4d4f; if (el) childMultiTableRefs.value[code] = el
} }
.result-field { const setAttachTableRef = (el: any, code: string) => {
font-weight: bold; if (el) childAttachTableRefs.value[code] = el
margin-bottom: 5px;
} }
.result-desc { const setMyVxeTableRef = (el: any, code: string) => {
font-size: 12px; if (el) childMyVexTableRefs.value[code] = el
color: #666;
margin-bottom: 5px;
} }
</script>
.result-value { <style lang="less" scoped>
// Base table styles
.bank-report-table {
font-family: "SimSun", "宋体", serif;
font-size: 12px; font-size: 12px;
color: #999; color: #000;
} margin: 5px auto;
width: 90%;
position: relative;
.result-error { // Shared table styles
font-size: 12px; .custom-table, .attachment-table {
color: #ff4d4f; width: 100%;
margin-top: 5px; border: 1px solid #000;
}
/* 验证公式帮助提示样式 */ .vxe-header--column,
.validation-tooltip { .vxe-body--column {
position: absolute; border-right: 1px solid #000;
background-color: #333; border-bottom: 1px solid #000;
color: #fff; padding: 5px;
padding: 10px; }
border-radius: 4px; }
font-size: 12px;
z-index: 1000;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
} }
.tooltip-content { // 表格信息文本
margin: 0; .table-info-text {
white-space: pre-wrap; font-weight: bold;
} }
/* 表格单元格样式 */ // 项目名称
.custom-table .vxe-header--column, .project-name {
.custom-table .vxe-body--column, font-weight: bold;
.attachment-table .vxe-header--column, font-size: 14px;
.attachment-table .vxe-body--column {
border-right: 1px solid #000;
border-bottom: 1px solid #000;
padding: 5px;
} }
/* 内容单元格 */ // Cell styles
.content-cell { .content-cell {
line-height: 1.8; line-height: 1.8;
} }
/* 输入框包装器 */ // 表单控件组
.input-wrapper { .radio-group, .checkbox-group {
position: relative;
display: inline-block; display: inline-block;
} margin-left: 10px;
/* 输入框样式 */ .vxe-radio, .vxe-checkbox {
.table-input, margin-left: 0px;
.vxe-input { white-space: nowrap;
height: 24px;
line-height: 30px; line-height: 30px;
min-width: 150px; padding: 0px 10px;
margin: 0 2px;
padding: 0 5px;
border: none;
border-bottom: 1px solid #333;
background: transparent;
text-align: center;
}
/* 表单元素的标签和图标 */ &--label {
.vxe-radio--label,
.vxe-checkbox--label {
font-size: 12px; font-size: 12px;
} }
.vxe-radio--icon, &--icon {
.vxe-checkbox--icon {
font-size: 12px; font-size: 12px;
}
}
} }
/* 单选框组和复选框组布局 */ // VXE specific overrides
.vxe-radio-group, .vxe {
.vxe-checkbox-group { &-radio-group, &-checkbox-group {
display: inline-block;
margin-right: 5px;
max-width: 99%;
}
/* 其他辅助样式 */
.radio-group,
.checkbox-group {
display: inline-block; display: inline-block;
margin-right: 5px; }
max-width: 99%;
min-width: 50%;
}
.vxe-radio,
.vxe-checkbox {
margin: 5px 5px 5px 30px;
white-space: nowrap;
}
/* 附件部分样式 */
.attachments {
margin-top: 20px;
width: 100%;
}
.attachments h4 { &-cell {
font-size: 14px; padding: 5px;
font-weight: bold; }
margin-bottom: 10px;
} }
.attachment-table { .vxe-input {
width: 100%; border-bottom: 1px solid #333;
border: 1px solid #000; text-align: center;
border-collapse: collapse; margin: 5px 3px;
padding: 0;
border-top: none;
border-left: none;
border-right: none;
background: transparent;
} }
/* 其他特殊块 */ // 输入框包装器
blockquote { .input-wrapper {
padding: 0 5px; position: relative;
color: black; display: inline-block;
cursor: pointer;
} }
/* 单位文本 */ // 单位文本
.unit { .unit {
margin-left: 5px; margin-left: 5px;
font-size: 12px; font-size: 12px;
} }
/* 帮助图标 */ // 帮助图标
.help-icon { .help-icon {
margin-left: 5px; margin-left: 5px;
cursor: pointer; cursor: pointer;
...@@ -1269,29 +1153,13 @@ blockquote { ...@@ -1269,29 +1153,13 @@ blockquote {
background: #e6f7ff; background: #e6f7ff;
border-radius: 50%; border-radius: 50%;
transition: all 0.3s; transition: all 0.3s;
opacity: 0;
animation: fadeIn 0.5s forwards;
animation-delay: 0.3s;
&:hover { &:hover {
background: #bae7ff; background: #bae7ff;
transform: scale(1.1);
}
}
@keyframes fadeIn {
from {
opacity: 0;
transform: scale(0.8);
}
to {
opacity: 1;
transform: scale(1);
} }
} }
/* 错误图标 */ // 错误图标
.error-icon { .error-icon {
margin-left: 5px; margin-left: 5px;
cursor: pointer; cursor: pointer;
...@@ -1309,9 +1177,8 @@ blockquote { ...@@ -1309,9 +1177,8 @@ blockquote {
} }
} }
/* 提示框 */ // 提示框
.tooltip, .tooltip, .error-tooltip {
.error-tooltip {
position: absolute; position: absolute;
top: 100%; top: 100%;
left: 0; left: 0;
...@@ -1355,4 +1222,42 @@ blockquote { ...@@ -1355,4 +1222,42 @@ blockquote {
border-color: transparent transparent #8b0000 transparent; border-color: transparent transparent #8b0000 transparent;
} }
} }
// 加载遮罩
.loading-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(255, 255, 255, 0.8);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
}
.loading-spinner {
text-align: center;
}
.spinner {
width: 40px;
height: 40px;
border: 3px solid #f3f3f3;
border-top: 3px solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
margin: 0 auto 10px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.loading-text {
font-size: 14px;
color: #666;
}
</style> </style>
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<!--引用表格--> <!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection"> <BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #action="{ record }"> <template #action="{ record }">
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" /> <TableAction :actions="getTableAction(record)" />
</template> </template>
</BasicTable> </BasicTable>
<!-- 表单区域 --> <!-- 表单区域 -->
...@@ -93,7 +93,6 @@ ...@@ -93,7 +93,6 @@
} }
async function handlePreview(record) { async function handlePreview(record) {
alert(JSON.stringify(record));
await gotoPage(record); await gotoPage(record);
} }
...@@ -205,7 +204,9 @@ const gotoPage = async (item) => { ...@@ -205,7 +204,9 @@ const gotoPage = async (item) => {
path: targetPath, path: targetPath,
query: { query: {
taskId: taskid, taskId: taskid,
taskName: "",
tplId: tplid, tplId: tplid,
tplName: "",
comfrom: 'archive' comfrom: 'archive'
} }
}); });
......
...@@ -597,7 +597,7 @@ ...@@ -597,7 +597,7 @@
keyword.value = value; keyword.value = value;
} }
function areaChange(value) { function areaChange(value) {
alert(value); //alert(value);
} }
return { return {
......
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
let formData = {}; let formData = {};
const queryById = '/problem/stProblemCheck/queryById'; const queryById = '/problem/stProblemCheck/queryById';
async function initFormData() { async function initFormData() {
alert(1)
let params = { id: props.formData.dataId }; let params = { id: props.formData.dataId };
const data = await defHttp.get({ url: queryById, params }); const data = await defHttp.get({ url: queryById, params });
formData = { ...data }; formData = { ...data };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论