Files
laws-sinotruk-client/src/views/workCenter/permissionApplicationProcess/modules/BaseInfoTable.vue
T
2024-02-07 09:28:23 +08:00

154 lines
4.3 KiB
Vue

<template>
<div>
<div class="table-operator" v-if="!disabled">
<!-- 新增 -->
<a-button icon="plus" type="primary" @click="handleAdd">{{ $t('newlyAdded') }}</a-button>
</div>
<div>
<j-table
bordered
v-if="columns && columns.length > 0"
:columns="columns"
:dataSource="dataSource"
:can-drag="true"
rowKey="id"
:row-selection="null"
:pagination="false"
:scroll="{x: '100%'}"
@change="handleTableChange">
<!-- 企标号企标名称 -->
<template v-slot:standard="{text, record}">
<a-tooltip overlay-class-name="tooltip-style">
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
<a v-if="text" class="link-a" @click="detailClick(record)">{{ text }}</a>
<div v-else class="table-text">{{ global.emptyLine }}</div>
</a-tooltip>
</template>
<!-- 操作 -->
<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 },
props: {
disabled: {
type: Boolean,
default: false
}
},
data () {
const column = [
{
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: 'standardNumber',
scopedSlots: { customRender: 'standard' }
},
{ // 企标名称
title: this.$t('workCenter.esInspectionPlan.inspectionBasisStandardName'),
align: 'center',
width: 180,
dataIndex: 'standardName',
scopedSlots: { customRender: 'standard' }
},
{
// 操作
title: this.$t('operation'),
dataIndex: 'action',
align: 'center',
width: 100,
scopedSlots: { customRender: 'action' }
}
]
return {
StandardSource,
model: {},
dataSource: [],
// 根据是否禁用显示操作列
columns: column.slice(0, this.disabled ? 3 : 4)
}
},
computed: {
// 已选的标准编号
excludeStandardNumbers () {
return this.dataSource.map(item => item.standardNumber).join(',')
}
},
methods: {
// 回显表格数据
setData (data) {
this.dataSource = data
},
// 新增
handleAdd () {
// 清空以已选数据
this.$refs.standardSelection.$refs.standardSelectionModal.selectedRowKeys = []
this.$refs.standardSelection.$refs.standardSelectionModal.selectedRowList = []
this.$refs.standardSelection.standardClick()
},
// 删除
handleDelete (index) {
this.$confirm({
title: this.$t('confirmDeletion'),
content: this.$t('areYouSure'),
onOk: () => {
this.dataSource.splice(index, 1)
this.$message.success(this.$t('operationSuccessful'))
}
})
},
// 添加标准回调
changeStandardSelect (val) {
this.$message.success(this.$t('operationSuccessful'))
this.dataSource = [...this.dataSource, ...val]
},
// 跳转详情
detailClick (record) {
this.$openPageNewSheet({
path: '/enterpriseStandardLibrary/enterpriseStandardDetail',
query: {
standardNumber: record.standardNumber
}
})
},
handleTableChange (pagination, filters, sorter) {
this.ipagination = pagination
},
// 获取所有标准号
getStandardNumbers () {
return this.dataSource.map(item => item.standardNumber).join(',')
}
}
}
</script>
<style scoped>
</style>