<template>
|
<GlobalWindow
|
:title="title"
|
:visible.sync="visible"
|
:confirm-working="isWorking"
|
@confirm="confirm"
|
>
|
<el-form :model="form" ref="form" :rules="rules">
|
<el-form-item label="保险公司" prop="name">
|
<el-input v-model="form.name" placeholder="平安保险" v-trim/>
|
</el-form-item>
|
<el-form-item label="logo" prop="logo">
|
<UploadAvatarImage :uploadData="{ folder: 'insurance' }" :file="file" @uploadSuccess="result" />
|
</el-form-item>
|
<el-form-item label="英文名称" prop="englishName">
|
<el-input v-model="form.englishName" maxlength="100" show-word-limit placeholder="请输入英文名称" v-trim/>
|
</el-form-item>
|
<el-form-item label="联系人" prop="linkName">
|
<el-input v-model="form.linkName" maxlength="10" show-word-limit placeholder="请输入联系人" v-trim/>
|
</el-form-item>
|
<el-form-item label="联系人电话" prop="linkPhone">
|
<el-input v-model="form.linkPhone" maxlength="11" show-word-limit placeholder="请输入联系人电话" v-trim/>
|
</el-form-item>
|
<div style="width: 100%; display: flex; align-items: center;margin-bottom: 10px;">
|
<el-button type="primary" @click="add">添加</el-button>
|
<el-button type="primary" @click="impor">导入工种</el-button>
|
<el-button type="text" @click="exprot">导入模版xls</el-button>
|
</div>
|
<el-table
|
:data="form.worktypeList"
|
border
|
style="width: 100%; margin-bottom: 20px;">
|
<el-table-column
|
label="序号"
|
align="center"
|
width="80">
|
<template slot-scope="scope">
|
<span>{{scope.$index + 1}}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
align="center"
|
label="工种名称">
|
<template slot-scope="{row}">
|
<el-input v-model="row.name" placeholder="请输入" v-trim/>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="操作"
|
align="center"
|
width="100">
|
<template slot-scope="scope">
|
<el-button type="text" size="small" style="color: red;" @click="dele(scope.$index)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<el-form-item label="理赔所需材料" prop="claimsInformation">
|
<RichEditor :richData="form.claimsInformation" :styleEditor="'border: 1px solid #ccc;display: inline-block;'" @getWangedditor="getWangedditor" :readonly="false"/>
|
</el-form-item>
|
<el-form-item label="保险政策" prop="policy">
|
<RichEditor :richData="form.policy" :styleEditor="'border: 1px solid #ccc;display: inline-block;'" @getWangedditor="getWangedditor1" :readonly="false"/>
|
</el-form-item>
|
<el-form-item label="保险条款" prop="agreement">
|
<RichEditor :richData="form.agreement" :styleEditor="'border: 1px solid #ccc;display: inline-block;'" @getWangedditor="getWangedditor2" :readonly="false"/>
|
</el-form-item>
|
</el-form>
|
<!-- 上传工种 -->
|
<input type="file" @change="getFile" style="opacity: 0;" ref="upload" accept=".xlsx" />
|
</GlobalWindow>
|
</template>
|
|
<script>
|
import BaseOpera from '@/components/base/BaseOpera'
|
import GlobalWindow from '@/components/common/GlobalWindow'
|
import UploadAvatarImage from '@/components/common/UploadAvatarImage'
|
import RichEditor from '@/components/common/RichEditor'
|
import { importExcel, all } from '@/api/business/worktype'
|
|
export default {
|
name: 'OperaInsuranceWindow',
|
extends: BaseOpera,
|
components: { GlobalWindow, UploadAvatarImage, RichEditor },
|
data () {
|
var phoneRule = (rule, value, callback) => {
|
if (value) {
|
if (!/^1[3-9]\d{9}$/.test(value)) {
|
return callback(new Error('请输入正确的手机号!'))
|
}
|
}
|
callback()
|
}
|
return {
|
// 表单数据
|
form: {
|
id: null,
|
name: '',
|
logo: '',
|
englishName: '',
|
linkName: '',
|
linkPhone: '',
|
agreement: '',
|
claimsInformation: '',
|
policy: '',
|
worktypeList: [
|
{ name: '' }
|
]
|
},
|
file: {
|
imgurlfull: ''
|
},
|
// 验证规则
|
rules: {
|
linkPhone: [
|
{ required: false, validator: phoneRule }
|
]
|
}
|
}
|
},
|
created () {
|
this.config({
|
api: '/business/insurance',
|
'field.id': 'id'
|
})
|
},
|
methods: {
|
open (title, target) {
|
this.form.worktypeList = [{ name: '' }]
|
this.title = title
|
this.visible = true
|
// 新建
|
if (target == null) {
|
this.$nextTick(() => {
|
this.$refs.form.resetFields()
|
this.form[this.configData['field.id']] = null
|
})
|
return
|
}
|
// 编辑
|
this.$nextTick(() => {
|
for (const key in this.form) {
|
this.form[key] = target[key]
|
}
|
this.file.imgurlfull = target.logoFullUrl
|
console.log(this.form)
|
all({ insuranceId: this.form.id })
|
.then(res => {
|
let arr = []
|
res.forEach(item => {
|
arr.push({ name: item.name })
|
})
|
this.form.worktypeList = arr
|
})
|
})
|
},
|
getWangedditor(val){
|
this.form.claimsInformation = val;
|
},
|
getWangedditor1(val){
|
this.form.policy = val;
|
},
|
getWangedditor2(val){
|
this.form.agreement = val;
|
},
|
result(res) {
|
this.form.logo = res.imgurl
|
this.file.imgurlfull = res.imgurlfull
|
},
|
// 导出模板
|
exprot() {
|
window.open(process.env.VUE_APP_TYPEWORK_URL)
|
// let a = document.createElement("a");
|
// a.href = '/public/file/typeWork.xlsx';
|
// a.download = '保险公司-工种导入模版.xlsx';
|
// a.click();
|
},
|
// 导入工种模板
|
getFile(e) {
|
const formdate = new FormData()
|
formdate.append('file', e.target.files[0])
|
importExcel(formdate)
|
.then(res => {
|
res.forEach(item => {
|
if (this.form.worktypeList.length === 0) {
|
this.form.worktypeList.push({ name: item })
|
} else {
|
let next = true
|
this.form.worktypeList.forEach(row => {
|
if (row.name === item) {
|
next = false
|
}
|
})
|
if (next) {
|
this.form.worktypeList.push({ name: item })
|
}
|
}
|
})
|
})
|
.catch(err => {
|
this.$message.error(err.message)
|
})
|
.finally(() => {
|
this.$refs.upload.value = null
|
})
|
},
|
// 上传文件
|
impor() {
|
this.$refs.upload.click()
|
},
|
add() {
|
this.form.worktypeList.push({ name: '' })
|
},
|
dele(index) {
|
if (this.form.worktypeList.length === 1) {
|
this.$message.warning('至少保留一项内容')
|
return
|
}
|
this.form.worktypeList.splice(index, 1)
|
}
|
}
|
}
|
</script>
|