使用elementui创建一个可展开子项的表格

使用elementui创建一个可展开子项的表格

Ezra
2023-11-13 / 7 评论 / 305 阅读 / 正在检测是否收录...

首先引入样式

<script src="public/lib/vue/vue.js"></script>
<!-- 引入样式 -->
<link rel="stylesheet" href="public/lib/element-ui/lib/theme-chalk/index.css">
<!-- 引入组件库 -->
<script src="public/lib/element-ui/lib/index.js"></script>
<div>
                        <el-table :data="tableData" style="width: 100%" row-key="id" border lazy 
                            :stripe=true  @expand-change="expandChange" v-loading="loading" size='small'>
                            <el-table-column type="expand" label="" width="">
                                <template slot-scope="props">
                                    <el-table :data="props.row.child" style="width: 100%" row-key="id" border  size='small'>
                                        <el-table-column prop="Itemname" label="项目名称">
                                        </el-table-column>
                                        <el-table-column prop="Itemresult" label="结果">
                                        </el-table-column>
                                        <el-table-column prop="Itemunit" label="项目单位">
                                        </el-table-column>
                                        <el-table-column prop="Refrange" label="参考范围">
                                        </el-table-column>
                                    </el-table>
                                </template>
                            </el-table-column>
                            <el-table-column prop="patient_name" label="姓名">
                            </el-table-column>
                            <el-table-column prop="GenderName" label="性别">
                            </el-table-column>
                            <el-table-column prop="Age1" label="年龄">
                            </el-table-column>
                            <el-table-column prop="ReportTime" label="报告时间" show-overflow-tooltip>
                            </el-table-column>
                            <el-table-column prop="doctor_inspect_code" label="条码号">
                            </el-table-column>
                            <el-table-column prop="Barcode" label="千麦条码号">
                            </el-table-column>
                            <el-table-column prop="mobile_phone" label="病人电话">
                            </el-table-column>
                            <!-- <el-table-column prop="paper_type" label="报告规格">
                            </el-table-column> -->
                            <el-table-column prop="inspect_name" label="检测项目">
                            </el-table-column>
                            <el-table-column prop="TestDate" label="检测时间" show-overflow-tooltip>
                            </el-table-column>
                            <el-table-column
                                fixed="right"
                                label="操作"
                                width="100">
                                <template slot-scope="scope">
                                    <el-button @click="viewPDF(scope.row.PDF)" type="text" size="small">检验报告</el-button>
                                    <!-- <el-button type="text" size="small">编辑</el-button> -->
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>
                    <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page.sync="currentPage1"
                    :page-size="20"
                    layout="total, prev, pager, next"
                    :total=total>
                    </el-pagination>
                </div>
<script>
    new Vue({
        el: '#app', //el用于指定当前Vue实例为哪个容器服务,值通常为选择器字符串。
        data: { //data中用于存储数据,数据供el所指定的容器去使用。
            loading: false,
            total:100,
            tableData: [],
            idCardCode:''
        },
        mounted() {
            this.getinfoajaxQM();
        },
        methods: {
            getinfoajaxQM(page) {
                var that = this;
                that.loading=true
                $.ajax({
                    type: 'POST',
                    url: 'index.php?f=report/c_patient_report&c=CPatientReport&m=getinfoajaxQM',
                    data: {
                        pageSeq:page,
                        idCardCode:that.idCardCode
                    },
                    dataType: 'json',
                    success: function (obj) {
                        that.loading=false
                        that.tableData = obj.data
                        that.total = obj.total
                    },
                    error: function (xhr, xhrStatus) {

                    },
                });
            },
            expandChange(row){
                console.log(row)
            },
            viewPDF(Url){
                if(Url) { window.open(Url,'_blank'); }
            },
            handleCurrentChange(val){
                this.getinfoajaxQM(val)
            },
            bySearch(){
                this.getinfoajaxQM(1)
            }
        }
    })
</script>
0

评论 (7)

取消
  1. 头像
    Tani98
    Windows 10 · Google Chrome

    该更新了

    回复
    1. 头像
      Ezra 作者
      Windows 10 · Google Chrome
      @ Tani98

      来了表情

      回复
  2. 头像
    wufquenegz
    Windows 10 · Google Chrome

    博主真是太厉害了!!!

    回复
  3. 头像
    ubhijldcdd
    Windows 10 · Google Chrome

    叼茂SEO.bfbikes.com

    回复
  4. 头像
    yvicvxllmz
    Windows 10 · Google Chrome

    想想你的文章写的特别好

    回复
  5. 头像
    ihqjubuzsz
    Windows 10 · Google Chrome

    不错不错,我喜欢看 https://www.jiwenlaw.com/

    回复
  6. 头像
    hxxwbumytw
    Windows 10 · Google Chrome

    叼茂SEO.bfbikes.com

    回复