|  |  |  | 
|---|
|  |  |  | @confirm="confirm" | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <el-button type="primary" style="margin-bottom: 15px;" @click="add">添加</el-button> | 
|---|
|  |  |  | <el-table | 
|---|
|  |  |  | <el-table v-if="form.solutionList && form.solutionList.length>0" | 
|---|
|  |  |  | :data="form.solutionList" | 
|---|
|  |  |  | border | 
|---|
|  |  |  | style="width: 100%"> | 
|---|
|  |  |  | 
|---|
|  |  |  | <el-table-column | 
|---|
|  |  |  | align="center" | 
|---|
|  |  |  | label="保险方案"> | 
|---|
|  |  |  | <template slot-scope="{row}"> | 
|---|
|  |  |  | <el-select v-model="row.solutionBaseId" placeholder="请选择"> | 
|---|
|  |  |  | <template slot-scope="scope"> | 
|---|
|  |  |  | <!--                    :value="{ id:item.id, baseId: item.baseId }"--> | 
|---|
|  |  |  | <el-select v-model="scope.row.solution.id" @change="changeSolution($event, scope.$index)" placeholder="请选择"> | 
|---|
|  |  |  | <el-option | 
|---|
|  |  |  | v-for="item in programme" | 
|---|
|  |  |  | :key="item.id" | 
|---|
|  |  |  | 
|---|
|  |  |  | </el-select> | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | </el-table-column> | 
|---|
|  |  |  | <el-table-column | 
|---|
|  |  |  | align="center" | 
|---|
|  |  |  | label="委托商户"> | 
|---|
|  |  |  | <template slot-scope="scope"> | 
|---|
|  |  |  | <el-select :ref="'shopSelect'+scope.$index" :disabled="scope.row.solution.type ==1" v-model="scope.row.shopId" clearable value-key="id" placeholder="请选择"> | 
|---|
|  |  |  | <el-option | 
|---|
|  |  |  | v-for="item in shops" | 
|---|
|  |  |  | :key="item.id" | 
|---|
|  |  |  | :label="item.name" | 
|---|
|  |  |  | :value="item.id"> | 
|---|
|  |  |  | </el-option> | 
|---|
|  |  |  | </el-select> | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | </el-table-column> | 
|---|
|  |  |  | <el-table-column | 
|---|
|  |  |  | align="center" | 
|---|
|  |  |  | label="加减保功能"> | 
|---|
|  |  |  | <template slot-scope="{row}"> | 
|---|
|  |  |  | <el-checkbox :true-label="1" :false-label="0" v-model="row.canAdd">加保</el-checkbox> | 
|---|
|  |  |  | <el-checkbox :true-label="1" :false-label="0" v-model="row.canReduce">减保</el-checkbox> | 
|---|
|  |  |  | <el-checkbox :true-label="1" :false-label="0" disabled  v-model="row.canAdd">加保</el-checkbox> | 
|---|
|  |  |  | <el-checkbox :true-label="1" :false-label="0"  disabled   v-model="row.canReduce">减保</el-checkbox> | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | </el-table-column> | 
|---|
|  |  |  | <el-table-column | 
|---|
|  |  |  | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <script> | 
|---|
|  |  |  | import BaseOpera from '@/components/base/BaseOpera' | 
|---|
|  |  |  | import GlobalWindow from '@/components/common/GlobalWindow' | 
|---|
|  |  |  | import { all } from '@/api/business/solutions' | 
|---|
|  |  |  | import { listForCompany } from '@/api/business/solutions' | 
|---|
|  |  |  | import { updateSolutions } from '@/api/business/company' | 
|---|
|  |  |  | import BaseOpera from '@/components/base/BaseOpera' | 
|---|
|  |  |  | import GlobalWindow from '@/components/common/GlobalWindow' | 
|---|
|  |  |  | import { all, listForCompany } from '@/api/business/solutions' | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export default { | 
|---|
|  |  |  | name: 'modification', | 
|---|
|  |  |  | extends: BaseOpera, | 
|---|
|  |  |  | components: { GlobalWindow }, | 
|---|
|  |  |  | data () { | 
|---|
|  |  |  | return { | 
|---|
|  |  |  | // 表单数据 | 
|---|
|  |  |  | form: { | 
|---|
|  |  |  | id: null, | 
|---|
|  |  |  | solutionList: [ | 
|---|
|  |  |  | { | 
|---|
|  |  |  | solutionBaseId: '', | 
|---|
|  |  |  | canAdd: 0, | 
|---|
|  |  |  | canReduce: 0 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ] | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // 验证规则 | 
|---|
|  |  |  | rules: { | 
|---|
|  |  |  | solutionList: [ | 
|---|
|  |  |  | { required: true, message: '请输入公司账号' } | 
|---|
|  |  |  | ] | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | programme: [] | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | created () { | 
|---|
|  |  |  | this.config({ | 
|---|
|  |  |  | api: '/business/company', | 
|---|
|  |  |  | 'field.id': 'id' | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | methods: { | 
|---|
|  |  |  | confirm() { | 
|---|
|  |  |  | this.isWorking = true | 
|---|
|  |  |  | updateSolutions(this.form) | 
|---|
|  |  |  | .then(res => { | 
|---|
|  |  |  | this.visible = false | 
|---|
|  |  |  | this.$tip.apiSuccess('新建成功') | 
|---|
|  |  |  | this.$emit('success') | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | .catch(e => { | 
|---|
|  |  |  | this.$tip.apiFailed(e) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | .finally(() => { | 
|---|
|  |  |  | this.isWorking = false | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // 获取全部方案 | 
|---|
|  |  |  | getAll() { | 
|---|
|  |  |  | all({}) | 
|---|
|  |  |  | .then(res => { | 
|---|
|  |  |  | this.programme = res | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | open (title, target) { | 
|---|
|  |  |  | var that = this; | 
|---|
|  |  |  | this.title = title | 
|---|
|  |  |  | for (const key in this.form) { | 
|---|
|  |  |  | this.form[key] = target[key] | 
|---|
|  |  |  | } | 
|---|
|  |  |  | this.getAll() | 
|---|
|  |  |  | listForCompany({ companyId: target.id }) | 
|---|
|  |  |  | .then(resa => { | 
|---|
|  |  |  | that.form.solutionList = resa.map(item => { | 
|---|
|  |  |  | return { | 
|---|
|  |  |  | solutionBaseId: item.solutionBaseId, | 
|---|
|  |  |  | canAdd: item.canAdd, | 
|---|
|  |  |  | canReduce: item.canReduce | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | that.visible = true | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | add() { | 
|---|
|  |  |  | this.form.solutionList.push({ | 
|---|
|  |  |  | solutionName: '', | 
|---|
|  |  |  | canAdd: '', | 
|---|
|  |  |  | canReduce: '' | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | dele(index) { | 
|---|
|  |  |  | if (this.form.solutionList.length === 1) { | 
|---|
|  |  |  | this.$message.warning('至少保留一项') | 
|---|
|  |  |  | return | 
|---|
|  |  |  | } | 
|---|
|  |  |  | this.form.solutionList.splice(index, 1) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | import { updateSolutions, pageAll as shopList } from '@/api/business/company' | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export default { | 
|---|
|  |  |  | name: 'modification', | 
|---|
|  |  |  | extends: BaseOpera, | 
|---|
|  |  |  | components: { GlobalWindow }, | 
|---|
|  |  |  | data () { | 
|---|
|  |  |  | return { | 
|---|
|  |  |  | // 表单数据 | 
|---|
|  |  |  | form: { | 
|---|
|  |  |  | id: null, | 
|---|
|  |  |  | solutionList: [ | 
|---|
|  |  |  | { | 
|---|
|  |  |  | solution: { id: null, baseId: null,type:0 }, | 
|---|
|  |  |  | canAdd: 0, | 
|---|
|  |  |  | shopId:null, | 
|---|
|  |  |  | canReduce: 0 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ] | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // 验证规则 | 
|---|
|  |  |  | rules: { | 
|---|
|  |  |  | solutionList: [ | 
|---|
|  |  |  | { required: true, message: '请输入公司账号' } | 
|---|
|  |  |  | ] | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | programme: [], | 
|---|
|  |  |  | shops: [] | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | created () { | 
|---|
|  |  |  | this.config({ | 
|---|
|  |  |  | api: '/business/company', | 
|---|
|  |  |  | 'field.id': 'id' | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | methods: { | 
|---|
|  |  |  | changeSolution (e, index) { | 
|---|
|  |  |  | let baseId = '' | 
|---|
|  |  |  | this.programme.forEach(item => { | 
|---|
|  |  |  | if (item.id === e) { | 
|---|
|  |  |  | baseId = item.baseId | 
|---|
|  |  |  | this.form.solutionList[index].solution.type = item.type | 
|---|
|  |  |  | if(item.type == 1){ | 
|---|
|  |  |  | this.form.solutionList[index].shopId =item.shopId | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | this.form.solutionList[index].solution.baseId = baseId | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | confirm () { | 
|---|
|  |  |  | this.isWorking = true | 
|---|
|  |  |  | updateSolutions(this.form) | 
|---|
|  |  |  | .then(res => { | 
|---|
|  |  |  | this.visible = false | 
|---|
|  |  |  | this.$tip.apiSuccess('新建成功') | 
|---|
|  |  |  | this.$emit('success') | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | .catch(e => { | 
|---|
|  |  |  | this.$tip.apiFailed(e) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | .finally(() => { | 
|---|
|  |  |  | this.isWorking = false | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // 获取全部方案 | 
|---|
|  |  |  | getAll () { | 
|---|
|  |  |  | all({ dataType: 2 }) | 
|---|
|  |  |  | .then(res => { | 
|---|
|  |  |  | this.programme = res | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | shopList({ type: 1, status: 0 }) | 
|---|
|  |  |  | .then(res => { | 
|---|
|  |  |  | console.log(res) | 
|---|
|  |  |  | this.shops = res | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | open (title, target) { | 
|---|
|  |  |  | var that = this | 
|---|
|  |  |  | this.title = title | 
|---|
|  |  |  | for (const key in this.form) { | 
|---|
|  |  |  | this.form[key] = target[key] | 
|---|
|  |  |  | } | 
|---|
|  |  |  | this.getAll() | 
|---|
|  |  |  | this.form.solutionList=[] | 
|---|
|  |  |  | listForCompany({ companyId: target.id }) | 
|---|
|  |  |  | .then(resa => { | 
|---|
|  |  |  | resa.forEach(item => { | 
|---|
|  |  |  | this.form.solutionList.push({ | 
|---|
|  |  |  | solution: { id: item.solutionId, baseId: item.solutionBaseId,type:item.solutionType }, | 
|---|
|  |  |  | shopId: item.shopId, | 
|---|
|  |  |  | canAdd: 1, | 
|---|
|  |  |  | canReduce: 1 | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | console.log(this.form.solutionList) | 
|---|
|  |  |  | that.visible = true | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | add () { | 
|---|
|  |  |  | this.form.solutionList.push({ | 
|---|
|  |  |  | solution: { id: null, baseId: null }, | 
|---|
|  |  |  | shopId: null, | 
|---|
|  |  |  | canAdd: 1, | 
|---|
|  |  |  | canReduce: 1 | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | dele (index) { | 
|---|
|  |  |  | if (this.form.solutionList.length === 1) { | 
|---|
|  |  |  | this.$message.warning('至少保留一项') | 
|---|
|  |  |  | return | 
|---|
|  |  |  | } | 
|---|
|  |  |  | this.form.solutionList.splice(index, 1) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | </script> | 
|---|