<!--切换企业-->
<template>
  <el-dialog :visible.sync="dialogVisible" width="60%" center="true" :show-close="from==3?false:true" :close-on-click-modal="false" :close-on-press-escape="false" @close="closeFun">
    <template slot="title">
      <div class='dialog-titleZise'>设置企业会计制度</div>
    </template>

    <el-row :gutter="17">
      <el-col :span="5">
        <div class="search">统一社会信用代码：</div>
      </el-col>
      <el-col :span="6">
        {{selectRow.nsrsbh}}
      </el-col>
      <el-col :span="1">
        &nbsp;
      </el-col>
      <el-col :span="4">
        <div class="search">纳税人名称：</div>
      </el-col>
      <el-col :span="8">
        {{selectRow.nsrmc}}
      </el-col>
    </el-row>
    <hr />
    <div v-if="(from!='3'&&yjbCwbbList.length>0)||(from=='3'&&yjbCwbbList.length>0&&selectRow.nsqxDm!='10')" style="padding: 16px">
      <el-row :gutter="17">
        <div class='dialog-titleZise'>月季报财务报表</div>
      </el-row>
      <el-row :gutter="17">
        <div style="margin-top: 20px">
          <el-radio-group v-model="yjradio" size="small">
            <el-radio @click.native.prevent="clickitemY(item.bblxDm)" v-for="(item,index) in this.yjbCwbbList" :key="index" :label="item.bblxDm">{{item.bblxMc}}</el-radio>
          </el-radio-group>
        </div>
      </el-row>
    </div>
    <div v-if="(from!='3'&&nbCwbbList.length>0)||(from=='3'&&nbCwbbList.length>0&&selectRow.nsqxDm=='10')" style="padding: 16px">
      <el-row :gutter="17">
        <div class='dialog-titleZise'>年报财务报表</div>
      </el-row>
      <el-row :gutter="17">
        <div style="margin-top: 20px">
          <el-radio-group v-model="nbradio" size="small">
            <el-radio @click.native.prevent="clickitemN(item.bblxDm)" v-for="(item,index) in this.nbCwbbList" :key="index" :label="item.bblxDm">{{item.bblxMc}}</el-radio>
          </el-radio-group>
        </div>
      </el-row>
    </div>
    <span slot="footer" class="dialog-footer">
      <!--    <el-button @click="dialogClose">取 消</el-button>-->
      <el-button type="primary" @click="handleClose">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
/**
 * @Author ygy
 * @Description //TODO 切换企业控制器
 * @Date 11:13 2020/5/27
 **/
