vueElementplus,使用nextTick获取input的focues,2022/6/10pm

<template>
  <div class="productInformation">

    <div class="table">
        <el-table
           height="760"
           :data="productTreeTable"
           style="width: 100%;"
           row-key="id"
           :default-expand-all="false"
           :header-cell-style="{fontSize:'18px',fontWeight:'600',  }"
            @cell-click="cellClick"  重点调用

        >
         
          <el-table-column  width="55" >
             <template  #default="scope">
               <el-image v-if="scope.row.treePic"  style="width:50px;vertical-align:center;" :src="scope.row.treePic" />
             </template>
          </el-table-column>
         
          <el-table-column prop="name" label="Item Description" width="300" >
            <!-- 有颜色 colorNo: "DDD5C7" -->
            <template  #default="scope">
               <div style="display: flex;align-items: center;">
                 <div v-if="scope.row.colorNo" class="colorbox" :style="{'background-color':'#' + scope.row.colorNo}"></div>
                 <span>{{scope.row.name}}</span>
               </div>
            </template>
          </el-table-column>
          <el-table-column prop="optionNo" label="Valve" />
           <el-table-column label="Price" >
              <template  #default="scope">
              <!-- <el-switch  v-model="scope.row.available" /> -->
              <el-input
                clearable
                ref="editInput"      重点
                v-if="scope.row.seen == true"
                v-model.number="scope.row.price"
                @blur="loseFcous(scope.row)">
              </el-input>
              <span v-else> {{scope.row.price}} </span>
            </template>
           </el-table-column>
          <el-table-column  label="Default" >
            <template  #default="scope">
              <el-switch v-if="scope.row.default == ''"  v-model="scope.row.default" />
            </template>
          </el-table-column>
          
       </el-table>
      
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, toRefs, reactive, onMounted, computed, ref, nextTick } from 'vue'
import { useStore } from 'vuex'
import { useRouter } from 'vue-router'

export default defineComponent({
  name: 'product',
  components: {
    // Table,
  },
  setup () {
    const Store = useStore()
    const Router = useRouter()
    const editInput = ref()
    const data = reactive({
      storeNo: computed(() => {
        return Store.state.Microstore.storeNo
      }),
      productTreeTable: computed(() => {
        return Store.state.Product.productTreeTable
      }),
      loseFcous (row:any) {
        console.log('失去焦点')
        row.seen = false
      },
      cellClick (row:any) {
        console.log('点击editInput', row)
        if (!row.children) {
          row.seen = true
          console.log(editInput.value)
          nextTick(() => {
            editInput.value.focus()
            console.log('11')
          })

        }

      },
      handleSubmit () {
        console.log('提交')
      },
      handleClose () {
        console.log('关闭')
        Router.push({
          path: `/dashboard/saleschannel/microstores/${data.storeNo}/products`
        })
      }

    })
    onMounted(() => {
      // data.getStoreStylesdata()
      console.log(data.productTreeTable)
    })
    return {
      ...toRefs(data), editInput

    }
  }

})

</script>
<style lang="less" scoped>
.productInformation {
  width: 100%;
  box-sizing: border-box;
  .table {
    margin-top:30px;
    .colorbox {
      width: 20px;
      height: 20px;
      margin-right:10px;
      // background-color: red;

    }
    .btnend {
      margin-top:60px;
      margin-bottom:40px;
      display: flex;
      justify-content: center;
      .btn {
        width: 92px;
        height: 40px;
        font-size: 18px;
      }
  }
  }
}
// 重置swich样式
::v-deep(.el-switch.is-checked .el-switch__core) {
  background-color: #6a49ac;
  border-color: #6a49ac;
}
// 重置input框的样式
  ::v-deep(.el-input__wrapper) {
    box-shadow: 0 0 0 1px #98a3b3 inset;
  }
  ::v-deep(.el-input__wrapper .is-focus) {
    box-shadow: 0 0 0 2px #6a49ac inset;
  }
  ::v-deep(.el-input__wrapper:hover) {
    box-shadow: 0 0 0 2px #6a49ac inset;
  }
</style>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值