<template>
  <div class="home">
    <!-- <a-alert :message="message" type="info" /> -->
    <a-card size="small" :bordered="false" class="page-cont" :bodyStyle="{padding: '17px 30px 20px'}">
      <h3 class="page-tit">客户信息</h3>
      <ul class="page-list">
        <li>商户名称：{{ $store.getters.userInfo.orgName || '--' }}</li>
        <li>商户别名：{{ dealerData&&dealerData.dealerAlias || '--' }}</li>
        <li>登录账号：{{ $store.getters.userInfo.username || '--' }}</li>
        <li>所属角色：{{ dealerData&&dealerData.dealerLevelDictValue || '--' }}</li>
      </ul>
    </a-card>
    <!-- 数据看板 -->
    <a-card v-if="$hasPermissions('M_homePage_data')" size="small" :bordered="false" class="page-cont" :bodyStyle="{padding: '0px'}">
      <a-row>
        <a-col :span="6">
          <div class="page-data-module">
            <div class="page-data-con">
              <p class="page-data-tit">今日总单量(个)/总销售金额(元)</p>
              <h3 class="page-data-num main-color">
                <a-statistic :valueStyle="{fontSize:'30px',color:'#e70012'}" :value="bizData&&bizData.sales&&(bizData.sales.dayTotalQty || bizData.sales.dayTotalQty==0) ? bizData.sales.dayTotalQty : 0" />
                /
                <a-statistic :precision="2" :valueStyle="{fontSize:'30px',color:'#e70012'}" :value="bizData&&bizData.sales&&(bizData.sales.dayTotalAmount || bizData.sales.dayTotalAmount==0) ? bizData.sales.dayTotalAmount : 0" />
              </h3>
              <p class="page-data-item">
                <span class="page-data-itemText">本周</span>
                <span class="page-data-itemText">
                  <a-statistic :valueStyle="{fontSize:'14px'}" :value="bizData&&bizData.sales&&(bizData.sales.weekSalesQty || bizData.sales.weekSalesQty==0) ? bizData.sales.weekSalesQty : 0" />
                  /
                  <a-statistic :valueStyle="{fontSize:'14px'}" :precision="2" :value="bizData&&bizData.sales&&(bizData.sales.weekSalesAmount || bizData.sales.weekSalesAmount==0) ? bizData.sales.weekSalesAmount : 0" />
                </span>
              </p>
              <p class="page-data-item">
                <span class="page-data-itemText">本月</span>
                <span class="page-data-itemText">
                  <a-statistic :valueStyle="{fontSize:'14px'}" :value="bizData&&bizData.sales&&(bizData.sales.monthSalesQty || bizData.sales.monthSalesQty==0) ? bizData.sales.monthSalesQty : 0" />
                  /
                  <a-statistic :valueStyle="{fontSize:'14px'}" :precision="2" :value="bizData&&bizData.sales&&(bizData.sales.monthSalesAmount || bizData.sales.monthSalesAmount==0) ? bizData.sales.monthSalesAmount : 0" />
                </span>
              </p>
            </div>
            <span class="page-data-line"></span>
          </div>
        </a-col>
        <a-col :span="6">
          <div class="page-data-module">
            <div class="page-data-con">
              <p class="page-data-tit">今日总采购单量(个)/总采购金额(元)</p>
              <h3 class="page-data-num">
                <a-statistic :valueStyle="{fontSize:'30px'}" :value="bizData&&bizData.purchaseBill&&(bizData.purchaseBill.dayTotalQty || bizData.purchaseBill.dayTotalQty==0) ? bizData.purchaseBill.dayTotalQty : 0" />
                /
                <a-statistic :precision="2" :valueStyle="{fontSize:'30px'}" :value="bizData&&bizData.purchaseBill&&(bizData.purchaseBill.dayDiscountedAmount || bizData.purchaseBill.dayDiscountedAmount==0) ? bizData.purchaseBill.dayDiscountedAmount : 0" />
              </h3>
              <p class="page-data-item">
                <span class="page-data-itemText">本周</span>
                <span class="page-data-itemText">
                  <a-statistic :valueStyle="{fontSize:'14px'}" :value="bizData&&bizData.purchaseBill&&(bizData.purchaseBill.weekPurchaseQty || bizData.purchaseBill.weekPurchaseQty==0) ? bizData.purchaseBill.weekPurchaseQty : 0" />
                  /
                  <a-statistic :valueStyle="{fontSize:'14px'}" :precision="2" :value="bizData&&bizData.purchaseBill&&(bizData.purchaseBill.weekDiscountedAmount || bizData.purchaseBill.weekDiscountedAmount==0) ? bizData.purchaseBill.weekDiscountedAmount : 0" />
                </span>
              </p>
              <p class="page-data-item">
                <span class="page-data-itemText">本月</span>
                <span class="page-data-itemText">
                  <a-statistic :valueStyle="{fontSize:'14px'}" :value="bizData&&bizData.purchaseBill&&(bizData.purchaseBill.monthPurchaseQty || bizData.purchaseBill.monthPurchaseQty==0) ? bizData.purchaseBill.monthPurchaseQty : 0" />
                  /
                  <a-statistic :valueStyle="{fontSize:'14px'}" :precision="2" :value="bizData&&bizData.purchaseBill&&(bizData.purchaseBill.monthDiscountedAmount || bizData.purchaseBill.monthDiscountedAmount==0) ? bizData.purchaseBill.monthDiscountedAmount : 0" />
                </span>
              </p>
            </div>
            <span class="page-data-line"></span>
          </div>
        </a-col>
        <a-col :span="6">
          <div class="page-data-module">
            <div class="page-data-con">
              <p class="page-data-tit">客户总数(个)</p>
              <h3 class="page-data-num">
                <a-statistic :valueStyle="{fontSize:'30px'}" :value="bizData&&bizData.customer&&(bizData.customer.custCount || bizData.customer.custCount==0) ? bizData.customer.custCount : 0 " />
              </h3>
              <p class="page-data-item">
                <span class="page-data-itemText">本周新增</span>
                <span class="page-data-itemText">
                  <a-statistic :valueStyle="{fontSize:'14px'}" :value="bizData&&bizData.customer&&(bizData.customer.addCurrentWeekCustCount || bizData.customer.addCurrentWeekCustCount==0) ? bizData.customer.addCurrentWeekCustCount : 0" />
                </span>
              </p>
              <p class="page-data-item">
                <span class="page-data-itemText">30天内采购客户</span>
                <span class="page-data-itemText">
                  <a-statistic :valueStyle="{fontSize:'14px'}" :value="bizData&&bizData.customer&&(bizData.customer.salesThirtyDayCustCount || bizData.customer.salesThirtyDayCustCount==0) ? bizData.customer.salesThirtyDayCustCount : 0" />
                </span>
              </p>
            </div>
            <span class="page-data-line"></span>
          </div>
        </a-col>
        <a-col :span="6">
          <div class="page-data-module">
            <div class="page-data-con">
              <p class="page-data-tit">总库存(个)</p>
              <h3 class="page-data-num" style="line-height: 36px;">
                <a-statistic :valueStyle="{fontSize:'30px'}" :value="bizData&&bizData.stock&&(bizData.stock.totalCurrentStockQty || bizData.stock.totalCurrentStockQty==0) ? bizData.stock.totalCurrentStockQty : 0" />
              </h3>
              <p class="page-data-tit">库存总金额(元)</p>
              <h3 class="page-data-num" style="line-height: 36px;margin: 0;">
                <a-statistic :precision="2" :valueStyle="{fontSize:'30px'}" :value="bizData&&bizData.stock&&(bizData.stock.totalCurrentStockCost || bizData.stock.totalCurrentStockCost==0) ? bizData.stock.totalCurrentStockCost : 0" />
              </h3>
            </div>
          </div>
        </a-col>
      </a-row>
    </a-card>
    <div>
      <a-row>
        <a-col :span="16">
          <a-card size="small" :bordered="false" class="page-cont" :bodyStyle="{padding: '17px 30px 20px'}">
            <h3 class="page-tit">销售/采购/调拨指引</h3>
            <div class="page-nav-main">
              <!-- 导航指引  start -->
              <div class="page-nav-con" v-for="(item, index) in navList" :key="index">
                <div class="page-nav-box" v-for="(subItem, subInd) in item" :key="subInd">
                  <a-badge
                    :count="countData&&unitItem.permission&&unitItem.orderNum&&$hasPermissions(unitItem.permission) ? countData[unitItem.orderNum] : 0"
                    class="page-nav-badge"
                    v-for="(unitItem, unitInd) in subItem"
                    :key="unitInd"
                    @click="unitItem.permission&&unitItem.url&&$hasPermissions(unitItem.permission) ? goPage(unitItem) : null"
                    :style="{cursor: unitItem.permission&&unitItem.url&&$hasPermissions(unitItem.permission)?'pointer': 'initial'}">
                    <div :class="['page-nav-item', unitItem.styleC]">
                      <div class="page-nav-n">
                        <img v-show="unitItem.icon" :src="unitItem.icon" width="16" height="16" />
                        <span>{{ unitItem.name }}</span>
                      </div>
                      <a-icon type="caret-right" v-show="unitItem.permission&&unitItem.url&&$hasPermissions(unitItem.permission)" style="color: #BBBBBB;" />
                    </div>
                  </a-badge>
                </div>
              </div>
              <!-- 导航指引  end -->
            </div>
          </a-card>
        </a-col>
        <a-col :span="8">
          <a-card size="small" :bordered="false" class="page-cont right-con" :bodyStyle="{padding: '17px 30px 20px'}">
            <h3 class="page-tit">财务指引</h3>
            <!-- 财务指引  start -->
            <div class="page-nav-con" v-for="(item, index) in navFinancialList" :key="index">
              <div class="page-nav-box" v-for="(subItem, subInd) in item" :key="subInd" style="width: 50%;">
                <div class="page-nav-badge" v-for="(unitItem, unitInd) in subItem" :key="unitInd" @click="unitItem.permission&&unitItem.url&&$hasPermissions(unitItem.permission) ? goPage(unitItem) : null" :style="{cursor: unitItem.permission&&unitItem.url&&$hasPermissions(unitItem.permission)?'pointer': 'initial'}">
                  <div :class="['page-nav-item', unitItem.styleC]">
                    <div class="page-nav-n">
                      <img v-show="unitItem.icon" :src="unitItem.icon" width="16" height="16" />
                      <span>{{ unitItem.name }}</span>
                    </div>
                    <a-icon type="caret-right" v-show="unitItem.permission&&unitItem.url&&$hasPermissions(unitItem.permission)" style="color: #BBBBBB;" />
                  </div>
                </div>
              </div>
            </div>
            <!-- 财务指引  end -->
          </a-card>
          <a-card size="small" :bordered="false" class="page-cont right-con" :bodyStyle="{padding: '17px 30px 20px'}">
            <h3 class="page-tit">其他指引</h3>
            <!-- 其他指引  start -->
            <div class="page-nav-con" v-for="(item, index) in navOtherList" :key="index">
              <div class="page-nav-box" v-for="(subItem, subInd) in item" :key="subInd" style="width: 50%;">
                <div class="page-nav-badge" v-for="(unitItem, unitInd) in subItem" :key="unitInd" @click="unitItem.permission&&unitItem.url&&$hasPermissions(unitItem.permission) ? goPage(unitItem):null" :style="{cursor: unitItem.permission&&unitItem.url&&$hasPermissions(unitItem.permission)?'pointer': 'initial'}">
                  <div :class="['page-nav-item', unitItem.styleC]">
                    <div class="page-nav-n">
                      <img v-show="unitItem.icon" :src="unitItem.icon" width="16" height="16" />
                      <span>{{ unitItem.name }}</span>
                    </div>
                    <a-icon type="caret-right" v-show="unitItem.permission&&unitItem.url&&$hasPermissions(unitItem.permission)" style="color: #BBBBBB;" />
                  </div>
                </div>
              </div>
            </div>
            <!-- 其他指引  end -->
          </a-card>
        </a-col>
      </a-row>
    </div>
    <!-- 重置密码 -->
    <a-modal
      class="resetPwdModal"
      title="重置密码"
      width="60%"
      centered
      :footer="null"
      :closable="false"
      :maskClosable="false"
      :destroyOnClose="true"
      @cancel="openResetPwd=false"
      v-model="openResetPwd">
      <ResetPwd />
    </a-modal>
    <!-- 新产品上线提醒 -->
    <a-modal
      class="newProductTips"
      :title="'新产品'+(onlineFalg=='1'?'上':'下')+'线提醒'"
      :width="800"
      centered
      :footer="null"
      :maskClosable="false"
      :destroyOnClose="true"
      @cancel="cancelProductTips"
      v-model="openNewProduct">
      <newProduct :onlineFalg="onlineFalg" @seeMore="seeMore"></newProduct>
    </a-modal>
  </div>
