<template>
<div class="app-container">
<!--表格渲染-->
<el-table v-loading="loading" :data="orders"style="width: 100%;margin-top: -10px;">
<el-table-column prop="orderNo" label="采购单号" />
<el-table-column :show-overflow-tooltip="true" prop="orderDate" label="下单日期">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.orderDate,'{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column :show-overflow-tooltip="true" prop="materialCode" label="物料编码" />
<el-table-column :show-overflow-tooltip="true" prop="materialName" label="物料名称" />
<el-table-column :show-overflow-tooltip="true" prop="materialModel" label="型号" />
<el-table-column :show-overflow-tooltip="true" prop="materialStd" label="规格" />
<el-table-column :show-overflow-tooltip="true" prop="qty" label="数量" />
<el-table-column :show-overflow-tooltip="true" width="50px" prop="currency" label="币别" />
<el-table-column :show-overflow-tooltip="true" width="100px" prop="price" label="单价" />
<el-table-column :show-overflow-tooltip="true" width="100px" prop="amount" label="金额" />
</el-table>
<!--分页组件-->
<el-pagination
:total="total"
:current-page="page + 1"
:page-size="size"style="margin-top:8px;"
layout="total, prev, pager, next"
@size-change="sizeChange"
@current-change="pageChange"
/>
</div>
</template>
<script>// 前端访问后端接口
import { init } from '@/api/data'
import { parseTime } from '@/utils/index'
export default {
props: {
username: {
type: String,
default: ''
},
editable: {
type: Boolean,
default: true
}
},
data() {
return {
loading: false,
title: '采购订单',
orders: [],
// 页码
page: 0,
// 每页数据条数
size: 10,
// 总数据条数
total: 0,
// 等待时间
time: 50
]
}
},
created() {
this.doInit()
},
methods: {
parseTime,
doInit(){
this.loading = true
init('api/srm/supplierOrder/username/' + this.username, { page: this.page, size: this.size, sort: 'id,desc', username: username }).then(data => {
this.total = data.totalElements
this.orders = data.content
// time 毫秒后显示表格
setTimeout(() => {
this.loading = false
}, this.time)
}).catch(err =>{
this.loading = false
})
}
// 改变页码
pageChange(e) {
this.page = e - 1
this.doInit()
},
// 改变每页显示数
sizeChange(e) {
this.page = 0
this.size = e
this.doInit()
}
}
}</script>