equitySet.vue 8.36 KB
<template>
  <div class="equity_container">
    <div class="top_wrap">
      <div class="title-header">
        <div class="line"></div>
        <div class="line_text">录单设置</div>
      </div>
      <div class="flex_box">
        <div class="content_main">
          <el-form :model="formData" :rules="rules" ref="ruleForm">
            <template v-for="(item, index) in formList">
              <el-form-item
                v-if="
                  item.prop != 'zyVoucher' && item.prop != 'goodsPriceModify'
                "
                :key="index"
                label-width="240px"
                :label="item.name"
                :prop="item.prop"
              >
                <el-radio-group
                  v-model="formData[item.prop]"
                  @change="changeType()"
                >
                  <el-radio :label="true">必填</el-radio>
                  <el-radio :label="false">非必填</el-radio>
                </el-radio-group>
              </el-form-item>
            </template>
          </el-form>
        </div>
        <div class="tip_container">
          <div class="tip_title">
            小程序端-录单-字段设置为必填将带“<span class="require">*</span>”号
          </div>
          <div class="img_wrap">
            <img
              class="viewimg"
              src="https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/web/mini_example_equity.png"
              alt=""
            />
          </div>
        </div>
      </div>
      <div class="title-header">
        <div class="line"></div>
        <div class="line_text">上传协议设置</div>
      </div>
      <div class="content_main">
        <el-form :model="formData" :rules="rules" ref="ruleForm">
          <template v-for="(item, index) in formList">
            <el-form-item
              :key="index"
              v-if="item.prop == 'zyVoucher'"
              label-width="240px"
              :label="item.name"
              :prop="item.prop"
            >
              <el-radio-group
                v-model="formData[item.prop]"
                @change="changeType()"
              >
                <el-radio :label="true">必须上传才分账</el-radio>
                <el-radio :label="false">无需上传</el-radio>
              </el-radio-group>
              <div class="tips-box">
                <p>
                  必须上传,则店面下单购买第三方权益或延保必须上传协议后才分账,未上传则订单不分帐;
                </p>
                <p>无需上传,则店面下单购买第三方权益或延保无上传协议要求。</p>
              </div>
            </el-form-item>
          </template>
        </el-form>
      </div>
      <div class="title-header">
        <div class="line"></div>
        <div class="line_text">商品价格修改</div>
      </div>
      <div class="content_main">
        <el-form :model="formData" :rules="rules" ref="ruleForm">
          <template v-for="(item, index) in formList">
            <el-form-item
              :key="index"
              v-if="item.prop == 'goodsPriceModify'"
              label-width="240px"
              :label="item.name"
              :prop="item.prop"
            >
              <el-radio-group
                v-model="formData[item.prop]"
                @change="changeType()"
              >
                <el-radio :label="true">禁止修改</el-radio>
                <el-radio :label="false">支持修改</el-radio>
              </el-radio-group>
              <div class="tips-box">
                <p>
                  禁止修改,指商品类目是权益服务或延保类,且供应方属于第三方的商品,下单购买时价格禁止修改;
                </p>
                <p>支持修改,指商品价格无限制,支持修改。</p>
              </div>
            </el-form-item>
          </template>
        </el-form>
      </div>
    </div>
    <div class="footer_btn">
      <el-button type="primary" class="ok-btn" @click="comfirm">
        确定
      </el-button>
      <el-button class="cancel-btn" @click="cancel"> 取消 </el-button>
    </div>
  </div>
</template>

<script>
import {
  orderFieldSettingList,
  orderFieldSettingUpdate
} from "@/api/shopConfig.js"
import { mapActions } from "vuex"
export default {
  name: "EquitySet",
  data() {
    return {
      settingInfo: [],
      formData: {
        carBrand: true,
        carNo: false,
        idNumber: false,
        zyVoucher: true,
        goodsPriceModify: false
      },
      rules: {
        carBrand: [
          { required: true, message: "请选择车型:", trigger: "change" }
        ],
        carNo: [
          { required: true, message: "请车架号(VIN)码:", trigger: "change" }
        ],
        idNumber: [
          { required: true, message: "请证件号码:", trigger: "change" }
        ],
        zyVoucher: [
          { required: true, message: "请选择上传协议", trigger: "change" }
        ],
        goodsPriceModify: [
          { required: true, message: "请选择价格修改", trigger: "change" }
        ]
      },
      formList: [
        {
          name: "选择车型:",
          prop: "carBrand"
        },
        {
          name: "车架号(VIN)码:",
          prop: "carNo"
        },
        {
          name: "证件号码:",
          prop: "idNumber"
        },
        {
          name: "上传协议:",
          prop: "zyVoucher"
        },
        {
          name: "价格修改:",
          prop: "goodsPriceModify"
        }
      ]
    }
  },
  computed: {
    merchantId() {
      const info = JSON.parse(this.$route.query.info)
      return info.merchantId
    },
    merchantName() {
      const info = JSON.parse(this.$route.query.info)
      return info.merchantName
    }
  },
  props: {},
  mounted() {
    this.getEquitySet()
  },
  methods: {
    ...mapActions({ close: "d2admin/page/close" }),
    getEquitySet() {
      orderFieldSettingList({
        merchantId: this.merchantId,
        scene: 0
      })
        .then((res) => {
          res.map((item) => {
            this.formData[item.fieldKey] = item.isRequired
          })
          this.settingInfo = res
        })
        .catch((err) => {
          console.log(err)
        })
    },
    changeType(e) {},
    comfirm() {
      const settings = this.settingInfo.map((item) => {
        item.isRequired = this.formData[item.fieldKey]
        return item
      })
      const params = {
        merchantId: this.merchantId,
        scene: 0,
        merchantName: this.merchantName,
        settings
      }
      orderFieldSettingUpdate(params)
        .then((res) => {
          this.notice.okTips("操作成功")
          this.cancel()
        })
        .catch((err) => {
          console.log(err)
        })
    },
    cancel() {
      this.$router.push({
        name: "shopConfig",
        params: {
          activeName: "equitySetting"
        }
      })
      this.close({ tagName: "/setWorkorderDetail" })
    }
  }
}
</script>
<style lang="scss" scoped>
.equity_container {
  .top_wrap {
    padding: 12px 20px;
    background: #fff;
    .flex_box {
      display: flex;
      .content_main {
        flex-shrink: 0;
        width: 50%;
      }
    }
    .title-header {
      display: flex;
      align-items: center;
      box-sizing: border-box;
      border-bottom: 1px solid #e8e8ea;
      padding: 12px 20px 16px;
      .line {
        width: 4px;
        height: 16px;
        background: #185efe;
        border-radius: 2px;
        margin-right: 8px;
      }
      .line_text {
        width: 150px;
        height: 24px;
        font-family: PingFangSC-Medium;
        font-weight: 500;
        font-size: 18px;
        color: #333333;
      }
    }
    .content_main {
      padding: 20px 0;
      .tips-box {
        color: #999999;
        font-size: 12px;
        p {
          margin: 0;
          line-height: 20px;
        }
      }
    }
    .tip_container {
      padding: 20px 0;

      .tip_title {
        padding-left: 48px;
        color: #333333;
        font-size: 14px;
        font-weight: 500;
        .require {
          color: #f24724;
        }
      }
      .img_wrap {
        padding-left: 30px;
        padding-top: 8px;
      }
      .viewimg {
        width: 192px;
        height: 370px;
      }
    }
  }

  .footer_btn {
    display: flex;
    align-items: center;
    padding: 16px 0px 16px 178px;
  }
}
</style>