wente
2023-11-22 d6e03c8b28806fe3e0523f9827bcd593c61454fb
web/packages/components/zt-dict/src/zt-dict.vue
@@ -4,9 +4,9 @@
          <el-option :label="data.dictLabel" v-for="data in dicts" :key="data.dictValue" :value ="data.dictValue">{{data.dictLabel}}</el-option>
      </el-select>
      <div v-if="showType === 'radio'" :disabled="disabled">
        <el-radio-group :value="dictValue" @input="$emit('input', $event)" >
          <el-radio :label="data.dictValue" @change="changeDictValue(data.dictValue,data.dictLabel)" v-for="data in dicts" :key="data.dictValue">{{data.dictLabel}}</el-radio>
          <el-input class="radio-input" v-if="isName" v-model="inputName"></el-input>
        <el-radio-group :value="dictValue" @input="$emit('input', $event)">
          <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"/>
@@ -19,6 +19,7 @@
    name: 'ZtDict',
    props: {
      inputName:{},
      origin:{}, // 字典字段
      value: [Number, String, Boolean],
      dict: { // 字典类型
        type: String,
@@ -48,7 +49,6 @@
      return {
        dictValue: typeof this.value === 'undefined' ? '' : (this.value + ''),
        isName:false,
        eventIndex:'',
      }
    },
    computed: {
@@ -64,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) {
@@ -78,19 +82,12 @@
    watch: {
      value(val, oldval) {
        this.dictValue = typeof val === 'undefined' ? '' : (val + '')
      },
      inputName(){
        this.$emit('getChangeInputData',this.inputName,this.origin)
      }
    },
    methods: {
      changeDictValue(value,name){
        if(name.indexOf("其他")!=-1){
          console.log(this.inputName,'inputName')
          console.log(name,'字典名字q34567')
          this.eventIndex = value
          this.isName = true
        }else {
          this.isName = false
        }
      },
      wrapTreeId(dictTypes) {
        dictTypes.forEach(item => {
          if ((item.dictType || '').length > 0) { // 字典类型