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

470 lines
15 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>
<internal-detail-page :title="pageTitle" :content-padding="0" :loading="loading">
<!-- 标题右侧tab -->
<template v-slot:titleRightCustom>
<div class="table-operator-tab">
<!-- 基础信息 -->
<a class="switch-item" :class="switchValue === 'base' ? 'table-operator-tab-active' : ''"
@click="switchChange('base')">{{ $t('basicInformation') }}
</a>
<!-- 人员信息 -->
<a class="switch-item" :class="switchValue === 'user' ? 'table-operator-tab-active' : ''"
@click="switchChange('user')">{{ $t('personalInformation') }}
</a>
</div>
</template>
<!--基本信息-->
<div class="detail-page-scroll-content" v-show="switchValue === 'base'">
<!-- 流程信息 -->
<div class="process-part-title">{{ $t('processInformation') }}</div>
<a-form :form="processInfoForm">
<a-row>
<a-col :span="12">
<!-- 流程名称 -->
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('processName')">
<a-input :placeholder="$t('pleaseEnter') + $t('processName')"
@change="event => event.target.value = event.target.value.trim()"
:disabled="disabled || processDisabled"
:maxLength="50"
v-decorator="['prcName', validatorRules.processName]" />
</a-form-item>
</a-col>
<a-col :span="12">
<!-- 截止日期 -->
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('expirationDate')">
<a-date-picker :placeholder="$t('pleaseSelect') + $t('expirationDate')"
style="width: 100%"
:disabled="disabled || processDisabled"
value-format="YYYY-MM-DD hh:mm:ss"
v-decorator="['dueTime']" />
</a-form-item>
</a-col>
<a-col :span="24">
<!-- 流程说明 -->
<a-form-item :labelCol="longLabelCol" :wrapperCol="longWrapperCol" :label="$t('processExplain')">
<a-textarea :placeholder="$t('pleaseEnter') + $t('processExplain')"
:maxLength="500"
:rows="4"
:disabled="disabled || processDisabled"
v-decorator="['prcMes']" />
</a-form-item>
</a-col>
</a-row>
</a-form>
<!-- 业务基本信息 -->
<div class="process-part-title">{{ $t('basicServiceInformation') }}</div>
<!-- 流程表格 -->
<inspection-process-table ref="inspectionProcessTable" :current-node="currentNode" :project-id="projectId"/>
<!-- 流程审批信息 -->
<div class="process-part-title">{{ $t('processApprovalInformation') }}</div>
<a-form :form="approvalInfoForm">
<!--备注-->
<a-form-item :labelCol="longLabelCol" :wrapperCol="longWrapperCol" :label="$t('remarks')">
<a-textarea :placeholder="$t('pleaseEnter') + $t('remarks')"
:maxLength="500"
:rows="4"
v-decorator="['commitText', validatorRules.remarks]" />
</a-form-item>
<!--附件-->
<a-form-item :labelCol="longLabelCol" :wrapperCol="longWrapperCol" :label="$t('businessSupport.questionAnswer.attach')">
<j-upload v-decorator="['commitFile']" return-id />
</a-form-item>
</a-form>
</div>
<!-- 人员信息 -->
<div v-show="switchValue === 'user'" class="detail-page-scroll-content p-0">
<process-detail-list>
<template #personnelInfo>
<personnel-info ref="personnelInfo" :data="personnelInfoData" :current-node="currentNodeName" />
</template>
</process-detail-list>
</div>
<div class="detail-page-bottom-operate-box">
<!--转办-->
<a-button v-if="1 & btn" type="primary" :loading="loading" @click="handleTurnTo" ghost icon="arrow-up">{{ $t('turnTo') }}</a-button>
<!--保存-->
<a-button v-if="2 & btn" type="primary" :loading="loading" @click="handleSave" ghost><i class="iconfont icon-save" />{{ $t('preservation') }}</a-button>
<!--提交-->
<a-button v-if="4 & btn" type="primary" :loading="loading" @click="handleSubmit" icon="upload">{{ $t('submit') }}</a-button>
<!--同意-->
<a-button v-if="8 & btn" type="primary" :loading="loading" @click="handleAgree" icon="check-circle">{{ $t('agree') }}</a-button>
<!--驳回-->
<a-button v-if="16 & btn" type="primary" :loading="loading" @click="handleReject" icon="close-circle">{{ $t('reject') }}</a-button>
</div>
<!--转办选人-->
<user-select-modal ref="userSelectModal" check-required @change="continueTurnTo" />
</internal-detail-page>
</template>
<script>
import '@assets/less/common.less'
import InternalDetailPage from '@comp/InternalDetailPage'
import PersonnelInfo from '@comp/PersonnelInfo'
import ProcessDetailList from '@comp/ProcessDetailList'
import InspectionProcessTable
from '@views/workCenter/enterpriseStandardInspectionProcess/modules/InspectionProcessTable'
import UserSelectModal from '@comp/selection/UserSelectModal'
import { EsInspectionProcess, ProcessKey } from '@/enums/commonEnums'
import { WorkCenterMixin } from '@/mixins/WorkCenterMixin'
import { getInspectPlanDetail, getInspectPlanProjectId } from '@api/workCenter'
export default {
name: 'EnterpriseStandardInspectionProcess',
components: { UserSelectModal, InspectionProcessTable, PersonnelInfo, ProcessDetailList, InternalDetailPage },
mixins: [WorkCenterMixin],
data () {
return {
loading: false,
switchValue: 'base',
disabled: false,
labelCol: {
xs: { span: 24 },
sm: { span: 4 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 20 }
},
longLabelCol: {
xs: { span: 24 },
sm: { span: 2 }
},
longWrapperCol: {
xs: { span: 24 },
sm: { span: 22 }
},
// 当前流程信息
EsInspectionProcess,
info: {},
currentNode: '',
currentNodeName: '',
// 项目id
projectId: '',
btn: 0,
validatorRules: {
// 流程名称
processName: {
rules: [
{ required: true, message: this.$t('pleaseEnter') + this.$t('processName') }
],
validateTrigger: 'blur'
},
// 备注
remarks: {
rules: [
{ required: false, message: this.$t('pleaseEnter') + this.$t('remarks') }
],
validateTrigger: 'blur'
}
},
// 流程表单
processInfoForm: this.$form.createForm(this),
// 流程审批信息表单
approvalInfoForm: this.$form.createForm(this),
url: {
list: '' // 人员信息右侧表的分页查询接口
}
}
},
computed: {
pageTitle () {
return this.$t('flowCenter') + this.$route.meta.title + '' + this.nodeTitle + ''
},
// 节点标题
nodeTitle () {
return this.$route.query.taskName || EsInspectionProcess.initiate.text
},
processDisabled () {
return this.currentNode !== EsInspectionProcess.initiate.value
}
},
created () {
const { projectId, nodeId, taskName } = this.$route.query
// 发起、草稿进来没有nodeId,就默认发起节点
this.currentNode = nodeId || EsInspectionProcess.initiate.value
this.currentNodeName = taskName || EsInspectionProcess.initiate.text
this.projectId = projectId
this.btn = EsInspectionProcess.propertyOfValue('btn', this.currentNode)
// 查询人员信息
this.getPersonInfoStructure(ProcessKey.ES_INSPECTION_PROCESS.value, () => {
this.initPersonInfoData(this.currentNode === EsInspectionProcess.initiate.value)
})
// 如果是待办进来,就获取详情数据
if (this.$route.query.projectId) {
this.loadPage()
return
}
// 如果是新建进来,就获取项目id
this.getProjectId()
},
methods: {
/**
* 获取项目id
*/
getProjectId () {
this.loading = true
// 否则就是创建一个新的流程
getInspectPlanProjectId().then(res => {
if (res) {
this.projectId = res + ''
}
}).finally(() => {
this.loading = false
})
},
/**
* 获取页面详情
*/
loadPage () {
const { projectId, taskId } = this.$route.query
this.btn = EsInspectionProcess.propertyOfValue('btn', this.currentNode)
this.loading = true
getInspectPlanDetail({
projectId,
taskId
}).then(res => {
if (res.success) {
const data = res.result || {}
const processAll = data.processAll || {}
const map = data.map || {}
const processApprovalRecord = data.processApprovalRecord || {}
this.info = data
// 页面回显
this.processInfoForm && this.processInfoForm.setFieldsValue({
prcName: processAll.prcName,
dueTime: processAll.dueTime,
prcMes: processAll.prcMes
})
this.countersignForm && this.countersignForm.setFieldsValue({
pass: this.convertPass(map.pass)
})
this.approvalInfoForm && this.approvalInfoForm.setFieldsValue({
commitText: processApprovalRecord.commitText,
commitFile: processApprovalRecord.commitFile
})
}
}).finally(() => {
this.loading = false
})
},
// 获取人员信息
getPersonInfo (isValidate = true) {
let personnelObj = {}
const funName = isValidate ? 'getDataObjVerify' : 'getDataObj'
// 节点1:所有的人员信息
if (this.currentNode === EsInspectionProcess.initiate.value) {
// 人员信息的数据, 处理成对象
personnelObj = this.$refs.personnelInfo[funName]()
if (!personnelObj) {
return false
}
// List拆成数组
for (const key in personnelObj) {
if (personnelObj[key] && key.includes('List')) {
personnelObj[key] = personnelObj[key].split(',')
}
}
// 通过表格中的所属部门人员获取稽查征求意见对象
const userList = this.$refs.inspectionPlanTable.dataSource.map(item => item.objectOfConsultation.split(',')).flat(Infinity)
personnelObj.opinionFillList = Array.from(new Set(userList))
}
return personnelObj
},
// 获取页面参数
async getPageParams (isValidate = true) {
if (this.$refs.inspectionPlanTable.dataSource.length === 0) {
this.$message.warning(this.$t('addAtLeastOneRowOfData'))
throw new Error('base')
}
const params = {}
// 收集所有表单信息
let formDataList = []
if (isValidate) {
formDataList = await this.validateFormList(this.processInfoForm, this.approvalInfoForm)
} else {
formDataList = [
this.processInfoForm.getFieldsValue(),
this.approvalInfoForm.getFieldsValue()
]
}
// 收集人员信息
const getPersonInfo = this.getPersonInfo(isValidate)
if (!getPersonInfo) {
throw new Error('user')
}
// 开始处理信息
// 流程信息
params.processAll = Object.assign({}, this.info.processAll, formDataList[0], {
projectId: this.projectId,
taskId: this.$route.query.taskId
})
// 处理其他参数
params.map = Object.assign({}, getPersonInfo)
// 流程审批信息
params.processApprovalRecord = Object.assign({}, this.info.processApprovalRecord, formDataList[1], {
projectId: this.projectId
})
return params
},
/**
* 转办弹框
*/
handleTurnTo () {
this.$refs.userSelectModal.open()
},
/**
* 转办
*/
continueTurnTo (userId) {
if (this.loading) return
this.loading = true
const params = {
taskId: this.$route.query.taskId,
userId
}
Promise.resolve(params).then(res => {
if (res.success) {
this.$message.success(res.message)
this.goBack()
} else {
this.$message.warn(res.message)
}
}).finally(() => {
this.loading = false
})
},
/**
* 保存
*/
handleSave () {
if (this.loading) return
this.loading = true
this.getPageParams(false).then(res => {
console.log(res)
return Promise.resolve(res)
}).then(res => {
if (res.success) {
this.$message.success(res.message)
this.goBack()
} else {
this.$message.warn(res.message)
}
}).catch((err) => {
console.log(err)
}).finally(() => {
this.loading = false
})
},
/**
* 提交
*/
handleSubmit () {
if (this.loading) return
this.loading = true
let fn
switch (this.currentNode) {
case EsInspectionProcess.initiate.value:
fn = Promise.resolve
break
default:
fn = Promise.resolve
break
}
this.getPageParams().then(res => {
console.log(res)
return fn && fn(res)
}).then(res => {
if (res.success) {
this.$message.success(res.message)
this.goBack()
} else {
this.$message.warn(res.message)
}
}).catch((err) => {
this.switchChange(err.message)
}).finally(() => {
this.loading = false
})
},
/**
* 同意
*/
handleAgree () {
if (this.loading) return
this.loading = true
this.getPageParams().then(res => {
res.map.pass = true
return Promise.resolve(res)
}).then(res => {
if (res.success) {
this.$message.success(res.message)
this.goBack()
} else {
this.$message.warn(res.message)
}
}).catch((err) => {
this.switchChange(err.message)
}).finally(() => {
this.loading = false
})
},
/**
* 驳回
*/
handleReject () {
if (this.loading) return
this.loading = true
this.getPageParams().then(res => {
res.map.pass = false
return Promise.resolve(res)
}).then(res => {
if (res.success) {
this.$message.success(res.message)
this.goBack()
} else {
this.$message.warn(res.message)
}
}).catch((err) => {
this.switchChange(err.message)
}).finally(() => {
this.loading = false
})
},
/**
* 验证所有表单
* @param formList - 多个需要校验的表单实例
*/
validateFormList (...formList) {
const promiseList = []
for (const form of formList) {
promiseList.push(
new Promise((resolve, reject) => {
form.validateFields((err, val) => {
if (!err) {
resolve(val)
} else {
reject(err)
}
})
})
)
}
return Promise.all(promiseList).catch(() => {
throw new Error('base')
})
}
}
}
</script>
<style scoped>
</style>