jiangping
2025-06-16 790008cbfc63dcd4ed545013335d44c33c859575
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
<template>
    <GlobalWindow
        :title="title"
        width="100%"
        :visible.sync="visible"
        :confirm-working="isWorking"
        @confirm="confirm"
    >
      <div>
        <el-form :model="form" ref="form" :rules="rules">
        <el-tabs type="border-card"    :before-leave="beforeTabClick"  v-model="form.saveType">
          <el-tab-pane label="方案基础信息" name="0">
            <el-form-item label="方案名称" prop="name">
              <el-input v-model="form.name" placeholder="请输入" v-trim/>
            </el-form-item>
            <el-form-item label="保险公司" prop="insuranceId">
              <el-select v-model="form.insuranceId" filterable @change="getAllWorktype1" placeholder="请选择">
                <el-option
                    v-for="item in company"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="承保公司" prop="companyName">
              <el-input v-model="form.companyName" placeholder="请输入" v-trim/>
            </el-form-item>
            <el-form-item label="投保年龄" required="true" >
              <div style="display: flex; align-items: center;">
                <el-form-item label="" prop="minAge" style="flex: 1;">
                <el-select v-model="form.minAge" @change="changeMinAge" style="flex: 1;" placeholder="请选择">
                  <el-option
                      v-for="item in 80"
                      :key="item"
                      :label="item"
                      :value="item">
                  </el-option>
                </el-select>
                </el-form-item>
                <span style="margin: 0 30px;padding-bottom: 20px;">至</span>
                <el-form-item label="" prop="maxAge" style="flex: 1;">
                <el-select v-model="form.maxAge" @change="changeMaxAge"  placeholder="请选择">
                  <el-option
                      v-for="item in 80"
                      :key="item"
                      :label="item"
                      :value="item">
                  </el-option>
                </el-select>
                </el-form-item>
              </div>
            </el-form-item>
            <el-form-item label="生效时间" prop="validTypeNum">
              <div style="width: 100%; display: flex; align-items: center;">
                <div style="flex-shrink: 0;">
                  <el-radio-group v-model="form.validType" @change="changeValidType">
                    <el-radio :label="0">日后生效</el-radio>
                    <el-radio :label="1">次月生效</el-radio>
                  </el-radio-group>
                </div>
                <el-input style="margin-left: 20px;" type="number" v-model="form.validTypeNum"   placeholder="请输入延迟天数" v-if="form.validType === 0"></el-input>
              </div>
            </el-form-item>
