Files
laws-sinotruk-client/src/views/workCenter/enterpriseStandardInspectionProcess/modules/InspectionProcessReport.vue
T

224 lines
6.6 KiB
Vue

<template>
<j-modal
:title="title"
:width="drawerWidth"
:visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel"
:cancelText="$t('close')">
<a-spin :spinning="confirmLoading">
<p>
{{ $t('workCenter.esInspectionProcess.enterpriseStandard') }}
{{model.inspectNo}}
{{model.inspectName}}
</p>
<div class="table-operator" v-if="!disabled">
<!-- 新增 -->
<a-button icon="plus" type="primary" @click="handleAdd">{{ $t('newlyAdded') }}</a-button>
</div>
<j-table
v-if="columns && columns.length > 0"
:columns="columns"
:dataSource="dataSource"
:can-drag="true"
:rowKey="(_, index) => index"
:row-selection="null"
:pagination="ipagination"
:scroll="{x: '100%',y: '50vh'}"
@change="tableOnChange">
<!-- 附件 -->
<template v-slot:file="{text, record}">
<a v-if="text" @click="fileLook(record)">{{ $t('view') }}</a>
<div v-else class="table-text">{{ global.emptyLine }}</div>
</template>
<!-- 操作 -->
<template slot="action" slot-scope="{text, record, index}">
<a @click="handleEdit(record, index)" >{{ $t('edit') }}</a>
<a-divider type="vertical" />
<a @click="handleDelete(index)" >{{ $t('delete') }}</a>
</template>
</j-table>
</a-spin>
<!-- 新增、编辑稽查报告 -->
<inspection-process-report-modal ref="modalForm" @ok="modalFormOk"/>
<!-- 上传回显 -->
<upload-file ref="uploadFile" disabled></upload-file>
</j-modal>
</template>
<script>
import JTable from '@comp/jero/JTable'
import { JeroListMixin } from '@/mixins/JeroListMixin'
import InspectionProcessReportModal
from '@views/workCenter/enterpriseStandardInspectionProcess/modules/InspectionProcessReportModal'
import UploadFile from '@comp/UploadFile'
export default {
name: 'InspectionProcessReport',
mixins: [JeroListMixin],
components: { UploadFile, InspectionProcessReportModal, JTable },
props: {
disabled: {
type: Boolean,
default: false
}
},
data () {
const 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.esInspectionProcess.accordingToTerms'),
align: 'center',
width: 120,
dataIndex: 'baseClause',
scopedSlots: { customRender: 'text' }
},
{ // 标准内容或要求
title: this.$t('workCenter.esInspectionProcess.standardContentOrDemand'),
align: 'center',
width: 180,
dataIndex: 'standardRequire',
scopedSlots: { customRender: 'text' }
},
{ // 执行情况
title: this.$t('workCenter.esInspectionProcess.implementation'),
align: 'center',
width: 180,
dataIndex: 'executionStatus',
scopedSlots: { customRender: 'text' }
},
{ // 附件
title: this.$t('workCenter.esInspectionProcess.file'),
align: 'center',
width: 140,
dataIndex: 'attachment',
scopedSlots: { customRender: 'file' }
},
{ // 评分
title: this.$t('workCenter.esInspectionProcess.score'),
align: 'center',
width: 100,
dataIndex: 'evaluateScore',
scopedSlots: { customRender: 'text' }
},
{
// 操作
fixed: 'right',
title: this.$t('operation'),
// dataIndex: 'action',
align: 'center',
width: 140,
scopedSlots: { customRender: 'action' }
}
]
return {
disableMixinCreated: true,
title: this.$t('workCenter.esInspectionProcess.inspectionReport'),
drawerWidth: 1000,
visible: false,
model: {},
confirmLoading: false,
url: {
list: '/laws.enterprise/EnterpriseStandardInspectReport/queryByProcessEsInspectId',
delete: '/laws.enterprise/EnterpriseStandardInspectReport/delete'
},
dataSource: [],
index: -1,
// 需要删除的数据id(前端添加后没有保存表的数据没有id)
delIds: [],
columns: columns.slice(0, this.disabled ? 6 : 7)
}
},
methods: {
show (record, index) {
const data = record.enterpriseStandardInspectReportList || []
this.dataSource = JSON.parse(JSON.stringify(data))
this.model = Object.assign({}, record)
this.index = index
this.visible = true
},
// 确定
handleOk () {
this.$emit('delIds', this.delIds)
this.$emit('ok', this.dataSource, this.index)
this.close()
},
// 关闭
handleCancel () {
this.close()
},
close () {
this.delIds = []
this.index = -1
this.$emit('close')
this.visible = false
},
tableOnChange (pagination, filters, sorter) {
this.orderBy = sorter.order === 'ascend' ? '1' : '2'
this.orderByField = sorter.columnKey
this.ipagination = pagination
this.getTableList()
},
handleAdd () {
this.$refs.modalForm.add(this.model)
this.$refs.modalForm.title = this.$t('newlyAdded')
this.$refs.modalForm.disableSubmit = false
},
handleEdit (record, index) {
this.$refs.modalForm.edit(this.model, record, index)
this.$refs.modalForm.title = this.$t('edit')
this.$refs.modalForm.disableSubmit = false
},
// 删除
handleDelete (index) {
this.$confirm({
title: this.$t('confirmDeletion'),
content: this.$t('areYouSure'),
onOk: () => {
if (this.dataSource[index].id) {
this.delIds.push(this.dataSource[index].id)
}
this.dataSource.splice(index, 1)
// 判断当前删除的数据是否是最后一页的最后一条数据,如果是的话页码减一
if (this.ipagination.current > 1 && ((this.ipagination.current - 1) * this.ipagination.pageSize) + 1 === this.ipagination.total) {
this.ipagination.current -= 1
}
}
})
},
// 表单回调
modalFormOk (row, index) {
console.log(row, index)
// 根据下标判断是添加还是编辑
if (index === undefined || index === -1) {
this.dataSource.push(row)
} else {
this.dataSource.splice(index, 1, row)
}
},
// 附件列的查看点击
fileLook (record) {
this.$refs.uploadFile.open(record.attachment)
}
}
}
</script>
<style scoped>
</style>