Files
laws-sinotruk-client/src/views/workCenter/enterpriseStandardInitChange/modules/FinishTimeChangeBaseInfo.vue
T
2024-01-16 14:23:26 +08:00

275 lines
8.8 KiB
Vue

<template>
<div class="change-base-info-wrapper">
<!-- 操作区域 -->
<div v-if="!disabled" class="table-operator">
<!-- 新增 -->
<a-button icon="plus" type="primary" @click="handleAdd" :disabled="disabled">
{{ $t('newlyAdded') }}
</a-button>
<!-- 批量删除 -->
<a-button icon="delete" type="primary" ghost @click="batchDel" :disabled="disabled">
{{ $t('batchDelete') }}
</a-button>
</div>
<div>
<j-table
:can-drag="true"
:scroll="{x: '100%'}"
ref="table"
rowKey="uid"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
@change="handleTableChange">
<!-- 企标编号/企标名称 -->
<template v-slot:toDetail="{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="handleGoDetail(record)">{{ text }}</a>
<div v-else class="table-text">{{ global.emptyLine }}</div>
</a-tooltip>
</template>
<!-- 操作栏 -->
<div slot="action" slot-scope="{record}" class="action-span-cell">
<a @click="handleEdit(record)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a>
<a-divider type="vertical" />
<a @click="handleDelete(record.uid)" class="table-ope-btn" :disabled="disabled">{{ $t('delete') }}</a>
</div>
</j-table>
</div>
<finish-time-change-base-info-drawer v-bind="$attrs" ref="changeBaseInfoDrawer" @ok="changeBaseInfoDrawerOk"></finish-time-change-base-info-drawer>
</div>
</template>
<script>
import FinishTimeChangeBaseInfoDrawer from './FinishTimeChangeBaseInfoDrawer'
import JTable from '@/components/jero/JTable'
export default {
name: 'FinishTimeChangeBaseInfo',
components: { FinishTimeChangeBaseInfoDrawer, JTable },
props: {
disabled: {
type: Boolean,
required: false,
default: false
},
currentNode: {
type: Number,
required: false,
default: 1
}
},
data () {
return {
loading: false,
/* 分页参数 */
ipagination: {
current: 1,
pageSize: 10,
pageSizeOptions: ['10', '30', '50', '100', '150', '200'],
showTotal: (total, range) => {
return range[0] + '-' + range[1] + ' ' + this.$t('total') + total + this.$t('strip')
},
showQuickJumper: true,
showSizeChanger: true,
total: 0
},
columns: [
{
title: this.$t('serialNumber'),
dataIndex: '',
key: 'rowIndex',
width: 80,
align: 'center',
customRender: function (t, r, index) {
return parseInt(index) + 1
}
},
{ // 企标编号
title: this.$t('workCenter.enterpriseInitChangePlan.enterpriseStandardNum'),
align: 'center',
width: 180,
dataIndex: 'originEnStandardNo',
scopedSlots: { customRender: 'toDetail' }
},
{ // 企标名称
title: this.$t('workCenter.enterpriseInitChangePlan.enterpriseStandardName'),
align: 'center',
width: 180,
dataIndex: 'originEnStandardName',
scopedSlots: { customRender: 'toDetail' }
},
{ // 主起草人
title: this.$t('workCenter.enterpriseInitChangePlan.principalDrafter'),
align: 'center',
width: 180,
dataIndex: 'mainDraftingUser_dictText',
scopedSlots: { customRender: 'text' }
},
{ // 主起草单位
title: this.$t('workCenter.enterpriseInitChangePlan.mainDraftUnit'),
align: 'center',
width: 180,
dataIndex: 'mainDraftingUnit_dictText',
scopedSlots: { customRender: 'text' }
},
{ // 原草稿计划完成日期
title: this.$t('workCenter.enterpriseInitChangePlan.originalDraftPlanFinishDate'),
align: 'center',
width: 180,
dataIndex: 'originDraftPlannedCompleteDate',
scopedSlots: { customRender: 'text' }
},
{ // 原征求意见稿计划完成日期
title: this.$t('workCenter.enterpriseInitChangePlan.originalExposureDraftPlanFinishDate'),
align: 'center',
width: 210,
dataIndex: 'originSolicitationDraftPlanCompleteDate',
scopedSlots: { customRender: 'text' }
},
{ // 原计划报批日期
title: this.$t('workCenter.enterpriseInitChangePlan.originalPlanSubmissionDate'),
align: 'center',
width: 180,
dataIndex: 'originPlanApprovalDate',
scopedSlots: { customRender: 'text' }
},
{ // 草稿计划完成日期
title: this.$t('workCenter.enterpriseInitChangePlan.draftPlanFinishDate'),
align: 'center',
width: 180,
dataIndex: 'draftPlannedCompleteDate',
scopedSlots: { customRender: 'text' }
},
{ // 征求意见稿计划完成日期
title: this.$t('workCenter.enterpriseInitChangePlan.exposureDraftPlanFinishDate'),
align: 'center',
width: 200,
dataIndex: 'solicitationDraftPlanCompleteDate',
scopedSlots: { customRender: 'text' }
},
{ // 计划报批日期
title: this.$t('workCenter.enterpriseInitChangePlan.planSubmissionDate'),
align: 'center',
width: 180,
dataIndex: 'planApprovalDate',
scopedSlots: { customRender: 'text' }
},
{ // 变更原因
title: this.$t('workCenter.enterpriseInitChangePlan.changeReason'),
align: 'center',
width: 180,
dataIndex: 'changeReason',
scopedSlots: { customRender: 'text' }
},
{ // 操作
title: this.$t('operation'),
scopedSlots: { customRender: 'action' },
align: 'center',
fixed: 'right',
width: 200
}
],
dataSource: [],
selectedRowKeys: [],
selectionRows: [],
url: {
list: ''
},
modalType: '' // 是在新增还是在编辑,编辑的时候放正在编辑的下标
}
},
mounted () {
if (this.disabled) {
this.columns.pop()
}
},
methods: {
// 企标编号,企标名称跳转详情
handleGoDetail (record) {
this.$openPageNewSheet({
path: '/enterpriseStandardLibrary/enterpriseStandardDetail',
query: {
standardNumber: record.standardNo
}
})
},
handleTableChange (pagination) {
this.ipagination = pagination
},
// 表格选中
onSelectChange (selectedRowKeys, selectionRows) {
this.selectedRowKeys = selectedRowKeys
this.selectionRows = selectionRows
},
// 新增或编辑完成
changeBaseInfoDrawerOk (value) {
console.log(value, this.modalType)
if (this.modalType === 'add') {
const uidGenerator = () => {
return '-' + parseInt(Math.random() * 10000 + 1, 10)
}
this.dataSource.push({ uid: uidGenerator(), ...value })
} else if (this.modalType && this.modalType.split(',')[0] === 'edit') {
const dataIndex = this.dataSource.findIndex(item => item.uid === this.modalType.split(',')[1])
this.dataSource.splice(dataIndex, 1, value)
}
},
// 新增
handleAdd () {
this.modalType = 'add'
this.$refs.changeBaseInfoDrawer.add()
this.$refs.changeBaseInfoDrawer.title = this.$t('newlyAdded')
},
// 编辑
handleEdit (record) {
this.modalType = 'edit' + ',' + record.uid
this.$refs.changeBaseInfoDrawer.edit(record)
this.$refs.changeBaseInfoDrawer.title = this.$t('edit')
},
// 删除
handleDelete (uid) {
this.$confirm({
title: this.$t('confirmDeletion'),
content: this.$t('areYouSure'),
onOk: () => {
const dataIndex = this.dataSource.findIndex(item => item.uid === uid)
this.dataSource.splice(dataIndex, 1)
}
})
},
// 批量删除
batchDel () {
if (this.selectedRowKeys.length <= 0) {
this.$message.warning(this.$t('selectARecord'))
return
}
this.$confirm({
title: this.$t('confirmBatchDeletion'),
content: this.$t('deleteAData'),
onOk: () => {
for (const i of this.selectedRowKeys) {
const dataIndex = this.dataSource.findIndex(item => item.uid === i)
this.dataSource.splice(dataIndex, 1)
}
this.selectedRowKeys = []
}
})
}
}
}
</script>
<style scoped lang="less">
.change-base-info-wrapper {
margin-top: 20px;
}
</style>