<!--            <el-form-item label="批改支持" prop="canAdd">
              <div style="width: 100%; display: flex; align-items: center;">
                <el-checkbox :true-label="1" :false-label="0" v-model="form.canAdd">加保</el-checkbox>
                <el-checkbox :true-label="1" :false-label="0" v-model="form.canReduce">减保</el-checkbox>
                <el-checkbox :true-label="1" :false-label="0" v-model="form.canChangeUnit">更换派遣单位</el-checkbox>
              </div>
            </el-form-item>
            <el-form-item label="批减仅支持替换(减保批改仅支持替换人员即减保人员少于加保人员)" prop="delOnlyReplace">
              <div style="width: 100%; display: flex; align-items: center;">
                <el-radio-group v-model="form.delOnlyReplace">
                  <el-radio :label="1">是</el-radio>
                  <el-radio :label="0">否</el-radio>
                </el-radio-group>
              </div>
            </el-form-item>-->
            <el-form-item label="批增生效(天数)" prop="addValidDays" v-if="form.delOnlyReplace != 1">
              <div style="width: 100%; display: flex; align-items: center;">
                <el-input style="margin-left: 0px;" type="number" v-model="form.addValidDays"   placeholder="请输入批增生效时间(天数)" ></el-input>
              </div>
            </el-form-item>
            <el-form-item label="批减生效(天数)" prop="delValidDays">
              <div style="width: 100%; display: flex; align-items: center;">
                <el-input style="margin-left: 0px;" type="number" v-model="form.delValidDays"   placeholder="请输入批减生效时间(天数)" ></el-input>
              </div>
            </el-form-item>
            <el-form-item label="批改提醒时间" prop="correctWarnTime">
              <el-time-picker
                  value-format="HH:mm"
                  v-model="form.correctWarnTime"
                  placeholder="请选择批改提醒时间">
              </el-time-picker>
            </el-form-item>
            <div style="width: 100%; padding: 10px; box-sizing: border-box; border: 1px solid #ececec;">
              <div style="display: flex; align-items: center; margin-bottom: 10px;">
                <el-select filterable multiple style="width: 800px;" v-model="worktypeId" placeholder="请选择">
                  <el-option
                      v-for="item in typeWorkCopy"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id">
                  </el-option>
                </el-select>
                <el-button type="primary" @click="add" :disabled="worktypeId.length === 0" style="margin-left: 10px;">添加工种</el-button>
                <el-button type="primary" @click="impor">导入工种</el-button>
                <el-button type="text" @click="exprot">导入模版xls</el-button>
              </div>
              <el-form-item label="已添加工种" prop="worktypeIdList">
                <u-table
                    :data="form.worktypeIdList"
                    border
                    use-virtual
                    style="width: 100%; margin-bottom: 20px;">
                  <u-table-column
                      label="序号"
                      width="80">
                    <template slot-scope="scope">
                      <span>{{scope.$index + 1}}</span>
                    </template>
                  </u-table-column>
                  <u-table-column
                      prop="worktypeName"
                      label="所属工种">
                  </u-table-column>
                  <u-table-column
                      label="操作"
                      width="100">
                    <template slot-scope="scope">
                      <el-button type="text" size="small" style="color: red;" @click="dele(scope.$index)">删除</el-button>
                    </template>
                  </u-table-column>
                </u-table>
              </el-form-item>
            </div>
            <el-form-item label="特别约定" prop="specialAgreement">
              <RichEditor :richData="form.specialAgreement" :styleEditor="'border: 1px solid #ccc;display: inline-block;'" @getWangedditor="getWangedditor" :readonly="false"/>
            </el-form-item>
            <el-form-item label="特别说明" prop="specialInfo">
              <RichEditor :richData="form.specialInfo" :styleEditor="'border: 1px solid #ccc;display: inline-block;'" @getWangedditor="getWangedditor1" :readonly="false"/>
            </el-form-item>
            <el-form-item label="其他说明" prop="ortherInfo">
              <RichEditor :richData="form.ortherInfo" :styleEditor="'border: 1px solid #ccc;display: inline-block;'" @getWangedditor="getWangedditor2" :readonly="false"/>
            </el-form-item>
          </el-tab-pane>
          <el-tab-pane label="风险设置" name="1" >
            <el-form-item label="风险设置" prop="risk">
              <div class="tx">
                <div class="tx_item">
                  <div class="tx_item_head">
                    <span>延迟报案提醒</span>
                    <el-switch :active-value="1" :inactive-value="0" v-model="form.riskDelayStatus"></el-switch>
                  </div>
                  <div class="tx_item_content">
                    <span>规则设置:当报案时间超过案发时间</span>
                    <el-input-number style="margin: 0 15px;" :disabled="form.riskDelayStatus === 0" v-model="form.riskDelayTime" :min="1"></el-input-number>
                    <el-select v-model="form.riskDelayUnit" :disabled="form.riskDelayStatus === 0" style="width: 100px; margin-right: 15px;" placeholder="请选择">
                      <el-option label="分钟" :value="0"></el-option>
                      <el-option label="小时" :value="1"></el-option>
                      <el-option label="天" :value="2"></el-option>
                    </el-select>
                    <span>时,进行提醒。</span>
                  </div>
                </div>
                <div class="tx_item">
                  <div class="tx_item_head">
                    <span>允许对新员工已投保未生效保险进行保障</span>
                    <el-switch :active-value="1" :inactive-value="0" v-model="form.riskNewUserStatus"></el-switch>
                  </div>
                  <div class="tx_item_content">
                    <span>规则设置:允许出险时间在保单生效前</span>
                    <el-input-number style="margin: 0 15px;" :disabled="form.riskNewUserStatus === 0"   v-model="form.riskNewUserTime" :min="1"></el-input-number>
                    <el-select v-model="form.riskNewUserUnit"  :disabled="form.riskNewUserStatus === 0"  style="width: 100px; margin-right: 15px;" placeholder="请选择">
                      <el-option label="小时" :value="1"></el-option>
                      <el-option label="天" :value="2"></el-option>
                    </el-select>
                  </div>
                </div>
              </div>
            </el-form-item>
          </el-tab-pane>
        </el-tabs>
        </el-form>
        <!--    上传工种    -->
        <input type="file" @change="getFile" style="opacity: 0;" ref="upload" accept=".xlsx" />
      </div>
    </GlobalWindow>
