Просмотр исходного кода

调查表-添加-监审级别只选择末级,
调查表-添加-调查表数据存储库表,去掉此字段,
调查表-单记录-内容维护-详情-去掉页面的添加项目、保存按钮,
调查表-单记录-内容维护-删除-提示语空白
调查表-固定表-内容维护-计算公式-其他模板指标项应展示此表的现行数据,其他不展示

cb_luzhixia 1 месяц назад
Родитель
Сommit
0fbad7b752

+ 65 - 53
src/views/costAudit/baseInfo/costFormManage/index.vue

@@ -8,18 +8,7 @@
             <el-cascader
               v-model="searchForm.catalogId"
               :options="catalogListOptions"
-              v-bind="{
-                filterable: true,
-                placeholder: '请选择关联监审项目',
-                style: 'width: 100%',
-                showAllLevels: false,
-                props: {
-                  children: 'children',
-                  checkStrictly: true,
-                  label: 'catalogName',
-                  value: 'id',
-                },
-              }"
+              v-bind="props"
               style="width: 100%"
               clearable
             ></el-cascader>
@@ -182,8 +171,9 @@
           <el-cascader
             v-model="formData.catalogId"
             :options="catalogListOptions"
-            v-bind="catalogProps"
+            v-bind="props"
             style="width: 100%"
+            @change="handleCatalogChange"
           ></el-cascader>
         </template>
         <template #surveyTemplateName>
@@ -203,12 +193,12 @@
           <el-radio v-model="formData.templateType" label="2">固定表</el-radio>
           <el-radio v-model="formData.templateType" label="3">动态表</el-radio>
         </template>
-        <template #storageTable>
+        <!-- <template #storageTable>
           <el-input
             v-model="formData.storageTable"
             placeholder="请输入调查表数据存储库表"
           />
-        </template>
+        </template> -->
         <template #remarks>
           <el-input v-model="formData.remarks" type="textarea"
           placeholder="请输入说明,填写调查表的业务说明、填报指引等内容" type:
@@ -325,6 +315,20 @@
           { value: '0', label: '启用' },
           { value: '1', label: '停用' },
         ],
+        props: {
+          filterable: true,
+          placeholder: '请选择关联监审项目',
+          style: 'width: 100%',
+          showAllLevels: false,
+          props: {
+            multiple: false,
+            children: 'children',
+            checkStrictly: false,
+            label: 'catalogName',
+            value: 'id',
+            emitPath: false,
+          },
+        },
       }
     },
     computed: {
@@ -339,6 +343,7 @@
             props: {
               placeholder: '请选择监审类别',
               style: { width: '100%' },
+              checkStrictly: false,
             },
             options: this.catalogIdOptions,
           },
@@ -365,12 +370,12 @@
             label: '表单样式:',
             slotName: 'templateType',
           },
-          {
-            prop: 'storageTable',
-            label: '调查表数据存储库表:',
-            type: 'input',
-            slotName: 'storageTable',
-          },
+          // {
+          //   prop: 'storageTable',
+          //   label: '调查表数据存储库表:',
+          //   type: 'input',
+          //   slotName: 'storageTable',
+          // },
           {
             prop: 'remarks',
             label: '说明:',
@@ -411,10 +416,10 @@
                 : '动态表'
             },
           },
