Переглянути джерело

Revert "数据模板表单按钮报表参数解析调整"

This reverts commit fc27d1bc2484c528d9362c1112f12583b4ad10e4.
cfort 1 рік тому
батько
коміт
a3dffd2873

+ 42 - 33
src/business/platform/data/templaterender/templates/list.vue

@@ -290,10 +290,12 @@
             :download="false"
             :readonly="true"
         />
+        <on-line-index :groove-data="grooveData" :groove-list="grooveList" :dialog-visible.sync="grooveDialogVisible" style="z-index: 9999;" />
 
     </div>
 </template>
 <script>
+import onLineIndex from '@/views/onLineEditing/onLineIndex'
 
 import { queryDataTable, removeFormData, exportData, checkExportData } from '@/api/platform/data/dataTemplate'
 import { startFlowFromList } from '@/api/platform/bpmn/bpmInst'
@@ -364,7 +366,8 @@ export default {
         Print: () => import('../components/print'),
         LabelPrint: () => import('../components/labelPrint'),
         xlsxFile,
-        generalModules
+        generalModules,
+        onLineIndex
 
         // BpmnFormrender
         // DataTemplateFormat
@@ -1021,7 +1024,6 @@ export default {
                 let src = ''
                 this.readonly = false
                 const { userId } = this.$store.getters || {}
-                const [path, ...rest] = button.reportPath.split('&') || []
                 switch (buttonType) {
                     case 'search': // 查询
                         ActionUtils.setFirstPagination(this.pagination)
@@ -1089,7 +1091,7 @@ export default {
                             if (!button.reportPath) {
                                 return this.$message.warning('请先配置对应报表路径!')
                             }
-                            src = this.$reportPath.replace('show', 'pdf') + path + this.getReportParams(rest, selection, data)
+                            src = this.$reportPath.replace('show', 'pdf') + button.reportPath.split('&')[0] + `&` + this.getReportParams(button.reportPath, selection, data)
                             this.$common.preview(this, src)
                         }
                         break
@@ -1098,7 +1100,7 @@ export default {
                             return this.$message.warning('请先配置对应报表路径!')
                         }
                         this.$common.snapshoot({
-                            url: this.$getReportFile(path, this.getReportParams(rest, selection, data)),
+                            url: this.$getReportFile(button.reportPath.split('&')[0], this.getReportParams(button.reportPath, selection, data)),
                             name: selection,
                             type: 'pdf'
                         }).then((res) => {
@@ -1358,7 +1360,26 @@ export default {
                 rowHandle: rowHandle,
                 searchForm: searchForms.length > 0 ? { forms: searchForms } : null
             }
-
+            // 判断地点是否第一层级
+            const position = this.$store.getters.userInfo.positions
+            let showBoolean = false
+            if (position && position.length > 0 && this.first) {
+                showBoolean = position.some((item) => item.id === this.first)
+            }
+            const columnsShow = this.listConfig.columns.some((item) => item.prop === 'di_dian_')
+            if (!showBoolean && columnsShow) {
+                this.listConfig.columns.forEach((item) => {
+                    if (item.prop === 'di_dian_') {
+                        item.hidden = true
+                    }
+                })
+            } else {
+                this.listConfig.columns.forEach((item) => {
+                    if (item.prop === 'di_dian_') {
+                        item.hidden = false
+                    }
+                })
+            }
             // 分页
             this.showPagination = this.template.attrs ? this.template.attrs.need_page === 'Y' : true
             this.pagination.limit = this.template.attrs ? parseInt(this.template.attrs.page_size, 10) || 20 : 20
@@ -2030,35 +2051,23 @@ export default {
             // conso
             this.handleAction(buttonTypeAct, buttonAct.position, selectAct, dataAct, indexAct, buttonAct)
         },
-        getReportParams (args, selection, data) {
-            const defaultParams = {
-                org_: this.first,
-                second_: this.second,
-                id_: selection
-            }
-            // 无额外参数时直接返回默认参数字符串
-            if (!args || !args.length) {
-                return this.serializeParams(defaultParams)
+        getReportParams (path, selection, data) {
+            /**
+             * 1、原报表路径:安全管理/紫外灯辐照度值测定记录表.rpx
+             * 2、补充报表路径:安全管理/紫外灯辐照度值测定记录表.rpx&id_=id_
+             * 2-1、最后那么id_表示在列上的字段属性,增加报表传参的便捷性;
+             * 2-2、有些列表需要展示的是子表的数据,但是报表需要展示的是主表数据,列表唯一字段只能是子表id_,所以主表的id_就不能也叫id_;
+             * 2-3、受限于报表快照生成的参数获取,当前只补充关于id_的逻辑;
+             */
+            const str = `org_=${this.orgId}&id_=`
+            const arr = path.split('&')
+            if (arr.length === 2) {
+                const fieldArr = arr[1].split('=')
+                return str + `${data[fieldArr[1]]}`
+            } else {
+                // 如果是没有传参,还是原报表路径
+                return str + `${selection}`
             }
-
-            // 解析额外参数,覆盖默认参数
-            const finalParams = args.reduce((acc, item) => {
-                const [key, field] = item.split('=') || []
-                // 无效参数跳过
-                if (!key || !field) return acc
-
-                // 若data中获取不到字段值,可能传参为值并非字段
-                const value = data[field] || field
-                if (this.$utils.isNotEmpty(value)) {
-                    // 同名参数覆盖
-                    acc[key] = value
-                }
-                return acc
-            }, { ...defaultParams })
-            return this.serializeParams(finalParams)
-        },
-        serializeParams (params) {
-            return Object.entries(params).map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join('&')
         }
     }
 }