shopSet.vue 18.9 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
<!-- 店铺设置 -->
<template>
  <d2-container>
    <el-form ref="shopSetFrom"
             class="shopSetFrom d2-container-content"
             :model="form"
             :rules="formRules"
             label-width="120px"
             v-loading="$store.state.d2admin.loading.value">
      <p class="edit-sub-title">
        店铺设置
        <span class="merchantName">{{ info.merchantName }} {{ info.merchantId }}</span>
      </p>
      <el-form-item label="业务性质:"
                    prop="businessType">
        <el-select v-model="form.businessType"
                   placeholder="请选择"
                   class="el_select itd">
          <el-option v-for="item in businessNature"
                     :key="item.confId"
                     :value="item.confId"
                     :label="item.confName" />
        </el-select>
        <span class="item-tips">注:包含直营渠道和直营4S店两种业务性质</span>
      </el-form-item>
      <el-form-item label="下级商户:">
        <div v-for="(item, index) in form.list"
             :key="index">
          <div class="inputCol">
            <!-- <el-form-item :prop="'list.' + index + '.merchantNo'"
                          :rules="[{ required: true, message: '请选择二级流量方', trigger: 'change' }]"> -->
            <el-form-item>
              <el-select v-model="item.merchantNo"
                         filterable
                         remote
                         reserve-keyword
                         placeholder="请输入关键字"
                         style="width: 432px"
                         :remote-method="remoteMethod"
                         @change="changeOpt"
                         :loading="loading">
                <el-option v-for="(opt, optIndex) in options"
                           :key="optIndex"
                           :label="opt.merchantName"
                           :value="opt.merchantNo"
                           :disabled="setDisabled(opt.merchantNo)">
                </el-option>
              </el-select>
              <el-button type="text"
                         style="color: red;paddingLeft:10px"
                         @click="handleDelMerchant(index)">删除</el-button>
            </el-form-item>
          </div>
        </div>
        <div>
          <el-button type="primary"
                     size="small"
                     plain
                     @click="handleAddMerchant">添加一行</el-button>
        </div>
      </el-form-item>
      <el-form-item label="部署状态:"
                    prop="deployScene">
        <el-checkbox-group v-model="form.deployScene">
          <el-checkbox v-for="(item, index) in sceneForShop"
                       :key="index"
                       :label="item.confId">{{ item.confValue
          }}</el-checkbox>
        </el-checkbox-group>
      </el-form-item>
      <el-form-item label="设置区域督导:"
                    prop="areaSupervision">
        <el-select clearable
                   filterable
                   value-key="userId"
                   v-model="form.areaSupervision"
                   collapse-tags
                   class="el_select itd"
                   placeholder="请选择">
          <el-option v-for="item in supervisionOptionsList"
                     :key="item.userId"
                     :label="item.userName"
                     :value="item">
          </el-option>
        </el-select>
        <span class="item-tips">注:区域督导在账户中心创建广联数科员工,角色类型选区域督导</span>
      </el-form-item>
      <el-form-item label="驻店负责人:"
                    prop="residentManager">
        <el-select clearable
                   filterable
                   value-key="userId"
                   v-model="form.residentManager"
                   collapse-tags
                   class="el_select itd"
                   placeholder="请选择">
          <el-option v-for="item in residentManagerOptionsList"
                     :key="item.userId"
                     :label="item.userName"
                     :value="item">
          </el-option>
        </el-select>
        <span class="item-tips">注:设置店面的驻店负责人,可配置驻店月份绩效</span>
      </el-form-item>
      <el-form-item>
        <div class="month-set-div">
          <div class="month-choose">
            <span class="month-choose-span">设置每月产值绩效(绩效细化到驻店负责人,汇总给区域督导)</span>
            <span>
              <el-date-picker v-model="year"
                              type="year"
                              placeholder="选择年"
                              value-format="yyyy"
                              format="yyyy"
                              :clearable="false"
                              :picker-options="pickerOption"
                              style="width:136px"
                              @change="chooseYear">
              </el-date-picker>
            </span>
          </div>
          <div class="set-value-div">
            <div class="label">目标产值:</div>
            <div class="right">
              <div class="set-value-alone"
                   v-for="(item, index) in outputValueListByYear"
                   :key="index">
                <p>{{ index + 1 }}月</p>
                <p>
                  <el-input style="height: 32px;"
                            v-model="item.outputValue"
                            @input="handleInput($event, item, index)"
                            :disabled="item.isDisabled"
                            placeholder="请输入" />
                </p>
              </div>
            </div>
          </div>
        </div>
      </el-form-item>
      <el-form-item>
        <div class="btnCon">
          <el-button type="primary"
                     @click="handleSave"
                     :disabled="$store.state.d2admin.loading.value"
                     class="ok-btn">
            提交
          </el-button>
          <el-button class="cancel-btn"
                     @click="handleCancel">
            取消
          </el-button>
        </div>
      </el-form-item>
    </el-form>
  </d2-container>