-          {
-            prop: 'storageTable',
-            label: '调查表数据存储表',
-          },
+          // {
+          //   prop: 'storageTable',
+          //   label: '调查表数据存储表',
+          // },
           {
             prop: 'status',
             label: '状态',
@@ -451,6 +456,16 @@
       this.handleSearch()
     },
     methods: {
+      handleCatalogChange(val) {
+        // 设置表单数据
+        this.$set(this.formData, 'catalogId', val)
+        console.log(this.formData.catalogId)
+        this.$nextTick(() => {
+          if (this.$refs.dataForm && this.$refs.dataForm.$refs.formRef) {
+            this.$refs.dataForm.$refs.formRef.clearValidate('catalogId')
+          }
+        })
+      },
       // 初始化表单选项
       initFormOptions() {
         // 将选项数据同步到表单配置中
@@ -468,10 +483,7 @@
         this.loading = true
 
         const params = {
-          catalogId:
-            this.searchForm.catalogId && this.searchForm.catalogId.length > 0
-              ? this.searchForm.catalogId[this.searchForm.catalogId.length - 1]
-              : '',
+          catalogId: this.searchForm.catalogId,
           status: this.searchForm.status,
           pageNum: this.pagination.currentPage,
           pageSize: this.pagination.pageSize,
@@ -604,38 +616,38 @@
       // 查看详情
       handleViewDetail(row) {
         // 处理级联选择器多选回显数据
-        const result = this.formatRelatedItemsForDisplay({
-          catalogId: {
-            value: row.catalogId,
-            options: this.catalogListOptions,
-            id: 'id',
-            parentId: 'parentId',
-          },
-        })
+        // const result = this.formatRelatedItemsForDisplay({
+        //   catalogId: {
+        //     value: row.catalogId,
+        //     options: this.catalogListOptions,
+        //     id: 'id',
+        //     parentId: 'parentId',
+        //   },
+        // })
         this.dialogVisible = true
         this.dialogTitle = `查看成本调查表`
         this.formData = {
           ...row,
-          catalogId: result.catalogId ? result.catalogId : [],
+          // catalogId: result.catalogId ? result.catalogId : [],
         }
       },
 
       // 修改
       handleEdit(row) {
         // 处理级联选择器多选回显数据
-        const result = this.formatRelatedItemsForDisplay({
-          catalogId: {
-            value: row.catalogId,
-            options: this.catalogListOptions,
-            id: 'id',
-            parentId: 'parentId',
-          },
-        })
+        // const result = this.formatRelatedItemsForDisplay({
+        //   catalogId: {
+        //     value: row.catalogId,
+        //     options: this.catalogListOptions,
+        //     id: 'id',
+        //     parentId: 'parentId',
+        //   },
+        // })
         this.dialogTitle = '修改成本调查表'
         this.isEdit = true
         this.formData = {
           ...row,
-          catalogId: result.catalogId ? result.catalogId : [],
+          // catalogId: result.catalogId ? result.catalogId : [],
         }
         this.dialogVisible = true
       },
@@ -690,7 +702,7 @@
 
       // 启动/停用状态
       handleStatus(row) {
-        const action = row.status === '启用' ? '停用' : '启用'
+        const action = row.status == '0' ? '停用' : '启用'
         this.$confirm(`确认要${action}该数据吗?`, '操作确认', {
           confirmButtonText: '确定',
           cancelButtonText: '取消',
@@ -700,7 +712,7 @@
             changeCostFormStatus(row.surveyTemplateId)
               .then((res) => {
                 if (res.code === 200) {
-                  this.$message.success(`${action}成功`)
+                  this.$message.success(res.message || `${action}成功`)
                   this.handleSearch()
                 }
               })
@@ -740,12 +752,12 @@
           return
         }
         // 处理级联选择器多选数据
-        const resultData = this.extractLastLevelValues({
-          catalogId: this.formData.catalogId,
-        })
+        // const resultData = this.extractLastLevelValues({
+        //   catalogId: this.formData.catalogId,
+        // })
         const data = {
           ...this.formData,
-          ...resultData,
+          // ...resultData,
         }
 
         this.$refs.dataForm

+ 98 - 22
src/views/costAudit/baseInfo/costFormManage/infoMaintain.vue

@@ -247,15 +247,15 @@
         <div v-if="contentEditForm.templateType === '1'">
           <div class="button-group">
             <el-button
+              v-if="!viewDetail"
               type="primary"
-              :disabled="viewDetail"
               @click="handleAddTableHeader('单记录')"
             >
               添加项目
             </el-button>
             <el-button
+              v-if="!viewDetail"
               type="primary"
-              :disabled="viewDetail"
               @click="handleSaveContent('单记录')"
             >
               保存
@@ -498,15 +498,15 @@
         <div v-if="contentEditForm.templateType === '2'">
           <div class="button-group">
             <el-button
+              v-if="!viewDetail"
               type="primary"
-              :disabled="viewDetail"
               @click="handleAddTableHeader('固定表表头')"
             >
               添加表头
             </el-button>
             <el-button
+              v-if="!viewDetail"
               type="primary"
-              :disabled="viewDetail"
               @click="handleSaveContent('固定表表头')"
             >
               下一步
@@ -765,15 +765,15 @@
           <div>
             <div class="button-group">
               <el-button
+                v-if="!viewDetail"
                 type="primary"
-                :disabled="viewDetail"
                 @click="handleAddTableHeader('固定表项目')"
               >
                 添加项目
               </el-button>
               <el-button
+                v-if="!viewDetail"
                 type="primary"
-                :disabled="viewDetail"
                 @click="handleSaveContent('固定表项目')"
               >
                 保存
@@ -955,15 +955,15 @@
         <div v-if="contentEditForm.templateType === '3'">
           <div class="button-group">
             <el-button
+              v-if="!viewDetail"
               type="primary"
-              :disabled="viewDetail"
               @click="handleAddTableHeader('动态表表头')"
             >
               添加表头
             </el-button>
             <el-button
+              v-if="!viewDetail"
               type="primary"
-              :disabled="viewDetail"
               @click="handleSaveContent('动态表表头')"
             >
               下一步
@@ -1206,15 +1206,15 @@
           <div>
             <div class="button-group">
               <el-button
+                v-if="!viewDetail"
                 type="primary"
-                :disabled="viewDetail"
                 @click="handleAddTableHeader('动态表项目')"
               >
                 添加项目
               </el-button>
               <el-button
+                v-if="!viewDetail"
                 type="primary"
-                :disabled="viewDetail"
                 @click="handleSaveContent('动态表项目')"
               >
                 保存
@@ -1364,11 +1364,11 @@
     <el-dialog
       title="计算公式"
       :visible.sync="calculationFormulaDialogVisible"
-      width="500px"
+      width="30%"
       :before-close="handleDialogClose"
     >
       <!-- 单选按钮组:切换“当前指标项”/“其他模板指标项” -->
-      <el-radio-group v-model="radioType">
+      <el-radio-group v-model="radioType" class="mb20">
         <el-radio label="current">当前指标项</el-radio>
         <el-radio label="other">其他模板指标项</el-radio>
       </el-radio-group>
@@ -1385,15 +1385,16 @@
 
       <!-- 「其他模板指标项」内容区域 -->
       <div v-else class="other-panel">
+        <span>版本号:</span>
         <el-select
           v-model="selectedTemplateId"
-          placeholder="请选择模板"
+          placeholder="请选择版本号"
           @change="handleTemplateChange"
         >
           <el-option
             v-for="(item, index) in templateList"
             :key="index"
-            :label="item.surveyTemplateName"
+            :label="item.versionNo"
             :value="item.pkVal"
           ></el-option>
         </el-select>
@@ -1415,8 +1416,25 @@
               ></el-checkbox>
             </template>
           </el-table-column>
-          <el-table-column prop="code" label="指标编号"></el-table-column>
-          <el-table-column prop="name" label="项目名称"></el-table-column>
+          <el-table-column
+            label="指标编号"
+            prop="cellCode"
+            align="center"
+          ></el-table-column>
+          <!--循环表头 -->
+          <el-table-column
+            v-for="(item, index) in indicatorTableHeaders"
+            :key="index"
+            :label="item.rkey"
+            align="center"
+            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"
@@ -1463,6 +1481,7 @@
     batchDeleteCostForm,
   } from '@/api/costSurveyTemplateVersion'
   import { getListFixedEnabled } from '@/api/costSurveyTemplate'
+  import { listByCurrentTemplateId } from '@/api/catalogManage.js'
   import {
     getListBySurveyTemplateId,
     getListBySurveyTemplateIdAndVersion,
@@ -1503,6 +1522,7 @@
         templateName: '',
         templateList: [],
         indicatorTableData: [],
+        indicatorTableHeaders: [],
         selectedIndicatorCodes: [],
         selectedIndicatorsPerTemplate: {},
         dialogTitle: '',
@@ -1793,7 +1813,15 @@
         this.handleSearch()
       },
       handleRowClick(row, column, event) {
+        // 只有点击非 checkbox 列才触发
         if (column && column.property !== 'checked') {
+          // 如果没有 cellCode,则不允许选中
+          if (!row.cellCode) {
+            // this.$message.warning('该数据没有指标编号,无法选择')
+            return
+          }
+
+          // 切换选中状态
           this.toggleRowSelection(row)
         }
       },
@@ -1810,6 +1838,12 @@
         this.$forceUpdate()
       },
       handleCheckboxChange(row) {
+        // 如果没有 cellCode,则不允许选中
+        if (!row.cellCode) {
+          this.$message.warning('该数据没有指标编号,无法选择')
+          this.$set(row, 'checked', false)
+          return
+        }
         this.$set(row, 'checked', !row.checked)
 
         if (row.checked) {
@@ -1888,9 +1922,25 @@
       },
 
       getListFixedEnabled() {
-        getListFixedEnabled().then((res) => {
-          this.templateList = res.value
-        })
+        // 修改为调用状态为现行的数据
+        const params = {
+          surveyTemplateId: this.surveyTemplateId,
+          status: '0',
+          // pageNum: this.pagination.currentPage,
+          // pageSize: this.pagination.pageSize,
+        }
+
+        // 根据成本调查表ID获取所有版本数据
+        getCostSurveyTemplateVersionsByTemplateId(params)
+          .then((response) => {
+            this.templateList = response.value || []
+          })
+          .catch((error) => {
+            console.error('查询失败:', error)
+          })
+        // getListFixedEnabled().then((res) => {
+        //   this.templateList = res.value
+        // })
       },
       // 处理模板选择变化
       handleTemplateChange(templateId) {
@@ -1901,7 +1951,33 @@
           )
 
           if (selectedTemplate && selectedTemplate.surveyTemplateId) {
-            this.getCellCodesByTemplateId(selectedTemplate.surveyTemplateId)
+            // this.getCellCodesByTemplateId(selectedTemplate.surveyTemplateId)
+            listByCurrentTemplateId({
+              surveyTemplateId: selectedTemplate.surveyTemplateId,
+            }).then((responseData) => {
+              //解析并显示数据
+              if (responseData.value && responseData.value.itemlist) {
+                const itemList = responseData.value.itemlist
+                let fixedTablesTitle = this.stringToObjects(
+                  responseData.value.fixedFields || ''
+                )
+                this.indicatorTableHeaders = fixedTablesTitle
+                // 遍历itemList,为每个项目创建一行数据
+                itemList.forEach((item, index) => {
+                  const newRow = {
+                    ...item,
+                    checked: false,
+                    cellCode: item.cellCode || '',
+                    fixedValues: {},
+                  }
+                  // 初始化fixedValues并填充实际值
+                  fixedTablesTitle.forEach((title) => {
+                    newRow.fixedValues[title.rkey] = item[title.rkey] || ''
+                  })
+                  this.indicatorTableData.push(newRow)
+                })
+              }
+            })
           } else {
             this.indicatorTableData = []
           }
@@ -3383,7 +3459,7 @@
             delSurveyTemplateVersionById(row.id)
               .then((res) => {
                 if (res.code === 200) {
-                  this.$message.success(res.message)
+                  this.$message.success(res.message || '删除成功')
                   this.handleSearch()
                   this.loading = false
                 }
@@ -3417,7 +3493,7 @@
             batchDeleteCostForm(ids)
               .then((res) => {
                 this.selectedRows = []
-                this.$message.success(res.message)
+                this.$message.success(res.message || '删除成功')
                 this.handleSearch()
                 this.loading = false
               })