فهرست منبع

1.分页修改
2.测算表模板管理开发

GouGengquan 8 ماه پیش
والد
کامیت
78d55fd22a

+ 5 - 2
src/api/tmplAssetCalculate.js

@@ -10,14 +10,17 @@ export function getDropDownBoxData() {
     return request.get('/tmplAssetCalculate/getDropDownBoxData')
 }
 
+// 获取测算表模板列表
 export function getTmplAssetCalculate(params) {
     return request.get('/tmplAssetCalculate/page', {params : params})
 }
 
+// 根据模板id查询详情
 export function getTmplAssetCalculateDetailById(params) {
-    return request.get('tmplAssetCalculate/detail/' + params)
+    return request.get(`tmplAssetCalculate/detail/${params}`)
 }
 
+// 删除测算表模板
 export function deleteCalculate(params) {
-    return request.delete('tmplAssetCalculate/delete/' + params)
+    return request.delete(`tmplAssetCalculate/delete/${params}`)
 }

+ 5 - 0
src/api/tmplAssetCalculateSection.js

@@ -3,4 +3,9 @@ import request from '@/utils/request'
 // 创建资产测算表段落模板
 export function createTmplAssetCalculateSection(params) {
     return request.post('/tmplAssetCalculateSection/save',params);
+}
+
+// 删除测算表段落模板
+export function deleteCalculateSection(params){
+    return request.delete(`/tmplAssetCalculateSection/delete/${params}`)
 }

+ 32 - 31
src/views/assets/template/createCalculate.vue

@@ -1,6 +1,6 @@
 <template>
     <div class="contrl">
-        <el-tabs v-model="activeName" class="condtion-tabs">
+        <el-tabs v-model="activeName" class="condtion-tabs" @tab-change="tabChange()">
             <el-tab-pane label="创建主模板" name="main">
                 <div>
                     <el-form ref="createCalculateTmpl" :model="tmplAssetCalculate" :rules="createRules" label-width="auto"
@@ -21,7 +21,7 @@
                                         </el-form-item>
                                     </el-col>
                                 </el-row>
-                                <el-row :gutter="10" v-if="tmplAssetCalculate.tmplType === 'true'">
+                                <el-row :gutter="10">
                                     <el-col :span="24">
                                         <el-form-item label="是否有段落模板:" class="form-item" prop="hasSection">
                                             <el-radio-group v-model="tmplAssetCalculate.hasSection">
@@ -83,8 +83,8 @@
             </el-tab-pane>
             <el-tab-pane label="创建段落模板" name="section">
                 <div>
-                    <el-form ref="createCalculateSectionTmpl" :model="tmplAssetCalculateSection" :rules="createSectionRules" label-width="auto"
-                        style="margin-top: 10px;">
+                    <el-form ref="createCalculateSectionTmpl" :model="tmplAssetCalculateSection" :rules="createSectionRules"
+                        label-width="auto" style="margin-top: 10px;">
                         <el-row :gutter="10">
                             <el-col :span="12">
                                 <el-form-item label="段落模板名称:" class="form-item" prop="sectionName">
@@ -93,9 +93,10 @@
                                 <el-row :gutter="10">
                                     <el-col :span="24">
                                         <el-form-item label="主模板id:" class="form-item" prop="tmplCode">
-                                            <el-select v-model="tmplAssetCalculateSection.templateReportId" placeholder="选择主模板">
-                                                <el-option v-for="item in calculateDropDownBoxData" :key="item.id" :label="item.name"
-                                                    :value="item.id" />
+                                            <el-select v-model="tmplAssetCalculateSection.templateCalculateId"
+                                                placeholder="选择主模板">
+                                                <el-option v-for="item in calculateDropDownBoxData" :key="item.id"
+                                                    :label="item.name" :value="item.id" />
                                             </el-select>
                                         </el-form-item>
                                     </el-col>
@@ -103,8 +104,8 @@
                                 <el-row :gutter="10">
                                     <el-col :span="24">
                                         <el-form-item label="测算类型:" class="form-item" prop="calculateType">
-                                            <el-select v-model="tmplAssetCalculateSection.calculateType" placeholder="选择测算类型"
-                                                @change="calculateTypeChange">
+                                            <el-select v-model="tmplAssetCalculateSection.calculateType"
+                                                placeholder="选择测算类型" @change="calculateTypeChange">
                                                 <el-option v-for="item in calculateType" :key="item.value"
                                                     :label="item.label" :value="item.value" />
                                             </el-select>
@@ -124,22 +125,24 @@
                                 <el-row :gutter="10">
                                     <el-col :span="24">
                                         <el-form-item label="模板文件名字:" class="form-item" prop="sectionFileName">
