【sgCreateTableColumn】自定义小工具:敏捷开发→自动化生成表格列html代码(表格列生成工具)[基于el-table-column]

源码

html 复制代码
<template>
  <!-- 
前往https://blog.csdn.net/qq_37860634/article/details/136126479
查看使用说明
-->
  <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: "sgCreateTableColumn",
  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 pinyinTexts = texts.map((v) => {
        let cn_col = v;
        let py_col = pinyin.getCamelChars(v);
        let r = `<el-table-column prop="${py_col}" label="${cn_col}" show-overflow-tooltip />`;
        return r;
      });

      this.textareaValue2 = pinyinTexts.join("\n");

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

<style lang="scss" scoped>
.sgCreateTableColumn {
  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>
相关推荐
黄焖鸡能干四碗6 分钟前
网络安全风险评估报告(WORD版本)
大数据·运维·网络·人工智能·制造
北京耐用通信10 分钟前
工业自动化中的协议桥梁:耐达讯自动化EtherCAT转RS232技术深度解析
人工智能·科技·物联网·自动化·信息与通信
跨境麦香鱼13 分钟前
2026自动化抢鞋机器人:如何通过高并发代理提高成功率?
运维·网络·自动化
路由侠内网穿透19 分钟前
本地部署开源发票管理系统 Invoice Ninja 并实现外部访问
运维·服务器·数据库·物联网·开源
Hello 0 127 分钟前
“机房学生认证系统”与批量自动化部署方案
运维·自动化
KKKlucifer29 分钟前
4A 平台合规自动化:从策略配置到审计追溯的全链路技术实现
运维·网络·自动化
信创DevOps先锋33 分钟前
Gitee DevOps:构筑国产化数字基座,赋能企业信创转型
运维·gitee·devops
似水এ᭄往昔1 小时前
【Linux】--进程控制
linux·运维·服务器
l14372332671 小时前
AI解说大师narrator-ai-cli:影视解说自动化工具,CLI架构让内容生产效率翻倍
运维·人工智能·自动化
Gofarlic_oms11 小时前
构建可视化监控体系实现ANSYS许可证可观测管理
大数据·运维·网络·数据库·人工智能