jinlin
2024-02-23 1772fc5e211f9e9e0ab4cdc6c29b436aac178c2a
web/packages/components/zt-dict/src/zt-dict.vue
@@ -3,9 +3,12 @@
      <el-select :value="dictValue" @change="changeProjectMajor" @input="$emit('input', $event)" :placeholder="placeholder" clearable style="width: 100%;" v-if="showType === 'select'" :disabled="disabled">
          <el-option :label="data.dictLabel" v-for="data in dicts" :key="data.dictValue" :value ="data.dictValue">{{data.dictLabel}}</el-option>
      </el-select>
      <el-radio-group :value="dictValue" @input="$emit('input', $event)" v-if="showType === 'radio'" :disabled="disabled">
        <el-radio :label="data.dictValue" v-for="data in dicts" :key="data.dictValue">{{data.dictLabel}}</el-radio>
      </el-radio-group>
      <div v-if="showType === 'radio'">
        <el-radio-group :value="dictValue" @input="$emit('input', $event)" :disabled="disabled">
          <el-radio :label="data.dictValue" v-for="data in dicts" :key="data.dictValue">{{data.dictLabel}}</el-radio>
          <el-input class="radio-input" v-if="isOtherOptionSelected" v-model="inputName"></el-input>
        </el-radio-group>
      </div>
      <zt-combo-tree v-model="dictValue" :datas="dictTrees" :disabled-filter="disabledFilter" @input="$emit('input', $event)" v-if="showType === 'tree'" :placeholder="placeholder"/>
    </div>
</template>
@@ -15,6 +18,8 @@
  export default {
    name: 'ZtDict',
    props: {
      inputName:{},
      origin:{}, // 字典字段
      value: [Number, String, Boolean],
      dict: { // 字典类型
        type: String,
@@ -42,7 +47,8 @@
    },
    data() {
      return {
        dictValue: typeof this.value === 'undefined' ? '' : (this.value + '')
        dictValue: typeof this.value === 'undefined' ? '' : (this.value + ''),
        isName:false,
      }
    },
    computed: {
@@ -58,6 +64,10 @@
        this.wrapTreeId(datas)
        return datas
      },
      isOtherOptionSelected() {
        const selectedOption = this.dicts.find(data => data.dictValue === this.dictValue);
        return selectedOption && selectedOption.dictLabel.includes('其他');
      },
      dicts: function () {
        let dicts = this.$store.getters.getDict(this.dict)
        if (this.excluded.length > 0) {
@@ -72,6 +82,9 @@
    watch: {
      value(val, oldval) {
        this.dictValue = typeof val === 'undefined' ? '' : (val + '')
      },
      inputName(){
        this.$emit('getChangeInputData',this.inputName,this.origin)
      }
    },
    methods: {
@@ -117,5 +130,13 @@
    background-color: #00a06e !important;
    border-color: #1890ff !important;
  }
  .radio-input.el-input{
    position: absolute;
    bottom: 5px;
    left: 68px;
  }
  .radio-input.el-input>.el-input__inner{
    height: 25px;
  }
</style>