</template>

<script>
import { deepClone } from '@/common/util'
import { getShopSetting, listByMerchantIdAndYear, shopSetting } from '@/api/shopConfig.js'
import { serviceGetMerchantList } from '@api/merchant'
import { findMerchantStaffList } from '@api/index'
import { businessNature, sceneForShop } from '@/common/constants.js'
import { mapActions } from 'vuex'
import { rangePickerOptions_year, limitPrice } from '@/common/format'
export default {
  name: 'ShopSet',
  data() {
    return {
      userInfo: this.$store.state.d2admin.user.info,
      businessNature: businessNature,
      pickerOption: rangePickerOptions_year,
      parkServiceList: [],
      info: {},
      setInfo: {},
      options: [],
      loading: false,
      sceneForShop: deepClone(sceneForShop),
      supervisionOptionsList: [],
      residentManagerOptionsList: [],
      form: {
        businessType: '',
        list: [],
        deployScene: [],
        areaSupervision: {},
        residentManager: {},
        currentMonthOutputValue: '',
        nextMonthOutputValue: ''
      },
      outputValueListByYear: [],
      year: '',
      nowYear: null,
      nowMoth: null,
      nowDay: null,
      formRules: {
        // businessType: [{
        //   required: true,
        //   message: '请选择业务性质',
        //   trigger: 'change'
        // }],
        // deployScene: [{
        //   required: true,
        //   message: '请选择部署状态',
        //   trigger: 'change'
        // }],
        // areaSupervision: [{
        //   required: true,
        //   message: '请选择区域督导',
        //   trigger: 'change'
        // }],
        // residentManager: [{
        //   required: true,
        //   message: '请选择驻店负责人',
        //   trigger: 'change'
        // }],
      }
    }
  },

  components: {},

  computed: {},

  mounted() {
    const nowDate = new Date()
    this.year = nowDate.getFullYear().toString()
    this.nowYear = nowDate.getFullYear().toString()
    this.nowMoth = nowDate.getMonth() + 1
    this.nowDay = nowDate.getDate()
    this.info = this.$route.params?.info
    this.getShopSetting(this.info)
    this.findMerchantStaffList()
    this.getSelectList(this.info)
    this.listByMerchantIdAndYear(this.year)
  },

  methods: {
    ...mapActions({
      get: 'd2admin/base/get',
      close: 'd2admin/page/close'
    }),
    async getBaseData() {
    },

    // 获取店铺设置信息
    getShopSetting(info) {
      const { merchantId } = info
      getShopSetting({ merchantId }).then(res => {
        // this.setInfo = res
        this.form = deepClone(res)
        console.log(this.form)
        if (this.form.list && this.form.list.length > 0) {
          this.form.list = this.form.list.map(item => {
            const item_new = {
              id: item.id,
              merchantName: item.subMerchantName,
              merchantNo: item.subMerchantId
            }
            this.options.push(item_new)
            return item_new
          })
        }
      })
    },

    handleAddMerchant() {
      this.options = []
      this.form.list.push({
        // merchantName: '',
        merchantNo: ''
      })
    },
    handleDelMerchant(index) {
      this.form.list.splice(index, 1)
    },
    remoteMethod(queryString) {
      if (queryString) {
        this.loading = true
        setTimeout(() => {
          this.loading = false
          var params = { currentPage: 1, pageSize: 1000, merchantIdName: queryString }
          serviceGetMerchantList(params).then(res => {
            this.options = res.list || []
          })
        }, 200)
      } else {
        this.options = []
      }
    },
    changeOpt(val) {
      const info = this.options.find(item => item.merchantNo == val)
      this.form.list = this.form.list.map(item => {
        if (item.merchantNo == info.merchantNo) {
          const id = deepClone(item.id)
          delete info.id
          item = deepClone(info)
          if (id) {
            item.id = id
            // return item = Object.assign(info, { id: item.id })
          }
        }
        return item
      })
    },
    setDisabled(val) {
      const info = this.form.list.find(item => item.merchantNo == val)
      if (info) {
        return true
      } else {
        return false
      }
    },
    findMerchantStaffList() {
      findMerchantStaffList({ merchantId: -1 }).then((result) => {
        this.supervisionOptionsList = result.map((item) => {
          return {
            userType: 1,
            userId: item.uuid,
            userName: item.staffName,
            userNum: item.staffPhone
          }
        })
      })
    },
    getSelectList(info) {
      const { merchantId } = info
      findMerchantStaffList({ merchantId }).then((result) => {
        this.residentManagerOptionsList = result.map((item) => {
          return {
            userType: 2,
            userId: item.uuid,
            userName: item.staffName,
            userNum: item.staffPhone
          }
        })
      })
    },
    chooseYear() {
      this.listByMerchantIdAndYear(this.year)
    },
    // 根据年份获取产值列表
    listByMerchantIdAndYear(year) {
      const { merchantId } = this.info
      listByMerchantIdAndYear({ yearStr: year, merchantId: merchantId }).then((result) => {
        this.outputValueListByYear = result || []
        if (this.outputValueListByYear && this.outputValueListByYear.length > 0) {
          this.outputValueListByYear = this.outputValueListByYear.map(item => {
            const _flag = this.setInputDisabled(item)
            item.isDisabled = _flag
            return item
          })
        }
      })
    },
    // 产值输入框输入限制
    handleInput(newValue, item, index) {
      newValue = newValue.replace(/[^\d.]/g, '') // 清除“数字”和“.”以外的字符
      this.outputValueListByYear[index].outputValue = limitPrice(newValue, item.outputValue, 6, 0, 1)
    },
    // 产值输入框是否禁用
    setInputDisabled(item) {
      const _itemYear = item.dataMonth.split('-')[0]
      const _itemMonth = item.dataMonth.split('-')[1]
      // console.log('_itemYear == this.year', _itemYear, this.nowYear, _itemYear == this.nowYear);
      if (_itemYear == this.nowYear) { // 是否当前年
        // console.log('this.nowMoth == _itemMonth', this.nowMoth, parseInt(_itemMonth), this.nowMoth == parseInt(_itemMonth));
        if (this.nowMoth == parseInt(_itemMonth)) { // 如果是当前年本月
          item.isCurrentMonthOutputValue = true // 代表为当前月产值
          if (item.outputValue == 0) { // 目标产值为0未设置过则可以设置
            return false
          } else {
            if (this.nowDay <= 10) { // 当前月10号前可更新覆盖产值
              // this.form.currentMonthOutputValue = this.outputValueListByYear[index].outputValue
              return false
            } else {
              return true
            }
          }
        } else if (this.nowMoth + 1 == parseInt(_itemMonth)) { // 如果是当前年下个月
          // this.form.nextMonthOutputValue = this.outputValueListByYear[index].outputValue
          item.isNextMonthOutputValue = true // 代表为下月产值
          return false
        } else {
          return true
        }
      } else {
        return true
      }
    },

    /**
     * 保存信息
     */
    handleSave() {
      const _params = deepClone(this.form)
      _params.merchantId = this.info.merchantId
      _params.merchantName = this.info.merchantName
      if (_params.list && _params.list.length > 0) {
        const list = []
        let info
        _params.list.forEach(item => {
          info = deepClone(item)
          info.subMerchantId = info.merchantNo
          info.subMerchantName = info.merchantName
          list.push(info)
        })
        _params.list = list
      }
      if (!_params.areaSupervision) {
        _params.areaSupervision = {}
      } else {
        _params.areaSupervision = {
          userId: _params.areaSupervision.userId,
          userType: _params.areaSupervision.userType,
          userName: _params.areaSupervision.userName,
          userNum: _params.areaSupervision.userNum
        }
      }
      if (!_params.residentManager) {
        _params.residentManager = {}
      } else {
        _params.residentManager = {
          userId: _params.residentManager.userId,
          userType: _params.residentManager.userType,
          userName: _params.residentManager.userName,
          userNum: _params.residentManager.userNum
        }
      }
      this.outputValueListByYear.forEach(item => {
        if (item.isCurrentMonthOutputValue) {
          _params.currentMonthOutputValue = item.outputValue
        } else if (item.isNextMonthOutputValue) {
          _params.nextMonthOutputValue = item.outputValue
        }
      })
      console.log(_params)
      shopSetting({ dataString: JSON.stringify(_params) }).then(res => {
        this.notice.okTips()
        this.handleCancel()
      })
    },
    handleCancel() {
      this.close({ tagName: '/shopSet' })
      this.$router.push({ name: 'shopConfig' })
    }
  }
}

