ViewDepotStockList.vue 7.5 KB
<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="品名">
              <j-input placeholder="请输入品名" v-model="queryParam.productName"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="采购性质">
              <j-dict-select-tag placeholder="请选择采购性质" v-model="queryParam.buyingClassify" dictCode="buying_classify" />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-button type="primary" icon="download" @click="handleExportXls('库存报表' + parseTime(new Date().getTime(),'{y}-{m}-{d} {h}:{i}:{s}'))" style="margin-right: 10px;">导出</a-button>
            <a-button type="primary" icon="edit" @click="priceVisible = true">安全库存设置</a-button>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->


    <!-- table区域-begin -->
    <div>
      <div style="margin-bottom: 16px;height: 10px;">

      </div>

      <a-table ref="table" size="middle" :scroll="{ x: true }" bordered rowKey="id" :columns="columns"
        :dataSource="dataSource" :pagination="ipagination" :loading="loading" class="j-table-force-nowrap"
        @change="handleTableChange" :rowClassName="tableRowClass">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt=""
            style="max-width:80px;font-size: 12px;font-style: italic;" />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleDetail(record)">库存明细</a>
          <!-- <a @click="updateBoh(record)">更新BOH</a> -->
        </span>
      </a-table>
    </div>

    <view-depot-stock-modal ref="modalForm" @ok="modalFormOk"></view-depot-stock-modal>

    <template v-if="priceVisible">
      <safety-stock-edit :visible.sync="priceVisible"></safety-stock-edit>
    </template>
  </a-card>
</template>
<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ViewDepotStockModal from './modules/ViewDepotStockModal'
import SafetyStockEdit from './modules/SafetyStockEdit.vue';
import { getAction } from '@/api/manage'
export default {
  name: 'ViewDepotStockList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    ViewDepotStockModal,
    SafetyStockEdit
  },
  data() {
    return {
      description: 'view_depot_stock管理页面',
      // 表头
      columns: [
        // {
        //   title: '#',
        //   dataIndex: '',
        //   key: 'rowIndex',
        //   width: 60,
        //   align: "center",
        //   customRender: function (t, r, index) {
        //     return parseInt(index) + 1;
        //   }
        // },
        {
          title: '编号',
          align: "center",
          dataIndex: 'partNumber',
          // customRender: (text, record) => {//根据状态判断字体
          //   console.log(this.safetyStock)
          // }
        },
        { 
          title: '品名',
          align: "center",
          dataIndex: 'productName'
        },
        {
          title: '型号',
          align: "center",
          dataIndex: 'type'
        },
        {
          title: '规格',
          align: "center",
          dataIndex: 'spec'
        },
        {
          title: '采购性质',
          align: "center",
          dataIndex: 'buyingClassify'
        },
        {
          title: '类别',
          align: "center",
          dataIndex: 'meterialType'
        },
        {
          title: '数量',
          align: "center",
          dataIndex: 'operNumber'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: "/depot_stock/viewDepotStock/list",
        delete: "/depot_stock/viewDepotStock/delete",
        deleteBatch: "/depot_stock/viewDepotStock/deleteBatch",
        exportXlsUrl: "/depot_stock/viewDepotStock/exportXls",
        importExcelUrl: "depot_stock/viewDepotStock/importExcel",

      },
      dictOptions: {},
      superFieldList: [],
      priceVisible: false,
      safetyStock: null,
      model:{},
      visibleBoh:false
    }
  },
  created() {
    this.getSuperFieldList();
    getAction("/safety/stock/getPrice").then(res => {
      if (res.success) {
        this.safetyStock = res.result.safetyStock;
      }
    })
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    tableRowClass(record) {
      
      if (record.meterialType == "耗材" || record.meterialType == "劳保") {
        if (record.operNumber <= this.safetyStock) {
          return "rowClass";
        } else {
          return "";
        }
      } else {
        return "";
      }
    },
    // updateBoh(recode){
    //     console.log("..............",recode)
    //     this.model= {}
    //     this.model = recode;
    //     // this.model.materialDescription = recode.materialReview;
    //     this.visibleBoh = true;
    //   },
    initDictConfig() {
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({ type: 'string', value: 'partNumber', text: '编号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'productName', text: '品名', dictCode: '' })
      fieldList.push({ type: 'string', value: 'type', text: '型号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'spec', text: '规格', dictCode: '' })
      fieldList.push({ type: 'string', value: 'buyingClassify', text: '采购性质', dictCode: 'buying_classify' })
      fieldList.push({ type: 'string', value: 'meterialType', text: 'meterialType', dictCode: '' })
      fieldList.push({ type: 'BigDecimal', value: 'operNumber', text: 'operNumber', dictCode: '' })
      this.superFieldList = fieldList
    }
  }
}
</script>
<style>
.rowClass {
  background-color: red;
  /* color: white; */
}

@import '~@assets/less/common.less';
</style>