<template>
|
<el-dialog
|
:title="dialogStatus==='add'?'新增':'编辑'"
|
:visible.sync="dialogVisible"
|
:modal-append-to-body="false"
|
:close-on-click-modal="false"
|
width="700px"
|
:before-close="handleClose"
|
>
|
<div class="infoTitle">
|
<div>组织架构名称:<span style="font-weight: bolder">{{deptName}}</span></div>
|
<!-- <div style="margin-left: 15px">管辖行政区划:<span style="font-weight: bolder">{{districtName}}</span></div>-->
|
</div>
|
<el-form ref="dataForm" :model="dataForm" :rules="rules" label-position="right" label-width="150px" style="padding-right: 50px" element-loading-text="保存中...">
|
<el-form-item label="批次名称:" prop="batchName">
|
<el-input v-model.trim="dataForm.batchName"/>
|
</el-form-item>
|
<!-- <el-form-item label="所属区划:" prop="districtCode">-->
|
<!-- <el-select v-model="dataForm.districtCode" placeholder="行政区划" @change="getNewCategoryList">-->
|
<!-- <el-option-->
|
<!-- v-for="item in areaList"-->
|
<!-- :key="item.id"-->
|
<!-- :label="item.name"-->
|
<!-- :value="item.code">-->
|
<!-- </el-option>-->
|
<!-- </el-select>-->
|
<!-- </el-form-item>-->
|
<!-- <el-form-item label="考试点:" prop="deptId">-->
|
<!-- <el-select v-model="dataForm.deptId" size="small" placeholder="请选择考试点">-->
|
<!-- <el-option-->
|
<!-- v-for="item in examList"-->
|
<!-- :key="item.siteId"-->
|
<!-- :label="item.siteName"-->
|
<!-- :value="item.siteId">-->
|
<!-- </el-option>-->
|
<!-- </el-select>-->
|
<!-- </el-form-item>-->
|
<el-form-item label="所属缴费周期:" prop="year">
|
<div style="display: flex">
|
<el-date-picker
|
v-model="dataForm.year"
|
type="year"
|
value-format="yyyy"
|
placeholder="选择年">
|
</el-date-picker>
|
<el-select v-model="dataForm.quarter" placeholder="请选择季度" style="width: 150px;margin-left: 5px" clearable>
|
<el-option
|
v-for="item in quarterList"
|
:key="item.id"
|
:label="item.label"
|
:value="item.id">
|
</el-option>
|
</el-select>
|
</div>
|
</el-form-item>
|
<el-form-item label="缴费类型:" prop="payType">
|
<el-radio-group v-model="dataForm.payType" @change="changeRadio" v-removeAriaHidden>
|
<el-radio
|
v-for="item in payTypeList"
|
:key="item.id"
|
:label="item.id"
|
>{{item.label}}</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
<el-form-item v-if="dataForm.payType === 1 || dataForm.payType === 3 || dataForm.payType === 4" label="理论类别:" prop="dealId">
|
<el-select v-model="dataForm.dealId" placeholder="请选择" style="width: 100%" clearable>
|
<el-option
|
v-for="item in dealList"
|
:key="item.id"
|
:label="item.subjectName"
|
:value="item.id">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item v-if="dataForm.payType === 2 || dataForm.payType === 3" label="实操类别:" prop="operateId">
|
<el-select v-model="dataForm.operateId" placeholder="请选择" style="width: 100%" clearable>
|
<el-option
|
v-for="item in operationList"
|
:key="item.id"
|
:label="item.subjectName"
|
:value="item.id">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-form>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="handleClose">取 消</el-button>
|
<el-button type="primary" @click="onSubmit">确 定</el-button>
|
</span>
|
</el-dialog>
|
</template>
|
|
<script >
|
import { addPlat, updatePlat } from '@/api/onlineEducation/plat'
|
import {addNonCoalPay, getNotCoalPayCategory} from "@/api/specialOperationsPay/notCoalPay";
|
import store from "@/store";
|
import {addCoalPay, getCoalPayCategory} from "@/api/specialOperationsPay/coalPay";
|
|
export default {
|
name: 'addUser',
|
components: {
|
},
|
data() {
|
return {
|
dialogVisible: false,
|
dialogStatus: '',
|
deptName: '',
|
districtName: '',
|
rules: {
|
batchName: [{ required: true, message: '请输入批次名称', trigger: 'blur' }],
|
year: [{ required: true, message: '请选择缴费周期', trigger: 'blur' }],
|
quarter: [{ required: true, message: '请选择缴费周期', trigger: 'blur' }],
|
payType: [{ required: true, message: '请选择季度', trigger: 'blur' }],
|
operateId: [{ required: true, message: '请选择实操类别', trigger: 'blur' }],
|
dealId: [{ required: true, message: '请选择理论类别', trigger: 'blur' }],
|
},
|
dataForm: {},
|
areaList: [],
|
examList: [],
|
quarterList: [
|
{
|
id: 1,
|
label: '第一季度'
|
},
|
{
|
id: 2,
|
label: '第二季度'
|
},
|
{
|
id: 3,
|
label: '第三季度'
|
},
|
{
|
id: 4,
|
label: '第四季度'
|
},
|
],
|
payTypeList: [
|
{
|
id: 1,
|
label: '初训理论'
|
},
|
{
|
id: 2,
|
label: '初训实操'
|
},
|
{
|
id: 3,
|
label: '初训理论与实操'
|
},
|
{
|
id: 4,
|
label: '复训理论'
|
},
|
],
|
dealList: [],
|
operationList: []
|
}
|
},
|
created() {
|
|
},
|
methods: {
|
openDialog (type, data, areaList, examList) {
|
const userInfo = store.getters && store.getters.userInfo
|
this.deptName = userInfo.dept.deptName
|
this.districtName = userInfo.district.districtName
|
this.resetDataForm(userInfo)
|
this.areaList = areaList
|
this.examList = examList
|
this.dialogVisible = true
|
this.dialogStatus = type
|
if(this.dialogStatus == 'edit') {
|
this.dataForm = data;
|
}
|
this.$nextTick(() => {
|
this.$refs['dataForm'].clearValidate()
|
})
|
},
|
getCateGoryList(type) {
|
getCoalPayCategory({categoryType: type,pageNum: 1, pageSize: 999}).then((res) => {
|
if (res.code == 200) {
|
if(type == 1){
|
this.dealList = res.rows.map(i=>{
|
i.subjectName = i.subjectName + ' ('+ i.amount +'元)'
|
return i
|
})
|
}else{
|
this.operationList = res.rows.map(i=>{
|
i.subjectName = i.subjectName + ' ('+ i.amount +'元)'
|
return i
|
})
|
}
|
}
|
})
|
},
|
|
// getNewCategoryList(val){
|
// if(this.dataForm.payType){
|
// this.changeRadio(this.dataForm.payType)
|
// }
|
// },
|
|
changeRadio(val){
|
if(val ==3){
|
this.getCateGoryList(1)
|
this.getCateGoryList(2)
|
}else if(val == 1 || val == 4){
|
this.getCateGoryList(1)
|
}else{
|
this.getCateGoryList(2)
|
}
|
this.dataForm.dealId = null
|
this.dataForm.operateId = null
|
},
|
handleClose() {
|
this.dialogVisible = false;
|
this.$emit("getList");
|
},
|
onSubmit() {
|
this.$refs["dataForm"].validate( async valid => {
|
if (valid) {
|
if(this.dialogStatus == 'add'){
|
if(this.dataForm.payType == 3){
|
this.dataForm.coalPayCategoryies = [this.transFormObj(this.dealList.find(i=>i.id == this.dataForm.dealId)),this.transFormObj(this.operationList.find(i=>i.id == this.dataForm.operateId))]
|
}else if(this.dataForm.payType == 1 || this.dataForm.payType == 4){
|
this.dataForm.coalPayCategoryies = [this.transFormObj(this.dealList.find(i=>i.id == this.dataForm.dealId))]
|
}else{
|
this.dataForm.coalPayCategoryies = [this.transFormObj(this.operationList.find(i=>i.id == this.dataForm.operateId))]
|
}
|
this.dataForm.amount = this.dataForm.coalPayCategoryies.map(i=>i.categoryAmount).reduce((acc, current) => acc + current, 0)
|
this.dataForm.coalPayCategoryies = this.dataForm.coalPayCategoryies.map(({categoryType,coalCategoryId})=>{return {categoryType,coalCategoryId}})
|
console.log(this.dataForm.coalPayCategoryies)
|
const {dealId, operateId,payPersonType,...data} = this.dataForm
|
const res = await addCoalPay(data);
|
if(res.code == 200) {
|
this.$emit("getList");
|
this.dialogVisible = false;
|
this.$message({
|
type:'success',
|
message: '新增成功'
|
})
|
}else{
|
this.$message({
|
type:'warning',
|
message: res.msg
|
})
|
}
|
}else {
|
// const res = await updatePlat(this.dataForm);
|
// if(res.code == 200) {
|
// this.$emit("getList");
|
// this.dialogVisible = false;
|
// this.$message({
|
// type:'success',
|
// message: '编辑成功'
|
// })
|
// }else{
|
// this.$message({
|
// type:'warning',
|
// message: res.msg
|
// })
|
// }
|
}
|
}
|
})
|
|
},
|
|
transFormObj(obj){
|
return {
|
categoryAmount: obj.amount,
|
categoryType: obj.categoryType,
|
coalCategoryId: obj.id
|
}
|
},
|
|
resetDataForm(info) {
|
this.dataForm = {
|
payPersonType: 1,
|
deptId: info.dept.deptId,
|
dealId: null,
|
operateId: null
|
}
|
},
|
}
|
}
|
|
</script>
|
<style scoped>
|
.infoTitle{
|
margin-top:-10px;
|
margin-bottom:20px;
|
display: flex;
|
justify-content: space-around;
|
font-size: 16px
|
}
|
|
</style>
|