Files
laws-sinotruk-mobile/src/views/workCenter/enterpriseStandardInspectionRectification/EnterpriseStandardInspectionRectification.vue
T

429 lines
14 KiB
Vue

<template>
<process-common-layout class="page-box" :process-key="processKey" :loading="loading">
<template v-slot:process>
<!-- 流程信息 -->
<div class="process-part">
<div class="process-part-title">{{ $t('processInformation') }}</div>
<van-form
ref="form"
input-align="right"
error-message-align="right">
<!-- 流程名称 -->
<van-field
:label="$t('processName')"
:placeholder="$t('pleaseEnter') + $t('processName')"
readonly
type="textarea"
rows="1"
autosize
:rules="rules.prcName"
v-model="processInfoForm.prcName"/>
<!-- 截止日期 -->
<calendar-field
:label="$t('expirationDate')"
v-model="processInfoForm.dueTime"
readonly
type="date"/>
<!-- 流程说明 -->
<van-field
v-model="processInfoForm.prcMes"
:label="$t('processExplain')"
type="textarea"
autosize
disabled
rows="2"
:placeholder="$t('pleaseEnter')+$t('processExplain')"
:border="false"
input-align="left"
class="vertical-form-item"/>
</van-form>
</div>
<!-- 业务信息 -->
<div class="process-part">
<div class="process-part-title">{{ $t('basicServiceInformation') }}</div>
<!-- 稽查依据 -->
<van-field
:label="$t('esInspectionRectification.inspectionBasis')"
readonly
type="textarea"
autosize
rows="1"
v-model="baseInfoForm.standardName" />
<!-- 依据条款 -->
<van-field
:label="$t('esInspectionRectification.accordingToTerms')"
readonly
type="textarea"
autosize
rows="1"
v-model="baseInfoForm.enterpriseStandardInspectRectifyPlan.enterpriseStandardInspectReport.baseClause" />
<!-- 标准内容或要求 -->
<van-field
:label="$t('esInspectionRectification.standardContentOrDemand')"
readonly
type="textarea"
autosize
rows="1"
v-model="baseInfoForm.enterpriseStandardInspectRectifyPlan.enterpriseStandardInspectReport.standardRequire" />
<!-- 整改单位 -->
<van-field
:label="$t('esInspectionRectification.rectificationUnit')"
readonly
type="textarea"
autosize
rows="1"
v-model="baseInfoForm.enterpriseStandardInspectRectifyPlan.responseDepart_dictText" />
<!-- 不符合项描述 -->
<van-field
:label="$t('esInspectionRectification.nonCompliantDescription')"
readonly
type="textarea"
autosize
rows="1"
v-model="baseInfoForm.enterpriseStandardInspectRectifyPlan.issue" />
<!-- 整改措施 -->
<van-field
:label="$t('esInspectionRectification.rectificationMeasures')"
readonly
type="textarea"
autosize
rows="1"
v-model="baseInfoForm.enterpriseStandardInspectRectifyPlan.rectifyMeasure" />
<!-- 整改责任人 -->
<van-field
:label="$t('esInspectionRectification.rectificationDirector')"
readonly
type="textarea"
autosize
rows="1"
v-model="baseInfoForm.enterpriseStandardInspectRectifyPlan.responseUserDictText" />
<!-- 计划完成日期 -->
<van-field
:label="$t('esInspectionRectification.planDoneDate')"
readonly
type="textarea"
autosize
rows="1"
v-model="baseInfoForm.enterpriseStandardInspectRectifyPlan.planCompleteDate" />
<!-- 操作类型 -->
<van-field
:label="$t('esInspectionRectification.operationType')"
readonly
type="textarea"
autosize
rows="1"
v-model="baseInfoForm.operationType_dictText" />
<template v-if="baseInfoForm.operationType === '1'">
<!-- 整改结果 -->
<van-field
:label="$t('esInspectionRectification.rectificationResults')"
readonly
type="textarea"
autosize
rows="1"
v-model="baseInfoForm.rectifyResult" />
<!-- 附件 -->
<van-field
:label="$t('esInspectionRectification.file')"
readonly
type="textarea"
autosize
rows="1"
v-model="baseInfoForm.attachment">
<template v-slot:input>
<file-display :file-ids="baseInfoForm.attachment" />
</template>
</van-field>
</template>
<template v-else-if="baseInfoForm.operationType === '2'">
<!-- 申请延期日期 -->
<van-field
:label="$t('esInspectionRectification.requestExtensionDate')"
readonly
type="textarea"
autosize
rows="1"
v-model="baseInfoForm.applyDelayDate" />
<!-- 延期说明 -->
<van-field
:label="$t('esInspectionRectification.extensionDescription')"
readonly
type="textarea"
autosize
rows="1"
v-model="baseInfoForm.delayDetail" />
</template>
</div>
<!-- 流程审批信息 -->
<div class="process-part">
<div class="process-part-title">{{ $t('processApprovalInformation') }}</div>
<van-form
ref="approvalInfoForm"
input-align="right"
error-message-align="right">
<!-- 备注 -->
<van-field
v-model="approvalInfoForm.commitText"
:label="$t('remark')"
:rules="rules.commitText"
name="commitText"
type="textarea"
autosize
rows="2"
:placeholder="$t('pleaseEnter')+$t('remark')"
:border="false"
input-align="left"
class="vertical-form-item"/>
<!--附件-->
<z-upload v-model="approvalInfoForm.commitFile" />
</van-form>
</div>
</template>
<template v-slot:operation>
<!-- 转办 -->
<van-button class="operation-common-btn" @click="handleTurnTo">
<template #icon>
<van-icon class="iconfont" class-prefix="icon" name="xunhuan" />
</template>
{{ $t('turnTo') }}
</van-button>
<!-- 同意 -->
<van-button class="operation-common-btn" type="primary" @click="handleAgree">
<template #icon>
<van-icon class="iconfont" class-prefix="icon" name="check" />
</template>
{{ $t('agree') }}
</van-button>
<!-- 驳回 -->
<van-button class="operation-common-btn light-color-button" @click="handleReject">
<template #icon>
<van-icon class="iconfont" class-prefix="icon" name="close" />
</template>
{{ $t('reject') }}
</van-button>
</template>
<select-user ref="selectUserRef" @selected-change="selectUserChange"></select-user>
</process-common-layout>
</template>
<script>
import ProcessCommonLayout from '@/components/ProcessCommonLayout'
import { ApprovalOpinions, EsInspectionRectification, ProcessKey } from '@/enums/commonEnums'
import SelectUser from '@/components/SelectUser'
import CalendarField from '@/components/CalendarField'
import ZUpload from '@/components/ZUpload'
import {
approvalInspectRectify,
getInspectRectifyDataById,
getInspectRectifyDetail, rejectInspectRectify,
transferInspectRectify
} from '@/api/api'
import FileDisplay from '@/components/FileDisplay'
export default {
name: 'EnterpriseStandardInspectionRectification',
components: { FileDisplay, ZUpload, CalendarField, SelectUser, ProcessCommonLayout },
data () {
return {
// 流程加载
loading: false,
// 表格加载
tableLoading: false,
processKey: ProcessKey.ES_INSPECTION_RECTIFICATION.value,
rules: {
// 备注
commitText: [
{ required: false, message: this.$t('pleaseEnter') + this.$t('remark') }
]
},
// 获取到的流程信息
info: {},
// 流程信息
processInfoForm: {},
// 审批意见信息
approvalInfoForm: {},
// 业务信息
baseInfoForm: {}
}
},
computed: {
// 当前项目id
projectId () {
return this.$route.query.projectId
}
},
// 组件内路由拦截
beforeRouteEnter (to, from, next) {
// 如果不是移动端支持的节点,就跳转NoMobile
if (!EsInspectionRectification.propertyOfValue('isMobile', to.query.nodeId)) {
next({ path: '/noMobile' })
}
next()
},
created () {
this.loadPage()
},
methods: {
// 加载页面数据
loadPage () {
this.loading = true
const { projectId, taskId } = this.$route.query
Promise.all([
// 获取业务数据
getInspectRectifyDataById({ projectId }).then(res => {
if (res.success) {
// this.baseInfoForm = res.result || {}
const data = res.result || {}
this.baseInfoForm = Object.assign({}, data)
// data.enterpriseStandardInspectRectifyPlan,
// data.enterpriseStandardInspectRectifyPlan && data.enterpriseStandardInspectRectifyPlan.enterpriseStandardInspectReport
console.log(this.baseInfoForm)
}
}).finally(() => {}),
// 获取流程数据
getInspectRectifyDetail({ projectId, taskId }).then(res => {
if (res.success) {
const data = res.result || {}
this.info = data
const processAll = data.processAll || {}
const processApprovalRecord = data.processApprovalRecord || {}
// 回显流程信息
this.processInfoForm = {
prcName: processAll.prcName,
dueTime: processAll.dueTime,
prcMes: processAll.prcMes
}
// 回显审批信息
this.approvalInfoForm = {
commitText: processApprovalRecord.commitText,
commitFile: processApprovalRecord.commitFile
}
}
}).finally(() => {})
]).finally(() => {
this.loading = false
})
},
// 转办
handleTurnTo () {
if (this.loading) return
// 点击显示选人组件
this.$refs.selectUserRef.open()
},
// 转办选完人的回调
selectUserChange (userIds) {
this.loading = true
const param = {}
param.userId = userIds
param.taskId = this.$route.query.taskId
transferInspectRectify(param).then(res => {
if (res.success) {
this.$message(res.message)
this.goBack()
} else {
this.$message(res.message)
}
}).finally(() => {
this.loading = false
})
},
// 获取页面参数
async getPageParams () {
const params = {}
let validateError = null
// 流程信息
params.processAll = Object.assign({}, this.info.processAll, {
projectId: this.projectId,
nodeId: this.$route.query.nodeId,
taskId: this.$route.query.taskId
})
// 审批意见
await this.$refs.approvalInfoForm.validate().then(() => {
params.processApprovalRecord = Object.assign({}, this.info.processApprovalRecord, this.approvalInfoForm, {
projectId: this.projectId
})
}).catch(err => {
console.log(err)
validateError = err
})
// 验证失败就返回一个错误
if (validateError) {
throw new Error(validateError)
}
// 其他参数
params.map = {}
return params
},
// 同意
handleAgree () {
if (this.loading) return
this.loading = true
this.rules.commitText[0].required = false
this.getPageParams().then(params => {
params.map.pass = true
// 如果没有填写注释,就默认同意
if (!params.processApprovalRecord.commitText) {
params.processApprovalRecord.commitText = '同意'
}
// 审批意见
params.processApprovalRecord.commitFlag = ApprovalOpinions.AGREE.value
console.log(params)
return approvalInspectRectify(params)
}).then(res => {
if (res.success) {
this.$message(res.message)
this.goBack()
} else {
this.$message(res.message)
}
}).catch((err) => {
console.log(err)
}).finally(() => {
this.loading = false
})
},
// 驳回
handleReject () {
if (this.loading) return
this.rules.commitText[0].required = true
// 驳回需要填写备注
if (!this.approvalInfoForm.commitText) {
this.$message(this.$t('pleaseEnterRemarks'))
}
this.getPageParams().then(params => {
params.map.pass = false
// 审批意见
params.processApprovalRecord.commitFlag = ApprovalOpinions.REJECT.value
console.log(params)
return rejectInspectRectify(params)
}).then(res => {
if (res.success) {
this.$message(res.message)
this.goBack()
} else {
this.$message(res.message)
}
}).catch((err) => {
console.log(err)
}).finally(() => {
this.loading = false
this.rules.commitText[0].required = false
})
},
goBack () {
// this.$router.go(-1)
}
}
}
</script>
<style scoped lang="less">
@import '~@/assets/less/common.less';
</style>