瀏覽代碼

对话框取消和确认报错问题修复

shenqilong 1 年之前
父節點
當前提交
1921942ad6
共有 2 個文件被更改,包括 260 次插入240 次删除
  1. 192 172
      src/business/platform/data/templaterender/preview/index.vue
  2. 68 68
      src/views/system/fasc/facilityEnvConfig.vue

+ 192 - 172
src/business/platform/data/templaterender/preview/index.vue

@@ -1,192 +1,212 @@
 <template>
-  <div>
-    <!--默认-->
-    <template-default
-      v-if="type==='default'"
-      :visible="dialogVisible"
-      :data="dataTemplate"
-      :dynamic-params="dynamicParams"
-      :preview="preview"
-      @close="closeDialog"
-    />
-    <!--对话框-->
-    <template-dialog
-      v-else-if="type==='dialog'"
-      ref="dataTemplate"
-      :visible="dialogVisible"
-      :title="title"
-      :value.sync="selectedValue"
-      :data="dataTemplate"
-      :dynamic-params="dynamicParams"
-      :multiple="multiple"
-      :width="width"
-      :height="height"
-      :dialog-height="dialogHeight"
-      :label-key="labelKey"
-      :toolbars="toolbars"
-      :preview="preview"
-      @close="closeDialog"
-    />
-    <!--值来源-->
-    <template-value-source
-      v-else-if="type==='valueSource'"
-      :visible="dialogVisible"
-      :data="dataTemplate"
-      :dynamic-params="dynamicParams"
-      @close="closeDialog"
-    />
-  </div>
+    <div>
+        <!--默认-->
+        <template-default
+            v-if="type==='default'"
+            :visible="dialogVisible"
+            :data="dataTemplate"
+            :dynamic-params="dynamicParams"
+            :preview="preview"
+            @close="closeDialog"
+        />
+        <!--对话框-->
+        <template-dialog
+            v-else-if="type==='dialog'"
+            ref="dataTemplate"
+            :visible="dialogVisible"
+            :title="title"
+            :value.sync="selectedValue"
+            :data="dataTemplate"
+            :dynamic-params="dynamicParams"
+            :multiple="multiple"
+            :width="width"
+            :height="height"
+            :dialog-height="dialogHeight"
+            :label-key="showLabel"
+            :toolbars="toolbars"
+            :preview="preview"
+            :temp-search="tempSearch"
+            @close="closeDialog"
+        />
+        <!--值来源-->
+        <template-value-source
+            v-else-if="type==='valueSource'"
+            :visible="dialogVisible"
+            :data="dataTemplate"
+            :dynamic-params="dynamicParams"
+            @close="closeDialog"
+        />
+    </div>
 </template>
 <script>
 import ButtonsConstants from '@/business/platform/data/constants/buttons'
 import TemplateDefault from './types/default'
 import TemplateDialog from './types/dialog'
 import TemplateValueSource from './types/value-source'
