addService.vue 26.2 KB
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 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750
<template>
  <div class="container" v-if="!routeInfo.extendedFlag">
    <template v-if="firstPage">
      <div class="base-info">
        <div class="global-title">基本信息</div>
        <div class="main-wrap">
          <glsx-combi-form ref="baseInfoRef" labelWidth="154px" defaultWidth="432px" :isInline="false" :formObj.sync="formObj" :formData="formData" :formRules="myRule">
            <div slot="guorenCodeSlot" class="codeSlot-class">
              <el-autocomplete :popper-append-to-body="false" value-key="copyServiceName" popper-class="my-autocomplete" v-model.trim="formObj.copyServiceName" :fetch-suggestions="querySearch" placeholder="请输入或选择内容" @select="handleSelect" @change="handleChange">
                <template slot-scope="{ item }">
                  <div>
                    <span class="code">{{ item.guorenCode || '--' }}</span>
                    <span class="name">{{ item.serviceName }}</span>
                  </div>
                </template>
              </el-autocomplete>
            </div>
            <div slot="timeLimitSlot">
              <el-checkbox-group :disabled="disabled" v-model="formObj.salePeriod">
                <el-checkbox v-for="item in salePeriodList" :label="item.key" :key="item.key">{{ item.label }}</el-checkbox>
              </el-checkbox-group>
            </div>
            <div slot="showProjectSlot">
              <el-radio-group :disabled="disabled" v-model="formObj.mainPageFlag">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </div>
            <div slot="logoSettingSlot" class="logo-setting">
              <Upload :disabled="routeInfo.type == 2" v-for="item in logoList" :url="formObj[item.key]" @delImage="delImage" @uploadSuccess="uploadSuccess" :attr="item.key" :key="item.key" :name="item.name"></Upload>
              <span class="upload-tip">建议尺寸:88px*88px,图片格式为jpg,jpeg,png</span>
            </div>
          </glsx-combi-form>
        </div>
      </div>
      <div class="services-wrap">
        <div class="global-title">服务介绍</div>
        <div class="main-wrap">
          <glsx-combi-form ref="servicesRef" labelWidth="154px" defaultWidth="432px" :isInline="false" :formObj.sync="formObj" :formData="servicesformData" :formRules="myRule">
            <div slot="buyConditionSlot" class="buy-condition">
              <el-checkbox-group :disabled="disabled" v-model="formObj.buyConditions">
                <el-checkbox v-for="(item, index) in conditionList" :disabled="!item.id" :label="item.id" :key="index">
                  <span class="sign">条件{{ index + 1 }}</span>
                  <div class="condition-text">
                    <span v-if="!item.newItem" class="condition">{{ item.contractContent }}</span>
                    <el-input class="condition-input" v-focus v-else type="textarea" v-model="curEditCondition.value" @blur.stop="createConfig(0, item)"></el-input>
                    <i v-if="!item.newItem && !disabled" class="el-icon-edit-outline edit" @click.prevent="editConditionFn(item, 'conditionList')"></i>
                  </div>
                </el-checkbox>
              </el-checkbox-group>
              <div v-if="!disabled" class="add-btn" @click="addCondition('conditionList')">
                <i class="el-icon-circle-plus-outline"></i>
                新增条件
              </div>
            </div>
            <div slot="prerequisiteSlot">
              <Editor :disabled="disabled" v-model="formObj.prerequisite"></Editor>
            </div>
            <div slot="responsibilitySlot" class="buy-condition">
              <el-checkbox-group :disabled="disabled" v-model="formObj.exclusionsResponsibility">
                <el-checkbox v-for="(item, index) in responsibilityList" :disabled="!item.id" :label="item.id" :key="index">
                  <span class="sign">责任{{ index + 1 }}</span>
                  <div class="condition-text">
                    <span v-if="!item.newItem" class="condition">{{ item.contractContent }}</span>
                    <el-input class="condition-input" v-focus v-else type="textarea" v-model="curEditCondition.value" @blur.stop="createConfig(1, item)"></el-input>
                    <i v-if="!item.newItem && !disabled" class="el-icon-edit-outline edit" @click.prevent="editConditionFn(item, 'responsibilityList')"></i>
                  </div>
                </el-checkbox>
              </el-checkbox-group>
              <div v-if="!disabled" class="add-btn" @click="addCondition('responsibilityList')">
                <i class="el-icon-circle-plus-outline"></i>
                新增责任
              </div>
            </div>
            <div slot="serviceDataSlot">
              <Editor :disabled="disabled" v-model="formObj.serviceData"></Editor>
            </div>
          </glsx-combi-form>
        </div>
      </div>
    </template>
    <template v-else>
      <div class="setting-wrap">
        <div class="global-title">规格和成本设置</div>
        <div class="main-wrap">
          <glsx-combi-form ref="editFormRefCar" labelWidth="154px" :isInline="false" :formObj.sync="gradeFormObj" :formData="settingformData" :formRules="gradeRule">
            <div slot="costSlot">
              <el-input class="cost-input" placeholder="请输入每月投保成本" @input="changePrice($event, gradeFormObj, 'monthlyInsuranceCost')" :disabled="disabled" v-model="gradeFormObj.monthlyInsuranceCost"></el-input>
            </div>
            <div slot="specConfigSlot">
              <ServicesTable :disabled="disabled" class="services-table" v-for="item in gradeList" :key="item.serviceGrade" :tableData="item"></ServicesTable>
              <div v-if="!disabled" class="add-btn" @click="handleAddGrade">
                <i class="el-icon-circle-plus-outline"></i>
                新增规格
              </div>
            </div>
          </glsx-combi-form>
        </div>
      </div>
    </template>
    <div class="footer-btn">
      <el-button @click="jumpListPage">取消</el-button>
      <template v-if="firstPage">
        <el-button type="primary" @click="nextStep">下一步</el-button>
      </template>
      <template v-else>
        <el-button type="primary" @click="firstPage = true">上一步</el-button>
        <el-button v-if="routeInfo.type != 2" type="primary" @click="commit">提交</el-button>
      </template>
    </div>
  </div>
  <div class="container" v-else>
    <add-extended :route-info="routeInfo"></add-extended>
  </div>
