Vxe UI 表格行编辑(默认不显示编辑框,点击后可编辑)

效果:

HTML代码:(type="integer"为这个,是限制只能输入正整数或负整数,英文和汉字自动转成0)

html 复制代码
<vxe-table
        show-overflow
        keep-source
        v-loading="loading"
        :data="ruleList"
        ref="Table"
        :row-config="{isHover: true}"
        height="100%"
        :edit-config="{trigger: 'click', mode: 'cell', showStatus: true}"
      >
        
        <vxe-column type="seq" width="60" />
        <vxe-column
          title="排序"
          field="orderNum"
          :show-overflow-tooltip="true"
          :edit-render="{autofocus: '.myinput'}"
        >
          <template #edit="scope">
            <vxe-input
              type="integer"
              maxlength="30"
              class="myinput"
              v-model="scope.row.orderNum"
              placeholder="请输入"
              @input="updateRowStatus(scope)"
              clearable
            ></vxe-input>
          </template>
        </vxe-column>
</vxe-table>

方法:

表格上方的 更新排序 按钮的禁用状态(动态)判断

this.updateRecords里装的就是已编辑的行数据数组包对象结构,编辑了几个行,就有几个对象

javascript 复制代码
 // 排序处理
    updateRowStatus(params) {
      //获取表格中所有编辑过的行数据(就是所有带红色标志的)
      const $table = this.$refs.Table;
      if ($table) {
        this.updateRecords = $table.getUpdateRecords();
        if (this.updateRecords.length) {//可以控制表格上方排序按钮的disabled状态
          this.multiple = false;
        } else {
          this.multiple = true;
        }
      }
    },

排序按钮方法

javascript 复制代码
  handleStor() {
        this.$modal
          .confirm("是否确按输入顺序排序")
          .then(res => {
            //如果表格中有变更的行数据  就传入及接口  后端排序
            updateAttributeSort(this.updateRecords).then(res => {
              if (res.code === 200) {
                this.multiple = true;
                this.$modal.msgSuccess("更新排序完成");
                this.getList();
              } else {
                this.$modal.msgError(res.msg);
              }
            });
          })
          .catch(() => {});
    },
相关推荐
Yvonne爱编码1 小时前
CSS- 1.1 css选择器
前端·css·状态模式·html5·hbuilder
山河故人1631 小时前
uniapp使用npm下载
前端·npm·uni-app
-曾牛2 小时前
基于微信小程序的在线聊天功能实现:WebSocket通信实战
前端·后端·websocket·网络协议·微信小程序·小程序·notepad++
一口一个橘子2 小时前
[ctfshow web入门] web72
前端·web安全·网络安全
Web极客码2 小时前
如何使用WordPress SEO检查器进行实时内容分析
前端·seo·wordpress
Stella25212 小时前
【Vue】CSS3实现关键帧动画
前端·vue.js·css3
junjun.chen06062 小时前
【在qiankun模式下el-dropdown点击,浏览器报Failed to execute ‘getComputedStyle‘ on ‘Window‘: parameter 1 is not o
前端·javascript·前端框架
Yvonne爱编码2 小时前
HTML-3.3 表格布局(学校官网简易布局实例)
前端·html·github·html5·hbuilder
素雪风华2 小时前
构建RAG混合开发---PythonAI+JavaEE+Vue.js前端的实践
java·vue.js·python·ai·语言模型·llms·qwen千问大模型
jllllyuz3 小时前
matlab实现蚁群算法解决公交车路径规划问题
服务器·前端·数据库