【sgCreateTableData】自定义小工具:敏捷开发→自动化生成表格列数据数组[基于el-table]

源码

<template>
  <!-- 
前往https://blog.csdn.net/qq_37860634/article/details/136141769
查看使用说明
-->
  <div :class="$options.name">
    <div class="sg-head">表格数据生成工具</div>
    <div class="sg-container">
      <div class="sg-start">
        <div style="margin-bottom: 10px">字段中文名</div>
        <el-input
          style="margin-bottom: 10px"
          type="textarea"
          :placeholder="`请粘贴字段中文名`"
          v-model="textareaValue1"
          :rows="30"
          show-word-limit
        />

        <el-button type="primary" @click="createResult">生成表格数据</el-button>
      </div>
      <div class="sg-center">→</div>

      <div class="sg-end">
        <div style="margin-bottom: 10px">生成结果</div>
        <el-input
          style="margin-bottom: 10px"
          type="textarea"
          :placeholder="`请复制结果`"
          v-model="textareaValue2"
          :rows="30"
          show-word-limit
        />

        <el-button type="primary" @click="copyResult">复制</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import pinyin from "@/js/pinyin";
export default {
  name: "sgCreateTableData",
  data() {
    return {
      textareaValue1: "",
      textareaValue2: "",
    };
  },
  watch: {
    textareaValue1(newValue, oldValue) {
      newValue && this.createResult(newValue);
    },
  },
  methods: {
    createResult(d) {
      let texts = this.textareaValue1.split("\n").map((v) => v.split("\t").join(""));
      let rowData = {};
      texts.map((v) => {
        let cn_col = v;
        let py_col = pinyin.getCamelChars(v);
        rowData[py_col] = cn_col;
      });
      let data = [...Array(5)].map((v) => rowData);
      this.textareaValue2 = JSON.stringify(data, null, 2);

      this.copyResult(); //自动复制生成结果
    },
    copyResult(d) {
      this.$g.copy(this.textareaValue2, true);
    },
  },
};
</script>

<style lang="scss" scoped>
.sgCreateTableData {
  width: 100%;
  height: 100%;
  position: absolute;
  box-sizing: border-box;
  padding: 20px;

  .sg-head {
    display: flex;
    // justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    color: #409eff;
    margin-bottom: 10px;
  }

  .sg-container {
    display: flex;
    flex-wrap: nowrap;

    & > .sg-start {
      width: calc(50% - 20px);
      flex-shrink: 0;
    }

    & > .sg-center {
      display: flex;
      justify-content: center;
      align-items: center;
      flex-grow: 1;
      margin: 0 10px;
      font-size: 24px;
      color: #409eff;
      font-weight: bold;
    }

    & > .sg-end {
      width: calc(50% - 20px);
      flex-shrink: 0;
    }

    >>> textarea {
      max-height: revert;
      height: calc(100vh - 200px);
      word-wrap: break-word;
      word-break: break-all;
      white-space: break-spaces;
    }
  }
}
</style>

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-18 08:18:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-18 08:18:01       101 阅读
  3. 在Django里面运行非项目文件

    2024-02-18 08:18:01       82 阅读
  4. Python语言-面向对象

    2024-02-18 08:18:01       91 阅读

热门阅读

  1. 7.Cloud-GateWay

    2024-02-18 08:18:01       45 阅读
  2. vue面试题

    2024-02-18 08:18:01       42 阅读
  3. useState和useReducer区别

    2024-02-18 08:18:01       44 阅读
  4. markdown绘制流程图相关代码片段记录

    2024-02-18 08:18:01       53 阅读
  5. Effective Objective-C 学习第三周

    2024-02-18 08:18:01       42 阅读
  6. MySQL导入/导出数据

    2024-02-18 08:18:01       35 阅读
  7. Linux下Spark offline安装graphframes包

    2024-02-18 08:18:01       65 阅读
  8. Arduino程序简单入门

    2024-02-18 08:18:01       39 阅读
  9. B31SE Image Processing

    2024-02-18 08:18:01       42 阅读
  10. MySQL的索引类型

    2024-02-18 08:18:01       42 阅读