Commit 871db7b4 by cwq0219

表格组件

1 parent c9f35e13
......@@ -13,7 +13,7 @@
width="60px"
label="序号"
type='index'
:index="index=>index+(currentPage - 1) * pageSize + 1"
:index="index=>index+(page.pageSize - 1) * page.pageCount + 1"
></el-table-column>
<el-table-column
v-for="(item, index) in tableColumns"
......@@ -46,8 +46,7 @@
fixed="right"
>
<template slot-scope="scope">
<auth-button v-if="!mapping" :data="scope.row"></auth-button>
<auth-button v-else :mapping="mapping" :data="scope.row"></auth-button>
<slot name="auth-button" :scope="scope.row"></slot>
</template>
</el-table-column>
</el-table>
......@@ -56,9 +55,9 @@
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:current-page="page.pageSize"
:page-sizes="[10,20,30,40]"
:page-size="pageSize"
:page-size="page.pageCount"
:total="total"
layout="sizes,total,->,prev,pager,next,jumper"
>
......@@ -75,55 +74,73 @@ export default {
searchParams: {},
tableData: [],
// 页码
currentPage: 1,
pageSize: 10,
page: {
pageCount: 10,
pageSize: 1
},
// currentPage: 1,
// pageSize: 10,
total: 10
}
},
props: {
// 后端返回列表参数名
listName: {
type: String,
default: ''
},
// 标签
tag: {
type: Array,
default: () => []
},
mapping: {
type: Array,
default: null
// 搜索条件
searchForm: {
type: Object,
default: () => []
},
// 表格栏
tableColumns: {
type: Array,
default: () => []
},
// 表格操作,默认没有
tableOption: {
type: Object,
default: null
},
// 分页,默认有
pagination: {
type: Boolean,
default: true
},
// 获取列表接口
getListApi: {
type: Function,
default: null
}
},
watch: {
searchForm(val) {
this.searchParams = val
}
},
mounted() {
this.$emit('handlePage')
this.searchParams = this.searchForm
this.getList()
},
methods: {
/**
* @param params Object 搜索参数
* @param listName String 后端返回列表参数名
* @param getListApi function 获取列表接口
*/
getList(params, listName, getListApi) {
this.searchParams = params
params = {
pageCount: this.pageSize,
pageSize: this.currentPage,
...params
getList() {
const params = {
...this.page,
...this.searchParams
}
// console.log(params)
getListApi(params).then(res => {
this.tableData = res[listName]
this.getListApi(params).then(res => {
this.tableData = res[this.listName]
res.pagination && (this.total = res.pagination.totalCount)
}).catch(() => {
notice.errorTips()
......@@ -132,33 +149,13 @@ export default {
// 页码
handleSizeChange(value) {
this.pageSize = value
this.$emit('handlePage')
this.page.pageCount = value
this.getList()
},
handleCurrentChange(value) {
this.currentPage = value
this.$emit('handlePage')
},
handleEdit(row) {
this.$emit('handleEdit', row)
},
handleDetail(row) {
this.$emit('handleDetail', row)
},
handleDelete(row) {
this.$emit('handleDelete', row)
},
handleVerify(row) {
this.$emit('handleVerify', row)
},
handleOperation(row, e) {
this.$emit('handleOperation', { row, e })
this.page.pageSize = value
this.getList()
}
}
}
......
......@@ -56,12 +56,18 @@
</d2-table-header>
<d2-table
ref="table"
:searchForm="searchForm"
:tableColumns="tableColumns"
tableOption=true
@handlePage="getList"
@handleEdit="handleEdit"
@handleDelete="handleDelete"
></d2-table>
listName='deviceList'
:getListApi="getListApi"
>
<auth-button
slot="auth-button"
slot-scope="scope"
:data="scope.scope"
></auth-button>
</d2-table>
<edit-dialog
:isVisible="editVisible"
:editForm="editForm"
......@@ -164,7 +170,8 @@ export default {
baseData: {
station: []
},
fileInfo: { fileType: '', fileBase: '' }
fileInfo: { fileType: '', fileBase: '' },
getListApi: getListApi
}
},
......@@ -182,15 +189,9 @@ export default {
},
/* 接口请求-start */
getParams() {
return {
...this.searchForm
}
},
getList() {
const params = this.getParams()
this.$refs.table.getList(params, 'deviceList', getListApi)
this.$refs.table.getList()
},
delObjMutiAttr(obj, keys) {
......@@ -282,8 +283,7 @@ export default {
},
exportFile() {
const params = this.getParams()
exportApi(params)
exportApi(this.searchForm)
.then(res => {
this.$open(res.url)
notice.okTips()
......
......@@ -35,7 +35,7 @@
</el-select>
<el-date-picker
v-else-if="item.type == 'datePick'"
v-model="searchForm[item.model]"
v-model="creatTime"
value-format="yyyy-MM-dd"
type="daterange"
start-placeholder="开始日期"
......@@ -49,13 +49,19 @@
<d2-table-header title="作业单列表"><auth-button category="Button"></auth-button></d2-table-header>
<d2-table
ref="table"
:searchForm="searchForm"
:tableColumns="tableColumns"
:tableOption="tableOption"
:tag="tag"
@handlePage="getList"
@handleDetail="handleDetail"
@handleDelete="handleDelete"
></d2-table>
listName='maintainList'
:getListApi="getListApi"
>
<auth-button
slot="auth-button"
slot-scope="scope"
:data="scope.scope"
></auth-button>
</d2-table>
</d2-container>
</template>
......@@ -69,13 +75,15 @@ export default {
name: 'fimsMaintainManagement',
data() {
return {
creatTime: '',
// 搜索
searchForm: {
taskCode: '',
taskType: '',
downDeviceNum: '',
userName: '',
createTime: '',
startTime: '',
endTime: '',
trafficCode: '',
stationCode: '',
subsystemCode: '',
......@@ -143,7 +151,8 @@ export default {
}, {
label: '创建时间',
type: 'datePick',
model: 'createTime'
// singleVal: 'creatTime',
model: 'creatTime'
}],
// 表格
tableOption: {
......@@ -235,18 +244,19 @@ export default {
}, {
label: '处理人',
prop: 'userName'
}]
}],
getListApi: getListApi
}
},
watch: {
'searchForm.createTime'(value) {
'creatTime'(value) {
!value && this.getList()
}
},
mounted() {
this.getList()
// this.getList()
this.loadBaseData()
},
......@@ -263,21 +273,15 @@ export default {
/* 接口请求-start */
getParams() {
return {
...this.searchForm,
...util.formatTime(this.searchForm.createTime)
}
return Object.assign(this.searchForm, util.formatTime(this.creatTime))
},
getList() {
const params = this.getParams()
delete params.createTime
// console.log(params)
this.$refs.table.getList(params, 'maintainList', getListApi)
this.getParams()
this.$refs.table.getList()
},
exportOrder() {
const params = this.getParams()
delete params.createTime
exportApi(params).then(res => {
this.$open(res.url)
notice.okTips()
......
......@@ -31,7 +31,7 @@
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker
v-model="searchForm.createTime"
v-model="createTime"
type="daterange"
value-format="yyyy-MM-dd"
start-placeholder="开始日期"
......@@ -45,13 +45,19 @@
<d2-table-header title="订单列表"><auth-button category="Button"></auth-button></d2-table-header>
<d2-table
ref="table"
:searchForm="searchForm"
:tableColumns="tableColumns"
tableOption=true
:tag="tag"
@handlePage="getList"
@handleDetail="handleDetail"
@handleDelete="handleDelete"
></d2-table>
listName='orderList'
:getListApi="getListApi"
>
<auth-button
slot="auth-button"
slot-scope="scope"
:data="scope.scope"
></auth-button>
</d2-table>
<detail-dialog
:isVisible="detailVisible"
:title="dialogTitle"
......@@ -77,12 +83,14 @@ export default {
dialogTitle: '',
pdfUrl: '',
// 搜索
createTime: '',
searchForm: {
orderCode: '',
orderType: '',
status: '',
userName: '',
createTime: ''
startTime: '',
endTime: ''
},
statusArr: [{
value: 1,
......@@ -135,12 +143,13 @@ export default {
prop: 'status',
tagLabel: true,
width: '140'
}]
}],
getListApi: getListApi
}
},
watch: {
'searchForm.createTime'(value) {
'createTime'(value) {
!value && this.getList()
}
},
......@@ -148,28 +157,26 @@ export default {
mounted() {},
methods: {
// test() {
// console.log('test---')
// },
// changePage() {
// this.getList()
// },
/* 接口请求-start */
getParams() {
return {
...this.searchForm,
...util.formatTime(this.searchForm.createTime)
}
return Object.assign(this.searchForm, util.formatTime(this.createTime))
},
getList() {
const params = this.getParams()
!params.orderCode && delete params.orderCode
delete params.createTime
this.$refs.table.getList(params, 'orderList', getListApi)
this.getParams()
this.$refs.table.getList()
},
exportFile() {
const params = this.getParams()
!params.orderCode && delete params.orderCode
delete params.createTime
exportApi(params).then(res => {
this.$open(res.url)
notice.okTips()
......
......@@ -11,14 +11,16 @@
<el-input v-model="searchForm.keyWord" placeholder="请输入物料代码/编码/名称" @clear="getList" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
<el-button type="primary" icon="el-icon-search" @click="getList">查询</el-button>
</el-form-item>
</el-form>
<d2-table-header title="物料列表"></d2-table-header>
<d2-table
ref="table"
:searchForm="searchForm"
:tableColumns="tableColumns"
@handlePage="getList"
listName='deviceList'
:getListApi="getListApi"
></d2-table>
</d2-container>
</template>
......@@ -33,6 +35,7 @@ export default {
searchForm: {
keyWord: ''
},
getListApi: getListApi,
// 表格
tableData: [],
tableColumns: [{
......@@ -70,20 +73,8 @@ export default {
mounted() {},
methods: {
/* 接口请求-start */
getParams() {
return {
...this.searchForm
}
},
getList() {
const params = this.getParams()
this.$refs.table.getList(params, 'deviceList', getListApi)
},
/* 接口请求-end */
// 搜索
handleSearch() {
this.getList()
this.$refs.table.getList()
}
}
}
......
......@@ -9,7 +9,7 @@
>
<el-form-item label="上报时间">
<el-date-picker
v-model="searchForm.reportTime"
v-model="reportTime"
type="daterange"
value-format="yyyy-MM-dd"
range-separator="至"
......@@ -39,8 +39,10 @@
<d2-table-header title="上报日志列表"></d2-table-header>
<d2-table
ref="table"
:searchForm="searchForm"
:tableColumns="tableColumns"
@handlePage="getList"
listName='loges'
:getListApi="getListApi"
></d2-table>
</d2-container>
</template>
......@@ -54,8 +56,11 @@ export default {
name: 'FimsReportingLogs',
data() {
return {
getListApi: getLogsApi,
reportTime: '',
searchForm: {
reportTime: '',
startTime: '',
endTime: '',
trafficCode: '',
stationCode: '',
subSystemCode: ''
......@@ -97,7 +102,7 @@ export default {
},
watch: {
'searchForm.reportTime'(value) {
'reportTime'(value) {
!value && this.getList()
}
},
......@@ -112,23 +117,14 @@ export default {
this.baseData.station = data
},
getParams() {
return {
...this.searchForm,
...util.formatTime(this.searchForm.reportTime)
}
},
getList() {
const params = this.getParams()
delete params.reportTime
this.$refs.table.getList(params, 'loges', getLogsApi)
Object.assign(this.searchForm, util.formatTime(this.reportTime))
this.$refs.table.getList()
},
handleExport() {
const params = this.getParams()
delete params.reportTime
exportApi(params).then(res => {
Object.assign(this.searchForm, util.formatTime(this.reportTime))
exportApi(this.searchForm).then(res => {
// console.log(res)
// window.location.href = res.url
this.$open(res.url)
......
......@@ -48,12 +48,18 @@
<d2-table-header title="子系统列表"><auth-button category="Button" :data="editFormReset"></auth-button></d2-table-header>
<d2-table
ref="table"
:searchForm="searchForm"
:tableColumns="tableColumns"
tableOption=true
@handlePage="getList"
@handleEdit="handleEdit"
@handleDelete="handleDelete"
></d2-table>
listName='subsystemList'
:getListApi="getListApi"
>
<auth-button
slot="auth-button"
slot-scope="scope"
:data="scope.scope"
></auth-button>
</d2-table>
<edit-dialog
:isVisible="editVisible"
:editForm="editForm"
......@@ -150,7 +156,8 @@ export default {
// 页码
baseData: {
subsys: []
}
},
getListApi: getListApi
}
},
......@@ -175,13 +182,6 @@ export default {
// this.getList()
// },
/* 接口请求-start */
getParams() {
return {
...this.searchForm
}
},
// getRemote (item) {
// let params = {}
// params[item.attr] = item.value
......@@ -192,8 +192,7 @@ export default {
// },
getList() {
const params = this.getParams()
this.$refs.table.getList(params, 'subsystemList', getListApi)
this.$refs.table.getList()
},
editSubSystem(value) {
......
......@@ -48,15 +48,17 @@
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
<el-button type="primary" icon="el-icon-search" @click="getList">查询</el-button>
</el-form-item>
</el-form>
<d2-table-header title="子系统状态列表"><auth-button category="Button"></auth-button></d2-table-header>
<d2-table
ref="table"
:searchForm="searchForm"
:tableColumns="tableColumns"
:tag="tag"
@handlePage="getList"
listName='subsystemList'
:getListApi="getListApi"
></d2-table>
</div>
</d2-container>
......@@ -178,7 +180,8 @@ export default {
baseData: {
station: [],
subsys: []
}
},
getListApi: getListApi
}
},
......@@ -200,19 +203,8 @@ export default {
this.baseData.subsys.unshift({ confCode: '', confValue: '全部' })
},
// loadingGetList() {
// this.getList()
// },
/* 接口请求-start */
getParams() {
return {
...this.searchForm
}
},
getList() {
const params = this.getParams()
this.$refs.table.getList(params, 'subsystemList', getListApi)
this.$refs.table.getList()
},
getPie(label = '') {
const params = {
......@@ -225,7 +217,10 @@ export default {
})
},
exportFile() {
const params = this.getParams()
const params = {
...this.$refs.table.page,
...this.searchForm
}
exportApi(params).then(res => {
this.$open(res.url)
notice.okTips()
......@@ -248,12 +243,6 @@ export default {
item.data[1].value = params.normalNum ? params.normalNum : 0
this.totalECharts.setOption(this.totalOptions)
},
// 搜索
handleSearch() {
// 调接口
this.getList()
}
}
}
......
......@@ -29,12 +29,18 @@
<d2-table-header title="车辆列表"><auth-button category="Button" :data="editFormReset"></auth-button></d2-table-header>
<d2-table
ref="table"
:searchForm="searchForm"
:tableColumns="tableColumns"
tableOption=true
@handlePage="getList"
@handleEdit="handleEdit"
@handleDelete="handleDelete"
></d2-table>
listName='trafficList'
:getListApi="getListApi"
>
<auth-button
slot="auth-button"
slot-scope="scope"
:data="scope.scope"
></auth-button>
</d2-table>
<edit-dialog
:isVisible="editVisible"
:editForm="editForm"
......@@ -111,7 +117,8 @@ export default {
}],
baseData: {
station: []
}
},
getListApi: getListApi
}
},
......@@ -125,17 +132,10 @@ export default {
this.baseData.station = data
},
/* 接口请求-start */
getParams() {
return {
...this.searchForm
}
},
getList() {
const params = this.getParams()
this.$refs.table.getList(params, 'trafficList', getListApi)
this.$refs.table.getList()
},
editTraffic(value) {
// console.log(value)
const params = _.cloneDeep(this.editFormReset)
......@@ -160,7 +160,6 @@ export default {
handleEditClose() {
this.editVisible = !this.editVisible
// delete this.editForm.id
},
handleEditConfirm() {
......@@ -170,7 +169,6 @@ export default {
// 表格-编辑
handleEdit(row) {
// console.log(row)
this.editForm = _.cloneDeep(row)
this.handleEditClose()
},
......
......@@ -18,7 +18,7 @@
</el-form-item>
<el-form-item label="登录时间">
<el-date-picker
v-model="searchForm.loginTime"
v-model="loginTime"
type="daterange"
value-format="yyyy-MM-dd"
range-separator="至"
......@@ -27,14 +27,16 @@
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
<el-button type="primary" icon="el-icon-search" @click="getList">查询</el-button>
</el-form-item>
</el-form>
<d2-table-header title="登录日志列表"></d2-table-header>
<d2-table
ref="table"
:searchForm="searchForm"
:tableColumns="tableColumns"
@handlePage="getList"
listName='loges'
:getListApi="getListApi"
></d2-table>
</d2-container>
</template>
......@@ -46,10 +48,11 @@ export default {
name: 'FimsLoginLogs',
data() {
return {
getListApi: getLoginlogs,
loginTime: '',
searchForm: {
// beginTime: '',
// endTime: '',
loginTime: '',
startTime: '',
endTime: '',
userName: '',
loginType: ''
},
......@@ -80,7 +83,7 @@ export default {
},
watch: {
'searchForm.loginTime'(value) {
'loginTime'(value) {
!value && this.getList()
}
},
......@@ -88,20 +91,9 @@ export default {
mounted() {},
methods: {
getParams() {
return Object.assign(
this.searchForm,
util.formatTime(this.searchForm.loginTime)
)
},
getList() {
const params = this.getParams()
delete params.loginTime
this.$refs.table.getList(params, 'loges', getLoginlogs)
},
// 搜索
handleSearch() {
this.getList()
Object.assign(this.searchForm, util.formatTime(this.loginTime))
this.$refs.table.getList()
}
}
}
......
......@@ -6,10 +6,15 @@
ref="table"
:tableColumns="tableColumns"
tableOption=true
:pagination="pagination"
@handlePage="getList"
@handleEdit="handleEdit"
></d2-table>
listName='roles'
:getListApi="getListApi"
>
<auth-button
slot="auth-button"
slot-scope="scope"
:data="scope.scope"
></auth-button>
</d2-table>
<edit-dialog
:isVisible="editVisible"
:editData="editData"
......@@ -29,6 +34,7 @@ export default {
},
data() {
return {
getListApi: RoleList,
// 新增/编辑弹窗
editVisible: false,
// 表格
......@@ -65,7 +71,7 @@ export default {
...mapActions('d2admin/base', ['set']),
getList() {
this.$refs.table.getList('', 'roles', RoleList)
this.$refs.table.getList()
},
async handleEdit(row) {
this.editData = row && await RoleDetail({ roleId: row.roleId })
......
......@@ -61,15 +61,20 @@
<d2-table-header title="用户列表"><auth-button category="action" label="创建用户"></auth-button></d2-table-header>
<d2-table
ref="table"
:searchForm="searchForm"
:tableColumns="tableColumns"
tableOption=true
:tag="tag"
:mapping="mapping"
@handlePage="getUserList"
@handleEdit="handleEdit"
@handleVerify="handleVerify"
@handleOperation="handleOperation"
></d2-table>
listName='userList'
:getListApi="getListApi"
>
<auth-button
slot="auth-button"
slot-scope="scope"
:data="scope.scope"
:mapping="mapping"
></auth-button>
</d2-table>
<dialog-reg :isVisible="registerDialogVisible" :editData="editData" :key="key"/>
</d2-container>
</template>
......@@ -95,6 +100,7 @@ export default {
},
data() {
return {
getListApi: UserList,
key: new Date(),
tag: Object.freeze({
effect: 'dark',
......@@ -219,15 +225,9 @@ export default {
Object.freeze(this.baseData)
},
/* 接口请求-start */
getParams() {
return {
...this.searchForm,
...util.formatTime(this.searchTimes)
}
},
getUserList() {
const params = this.getParams()
this.$refs.table.getList(params, 'userList', UserList)
Object.assign(this.searchForm, util.formatTime(this.searchTimes))
this.$refs.table.getList()
},
filterTag(value, row) {
return row.status === value
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!