<template>
  <div class="app-container">
      <el-card class="fiche">
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList">收起</right-toolbar>
          <span style="margin-bottom: 10px;color:#333333;font:14px Helvetica Neue, Helvetica, PingFang SC, Tahoma, Arial,sans-serif">所选条件:</span>
         <div  style="float: right;margin-right:1%">
            <el-button type="cyan"  icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"  style="float: ;">重置</el-button>
                         <column-setting :checkList="checkList" :tableList="tableList" :selfDom="selfDom" :tableId="tableId" style="margin-left:5px" v-if="this.companyType != '02'"></column-setting>
         </div>
         <hr  style="margin-top: 16px;">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px" >
      <el-form-item prop="rzScyName" label="资金方名称" label-width="82px" v-if="this.companyType != '02'">
        <el-input
          v-model="queryParams.rzScyName"
          placeholder="请输入资金方名称"
          clearable
          size="small"
          maxlength="25"
          style="width: 190px"
        />
      </el-form-item>
      <el-form-item prop="zfpName" label="融资产品">
        <el-input
          v-model="queryParams.zfpName"
          placeholder="请输入融资产品"
          clearable
          size="small"
          maxlength="25"
          style="width: 190px"
        />
      </el-form-item>
      <el-form-item prop="AmountA"  label="授信额度范围" label-width="96px">
        <el-input
          v-model="queryParams.AmountA"
          placeholder="请输授信额度"
          clearable
          size="small"
          maxlength="20"
          style="width: 190px"
        /> 
      </el-form-item>
      <!-- <el-form-item>
        -
      </el-form-item> -->
      <el-form-item prop="AmountB">
        <el-input
          v-model="queryParams.AmountB"
          placeholder="请输授信额度"
          clearable
          size="small"
          maxlength="20"
          style="width: 190px"
        />
      </el-form-item>
      <el-form-item label="授信状态" prop="zfpcrStatus">
        <el-select v-model="queryParams.zfpcrStatus" placeholder="请选择状态" clearable size="small">
          <el-option
            v-for="dict in statusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="授信类型" prop="zfpType" v-if="this.companyType != '02'">
        <el-select v-model="queryParams.zfpType" placeholder="请选择类型" clearable size="small" >
          <el-option
            v-for="dict in typeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="生效日期" prop="startTime">
        <el-date-picker  size="small"
         v-model="queryParams.startTime"
         style="width: 240px"
         unlink-panels
         value-format="yyyy-MM-dd"
         type="daterange"
         range-separator="-"
         start-placeholder="开始日期"
         end-placeholder="结束日期">
         </el-date-picker>
      </el-form-item>
      <el-form-item label="到期日期" prop="endTime">
        <el-date-picker  size="small"
         v-model="queryParams.endTime"
         style="width: 240px"
         unlink-panels
         value-format="yyyy-MM-dd"
         type="daterange"
         range-separator="-"
         start-placeholder="开始日期"
         end-placeholder="结束日期">
         </el-date-picker>
      </el-form-item>
    </el-form>
