【VUE-编辑回显】

<el-button
              plain
              size="mini"
              type="primary"
              @click="editBtn(scope.row)"
              >编辑el-button
            >

<el-dialog
        :visible.sync="dialogVisible"
        width="800px"
        center
        :show-close="false"
      >
        <el-divider><h3>编辑h3>el-divider>
        <div style="flex: 1">
          <el-form
            label-width="130px"
            label-position="right"
            size="mini"
            :model="editForm"
          >
            <el-row>
              <el-col :span="14">
                <el-form-item label="章名称">
                  <el-input v-model="editForm.str23">el-input> el-form-item
              >el-col>
              <el-col :span="8">
                <el-form-item label="备注">
                  <el-input v-model="editForm.str3">el-input>
                el-form-item>
              el-col>
            el-row>

            <el-row>
              <el-col :span="14">
                <el-form-item label="节名称">
                  <el-input v-model="editForm.str24">el-input> el-form-item
              >el-col>
              <el-col :span="8">
                <el-form-item label="视频时长">
                  <el-input v-model="editForm.str2">el-input> el-form-item
              >el-col>
            el-row>
            <el-row>
              <el-col :span="14"
                ><el-form-item label="视频标题">
                  <el-input v-model="editForm.str21">el-input> el-form-item
              >el-col>
              <el-col :span="8">
                <el-form-item label="学时">
                  <el-input v-model="editForm.str4">el-input> el-form-item
              >el-col>
            el-row>

            <el-row>
              <el-col :span="14">
                <el-form-item label="视频分类"
                  ><el-cascader
                    ref="cascader02"
                    v-model="editForm.str15"
                    
                    :options="optionIds2"
                    :props="{ expandTrigger: 'hover' }"
                    :show-all-levels="false"
                    @change="handleChanges2"
                    clearable
                  >
                  el-cascader>el-form-item
              >el-col>
              <el-col :span="8"
                ><el-form-item label="标签">
                  <el-select
                    v-model.trim="editForm.str30"
                    filterable
                    remote
                    multiple
                    placeholder="请选择标签"
                    :remote-method="getOption"
                    @change="tagsChange2"
                    :loading="loading"
                  >
                    <el-option
                      v-for="item in tagOptions2"
                      :key="item.code.toString()"
                      :label="item.tagTitle"
                      :value="item.code.toString()"
                    >
                    el-option>
                  el-select> el-form-item
              >el-col>
            el-row>

            <el-row>
              <el-col :span="12">
                <el-form-item label="讲师">
                  <el-input v-model="editForm.str28">el-input> el-form-item
              >el-col>
              <el-col :span="12">
                <el-form-item label="服务器ip">
                  <el-input v-model="editForm.str7">el-input> el-form-item
              >el-col>
            el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="分辨率">
                  <el-input v-model="editForm.str17">el-input> el-form-item
              >el-col>
              <el-col :span="12">
                <el-form-item label="用于">
                  <el-select
                    v-model="editForm.str16"
                    placeholder="用于"
                    style="width: 80px !important"
                  >
                    <el-option key="01" label="PC" value="01"> el-option>
                    <el-option key="02" label="移动端" value="02"> el-option>
                  el-select> el-form-item
              >el-col>
            el-row>
            <el-row>
              <el-col :span="12"
                ><el-form-item label="片头">
                  <el-select
                    v-model="editForm.str25"
                    placeholder="片头"
                    style="width: 80px !important"
                  >
                    <el-option key="02" label="" value="02"> el-option>
                    <el-option key="01" label="" value="01"> el-option>
                  el-select> el-form-item
              >el-col>
              <el-col :span="12"
                ><el-form-item label="片尾">
                  <el-select
                    v-model="editForm.str26"
                    placeholder="片尾"
                    style="width: 80px !important"
                  >
                    <el-option key="02" label="" value="02"> el-option>
                    <el-option key="01" label="" value="01"> el-option>
                  el-select> el-form-item
              >el-col>
            el-row>

            <el-row>
              <el-col :span="12">el-col>
              <el-col :span="12">el-col>
            el-row>

            <el-form-item label="录制时间">
              <el-input v-model="editForm.str5">el-input>
            el-form-item>
            <el-form-item label="视频路径">
              <el-input v-model="editForm.str27">el-input>
            el-form-item>
            <el-form-item label="视频切片索引路径">
              <el-input v-model="editForm.str29">el-input>
            el-form-item>
          el-form>
        div>
        <div class="btns flex jcc">
          <el-button type="primary" @click="editSave">保存el-button>
          <el-button @click="cancel">取消el-button>
        div>
      el-dialog>
 editForm: {
        str2: "",
        str3: "",
        str4: "",
        str5: "",
        str7: "",
        str15: "",
        str16: "",
        str17: "",
        str21: "",
        str23: "",
        str24: "",
        str25: "",
        str26: "",
        str27: "",
        str28: "",
        str29: "",
        str30: [],
      },//注意:一定要初始化里面的字段,不然当数据里面的字段是null,则由于回显值没有初始化,就位默认回显为null
      editBtn(item) {
      //编辑
      this.getOption();
      this.editForm.str23 = item.str23
      this.editForm.str3 = item.str3
      this.editForm.str24 = item.str24
      this.editForm.str2 = item.str2
      this.editForm.str21 = item.str21
      this.editForm.str4 = item.str4
      this.editForm.str15 = item.str15
      this.editForm.str30 = item.str30.toString().split(",")
      this.editForm.str28 = item.str28
      this.editForm.str7 = item.str7
      this.editForm.str17 = item.str17
      this.editForm.str16 = item.str16
      this.editForm.str25 = item.str25
      this.editForm.str26 = item.str26
      this.editForm.str5 = item.str5
      this.editForm.str27 = item.str27
      this.editForm.str29 = item.str29
      this.dialogVisible = true;
      this.isTagCode =  item.str30.toString().split(",")
      this.isClassifyCode = this.editForm.str15
    },//里面复制需要用哪些就直接复制给哪些,如果直接等于对象,则会有问题

你可能感兴趣的:(记录项目中遇到的问题,vue.js,elementui)