321 lines
10 KiB
Vue
321 lines
10 KiB
Vue
<template>
|
||
<j-modal
|
||
:title="title"
|
||
:width="width"
|
||
:visible="visible"
|
||
:confirmLoading="confirmLoading"
|
||
switchFullscreen
|
||
@ok="handleOk"
|
||
@cancel="handleCancel"
|
||
cancelText="关闭">
|
||
<a-spin :spinning="confirmLoading">
|
||
<span class="prompt-message">
|
||
说明:1.负责人A为该起草组的主负责人,负责人B为该起草组的辅助负责人。<br>
|
||
</span>
|
||
<a-form :form="form">
|
||
<a-row>
|
||
<a-col :span="24">
|
||
<a-form-item label="起草组项目" :labelCol="remarksLabelCol" :wrapperCol="remarksWrapperCol">
|
||
<a-input placeholder="请输入起草组项目"
|
||
v-decorator="['workingGroupProject',validatorRules.workingGroupProject]"
|
||
:maxLength='50'
|
||
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
|
||
</a-form-item>
|
||
</a-col>
|
||
</a-row>
|
||
<a-row>
|
||
<a-col :span="24">
|
||
<a-form-item label="关联工作组" :labelCol="remarksLabelCol" :wrapperCol="remarksWrapperCol">
|
||
<a-select
|
||
placeholder="请选择关联工作组"
|
||
show-search
|
||
v-decorator="['workingGroupId',validatorRules.workingGroupId]"
|
||
:filter-option="filterOption"
|
||
>
|
||
<a-select-option v-for="item in workingGroupList" :key="item.id" :value="item.id">
|
||
{{ item.workingGroupProject }}
|
||
</a-select-option>
|
||
</a-select>
|
||
</a-form-item>
|
||
</a-col>
|
||
</a-row>
|
||
<a-row>
|
||
<a-col :span="12">
|
||
<a-form-item label="运行年份" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||
<j-year-date style="width:100%" placeholder="请选择运行年份"
|
||
v-decorator="['year',validatorRules.year]"></j-year-date>
|
||
</a-form-item>
|
||
</a-col>
|
||
</a-row>
|
||
<a-row>
|
||
<a-col :span="12">
|
||
<a-form-item label="负责人A" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||
<select-principal placeholder="请选择负责人A"
|
||
v-decorator="['principalIdA',validatorRules.principalIdA]"
|
||
:maxLength='50'></select-principal>
|
||
</a-form-item>
|
||
</a-col>
|
||
<a-col :span="12">
|
||
<a-form-item label="负责人B" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||
<select-principal placeholder="请选择负责人B"
|
||
v-decorator="['principalIdB',validatorRules.principalIdB]"
|
||
:maxLength='50'></select-principal>
|
||
</a-form-item>
|
||
</a-col>
|
||
</a-row>
|
||
<a-row>
|
||
<a-col :span="12">
|
||
<a-form-item label="每年召开次数" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||
<a-input placeholder="请输入每年召开次数"
|
||
v-decorator="['convokeNum']"
|
||
:maxLength='50'
|
||
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
|
||
</a-form-item>
|
||
</a-col>
|
||
<a-col :span="12">
|
||
<a-form-item label="运行周期" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||
<a-input placeholder="请输入运行周期"
|
||
v-decorator="['operationCycle']"
|
||
:maxLength='50'
|
||
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
|
||
</a-form-item>
|
||
</a-col>
|
||
</a-row>
|
||
<a-row>
|
||
<a-col>
|
||
<a-form-item label="任务及目标" :labelCol="remarksLabelCol" :wrapperCol="remarksWrapperCol">
|
||
<a-textarea
|
||
placeholder="请输入任务及目标"
|
||
:auto-size="{ minRows: 3, maxRows: 6 }"
|
||
v-decorator="['missionAndObjectives']"
|
||
:maxLength='200'
|
||
@change="e => {e.target.value = (e.target.value + '').trim()}"/>
|
||
</a-form-item>
|
||
</a-col>
|
||
</a-row>
|
||
<a-row>
|
||
<a-col>
|
||
<a-form-item label="备注" :labelCol="remarksLabelCol" :wrapperCol="remarksWrapperCol">
|
||
<a-textarea
|
||
placeholder="请输入备注"
|
||
:auto-size="{ minRows: 3, maxRows: 6 }"
|
||
v-decorator="['remarks']"
|
||
:maxLength='200'
|
||
@change="e => {e.target.value = (e.target.value + '').trim()}"/>
|
||
</a-form-item>
|
||
</a-col>
|
||
</a-row>
|
||
</a-form>
|
||
</a-spin>
|
||
</j-modal>
|
||
</template>
|
||
|
||
<script>
|
||
import pick from 'lodash.pick'
|
||
import { httpAction } from '@api/manage'
|
||
import JUpload from '@comp/jero/JUpload'
|
||
import JYearDate from '@comp/jero/JYearDate'
|
||
import SelectPrincipal from '@comp/company/SelectPrincipal'
|
||
import { isRepeat } from '../../../utils/util'
|
||
import { money } from '../../../utils/validate'
|
||
import { addZero } from '../../../utils/util'
|
||
import {getAllWorkProjects} from '@api/incomeMeetingApi'
|
||
|
||
export default {
|
||
name: 'DraftingGroupModule',
|
||
components: { JUpload, JYearDate, SelectPrincipal },
|
||
data() {
|
||
return {
|
||
title: '操作',
|
||
width: 800,
|
||
visible: false,
|
||
confirmLoading: false,
|
||
form: this.$form.createForm(this),
|
||
model: {},
|
||
labelCol: {
|
||
xs: { span: 24 },
|
||
sm: { span: 6 }
|
||
},
|
||
wrapperCol: {
|
||
xs: { span: 24 },
|
||
sm: { span: 18 }
|
||
},
|
||
remarksLabelCol: {
|
||
xs: { span: 24 },
|
||
sm: { span: 3 }
|
||
},
|
||
remarksWrapperCol: {
|
||
xs: { span: 24 },
|
||
sm: { span: 21 }
|
||
},
|
||
validatorRules: {
|
||
workingGroupProject: {
|
||
rules: [{ required: true, message: '请输入项目名称' }],
|
||
validateTrigger: 'blur'
|
||
},
|
||
workingGroupId: {
|
||
rules: [{ required: true, message: '请选择关联工作组' }],
|
||
validateTrigger: 'change'
|
||
},
|
||
year: {
|
||
rules: [{ required: true, message: '请选择运行年份' }],
|
||
validateTrigger: 'change'
|
||
},
|
||
principalIdA: {
|
||
rules: [{ required: true, validator: this.validatePrincipal }],
|
||
validateTrigger: 'change'
|
||
},
|
||
principalIdB: {
|
||
rules: [{ required: false, validator: this.validatePrincipal }],
|
||
validateTrigger: 'change'
|
||
},
|
||
checkMoney: {
|
||
rules: [{ required: false, validator: this.checkMoney }],
|
||
validateTrigger: 'blur'
|
||
}
|
||
},
|
||
url: {
|
||
add: '/project/payWorkingGroup/add',
|
||
edit: '/project/payWorkingGroup/edit'
|
||
},
|
||
// 工作组下拉列表
|
||
workingGroupList: [],
|
||
}
|
||
},
|
||
methods: {
|
||
addZero,
|
||
add() {
|
||
this.edit({})
|
||
},
|
||
edit(record) {
|
||
// 获取工作组下拉列表
|
||
this.loadWorkingGroupList()
|
||
this.form.resetFields()
|
||
// 防止下拉选项出现问题
|
||
record.principalIdA = record.principalIdA || undefined
|
||
record.principalIdB = record.principalIdB || undefined
|
||
this.model = Object.assign({}, record)
|
||
this.visible = true
|
||
this.$nextTick(() => {
|
||
this.form.setFieldsValue(pick(this.model, 'workingGroupProject', 'year', 'principalIdA', 'principalIdB', 'convokeNum', 'operationCycle', 'yearChargeA', 'chargeNoticeNoA', 'chargeNoticeAId', 'yearChargeB', 'chargeNoticeNoB', 'chargeNoticeBId', 'missionAndObjectives', 'remarks'))
|
||
if (!this.model.id) {
|
||
this.form.setFieldsValue({'year': (new Date().getFullYear()).toString()})
|
||
}
|
||
})
|
||
},
|
||
// 获取工作组下拉列表
|
||
loadWorkingGroupList () {
|
||
getAllWorkProjects().then(res => {
|
||
if (res.success) {
|
||
this.workingGroupList = res.result || []
|
||
}
|
||
})
|
||
},
|
||
close() {
|
||
this.$emit('close')
|
||
this.visible = false
|
||
},
|
||
handleOk() {
|
||
if (this.confirmLoading) {
|
||
return
|
||
}
|
||
this.confirmLoading = true
|
||
const that = this
|
||
// 触发表单验证
|
||
this.form.validateFields((err, values) => {
|
||
if (!err) {
|
||
that.confirmLoading = true
|
||
let httpurl = ''
|
||
let method = 'post'
|
||
if (!this.model.id) {
|
||
httpurl += this.url.add
|
||
} else {
|
||
httpurl += this.url.edit
|
||
}
|
||
values.yearChargeA = values.yearChargeA ? Number(values.yearChargeA) : null
|
||
values.yearChargeB = values.yearChargeB ? Number(values.yearChargeB) : null
|
||
values.chargeA = values.chargeNoticeNoA ? 'a' : null
|
||
values.chargeB = values.chargeNoticeNoB ? 'b' : null
|
||
const formData = Object.assign(this.model, values)
|
||
console.log('表单提交数据', formData)
|
||
httpAction(httpurl, formData, method).then((res) => {
|
||
if (res.success) {
|
||
that.$message.success(res.message)
|
||
that.$emit('ok')
|
||
that.close()
|
||
} else {
|
||
that.$message.warning(res.message)
|
||
}
|
||
}).finally(() => {
|
||
setTimeout(() => {
|
||
this.confirmLoading = false
|
||
}, 1000)
|
||
})
|
||
} else {
|
||
this.confirmLoading = false
|
||
}
|
||
})
|
||
},
|
||
// 下拉框的搜索
|
||
filterOption(input, option) {
|
||
return (
|
||
option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
||
)
|
||
},
|
||
handleCancel() {
|
||
this.close()
|
||
},
|
||
/**
|
||
* 校验负责人是否重复
|
||
* @param rule
|
||
* @param value
|
||
* @param callback
|
||
*/
|
||
validatePrincipal(rule, value, callback) {
|
||
if (rule.field === 'principalIdA') {
|
||
if (!value) {
|
||
callback('请选择负责人A')
|
||
}
|
||
}
|
||
if (value) {
|
||
const principalObj = this.form.getFieldsValue(['principalIdA', 'principalIdB'])
|
||
const principalArr = Object.values(principalObj)
|
||
principalArr.filter(tt => tt !== undefined)
|
||
if (isRepeat(principalArr)) {
|
||
callback('请选择不同的负责人')
|
||
} else {
|
||
callback()
|
||
}
|
||
return
|
||
}
|
||
callback()
|
||
},
|
||
/**
|
||
* 校验金额格式
|
||
* @param rules
|
||
* @param value
|
||
* @param callback
|
||
*/
|
||
checkMoney(rules, value, callback) {
|
||
if (value) {
|
||
if (money(value)) {
|
||
callback()
|
||
return
|
||
}
|
||
callback('请输入合法的金额数字,最多2位小数,10位整数')
|
||
}
|
||
callback()
|
||
},
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style scoped lang="less">
|
||
.prompt-message {
|
||
color: red;
|
||
|
||
&-line2 {
|
||
padding-left: 2.7rem;
|
||
}
|
||
}
|
||
</style> |