vue点击文字打开扩展列

发布时间 2023-10-18 16:27:44作者: 文采呱呱
<template>
    <custom-card shadow="hover" bordered>
      <div class="system-search">
        <div class="search-box">
          <el-input
            class="box-input"
            placeholder="请输入门店/编码"
            v-model="StoreCode"
          >
            <i
              slot="suffix"
              class="el-input__icon el-icon-search"
              @click="searchfor(field)"
            ></i>
          </el-input>
        </div>
      </div>
      <el-table :data="StoreData" style="width: 100%; cursor: pointer" ref="table" border>
        <el-table-column type="selection" width="55" fixed="left">
        </el-table-column>
        <el-table-column prop="id" label="序号" width="50" fixed="left">
        </el-table-column>
        <el-table-column prop="StoreName" label="门店名称" width="280">
        </el-table-column>
        <el-table-column prop="StoreCode" label="门店编码" width="180">
        </el-table-column>
        <el-table-column prop="Enable" label="是否启用" width="180">
        </el-table-column>
        <el-table-column prop="CreationTime" label="创建时间"> </el-table-column>
        <el-table-column label="操作" width="100">
          <template slot-scope="scope">
            <el-button type="text" @click="toogleExpand(scope.row)"
              >查看详情</el-button
            >
          </template>
        </el-table-column>
        <el-table-column type="expand" width="1">
          <template slot-scope="props">
            <el-form label-position="left" inline class="demo-table-expand">
              <el-form-item label="商品名称">
                <span>{{ props.row.name }}</span>
              </el-form-item>
            </el-form>
          </template>
        </el-table-column>
      </el-table>
    </custom-card>
  </template>
  
  <script>
  import CustomCard from "../../components/CustomCard.vue";
  export default {
    name: "control",
    components: {
      CustomCard,
    },
    data() {
      return {
        StoreCode: "", //编码搜索
        StoreData: [
          {
            id: 1,
            StoreName: "111",
            StoreCode: "王小虎",
            address: "上海市普陀区金沙江路 1518 弄",
            Enable: "是",
            CreationTime: "2020-10-17 14:34:25",
          },
          {
            id: 2,
            StoreName: "111",
            StoreCode: "王小虎",
            address: "上海市普陀区金沙江路 1518 弄",
            Enable: "是",
            CreationTime: "2020-10-17 14:34:25",
          },
        ],
      };
    },
    methods: {
      toogleExpand(row) {
        let $table = this.$refs.table;
        this.StoreData.map((item) => {
          if (row.id != item.id) {
            $table.toggleRowExpansion(item, false);
          }
        });
        $table.toggleRowExpansion(row);
      },
    },
  };
  </script>
  
  <style lang="less" scoped>
  .system-search {
    width: 98%;
    height: 30px;
    margin: auto;
    margin-bottom: 100px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    &::after {
      content: "";
      flex: 1;
    }
    .search-box {
      width: 275px;
      height: 30px;
      font-size: 14px;
      font-weight: normal;
      line-height: 22px;
      text-align: right;
      letter-spacing: 0em;
      font-family: "darkcolor";
      display: flex;
      margin-top: 24px;
      margin-right: 45px;
      .box-input {
        /deep/ .el-input__inner {
          width: 200px;
          height: 30px;
          border-radius: 3px;
        }
        /deep/ .el-input__inner:focus {
          border-color: #c0c4cc;
        }
        /deep/ .el-input__icon {
          line-height: 30px;
          cursor: pointer;
        }
      }
    }
  }
  </style>