TblInventoryList.vue 12.9 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 -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!-- <a-button type="primary" icon="download" @click="handleExportXls('tbl_inventory')">导出</a-button> -->
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrlBoh" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入更新BOH</a-button>
      </a-upload>
    </div>

    <!-- table区域-begin -->
    <div>
      <div style="margin-bottom: 16px;">
        
      </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="meterialTypeSlot" slot-scope="text, record">
          <span v-if="text == 1">零件</span>
          <span v-else-if="text == 2">半成品</span>
          <span v-else-if="text == 3">耗材</span>
          <span v-else>劳保</span>
        </span>
        <span slot="action" slot-scope="text, record">
          <a @click="handleDetail(record)">库存明细</a> &nbsp;
          <a @click="updateBoh(record)">更新BOH</a>
        </span>

      </a-table>
    </div>

    <!-- <tbl-inventory-modal ref="modalForm" @ok="modalFormOk"></tbl-inventory-modal> -->
    <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>

    <j-modal
      :title="title"
      :width="width"
      :visible="visibleBoh"
      switchFullscreen
      @ok="handleOkBohInfo"
      :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
      @cancel="handleCancelBoh"
      cancelText="关闭">

        <a-spin :spinning="confirmLoading">
          <j-form-container :disabled="disabled">
            <a-form-model ref="form" :model="model"  slot="detail">
              <a-row>
          <a-col :span="24">
            <a-form-model-item label="编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="partNumber">
              <a-input v-model="model.partNumber" placeholder="请输入编号"   disabled="disabled"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="品名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productName">
              <a-input v-model="model.productName" placeholder="请输入品名"  disabled="disabled" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="规格" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="spec">
              <a-input v-model="model.spec" placeholder="请输入规格"  disabled="disabled" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="型号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="type">
              <a-input v-model="model.type" placeholder="请输入型号"   disabled="disabled"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="采购性质" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="buyingClassify">
              <a-input v-model="model.buyingClassify" placeholder="请输入采购性质"   disabled="disabled"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="类别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="meterialType">
              <a-input v-model="model.meterialType" placeholder="请输入类别"   disabled="disabled"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="当前库存量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="currentInventory">
              <a-input-number v-model="model.currentInventory" placeholder="请输入当前库存量" style="width: 100%"  disabled="disabled"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="库存BOH" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="inventoryBoh">
              <a-input-number v-model="model.inventoryBoh" placeholder="请输入库存BOH" style="width: 100%" />
            </a-form-model-item>
          </a-col>
        </a-row>
            </a-form-model>
          </j-form-container>
        </a-spin>

    </j-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import TblInventoryModal from './modules/TblInventoryModal'
  import ViewDepotStockModal from '../depot_stock/modules/ViewDepotStockModal'
  import SafetyStockEdit from '../depot_stock/modules/SafetyStockEdit.vue';
  import { getAction ,postAction} from '@/api/manage'
  export default {
    name: 'TblInventoryList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      TblInventoryModal,
      SafetyStockEdit,
      ViewDepotStockModal
    },
    data () {
      return {
        confirmLoading: false,
        description: 'tbl_inventory管理页面',
        // 表头
        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: 'spec'
          },
          {
            title:'型号',
            align:"center",
            dataIndex: 'type'
          },
          {
            title:'采购性质',
            align:"center",
            dataIndex: 'buyingClassify'
          },
          {
            title:'类别',
            align:"center",
            dataIndex: 'meterialType',
            scopedSlots: { customRender: 'meterialTypeSlot' },
          },
          {
            title:'当前库存量',
            align:"center",
            dataIndex: 'currentInventory'
          },
          {
            title:'BOH',
            align:"center",
            dataIndex: 'inventoryBoh'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/depot/tblInventory/list",
          delete: "/depot/tblInventory/delete",
          deleteBatch: "/depot/tblInventory/deleteBatch",
          exportXlsUrl: "/depot/tblInventory/exportXls",
          importExcelUrl: "depot/tblInventory/importExcel",
          importExcelUrlBoh:"depot/tblInventory/importExcelBoh",
          updateBoh:"/depot/tblInventory/updateBoh"
        },
        dictOptions:{},
        superFieldList:[],
        priceVisible: false,
      safetyStock: null,
      model:{},
      visibleBoh:false,
      labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
      }
    },
    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}`;
    },
    importExcelUrlBoh: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrlBoh}`;
    },
  },
  methods: {
    tableRowClass(record) {
      if (record.meterialType != "1" && record.meterialType != "2") {
        if (record.currentInventory <= this.safetyStock) {
          return "rowClass";
        } else {
          return "";
        }
      } else {
        return "";
      }
    },
    reSeach() {
        this.loading = true;
        let params = {}
        getAction(this.url.list, params).then(res => {
          this.loading = false;
          if (res.success) {
            this.dataSource = res.result.records;
          }
        })
      },
    updateBoh(recode){
        console.log("..............",recode)
        this.model= {}
        this.model = recode;
        this.visibleBoh = true;
      },
      handleOkBohInfo(){
        this.$refs.form.validate((valid) => {
          if (valid){
            postAction(this.url.updateBoh,this.model).then(res=>{
              this.reSeach();
              if (res.success){
                this.$message.success("更新成功")
              }else {
                this.$message.error(res.message)
              }
            })
            console.log("提交表单内容")
            this.visibleBoh = false
          }
        })
      },
      handleCancelBoh(){
        this.visibleBoh = false;
        this.model = {}
      },
    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>