-                                            <el-input v-model="tmplAssetCalculateSection.sectionFileName" clearable disabled />
+                                            <el-input v-model="tmplAssetCalculateSection.sectionFileName" clearable
+                                                disabled />
                                         </el-form-item>
                                     </el-col>
                                 </el-row>
                                 <el-row :gutter="10">
                                     <el-col :span="24">
                                         <el-form-item label="模板文件存储位置:" class="form-item" prop="sectionFileUrl">
-                                            <el-input v-model="tmplAssetCalculateSection.sectionFileUrl" clearable disabled />
+                                            <el-input v-model="tmplAssetCalculateSection.sectionFileUrl" clearable
+                                                disabled />
                                         </el-form-item>
                                     </el-col>
                                 </el-row>
                             </el-col>
                             <el-col :span="12">
                                 <el-upload drag action="#" multiple style="width:50%;margin-left:25%;" accept=".xls,.xlsx"
-                                    :limit="1" :http-request="handleSectionUpload" :file-list="sectionFileList" :on-exceed="handleExceed"
-                                    :before-remove="beforeRemove">
+                                    :limit="1" :http-request="handleSectionUpload" :file-list="sectionFileList"
+                                    :on-exceed="handleExceed" :before-remove="beforeRemove">
                                     <el-icon class="el-icon--upload"><upload-filled /></el-icon>
                                     <div class="el-upload__text">
                                         拖拽文件 <em>或点击上传</em>
@@ -170,7 +173,7 @@
 <script>
 
 import { uploadAssetsCalculateTmpl } from '@/api/fileUpload'
