MrShi
2024-11-04 b6fde711bf33cede4cb84f85146c32b0c0c61aa5
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
<template>
    <GlobalWindow
        :title="title"
        width="100%"
        :visible.sync="visible"
        :confirm-working="isWorking"
        @confirm="confirm"
    >
        <el-form :model="form" ref="form" :rules="rules">
            <el-form-item label="主方案" prop="parentId">
                <el-select v-model="form.parentId" filterable @change="changeParent" placeholder="请选择">
                    <el-option
                        v-for="item in list"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="子方案名称" prop="name">
                <el-input v-model="form.name" placeholder="请输入" v-trim/>
            </el-form-item>
            <el-form-item label="保险费用" prop="price">
                <div style="display: flex; align-items: center;">
                    <el-input v-model="form.price" style="flex: 1;" placeholder="请输入" v-trim/>
                    <span style="margin: 0 30px;">元/人</span>
                    <el-select v-model="form.timeUnit" style="flex: 1;" placeholder="请选择周期单位" @change="changeTimeUnit">
                        <el-option label="天" :value="0"></el-option>
                        <!--                        <el-option label="半月" :value="1"></el-option>-->
                        <el-option label="月" :value="2"></el-option>
                        <el-option label="季度" :value="3"></el-option>
                        <el-option label="半年" :value="4"></el-option>
                        <el-option label="年" :value="5"></el-option>
                    </el-select>
                </div>
            </el-form-item>
            <el-form-item label="批改计费规则" prop="insureCycleUnit">
                <div style="display: flex; align-items: center;">
                    <el-select v-model="form.insureCycleUnit" style="flex: 1;" placeholder="请选择">
                        <el-option  label="天" :value="0"></el-option>
                        <el-option v-if="form.timeUnit>=1"  label="半月" :value="1"></el-option>
                        <el-option v-if="form.timeUnit>=2"  label="月" :value="2"></el-option>
                        <el-option v-if="form.timeUnit>=3"  label="季度" :value="3"></el-option>
                        <el-option  v-if="form.timeUnit>=4"  label="半年" :value="4"></el-option>
                        <el-option v-if="form.timeUnit>=5" label="年" :value="5"></el-option>
                    </el-select>
                </div>
            </el-form-item>
            <el-form-item label="投保类型" prop="type">
                <el-radio-group v-model="form.type" :disabled="form.id!=null" @change="form.signType = ''">
                    <el-radio :label="0">直保</el-radio>
                    <el-radio :label="1">委托投保</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="委托商户" prop="shopId" :rules="form.type === 1 ? [{required:true,message:'请选择商户'}] : [{ required:false }]">
                <el-select v-model="form.shopId" filterable placeholder="请选择委托商户">
                    <el-option
                        v-for="item in shops"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="签章方式" prop="signType" v-if="form.type === 1">
                <el-select v-model="form.signType" placeholder="请选择委托商户">
                    <el-option label="企业签署商户上传投保单" :value="0"></el-option>
                    <el-option label="企业签投保申请" :value="1"></el-option>
                    <el-option label="企业无需签章" :value="2"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="有派遣单位" prop="hasDispatchUnit">
                <el-radio-group v-model="form.hasDispatchUnit">
                    <el-radio :label="0">有</el-radio>
                    <el-radio :label="1">无</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="需要复核" prop="retrial">
                <el-radio-group v-model="form.retrial">
                    <el-radio :label="1">需要</el-radio>
                    <el-radio :label="0">不需要</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="上传方案确认书:" prop="fanganFile" :rules="[{required:true,message:'请上传方案确认书'}]">
                <div>
                    <UploadFile @remove="deleFile" :uploadData="{ folder: 'apply', fileType:'.pdf' }" :fileList="form.fileList1" @uploadSuccess="editFanganFile" />
                </div>
            </el-form-item>
            <el-form-item label="接收文件邮箱" prop="email">
                <el-input v-model="form.email" placeholder="请输入" v-trim/>
            </el-form-item>
        </el-form>
    </GlobalWindow>