</template>

<script>
import glsxCombiForm from '@/components/glsx-combi-form'
import Upload from '@/components/Upload'
import ServicesTable from './components/ServicesTable'
import Editor from '@/components/Editor'
import { addGradeItem, handleGradeData } from '@/util/gradeData'
import NP from 'number-precision'
import addExtended from './addExtended.vue'
const TIP_OBJ = {
  minPrice: '最小值',
  maxPrice: '最大值',
  standardSalesCost: '上架成本',
  standardShelfCost: '嘀加成本',
  priceCoefficient: '价格系数'
}
export default {
  name: 'addService',
  components: {
    glsxCombiForm,
    Upload,
    Editor,
    ServicesTable,
    addExtended
  },
  data() {
    return {
      firstPage: true,
      disabled: false,
      curEditCondition: {
        id: '',
        value: ''
      },
      servicesList: [],
      conditionList: [],
      responsibilityList: [],
      salePeriodList: [
        { label: '1年', key: 1 },
        { label: '2年', key: 2 },
        { label: '3年', key: 3 },
        { label: '4年', key: 4 },
        { label: '5年', key: 5 }
      ],
      logoList: [
        {
          name: '未激活:',
          url: '',
          key: 'unactivatedLogo'
        },
        {
          name: '已激活:',
          url: '',
          key: 'activatedLogo'
        },
        {
          name: '详情页Logo:',
          url: '',
          key: 'detailLogo'
        }
      ],
      myRule: {
        serviceName: [{ required: true, message: '请输入服务项目名称', trigger: 'change' }],
        serviceShortName: [{ required: true, message: '请输入服务项目简称', trigger: 'change' }],
        // guorenCode: [{ required: true, message: '请输入国任理赔编码', trigger: 'change' }],
        salePeriod: [{ required: true, message: '请选择销售年限', trigger: 'change' }],
        mainPageFlag: [{ required: true, message: '请选择小程序端展示', trigger: 'change' }],
        logoUrl: [
          {
            required: true,
            validator: (rule, value, callback) => {
              if (!this.formObj.unactivatedLogo) {
                callback(new Error('请上传未激活Logo图'))
              } else if (!this.formObj.activatedLogo) {
                callback(new Error('请上传已激活Logo图'))
              } else if (!this.formObj.detailLogo) {
                callback(new Error('请上传详情页Logo图'))
              } else {
                callback()
              }
            },
            trigger: 'change'
          }
        ],
        buyConditions: [{ required: true, message: '请选择购买条件', trigger: 'change' }],
        prerequisite: [{ required: true, message: '请输入前提条件', trigger: 'change' }],
        exclusionsResponsibility: [{ required: true, message: '请选择除外责任', trigger: 'change' }],
        serviceData: [{ required: true, message: '请输入服务资料', trigger: 'change' }]
      },
      formObj: {
        serviceName: '',
        serviceShortName: '',
        copyServiceName: '',
        guorenCode: '',
        copyServiceCode: '',
        mainPageFlag: 1,
        unactivatedLogo: '',
        activatedLogo: '',
        detailLogo: '',
        serviceData: '',
        prerequisite: '',
        exclusionsResponsibility: [],
        salePeriod: [],
        buyConditions: []
      },
      formData: [
        {
          label: '服务项目名称:',
          name: 'serviceName',
          placeholder: '请输入服务项目名称',
          type: 'input',
          isDisabled: false,
          maxlength: 50
        },
        {
          label: '服务项目简称:',
          name: 'serviceShortName',
          placeholder: '请输入服务项目简称',
          isDisabled: false,
          type: 'input',
          maxlength: 50
        },
        {
          label: '国任理赔编码:',
          name: 'guorenCode',
          addHtml: 'guorenCodeSlot',
          isDisabled: false,
          placeholder: '请输入国任理赔编码',
          type: 'input',
          maxlength: 50
        },
        {
          label: '销售年限:',
          name: 'salePeriod',
          addHtml: 'timeLimitSlot'
        },
        {
          label: '小程序端展示:',
          name: 'mainPageFlag',
          addHtml: 'showProjectSlot'
        },
        {
          label: 'Logo设置:',
          name: 'logoUrl',
          addHtml: 'logoSettingSlot'
        }
      ],
      servicesformData: [
        {
          label: '购买条件:',
          name: 'buyConditions',
          addHtml: 'buyConditionSlot'
        },
        {
          label: '前提条件:',
          name: 'prerequisite',
          addHtml: 'prerequisiteSlot'
        },
        {
          label: '除外责任:',
          name: 'exclusionsResponsibility',
          addHtml: 'responsibilitySlot'
        },
        {
          label: '服务资料:',
          name: 'serviceData',
          addHtml: 'serviceDataSlot'
        }
      ],
      gradeFormObj: {
        monthlyInsuranceCost: ''
      },
      gradeRule: {
        monthlyInsuranceCost: [{ required: true, message: '请输入每月投保成本', trigger: 'change' }],
        nianxian: [{ required: true, message: '请输入每月投保成本', trigger: 'change' }]
      },
      settingformData: [
        {
          label: '每月投保成本/元:',
          placeholder: '请输入每月投保成本',
          name: 'monthlyInsuranceCost',
          addHtml: 'costSlot'
        },
        {
          label: '规格配置:',
          name: 'nianxian',
          addHtml: 'specConfigSlot'
        }
      ],
      gradeList: [],
      selectDisabled: false
    }
  },
  directives: {
    focus: {
      inserted(el) {
        el.querySelector('textarea').focus()
      }
    }
  },
  created() {
    const urlParam = this.$route.params
    this.routeInfo = JSON.parse(decodeURIComponent(urlParam.id))
    // 延保服务项目配置在组件中
    if (this.routeInfo.extendedFlag) return
    if (this.routeInfo.type == 2) {
      this.disabled = true
      this.formData.forEach(item => {
        item.isDisabled = item.type == 'input'
      })
      this.settingformData.forEach(item => {
        item.isDisabled = item.type == 'input'
      })
    }
    if (this.routeInfo?.id) {
      this.getServiceDetail()
    }
    this.getConfigList()
    this.getServicesList()
  },
  mounted() {},

  methods: {
    changePrice(value, item, key) {
      item[key] = value
        ? value
            .replace(/^0\d/g, '0')
            .replace(/[^\d.]/g, '')
            .replace(/^\./g, '')
            .replace(/^\d{6}\d+(\.\d+)?/g, value.substr(0, 6))
            .replace(/\.{2,}/g, '')
            .replace('.', '$#$')
            .replace(/\./g, '')
            .replace('$#$', '.')
            .replace(/^(-)*(\d+)\.(\d\d).*$/, '$1$2.$3')
        : ''
    },
    handleSelect(e) {
      this.formObj.copyServiceCode = e.serviceCode
      this.formObj.guorenCode = e.guorenCode
      this.selectDisabled = true
    },
    handleChange(e) {
      // 只有选择之后的第一次按了按键失焦才会触发,想要再次触发必须再选一次
      if (!this.formObj.copyServiceCode) return
      const _target = this.servicesList.find(item => item.serviceCode == this.formObj.copyServiceCode)
      if (_target && _target.copyServiceName != this.formObj.copyServiceName.trim()) {
        this.formObj.copyServiceCode = ''
        this.formObj.guorenCode = this.formObj.copyServiceName
      }
    },
    querySearch(queryString, cb) {
      var restaurants = this.servicesList
      var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants
      // 调用 callback 返回建议列表的数据
      cb(results)
    },
    createFilter(queryString) {
      return restaurant => {
        return restaurant.copyServiceName.toLowerCase().indexOf(queryString.toLowerCase()) > -1
      }
    },
    getServicesList() {
      this.$apis.serviceConfig.getServicesItemsList({ pageSize: 1000, pageNum: 1, serviceStatus: 1 }).then(res => {
        if (res?.list) {
          this.servicesList = res.list.map(item => ({ ...item, copyServiceName: `${item.guorenCode || '--'} ${item.serviceName}` }))
        }
      })
    },
    editConditionFn(row, key) {
      this.curEditCondition = {
        id: row.id,
        value: row.contractContent
      }
      const target = this[key].find(item => item.id == row.id)
      this.$set(target, 'newItem', true)
    },
    addCondition(key) {
      this[key].push({ newItem: true })
    },
    ininData() {
      this.gradeList = [addGradeItem('A', this.formObj.salePeriod)]
    },
    isEmpty(value) {
      return value !== 0 && value !== '0' && !value
    },
    // 计算精确价格
    calcPrice(price1, price2) {
      price1 = price1 || 0
      price2 = price2 || 0
      return NP.times(price1, price2)
    },
    commit() {
      const _gradeList = []
      try {
        this.gradeList.forEach(item => {
          const { id, serviceGrade, serviceOverview, serviceDetail, salePeriodData, gradeConfigList } = item
          let _gradeConfigList = []
          gradeConfigList.forEach((ele, eleIdx) => {
            let { priceCoefficient, minPrice, maxPrice, childSalePeriodData, computeFlag } = ele
            if (this.isEmpty(minPrice) || this.isEmpty(maxPrice) || (this.isEmpty(priceCoefficient) && computeFlag == 0)) {
              throw new Error(`请输入${serviceGrade}规格的${this.isEmpty(priceCoefficient) && computeFlag == 0 ? '价格系数' : '价格区间'}`)
            }
            // 标准行数据
            salePeriodData.forEach(element => {
              let { servicePeriod, standardSalesCost, standardShelfCost } = element
              if (this.isEmpty(standardSalesCost) || this.isEmpty(standardShelfCost)) {
                throw new Error(`请输入${serviceGrade}规格${servicePeriod}年版的${this.isEmpty(standardSalesCost) ? '嘀加成本' : '上架成本'}`)
              }
            })
            // 计算/自定义行数据
            childSalePeriodData?.forEach(element => {
              let { servicePeriod, standardSalesCost, standardShelfCost, salesCost, shelfCost } = element
              const it = salePeriodData.find(v => v.servicePeriod == servicePeriod)
              if (computeFlag == 0) {
                shelfCost = this.calcPrice(it?.standardShelfCost, priceCoefficient) || 0 // 计算后嘀加成本
                salesCost = this.calcPrice(it?.standardSalesCost, priceCoefficient) || 0 // 计算后上架成本
              }
              if (this.isEmpty(salesCost) || this.isEmpty(shelfCost)) {
                throw new Error(`请输入${serviceGrade}规格${servicePeriod}年版的${this.isEmpty(salesCost) ? '嘀加成本' : '上架成本'}`)
              }
              standardSalesCost = NP.times(it?.standardSalesCost || 0, 100) // 标准嘀加成本
              standardShelfCost = NP.times(it?.standardShelfCost || 0, 100) // 标准上架成本
              let min_price = NP.times(minPrice || 0, 1000000)
              let max_price = NP.times(maxPrice || 0, 1000000)
              let gradeConfigObj = { id: element.id, priceGrade: eleIdx, priceCoefficient: priceCoefficient ? priceCoefficient : undefined, minPrice: min_price, maxPrice: max_price, servicePeriod, standardSalesCost, standardShelfCost, computeFlag, salesCost, shelfCost }
              _gradeConfigList.push(gradeConfigObj)
            })
          })
          if (!serviceOverview || !serviceDetail) {
            throw new Error(`请输入${serviceGrade}规格的${serviceOverview ? '规格详细描述' : '服务条款概述'}`)
          }
          let _gradeObj = {
            id,
            serviceGrade,
            serviceOverview,
            serviceDetail,
            gradeConfigList: _gradeConfigList
          }
          _gradeList.push(_gradeObj)
        })
      } catch (e) {
        if (e.message) {
          return this.$message.error(e.message)
        }
      }
      const params = {
        serviceCode: this.routeInfo.serviceCode,
        serviceName: this.routeInfo.serviceName,
        gradeList: '',
        monthlyInsuranceCost: NP.times(this.gradeFormObj.monthlyInsuranceCost || 0, 100)
      }
      this.splitParam(_gradeList, params)
      // this.$apis.serviceConfig.addGradeApi(params).then(res => {
      //   console.log(res)
      //   if (res) {
      //     this.$message.success('提交成功')
      //     this.jumpListPage()
      //   }
      // })
    },
    splitParam(list, params) {
      let promiseList = []
      for (let i = 0; i < list.length; i = i + 5) {
        let _gradeList = list.slice(i, i + 5)
        let _params = params
        _params.gradeList = _gradeList
        promiseList.push(
          new Promise((resolve, reject) => {
            this.$apis.serviceConfig
              .addGradeApi(_params)
              .then(res => {
                resolve(res)
              })
              .catch(err => {
                reject(err)
              })
          })
        )
      }
      Promise.all(promiseList).then(res => {
        this.$message.success('提交成功')
        this.jumpListPage()
      })
    },
    handleAddGrade() {
      const _gradeList = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
      if (this.gradeList.length == _gradeList.length) return this.$message.error(`最多添加${_gradeList.length}个规格`)
      const _grade = _gradeList[this.gradeList.length]
      this.gradeList.push(addGradeItem(_grade, this.formObj.salePeriod))
    },
    // 编辑的时候获取规格数据
    getSpecificaList(serviceCode) {
      this.$apis.serviceConfig.getSpecificaListApi({ serviceCode: this.routeInfo.serviceCode }).then(res => {
        if (res) {
          if (res.length == 0) {
            this.ininData()
          } else {
            this.gradeList = handleGradeData(res, this.formObj.salePeriod)
          }
        }
      })
    },
    jumpListPage() {
      this.$router.push('/serviceConfig/index')
    },

    // 查看基本信息详情
    getServiceDetail() {
      this.$apis.serviceConfig.getServiceDetailApi({ id: this.routeInfo?.id }).then(res => {
        if (res) {
          const transKeyList = ['buyConditions', 'salePeriod', 'exclusionsResponsibility']
          for (const key in this.formObj) {
            this.formObj[key] = transKeyList.includes(key) && res[key].split ? res[key].split(',').map(item => parseInt(item)) : res[key]
          }
          this.gradeFormObj.monthlyInsuranceCost = NP.divide(res.monthlyInsuranceCost || 0, 100)
          if (res.copyServiceCode) {
            this.formObj.copyServiceName = `${res.guorenCode || '--'} ${res.copyServiceName}`
          } else {
            this.formObj.copyServiceName = res.guorenCode
          }
        }
      })
    },
    async nextStep() {
      if (this.routeInfo.type == 2) {
        this.getSpecificaList()
        this.firstPage = false
        return
      }
      this.$refs.baseInfoRef.$refs.formRef.validate(bValid => {
        this.$refs.servicesRef.$refs.formRef.validate(sValid => {
          if (bValid && sValid) {
            const params = JSON.parse(JSON.stringify(this.formObj))
            params.exclusionsResponsibility = params.exclusionsResponsibility.join(',')
            params.buyConditions = params.buyConditions.join(',')
            params.salePeriod = params.salePeriod.join(',')
            if (!params.copyServiceCode) {
              params.guorenCode = params.copyServiceName
            }
            if (this.routeInfo.id) params.id = this.routeInfo.id
            delete params.copyServiceName
            this.$apis.serviceConfig.addServicesProject(params).then(res => {
              if (res) {
                if (this.routeInfo.id) {
                  this.getSpecificaList()
                } else {
                  this.ininData()
                  this.routeInfo.serviceCode = res.serviceCode
                }
                this.routeInfo.serviceName = res.serviceName
                this.firstPage = false
              }
            })
          }
        })
      })
    },
    uploadSuccess(e) {
      this.formObj[e.attr] = e.url
    },
    delImage(e) {
      this.formObj[e.attr] = ''
    },
    // 获取责任和条件
    getConfigList() {
      this.$apis.serviceConfig.getCommonConfig({}).then(res => {
        if (!res) return
        this.conditionList = res.filter(item => item.contentType == 0)
        this.responsibilityList = res.filter(item => item.contentType == 1)
      })
    },

    // 添加  编辑 =》 购买条件或者除外责任
    createConfig(type, row) {
      const { id, value } = this.curEditCondition
      if (!value) {
        row.newItem = false
        let key = type == 0 ? 'conditionList' : 'responsibilityList'
        this[key] = this[key].filter(item => !!item.contractContent)
        this.clearData()
        this.$message.error(`${type == 0 ? '购买条件' : '除外责任'}不能为空`)
        return
      }
      const params = {
        contentType: type,
        contractContent: value
      }
      if (id) params.id = id
      this.$apis.serviceConfig
        .createCommonConfig(params)
        .then(res => {
          if (res) {
            this.$message.success('操作成功')
            this.getConfigList()
          }
        })
        .finally(end => {
          row.newItem = false
          this.clearData()
        })
    },
    clearData() {
      this.curEditCondition = {
        id: '',
        value: ''
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.container {
  .main-wrap {
    padding: 32px 20px;
    .codeSlot-class {
      font-size: 14px;
      /deep/ .my-autocomplete {
        width: 432px;
      }
      /deep/ .el-input__inner {
        width: 432px;
      }
      .code {
        color: #333;
        margin-right: 13px;
      }
      .name {
        color: #999999;
      }
    }
    .services-table {
      margin-top: 20px;
      &:first-child {
        margin-top: 0;
      }
    }
    .add-btn {
      display: inline-block;
      color: #2a58ad;
      cursor: pointer;
      i {
        font-size: 20px;
        vertical-align: middle;
      }
    }
  }
  .base-info {
    background-color: #fff;
    /deep/ .glsx-combi-form-block {
      .el-form-item:last-child {
        margin: 0;
      }
    }
    .logo-setting {
      width: 778px;
      background: #f9f9f9;
      padding: 20px 0;
      .upload-ctnr {
        margin-bottom: 20px;
        &:nth-child(3) {
          margin-bottom: 0;
        }
      }

      .upload-tip {
        margin-left: 154px;
        height: 20px;
        font-weight: 400;
        font-size: 14px;
        color: #999999;
      }
    }
  }
  .services-wrap {
    margin-top: 20px;
    background-color: #fff;
    /deep/ .editor {
      width: 935px !important;
    }
    .buy-condition {
      .el-checkbox {
        width: fit-content;
        margin-bottom: 10px;
      }
      /deep/ .el-checkbox__input {
      }
      /deep/ .el-checkbox__label {
        // display: inline-flex;
        // align-items: center;
      }
      .condition-text {
        display: inline-flex;
        align-items: center;
        .condition-input {
          width: 592px;
        }
      }
      .sign {
        margin-right: 8px;
      }
      .condition {
        display: inline-block;
        box-sizing: border-box;
        vertical-align: text-top;
        white-space: pre-wrap;
        width: 592px;
        line-height: 32px;
        background: #f5f7fa;
        border-radius: 4px;
        padding: 0 12px;
        font-size: 14px;
        color: #333333;
      }
      .el-checkbox {
        display: block;
      }
      .edit {
        color: #c6c6c6;
        margin-left: 8px;
      }
    }
  }
  .setting-wrap {
    background-color: #fff;
    .cost-input {
      width: 432px;
    }
  }
  .footer-btn {
    text-align: center;
    margin-top: 16px;
  }
}
</style>