</script>
<style scoped  lang="scss" >
.d2-container-content {
  background: #ffffff;
}

.shopSetFrom.d2-container-content {
  margin-top: 0 !important;
}

.edit-sub-title {
  padding-bottom: 14px;
  border-bottom: 1px solid #e8e8ea;

  .merchantName {
    font-weight: 400;
    color: #666;
    margin-left: 15px;
    font-size: 14px;
  }
}

.shopSetFrom .addorder_page {
  padding: 20px;
  position: relative;
}

.shopSetFrom .el_select {
  width: 100%;
}

.shopSetFrom .sort_input {
  width: 200px;
}

.shopSetFrom .warningFont {
  color: #f56c6c;
  font-size: 12px;
  line-height: 1;
}

.shopSetFrom .text-wrapper {
  white-space: pre-wrap;
}

.shopSetFrom .itd {
  width: 432px;
}

.shopSetFrom .pro-img {
  width: 80px;
  height: 80px;
}

.shopSetFrom .tips {
  font-size: 12px;
  color: #999999;
  margin: 0 0;
}

::v-deep.shopSetFrom .el-form-item {
  margin-bottom: 36px;
}

.shopSetFrom .el-radio__label {
  height: 20px;
  line-height: 20px;
  color: #a1a1a1;
  padding: 5px 10px;
  border: 1px solid #a1a1a1;
  border-radius: 2px;
}