export default {
  name: "enterpriseDialog",
  props: ["selectRow", "allData", "from", "dialogVisible","searchEnterprisesList","loginData"],
  watch: {
    allData(val) { // 监听数据
      if (val.oldSelYjbCwbb != undefined) {
        this.yjradio = val.oldSelYjbCwbb
      }
      if (val.oldSelNbCwbb != undefined) {
        this.nbradio = val.oldSelNbCwbb
      }
      if (val.yjbCwbbList != undefined) {
        this.yjbCwbbList = val.yjbCwbbList
      }
      if (val.nbCwbbList != undefined) {
        this.nbCwbbList = val.nbCwbbList
      }
    },
  },
  computed: {
  },
  data() {
    return {
      nbradio: this.allData.oldSelNbCwbb,
      yjradio: this.oldSelYjbCwbbm,
      yjbCwbbList: [],
      nbCwbbList: [],
    };
  },
  methods: {
    closeFun() {
      this.$parent.dialogVisible = false
    },
    //
    clickitemY(e) {
      e === this.yjradio ? this.yjradio = '' : this.yjradio = e
    },
    clickitemN(e) {
      e === this.nbradio ? this.nbradio = '' : this.nbradio = e
    },
    /**
     * @Author ygy
     * @Description //TODO 修改面包屑
     * @Date 13:27 2020/5/28
     * @Param
     * @return
     **/
    changeBreadcrumb() {
      var breadCrumb = this.$route.meta.breadCrumb
      if (this.$route.name == "listTaxes") { // 跳页到税种列表
        breadCrumb[breadCrumb.length - 1].name = "填写报表：" + this.$store.state.data.zlRowData.nsrmc;
        console.log(breadCrumb);
        this.$store.commit('changeBreadcumb', breadCrumb)
      }
    },
    /**
     * @Author ygy
     * @Description //TODO 关闭模态框
     * @Date 11:43 2020/5/27
     **/
    dialogClose() {
      this.dialogVisible = false
    },
    /**
     * @Author ygy
     * @Description //TODO 切换企业查询按钮
     * @Date 10:17 2020/5/18
     **/
    switchEnterprise() {
      var _self = this;
      this.searchEnterprisesList = Enumerable.From(this.dialogVisible).Where("x=>x.nsrsbh.indexOf('" + _self.nsr + "')>-1||x.nsrmc.indexOf('" + _self.nsr + "')>-1").ToArray();
    },
    /**
     * @Author ygy
     * @Description //TODO 模态框关闭按钮
     * @Date 11:05 2020/5/18
     **/
    handleClose(done) {
      var _self = this;
      var yjbShow = (_self.from != '3' && _self.yjbCwbbList.length > 0) || (_self.from == '3' && _self.yjbCwbbList.length > 0 && _self.selectRow.nsqxDm != '10')
      if ([undefined, null, 'undefined', 'null', ''].includes(_self.yjradio) && yjbShow) {
        _self.$alert('请选择月季报财务报表企业会计制度', '提示', {
          confirmButtonText: '确定',
          callback: action => {
          }
        });
        return false
      }
      var nbShow = (_self.from != '3' && _self.nbCwbbList.length > 0) || (_self.from == '3' && _self.nbCwbbList.length > 0 && _self.selectRow.nsqxDm == '10');
      if ([undefined, null, 'undefined', 'null', ''].includes(_self.nbradio) && nbShow) {
        _self.$alert('请选择年报财务报表企业会计制度', '提示', {
          confirmButtonText: '确定',
          callback: action => {
          }
        });
        return false
      }
      var param = {
        djxh: _self.selectRow.djxh,
        yjbBblxDm: _self.yjradio,
        nbBblxDm: _self.nbradio,
        nsrsbq: _self.$store.state.data.nsrsbq,
        token:this.$store.state.data.token,
        //涉税传参
        // rylx: this.loginData.rylx,
        // zjlx: this.loginData.zjlx,
        // zjhm: this.loginData.zjhm,
        // dlDjxh: this.loginData.dl_djxh
      }
      var url = interfacePrefix + config.sel_qykjzd
      _self.ajax.post(url, param, function (data) {
        if (data.returnCode == "00" && data.returnMessage == "ok") {
          // _self.$message({ message: '企业会计制度设置成功！', type: 'success' });
          _self.$alert('企业会计制度设置成功！', '提示', { type: 'success' });
          _self.dialogVisible = false
          if (_self.from == "1") {
            _self.$router.push({ name: 'listTaxes', params: { nsrmc: _self.selectRow.nsrmc } });
          } else if (_self.from == "2") {
          } else if (_self.from == "3") {
            _self.$parent.getBbList(_self.selectRow);
            _self.$parent.dialogVisible = false
          } else {
            _self.$parent.batchInit.visible = true
          }
        }
      }, "json", true);
    },
    /**
     * @Author ygy
     * @Description //TODO 行点击事件
     * @Date 11:52 2020/5/27
     **/
    rowClick(row, event, column) {
      console.log(row);
      this.selectRow = row
    }
  },
}
</script>

<style scoped>
.el-radio {
  padding-top: 10px;
}
.el-radio-group {
  display: grid;
}
</style>

