Write a row of numbers in excel, copy and paste directly into different columns of the table

<td v-for="(item, i) in list" :key="'汉堡' + item" class="td-num">
              <el-input
                v-model="form['remark' + (12 + i)]"
                @input="onInput($event, form, i, 1)"
                placeholder="请输入"
                class="noneBorderInput"
              />
            </td>
<td v-for="(item, i) in list" :key="'薯条' + item" class="td-num">
              <el-input
                v-model="form['remark' + (20 + i)]"
                @input="onInput($event, form, i, 2)"
                placeholder="请输入"
                class="noneBorderInput"
              />
            </td>
 onInput(value, form, index, row) {
    
    
      // 获取粘贴内容
      // const value = e.target.value;
      if (!value) {
    
    
        return;
      }
      // 粘贴内容分隔成数组
      const values = value.split(" ");
      values.forEach((line, num) => {
    
    
        const lines = line
          .replace(/\t/g, " ")
          .trim()
          .split(/\s+/);
        // 将数组每项赋给对应的remark
        if (values.length > 1) {
    
    
          // 多行
          lines.forEach((v, i) => {
    
    
            if (this.list.length + 1 >= i) {
    
    
              form["remark" + ((num === 0 ? 12 : 20) + index + i)] = v;
            }
          });
        } else {
    
    
          // 单行
          lines.forEach((v, i) => {
    
    
            if (this.list.length + 1 >= i) {
    
    
              form["remark" + ((row === 1 ? 12 : 20) + index + i)] = v;
            }
          });
        }
      });
    }

Guess you like

Origin blog.csdn.net/Ybittersweet/article/details/129851561