.shopSetFrom .is-checked .el-radio__label {
  border: 1px solid #0947c6;
}

.shopSetFrom .el-radio__input {
  display: none;
}

.base-pro-block-wh {
  width: 160px;
  height: 262px;
  margin-bottom: 20px;
}

.base-pro-block {
  position: relative;
  display: inline-block;
  margin-right: 20px;
}

.base-pro-block .base-pro-block-wh {
  border: 1px solid #e5e6e7;
  box-shadow: 2px 2px 5px 1px rgba(0, 0, 0, 0.1);
}

.base-pro-block .base-pro-block-wh.is-checked {
  border: 1px solid #0947c6;
}

.base-pro-block .el-checkbox__label {
  padding: 0 0;
}

.base-pro-block .el-checkbox__input {
  display: none;
}

.base-pro-block .base-pro-block-wh .pro-icon {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  /* background: url("../../assets/uncheck.png"); */
  background-size: 24px 24px;
  margin: 0 0;
}

.base-pro-block .base-pro-block-wh.is-checked .pro-icon {
  /* background: url("../../assets/check.png"); */
  background-size: 24px 24px;
}

.base-pro-block .pro-icon img {
  width: 24px;
  height: 24px;
}

.base-pro-block img {
  vertical-align: top;
  width: 160px;
  height: 160px;
}

.base-pro-block .pro-block-txt {
  font-size: 12px;
  color: #a1a1a1;
  padding: 22px 12px;
}

.base-pro-block .block-title {
  color: #6c6f71;
  font-weight: bold;
}

.base-pro-block .ellipsis {
  width: 140px;
  height: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0 0;
}

.item-tips {
  padding-left: 10px;
  height: 17px;
  font-family: PingFangSC-Regular;
  font-weight: 400;
  font-size: 12px;
  color: #999999;
}

.add-merchant-btn {
  padding-top: 10px;
  height: 32px;
}

.inputCol {
  /* box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center; */
  // padding: 0 0 20px;
}

.month-set-div {
  width: 720px;
  height: 300px;
}

.month-choose {
  box-sizing: border-box;
  width: 100%;
  padding: 0 20px;
  height: 40px;
  background: #f2f4f7;
  border: 1px solid #e8e8ea;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.month-choose-span {
  /* padding-left: 20px; */
  font-family: PingFangSC-Regular;
  font-weight: 400;
  font-size: 14px;
  color: #333333;
}

.set-value-div {
  box-sizing: border-box;
  padding: 20px 36px;
  width: 100%;
  height: 251px;
  background: #ffffff;
  border: 1px solid #e8e8ea;
  display: flex;
  // flex-wrap: wrap;

  .label {
    height: 100%;
    width: 215px;
  }

  .right {
    display: flex;
    flex-wrap: wrap;
  }
}

.set-value-alone {
  width: 136px;
  height: 57px;
  margin-right: 8px;

  p {
    margin: 0;
  }

  &:nth-child(4n) {
    margin-right: 0;
  }
}

.btnCon {
  width: 710px;
  margin-top: 40px;
  text-align: center;
}
</style>