Files
laws-sinotruk-client/src/views/workCenter/enterpriseStandardInspectionPlan/modules/WriteOpinionModal.vue
T

181 lines
5.3 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">
<j-table
v-if="columns && columns.length > 0"
:columns="columns"
:dataSource="dataSource"
:can-drag="true"
:pagination="false"
rowKey="id"
ref="table"
size="middle"
:scroll="{x:'100%'}"
bordered>
<!-- 企标号、企标名称 -->
<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>
</j-table>
<a-form-model ref="form" :model="formData" :rules="validatorRules">
<a-form-model-item
prop="opinion"
:label="$t('workCenter.esInspectionPlan.opinion')">
<a-textarea :max-length="500" :rows="4" :disabled="disabled"
:placeholder="$t('pleaseEnter') + $t('workCenter.esInspectionPlan.opinion')" v-model="formData.opinion"/>
</a-form-model-item>
</a-form-model>
</a-spin>
</j-modal>
</template>
<script>
import JTable from '@comp/jero/JTable'
import { fillInOpinionInspectPlanTable } from '@api/workCenter'
export default {
name: 'WriteOpinionModal',
components: { JTable },
data () {
return {
disabled: false,
title: this.$t('workCenter.esInspectionPlan.writeOpinion'),
drawerWidth: 1000,
visible: false,
model: {},
confirmLoading: false,
validatorRules: {
opinion: [
{ required: true, message: this.$t('pleaseEnter') + this.$t('workCenter.esInspectionPlan.opinion'), trigger: 'blur' }
]
},
formData: {
opinion: ''
},
columns: [
{ // 稽查依据标准号
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' }
}
],
dataSource: []
}
},
methods: {
show (record, disabled) {
// 是否禁用表单
this.disabled = disabled
const list = record.processEsInspectPlanOpinionList || []
this.formData.opinion = (list.find(item => item.createBy === this.$store.getters.userInfo.username) || {}).opinion
this.dataSource = [record]
this.model = Object.assign({}, record)
this.visible = true
},
// 确定
handleOk () {
if (this.disabled) {
this.close()
return
}
const that = this
// 触发表单验证
this.$refs.form.validate(valid => {
if (valid) {
that.confirmLoading = true
const formData = Object.assign({}, {
inspectPlanId: this.model.id
}, this.formData)
fillInOpinionInspectPlanTable(formData).then((res) => {
if (res.success) {
that.$message.success(res.message)
that.$emit('ok')
that.close()
} else {
that.$message.warning(res.message)
}
}).finally(() => {
that.confirmLoading = false
})
} else {
return false
}
})
},
// 关闭
handleCancel () {
this.close()
},
close () {
this.$emit('close')
this.dataSource = []
this.$refs.form.resetFields()
this.visible = false
},
// 跳转详情
detailClick (record) {
this.$openPageNewSheet({
path: '/enterpriseStandardLibrary/enterpriseStandardDetail',
query: {
standardNumber: record.inspectNo
}
})
}
}
}
</script>
<style scoped>
</style>