-
+import { buildLabelTitle } from '../utils'
 export default {
-  components: {
-    TemplateDefault,
-    TemplateDialog,
-    TemplateValueSource
-  },
-  props: {
-    visible: {
-      type: Boolean,
-      default: false
-    },
-    value: {
-      type: [Array, Object]
-    },
-    multiple: {
-      type: Boolean,
-      default: true
-    },
-    dynamicParams: {
-      type: Object
+    components: {
+        TemplateDefault,
+        TemplateDialog,
+        TemplateValueSource
     },
-    data: {
-      type: Object
+    props: {
+        visible: {
+            type: Boolean,
+            default: false
+        },
+        value: {
+            type: [Array, Object]
+        },
+        multiple: {
+            type: Boolean,
+            default: true
+        },
+        dynamicParams: {
+            type: Object
+        },
+        data: {
+            type: Object
+        },
+        labelKey: {
+            type: [String, Function]
+        },
+        preview: {
+            type: Boolean,
+            default: true
+        },
+        tempSearch: { // 是否是数据模板使用的筛选条件
+            type: Boolean,
+            default: false
+        }
     },
-    labelKey: {
-      type: [String, Function]
-    },
-    preview: {
-      type: Boolean,
-      default: true
-    }
-  },
-  data() {
-    return {
-      dialogVisible: this.visible,
-      dataTemplate: {},
-      type: 'default',
-      title: '',
-      width: null,
-      height: null,
-      dialogHeight: null,
-      toolbars: [],
-      selectedValue: this.multiple ? [] : {}
-    }
-  },
-  watch: {
-    visible: {
-      handler: function(val, oldVal) {
-        this.dialogVisible = val
-      },
-      immediate: true
+    data () {
+        return {
+            dialogVisible: this.visible,
+            dataTemplate: {},
+            type: 'default',
+            title: '',
+            width: null,
+            height: null,
+            dialogHeight: null,
+            toolbars: [],
+            selectedValue: this.multiple ? [] : {},
+            showLabel: this.labelKey
+        }
     },
-    data: {
-      handler: function(val, oldVal) {
-        this.initDataTemplate(val)
-        this.dataTemplate = val
-      },
-      deep: true,
-      immediate: true
+    watch: {
+        visible: {
+            handler: function (val, oldVal) {
+                this.dialogVisible = val
+            },
+            immediate: true
+        },
+        labelKey: {
+            handler: function (val, oldVal) {
+                if (val) {
+                    this.showLabel = val
+                }
+            },
+            immediate: true
+        },
+        data: {
+            handler: function (val, oldVal) {
+                this.initDataTemplate(val)
+                this.dataTemplate = val
+            },
+            deep: true,
+            immediate: true
+        },
+        value: {
+            handler (val, oldVal) {
+                this.selectedValue = this.$utils.isNotEmpty(val) ? JSON.parse(JSON.stringify(val)) : val
+            },
+            deep: true,
+            immediate: true
+        }
     },
-    value: {
-      handler(val, oldVal) {
-        this.selectedValue = this.$utils.isNotEmpty(val) ? JSON.parse(JSON.stringify(val)) : val
-      },
-      deep: true,
-      immediate: true
-    }
-  },
-  methods: {
-    // 关闭当前窗口
-    closeDialog() {
-      this.$emit('close', false)
-    },
-    initDataTemplate(dataTemplate) {
-      if (!dataTemplate) return
-      this.type = dataTemplate.type
-      this.title = dataTemplate.name
-      if (this.type === 'dialog') {
-        const dialogs = dataTemplate.dialogs
-        const width = parseInt(dialogs.attrs ? dialogs.attrs.width || '80' : '80')
-        const height = parseInt(dialogs.attrs ? (dialogs.attrs.height || '80') : '80')
-        this.width = width <= 100 ? `${width}%` : `${width}px`
-        this.height = height <= 100 ? `${height}%` : `${height}px`
-        const h = height <= 100 ? document.body.clientHeight : height
+    methods: {
+        // 关闭当前窗口
+        closeDialog () {
+            this.$emit('close', false)
+        },
+        initDataTemplate (dataTemplate) {
+            if (!dataTemplate) return
+            this.type = dataTemplate.type
+            this.title = dataTemplate.name
+            if (this.type === 'dialog') {
+                const dialogs = dataTemplate.dialogs
+                const width = parseInt(dialogs.attrs ? dialogs.attrs.width || '80' : '80')
+                const height = parseInt(dialogs.attrs ? (dialogs.attrs.height || '80') : '80')
+                this.width = width <= 100 ? `${width}%` : `${width}px`
+                this.height = height <= 100 ? `${height}%` : `${height}px`
+                const h = height <= 100 ? document.body.clientHeight : height
 
-        const vh = height === 100 ? 0 : (document.body.clientHeight / 100 * 7)
+                const vh = height === 100 ? 0 : (document.body.clientHeight / 100 * 7)
 
-        this.dialogHeight = h - 130 - (this.multiple ? 60 : 40) - vh
-        this.toolbars = this.handleToolbars(dialogs.buttons ? dialogs.buttons.dialog_buttons : [])
-      }
-    },
-    handleToolbars(buttons) {
-      const toolbars = []
-      buttons.forEach(button => {
-        const buttonType = button.button_type
-        const btn = ButtonsConstants[buttonType] || {}
-        toolbars.push({
-          key: buttonType,
-          label: button.label || btn.label,
-          type: button.style || btn.type,
-          icon: button.icon || btn.icon,
-          action: () => {
-            if (buttonType === 'ok') {
-              if (this.$utils.isEmpty(this.selectedValue)) {
-                this.$message.closeAll()
-                this.$message.warning('请选择记录!')
-                return
-              }
-            } else if (buttonType === 'clean' || buttonType === 'cleanClose') {
-              this.$refs['dataTemplate'].clearSelection()
+                this.dialogHeight = h - 130 - (this.multiple ? 60 : 40) - vh
+                this.toolbars = this.handleToolbars(dialogs.buttons ? dialogs.buttons.dialog_buttons : [])
             }
-            this.handleActionEvent(buttonType)
-          }
-        })
-      })
-      return toolbars
-    },
-    handleActionEvent(key) {
-      if (key === 'clean' || key === 'cleanClose') {
-        this.selectedValue = this.multiple ? [] : {}
-        this.setSelectRow()
-      }
-      this.$emit('action-event', key, JSON.parse(JSON.stringify(this.selectedValue)))
-    },
-    setSelectRow() {
-      if (this.$refs['dataTemplate'] && this.$refs['dataTemplate'].setSelectRow) {
-        this.$refs['dataTemplate'].setSelectRow()
-      }
-    }
+            if (this.$utils.isEmpty(this.labelKey)) {
+                this.showLabel = buildLabelTitle(dataTemplate)
+            }
+        },
+        handleToolbars (buttons) {
+            const toolbars = []
+            buttons.forEach(button => {
+                const buttonType = button.button_type
+                const btn = ButtonsConstants[buttonType] || {}
+                toolbars.push({
+                    key: buttonType,
+                    label: button.label || btn.label,
+                    type: button.style || btn.type,
+                    icon: button.icon || btn.icon,
+                    action: () => {
+                        if (buttonType === 'ok') {
+                            if (this.$utils.isEmpty(this.selectedValue)) {
+                                this.$message.closeAll()
+                                this.$message.warning('请选择记录!')
+                                return
+                            }
+                        } else if (buttonType === 'clean' || buttonType === 'cleanClose') {
+                            this.$refs['dataTemplate'].clearSelection()
+                        }
+                        this.handleActionEvent(buttonType)
+                    }
+                })
+            })
+            return toolbars
+        },
+        handleActionEvent (key) {
+            if (key === 'clean' || key === 'cleanClose') {
+                this.selectedValue = this.multiple ? [] : {}
+                this.setSelectRow()
+            }
+            this.$emit('close', false)
+            if (typeof this.selectedValue !== 'undefined') {
+                this.$emit('action-event', key, JSON.parse(JSON.stringify(this.selectedValue)))
+            }
+        },
+        setSelectRow () {
+            if (this.$refs['dataTemplate'] && this.$refs['dataTemplate'].setSelectRow) {
+                this.$refs['dataTemplate'].setSelectRow()
+            }
+        }
 
-  }
+    }
 }
 </script>
 <style lang="scss" >
-  .data-template-renderer-dialog{
-    .el-dialog__header{
-      padding: 0;
-      border-bottom:0;
-    }
-    .el-dialog__body {
-      padding: 0;
-    }
-    .el-dialog__headerbtn{
-      z-index: 99999;
-    }
-  }
+.data-template-renderer-dialog{
+.el-dialog__header{
+  padding: 0;
+  border-bottom:0;
+}
+.el-dialog__body {
+  padding: 0;
+}
+.el-dialog__headerbtn{
+  z-index: 99999;
+}
+}
 </style>

+ 68 - 68
src/views/system/fasc/facilityEnvConfig.vue

@@ -326,75 +326,75 @@ export default {
                     label: '冰箱温度监控',
                     path: '/sshjgl/wdjc/bxwdjc',
                     showDevice: true
-                },
-                '03-温浴箱温度监控': {
-                    label: '温浴箱温度监控',
-                    path: '/sshjgl/wdjc/wyxwdjkywh',
-                    showDevice: true
-                },
-                '04-阴凉柜温度监控': {
-                    label: '阴凉柜温度监控',
-                    path: '/sshjgl/wdjc/ylgwdjc',
-                    showDevice: true
-                },
-                '05-纯水机水质监测': {
-                    label: '纯水机水质监测',
-                    path: '/sshjgl/csjszjcb',
-                    showDevice: true
-                },
-                '06-每日安全检查': {
-                    label: '每日安全检查',
-                    path: '/sshjgl/aqgl/mraqjc',
-                    showDevice: false
-                },
-                '07-每月安全检查': {
-                    label: '每月安全检查',
-                    path: '/sshjgl/aqgl/myaqjc',
-                    showDevice: true
-                },
-                '08-含氯有效性监测': {
-                    label: '含氯有效性监测',
-                    path: '/sshjgl/aqgl/hlyxxjc',
-                    showDevice: false
-                },
-                // '09-紫外灯辐照测定': {
-                //     path: '/sshjgl/aqgl/zwdfzd',
-                // },
-                '10-洗眼器检查': {
-                    label: '洗眼器检查',
-                    path: '/sshjgl/aqgl/xyqjc',
-                    showDevice: true
-                },
-                '11-紧急淋浴器检查': {
-                    label: '紧急淋浴器检查',
-                    path: '/sshjgl/aqgl/jjlyqjc',
-                    showDevice: true
-                },
-                '12-紫外灯消毒': {
-                    label: '紫外灯消毒',
-                    path: '/sshjgl/aqgl/jykzwdxdjlb',
-                    showDevice: true
-                },
-                '13-高压灭菌': {
-                    label: '高压灭菌',
-                    path: '/sshjgl/aqgl/gymjjlb',
-                    showDevice: true
-                },
-                '14-空气消毒机': {
-                    label: '空气消毒机',
-                    path: '/sshjgl/aqgl/xdjsyjlb',
-                    showDevice: true
-                },
-                '15-日常防护消毒': {
-                    label: '日常防护消毒',
-                    path: '/sshjgl/aqgl/rcfhxd',
-                    showDevice: false
-                },
-                '16-设备排出废液': {
-                    label: '设备排出废液',
-                    path: '/sshjgl/aqgl/sbpcfyxd',
-                    showDevice: true
                 }
+                // '03-温浴箱温度监控': {
+                //     label: '温浴箱温度监控',
+                //     path: '/sshjgl/wdjc/wyxwdjkywh',
+                //     showDevice: true
+                // },
+                // '04-阴凉柜温度监控': {
+                //     label: '阴凉柜温度监控',
+                //     path: '/sshjgl/wdjc/ylgwdjc',
+                //     showDevice: true
+                // },
+                // '05-纯水机水质监测': {
+                //     label: '纯水机水质监测',
+                //     path: '/sshjgl/csjszjcb',
+                //     showDevice: true
+                // },
+                // '06-每日安全检查': {
+                //     label: '每日安全检查',
+                //     path: '/sshjgl/aqgl/mraqjc',
+                //     showDevice: false
+                // },
+                // '07-每月安全检查': {
+                //     label: '每月安全检查',
+                //     path: '/sshjgl/aqgl/myaqjc',
+                //     showDevice: true
+                // },
+                // '08-含氯有效性监测': {
+                //     label: '含氯有效性监测',
+                //     path: '/sshjgl/aqgl/hlyxxjc',
+                //     showDevice: false
+                // },
+                // // '09-紫外灯辐照测定': {
+                // //     path: '/sshjgl/aqgl/zwdfzd',
+                // // },
+                // '10-洗眼器检查': {
+                //     label: '洗眼器检查',
+                //     path: '/sshjgl/aqgl/xyqjc',
+                //     showDevice: true
+                // },
+                // '11-紧急淋浴器检查': {
+                //     label: '紧急淋浴器检查',
+                //     path: '/sshjgl/aqgl/jjlyqjc',
+                //     showDevice: true
+                // },
+                // '12-紫外灯消毒': {
+                //     label: '紫外灯消毒',
+                //     path: '/sshjgl/aqgl/jykzwdxdjlb',
+                //     showDevice: true
+                // },
+                // '13-高压灭菌': {
+                //     label: '高压灭菌',
+                //     path: '/sshjgl/aqgl/gymjjlb',
+                //     showDevice: true
+                // },
+                // '14-空气消毒机': {
+                //     label: '空气消毒机',
+                //     path: '/sshjgl/aqgl/xdjsyjlb',
+                //     showDevice: true
+                // },
+                // '15-日常防护消毒': {
+                //     label: '日常防护消毒',
+                //     path: '/sshjgl/aqgl/rcfhxd',
+                //     showDevice: false
+                // },
+                // '16-设备排出废液': {
+                //     label: '设备排出废液',
+                //     path: '/sshjgl/aqgl/sbpcfyxd',
+                //     showDevice: true
+                // }
             },
             subIdList: [],
             isFirstLieBiao: true