</template>
 
<script>
  import BaseOpera from '@/components/base/BaseOpera'
  import GlobalWindow from '@/components/common/GlobalWindow'
  import { all } from '@/api/business/insurance'
  import { solutionsId } from '@/api/business/solutions'
  import { list } from '@/api/business/solutionsBase'
  import { pageAll as shopList } from '@/api/business/company'
  import UploadFile from '@/components/common/UploadFile'
  import RichEditor from '@/components/common/RichEditor'
 
  export default {
  name: 'OperaSolutionsWindow',
  extends: BaseOpera,
  components: { GlobalWindow, UploadFile, RichEditor },
  data () {
    return {
      // 表单数据
      form: {
        id: null,
        name: '',
        parentId: '',
        signType: '',
        type: 0,
        price: '',
        timeUnit: '',
        shopId: null,
        retrial: 0,
        hasDispatchUnit: 0,
        insureCycleUnit: '',
        email: '',
        fileList1: [],
        fanganFile: null
      },
      // 验证规则
      rules: {
        name: [
          { required: true, message: '请输入方案名称' }
        ],
        parentId: [
          { required: true, message: '请选择主方案' }
        ],
        signType: [
          { required: true, message: '请选择签章方式' }
        ],
        price: [
          { required: true, message: '请输入方案费用' }
        ],
        insureCycleUnit: [
          { required: true, message: '请输入批改计费单位' }
        ],
        type: [
          { required: true, message: '请选择投保类型' }
        ]
      },
      list: [],
      shops: [],
      company: []
    }
  },
  created () {
    this.config({
      api: '/business/solutions',
      'field.id': 'id'
    })
  },
  methods: {
    changeParent(e) {
      let name = this.list.filter(item => {
        if (e === item.id) {
          return item.name
        }
      })
      this.form.name = name[0].name
    },
    async getList() {
      this.list = await list({})
    },
    changeTimeUnit () {
      if (this.form.timeUnit < this.form.insureCycleUnit) {
        this.form.insureCycleUnit = null
      }
    },
    editFanganFile (data) {
      this.form.fanganFile = data
    },
    // 确认新建/修改
    confirm () {
      const data = JSON.parse(JSON.stringify(this.form))
      this.$refs.form.validate((valid) => {
        if (!valid) {
          return
        }
        if (data.type === 1 && (!data.fanganFile || !data.fanganFile.fileurl)) {
          this.$message.error('请上传方案确认书!')
          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
            })
        }
      })
    },
    deleFile () {
      this.form.fanganFile = {}
    },
    open (title, target) {
      this.title = title
      this.visible = true
      this.form.timeUnit = ''
      this.form.insureCycleUnit = ''
      this.form.fanganFile = null
      this.form.fileList1 = []
      this.allCompany()
      this.allShops()
      this.getList()
      // 新建
      if (target == null) {
        this.$nextTick(() => {
          this.$refs.form.resetFields()
          this.form.timeUnit = ''
          this.form.insureCycleUnit = ''
          this.form.fanganFile = null
          this.form.fileList1 = []
          this.form[this.configData['field.id']] = null
        })
        return
      }
      // 编辑
      this.$nextTick(() => {
        solutionsId(target.id)
          .then(res => {
            for (const key in this.form) {
              this.form[key] = res[key]
            }
            if (this.form.fanganFile && this.form.fanganFile.fileurl) {
              this.form.fileList1 = [{ url: this.form.fanganFile.fileurlFull, name: this.form.fanganFile.name }]
            }
          })
      })
    },
    // 查询全部保险公司
    allCompany () {
      all({ dataType: 2, status: 0 })
        .then(res => {
          this.company = res
        })
    },
    allShops () {
      shopList({ type: 1, status: 0 })
        .then(res => {
          this.shops = res
        })
    }
  }
}
</script>