k94314517
2025-07-01 f7a3d41075e00498f7033475108c0bcd86cda733
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
<template>
    <GlobalWindow
        :title="title"
        width="100%"
        :visible.sync="visible"
        :confirm-working="isWorking"
        @confirm="confirm"
    >
        <el-button type="primary" style="margin-bottom: 15px;" @click="add">添加</el-button>
        <el-table v-if="form.solutionList && form.solutionList.length>0"
            :data="form.solutionList"
            border
            style="width: 100%">
            <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="scope">
                    <el-select v-model="scope.row.solution.id" :disabled="scope.row.disabled" filterable @change="changeSolution($event, scope.$index)" placeholder="请选择">
                        <el-option
                            v-for="item in programme"
                            :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="scope">
              <el-select :ref="'shopSelect'+scope.$index" disabled 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" 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
                align="center"
                label="签署状态">
                <template slot-scope="{row}">
                    <template v-if="row.signStatus === 0">待签章</template>
                    <template v-else-if="row.signStatus === 1">已签章</template>
                </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>
    </GlobalWindow>
</template>
 
<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
import { all, listForCompany } from '@/api/business/solutions'
 
import {updateSolutions, pageAll as shopList, allForFp} 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
          // console.log(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
        })
      allForFp({ 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({
              disabled: true,
              solution: { id: item.solutionId, baseId: item.solutionBaseId,type:item.solutionType },
              shopId: item.shopId,
              canAdd: 1,
              canReduce: 1,
              signStatus: item.signStatus
            })
          })
          that.visible = true
        })
    },
    add () {
      this.form.solutionList.push({
        disabled: false,
        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>