ItemComponentChild.vue 3.8 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
<template>
  <div style="width:100%;height:100%;">
    <template v-if="item.showType==='text'||!item.showType">
      <span
        style="width:100%"
        clearable
        :style="{width:item.width+'px'}"
        size='mini'
        :placeholder="item.label"
      >{{formParms[item.prop]}}</span>
    </template>
    <template v-if="item.showType==='input'">
      <el-input
        @keyup.enter.native="enterInput"
        style="width:100%"
        clearable
        :disabled='disabled'
        size='mini'
        v-model="formParms[item.prop]"
        :placeholder="item.label"
      ></el-input>
    </template>
    <template v-if="item.showType==='textarea'">
      <el-input
        style="width:100%"
        type='textarea'
        clearable
        :disabled='disabled'
        v-model="formParms[item.prop]"
        :placeholder="item.label"
      ></el-input>
    </template>

    <template v-if="item.showType==='elDatePicker'">
      <el-date-picker
        clearable
        :disabled='disabled'
        style="width:100%"
        size='mini'
        v-model="formParms[item.prop]"
        type="daterange"
        valueFormat='yyyy-MM-dd'
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
      >
      </el-date-picker>
    </template>
    <template v-if="item.showType==='elDatePickerDatetime'">
      <el-date-picker
        clearable
        :disabled='disabled'
        style="width:100%"
        size='mini'
        v-model="formParms[item.prop]"
        type="datetime"
        valueFormat='yyyy-MM-dd HH:mm:ss'
        placeholder="选择日期时间"
      >
      </el-date-picker>
    </template>
    <template v-if="item.showType==='elSwitch'">
      <hsSwitch
        style="width:100%"
        size='mini'
        v-model="formParms[item.prop]"
        :disabled='disabled'
      >
      </hsSwitch>
    </template>
    <template v-if="item.showType==='elCheckbox'">
      <el-checkbox
        style="width:100%"
        size='mini'
        :disabled='disabled'
        v-model="formParms[item.prop]"
      >
      </el-checkbox>
    </template>
    <template v-if="item.showType==='hsComputed'">
        <hsComputed
        v-model="formParms[item.prop]"
        :allSourceData='item.allSourceData'
        :elInfo='item.elInfo'
        :readonly='disabled'
        :formData='formParms'
        >
      </hsComputed>
    </template>
    <template v-if="item.showType==='hsSelectPlus'">
      <hsSelectPlus
       v-model="formParms[item.prop]"
      :allSourceData='item.allSourceData'
      :elInfo='item.elInfo'
      :writeBackObject='formParms'
      :readonly='disabled'
何虹's avatar
何虹 committed
97
      :requestMethod='item.requestMethod'
何虹's avatar
何虹 committed
98 99 100 101 102 103 104 105
      >
      </hsSelectPlus>
    </template>
  </div>

</template>
<script>
export default {
何虹's avatar
.  
何虹 committed
106
  name: 'dyncFormItemComponentChild_',
何虹's avatar
何虹 committed
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
  props: {
    item: {},
    formParms: {},
    jsoneditorOpenAfter: {
      type: Function
    },
    allColumsConfig: {},
    readonly: {}
  },
  watch: {
    item: {
      handler: function(newData) {},
      deep: true
    }
  },
  computed: {
    disabled() {
      let bool = false
      if (this.formParms._readonlyFields) {
        bool = JSON.parse(this.formParms._readonlyFields).includes(
          this.item.prop
        )
      } else {
        bool = this.item.isDisabled
      }
      return !!(this.readonly || bool)
    }
  },
  data() {
    return {}
  },
  mounted() {},
  methods: {
    enterInput(val) {
      this.$emit('enterInput', val)
    },
    showLabel(item) {
      if (item.isHideLabel) {
        return false
      }
      if (!item.label) {
        return false
      }
      return true
    },
    isShowItem(item) {
      if (item.isMoreSearch) {
        return false
      }
      if (!item.isHide) {
        return true
      }
    }
  }
}
</script>
<style scoped>
.inputBox {
  height: 100%;
}
</style>