421 lines
14 KiB
Vue
421 lines
14 KiB
Vue
<template>
|
||
<div>
|
||
<!-- 操作区域 -->
|
||
<div v-if="!disabled" class="table-operator">
|
||
<!-- 新增 -->
|
||
<a-button icon="plus" type="primary" @click="handleAdd" :disabled="disabled">
|
||
{{ $t('newlyAdded') }}
|
||
</a-button>
|
||
<!-- 导入 -->
|
||
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
|
||
<a-button icon="upload" type="primary" ghost>{{ $t('import') }}</a-button>
|
||
</a-upload>
|
||
<!-- 模板下载 -->
|
||
<a-button icon="download" type="primary" ghost @click="downTemplate($t('workCenter.revisionPlanActivelyReport.templateExport'))">
|
||
{{ $t('templateDownload') }}
|
||
</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="(record, index) => { return index }"
|
||
:columns="columns"
|
||
:dataSource="dataSource"
|
||
:pagination="false"
|
||
:loading="loading"
|
||
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}">
|
||
|
||
<!-- 原企标编号/企标名称 -->
|
||
<template v-slot:toDetailOld="{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="handleGoDetailOld(record)">{{ text }}</a>
|
||
<div v-else class="table-text">{{ global.emptyLine }}</div>
|
||
</a-tooltip>
|
||
</template>
|
||
|
||
<!-- 新企标编号/企标名称 -->
|
||
<template v-slot:toDetailNew="{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="handleGoDetailNew(record)">{{ text }}</a>
|
||
<div v-else class="table-text">{{ global.emptyLine }}</div>
|
||
</a-tooltip>
|
||
</template>
|
||
|
||
<!-- 操作栏 -->
|
||
<div slot="action" slot-scope="{record, index}" class="action-span-cell">
|
||
<template v-if="!disabled">
|
||
<a @click="handleEdit(record, index)" class="table-ope-btn">{{ $t('edit') }}</a>
|
||
<a-divider type="vertical" />
|
||
<a @click="handleDelete(record.id, index)" class="table-ope-btn">{{ $t('delete') }}</a>
|
||
</template>
|
||
<template v-else-if="onlyCanLook">
|
||
<a @click="handleLook(record, index)" class="table-ope-btn">{{ $t('lookDetail') }}</a>
|
||
</template>
|
||
<template v-else-if="editAndLook">
|
||
<a @click="handleEdit(record, index)" class="table-ope-btn">{{ $t('edit') }}</a>
|
||
<a-divider type="vertical" />
|
||
<a @click="handleLook(record, index)" class="table-ope-btn">{{ $t('lookDetail') }}</a>
|
||
</template>
|
||
</div>
|
||
|
||
</j-table>
|
||
</div>
|
||
<!-- 表格新增、编辑弹框 -->
|
||
<contact-enter-send-task-modal ref="contactEnterSendTaskModal" @ok="modelFormOk"></contact-enter-send-task-modal>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import Vue from 'vue'
|
||
import { ACCESS_TOKEN, TENANT_ID } from '@/store/mutation-types'
|
||
import store from '@/store'
|
||
import JTable from '@/components/jero/JTable'
|
||
import ContactEnterSendTaskModal from './ContactEnterSendTaskModal'
|
||
import { downloadFile } from '@/api/manage'
|
||
|
||
// 导入的加载提示
|
||
let importModalLoading
|
||
|
||
export default {
|
||
name: 'OnlyTableForm',
|
||
components: { ContactEnterSendTaskModal, JTable },
|
||
props: {
|
||
disabled: {
|
||
type: Boolean,
|
||
required: false,
|
||
default: false
|
||
},
|
||
// 只能查看
|
||
onlyCanLook: {
|
||
type: Boolean,
|
||
required: false,
|
||
default: false
|
||
},
|
||
// 可以编辑和查看
|
||
editAndLook: {
|
||
type: Boolean,
|
||
required: false,
|
||
default: false
|
||
}
|
||
},
|
||
computed: {
|
||
tokenHeader () {
|
||
const head = { 'X-Access-Token': Vue.ls.get(ACCESS_TOKEN) }
|
||
const tenantid = Vue.ls.get(TENANT_ID)
|
||
if (tenantid) {
|
||
head['tenant-id'] = tenantid
|
||
}
|
||
return head
|
||
},
|
||
importExcelUrl: function () {
|
||
return `${window._CONFIG.domianURL}/${this.url.importExcelUrl}`
|
||
}
|
||
},
|
||
mounted () {
|
||
if (this.disabled) {
|
||
this.columns.pop()
|
||
}
|
||
},
|
||
data () {
|
||
return {
|
||
loading: false,
|
||
columns: [
|
||
{
|
||
title: this.$t('serialNumber'),
|
||
dataIndex: '',
|
||
key: 'rowIndex',
|
||
align: 'center',
|
||
width: 80,
|
||
customRender: function (t, r, index) {
|
||
return parseInt(index) + 1
|
||
}
|
||
},
|
||
{ // 制修订类型
|
||
title: this.$t('enterpriseStandardLibrary.plan.revisionType'),
|
||
align: 'center',
|
||
width: 180,
|
||
dataIndex: 'projectType_dictText',
|
||
scopedSlots: { customRender: 'text' }
|
||
},
|
||
{ // 原企标编号
|
||
title: this.$t('enterpriseStandardLibrary.plan.oldEnterpriseStandardNum'),
|
||
align: 'center',
|
||
width: 180,
|
||
dataIndex: 'originEnStandardNo',
|
||
scopedSlots: { customRender: 'toDetailOld' }
|
||
},
|
||
{ // 新企标编号
|
||
title: this.$t('enterpriseStandardLibrary.plan.newEnterpriseStandardNum'),
|
||
align: 'center',
|
||
width: 180,
|
||
dataIndex: 'newEnStandardNo',
|
||
scopedSlots: { customRender: 'toDetailNew' }
|
||
},
|
||
{ // 原企标名称
|
||
title: this.$t('enterpriseStandardLibrary.plan.oldEnterpriseStandardName'),
|
||
align: 'center',
|
||
width: 180,
|
||
dataIndex: 'originEnStandardName',
|
||
scopedSlots: { customRender: 'toDetailOld' }
|
||
},
|
||
{ // 新企标名称
|
||
title: this.$t('enterpriseStandardLibrary.plan.newEnterpriseStandardName'),
|
||
align: 'center',
|
||
width: 180,
|
||
dataIndex: 'newEnStandardName',
|
||
scopedSlots: { customRender: 'toDetailNew' }
|
||
},
|
||
{ // 授权部门
|
||
title: this.$t('enterpriseStandardLibrary.plan.authDepartment'),
|
||
align: 'center',
|
||
width: 180,
|
||
dataIndex: 'authDept_dictText',
|
||
scopedSlots: { customRender: 'text' }
|
||
},
|
||
{ // 企业标准代号
|
||
title: this.$t('enterpriseStandardLibrary.plan.enterpriseStandardCode'),
|
||
align: 'center',
|
||
width: 180,
|
||
dataIndex: 'enStandardCode_dictText',
|
||
scopedSlots: { customRender: 'text' }
|
||
},
|
||
{ // 配合单位
|
||
title: this.$t('enterpriseStandardLibrary.plan.suitUnit'),
|
||
align: 'center',
|
||
width: 180,
|
||
dataIndex: 'cooperationUnit_dictText',
|
||
scopedSlots: { customRender: 'text' }
|
||
},
|
||
// { // 主起草人
|
||
// title: this.$t('enterpriseStandardLibrary.plan.principalDrafter'),
|
||
// align: 'center',
|
||
// width: 180,
|
||
// dataIndex: 'mainDraftingUser_dictText',
|
||
// scopedSlots: { customRender: 'text' }
|
||
// },
|
||
{ // 主起草单位
|
||
title: this.$t('enterpriseStandardLibrary.plan.mainDraftingUnit'),
|
||
align: 'center',
|
||
width: 180,
|
||
dataIndex: 'mainDraftingUnit_dictText',
|
||
scopedSlots: { customRender: 'text' }
|
||
},
|
||
{ // 主起草单位负责人
|
||
title: this.$t('enterpriseStandardLibrary.plan.headOfMainDraftingUnit'),
|
||
align: 'center',
|
||
width: 180,
|
||
dataIndex: 'mainDraftingUnitResponsiblePerson_dictText',
|
||
scopedSlots: { customRender: 'text' }
|
||
},
|
||
{ // 隶属工作组
|
||
title: this.$t('workCenter.revisionPlanActivelyReport.affiliatedWorkingGroup'),
|
||
align: 'center',
|
||
width: 180,
|
||
dataIndex: 'workGroup_dictText',
|
||
scopedSlots: { customRender: 'text' }
|
||
},
|
||
{ // 标准推进人
|
||
title: this.$t('enterpriseStandardLibrary.plan.standardPusher'),
|
||
align: 'center',
|
||
width: 180,
|
||
dataIndex: 'standardPromoter_dictText',
|
||
scopedSlots: { customRender: 'text' }
|
||
},
|
||
{ // 草稿计划完成日期
|
||
title: this.$t('enterpriseStandardLibrary.plan.draftPlanFinishDate'),
|
||
align: 'center',
|
||
width: 180,
|
||
dataIndex: 'draftPlannedCompleteDate',
|
||
scopedSlots: { customRender: 'text' }
|
||
},
|
||
{ // 征求意见稿计划完成日期
|
||
title: this.$t('enterpriseStandardLibrary.plan.exposureDraftPlanFinishDate'),
|
||
align: 'center',
|
||
width: 200,
|
||
dataIndex: 'solicitationDraftPlanCompleteDate',
|
||
scopedSlots: { customRender: 'text' }
|
||
},
|
||
{ // 计划报批日期
|
||
title: this.$t('enterpriseStandardLibrary.plan.planSubmissionDate'),
|
||
align: 'center',
|
||
width: 180,
|
||
dataIndex: 'planApprovalDate',
|
||
scopedSlots: { customRender: 'text' }
|
||
},
|
||
{ // 变更状态
|
||
title: this.$t('enterpriseStandardLibrary.plan.changeState'),
|
||
align: 'center',
|
||
width: 180,
|
||
dataIndex: 'changeStatus_dictText',
|
||
scopedSlots: { customRender: 'text' }
|
||
},
|
||
{
|
||
title: this.$t('operation'),
|
||
scopedSlots: { customRender: 'action' },
|
||
align: 'center',
|
||
fixed: 'right',
|
||
width: 200
|
||
}
|
||
],
|
||
dataSource: [],
|
||
selectedRowKeys: [],
|
||
selectionRows: [],
|
||
url: {
|
||
downTemplateUrl: '/process/es/annualReport/templateDownload',
|
||
importExcelUrl: '/process/es/annualReport/importExcel'
|
||
},
|
||
modalType: '' // 是在新增还是在编辑,编辑的时候放正在编辑的下标
|
||
}
|
||
},
|
||
methods: {
|
||
// 企标编号,企标名称跳转详情,原企标
|
||
handleGoDetailOld (record) {
|
||
this.$openPageNewSheet({
|
||
path: '/enterpriseStandardLibrary/enterpriseStandardDetail',
|
||
query: {
|
||
standardNumber: record.originEnStandardNo
|
||
}
|
||
})
|
||
},
|
||
// 企标编号,企标名称跳转详情,新企标
|
||
handleGoDetailNew (record) {
|
||
this.$openPageNewSheet({
|
||
path: '/enterpriseStandardLibrary/enterpriseStandardDetail',
|
||
query: {
|
||
standardNumber: record.newEnStandardNo
|
||
}
|
||
})
|
||
},
|
||
// 表格选中
|
||
onSelectChange (selectedRowKeys, selectionRows) {
|
||
this.selectedRowKeys = selectedRowKeys
|
||
this.selectionRows = selectionRows
|
||
},
|
||
// 下载导入模板
|
||
downTemplate (fileName) {
|
||
if (!fileName || typeof fileName !== 'string') {
|
||
fileName = '模板文件'
|
||
}
|
||
downloadFile(this.url.downTemplateUrl, fileName + '.xls')
|
||
},
|
||
// 新增或编辑完成
|
||
modelFormOk (value) {
|
||
console.log(value, this.modalType)
|
||
if (this.modalType === 'add') {
|
||
this.dataSource.push(value)
|
||
} else if (this.modalType && this.modalType.split(',')[0] === 'edit') {
|
||
this.dataSource.splice(Number(this.modalType.split(',')[1]), 1, value)
|
||
}
|
||
},
|
||
// 新增
|
||
handleAdd () {
|
||
this.modalType = 'add'
|
||
this.$refs.contactEnterSendTaskModal.add()
|
||
},
|
||
// 导入
|
||
handleImportExcel (info) {
|
||
// 加一个大的提示
|
||
if (!this.loading) {
|
||
importModalLoading = this.$info({
|
||
title: '提示',
|
||
content: <span>正在导入,请稍候 <a-spin size="small" /></span>,
|
||
keyboard: false
|
||
})
|
||
}
|
||
this.loading = true
|
||
// 把知道了这个按钮去掉
|
||
this.$nextTick(() => {
|
||
document.getElementsByClassName('ant-modal-confirm-btns')[0].style = 'display:none'
|
||
})
|
||
if (info.file.status !== 'uploading') {
|
||
console.log(info.file, info.fileList)
|
||
}
|
||
if (info.file.status === 'done') {
|
||
// 销毁这个提示
|
||
importModalLoading && importModalLoading.destroy()
|
||
this.loading = false
|
||
if (info.file.response.success) {
|
||
// this.$message.success(`${info.file.name} 文件上传成功`);
|
||
if (info.file.response.code === 201) {
|
||
const { message, result: { msg, fileUrl, fileName } } = info.file.response
|
||
const href = window._CONFIG.domianURL + fileUrl
|
||
this.$warning({
|
||
title: message,
|
||
content: (<div>
|
||
<span>{msg}</span><br />
|
||
<span>具体详情请 <a href={href} target="_blank" download={fileName}>点击下载</a> </span>
|
||
</div>
|
||
)
|
||
})
|
||
} else {
|
||
this.$message.success(info.file.response.message || `${info.file.name} 文件上传成功`)
|
||
}
|
||
// 推入表格中
|
||
this.dataSource = this.dataSource.concat(info.file.response.result)
|
||
} else {
|
||
this.$message.warning(`${info.file.name} ${info.file.response.message}.`)
|
||
}
|
||
} else if (info.file.status === 'error') {
|
||
// 销毁这个提示
|
||
importModalLoading && importModalLoading.destroy()
|
||
this.loading = false
|
||
if (info.file.response.status === 500) {
|
||
const data = info.file.response
|
||
const token = Vue.ls.get(ACCESS_TOKEN)
|
||
if (token && data.message.includes('Token失效')) {
|
||
this.error({
|
||
title: '登录已过期',
|
||
content: '很抱歉,登录已过期,请重新登录',
|
||
okText: '重新登录',
|
||
mask: false,
|
||
onOk: () => {
|
||
store.dispatch('Logout').then(() => {
|
||
Vue.ls.remove(ACCESS_TOKEN)
|
||
window.location.reload()
|
||
})
|
||
}
|
||
})
|
||
}
|
||
} else {
|
||
this.$message.warning(`文件上传失败: ${info.file.msg} `)
|
||
}
|
||
}
|
||
},
|
||
// 编辑
|
||
handleEdit (record, index) {
|
||
this.modalType = 'edit' + ',' + index
|
||
this.$refs.contactEnterSendTaskModal.edit(record)
|
||
},
|
||
// 查看
|
||
handleLook (record) {
|
||
this.$refs.contactEnterSendTaskModal.look(record)
|
||
},
|
||
// 删除
|
||
handleDelete (id, index) {
|
||
this.dataSource.splice(index, 1)
|
||
},
|
||
// 批量删除
|
||
batchDel () {
|
||
for (let i = 0; i < this.selectedRowKeys.length; i++) {
|
||
this.dataSource.splice(this.selectedRowKeys[i], 1, false)
|
||
}
|
||
this.dataSource = this.dataSource.filter(item => !!item)
|
||
this.selectedRowKeys = []
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
|
||
</style>
|