</el-card>
    <el-row :gutter="10" class="mb8" style="width:96%">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['credit:line:add']"
        >新增</el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="creditLineList" @selection-change="handleSelectionChange" :row-key="rowKey" stripe  :cell-style="changeCellStyle" border v-if="this.companyType == '02'">
      <!-- <el-table-column type="selection" width="50" align="center" :reserve-selection="true" /> -->
      <el-table-column label="序号" type="index" width="50" align="center">
        <template slot-scope="scope">
          <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
        </template>
      </el-table-column>
      <el-table-column label="核心企业" align="center" prop="scyName" show-overflow-tooltip/>
      <el-table-column label="融资产品" align="center" prop="zfpName"  show-overflow-tooltip/>
      <el-table-column label="授信额度" :formatter="moneyFormat"  align="center" prop="zfsqAmount" show-overflow-tooltip  width="120"/>
      <el-table-column label="利率(%)" align="center" prop="zfpcrRate"  width="120" />
      <el-table-column label="已使用额度" :formatter="moneyFormat"  align="center" prop="zfiAmount"  width="120"/>
      <el-table-column label="可用额度" :formatter="moneyFormat"  align="center" prop="usableAmount"  width="120"/>
      <el-table-column label="生效日期" align="center" prop="zfpcrStartDate"  show-overflow-tooltip/>
      <el-table-column label="到期日期" align="center" prop="zfpcrEndDate"  show-overflow-tooltip/>
      <el-table-column label="授信状态" :formatter="statuFormat" align="center" prop="zfsqStatus"  show-overflow-tooltip/>
    </el-table>

    <el-table v-loading="loading" :data="creditLineList" @selection-change="handleSelectionChange" :row-key="rowKey" stripe  :cell-style="changeCellStyle" border v-if="this.companyType != '02'">
      <!-- <el-table-column type="selection" width="50" align="center" :reserve-selection="true" /> -->
      <el-table-column label="序号" type="index" width="50" align="center">
        <template slot-scope="scope">
          <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
        </template>
      </el-table-column>
      <el-table-column label="资金方" align="center" prop="rzScyName" show-overflow-tooltip v-if="uncheckList.rzScyName" />
      <el-table-column label="授信类型" :formatter="typeFormat" align="center" prop="zfpType" show-overflow-tooltip v-if="uncheckList.zfpType" />
      <el-table-column label="融资产品" align="center" prop="zfpName" v-if="uncheckList.zfpName" show-overflow-tooltip/>
      <el-table-column label="企业名称" align="center" prop="scyName" v-if="uncheckList.scyName" show-overflow-tooltip/>
      <el-table-column label="企业代码" align="center" prop="scySocialCode" v-if="uncheckList.scySocialCode" show-overflow-tooltip/>
      <el-table-column label="授信额度" :formatter="moneyFormat"  align="center" prop="zfpcrAmount" show-overflow-tooltip v-if="uncheckList.zfpcrAmount" width="120"/>
      <el-table-column label="利率(%)" align="center" prop="zfpcrRate" v-if="uncheckList.zfpcrRate" width="120" />
      <!-- <el-table-column label="已分割额度" :formatter="moneyFormat"  align="center" prop="zfpcrDivisionAmount" v-if="uncheckList.zfpcrDivisionAmount" width="120"/> -->
      <el-table-column label="已使用额度" :formatter="moneyFormat"  align="center" prop="zfiAmount" v-if="uncheckList.zfiAmount" width="120"/>
      <el-table-column label="已分配额度" :formatter="moneyFormat"  align="center" prop="supplierAmount" v-if="uncheckList.supplierAmount" width="120"/>
      <el-table-column label="可用额度" :formatter="moneyFormat"  align="center" prop="usableAmount" v-if="uncheckList.usableAmount && (this.companyType == '00' || this.companyType == '03')" width="120"/>
      <el-table-column label="生效日期" align="center" prop="zfpcrStartDate" v-if="uncheckList.zfpcrStartDate" show-overflow-tooltip/>
      <el-table-column label="到期日期" align="center" prop="zfpcrEndDate" v-if="uncheckList.zfpcrEndDate" show-overflow-tooltip/>
      <el-table-column label="授信状态" :formatter="statusFormat" align="center" prop="zfpcrStatus" v-if="uncheckList.zfpcrStatus" show-overflow-tooltip/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="250">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleEdit(scope.row)"
            v-if="scope.row.zfpcrStatus == '01'"
            v-hasPermi="['credit:line:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleRows(scope.row)"
            v-hasPermi="['credit:line:query']"
          >详情</el-button>
          <el-button
            type="text"
            size="mini"
            icon="el-icon-s-check"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['credit:line:update']"
            v-if="scope.row.zfpcrStatus == '00'"
          >冻结</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleUpdate(scope.row)"
            v-if="scope.row.zfpcrStatus == '01'"
            v-hasPermi="['credit:line:update']"
          >解冻</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleSupplier(scope.row)"
            v-hasPermi="['supplierCredit:line:list']"
            v-if="scope.row.zfpType == '0'"
          >融资方列表</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listCreditLine, getCreditLine, delCreditLine, addCreditLine, updateCreditLine,changeStatus} from "@/api/service/creditLine/creditLine";
