马宇豪
2025-03-07 db905ecd14f63dba9337b4f4715584ef2d7e8c7e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<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";
 
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) {
      getNotCoalPayCategory({categoryType: type,districtCode: this.dataForm.districtCode?this.dataForm.districtCode:''}).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.nonCoalPayCategoryList = [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.nonCoalPayCategoryList = [this.transFormObj(this.dealList.find(i=>i.id == this.dataForm.dealId))]
            }else{
              this.dataForm.nonCoalPayCategoryList = [this.transFormObj(this.operationList.find(i=>i.id == this.dataForm.operateId))]
            }
            this.dataForm.amount = this.dataForm.nonCoalPayCategoryList.map(i=>i.categoryAmount).reduce((acc, current) => acc + current, 0)
            const {dealId, operateId, ...data} = this.dataForm
            const res = await addNonCoalPay(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,
        categoryId: obj.id
      }
    },
 
    resetDataForm(info) {
      this.dataForm = {
        payPersonType: 1,
        districtCode: info.district.districtCode,
        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>