<template>
  <div class="warpper">
    <header>
      <!-- <span>公司注册方案</span>
      <i class="el-icon-close"></i>-->
    </header>
    <div class="content">
      <div class="title">
        <div></div>
        <div>方案信息</div>
      </div>
      <div class="cell-group">
        <span>
          <span>*</span>
          公司名称：
        </span>
        <el-input v-model="name" placeholder="请输入客户的商号或公司全称（城市+商号+行业+组织形式）"></el-input>
      </div>
      <div class="cell-group">
        <span>
          <span>*</span>
          注册地区：
        </span>
        <div class="region">
          <el-select v-model="region" placeholder="请选择">
            <el-option
              v-for="(item,index) in options"
              :key="index"
              @click.native="getAreaIndex(index)"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
          <el-select v-model="value" placeholder="请选择">
            <el-option
              v-for="item in cities"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </div>
      </div>
      <div class="cell-group">
        <span>
          <span>*</span>
          纳税人类型：
        </span>
        <div class="select">
          <el-select v-model="taxpayerValue" placeholder="请选择">
            <el-option
              v-for="item in taxpayer"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </div>
      </div>
      <div class="cell-group">
        <span>
          <!-- <span>*</span> -->
          公司性质：
        </span>
        <div class="select">
          <el-select v-model="natureValue" placeholder="请选择">
            <el-option
              v-for="item in nature"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </div>
      </div>
      <div class="cell-group">
        <span>
          <span>*</span>
          组织类型：
        </span>
        <div class="select">
          <el-select v-model="tissueValue" placeholder="请选择">
            <el-option
              v-for="item in tissue"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </div>
      </div>
      <div class="cell-group">
        <span>
          <span>*</span>
          从事行业：
        </span>
        <div class="industry">
          <el-radio-group v-model="industryValue">
            <el-radio-button :label="item" v-for="(item, index) in industry" :key="index"></el-radio-button>
          </el-radio-group>
        </div>
      </div>
      <div class="cell-group">
        <span>
          <!-- <span>*</span> -->
          经营范围：
        </span>
        <el-input type="textarea" :rows="3" placeholder="请自定义输入公司经营范围，每个经营项以“ ；”隔开" v-model="scope"></el-input>
      </div>
      <div class="cell-group">
        <span>
          <!-- <span>*</span> -->
          方案备注：
        </span>
        <el-input v-model="notes" placeholder="请输入该方案其他备注"></el-input>
      </div>
      <div class="cell-group submitwrap">
        <el-button @click="submitAdd">提交</el-button>
      </div>
    </div>
  </div>
