index.vue 2.97 KB
Newer Older
何虹's avatar
何虹 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
<template>
      <div  :id='elId'  class="outBox" :style="{'height':height}">
        <template v-if="type!=='queryArea'">
              <dyncFormItemComponentTable
                :elInfo='elInfo'
                :formParms='formParms'
                :jsoneditorOpenAfter='jsoneditorOpenAfter'
                :allSourceData='allSourceData_'
                :type='type'
                :readonlyStatus='readonlyStatus'
                >
              </dyncFormItemComponentTable>
        </template>
        <template v-else>
          <dyncFormItemComponentQuery
          :elInfo='elInfo'
          :formParms='formParms'
          :jsoneditorOpenAfter='jsoneditorOpenAfter'
          @submit='searchSubmit'
          @enterInput='searchSubmit'
          :allSourceData='allSourceData_'
          :type='type'
          ></dyncFormItemComponentQuery>
        </template>
          <jsoneditor
            :controlType='type'
            v-model='jsoneditorVisible'
            :elInfo='elInfo'
            :jsoneditorCloseAfter='jsoneditorCloseAfter'
            :jsoneditorOpenAfter='jsoneditorOpenAfter'
            >
          </jsoneditor>
      </div>
</template>
<script>
import ucComponent from '../ucClass/uc_component'
import jsoneditor from '../common/jsoneditor'
import _ from 'lodash'
import dyncFormItemComponentTable from './dyncFormItemComponentTable'
import dyncFormItemComponentQuery from './dyncFormItemComponentQuery'
export default {
  name: 'hsDyncForm',
  mixins: [ucComponent],
  components: {
    jsoneditor,
    dyncFormItemComponentTable,
    dyncFormItemComponentQuery
  },
  props: {
    allSourceData: {
      type: Object,
      default() {
        return {}
      }
    },
    formParms: {},
    elInfo: {},
    jsoneditorCloseAfter: {
      default() {
        return () => {}
      }
    },
    jsoneditorOpenAfter: {
      default() {
        return () => {}
      }
    },
    type: {
      default: 'queryArea'
    },
    readonlyStatus: {}
  },
  watch: {
    allSourceData: {
      handler: function(newVal) {
        this.initConfig(newVal)
      },
      deep: true
    }
  },
  data() {
    return {
      jsoneditorVisible: false,
      height: '100%',
      allSourceData_: {}
    }
  },
  mounted() {
    this.initConfig(this.allSourceData)
  },
  methods: {
    initConfig(data) {
      this.allSourceData_ = _.cloneDeep(data)
      const { config } = this.allSourceData_
      if (!config) return
      const { height, formColumn } = config
      this.height = height || this.height
      if (formColumn) {
      // auto 生成控件名
        formColumn.forEach(item => {
          if (item.type.startsWith('hs')) {
            item.elInfo = {
              position: item.control_name,
              el: item.type
            }
          }
        })
      }
    },
    enterInput() {
      this.$emit('searchSubmit', this.formParms)
    },
    searchSubmit() {
      this.$emit('searchSubmit', this.formParms)
    }
  }
}
</script>
<style scoped>
.outBox{
  width: 100%;
}

</style>