import Cookies from 'js-cookie'
import { columnQuery, columnfilter } from "@/api/common/columnSetting";
import ColumnSetting from "../../../components/Table/columnSetting.vue";
import {getPreMonthDay,getCurrentDateStr} from "@/api/common/getDateUtils";
export default {
  name: "CreditLine",
  components: {
    ColumnSetting
  },
  data() {
    return {
      //企业类型
      companyType: '',
      // 遮罩层
      loading: true,
      //弹窗是否禁用
      isShow: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 授信信息表格数据
      creditLineList: [],
      //合同列表
      contractList: [],
      //授信状态数据字典
      statusOptions: [],
      //供应商授信状态数据字典
      statuOptions: [],
      //授信类型(融资产品类型)
      typeOptions: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        zfpcrProductId: null,
        zfpcrCompanyId: null,
        zfpcrType: null,
        zfpcrAmount: null,
        zfpcrRate: null,
        zfpcrDivisionAmount: null,
        zfpcrDateType: null,
        zfpcrStartDate: null,
        zfpcrEndDate: null,
        zfpcrAddress: null,
        zfpcrCharge: null,
        zfpcrChargeRate: null,
        zfpcrAccount: null,
        zfpcrLoanType: null,
        zfpcrBookkeepingType: null,
        zfpcrStatus: null,
        zfpcrProfitSpare1: null,
        zfpcrProfitSpare2: null,
        zfpcrProfitSpare3: null,
        zfpcrProfitSpare4: null,
        zfpcrProfitSpare5: null,
        zfpcrProfitSpare6: null,
        zfpcrProfitSpare7: null,
        zfpcrProfitSpare8: null,
        zfpcrProfitSpare9: null,
        rzScyName: null,
        AmountA: null,
        AmountB: null,
        startTime: [],
        endTime: [],
        zfpType: null,
        zfpName: null
      },
      options: [],
      // 表单参数
      form: {},
      //筛选按钮的数据列表，与table表头的数据一致 --显示隐藏列用
      tableList: [
        {
          label: "rzScyName",
          value: "资金方"
        },
        {
          label: "zfpType",
          value: "授信类型"
        },
        {
          label: "zfpName",
          value: "融资产品"
        },
        {
          label: 'scyName',
          value: '企业名称'
        },
        {
          label: 'scySocialCode',
          value: '企业代码'
        },
        {
          label: "zfpcrAmount",
          value: "授信额度"
        },
        {
          label: "zfpcrRate",
          value: "利率"
        },
        // {
        //   label: "zfpcrDivisionAmount",
        //   value: "已分割额度"
        // },
        {
          label: "zfiAmount",
          value: "已使用额度"
        },
        {
          label: "supplierAmount",
          value: "已分配额度"
        },
        {
          label: "usableAmount",
          value: "可用额度"
        },
        {
          label: "zfpcrStartDate",
          value: "生效日期"
        },
        {
          label: "zfpcrEndDate",
          value: "到期日期"
        },
        {
          label: "zfpcrStatus",
          value: "授信状态"
        }
      ],
      checkList: [], //筛选列选中的数据列表--显示隐藏列用
      uncheckList: {}, //控制筛选列显示隐藏--显示隐藏列用
      selfDom: this,
      tableId: "/sc-service/creditLine/list",
      // 表单校验
      rules: {
        zfpcrProductId: [
          { required: true, message: "融资产品不能为空", trigger: "blur" }
        ],
        zfpcrCompanyId: [
          { required: true, message: "关联企业不能为空", trigger: "blur" }
        ],
        zfpcrAmount: [
          { required: true, message: "授信额度不能为空", trigger: "blur" }
        ],
        zfpcrRate: [
          { required: true, message: "利率不能为空", trigger: "blur" }
        ],
        zfpcrCharge: [
          { required: true, message: "是否收取手续费不能为空", trigger: "blur" }
        ],
        zfpcrChargeRate: [
          { required: true, message: "平台服务费收取费率不能为空", trigger: "blur" }
        ],
        zfpcrLoanType: [
          { required: true, message: "融资放款方式不能为空", trigger: "change" }
        ],
        zfpcrBookkeepingType: [
          { required: true, message: "记账簿托管方式不能为空", trigger: "change" }
        ],
      }
    };
  },
  created() {
    // this.$set(this.queryParams, 'startTime',[this.parseTime(getPreMonthDay(getCurrentDateStr(),3), '{y}-{m}-{d}'), this.parseTime(getCurrentDateStr(), '{y}-{m}-{d}')]);
    // this.$set(this.queryParams, 'endTime',[this.parseTime(getPreMonthDay(getCurrentDateStr(),3), '{y}-{m}-{d}'), this.parseTime(getCurrentDateStr(), '{y}-{m}-{d}')]);
    this.getList();
    // this.getContractList();
    this.getDicts("zc_zfpcr_status").then(response => {
      this.statusOptions = response.data;
    });
    this.getDicts("zc_zfp_type").then(response => {
      this.typeOptions = response.data;
    });
  },
  activated() {
    this.getList();
    // this.getContractList();
    this.getDicts("zc_zfpcr_status").then(response => {
      this.statusOptions = response.data;
    });
    this.getDicts("zc_zfsq_status").then(response => {
      this.statuOptions = response.data;
    });
    this.getDicts("zc_zfp_type").then(response => {
      this.typeOptions = response.data;
    });
  },
  mounted() {
    this.columnQuery();
  },
  methods: {
    /** 查询授信信息列表 */
    getList() {
      this.loading = true;
      listCreditLine(this.queryParams).then(response => {
        debugger
        this.creditLineList = response.data.records;
        if(response.data.records[0]){
          this.companyType = response.data.records[0].companyType
        }
        this.total = response.data.total;
        this.loading = false
      });
    },
    
    rowKey(row) {
      return row.zfpcrId;
    },
    //获取当前客户是否之前设置过列展示隐藏
    columnQuery() {
      //获取页面路径
      var psfPagePath = window.location.pathname;
      //用请求后台的url作为唯一标识
      var psfTableName = this.tableId;
      var columnForm = {};
      columnForm.psfPagePath = psfPagePath;
      columnForm.psfTableName = psfTableName;
      columnQuery(columnForm).then(response => {
        if (response.data && response.data.psfShowData) {
          this.checkList = response.data.psfShowData;
        }
        this.filter();
      });
    },
    //控制隐藏显示的函数
    filter(checkList) {
      if (!!checkList) {
        this.checkList = checkList;
      }
      columnfilter(this.selfDom);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.custId = "";
      this.ctmId = "";
      this.customerList = [];
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        zfpcrId: null,
        zfpcrProductId: null,
        zfpcrCompanyId: null,
        zfpcrType: null,
        zfpcrAmount: null,
        zfpcrRate: null,
        zfpcrDivisionAmount: null,
        zfpcrDateType: null,
        zfpcrStartDate: null,
        zfpcrEndDate: null,
        zfpcrAddress: null,
        zfpcrCharge: null,
        zfpcrChargeRate: null,
        zfpcrAccount: null,
        zfpcrLoanType: null,
        zfpcrBookkeepingType: null,
        zfpcrStatus: "0",
        zfpcrProfitSpare1: null,
        zfpcrProfitSpare2: null,
        zfpcrProfitSpare3: null,
        zfpcrProfitSpare4: null,
        zfpcrProfitSpare5: null,
        zfpcrProfitSpare6: null,
        zfpcrProfitSpare7: null,
        zfpcrProfitSpare8: null,
        zfpcrProfitSpare9: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.pafId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 字典翻译 */
    statusFormat(row, column) {
      return this.selectDictLabel(this.statusOptions, row.zfpcrStatus);
    },
    statuFormat(row, column) {
      return this.selectDictLabel(this.statuOptions, row.zfsqStatus);
    },
    typeFormat(row, column) {
      return this.selectDictLabel(this.typeOptions, row.zfpType);
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.resetQuery();
      Cookies.set("/creditLine/addCreditLine/", this.$route.fullPath)
      this.$router.push("/creditLine/addCreditLine/");
    },
    /** 修改按钮操作 */
    handleEdit(row) {
      const zfpcrId = row.zfpcrId || this.ids;
      const zfiAmount = row.zfiAmount;
      const usableAmount = row.usableAmount;
      this.resetQuery();
      Cookies.set("/creditLine/editCreditLine/" + zfpcrId + '/' + zfiAmount + '/' + usableAmount + '/', this.$route.fullPath)
      this.$router.push("/creditLine/editCreditLine/" + zfpcrId + '/' + zfiAmount + '/' + usableAmount + '/');
    },
    // /** 详情按钮操作 */
    handleRows(row) {
      const zfpcrId = row.zfpcrId || this.ids;
      const zfiAmount = row.zfiAmount;
      const usableAmount = row.usableAmount;
      const companyType = this.companyType;
      this.resetQuery();
      Cookies.set("/creditLine/detailCreditLine/" + zfpcrId + '/' + zfiAmount + '/' + usableAmount + '/' + companyType + '/', this.$route.fullPath)
      this.$router.push("/creditLine/detailCreditLine/" + zfpcrId + '/' + zfiAmount + '/' + usableAmount + '/' + companyType + '/',);
    },
    /** 冻结/解冻按钮操作 */
    handleUpdate(row) {
      let text = row.zfpcrStatus === "01" ? "解冻" : "冻结";
      this.$confirm(
        "确认要" + text + '此数据项吗?',
        "警告",
        {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
        }
      )
      .then(function() {
        return changeStatus(row.zfpcrId, row.zfiAmount,row.zfpcrStatus);
      })
      .then(() => {
        this.resetQuery();
        this.msgSuccess(text + "成功");
      })
      
    },
    /* 融资方列表 */
    handleSupplier(row){
      const zfpcrId = row.zfpcrId || this.ids;
      const zfpcrCompanyId = row.zfpcrCompanyId;
      this.resetQuery();
      Cookies.set("/creditLine/supplierCreditLine/" + zfpcrId + '/' + zfpcrCompanyId, this.$route.fullPath)
      this.$router.push("/creditLine/supplierCreditLine/" + zfpcrId + '/' + zfpcrCompanyId);
    },
    /** 提交按钮 */
    submitForm(state) {
      this.$refs["form"].validate(valid => {
        if (state) {
          this.form.pafState = state;
        }
        console.log(this.form,"提交form")
        debugger
        if (valid) {
          if (this.form.pafId != null) {
            const loading = this.$loading({
              lock: true,
              text: "Loading",
              spinner: "el-icon-loading",
              background: "rgba(0, 0, 0, 0.7)"
            });
            updateFlow(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.reset();
              this.resetQuery();
            });
            loading.close();
          } else {
            const loading = this.$loading({
              lock: true,
              text: "Loading",
              spinner: "el-icon-loading",
              background: "rgba(0, 0, 0, 0.7)"
            });
            addFlow(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.reset();
              this.resetQuery();
            });
            loading.close();
          }
        }
      });
    },
    /* 金额格式化 */
    moneyFormat(row, column, cellValue) {
        if(cellValue == null || cellValue== undefined || cellValue == ''){
            cellValue = '0.00'
        }
        cellValue += '';
        if (!cellValue.includes('.')) {
            cellValue += '.00';
        }
        return cellValue.replace(/(\d)(?=(\d{3})+\.)/g, function ($0, $1) {
            return $1 + ',';
          }).replace(/\.$/, '');
    },
    /* 修改表格样式 */
    changeCellStyle(row, column, rowIndex, columnIndex) {
      if (row.column.label === "授信额度" || row.column.label === "已分割额度" || row.column.label === "已使用额度"
      || row.column.label === "可用额度") {
        return "font-weight: 700;"; // 修改的样式
      } else {
        return "";
      }
    },
    /* //  将数字金额转换为大写金额 */
    smallToBig(money) {
      //  将数字金额转换为大写金额
      var cnNums = new Array(
        "零",
        "壹",
        "贰",
        "叁",
        "肆",
        "伍",
        "陆",
        "柒",
        "捌",
        "玖"
      ); //汉字的数字
      var cnIntRadice = new Array("", "拾", "佰", "仟"); //基本单位
      var cnIntUnits = new Array("", "万", "亿", "兆"); //对应整数部分扩展单位
      var cnDecUnits = new Array("角", "分", "毫", "厘"); //对应小数部分单位
      var cnInteger = "整"; //整数金额时后面跟的字符
      var cnIntLast = "元"; //整数完以后的单位
      //最大处理的数字
      var maxNum = 999999999999999.9999;
      var integerNum; //金额整数部分
      var decimalNum; //金额小数部分
      //输出的中文金额字符串
      var chineseStr = "";
      var parts; //分离金额后用的数组，预定义
      if (money == "" || money == null || money == undefined) {
        return "零元零角零分";
      }

      money = parseFloat(money);
      if (money >= maxNum) {
        //超出最大处理数字
        return "超出最大处理数字";
      }
      if (money == 0) {
        chineseStr = cnNums[0] + cnIntLast + cnInteger;
        return chineseStr;
      }

      //四舍五入保留两位小数,转换为字符串
      money = Math.round(money * 100).toString();
      integerNum = money.substr(0, money.length - 2);
      decimalNum = money.substr(money.length - 2);

      //获取整型部分转换
      if (parseInt(integerNum, 10) > 0) {
        var zeroCount = 0;
        var IntLen = integerNum.length;
        for (var i = 0; i < IntLen; i++) {
          var n = integerNum.substr(i, 1);
          var p = IntLen - i - 1;
          var q = p / 4;
          var m = p % 4;
          if (n == "0") {
            zeroCount++;
          } else {
            if (zeroCount > 0) {
              chineseStr += cnNums[0];
            }
            //归零
            zeroCount = 0;
            chineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
          }
          if (m == 0 && zeroCount < 4) {
            chineseStr += cnIntUnits[q];
          }
        }
        chineseStr += cnIntLast;
      }
      //小数部分
      if (decimalNum != "") {
        var decLen = decimalNum.length;
        for (var i = 0; i < decLen; i++) {
          var n = decimalNum.substr(i, 1);
          if (n != "0") {
            chineseStr += cnNums[Number(n)] + cnDecUnits[i];
          }
        }
      }
      if (chineseStr == "") {
        chineseStr += cnNums[0] + cnIntLast + cnInteger;
      } else if (decimalNum == "" || /^0*$/.test(decimalNum)) {
        chineseStr += cnInteger;
      }
      return chineseStr;
    }
  }
};
</script>

