|
|
@@ -8,7 +8,7 @@
|
|
|
v-model="searchForm.catalogId"
|
|
|
:options="catalogListOptions"
|
|
|
placeholder=" 请选择监审类别"
|
|
|
- v-bind="catalogIdProps"
|
|
|
+ v-bind="props"
|
|
|
style="width: 100%"
|
|
|
clearable
|
|
|
></el-cascader>
|
|
|
@@ -162,7 +162,12 @@
|
|
|
>
|
|
|
查看
|
|
|
</el-button>
|
|
|
- <el-button type="text" size="mini" @click="handleEdit(scope.row)">
|
|
|
+ <el-button
|
|
|
+ v-if="scope.row.status != '0'"
|
|
|
+ type="text"
|
|
|
+ size="mini"
|
|
|
+ @click="handleEdit(scope.row)"
|
|
|
+ >
|
|
|
修改
|
|
|
</el-button>
|
|
|
<el-button
|
|
|
@@ -174,6 +179,7 @@
|
|
|
{{ scope.row.status == '0' ? '停用' : '启用' }}
|
|
|
</el-button>
|
|
|
<el-button
|
|
|
+ v-if="scope.row.status != '0'"
|
|
|
type="text"
|
|
|
size="mini"
|
|
|
@click="handleDeleteRow(scope.row)"
|
|
|
@@ -187,6 +193,7 @@
|
|
|
class="mt20"
|
|
|
:current-page.sync="searchForm.pageNum"
|
|
|
:page-size="searchForm.pageSize"
|
|
|
+ :page-sizes="[50, 100]"
|
|
|
layout="total, sizes, prev, pager, next, jumper"
|
|
|
:total="pagination.total"
|
|
|
@current-change="handleCurrentChange"
|
|
|
@@ -215,19 +222,7 @@
|
|
|
<el-cascader
|
|
|
v-model="contentEditForm.catalogId"
|
|
|
:options="catalogListOptions"
|
|
|
- v-bind="{
|
|
|
- filterable: true,
|
|
|
- placeholder: '请选择关联监审项目',
|
|
|
- style: 'width: 100%',
|
|
|
- showAllLevels: false,
|
|
|
- props: {
|
|
|
- children: 'children',
|
|
|
- checkStrictly: true,
|
|
|
- label: 'catalogName',
|
|
|
- value: 'id',
|
|
|
- emitPath: false,
|
|
|
- },
|
|
|
- }"
|
|
|
+ v-bind="props"
|
|
|
style="width: 100%"
|
|
|
></el-cascader>
|
|
|
</el-form-item>
|
|
|
@@ -251,6 +246,11 @@
|
|
|
<el-radio
|
|
|
v-model="contentEditForm.createmode"
|
|
|
label="1"
|
|
|
+ :disabled="
|
|
|
+ dialogTitle == '修改成本核定模板' ||
|
|
|
+ dialogTitle == '查看成本核定模板' ||
|
|
|
+ contentEditForm.createmode != '1'
|
|
|
+ "
|
|
|
@change="handleCreateModeChange"
|
|
|
>
|
|
|
根据调查表生成:
|
|
|
@@ -261,6 +261,7 @@
|
|
|
placeholder="请选择"
|
|
|
:disabled="
|
|
|
dialogTitle == '修改成本核定模板' ||
|
|
|
+ dialogTitle == '查看成本核定模板' ||
|
|
|
contentEditForm.createmode != '1'
|
|
|
"
|
|
|
>
|
|
|
@@ -279,7 +280,11 @@
|
|
|
<el-radio
|
|
|
v-model="contentEditForm.createmode"
|
|
|
label="2"
|
|
|
- :disabled="dialogTitle == '修改成本核定模板'"
|
|
|
+ :disabled="
|
|
|
+ dialogTitle == '修改成本核定模板' ||
|
|
|
+ dialogTitle == '查看成本核定模板' ||
|
|
|
+ contentEditForm.createmode != '2'
|
|
|
+ "
|
|
|
@change="handleCreateModeChange"
|
|
|
>
|
|
|
根据历史核定模板生成:
|
|
|
@@ -290,6 +295,7 @@
|
|
|
placeholder="请选择"
|
|
|
:disabled="
|
|
|
dialogTitle == '修改成本核定模板' ||
|
|
|
+ dialogTitle == '查看成本核定模板' ||
|
|
|
contentEditForm.createmode != '2'
|
|
|
"
|
|
|
>
|
|
|
@@ -314,9 +320,6 @@
|
|
|
>
|
|
|
生成模版
|
|
|
</el-button>
|
|
|
- <el-button type="primary" @click="handleSaveTemplate">
|
|
|
- 保存模版
|
|
|
- </el-button>
|
|
|
</div>
|
|
|
<div
|
|
|
v-if="contentEditForm.surveyTemplateId"
|
|
|
@@ -324,11 +327,19 @@
|
|
|
>
|
|
|
<div class="mb20">
|
|
|
<el-button
|
|
|
+ v-if="dialogTitle != '查看成本核定模板'"
|
|
|
type="primary"
|
|
|
@click="handleAddTableHeader('固定表表头')"
|
|
|
>
|
|
|
添加表头
|
|
|
</el-button>
|
|
|
+ <el-button
|
|
|
+ v-if="dialogTitle != '查看成本核定模板'"
|
|
|
+ type="primary"
|
|
|
+ @click="handleSaveContent('固定表表头')"
|
|
|
+ >
|
|
|
+ 下一步
|
|
|
+ </el-button>
|
|
|
</div>
|
|
|
<div class="table-edit-container">
|
|
|
<el-table
|
|
|
@@ -352,7 +363,9 @@
|
|
|
v-model="scope.row.fieldName"
|
|
|
placeholder="请输入字段名称"
|
|
|
size="small"
|
|
|
- :disabled="scope.row.isReadOnly"
|
|
|
+ :disabled="
|
|
|
+ scope.row.isReadOnly || dialogTitle == '查看成本核定模板'
|
|
|
+ "
|
|
|
@change="handleFieldNameChange(scope.row)"
|
|
|
></el-input>
|
|
|
</template>
|
|
|
@@ -368,7 +381,9 @@
|
|
|
v-model="scope.row.fieldType"
|
|
|
placeholder="请选择字段类型"
|
|
|
size="small"
|
|
|
- :disabled="scope.row.isReadOnly"
|
|
|
+ :disabled="
|
|
|
+ scope.row.isReadOnly || dialogTitle == '查看成本核定模板'
|
|
|
+ "
|
|
|
@change="handleFieldTypeChange(scope.row)"
|
|
|
>
|
|
|
<el-option label="字符串" value="string"></el-option>
|
|
|
@@ -397,7 +412,10 @@
|
|
|
placeholder="请输入长度"
|
|
|
size="small"
|
|
|
style="width: calc(100% - 80px); margin-left: 5px"
|
|
|
- :disabled="scope.row.isReadOnly"
|
|
|
+ :disabled="
|
|
|
+ scope.row.isReadOnly ||
|
|
|
+ dialogTitle == '查看成本核定模板'
|
|
|
+ "
|
|
|
></el-input>
|
|
|
</div>
|
|
|
|
|
|
@@ -412,7 +430,10 @@
|
|
|
placeholder="整数位数"
|
|
|
size="small"
|
|
|
style="width: calc(100% - 80px); margin: 0 5px"
|
|
|
- :disabled="scope.row.isReadOnly"
|
|
|
+ :disabled="
|
|
|
+ scope.row.isReadOnly ||
|
|
|
+ dialogTitle == '查看成本核定模板'
|
|
|
+ "
|
|
|
></el-input>
|
|
|
</div>
|
|
|
|
|
|
@@ -427,7 +448,10 @@
|
|
|
placeholder="小数位数"
|
|
|
size="small"
|
|
|
style="width: calc(100% - 80px); margin-left: 5px"
|
|
|
- :disabled="scope.row.isReadOnly"
|
|
|
+ :disabled="
|
|
|
+ scope.row.isReadOnly ||
|
|
|
+ dialogTitle == '查看成本核定模板'
|
|
|
+ "
|
|
|
></el-input>
|
|
|
</div>
|
|
|
<!-- 日期类型格式 -->
|
|
|
@@ -440,7 +464,10 @@
|
|
|
placeholder="请选择日期格式"
|
|
|
size="small"
|
|
|
style="width: 100%"
|
|
|
- :disabled="scope.row.isReadOnly"
|
|
|
+ :disabled="
|
|
|
+ scope.row.isReadOnly ||
|
|
|
+ dialogTitle == '查看成本核定模板'
|
|
|
+ "
|
|
|
>
|
|
|
<el-option
|
|
|
label="yyyy-MM-dd HH:mm:ss"
|
|
|
@@ -459,7 +486,10 @@
|
|
|
placeholder="请选择布尔值格式"
|
|
|
size="small"
|
|
|
style="width: 100%"
|
|
|
- :disabled="scope.row.isReadOnly"
|
|
|
+ :disabled="
|
|
|
+ scope.row.isReadOnly ||
|
|
|
+ dialogTitle == '查看成本核定模板'
|
|
|
+ "
|
|
|
>
|
|
|
<el-option label="true" value="true"></el-option>
|
|
|
<el-option label="false" value="false"></el-option>
|
|
|
@@ -485,7 +515,9 @@
|
|
|
<el-select
|
|
|
v-model="scope.row.isRequired"
|
|
|
size="small"
|
|
|
- :disabled="scope.row.isReadOnly"
|
|
|
+ :disabled="
|
|
|
+ scope.row.isReadOnly || dialogTitle == '查看成本核定模板'
|
|
|
+ "
|
|
|
>
|
|
|
<el-option label="是" value="true"></el-option>
|
|
|
<el-option label="否" value="false"></el-option>
|
|
|
@@ -503,7 +535,9 @@
|
|
|
<el-select
|
|
|
v-model="scope.row.showVisible"
|
|
|
size="small"
|
|
|
- :disabled="scope.row.isReadOnly"
|
|
|
+ :disabled="
|
|
|
+ scope.row.isReadOnly || dialogTitle == '查看成本核定模板'
|
|
|
+ "
|
|
|
>
|
|
|
<el-option label="是" value="1"></el-option>
|
|
|
<el-option label="否" value="0"></el-option>
|
|
|
@@ -521,7 +555,9 @@
|
|
|
<el-select
|
|
|
v-model="scope.row.isAuditPeriod"
|
|
|
size="small"
|
|
|
- :disabled="scope.row.isReadOnly"
|
|
|
+ :disabled="
|
|
|
+ scope.row.isReadOnly || dialogTitle == '查看成本核定模板'
|
|
|
+ "
|
|
|
>
|
|
|
<el-option label="是" value="true"></el-option>
|
|
|
<el-option label="否" value="false"></el-option>
|
|
|
@@ -538,9 +574,13 @@
|
|
|
<template slot-scope="scope">
|
|
|
<div class="table-actions">
|
|
|
<el-button
|
|
|
+ v-if="dialogTitle != '查看成本核定模板'"
|
|
|
type="text"
|
|
|
size="mini"
|
|
|
- :disabled="scope.row.isReadOnly"
|
|
|
+ :disabled="
|
|
|
+ scope.row.isReadOnly ||
|
|
|
+ dialogTitle == '查看成本核定模板'
|
|
|
+ "
|
|
|
@click="
|
|
|
handleDeleteHeader(
|
|
|
scope.$index,
|
|
|
@@ -552,10 +592,15 @@
|
|
|
删除
|
|
|
</el-button>
|
|
|
<el-button
|
|
|
- v-if="scope.$index !== 0"
|
|
|
+ v-if="
|
|
|
+ scope.$index !== 0 || dialogTitle != '查看成本核定模板'
|
|
|
+ "
|
|
|
type="text"
|
|
|
size="mini"
|
|
|
- :disabled="scope.row.isReadOnly"
|
|
|
+ :disabled="
|
|
|
+ scope.row.isReadOnly ||
|
|
|
+ dialogTitle == '查看成本核定模板'
|
|
|
+ "
|
|
|
@click="handleMoveUp(scope.$index)"
|
|
|
>
|
|
|
上升
|
|
|
@@ -563,11 +608,15 @@
|
|
|
<el-button
|
|
|
v-if="
|
|
|
scope.$index !==
|
|
|
- contentEditForm.fixedTable.tableHeaders.length - 1
|
|
|
+ contentEditForm.fixedTable.tableHeaders.length - 1 ||
|
|
|
+ dialogTitle == '查看成本核定模板'
|
|
|
"
|
|
|
type="text"
|
|
|
size="mini"
|
|
|
- :disabled="scope.row.isReadOnly"
|
|
|
+ :disabled="
|
|
|
+ scope.row.isReadOnly ||
|
|
|
+ dialogTitle == '查看成本核定模板'
|
|
|
+ "
|
|
|
@click="handleMoveDown(scope.$index)"
|
|
|
>
|
|
|
下降
|
|
|
@@ -580,11 +629,19 @@
|
|
|
<div>
|
|
|
<div class="button-group mt20 mb20">
|
|
|
<el-button
|
|
|
+ v-if="dialogTitle != '查看成本核定模板'"
|
|
|
type="primary"
|
|
|
@click="handleAddTableHeader('固定表项目')"
|
|
|
>
|
|
|
添加项目
|
|
|
</el-button>
|
|
|
+ <el-button
|
|
|
+ v-if="dialogTitle != '查看成本核定模板'"
|
|
|
+ type="primary"
|
|
|
+ @click="handleSaveTemplate"
|
|
|
+ >
|
|
|
+ 保存
|
|
|
+ </el-button>
|
|
|
</div>
|
|
|
<div class="table-edit-container">
|
|
|
<el-table
|
|
|
@@ -604,6 +661,7 @@
|
|
|
"
|
|
|
size="small"
|
|
|
placeholder="数字或中文"
|
|
|
+ :disabled="dialogTitle == '查看成本核定模板'"
|
|
|
@input="
|
|
|
handleFixedValueChange(scope.row, '序号', $event)
|
|
|
"
|
|
|
@@ -660,6 +718,7 @@
|
|
|
: ''
|
|
|
"
|
|
|
size="small"
|
|
|
+ :disabled="dialogTitle == '查看成本核定模板'"
|
|
|
@input="
|
|
|
handleFixedValueChange(scope.row, item.rkey, $event)
|
|
|
"
|
|
|
@@ -673,6 +732,7 @@
|
|
|
<el-input
|
|
|
:value="scope.row.cellCode"
|
|
|
size="small"
|
|
|
+ :disabled="dialogTitle == '查看成本核定模板'"
|
|
|
@input="(val) => $set(scope.row, 'cellCode', val)"
|
|
|
></el-input>
|
|
|
</div>
|
|
|
@@ -690,6 +750,7 @@
|
|
|
:value="scope.row.calculationFormula"
|
|
|
size="small"
|
|
|
readonly
|
|
|
+ :disabled="dialogTitle == '查看成本核定模板'"
|
|
|
@click.native="
|
|
|
openCalculationFormulaDialogVisible(
|
|
|
scope.row,
|
|
|
@@ -706,6 +767,7 @@
|
|
|
<el-input
|
|
|
:value="scope.row.unit"
|
|
|
size="small"
|
|
|
+ :disabled="dialogTitle == '查看成本核定模板'"
|
|
|
@input="(val) => $set(scope.row, 'unit', val)"
|
|
|
></el-input>
|
|
|
</div>
|
|
|
@@ -720,8 +782,10 @@
|
|
|
<template slot-scope="scope">
|
|
|
<div class="table-actions">
|
|
|
<el-button
|
|
|
+ v-if="scope.row.isChild"
|
|
|
type="text"
|
|
|
size="mini"
|
|
|
+ :disabled="dialogTitle == '查看成本核定模板'"
|
|
|
@click="
|
|
|
handleAddChildItem(
|
|
|
scope.$index,
|
|
|
@@ -735,6 +799,7 @@
|
|
|
<el-button
|
|
|
type="text"
|
|
|
size="mini"
|
|
|
+ :disabled="dialogTitle == '查看成本核定模板'"
|
|
|
@click="
|
|
|
handleDeleteHeader(
|
|
|
scope.$index,
|
|
|
@@ -749,6 +814,7 @@
|
|
|
v-if="scope.$index !== 0"
|
|
|
type="text"
|
|
|
size="mini"
|
|
|
+ :disabled="dialogTitle == '查看成本核定模板'"
|
|
|
@click="handleMoveUp(scope.$index, '固定表')"
|
|
|
>
|
|
|
上升
|
|
|
@@ -760,6 +826,7 @@
|
|
|
"
|
|
|
type="text"
|
|
|
size="mini"
|
|
|
+ :disabled="dialogTitle == '查看成本核定模板'"
|
|
|
@click="handleMoveDown(scope.$index, '固定表')"
|
|
|
>
|
|
|
下降
|
|
|
@@ -786,7 +853,11 @@
|
|
|
:close-on-click-modal="false"
|
|
|
>
|
|
|
<!-- 单选按钮组:切换“当前指标项”/“其他模板指标项” -->
|
|
|
- <el-radio-group v-model="radioType" class="mb20">
|
|
|
+ <el-radio-group
|
|
|
+ v-model="radioType"
|
|
|
+ class="mb20"
|
|
|
+ @change="handleRadioChange"
|
|
|
+ >
|
|
|
<el-radio label="current">当前指标项</el-radio>
|
|
|
<el-radio label="other">其他模板指标项</el-radio>
|
|
|
</el-radio-group>
|
|
|
@@ -826,26 +897,35 @@
|
|
|
style="width: 100%; margin-top: 10px"
|
|
|
class="mb20"
|
|
|
@row-click="handleRowClick"
|
|
|
- @selection-change="selectionIndicatorChange"
|
|
|
>
|
|
|
+ <!-- @selection-change="selectionIndicatorChange" -->
|
|
|
<el-table-column type="selection" label="选择" width="60">
|
|
|
- <!-- <template #default="scope">
|
|
|
+ <template #default="scope">
|
|
|
<el-checkbox
|
|
|
v-model="scope.row.checked"
|
|
|
@change="handleCheckboxChange(scope.row)"
|
|
|
></el-checkbox>
|
|
|
- </template> -->
|
|
|
+ </template>
|
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
|
prop="code"
|
|
|
label="指标编号"
|
|
|
align="center"
|
|
|
></el-table-column>
|
|
|
+ <!--循环表头 -->
|
|
|
<el-table-column
|
|
|
- prop="name"
|
|
|
- label="项目名称"
|
|
|
+ v-for="(item, index) in indicatorTableHeaders"
|
|
|
+ :key="index"
|
|
|
+ :label="item.rkey"
|
|
|
align="center"
|
|
|
- ></el-table-column>
|
|
|
+ show-overflow-tooltip
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{
|
|
|
+ scope.row.fixedValues ? scope.row.fixedValues[item.rkey] : ''
|
|
|
+ }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
</el-table>
|
|
|
<el-input
|
|
|
v-model="formulaText"
|
|
|
@@ -903,15 +983,17 @@
|
|
|
catalogId: '',
|
|
|
keyword: '',
|
|
|
pageNum: 1,
|
|
|
- pageSize: 10,
|
|
|
+ pageSize: 50,
|
|
|
},
|
|
|
- catalogIdProps: {
|
|
|
+ props: {
|
|
|
filterable: true,
|
|
|
+ placeholder: '请选择监审类别',
|
|
|
style: 'width: 100%',
|
|
|
showAllLevels: false,
|
|
|
props: {
|
|
|
+ multiple: false,
|
|
|
children: 'children',
|
|
|
- checkStrictly: true,
|
|
|
+ checkStrictly: false,
|
|
|
label: 'catalogName',
|
|
|
value: 'id',
|
|
|
emitPath: false,
|
|
|
@@ -989,6 +1071,7 @@
|
|
|
templateName: '',
|
|
|
templateList: [],
|
|
|
indicatorTableData: [],
|
|
|
+ indicatorTableHeaders: [],
|
|
|
selectedIndicatorsPerTemplate: {},
|
|
|
selectedIndicatorCodes: [],
|
|
|
isAutoGeneratedFormula: false,
|
|
|
@@ -1304,7 +1387,7 @@
|
|
|
// 查看详情
|
|
|
handleViewDetail(row) {
|
|
|
this.dialogTitle = '查看成本核定模板'
|
|
|
- this.detailForm = {
|
|
|
+ this.contentEditForm = {
|
|
|
...row,
|
|
|
// 固定表列表
|
|
|
fixedTable: {
|
|
|
@@ -1327,28 +1410,40 @@
|
|
|
this.loadTemplateDataForEdit(this.contentEditForm.surveyTemplateId)
|
|
|
this.dialogVisible = true
|
|
|
},
|
|
|
+
|
|
|
// 生成模板
|
|
|
handleGenerateTemplate() {
|
|
|
- // 校验表单
|
|
|
- this.$refs['contentEditForm'].validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- if (this.contentEditForm.createmode == '1') {
|
|
|
- if (!this.contentEditForm.createtemplateid) {
|
|
|
- this.$message.error('请选择成本调查表模板')
|
|
|
- return
|
|
|
- }
|
|
|
- this.generateFromSurveyTemplate()
|
|
|
- } else if (this.contentEditForm.createmode == '2') {
|
|
|
- if (!this.contentEditForm.createtemplateid1) {
|
|
|
- this.$message.error('请选择成本调查表模板')
|
|
|
- return
|
|
|
+ // 提示生成后不能修改
|
|
|
+ this.$confirm(
|
|
|
+ '生成后不能修改根据调查表生成还是根据历史核定模板生成,确定生成模板吗?',
|
|
|
+ '提示',
|
|
|
+ {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ }
|
|
|
+ ).then(() => {
|
|
|
+ // 校验表单
|
|
|
+ this.$refs['contentEditForm'].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ if (this.contentEditForm.createmode == '1') {
|
|
|
+ if (!this.contentEditForm.createtemplateid) {
|
|
|
+ this.$message.error('请选择成本调查表模板')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.generateFromSurveyTemplate()
|
|
|
+ } else if (this.contentEditForm.createmode == '2') {
|
|
|
+ if (!this.contentEditForm.createtemplateid1) {
|
|
|
+ this.$message.error('请选择成本调查表模板')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.generateFromHistoryTemplate()
|
|
|
}
|
|
|
- this.generateFromHistoryTemplate()
|
|
|
+ } else {
|
|
|
+ this.$message.error('请填写表单数据')
|
|
|
+ return
|
|
|
}
|
|
|
- } else {
|
|
|
- this.$message.error('请填写表单数据')
|
|
|
- return
|
|
|
- }
|
|
|
+ })
|
|
|
})
|
|
|
},
|
|
|
async loadTemplateDataForEdit(surveyTemplateId) {
|
|
|
@@ -1421,7 +1516,7 @@
|
|
|
this.contentEditForm.surveyTemplateId = data.value
|
|
|
? data.value.surveyTemplateId
|
|
|
: ''
|
|
|
- this.loadTemplateDataForEdit(this.contentEditForm.createtemplateid)
|
|
|
+ this.loadTemplateDataForEdit(this.contentEditForm.surveyTemplateId)
|
|
|
// // 并行获取表头和表格数据
|
|
|
// const [tableHeadersRes, tableDataRes] = await Promise.all([
|
|
|
// getlistBySurveyTemplateIdcurrentversion({
|
|
|
@@ -1469,7 +1564,7 @@
|
|
|
this.contentEditForm.surveyTemplateId = data.value
|
|
|
? data.value.surveyTemplateId
|
|
|
: ''
|
|
|
- this.loadTemplateDataForEdit(this.contentEditForm.createtemplateid1)
|
|
|
+ this.loadTemplateDataForEdit(this.contentEditForm.surveyTemplateId)
|
|
|
},
|
|
|
// 添加表头
|
|
|
handleAddTableHeader(type) {
|
|
|
@@ -1487,6 +1582,7 @@
|
|
|
tabtype: '2',
|
|
|
surveyTemplateId: this.contentEditForm.surveyTemplateId,
|
|
|
versionId: this.versionId,
|
|
|
+ orderNum: this.contentEditForm.fixedTable.tableHeaders.length + 1,
|
|
|
})
|
|
|
|
|
|
break
|
|
|
@@ -1583,6 +1679,66 @@
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ // 保存内容
|
|
|
+ handleSaveContent(type) {
|
|
|
+ try {
|
|
|
+ if (type === '固定表表头') {
|
|
|
+ var data = {
|
|
|
+ headersList: this.contentEditForm.fixedTable.tableHeaders,
|
|
|
+ }
|
|
|
+ batchSaveOrUpdate(data)
|
|
|
+ .then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ // 如果后端返回了保存后的数据,更新本地数据
|
|
|
+ if (res.value && Array.isArray(res.value)) {
|
|
|
+ this.contentEditForm.fixedTable.tableHeaders =
|
|
|
+ res.value.map((item) => ({
|
|
|
+ ...item,
|
|
|
+ }))
|
|
|
+ }
|
|
|
+ this.loadTemplateDataForEdit(
|
|
|
+ this.contentEditForm.surveyTemplateId
|
|
|
+ )
|
|
|
+ this.contentEditForm.fixedTable.fixedTables.forEach((row) => {
|
|
|
+ this.initFixedTableRow(row)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ console.error('保存接口异常:', error)
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('保存处理异常:', error)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ initFixedTableRow(row) {
|
|
|
+ if (row.cellCode === undefined) {
|
|
|
+ this.$set(row, 'cellCode', '')
|
|
|
+ }
|
|
|
+ if (row.calculationFormula === undefined) {
|
|
|
+ this.$set(row, 'calculationFormula', '')
|
|
|
+ }
|
|
|
+ if (row.unit === undefined) {
|
|
|
+ this.$set(row, 'unit', '')
|
|
|
+ }
|
|
|
+ if (!row.fixedValues) {
|
|
|
+ this.$set(row, 'fixedValues', {})
|
|
|
+ }
|
|
|
+ this.contentEditForm.fixedTable.fixedTablesTitle.forEach(
|
|
|
+ (title, index) => {
|
|
|
+ if (!(title.rkey in row.fixedValues)) {
|
|
|
+ this.$set(row.fixedValues, title.rkey, '')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+
|
|
|
+ return row
|
|
|
+ },
|
|
|
+
|
|
|
// 删除表头
|
|
|
handleDeleteHeader(index, type, row) {
|
|
|
// 提取重复的删除逻辑为内部函数
|
|
|
@@ -1636,18 +1792,16 @@
|
|
|
handleMoveUp(index, tableType) {
|
|
|
if (tableType === '固定表') {
|
|
|
if (index > 0) {
|
|
|
- const currentRow =
|
|
|
- this.contentEditForm.fixedTable.fixedTables[index]
|
|
|
- const prevRow =
|
|
|
- this.contentEditForm.fixedTable.fixedTables[index - 1]
|
|
|
-
|
|
|
- const temp = currentRow
|
|
|
+ const temp = this.contentEditForm.fixedTable.fixedTables[index]
|
|
|
this.contentEditForm.fixedTable.fixedTables.splice(index, 1)
|
|
|
this.contentEditForm.fixedTable.fixedTables.splice(
|
|
|
index - 1,
|
|
|
0,
|
|
|
temp
|
|
|
)
|
|
|
+
|
|
|
+ // 更新显示的序号值
|
|
|
+ this.updateFixedTableDisplayOrder()
|
|
|
}
|
|
|
} else {
|
|
|
if (index > 0) {
|
|
|
@@ -1658,11 +1812,12 @@
|
|
|
0,
|
|
|
temp
|
|
|
)
|
|
|
- // 更新orderNum字段
|
|
|
+
|
|
|
+ // 更新orderNum字段(从1开始)
|
|
|
this.contentEditForm.fixedTable.tableHeaders.forEach(
|
|
|
(header, idx) => {
|
|
|
if (header.orderNum !== undefined) {
|
|
|
- header.orderNum = idx - 1
|
|
|
+ header.orderNum = idx + 1
|
|
|
}
|
|
|
}
|
|
|
)
|
|
|
@@ -1673,18 +1828,16 @@
|
|
|
handleMoveDown(index, tableType) {
|
|
|
if (tableType === '固定表') {
|
|
|
if (index < this.contentEditForm.fixedTable.fixedTables.length - 1) {
|
|
|
- const currentRow =
|
|
|
- this.contentEditForm.fixedTable.fixedTables[index]
|
|
|
- const nextRow =
|
|
|
- this.contentEditForm.fixedTable.fixedTables[index + 1]
|
|
|
-
|
|
|
- const temp = currentRow
|
|
|
+ const temp = this.contentEditForm.fixedTable.fixedTables[index]
|
|
|
this.contentEditForm.fixedTable.fixedTables.splice(index, 1)
|
|
|
this.contentEditForm.fixedTable.fixedTables.splice(
|
|
|
index + 1,
|
|
|
0,
|
|
|
temp
|
|
|
)
|
|
|
+
|
|
|
+ // 更新显示的序号值
|
|
|
+ this.updateFixedTableDisplayOrder()
|
|
|
}
|
|
|
} else {
|
|
|
if (index < this.contentEditForm.fixedTable.tableHeaders.length - 1) {
|
|
|
@@ -1695,7 +1848,8 @@
|
|
|
0,
|
|
|
temp
|
|
|
)
|
|
|
- // 更新orderNum字段
|
|
|
+
|
|
|
+ // 更新orderNum字段(从1开始)
|
|
|
this.contentEditForm.fixedTable.tableHeaders.forEach(
|
|
|
(header, idx) => {
|
|
|
if (header.orderNum !== undefined) {
|
|
|
@@ -1706,6 +1860,22 @@
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ // 更新固定表中显示的序号值
|
|
|
+ updateFixedTableDisplayOrder() {
|
|
|
+ this.contentEditForm.fixedTable.fixedTables.forEach((row, index) => {
|
|
|
+ // 更新 orderText(显示用序号)
|
|
|
+ row.orderText = index + 1
|
|
|
+
|
|
|
+ // 更新 orderNum(用于后端)
|
|
|
+ row.orderNum = index + 1
|
|
|
+
|
|
|
+ // 如果有"序号"列,也更新该列的值
|
|
|
+ if (row.fixedValues && row.fixedValues['序号'] !== undefined) {
|
|
|
+ // 可以根据需求决定是否更新,这里保持原值或更新为新序号
|
|
|
+ // row.fixedValues['序号'] = index + 1
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
// 添加子项方法
|
|
|
handleAddChildItem(index, type, parentRow) {
|
|
|
if (!parentRow.rowid) {
|
|
|
@@ -1821,6 +1991,10 @@
|
|
|
.then((res) => {
|
|
|
// 将返回的数据转换为表格需要的格式
|
|
|
if (res.value && Array.isArray(res.value.itemlist)) {
|
|
|
+ let fixedTablesTitle = this.stringToObjects(
|
|
|
+ res.value.fixedFields || ''
|
|
|
+ )
|
|
|
+ this.indicatorTableHeaders = fixedTablesTitle
|
|
|
this.indicatorTableData = res.value.itemlist.map((item) => ({
|
|
|
...item,
|
|
|
checked: false,
|
|
|
@@ -1894,19 +2068,25 @@
|
|
|
)
|
|
|
},
|
|
|
handleRowClick(row, column, event) {
|
|
|
+ // 只有点击非 checkbox 列才触发
|
|
|
if (column && column.property !== 'checked') {
|
|
|
+ // 如果没有 cellCode,则不允许选中
|
|
|
+ if (!row.cellCode) {
|
|
|
+ // this.$message.warning('该数据没有指标编号,无法选择')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 切换选中状态
|
|
|
this.toggleRowSelection(row)
|
|
|
}
|
|
|
},
|
|
|
toggleRowSelection(row) {
|
|
|
// 切换选中状态
|
|
|
this.$set(row, 'checked', !row.checked)
|
|
|
+
|
|
|
// 格式化代码并存储在行数据中
|
|
|
if (row.checked) {
|
|
|
this.formatRowCode(row)
|
|
|
- this.$refs.indicatorTable.toggleRowSelection(row)
|
|
|
- } else {
|
|
|
- this.$refs.indicatorTable.toggleRowSelection(row, false)
|
|
|
}
|
|
|
|
|
|
// 触发选中状态更新
|
|
|
@@ -1918,12 +2098,21 @@
|
|
|
})
|
|
|
},
|
|
|
handleCheckboxChange(row) {
|
|
|
+ // 如果没有 cellCode,则不允许选中
|
|
|
+ if (!row.cellCode) {
|
|
|
+ this.$message.warning('该数据没有指标编号,无法选择')
|
|
|
+ this.$set(row, 'checked', false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.$set(row, 'checked', !row.checked)
|
|
|
+
|
|
|
if (row.checked) {
|
|
|
this.formatRowCode(row)
|
|
|
}
|
|
|
|
|
|
- // 更新选中的指标代码列表
|
|
|
this.updateSelectedIndicatorCodes()
|
|
|
+
|
|
|
+ this.$forceUpdate()
|
|
|
},
|
|
|
handleFormulaTextChange(value) {
|
|
|
// 当用户手动修改公式文本时,标记为非自动生成
|
|
|
@@ -1933,6 +2122,9 @@
|
|
|
this.selectedIndicatorsPerTemplate = {}
|
|
|
done()
|
|
|
},
|
|
|
+ handleRadioChange(value) {
|
|
|
+ this.formulaText = ''
|
|
|
+ },
|
|
|
handleConfirm() {
|
|
|
const result = {
|
|
|
type: this.radioType,
|
|
|
@@ -1940,6 +2132,20 @@
|
|
|
selectedTemplate: this.selectedTemplateId,
|
|
|
selectedItems: this.indicatorTableData.filter((item) => item.checked),
|
|
|
}
|
|
|
+ let _data = []
|
|
|
+ if (this.radioType == 'current') {
|
|
|
+ _data = this.contentEditForm.fixedTable.fixedTables.map(
|
|
|
+ (item) => item.cellCode
|
|
|
+ )
|
|
|
+ } else if (this.radioType == 'other') {
|
|
|
+ _data = this.indicatorTableData.map((item) => item.code)
|
|
|
+ }
|
|
|
+ if (!this.validateFormula(this.formulaText, _data).valid) {
|
|
|
+ this.$message.error(
|
|
|
+ this.validateFormula(this.formulaText, _data).errorMsg
|
|
|
+ )
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
// 生成 jsonstr 字段
|
|
|
const jsonStrArray = this.indicatorTableData
|
|
|
@@ -1989,16 +2195,12 @@
|
|
|
* @param {Object} responseData - listByCurrentTemplateId接口返回的数据
|
|
|
*/
|
|
|
parseAndDisplayFixedTableData(responseData) {
|
|
|
- if (responseData.value.fixedFields) {
|
|
|
- this.contentEditForm.fixedTable.fixedTablesTitle =
|
|
|
- this.stringToObjects(responseData.value.fixedFields || '')
|
|
|
- } else {
|
|
|
- let fixedFields = this.contentEditForm.fixedTable.tableHeaders
|
|
|
- .map((item) => item.fieldName)
|
|
|
- .join(',')
|
|
|
- this.contentEditForm.fixedTable.fixedTablesTitle =
|
|
|
- this.stringToObjects(fixedFields || '')
|
|
|
- }
|
|
|
+ let fixedFields = this.contentEditForm.fixedTable.tableHeaders
|
|
|
+ .map((item) => item.fieldName)
|
|
|
+ .join(',')
|
|
|
+ this.contentEditForm.fixedTable.fixedTablesTitle = this.stringToObjects(
|
|
|
+ fixedFields || ''
|
|
|
+ )
|
|
|
const fixedTitles = this.contentEditForm.fixedTable.fixedTablesTitle
|
|
|
this.contentEditForm.fixedTable.fixedTableHeaders = fixedTitles.filter(
|
|
|
(title) => title.rkey !== '序号'
|
|
|
@@ -2142,7 +2344,8 @@
|
|
|
jsonstr: row.jsonstr || null,
|
|
|
}
|
|
|
|
|
|
- if (row.orderNum) {
|
|
|
+ // 只有非子项才添加序号
|
|
|
+ if (!row.isSubItem && row.orderNum) {
|
|
|
newItem.orderNum =
|
|
|
typeof row.orderNum === 'number'
|
|
|
? row.orderNum
|
|
|
@@ -2150,8 +2353,10 @@
|
|
|
}
|
|
|
|
|
|
// 添加其他固定表特有的字段
|
|
|
- newItem.cellCode = row.cellCode || ''
|
|
|
- newItem.unit = row.unit || ''
|
|
|
+ if (!row.isSubItem) {
|
|
|
+ newItem.cellCode = row.cellCode || ''
|
|
|
+ newItem.unit = row.unit || ''
|
|
|
+ }
|
|
|
|
|
|
// 添加其他可能需要的字段,但排除特定字段
|
|
|
Object.keys(row).forEach((key) => {
|
|
|
@@ -2287,6 +2492,129 @@
|
|
|
? row['序号']
|
|
|
: row.orderNum || ''
|
|
|
},
|
|
|
+ // 公式验证函数
|
|
|
+ validateFormula(formula, data) {
|
|
|
+ if (!formula || typeof formula !== 'string') {
|
|
|
+ return { valid: false, errorMsg: '公式不能为空' }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 定义有效的操作符
|
|
|
+ const operators = ['+', '-', '*', '/', '(', ')']
|
|
|
+
|
|
|
+ // 检查是否包含至少一个操作符
|
|
|
+ const hasOperator = operators.some((operator) =>
|
|
|
+ formula.includes(operator)
|
|
|
+ )
|
|
|
+ if (!hasOperator) {
|
|
|
+ return { valid: false, errorMsg: '公式必须包含操作符' }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查值是否在data中存在
|
|
|
+ function checkValueInData(value, data) {
|
|
|
+ if (!data) return false
|
|
|
+
|
|
|
+ if (Array.isArray(data)) {
|
|
|
+ return data.includes(value)
|
|
|
+ } else if (typeof data === 'object') {
|
|
|
+ return Object.values(data).includes(value)
|
|
|
+ }
|
|
|
+ return data === value
|
|
|
+ }
|
|
|
+
|
|
|
+ // 提取公式中的变量/值
|
|
|
+ function extractValues(formulaStr) {
|
|
|
+ // 改进实现:支持形如"CeShi3.C2"的格式,提取点后面的部分作为变量,同时保留普通变量
|
|
|
+ const result = new Set()
|
|
|
+
|
|
|
+ // 1. 首先提取带点格式中的变量部分(如CeShi3.C2中的C2)
|
|
|
+ const dotRegex = /[A-Za-z0-9]+\.([A-Za-z0-9]+)/g
|
|
|
+ let dotMatch
|
|
|
+ while ((dotMatch = dotRegex.exec(formulaStr)) !== null) {
|
|
|
+ result.add(dotMatch[1]) // 提取点后面的部分作为变量
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 然后提取普通变量(C3等),但排除已经从带点格式中提取的部分
|
|
|
+ // 移除所有带点的部分,然后提取剩余的变量
|
|
|
+ const remainingFormula = formulaStr.replace(
|
|
|
+ /[A-Za-z0-9]+\.[A-Za-z0-9]+/g,
|
|
|
+ ''
|
|
|
+ )
|
|
|
+ const normalRegex = /[A-Za-z0-9]+/g
|
|
|
+ let normalMatch
|
|
|
+ while ((normalMatch = normalRegex.exec(remainingFormula)) !== null) {
|
|
|
+ // 跳过纯数字
|
|
|
+ if (
|
|
|
+ !isNaN(Number(normalMatch[0])) &&
|
|
|
+ Number(normalMatch[0]).toString() === normalMatch[0]
|
|
|
+ ) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ result.add(normalMatch[0])
|
|
|
+ }
|
|
|
+
|
|
|
+ return Array.from(result)
|
|
|
+ }
|
|
|
+
|
|
|
+ function checkOperatorContext(formulaStr, data) {
|
|
|
+ for (let i = 0; i < formulaStr.length; i++) {
|
|
|
+ const char = formulaStr[i]
|
|
|
+ // 跳过括号
|
|
|
+ if (char === '(' || char === ')') continue
|
|
|
+
|
|
|
+ // 检查操作符
|
|
|
+ if (operators.includes(char)) {
|
|
|
+ // 检查操作符前是否有值(开头或不是操作符和左括号)
|
|
|
+ if (
|
|
|
+ i === 0 ||
|
|
|
+ (operators.includes(formulaStr[i - 1]) &&
|
|
|
+ formulaStr[i - 1] !== ')') ||
|
|
|
+ formulaStr[i - 1] === '('
|
|
|
+ ) {
|
|
|
+ return {
|
|
|
+ valid: false,
|
|
|
+ errorMsg: `位置 ${i + 1} 的操作符 '${char}' 前缺少值`,
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查操作符后是否有值(结尾或不是操作符和右括号)
|
|
|
+ if (
|
|
|
+ i === formulaStr.length - 1 ||
|
|
|
+ (operators.includes(formulaStr[i + 1]) &&
|
|
|
+ formulaStr[i + 1] !== '(') ||
|
|
|
+ formulaStr[i + 1] === ')'
|
|
|
+ ) {
|
|
|
+ return {
|
|
|
+ valid: false,
|
|
|
+ errorMsg: `位置 ${i + 1} 的操作符 '${char}' 后缺少值`,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证通过后,检查公式中的值是否都在data中存在
|
|
|
+ if (data) {
|
|
|
+ const values = extractValues(formulaStr)
|
|
|
+ for (const value of values) {
|
|
|
+ // 跳过纯数字(假设有值不在data中)
|
|
|
+ if (!isNaN(Number(value)) && Number(value).toString() === value) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!checkValueInData(value, data)) {
|
|
|
+ return {
|
|
|
+ valid: false,
|
|
|
+ errorMsg: `变量 '${value}' 在数据中不存在`,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return { valid: true }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 执行验证
|
|
|
+ return checkOperatorContext(formula, data)
|
|
|
+ },
|
|
|
},
|
|
|
}
|
|
|
</script>
|