</template>

<script>
import { commonMixin } from '@/utils/mixin'
import { mapGetters } from 'vuex'
import ResetPwd from '@/views/user/ResetPwd.vue'
import newProduct from '@/views/productManagement/newProduct/modal.vue'
import { queryNewProductPage } from '@/api/product'
import { bizStateCount, bizData, dealerData } from '@/api/data'
export default {
  name: 'Home',
  components: { ResetPwd, newProduct },
  mixins: [commonMixin],
  data () {
    return {
      message: '欢迎登录' + process.env.VUE_APP_PRO_NAME,
      openResetPwd: false, //  重置密码是否显示
      openNewProduct: false,
      onlineFalg: '1', // 上下线标识  1为上线，0为下线
      navList: [
        [ // 客户
          [
            {
              icon: require('@/assets/home-icon/home_icon_customer.png'),
              name: '客户',
              styleC: 'blue-color',
              url: '/customerManagement/customerInfo/list',
              permission: 'M_customerInfoList',
              orderNum: ''
            }
          ],
          [
            {
              icon: require('@/assets/home-icon/home_icon_billing.png'),
              name: '销售开单',
              styleC: 'red-color',
              url: '/salesManagement/salesQuery/list',
              permission: 'M_salesQueryList',
              orderNum: ''
            },
            {
              icon: require('@/assets/home-icon/home_icon_return.png'),
              name: '销售退货',
              styleC: 'red-color',
              url: '/salesManagement/salesReturn/list',
              permission: 'M_salesReturnList',
              orderNum: ''
            }
          ],
          [
            {
              icon: require('@/assets/home-icon/home_icon_verify.png'),
              name: '销售审核',
              styleC: 'blue-color',
              url: '/salesManagement/salesQuery/list',
              params: { billStatus: 'WAIT_AUDIT' },
              permission: 'M_salesQueryList',
              orderNum: 'salesWaitAuditCount'
            },
            {
              icon: require('@/assets/home-icon/home_icon_verify.png'),
              name: '退货审核',
              styleC: 'blue-color',
              url: '/salesManagement/salesReturn/list',
              params: { state: 'WAIT_AUDIT' },
              permission: 'M_salesReturnList',
              orderNum: 'salesReturnWaitAuditCount'
            }
          ],
          [
            {
              icon: require('@/assets/home-icon/home_icon_stock.png'),
              name: '销售出库',
              styleC: 'red-color',
              url: '/outboundOrderManagement/outboundOrder/list',
              params: JSON.stringify({ state: 'WAIT', outBizType: 'SALES' }),
              permission: 'M_outboundList',
              orderNum: 'salesWaitOutWarehouseCount'
            },
            {
              icon: require('@/assets/home-icon/home_icon_finance_pay.png'),
              name: '财务付款',
              styleC: 'red-color',
              url: '/financialManagement/financialPayment/list',
              params: JSON.stringify({ bizType: 'SELL_REFUND', billState: 'UNSETTLE' }),
              permission: 'M_financialPaymentList',
              orderNum: 'salesReturnFinancialWaitCount'
            }
          ],
          [
            {
              icon: require('@/assets/home-icon/home_icon_finance_payment.png'),
              name: '财务收款',
              styleC: 'blue-color',
              url: '/financialManagement/financialCollection/list',
              params: JSON.stringify({ bizType: 'SELL', billState: 'UNSETTLE' }),
              permission: 'M_financialCollectionList',
              orderNum: 'salesFinancialWaitCount'
            },
            {}
          ]
        ],
        [ // 供应商(箭冠)
          [
            {
              icon: require('@/assets/home-icon/home_icon_supplier.png'),
              name: '供应商(箭冠)',
              styleC: 'blue-color',
              url: '',
              orderNum: ''
            }
          ],
          [
            {
              icon: require('@/assets/home-icon/home_icon_purchase_billing.png'),
              name: '采购开单',
              styleC: 'red-color',
              url: '/purchasingManagement/purchaseOrder/list',
              permission: 'M_purchasingList',
              orderNum: ''
            },
            {
              icon: require('@/assets/home-icon/home_icon_purchase_return.png'),
              name: '采购退货',
              styleC: 'red-color',
              url: '/purchasingManagement/purchaseReturn/list',
              permission: 'M_purchaseReturnList',
              orderNum: ''
            }
          ],
          [
            {
              icon: require('@/assets/home-icon/home_icon_verify_return.png'),
              name: '入库审核',
              styleC: 'blue-color',
              url: '/financialManagement/warehousingAudit/list',
              params: { auditState: 'WAIT_PUT_WAREHOUSE_AUDIT' },
              permission: 'M_warehousingAuditList',
              orderNum: 'purchaseWaitAuditCount'
            },
            {
              icon: require('@/assets/home-icon/home_icon_verify_return.png'),
              name: '退货审核',
              styleC: 'blue-color',
              url: '/purchasingManagement/purchaseReturn/list',
              params: { state: 'WAIT_AUDIT' },
              permission: 'M_purchaseReturnList',
              orderNum: 'purchaseReturnWaitAuditCount'
            }
          ],
          [
            {},
            {
              icon: require('@/assets/home-icon/home_icon_finance_pay.png'),
              name: '财务收款',
              styleC: 'red-color',
              url: '/financialManagement/financialCollection/list',
              params: JSON.stringify({ bizType: 'PURCHASE_RETURN', billState: 'UNSETTLE' }),
              permission: 'M_financialCollectionList',
              orderNum: 'purchaseReturnFinancialWaitCount'
            }
          ]
        ],
        [ // 供应商(其他)
          [
            {
              icon: require('@/assets/home-icon/home_icon_supplier.png'),
              name: '供应商(其他)',
              styleC: 'blue-color',
              url: '/supplierManagement/supplierInfo/list',
              permission: 'M_supplierInfoList',
              orderNum: ''
            }
          ],
          [
            {
              icon: require('@/assets/home-icon/home_icon_scatter_warehousing.png'),
              name: '散件入库',
              styleC: 'red-color',
              url: '/bulkManagement/bulkWarehousingOrder/list',
              permission: 'M_bulkWarehousingOrderList',
              orderNum: ''
            },
            {
              icon: require('@/assets/home-icon/home_icon_scatter_return.png'),
              name: '散件退货',
              styleC: 'red-color',
              url: '/bulkManagement/bulkReturnGoods/list',
              permission: 'M_bulkReturnGoodsList',
              orderNum: ''
            }
          ],
          [
            {
              icon: require('@/assets/home-icon/home_icon_verify_return.png'),
              name: '待入库',
              styleC: 'blue-color',
              url: '/bulkManagement/bulkWarehousingOrder/list',
              params: { state: 'WAIT_PUT_WAREHOUSE' },
              permission: 'M_bulkWarehousingOrderList',
              orderNum: 'sparePartsPurchaseWaitAuditCount'
            },
            {
              icon: require('@/assets/home-icon/home_icon_verify_return.png'),
              name: '退货审核',
              styleC: 'blue-color',
              url: '/bulkManagement/bulkReturnGoods/list',
              params: { state: 'WAIT_AUDIT' },
              permission: 'M_bulkReturnGoodsList',
              orderNum: 'sparePartsReturnWaitAuditCount'
            }
          ],
          [
            {
              icon: require('@/assets/home-icon/home_icon_finance_pay.png'),
              name: '财务付款',
              styleC: 'red-color',
              url: '/financialManagement/financialPayment/list',
              params: JSON.stringify({ bizType: 'PARTS_INPUT', billState: 'UNSETTLE' }),
              permission: 'M_financialPaymentList',
              orderNum: 'sparePartsPurchaseFinancialWaitCount'
            },
            {
              icon: require('@/assets/home-icon/home_icon_stock.png'),
              name: '待出库',
              styleC: 'red-color',
              url: '/bulkManagement/bulkReturnGoods/list',
              params: { state: 'WAIT_OUT_WAREHOUSE' },
              permission: 'M_bulkReturnGoodsList',
              orderNum: 'sparePartsReturnWaitOutWarehouseCount'
            }
          ],
          [
            {},
            {
              icon: require('@/assets/home-icon/home_icon_finance_payment.png'),
              name: '财务收款',
              styleC: 'blue-color',
              url: '/financialManagement/financialCollection/list',
              params: JSON.stringify({ bizType: 'SPARE_PARTS_RETURN', billState: 'UNSETTLE' }),
              permission: 'M_financialCollectionList',
              orderNum: 'sparePartsReturnFinancialWaitCount'
            }
          ]
        ],
        [ // 调拨
          [
            {
              icon: require('@/assets/home-icon/home_icon_transfer.png'),
              name: '调拨',
              styleC: 'blue-color',
              url: '',
              orderNum: ''
            }
          ],
          [
            {
              icon: require('@/assets/home-icon/home_icon_stor_out.png'),
              name: '店内调出',
              styleC: 'red-color',
              url: '/allocationManagement/storeTransferOut/list',
              permission: 'M_storeTransferOutList',
              orderNum: ''
            },
            {
              icon: require('@/assets/home-icon/home_icon_billing.png'),
              name: '仓库调拨',
              styleC: 'red-color',
              url: '/allocationManagement/warehouseAllocation/list',
              permission: 'M_warehouseAllocationList',
              orderNum: ''
            },
            {
              icon: require('@/assets/home-icon/home_icon_billing.png'),
              name: '连锁调出',
              styleC: 'red-color',
              url: '/allocationManagement/chainTransferOut/list',
              permission: 'M_chainTransferOutList',
              orderNum: ''
            }
          ],
          [
            {
              icon: require('@/assets/home-icon/home_icon_verify.png'),
              name: '调出审核',
              styleC: 'blue-color',
              url: '/allocationManagement/storeTransferOut/list',
              params: { state: 'WAIT_AUDIT' },
              permission: 'M_storeTransferOutList',
              orderNum: 'storeCallOutWaitAuditCount'
            },
            {
              icon: require('@/assets/home-icon/home_icon_verify.png'),
              name: '调拨审核',
              styleC: 'blue-color',
              url: '/allocationManagement/warehouseAllocation/list',
              params: { state: 'WAIT_AUDIT' },
              permission: 'M_warehouseAllocationList',
              orderNum: 'alloWarehouseWaitAuditCount'
            },
            {
              icon: require('@/assets/home-icon/home_icon_verify.png'),
              name: '调出审核',
              styleC: 'blue-color',
              url: '/allocationManagement/chainTransferOut/list',
              params: { state: 'WAIT_AUDIT' },
              permission: 'M_chainTransferOutList',
              orderNum: 'alloLinkageOutWaitAuditCount'
            }
          ],
          [
            {
              icon: require('@/assets/home-icon/home_icon_stock.png'),
              name: '出库审核',
              styleC: 'red-color',
              url: '/outboundOrderManagement/outboundOrder/list',
              params: JSON.stringify({ state: 'WAIT', outBizType: 'SHOP_CALL_OUT' }),
              permission: 'M_outboundList',
              orderNum: 'storeCallOutWaitOutWarehouseCount'
            },
            {},
            {
              icon: require('@/assets/home-icon/home_icon_stock.png'),
              name: '出库审核',
              styleC: 'red-color',
              url: '/outboundOrderManagement/outboundOrder/list',
              params: JSON.stringify({ state: 'WAIT', outBizType: 'LINKAGE_CALL_OUT' }),
              permission: 'M_outboundList',
              orderNum: 'alloLinkageOutWaitOutWarehouseCount'
            }
          ],
          [
            {
              icon: require('@/assets/home-icon/home_icon_finance_payment.png'),
              name: '财务收款',
              styleC: 'blue-color',
              url: '/financialManagement/financialCollection/list',
              params: JSON.stringify({ bizType: 'STORE_CALL_OUT', billState: 'UNSETTLE' }),
              permission: 'M_financialCollectionList',
              orderNum: 'storeCallOutFinancialWaitCount'
            },
            {},
            {}
          ]
        ]

      ],
      countData: null,
      bizData: null,
      dealerData: null,
      navFinancialList: [ // 财务指引
        [
          [
            {
              icon: require('@/assets/home-icon/home_icon_receivable.png'),
              name: '应收应付',
              styleC: 'blue-color',
              url: '/financialManagement/companyReceivablePayable/list',
              permission: 'M_companyReceivablePayableList',
              orderNum: ''
            },
            {
              icon: require('@/assets/home-icon/home_icon_finance.png'),
              name: '财务收款',
              styleC: 'blue-color',
              url: '/financialManagement/financialCollection/list',
              params: JSON.stringify({ bizType: 'ALL' }),
              permission: 'M_financialCollectionList',
              orderNum: ''
            }
          ],
          [
            {
              icon: require('@/assets/home-icon/home_icon_unit.png'),
              name: '收付款记录',
              styleC: 'blue-color',
              url: '/financialManagement/companyCollectionPayment/list',
              permission: 'M_companyCollectionPaymentList',
              orderNum: ''
            },
            {
              icon: require('@/assets/home-icon/home_icon_pay.png'),
              name: '财务付款',
              styleC: 'blue-color',
              url: '/financialManagement/financialPayment/list',
              params: JSON.stringify({ bizType: 'ALL' }),
              permission: 'M_financialPaymentList',
              orderNum: ''
            }
          ]
        ]
      ],
      navOtherList: [ // 其他指引
        [
          [
            {
              icon: require('@/assets/home-icon/home_icon_stock s.png'),
              name: '实时库存',
              styleC: 'blue-color',
              url: '/inventoryManagement/inventoryQuery/list',
              permission: 'M_inventoryInventoryQueryList',
              orderNum: ''
            }
          ],
          [
            {
              icon: require('@/assets/home-icon/home_icon_inventory.png'),
              name: '库存盘点',
              styleC: 'blue-color',
              url: '/inventoryManagement/inventoryChecking/list',
              permission: 'M_inventoryCheckingList',
              orderNum: ''
            }
          ]
        ]
      ]
    }
  },
  computed: {
    ...mapGetters(['mustChangePwd'])
  },
  methods: {
    hasNewProduct () {
      queryNewProductPage({ pageNo: 1, pageSize: 20, onlineFalg: this.onlineFalg }).then(res => {
        if (res.status == 200) {
          if (res.data.count > 0) {
            this.openNewProduct = true
          } else {
            if (this.onlineFalg == '1') {
              this.onlineFalg = '0'
              this.hasNewProduct()
            }
          }
        }
      })
    },
    // 查看更多产品
    seeMore () {
      this.openNewProduct = false
      if (this.onlineFalg == '1') { // 上线
        this.$router.push({ path: '/productManagement/productOnlineInfo/list' })
      } else { // 下线
        this.$router.push({ name: 'newProductList', params: { onlineFalg: this.onlineFalg } })
      }
    },
    // 关闭弹框
    cancelProductTips () {
      const _this = this
      this.openNewProduct = false
      if (this.onlineFalg == '1') {
        this.onlineFalg = '0'
        setTimeout(() => { _this.hasNewProduct() }, 100)
      }
    },
    // 导航指引合计
    getNavCount () {
      bizStateCount({}).then(res => {
        if (res.status == 200) {
          this.countData = res.data
        } else {
          this.countData = null
        }
      })
    },
    // 导航跳转
    goPage (data) {
      if (data) {
        // 有待办数据,则跳转带有条件的;若无待办数据,则跳转全部数据
        if (data.orderNum && this.countData[data.orderNum]) {
          this.$router.push({ path: data.url, query: { pageParams: data.params ? data.params : null } })
        } else {
          if (data.url == '/outboundOrderManagement/outboundOrder/list') { // 出库
            const params = data.params ? JSON.parse(data.params) : null
            this.$router.push({ path: data.url, query: { pageParams: JSON.stringify({ outBizType: params && params.outBizType ? params.outBizType : null }) } })
          } else if (data.url == '/financialManagement/financialPayment/list') { // 财务付款
            const params = data.params ? JSON.parse(data.params) : null
            this.$router.push({ path: data.url, query: { pageParams: JSON.stringify({ bizType: params && params.bizType ? params.bizType : null }) } })
          } else if (data.url == '/financialManagement/financialCollection/list') { // 财务收款
            const params = data.params ? JSON.parse(data.params) : null
            this.$router.push({ path: data.url, query: { pageParams: JSON.stringify({ bizType: params && params.bizType ? params.bizType : null }) } })
          } else {
            this.$router.push({ path: data.url, query: { pageParams: null } })
          }
        }
      }
    },
    // 数据看板信息
    getBizData () {
      bizData({}).then(res => {
        if (res.status == 200) {
          this.bizData = res.data
        } else {
          this.bizData = null
        }
      })
    },
    // 商户信息
    getMerchantData () {
      dealerData({}).then(res => {
        if (res.status == 200) {
          this.dealerData = res.data
        } else {
          this.dealerData = null
        }
      })
    }
  },
  activated () {
    // 请求导航指引合计
    this.getNavCount()
    this.getBizData()
    this.getMerchantData()
  },
  beforeRouteEnter (to, from, next) {
    next(vm => {
      //  判断登录用户是否重置过密码（首次登陆需强制重置密码）
      if (vm.mustChangePwd == 0) {
        vm.openResetPwd = false
        if (from.name == 'login') {
          // 判断是否有新产品上线
          vm.hasNewProduct()
        }
      } else {
        vm.openResetPwd = true
      }
    })
  }
}
</script>
<style lang="less" scoped>
  .ant-card-body{
    padding: 17px 30px 20px;
  }
  .home {
    .page-cont{
      margin-bottom: 10px;
      // 客户信息
      .page-tit{
        color: #000000;
        font-size: 16px;
        font-weight: 500;
        margin-bottom: 18px;
      }
      .page-list{
        list-style: none;
        margin: 0;
        padding: 0;
        li{
          display: inline-block;
          width: 25%;
          font-size: 14px;
          color: rgba(0, 0, 0);
          vertical-align: top;
        }
      }
      // 数据看板
      .page-data-module{
        display: flex;
        justify-content: space-between;
        align-items: center;
        .page-data-con{
          padding: 20px 30px;
          flex-grow: 1;
          .page-data-tit{
            font-size: 14px;
            color: rgba(0, 0, 0);
            margin: 0;
          }
          .page-data-num{
            font-size: 28px;
            font-family: PingFang SC;
            color: #000000;
            margin-bottom: 5px;
            display: flex;
            align-items: center;
          }
          .main-color{
            color: rgba(231, 0, 18, 1);
          }
          .page-data-item{
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 3px;
            .page-data-itemText{
              font-size: 14px;
              color: rgba(0, 0, 0);
              display: flex;
              align-items: center;
            }
          }
        }
        .page-data-line{
          display: block;
          width: 1px;
          height: 76px;
          background-color: rgba(232, 232, 232, 1);
        }
      }
      // 操作导航引导
      .page-nav-con{
        display: flex;
        align-items: center;
        margin-bottom: 20px;
        padding-bottom: 20px;
        border-bottom: 1px solid #e8e8e8;
        &:last-child{
          margin-bottom: 0px;
          padding-bottom: 0px;
          border-bottom: none;
        }
        .page-nav-box{
          display: inline-block;
          width: 20%;
          .page-nav-badge{
            width: 94%;
            margin: 5px 0;
            .page-nav-item{
              border-radius: 8px;
              display: flex;
              justify-content: space-between;
              align-items: center;
              padding: 13px 10px;
              .page-nav-n{
                img{
                  vertical-align: sub;
                }
                span{
                  color: rgba(0, 0, 0);
                  font-size: 14px;
                  padding-left: 5px;
                }
              }
            }
            .blue-color{
              background-color: #EDF0F9;
            }
            .red-color{
              background-color: #F8F1EF;
            }
          }
        }
      }
    }
    .right-con{
      margin-left: 10px;
    }
  }
</style>
