stockMonthDialog.vue 5.91 KB
<template>
  <GLDialog class="stock-dialog" v-if="stockMonthVisible" :destroy-on-close="true" :before-close="handleClose"
    bigTitle="月度库存结算单" mode="big" okText="关闭" :visible.sync="stockMonthVisible" :close-on-click-modal="false"
    @onOk="handleClose" @onCancel="handleClose" :hasFooter="false">
    <div class="detail-content" v-if="stockMonthVisible">
      <el-form :inline="true" :model="searchForm" size="small">
        <el-form-item label="年度:">
          <el-date-picker v-model="searchForm.year" type="year" placeholder="选择年" value-format="yyyy" format="yyyy"
            :clearable="false" :picker-options="pickerOption" @change="chooseYear"></el-date-picker>
        </el-form-item>
      </el-form>
      <div class="table-class">
        <GLTable ref="purchaseOrderDetailTable" :tableParams="tableParams" :has-num="false" :hasPage="false"
          :tableData="tableData" :pageConf="pageConf"></GLTable>
      </div>
      <span class="btn-tips">
        <img src="@/images/icon-warn.png" />
        说明:月平均加权单价=上月结存库存金额+本月采购金额/上月结存库存数量+本月采购数量
      </span>
    </div>
    <!-- <span slot="footer" class="dialog-footer">
      <el-button type="primary" size="small" @click="handleClose">关闭</el-button>
    </span> -->
  </GLDialog>
</template>

<script>
// import { membraneTypeList } from '@/utils/constants.js'
export default {
  name: 'StockMonthDialog',
  props: {
    stockMonthVisible: {
      type: Boolean,
      default: false
    },
    stockInfo: {
      type: Object,
      default: () => { }
    }
  },
  data() {
    return {
      pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
      // membraneTypeList: membraneTypeList,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        // singleSelectUniqueKey: 'id',
        tableOption: false,
        tableColumns: [
          {
            label: '月份',
            prop: 'dataMonth',
            width: 100
          },
          {
            label: '本月采购金额/元',
            prop: 'purchaseMoney',
            formatter: cellValue => {
              return cellValue.purchaseMoney || cellValue.purchaseMoney == 0 ? '¥' + cellValue.purchaseMoney.toFixed(2) : '-'
            },
            width: 140
          },
          {
            label: '本月采购数量',
            prop: 'purchaseNum',
            formatter: cellValue => {
              return cellValue.purchaseNum || cellValue.purchaseNum == 0 ? parseFloat(cellValue.purchaseNum).toFixed(2) + (this.$membraneTypeList.includes(cellValue.goodsType) ? '米' : '件') : '-'
            }
          },
          {
            label: '月平均加权单价',
            prop: 'averageWeightedPrice',
            formatter: cellValue => {
              return cellValue.averageWeightedPrice || cellValue.averageWeightedPrice == 0 ? '¥' + cellValue.averageWeightedPrice.toFixed(2) : '-'
            },
            width: 140
          },
          {
            label: '出库金额/元',
            prop: 'reduceStockMoney',
            formatter: cellValue => {
              return cellValue.reduceStockMoney || cellValue.reduceStockMoney == 0 ? '¥' + cellValue.reduceStockMoney.toFixed(2) : '-'
            }
          },
          {
            label: '出库数量',
            prop: 'reduceStockNum',
            formatter: cellValue => {
              return cellValue.reduceStockNum || cellValue.reduceStockNum == 0 ? parseFloat(cellValue.reduceStockNum).toFixed(2) + (this.$membraneTypeList.includes(cellValue.goodsType) ? '米' : '件') : '-'
            }
          },
          {
            label: '结存库存金额/元',
            prop: 'remainMoney',
            formatter: cellValue => {
              return cellValue.remainMoney || cellValue.remainMoney == 0 ? '¥' + cellValue.remainMoney.toFixed(2) : '-'
            },
            width: 140
          },
          {
            label: '结存库存数量',
            prop: 'stock',
            formatter: cellValue => {
              return cellValue.stock || cellValue.stock == 0 ? parseFloat(cellValue.stock).toFixed(2) + (this.$membraneTypeList.includes(cellValue.goodsType) ? '米' : '件') : '-'
            }
          }
        ]
      },
      searchForm: {
        year: '',
        upgradeGoodsId: '',
        yqMerchantId: ''
      },
      searchFormSearch: {},
      tableData: [],
      merchantDialogVisible: false,
      pickerOption: {
        disabledDate(date) {
          if (date.getFullYear() > new Date().getFullYear() || date.getFullYear() < 2023) {
            return true
          }
          return false
        }
      }
    }
  },
  mounted() {
    const nowDate = new Date()
    this.searchForm.year = nowDate.getFullYear().toString()
    if (this.stockInfo) {
      this.searchForm.upgradeGoodsId = this.stockInfo.upgradeGoodsId
      this.searchForm.yqMerchantId = this.stockInfo.yqMerchantId
    }
    this.getList()
  },
  methods: {
    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchFormSearch = this.$common.utils.deepClone(this.searchForm)
        resolve()
      })
    },

    chooseYear() {
      this.getList()
    },

    getList() {
      var params = this.$common.utils.deepClone(this.searchForm)
      this.$apis.stockManage.getReportByGoods(params).then(res => {
        this.tableData = res
      })
    },

    handleClose() {
      console.log(111)
      this.$emit('dialogClose')
    }
  }
}
</script>

<style lang="scss" scoped>
.stock-dialog {
  /deep/.el-dialog__body {
    min-height: 167px;
    max-height: 616px;
  }
}

.btn-tips {
  display: inline-block;
  font-size: 12px;
  height: 14px;
  line-height: 14px;
  background-color: #fff2e5;
  color: #999;
  margin-right: 24px;
  padding: 6.5px 10px;

  img {
    width: 18px;
    height: 15px;
    margin-right: 9px;
    vertical-align: bottom;
  }
}</style>