<template>
  <div class="company">
    <div class="title">注册方案</div>
    <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane label="公司注册" name="1">
        <el-dialog title="公司注册方案" :visible.sync="companyAddDialog" width="60%" center>
          <companysub />
        </el-dialog>
        <div class="company-find">
          <div class="box">
            <div>方案编号：</div>
            <div>
              <el-input v-model="schemeNo" placeholder="请输入内容"></el-input>
            </div>
          </div>
          <div class="box">
            <div>服务单号：</div>
            <div>
              <el-input v-model="serviceNo" placeholder="请输入内容"></el-input>
            </div>
          </div>
          <div class="box">
            <div>公司名称：</div>
            <div>
              <el-input v-model="entName" placeholder="请输入内容"></el-input>
            </div>
          </div>
          <div class="box">
            <div>组织类型：</div>
            <div>
              <el-select v-model="tissue" placeholder="请选择">
                <el-option
                  v-for="item in tissueOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </div>
          </div>
        </div>
        <div class="company-find">
          <div class="box">
            <div>纳税人类型：</div>
            <div>
              <el-select v-model="taxpayer" placeholder="请选择">
                <el-option
                  v-for="item in taxpayerOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </div>
          </div>
          <div class="box">
            <div>注册城市：</div>
            <div>
              <el-select v-model="city" placeholder="请选择">
                <el-option
                  v-for="item in cityOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </div>
          </div>
          <div class="box">
            <div>方案状态：</div>
            <div>
              <el-select v-model="scheme" placeholder="请选择">
                <el-option
                  v-for="item in schemeOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </div>
          </div>
          <div class="box btn">
            <el-button>查询</el-button>
            <el-button @click="addCompany">新增</el-button>
          </div>
        </div>
        <div class="companylist">
          <el-table :data="companyData" style="width: 100%">
            <div slot="empty">
              <div class="ndata">
                <img src="@/assets/imgs/fqembed/datanull.png" alt />
              </div>
            </div>
            <el-table-column fixed prop="date" label="方案编号" width></el-table-column>
            <el-table-column prop="name" label="服务单号" width></el-table-column>
            <el-table-column prop="province" label="公司名称" width></el-table-column>
            <el-table-column prop="city" label="组织类型" width></el-table-column>
            <el-table-column prop="address" label="公司性质" width></el-table-column>
            <el-table-column prop="zip" label="纳税人类型" width></el-table-column>
            <el-table-column prop="zip" label="注册城市" width></el-table-column>
            <el-table-column prop="zip" label="方案状态">
              <template slot-scope="scope">
                <div class="payment">
                  <div :class="dotColor(1)"></div>
                  <div>{{scope.row.date}}</div>
                </div>
              </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作">
              <template slot-scope="scope">
                <div class="handle">
                  <!-- 需要判断当前付款状态是否有作废 -->
                  <span @click="toDetails(scope.$index,scope.row)">详情&nbsp;</span>&nbsp;
                  <span>|</span>&nbsp;
                  <span>&nbsp;作废</span>
                </div>
              </template>
            </el-table-column>
          </el-table>
          <el-dialog title="公司注册方案" :visible.sync="companyDetailDialog" width="60%" center>
            <Companydetail />
          </el-dialog>
        </div>
        <div class="block">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="currentPage2"
            :page-size="100"
            background
            layout="prev, pager, next, jumper"
            :total="1000"
          ></el-pagination>
        </div>
      </el-tab-pane>
      <el-tab-pane label="云上公司注册" name="2">
        <el-dialog title="云上公司注册方案" :visible.sync="cloudCompanyAddDialog" width="60%" center>
          <Cloudcompany />
        </el-dialog>
        <div class="company-find">
          <div class="box">
            <div>方案编号：</div>
            <div>
              <el-input v-model="cSchemeNo" placeholder="请输入内容"></el-input>
            </div>
          </div>
          <div class="box">
            <div>服务单号：</div>
            <div>
              <el-input v-model="cServiceNo" placeholder="请输入内容"></el-input>
            </div>
          </div>
          <div class="box">
            <div>公司名称：</div>
            <div>
              <el-input v-model="cEntName" placeholder="请输入内容"></el-input>
            </div>
          </div>
          <!-- <div class="box">
            <div>组织类型：</div>
            <div>
              <el-select v-model="tissue" placeholder="请选择">
                <el-option
                  v-for="item in tissueOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </div>
          </div>-->
        </div>
        <div class="company-find">
          <div class="box">
            <div>注册园区：</div>
            <div>
              <el-select v-model="regPark" placeholder="请选择">
                <el-option
                  v-for="item in regParkOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </div>
          </div>
          <div class="box">
            <div>产品类型：</div>
            <div>
              <el-select v-model="pType" placeholder="请选择">
                <el-option
                  v-for="item in pTypeOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </div>
          </div>
          <div class="box">
            <div>方案状态：</div>
            <div>
              <el-select v-model="cScheme" placeholder="请选择">
                <el-option
                  v-for="item in cSchemeOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </div>
          </div>
          <div class="box btn">
            <el-button>查询</el-button>
            <el-button @click="addCloudCompany">新增</el-button>
          </div>
        </div>
        <div class="companylist">
          <el-table :data="companyData" style="width: 100%">
            <div slot="empty">
              <div class="ndata">
                <img src="@/assets/imgs/fqembed/datanull.png" alt />
              </div>
            </div>
            <el-table-column fixed prop="date" label="方案编号" width></el-table-column>
            <el-table-column prop="name" label="服务单号" width></el-table-column>
            <el-table-column prop="province" label="注册园区" width></el-table-column>
            <el-table-column prop="city" label="产品类型" width></el-table-column>
            <el-table-column prop="address" label="注册类型" width></el-table-column>
            <el-table-column prop="zip" label="方案状态" width>
              <template slot-scope="scope">
                <div class="payment">
                  <div :class="dotColor(1)"></div>
                  <div>{{scope.row.date}}</div>
                </div>
              </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作" width>
              <template slot-scope="scope">
                <div class="handle">
                  <!-- 需要判断当前付款状态是否有作废 -->
                  <span @click="toDetails(scope.$index,scope.row)">详情&nbsp;</span>&nbsp;
                  <span>|</span>&nbsp;
                  <span>&nbsp;作废</span>
                </div>
              </template>
            </el-table-column>
          </el-table>
          <el-dialog title="云上公司注册方案" :visible.sync="cloudDetailDialog" width="60%" center>
            <Clouddetails />
          </el-dialog>
        </div>
        <div class="block">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="currentPage2"
            :page-size="100"
            background
            layout="prev, pager, next, jumper"
            :total="1000"
          ></el-pagination>
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import Companysub from "./Companysub.vue";
import Cloudcompany from "./Cloudcompany.vue";
import Companydetail from "./Companydetail.vue";
import Clouddetails from "./Clouddetails.vue";
import req from "axios";
export default {
  components: {
    Companysub,
    Cloudcompany,
    Companydetail,
    Clouddetails
  },
  data() {
    return {
      haveChoosedTab: 1, // 选中的Tab标签的名字，来判定详情是显示 公司详情 或 云公司详情
      companyAddDialog: false, // 公司注册对话框
      cloudCompanyAddDialog: false, // 云公司注册对话框
      companyDetailDialog: false, // 公司详情对话框
      cloudDetailDialog: false, // 云公司详情对话框
      activeName: "1",
      schemeNo: "",
      serviceNo: "",
      entName: "",
      tissue: "",
      taxpayer: "",
      city: "",
      tissueOptions: [
        {
          value: "个人独资",
          label: "个人独资"
        },
        {
          value: "合伙企业",
          label: "合伙企业"
        }
      ],
      taxpayerOptions: [
        {
          value: "内资小规模",
          label: "内资小规模"
        },
        {
          value: "内资一般人",
          label: "内资一般人"
        },
        {
          value: "外资小规模",
          label: "外资小规模"
        },
        {
          value: "外资一般人",
          label: "外资一般人"
        },
        {
          value: "合资小规模",
          label: "合资小规模"
        },
        {
          value: "合资一般人",
          label: "合资一般人"
        }
      ],
      cityOptions: [
        {
          value: "北京",
          label: "北京"
        },
        {
          value: "上海",
          label: "上海"
        },
        {
          value: "山西",
          label: "山西"
        },
        {
          value: "河北",
          label: "河北"
        }
      ],
      scheme: "",
      schemeOptions: [
        {
          value: "待确认",
          label: "待确认"
        },
        {
          value: "已完成",
          label: "已完成"
        },
        {
          value: "已作废",
          label: "已作废"
        }
      ],
      companyData: [
        {
          date: 123
        }
      ],
      // 云*******************
      regParkOptions: [],
      regPark: "",
      cSchemeNo: "",
      cServiceNo: "",
      cEntName: "",
      cScheme: "",
      cSchemeOptions: [
        {
          value: "待确认",
          label: "待确认"
        },
        {
          value: "已完成",
          label: "已完成"
        },
        {
          value: "已作废",
          label: "已作废"
        }
      ],
      pType: "",
      pTypeOptions: [],
      currentPage1: 1,
      currentPage2: 1
    };
  },
  methods: {
    addCompany() {
      console.log("公司注册--添加--详情--test");
      this.companyAddDialog = true;
    }, // 公司注册添加
    addCloudCompany() {
      console.log("云上公司注册--添加--详情--test");
      this.cloudCompanyAddDialog = true;
      // this.cloudDetailDialog = true;
    }, // 云上公司注册添加
    handleClick(tab, event) {
      console.log(tab, event);
      if (tab.name == "1") {
        this.haveChoosedTab = 1;
        console.log("公司注册");
      }
      if (tab.name == "2") {
        this.haveChoosedTab = 2;
        console.log("云上公司注册");
      }
    },
    deleteRow(idx, row) {
      console.log(idx, row);
    },
    toDetails(idx, row) {
      console.log(row);
      if (this.haveChoosedTab == 1) {
        this.companyDetailDialog = true;
      }
      if (this.haveChoosedTab == 2) {
        this.cloudDetailDialog = true;
      }
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    dotColor(status) {
      switch (status) {
        case 1:
          return `hold`;
          break;
        case 2:
          return `done`;
          break;
        case 3:
          return `cancellation`;
          break;
      }
    }
  },
  created() {
    let baseURL = "";
    if (process.env.NODE_ENV == "development") {
      //开发环境
      baseURL = "/api/web/action/icapi/springBoard";
    } else if (process.env.NODE_ENV == "production") {
      //生产环境
      baseURL = "/web/action/icapi/springBoard";
    }

    req
      .post(
        baseURL,
        {
          actionType: "getProgrammeInfoByNeedNo",
          actionBody: {
            needNo: "N202002141324bupnr8L",
            solutionContent: {
              bizType: "companyreg",
              notes: "方案备注",
              solution: {
                //公司注册方案
                entName: "公司名称",
                province: "省",
                city: "市",
                taxpayerType: "纳税人类型",
                entNature: "公司性质",
                organizationType: "组织类型",
                industry: "行业",
                businessScope: "经营范围",
                //云上公司注册方案
                regPark: "注册园区",
                regType: "注册类型",
                productType: "产品类型"
              }
            }
          }
        },
        {
          headers: {
            token: "3260d5a2452441dd93ecc7ecb35f6dc0",
            userpin: "39fcf7bc5f6c4e55a1f85d750e37316b"
          }
        }
      )
      .then(res => {
        console.log(res);
      });
  }
};
</script>
<style lang="scss" scoped>
.company {
  padding: 30px 22px;
  box-sizing: border-box;
  width: 100%;
  .ndata {
    width: 612px;
    height: 398px;
    margin: 24px auto 0;
    > img {
      width: 100%;
      height: 100%;
    }
  }
  .el-tabs--card > .el-tabs__header {
    margin: 0;
  }
  > .title {
    height: 28px;
    font-size: 20px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.85);
    margin-bottom: 30px;
  }
  .company-find {
    box-sizing: border-box;
    width: 100%;
    margin-top: 30px;
    min-width: 1300px;
    padding: 0 0 0 2.24%;
    .box {
      display: flex;
      width: 284px;
      align-items: center;
      float: left;
      margin-right: 25px;
      > div:nth-child(1) {
        width: 84px;
        height: 36px;
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: rgba(0, 0, 0, 0.85);
        text-align: right;
        line-height: 36px;
      }
      > div:nth-child(2) {
        flex: 1;
        .el-input__inner {
          height: 36px;
        }
      }
      > .el-button {
        width: 80px;
        height: 36px;
        background: rgba(223, 183, 107, 1);
        border-radius: 4px;
        color: white;
      }
      > .el-button:nth-child(2) {
        width: 80px;
        height: 36px;
        background: #4a90e2;
        border-radius: 4px;
        color: white;
      }
    }
    > .btn {
      margin-left: 14px;
    }
    .box:nth-child(4n) {
      margin-right: 0;
    }
    .el-dialog__wrapper {
      .el-dialog {
        .el-dialog__body {
        }
      }
    }
  }
  .company-find::after {
    content: "";
    clear: both;
    display: block;
  }
  .companylist {
    margin-top: 30px;
  }
  .handle {
    > span {
      color: #4a90e2;
    }
    > span:nth-child(2) {
      font-size: 16px;
    }
    > span:not(:nth-child(2)) {
      cursor: pointer;
    }
  }
  .block {
    text-align: center;
  }
  .payment {
    display: flex;
    align-items: center;
    justify-content: center;
    .hold {
      display: block;
      width: 6px;
      height: 6px;
      background: rgba(255, 189, 46, 1);
      border-radius: 6px;
      transform: translate(-1px, 1px);
    }
  }
}
</style>