Files
laws-sinotruk-client/src/views/workCenter/enterpriseStandardInspectionPlan/modules/InspectionPlanTable.vue
T
2023-11-28 18:19:31 +08:00

323 lines
12 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div>
<div class="table-operator" v-if="hasTableOperator">
<!-- 新增 -->
<a-button icon="plus" type="primary" @click="handleAdd" v-has="'enterpriseStandard:add'">{{ $t('newlyAdded') }}</a-button>
<!-- 导入 -->
<a-upload name="file" :data="{projectId}" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
<a-button icon="upload" type="primary" ghost v-has="'enterpriseStandard:upload'">{{ $t('import') }}</a-button>
</a-upload>
<!-- 批量删除 -->
<a-button icon="delete" type="primary" ghost @click="batchDel" v-has="'enterpriseStandard:batchDel'">{{ $t('batchDelete') }}</a-button>
</div>
<div>
<j-table
v-if="columns && columns.length > 0"
:columns="columns"
:dataSource="dataSource"
:can-drag="true"
rowKey="id"
:loading="loading"
:pagination="false"
:row-selection="hasTableOperator ? { selectedRowKeys: selectedRowKeys, onChange: onSelectChange, getCheckboxProps } : null"
:scroll="{x: '100%'}"
@change="tableOnChange">
<!-- 企标号企标名称 -->
<template v-slot:standard="{text, record}">
<a-tooltip overlay-class-name="tooltip-style">
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
<a class="table-text can-click-table-text" @click="detailClick(record)" v-if="(text || text === 0) && record.detailFlag">{{ text }}</a>
<div class="table-text" v-else-if="(text || text === 0) && !record.detailFlag">{{ text }}</div>
<div class="table-text" v-else>{{ global.emptyLine }}</div>
</a-tooltip>
</template>
<!-- 所属部门意见 -->
<template v-slot:departOpinion="{text, record}">
<a-tooltip overlay-class-name="tooltip-style">
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
<a class="table-text can-click-table-text" @click="showDepartOpinion(record)" v-if="text && text.length">{{ $t('view') }}</a>
<div class="table-text" v-else>{{ global.emptyLine }}</div>
</a-tooltip>
</template>
<!-- 操作 -->
<template slot="action" slot-scope="{text, record, index}">
<!-- 编辑 and 删除:节点1 节点3 节点2且当前登录人是创建人 -->
<template v-if="isInitiateOrLiaisonCollect || (currentNode === EsInspectionPlan.fillInComments.value && $store.getters.userInfo.username === record.createBy)">
<a @click="handleEdit(record, index)" >{{ $t('edit') }}</a>
<a-divider type="vertical" />
<a @click="handleDelete(record.id)" >{{ $t('delete') }}</a>
</template>
<!-- 意见 or 填写意见节点2非自己创建的就是意见和填写意见 -->
<template v-else-if="currentNode === EsInspectionPlan.fillInComments.value">
<a v-if="record.processEsInspectPlanOpinionList && record.processEsInspectPlanOpinionList.length" @click="handleShowOpinion(record, index)" >{{ $t('workCenter.esInspectionPlan.opinion') }}</a>
<a v-else @click="handleWriteOpinion(record, index)" >{{ $t('workCenter.esInspectionPlan.writeOpinion') }}</a>
</template>
</template>
</j-table>
</div>
<!-- 新增/编辑稽查计划 -->
<inspection-plan-drawer ref="modalForm" @ok="modalFormOk" :project-id="projectId"/>
<!-- 节点2填写意见意见回显 -->
<write-opinion-modal ref="writeOpinionModal" @ok="modalFormOk"/>
<!-- 节点3所属部门意见-查看 -->
<show-opinion-modal ref="showOpinionModal" @ok="modalFormOk"/>
</div>
</template>
<script>
import { JeroListMixin } from '@/mixins/JeroListMixin'
import JTable from '@comp/jero/JTable'
import InspectionPlanDrawer from '@views/workCenter/enterpriseStandardInspectionPlan/modules/InspectionPlanDrawer'
import WriteOpinionModal from '@views/workCenter/enterpriseStandardInspectionPlan/modules/WriteOpinionModal'
import ShowOpinionModal from '@views/workCenter/enterpriseStandardInspectionPlan/modules/ShowOpinionModal'
import { EsInspectionPlan } from '@/enums/commonEnums'
export default {
name: 'InspectionPlanTable',
components: { ShowOpinionModal, WriteOpinionModal, InspectionPlanDrawer, JTable },
mixins: [JeroListMixin],
props: {
// 当前节点
currentNode: {
type: String,
required: true
},
// 项目id
projectId: {
type: String,
required: true
}
},
data () {
return {
EsInspectionPlan,
disableMixinCreated: true,
url: {
list: '/process/processEsInspectPlan/list',
delete: '/process/processEsInspectPlan/delete',
importExcelUrl: '/process/processEsInspectPlan/importExcel',
deleteBatch: '/process/processEsInspectPlan/deleteBatch'
},
model: {},
dataSource: [],
allColumns: [
{
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: 'inspectNo',
scopedSlots: { customRender: 'standard' }
},
{ // 稽查依据标准名称
title: this.$t('workCenter.esInspectionPlan.inspectionBasisStandardName'),
align: 'center',
width: 180,
dataIndex: 'inspectName',
scopedSlots: { customRender: 'standard' }
},
{ // 计划稽查对象
title: this.$t('workCenter.esInspectionPlan.planInspectionObjects'),
align: 'center',
width: 120,
dataIndex: 'inspectObject_dictText',
scopedSlots: { customRender: 'text' }
},
{ // 主责标准化工作组
title: this.$t('workCenter.esInspectionPlan.mainDutyStandardizationGroup'),
align: 'center',
width: 150,
dataIndex: 'standardizationWorkGroup',
scopedSlots: { customRender: 'text' }
},
{ // 所属部门
title: this.$t('workCenter.esInspectionPlan.department'),
align: 'center',
width: 120,
dataIndex: 'belongDept_dictText',
scopedSlots: { customRender: 'text' }
},
{ // 计划稽查日期
title: this.$t('workCenter.esInspectionPlan.planInspectionDate'),
align: 'center',
width: 120,
dataIndex: 'planInspectDate',
scopedSlots: { customRender: 'text' }
},
{ // 稽查负责人
title: this.$t('workCenter.esInspectionPlan.inspectionDirector'),
align: 'center',
width: 120,
dataIndex: 'inspectUserDictText',
scopedSlots: { customRender: 'text' }
},
{ // 标准化组对接人
title: this.$t('workCenter.esInspectionPlan.standardizationGroupContactPerson'),
align: 'center',
width: 140,
dataIndex: 'standardizationDockingUserDictText',
scopedSlots: { customRender: 'text' }
},
{ // 所属部门人员
title: this.$t('workCenter.esInspectionPlan.departmentPersonnel'),
align: 'center',
width: 120,
dataIndex: 'objectOfConsultationDictText',
showCodeList: [EsInspectionPlan.initiate.value],
scopedSlots: { customRender: 'text' }
},
{ // 创建人
title: this.$t('workCenter.esInspectionPlan.creator'),
align: 'center',
width: 120,
dataIndex: 'createByDictText',
showCodeList: [EsInspectionPlan.fillInComments.value],
scopedSlots: { customRender: 'text' }
},
{ // 发起人
title: this.$t('workCenter.esInspectionPlan.initiator'),
align: 'center',
width: 120,
dataIndex: 'createByDictText',
showCodeList: [
EsInspectionPlan.liaisonCollect.value,
EsInspectionPlan.relevantPersonnelCountersign.value,
EsInspectionPlan.liaisonLeaderApproval.value
],
scopedSlots: { customRender: 'text' }
},
{ // 所属部门意见
title: this.$t('workCenter.esInspectionPlan.departOpinion'),
align: 'center',
width: 120,
dataIndex: 'processEsInspectPlanOpinionList',
showCodeList: [EsInspectionPlan.liaisonCollect.value],
scopedSlots: { customRender: 'departOpinion' }
},
{
fixed: 'right',
// 操作
showCodeList: [
EsInspectionPlan.initiate.value,
EsInspectionPlan.fillInComments.value,
EsInspectionPlan.liaisonCollect.value
],
title: this.$t('operation'),
dataIndex: 'action',
align: 'center',
width: 180,
scopedSlots: { customRender: 'action' }
}
]
}
},
watch: {
// 列表查询带上项目id
projectId: {
immediate: true,
handler (val) {
if (!val) {
return
}
this.filters.projectId = this.projectId
if (this.currentNode === EsInspectionPlan.fillInComments.value) {
this.filters.nodeId = this.$route.query.nodeId
}
this.loadData()
}
}
},
computed: {
// 是否显示表格操作按钮
hasTableOperator () {
const arr = [
EsInspectionPlan.initiate.value,
EsInspectionPlan.fillInComments.value
]
return arr.includes(this.currentNode)
},
// 是否发起节点和联络人汇总节点
isInitiateOrLiaisonCollect () {
const arr = [EsInspectionPlan.initiate.value, EsInspectionPlan.liaisonCollect.value]
return arr.includes(this.currentNode)
},
// 按节点进行过滤
columns () {
return this.allColumns.filter(item => {
// 没有这个属性,就默认显示
if (!item.showCodeList) {
return true
}
// 如果有,就根据当前节点显示
return item.showCodeList.includes(this.currentNode)
})
}
},
created () {
this.filters.taskId = this.$route.query.taskId
},
methods: {
getCheckboxProps (record) {
const obj = { props: { disabled: false } }
// 第二个节点,只有自己的才能勾选删除
if (this.currentNode === EsInspectionPlan.fillInComments.value) {
obj.props.disabled = record.createBy !== this.$store.getters.userInfo.username
}
return obj
},
getData () {
return this.dataSource
},
// 更新表格数据
updateData (list) {
this.dataSource = list || []
},
// 跳转详情
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()
},
// 显示意见
handleShowOpinion (record) {
this.$refs.writeOpinionModal.show(record, true)
},
// 填写意见
handleWriteOpinion (record) {
this.$refs.writeOpinionModal.show(record)
},
// 查看所属部门意见
showDepartOpinion (record) {
this.$refs.showOpinionModal.show(record)
}
}
}
</script>
<style scoped>
</style>