</template>
 
<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
import { all } from '@/api/business/insurance'
import { all as allWorktype, importExcelForSolution } from '@/api/business/worktype'
import { solutionsBaseId } from '@/api/business/solutionsBase'
import { pageAll as shopList } from '@/api/business/company'
import UploadFile from '@/components/common/UploadFile'
import { numRule } from '@/utils/form'
import RichEditor from '@/components/common/RichEditor'
import { UTable, UTableColumn } from 'umy-ui'
import {getChangeMemberListOnlineSignLink} from "@/api/business/applyChange";
export default {
  name: 'OperaSolutionsBaseWindow',
  extends: BaseOpera,
  components: { GlobalWindow, UploadFile, RichEditor, UTable, UTableColumn },
  data () {
    var validatorWorktype = (rule, value, callback) => {
      if (!this.form.worktypeIdList || this.form.worktypeIdList.length === 0) {
        callback(new Error('请完善工种信息!'));
      } else {
        callback();
      }
    };
    var validType = (rule, value, callback) => {
      if (this.form.validType === 0 && !value) {
        return callback(new Error('延迟天数不能为空'))
      } else if (this.form.validType === 0 && !/^[0-9]*[1-9][0-9]*$/.test(value)) {
        return callback(new Error('延迟天数只能为正整数'))
      }
      callback()
    }
    var canAddFun = (rule, value, callback) => {
      if (!this.form.canAdd && !this.form.canReduce && !this.form.canChangeUnit) {
        return callback(new Error('批改支持不能为空'))
      }
      callback()
    }
    var riskRule = (rule, value, callback) => {
      if (this.form.riskDelayStatus === '1') {
        if (!this.form.riskDelayTime || !this.form.riskDelayUnit) {
          return callback(new Error('请完善内容'))
        }
      }
      if (this.form.riskNewUserStatus === '1') {
        if (!this.form.riskNewUserTime || !this.form.riskNewUserUnit) {
          return callback(new Error('请完善内容'))
        }
      }
      callback()
    }
    return {
      // 表单数据
      form: {
        id: null,
        name: '',
        companyName: '',
        insuranceId: '',
        validType: 0,
        minAge: '',
        maxAge: '',
        specialAgreement: '',
        specialInfo: '',
        ortherInfo: '',
        validTypeNum: '',
        canAdd: 0,
        canReduce: 0,
        canChangeUnit: 0,
        delOnlyReplace: 0,
        addValidDays: 0,
        delValidDays: 0,
        saveType: '0',
        correctWarnTime: '',
        worktypeIdList: [],
 
        riskDelayStatus: 0,
        riskDelayTime: 1,
        riskDelayUnit: 0,
        riskNewUserStatus: 0,
        riskNewUserTime: 1,
        riskNewUserUnit: 1
      },
      value: '',
      options: [],
      worktypeId: [],
      // 验证规则
      rules: {
        name: [
          { required: true, message: '请输入方案名称' }
        ],
        delOnlyReplace: [
          { required: true, message: '请选择' }
        ],
        addValidDays: [
          { required: true, validator: numRule }
        ],
        delValidDays: [
          { required: true, validator: numRule }
        ],
        risk: [
          { required: true, validator: riskRule }
        ],
        insuranceId: [
          { required: true, message: '请选择保险公司' }
        ],
        companyName: [
          { required: true, message: '请输入承保公司' }
        ],
        minAge: [
          { required: true, message: '请选择投保最小年龄' }
        ],
        maxAge: [
          { required: true, message: '请选择投保最大年龄' }
        ],
        validTypeNum: [
          { required: true, validator: validType }
        ],
        correctWarnTime: [
          { required: true, message: '请输入批改提醒时间' }
        ],
        worktypeIdList: [
          { required: true, validator: validatorWorktype }
        ],
        // canAdd: [
        //   { required: true, validator: canAddFun }
        // ]
      },
      shops: [],
      company: [],
      typeWork: [],
      typeWorkCopy: []
    }
  },
  created () {
    this.config({
      api: '/business/solutionsBase',
      'field.id': 'id'
    })
  },
  methods: {
    beforeTabClick(n,o){
      let re = true
      if( !this.form.id && n === '1'){
        this.$refs.form.validate((valid) => {
          if (!valid) {
            re = false
          }
          this.form.saveType = n
        })
      }
      return re
    },
    // 导入工种模板
    getFile (e) {
      const formdate = new FormData()
      formdate.append('file', e.target.files[0])
      formdate.append('insuranceId', this.form.insuranceId)
      importExcelForSolution(formdate)
        .then(res => {
          const arr = []
          res.forEach(item => {
            arr.push({ worktypeId: item.id, worktypeName: item.name })
          })
          this.form.worktypeIdList = [...arr, ...this.form.worktypeIdList]
          this.$refs.form.validate()
          const valData = this.form.worktypeIdList.map(item => item.worktypeName)
          this.typeWorkCopy = this.typeWorkCopy.filter(item => !valData.includes(item.name))
          this.$refs.form.validate()
        })
        .catch(err => {
          this.$message.error(err.message)
        })
        .finally(() => {
          this.$refs.upload.value = null
        })
    },
    impor () {
      if (!this.form.insuranceId) return this.$message.warning('请先选择保险公司')
      this.$refs.upload.click()
    },
    // 导出模板
    exprot () {
      window.open(process.env.VUE_APP_TYPEWORK_URL)
    },
    getWangedditor (val) {
      this.form.specialAgreement = val
    },
    getWangedditor1 (val) {
      this.form.specialInfo = val
    },
    getWangedditor2 (val) {
      this.form.ortherInfo = val
    },
    changeMinAge (e) {
      if (this.form.maxAge && this.form.maxAge >= 0 && e > this.form.maxAge) {
        this.form.minAge = ''
        this.$message.warning('起始年龄不能大于截止年龄!')
      }
    },
    changeMaxAge (e) {
      if (this.form.minAge && this.form.minAge >= 0 && e < this.form.minAge) {
        this.form.maxAge = ''
        this.$message.warning('截止年龄不能大于起始年龄!')
      }
    },
    handNumberInput (value) {
      const regex = /^[-+]?\d*$/
      if (!regex.test(value)) {
        // 如果输入的不是整数,则设置为上一个有效的整数值
        this.form.addValidDays = value.replace(/[^0-9]/g, '')
        this.form.addValidDays = value.replace(/[^0-9]/g, '')
        this.form.delValidDays = value.replace(/[^0-9]/g, '')
      }
    },
    // 切换公司
    getAllWorktype1 () {
      this.form.worktypeIdList = []
      this.getAllWorktype()
    },
    changeValidType (e) {
      if (e === 1) {
        this.form.validTypeNum = 0
      } else {
        this.form.validTypeNum = ''
      }
    },
    // 确认新建/修改
    confirm () {
      const data = JSON.parse(JSON.stringify(this.form))
      data.worktypeIdList = data.worktypeIdList.map(item => item.worktypeId)
      this.$refs.form.validate((valid) => {
        if (!valid) {
          return
        }
        // 调用新建接口
        this.isWorking = true
        if (data.id == null || data.id === '') {
          this.api.create(data)
            .then(() => {
              this.visible = false
              this.$tip.apiSuccess('新建成功')
              this.$emit('success')
            })
            .catch(e => {
              this.$tip.apiFailed(e)
            })
            .finally(() => {
              this.isWorking = false
            })
        } else {
          this.api.updateById(data)
            .then(() => {
              this.visible = false
              this.$tip.apiSuccess('修改成功')
              this.$emit('success')
            })
            .catch(e => {
              this.$tip.apiFailed(e)
            })
            .finally(() => {
              this.isWorking = false
            })
        }
      })
    },
    open (title, target) {
      this.title = title
      this.visible = true
      this.form.maxAge = ''
      this.form.validTypeNum = ''
      this.form.canReduce = 0
      this.form.canChangeUnit = 0
      this.form.addValidDays = 0
      this.form.delOnlyReplace = 0
      this.form.delValidDays = 0
      this.form.canAdd = 0
      this.form.worktypeIdList = []
      this.typeWork = []
      this.typeWorkCopy = []
      // this.$refs['$upload'].clearFiles()//初始化导入组件
      this.allCompany()
      this.allShops()
      // 新建
      if (target == null) {
        this.$nextTick(() => {
          this.$refs.form.resetFields()
          this.form.maxAge = ''
          this.form.validTypeNum = ''
          this.form.fanganFile = null
          this.form.worktypeIdList = []
          this.form[this.configData['field.id']] = null
          this.form.saveType = '0'
        })
        return
      }
      // 编辑
      this.$nextTick(() => {
        solutionsBaseId(target.id)
          .then(res => {
            for (const key in this.form) {
              this.form[key] = res[key]
            }
            this.form.saveType = '0'
            this.form.correctWarnTime = `${this.form.correctWarnTime}:00`
            if (res.worktypeList) {
              this.form.worktypeIdList = res.worktypeList.map(item => {
                return {
                  worktypeId: item.worktypeId,
                  worktypeName: item.worktypeName
                }
              })
            }
            this.getAllWorktype()
          })
      })
    },
    // 查询保险公司下全部工种
    getAllWorktype () {
      allWorktype({
        insuranceId: this.form.insuranceId,
        dataType: 2
      }).then(res => {
        this.typeWork = res
        if (!this.form.id) {
          this.typeWorkCopy = res
        } else {
          const valData = this.form.worktypeIdList.map(item => item.worktypeName)
          this.typeWorkCopy = res.filter(item => !valData.includes(item.name))
        }
      })
    },
 
    // 查询全部保险公司
    allCompany () {
      all({ dataType: 2, status: 0 })
        .then(res => {
          this.company = res
        })
    },
    allShops () {
      shopList({ type: 1, status: 0 })
        .then(res => {
          this.shops = res
        })
    },
    add () {
      const arr = this.typeWorkCopy.filter(item => this.worktypeId.includes(item.id))
      const dataVal = arr.map(item => {
        return {
          worktypeId: item.id,
          worktypeName: item.name
        }
      })
      this.form.worktypeIdList = [...dataVal, ...this.form.worktypeIdList]
      const valData = this.form.worktypeIdList.map(item => item.worktypeName)
      this.typeWorkCopy = this.typeWorkCopy.filter(item => !valData.includes(item.name))
      this.worktypeId = []
      this.$refs.form.validate()
    },
    dele (index) {
      if (this.form.worktypeIdList.length === 1) {
        this.$message.warning('至少要保留一项')
        return
      }
      const row = this.typeWork.filter(item => item.name === this.form.worktypeIdList[index].worktypeName)
      this.typeWorkCopy.unshift(row[0])
      this.form.worktypeIdList.splice(index, 1)
    }
  }
}
</script>
 
<style lang="scss" scoped>
    .tx {
        width: 100%;
        background-color: #ffffff;
        display: flex;
        flex-direction: column;
        .tx_item {
            width: 50%;
            padding: 20px 20px;
            box-sizing: border-box;
            background-color: #ffffff;
            border: 1px solid #ececec;
            margin-bottom: 20px;
            .tx_item_head {
                display: flex;
                align-items: center;
                span {
                    color: rgba(16,16,16,1);
                    font-size: 16px;
                    font-weight: bold;
                    margin-right: 15px;
                }
            }
            .tx_item_content {
                display: flex;
                align-items: start;
                margin-top: 10px;
                span {
                    flex-shrink: 0;
                    color: rgba(16,16,16,1);
                    font-size: 14px;
                }
            }
        }
    }
</style>