</template>
<script>
import req from "axios";
export default {
  data() {
    return {
      passCompanyDialog: false, // 传递到父组件，关闭对话框
      name: "",
      cities: [], // 省对应的城市区域集合 实现联动
      options: [
        {
          label: "北京市",
          value: "北京市",
          children: [
            {
              value: "朝阳区",
              label: "朝阳区"
            },
            {
              value: "海淀区",
              label: "海淀区"
            },
            {
              value: "顺义区",
              label: "顺义区"
            },
            {
              value: "东城区",
              label: "东城区"
            },
            {
              value: "西城区",
              label: "西城区"
            },
            {
              value: "丰台区",
              label: "丰台区"
            },
            {
              value: "石景山区",
              label: "石景山区"
            }
          ]
        },
        {
          value: "上海市",
          label: "上海市",
          children: [
            {
              value: "杨浦区",
              label: "杨浦区"
            },
            {
              value: "嘉定区",
              label: "嘉定区"
            },
            {
              value: "崇明区",
              label: "崇明区"
            }
          ]
        },
        {
          label: "杭州市",
          value: "杭州市",
          children: [
            {
              value: "西湖区",
              label: "西湖区"
            },
            {
              value: "江干区",
              label: "江干区"
            },
            {
              value: "余杭区",
              label: "余杭区"
            },
            {
              value: "上城区",
              label: "上城区"
            },
            {
              value: "拱墅区",
              label: "拱墅区"
            },
            {
              value: "滨江区",
              label: "滨江区"
            },
            {
              value: "下城区",
              label: "下城区"
            },
            {
              value: "萧山区",
              label: "萧山区"
            }
          ]
        },
        {
          value: "深圳市",
          label: "深圳市",
          children: [
            {
              value: "南山区",
              label: "南山区"
            },
            {
              value: "福田区",
              label: "福田区"
            },
            {
              value: "罗湖区",
              label: "罗湖区"
            },
            {
              value: "龙岗区",
              label: "龙岗区"
            },
            {
              value: "前海自贸区",
              label: "前海自贸区"
            }
          ]
        },
        {
          label: "成都市",
          value: "成都市",
          children: [
            {
              value: "锦江区",
              label: "锦江区"
            },
            {
              value: "高新区",
              label: "高新区"
            },
            {
              value: "武侯区",
              label: "武侯区"
            },
            {
              value: "金牛区",
              label: "金牛区"
            },
            {
              value: "青羊区",
              label: "青羊区"
            },
            {
              value: "天府新区",
              label: "天府新区"
            }
          ]
        },
        {
          label: "广州市",
          value: "广州市",
          children: [
            {
              value: "天河区",
              label: "天河区"
            },
            {
              value: "越秀区",
              label: "越秀区"
            }
          ]
        }
      ],
      region: "",
      taxpayerValue: "",
      natureValue: "",
      value: "",
      industryValue: "文化传媒类",
      tissueValue: "",
      notes: "",
      scope: "",
      taxpayer: [
        {
          value: "内资小规模",
          label: "内资小规模"
        },
        {
          value: "内资一般人",
          label: "内资一般人"
        },
        {
          value: "合资小规模",
          label: "合资小规模"
        },
        {
          value: "合资一般人",
          label: "合资一般人"
        },
        {
          value: "外资小规模",
          label: "外资小规模"
        },
        {
          value: "外资一般人",
          label: "外资一般人"
        }
      ],
      nature: [
        {
          value: "股份",
          label: "股份"
        },
        {
          value: "集团",
          label: "集团"
        }
      ],
      tissue: [
        {
          value: "有限公司",
          label: "有限公司"
        },
        {
          label: "个人独资",
          value: "个人独资"
        },
        {
          label: "合伙企业",
          value: "合伙企业"
        }
      ],
      industry: [
        "文化传媒类",
        "科技类",
        "影业类",
        "贸易类",
        "咨询类",
        "广告类",
        "管理类",
        "租赁类",
        "代理类",
        "培训类",
        "设计类",
        "服务类",
        "工程类"
      ]
    };
  },
  methods: {
    getAreaIndex(index) {
      this.value = ""; // 点击 省级 城市区域的value清空
      this.cities = this.options[index].children;
    }, // 获取地区索引
    submitAdd() {
      // 非空判断
      if (this.name == "") {
        this.$message("公司注册名称不能为空");
        return;
      }
      if (this.region == "") {
        this.$message("公司注册地区省份不能为空");
        return;
      }
      if (this.value == "") {
        this.$message("公司注册地区市区不能为空");
        return;
      }

      if (this.taxpayerValue == "") {
        this.$message("公司注册纳税人类型不能为空");
        return;
      }
      // if (this.natureValue == "") {
      //   this.$message("公司注册公司性质不能为空");
      //   return;
      // } // 公司性质 股份和 集团  在提交给后端后，可以为空
      if (this.tissueValue == "") {
        this.$message("公司注册组织类型不能为空");
        return;
      }
      if (this.industryValue == "") {
        this.$message("公司注册从事行业不能为空");
        return;
      }

      console.log(
        "按提交按钮的提交前的参数：",
        "公司名称：",
        this.name,
        "注册地区-省：",
        this.region,
        "注册地区-市：",
        this.value,
        "纳税人类型：",
        this.taxpayerValue,
        "公司性质：",
        this.natureValue,
        "组织类型：",
        this.tissueValue,
        "从事行业：",
        this.industryValue,
        "经营范围：",
        this.scope,
        "方案备注：",
        this.notes
      );
      this.$emit("companyAddDone", this.passCompanyDialog);

      req
        .post(
          "/api/web/action/icapi/springBoard",
          {
            actionType: "submitProgramme",
            actionBody: {
              // needNo: "N202002141324bupnr8L",
              needNo: this.$route.query.needNo,
              solutionContent: {
                bizType: "companyreg", // 注册类型：
                solution: {
                  // 公司注册方案
                  companyName: this.name, //公司名称
                  city: this.region, // 注册地区：省
                  area: this.value, // 注册地区：市
                  companyCategory: this.taxpayerValue, // 纳税人类型
                  companyType: this.natureValue, // 公司性质
                  orgType: this.tissueValue, // 组织类型
                  industryType: this.industryValue, // 从事行业
                  scope: this.scope, //  经营范围
                  remark: this.notes, // 方案备注
                  // 云上公司注册方案
                  park: "", // 注册园区
                  registerType: "", // 注册类型
                  productType: "" // 产品类型
                }
              }
            }
          },
          {
            headers: {
              // token: "3260d5a2452441dd93ecc7ecb35f6dc0",
              token: this.$route.query.token,
              userpin: "39fcf7bc5f6c4e55a1f85d750e37316b"
            }
          }
        )
        .then(res => {
          console.log("提交公司注册方案", res);
          if (res.data.status == 0) {
            this.$message("公司注册方案提交成功");
            // 清空 字段
            this.name = "";
            this.region = "";
            this.value = "";
            this.taxpayerValue = "";
            this.natureValue = "";
            this.tissueValue = "";
            this.industryValue = "";
            this.scope = "";
            this.notes = "";
            // this.$emit("companyAddDone", this.passCompanyDialog);
          } else {
            this.$message("公司注册方案提交失败");
          }
        });
    }
  }
};
</script>
<style lang="scss">
.warpper {
  header {
    /* height: 43px; */
    /* padding: 0 20px; */
    border-bottom: 1px solid #e8e8e8;
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: rgba(51, 51, 51, 1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    > i {
      cursor: pointer;
    }
  }
  .content {
    box-sizing: border-box;
    .title {
      display: flex;
      height: 38px;
      align-items: flex-end;
      font-size: 14px;
      font-family: PingFang-SC-Bold, PingFang-SC;
      font-weight: bold;
      color: rgba(51, 51, 51, 1);
      box-sizing: border-box;
      /* padding-left: 70px; */
      padding-left: 50px;
      > div:nth-child(1) {
        width: 2px;
        margin-right: 6px;
        height: 12px;
        background: rgba(223, 183, 106, 1);
      }
    }
    .cell-group {
      margin-top: 20px;
      box-sizing: border-box;
      /* padding-left: 55px; */
      padding-left: 75px;
      > span {
        display: inline-block;
        width: 94px;
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        text-align: right;
        > span {
          color: #dfb76a;
          font-size: 12px;
        }
      }
      .el-input {
        width: 430px;
        .el-input__inner {
          height: 34px;
          line-height: 0;
        }
      }
      .el-textarea {
        width: 430px;
        display: inline-block;
        .el-textarea__inner {
          resize: none;
        }
      }
      > .region {
        display: inline-block;
        .el-select {
          .el-input--suffix {
            width: 210px;
          }
          .el-input--suffix:nth-child(1) {
            margin-right: 10px;
          }
        }
      }
      > .select {
        display: inline-block;
        .el-select {
          .el-input--suffix {
            width: 430px;
          }
        }
      }
      > .industry {
        display: inline-block;
        /* width: 430px; */
        width: 600px;
        .el-radio-button__inner {
          padding: 0;
          line-height: 34px;
          text-align: center;
          width: 100px;
          height: 34px;
          background: rgba(255, 255, 255, 1);
          border-radius: 3px;
          border: 1px solid rgb(7, 10, 14);
          margin-right: 10px;
          margin-top: 10px;
        }
        .el-radio-button {
          position: relative;
        }
        // 小图标
        .el-radio-button__orig-radio:checked + .el-radio-button__inner::after {
          content: "";
          background: url("../../assets/imgs/fqembed/right.png") no-repeat;
          background-size: 103% 103%;
          width: 21.6px;
          height: 22.6px;
          position: absolute;
          right: -1px;
          bottom: 0;
        }
        .el-radio-button__orig-radio:checked + .el-radio-button__inner {
          color: #333333;
          border-color: #dfb76a;
          box-shadow: none;
        }

        .el-radio-button__inner:hover {
          color: #333;
        }
        .el-radio-button:nth-child(5n) {
          .el-radio-button__inner {
            margin-right: 0;
          }
        }
      }
      > .el-button {
        width: 106px;
        height: 30px;
        background: rgba(223, 183, 106, 1);
        border-radius: 3px;
        padding: 0;
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: rgba(255, 255, 255, 1);
        margin-left: 94px;
      }
    }
    .cell-group:nth-child(7),
    .cell-group:nth-child(8) {
      display: flex;
      > span {
        margin-top: 15px;
      }
    }
    .cell-group:nth-of-type(10) {
      margin-top: 25px;
    }
    .submitwrap {
      padding-left: 30%;
    }
  }
}
</style>