<template>123123123123 <div class=“container“>123123123123 <table>123123123123 <tbody>12312

<template>123123123123  <div class="container">123123123123    <table>123123123123      <tbody>123123123123        <tr>123123123123          <th class="report-table-message-title">姓名</th>123123123123          <td>123123123123            <div class="report-table-message-info">123123123123              <textarea123123123123                class="auto-resize-textarea"123123123123                v-model="name"123123123123                @focus="expandTextarea"123123123123                @blur="collapseTextarea"123123123123                @input="autoResizeTextarea"123123123123              ></textarea>123123123123            </div>123123123123          </td>123123123123        </tr>123123123123        <tr>123123123123          <th class="report-table-message-title">性别</th>123123123123          <td>123123123123            <div class="report-table-message-info">123123123123              <textarea123123123123                class="auto-resize-textarea"123123123123                v-model="gender"123123123123                @focus="expandTextarea"123123123123                @blur="collapseTextarea"123123123123                @input="autoResizeTextarea"123123123123              ></textarea>123123123123            </div>123123123123          </td>123123123123        </tr>123123123123        <tr>123123123123          <th class="report-table-message-title">年纪</th>123123123123          <td>123123123123            <div class="report-table-message-info">123123123123              <textarea123123123123                class="auto-resize-textarea"123123123123                v-model="age"123123123123                @focus="expandTextarea"123123123123                @blur="collapseTextarea"123123123123                @input="autoResizeTextarea"123123123123              ></textarea>123123123123            </div>123123123123          </td>123123123123        </tr>123123123123      </tbody>123123123123    </table>123123123123  </div>123123123123</template>123123123123123123123123<script>123123123123export default {123123123123  data() {123123123123    return {123123123123      name: '张三',123123123123      gender: '男',123123123123      age: '25',123123123123    };123123123123  },123123123123  methods: {123123123123    autoResizeTextarea(event) {123123123123      const textarea = event.target;123123123123      textarea.style.height = 'auto';123123123123      textarea.style.height = textarea.scrollHeight + 'px';123123123123    },123123123123    expandTextarea(event) {123123123123      const textarea = event.target;123123123123      textarea.classList.add('textarea-expanded');123123123123      textarea.style.overflow = 'visible'; // Expand textarea to show all content123123123123      this.autoResizeTextarea(event);123123123123    },123123123123    collapseTextarea(event) {123123123123      const textarea = event.target;123123123123      textarea.classList.remove('textarea-expanded');123123123123      textarea.style.height = '30px'; // Reset height to cell height123123123123      textarea.style.overflow = 'hidden'; // Hide overflow content when collapsed123123123123    },123123123123  },123123123123  mounted() {123123123123    const textareas = document.querySelectorAll('.auto-resize-textarea');123123123123    textareas.forEach((textarea) => {123123123123      this.autoResizeTextarea({ target: textarea });123123123123    });123123123123  },123123123123};123123123123</script>123123123123123123123123<style>123123123123.container {123123123123  width: 600px;123123123123  height: 200px;123123123123  border: 1px solid black; /* 可选:为容器添加边框 */123123123123}123123123123table {123123123123  border-collapse: collapse;123123123123  width: 100%;123123123123}123123123123th.report-table-message-title {123123123123  width: 10%;123123123123  height: 30px;123123123123  background-color: grey; /* 表头背景为灰色 */123123123123  border: 1px solid black;123123123123  padding: 0;123123123123  position: relative; /* Required for absolute positioning of textarea */123123123123}123123123123td {123123123123  width: 90%;123123123123  height: 30px;123123123123  border: 1px solid black;123123123123  padding: 0;123123123123  position: relative; /* Required for absolute positioning of textarea */123123123123}123123123123.report-table-message-info {123123123123  width: 100%;123123123123  height: 100%;123123123123  position: absolute;123123123123  top: 0;123123123123  left: 0;123123123123  box-sizing: border-box;123123123123}123123123123.auto-resize-textarea {123123123123  width: 100%; /* Adjust to fit within the 90% cell, considering border and padding */123123123123  height: 30px; /* Initial height to match the cell height */123123123123  border: none;123123123123  box-sizing: border-box;123123123123  resize: none; /* Prevent resizing */123123123123  overflow: hidden; /* Hide overflow by default */123123123123  position: absolute; /* Ensure textarea is positioned absolutely */123123123123  top: 0;123123123123  left: 0;123123123123  z-index: 1; /* Default z-index */123123123123  background: white; /* Optional: to ensure textarea background covers the cell content */123123123123  min-height: 30px; /* Ensure minimum height matches cell height */123123123123}123123123123.textarea-expanded {123123123123  z-index: 1000;123123123123  overflow: visible; /* Show overflow content when expanded */123123123123  min-height: 30px; /* Ensure minimum height matches cell height */123123123123}123123123123</style>123123123123

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
{% extends "admin/base.html" %} {% block content %} <div class="container-fluid"> <div class="row"> <div class="col-md-6"> <h2>药品列表</h2> <table class="table"> <thead> <tr> <th>ID</th> <th>药品名称</th> <th>操作</th> </tr> </thead> <tbody> {% for drug in drugs %} <tr> <td>{{ drug.id }}</td> <td>{{ drug.drug_name }}</td> <td> <a href="{% url 'admin:drug_db_drug_list_change' drug.id %}" class="btn btn-primary btn-sm">编辑</a> <form action="{% url 'admin:drug_db_drug_list_delete' drug.id %}" method="post" class="d-inline"> {% csrf_token %} <button class="btn btn-danger btn-sm">删除</button> </form> </td> </tr> {% empty %} <tr> <td colspan="3">暂无药品</td> </tr> {% endfor %} </tbody> </table> <a href="{% url 'admin:drug_db_drug_list_add' %}" class="btn btn-success">添加新药品</a> </div> <div class="col-md-6"> <h2>药品相互作用</h2> <table class="table"> <thead> <tr> <th>ID</th> <th>药品1</th> <th>药品2</th> <th>相互作用</th> <th>操作</th> </tr> </thead> <tbody> {% for interaction in interactions %} <tr> <td>{{ interaction.id }}</td> <td>{{ interaction.drug1 }}</td> <td>{{ interaction.drug2 }}</td> <td>{{ interaction.interaction }}</td> <td> <a href="{% url 'admin:drug_db_drug_interaction_change' interaction.id %}" class="btn btn-primary btn-sm">编辑</a> <form action="{% url 'admin:drug_db_drug_interaction_delete' interaction.id %}" method="post" class="d-inline"> {% csrf_token %} <button class="btn btn-danger btn-sm">删除</button> </form> </td> </tr> {% empty %} <tr> <td colspan="5">暂无药品相互作用</td> </tr> {% endfor %} </tbody> </table> <a href="{% url 'admin:drug_db_drug_interaction_add' %}" class="btn btn-success">添加新药品相互作用</a> </div> </div> </div> {% endblock %} 为上述代码设置相应的视图和URL配置,并将这些视图和操作注册到Django admin页面中。
05-18

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值