目标效果如下:

vue联动效果

vue联动效果

 

 dialog弹出框中增加两个item

          <el-form-item label="维护方式" prop="oprType">
            <el-select class="filter-item" v-model="form.oprType" @change="switchOprType" placeholder="请选择维护方式">
              <el-option v-for="orTyp in  orTypeOptions" :key="orTyp.id" :label="orTyp.labelDefault" :value="orTyp.value"> </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="属性对象" prop="attrObj">
            <el-input v-model="form.attrObj" v-if="OprTypeFlag == 'input'" placeholder="请录入需要的属性对象"></el-input>
            <el-select class="filter-item" v-model="form.attrObj" v-if="OprTypeFlag == 'select'" placeholder="请录入需要的属性对象">
              <el-option v-for="attr in  dictOptions" :key="attr.code" :label="attr.name" :value="attr.code"> </el-option>
            </el-select>
          </el-form-item>
        </el-form-item>

在data->return{}中定义一个全局变量

OprTypeFlag: 'default',

  生成dialog时默认为文本框,created(){}方法中

this.OprTypeFlag = 'input';

  在methods里面添加切换方法:

    switchOprType() {
      if (event.target.innerText === '下拉框') {
        this.OprTypeFlag = 'select';
        this.form.attrObj = ''
      } else {
        this.OprTypeFlag = 'input';
        this.form.attrObj = ''
      }
    }

  

相关文章:

  • 2021-06-21
  • 2022-12-23
  • 2021-07-11
  • 2022-02-21
  • 2021-07-08
  • 2021-08-13
  • 2021-09-08
  • 2022-12-23
猜你喜欢
  • 2021-03-28
  • 2022-12-23
  • 2021-05-20
  • 2021-05-05
  • 2022-12-23
  • 2021-08-14
  • 2022-12-23
相关资源
相似解决方案