Files
laws-sinotruk-client/src/views/workCenter/permissionApplicationProcess/modules/BaseInfoTable.vue
T
2023-12-01 15:28:36 +08:00

134 lines
3.5 KiB
Vue

<template>
<div>
<div class="table-operator">
<!-- 新增 -->
<a-button icon="plus" type="primary" @click="handleAdd">{{ $t('newlyAdded') }}</a-button>
</div>
<div>
<j-table
v-if="columns && columns.length > 0"
:columns="columns"
:dataSource="dataSource"
:can-drag="true"
rowKey="id"
:row-selection="null"
:pagination="false"
:scroll="{x: '100%'}"
@change="tableOnChange">
<!-- 操作 -->
<template slot="action" slot-scope="{text, record, index}">
<a @click="handleDelete(index)" >{{ $t('delete') }}</a>
</template>
</j-table>
</div>
<standard-selection v-show="false" :source="StandardSource.ENTERPRISE.value" disabledSourceSearch ref="standardSelection" :excludeStandardNumbers="excludeStandardNumbers" @listChange="changeStandardSelect"/>
</div>
</template>
<script>
import JTable from '@comp/jero/JTable'
import StandardSelection from '@comp/selection/StandardSelection'
import { StandardSource } from '@/enums/commonEnums'
export default {
name: 'BaseInfoTable',
components: { StandardSelection, JTable },
data () {
return {
StandardSource,
model: {},
dataSource: [],
columns: [
{
title: this.$t('serialNumber'),
dataIndex: '',
key: 'rowIndex',
align: 'center',
width: 80,
customRender: function (t, r, index) {
return parseInt(index) + 1
}
},
{ // 企标编号
title: this.$t('workCenter.esInspectionPlan.inspectionBasisStandardNumber'),
align: 'center',
width: 180,
dataIndex: 'standardName',
scopedSlots: { customRender: 'text' }
},
{ // 企标名称
title: this.$t('workCenter.esInspectionPlan.inspectionBasisStandardName'),
align: 'center',
width: 180,
dataIndex: 'standardNumber',
scopedSlots: { customRender: 'text' }
},
{
// 操作
title: this.$t('operation'),
dataIndex: 'action',
align: 'center',
width: 100,
scopedSlots: { customRender: 'action' }
}
]
}
},
computed: {
// 已选的标准编号
excludeStandardNumbers () {
return this.dataSource.map(item => item.standardNumber).join(',')
}
},
methods: {
// 回显表格数据
setData (data) {
this.dataSource = data
},
// 新增
handleAdd () {
this.$refs.standardSelection.standardClick()
},
// 删除
handleDelete (index) {
this.$confirm({
title: this.$t('confirmDeletion'),
content: this.$t('areYouSure'),
onOk: () => {
this.dataSource.splice(index, 1)
}
})
},
// 添加标准回调
changeStandardSelect (val) {
this.dataSource = [...this.dataSource, ...val]
},
// 跳转详情
detailClick (record) {
this.$openPageNewSheet({
path: '/enterpriseStandardLibrary/enterpriseStandardDetail',
query: {
id: record.id
}
})
},
tableOnChange (pagination, filters, sorter) {
this.orderBy = sorter.order === 'ascend' ? '1' : '2'
this.orderByField = sorter.columnKey
this.ipagination = pagination
this.getTableList()
},
// 获取所有标准号
getStandardNumbers () {
return this.dataSource.map(item => item.standardNumber).join(',')
}
}
}
</script>
<style scoped>
</style>