-import { getDropDownBoxData,createTmplAssetCalculate } from '@/api/tmplAssetCalculate'
+import { getDropDownBoxData, createTmplAssetCalculate } from '@/api/tmplAssetCalculate'
 import { createTmplAssetCalculateSection } from '@/api/tmplAssetCalculateSection'
 
 export default {
@@ -252,13 +255,13 @@ export default {
                 ]
             },
             tmplAssetCalculateSection: {
-                
+
             },
             createSectionRules: {
                 sectionName: [
                     { required: true, message: '请输入段落模板名称', trigger: 'blur' }
                 ],
-                templateReportId: [
+                templateCalculateId: [
                     { required: true, message: '请选择主模板', trigger: 'change' }
                 ],
                 calculateType: [
@@ -278,10 +281,15 @@ export default {
         }
     },
     created() {
-        this.getDropDownBoxData();
+        
     },
     methods: {
-        getDropDownBoxData(){
+        tabChange() {
+            if (this.activeName === "section") {
+                this.getDropDownBoxData();
+            }
+        },
+        getDropDownBoxData() {
             getDropDownBoxData().then(res => {
                 this.calculateDropDownBoxData = res.data
             })
@@ -330,15 +338,12 @@ export default {
                     createTmplAssetCalculate(this.tmplAssetCalculate).then(res => {
                         if (res.code == 200) {
                             this.$refs.createCalculateTmpl.resetFields();
+                            this.tmplCodes = null;
                             this.fileList = [];
                             ElMessage({
                                 showClose: true,
                                 message: res.message,
-                                type: 'success',
-                                onClose: () => {
-                                    // 跳转到模板列表页面
-                                    this.$router.push('/home/assets/template/mange')
-                                }
+                                type: 'success'
                             })
                         }
                     })
@@ -381,15 +386,12 @@ export default {
                     createTmplAssetCalculateSection(this.tmplAssetCalculateSection).then(res => {
                         if (res.code == 200) {
                             this.$refs.createCalculateSectionTmpl.resetFields();
-                            this.fileList = [];
+                            this.tmplCodes = null;
+                            this.sectionFileList = [];
                             ElMessage({
                                 showClose: true,
                                 message: res.message,
-                                type: 'success',
-                                onClose: () => {
-                                    // 跳转到模板列表页面
-                                    this.$router.push('/home/assets/template/mange')
-                                }
+                                type: 'success'
                             })
                         }
                     })
@@ -418,5 +420,4 @@ export default {
     --el-color-primary-light-8: #ffa999;
     --el-color-primary-light-9: #ffa854;
     --el-color-primary-dark-2: #ff8154;
-}
-</style>
+}</style>

+ 57 - 25
src/views/assets/template/mange.vue

@@ -15,7 +15,7 @@
         <img src="../../../assets/icons/plus.png" style="width: 32px; height: 32px;float: right;margin-top: 22px;" />
       </div>
     </div>
-    <el-tabs v-model="activeName" class="condtion-tabs">
+    <el-tabs v-model="activeName" class="condtion-tabs" @tab-change="tabChange()">
       <el-tab-pane label="测算表模板" name="calculate">
         <div class="example-list report-div">
           <el-card v-for="item in pageData" class="report-item no-border" shadow="never">
@@ -59,7 +59,7 @@
           </el-card>
         </div>
         <el-pagination background layout="prev, pager, next" style="--el-color-primary: #ff6154"
-          v-model:page-count="listQuery.pages" v-model:current-page="listQuery.pageNum"
+          v-model:page-count="listQuery.pages" v-model:current-page="listQuery.current"
           @current-change="getTmplAssetCalculate" />
       </el-tab-pane>
       <el-tab-pane label="报告模板" name="report">
@@ -124,26 +124,34 @@
         </el-row>
         <el-row :gutter="10">
           <el-col :span="24">
-            <el-card v-for="item in calculateDetail.sectionList" class="report-item no-border" shadow="never">
-              <div class="report-text">
-                <span> 测算表段落模板名称: </span>
-                <span class="report-text-type">{{ item.sectionName }}</span><br />
-                <span> 段落模板文件名字: </span>
-                <span class="report-text-name">{{ item.sectionFileName }}
-                </span><br />
-                <span> 段落模板文件存储位置: </span>
-                <span class="report-text-name">{{ item.sectionFileUrl }}
-                </span><br />
-                <span> 模板code: </span>
-                <span class="report-text-name">{{ item.tmplCode }}
-                </span><br />
-              </div>
-              <div class="report-button" style="margin-left: 20px;">
-                <el-icon>
-                  <Delete />
-                </el-icon>
-              </div>
-            </el-card>
+            <div class="dialog-section-tmpl">
+              <el-card v-for="item in calculateDetail.sectionList" class="report-item no-border" shadow="never">
+                <div>
+                  <span> 测算表段落模板名称: </span>
+                  <span class="report-text-type">{{ item.sectionName }}</span><br />
+                  <span> 段落模板文件名字: </span>
+                  <span class="report-text-name">{{ item.sectionFileName }}
+                  </span><br />
+                  <span> 段落模板文件存储位置: </span>
+                  <span class="report-text-name">{{ item.sectionFileUrl }}
+                  </span><br />
+                  <span> 模板code: </span>
+                  <span class="report-text-name">{{ item.tmplCode }}
+                  </span><br />
+                </div>
+                <el-popconfirm title="确定要删除当前模板?" confirm-button-text="确定" cancel-button-text="取消"
+                  @confirm="deleteCalculateSection(item.id)">
+                  <template #reference>
+                    <div class="report-button" style="margin-left: 20px;">
+                      <el-icon>
+                        <Delete />
+                      </el-icon>
+                    </div>
+                  </template>
+                </el-popconfirm>
+              </el-card>
+            </div>
+
           </el-col>
         </el-row>
       </el-form>
@@ -153,6 +161,7 @@
 
 <script>
 import { getTmplAssetCalculate, getTmplAssetCalculateDetailById, deleteCalculate } from '@/api/tmplAssetCalculate';
+import { deleteCalculateSection } from '@/api/tmplAssetCalculateSection';
 export default {
   name: 'assetsTmplMange',
   data() {
@@ -161,8 +170,8 @@ export default {
       folderName: null,
       activeName: 'calculate',
       listQuery: {
-        pageNum: 1,
-        pageSize: 5,
+        current: 1,
+        size: 5,
         pages: 1
       },
       pageData: {
@@ -177,6 +186,11 @@ export default {
     this.getTmplAssetCalculate();
   },
   methods: {
+    tabChange() {
+      if (this.activeName === "calculate") {
+        this.getTmplAssetCalculate();
+      }
+    },
     goCreateCalculateTmpl() {
       this.$router.push('/home/assets/template/create/calculate')
     },
@@ -184,7 +198,7 @@ export default {
     getTmplAssetCalculate() {
       getTmplAssetCalculate(this.listQuery).then(res => {
         this.listQuery.pages = res.data.pages
-        this.pageData = res.data.list;
+        this.pageData = res.data.records;
       })
     },
     openCalculateDetail(id) {
@@ -211,6 +225,19 @@ export default {
           })
         }
       })
+    },
+    // 删除测算表段落模板
+    deleteCalculateSection(id) {
+      deleteCalculateSection(id).then(res => {
+        if (res.code == 200) {
+          this.getTmplAssetCalculateDetailById(this.calculateDetail.id);
+          ElMessage({
+            showClose: true,
+            message: res.message,
+            type: 'success'
+          })
+        }
+      })
     }
   }
 }
@@ -313,4 +340,9 @@ export default {
 .no-border:hover {
   cursor: pointer;
 }
+
+.dialog-section-tmpl {
+  max-height: 500px;
+  overflow: auto;
+}
 </style>