MissingMaterialsPlease.vue 10.7 KB
<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form  layout="inline" @keyup.enter.native="query">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="项目名称">
              <j-popup  v-model="queryParam.workOrder" code="find_projectc"
                        field="field0056"
                        orgFields="field0056,field0054,field0055,field0057"
                        destFields="field0056,field0054,field0055,field0057" :trigger-change="true" @callback="findCarNumberClick" :multi="true"/>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="主要部件">
              <j-popup  v-model="queryParam.pno" code="findPart"
                        field="name"
                        :param="param1"
                        orgFields="name,field0054,field0057"
                        destFields="name,field0054,field0057" :trigger-change="true" @callback="findCarNumberClick2" :multi="true"/>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="制造属性">
              <a-select
                show-search
                placeholder="请选择"
                option-filter-prop="children"
                v-model="queryParam.attr"
              >
                <a-select-option v-for="item in materia_Attr" :key="item.key" :value="item.value">{{ item.text }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="父级编码">
              <a-input placeholder="请输入物料编码" v-model="queryParam.pno"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="子级编码">
              <a-input placeholder="请输入物料编码" v-model="queryParam.bomCode"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="query" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a-button type="primary" icon="download" style="margin-left: 8px" @click="toExportXls('缺料清单')">导出</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- table区域-begin -->
    <div>

      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i>已选择&nbsp;<a style="font-weight: 600">{{
          selectedRowKeys.length }}</a>项&nbsp;&nbsp;
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        bordered
        size="middle"
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
          <a @click="checkQty(record)">库存详情</a>
        </span>

        <span slot="receive" slot-scope="text, record">
            <a @click="receiveClick(record)">{{ numFormat(record.llqty) }}</a>
      </span>
        <span slot="inStock" slot-scope="text, record">
            <a @click="inventoryClick(record)">{{ numFormat(record.qty) }}</a>
      </span>

        <span slot="checkQty" slot-scope="text, record">
            <a @click="checkQty(record)">{{ numFormat(record.qty) }} <a-divider v-has="'bom:lock'" type="vertical"/> {{ numFormat(record.lockqty) }}</a>
      </span>

        <span slot="tradeNum" slot-scope="qty">
          {{ numFormat(qty) }}
      </span>
      </a-table>

    </div>
    <j-popup
      v-show="showRentPrise"
      ref="material_details"
      code="find_material"
      :param="materialParam"
      org-fields="username"
      dest-fields="popup"
      field="popup"/>
    <j-popup
      v-show="showRentPrise"
      ref="shipment_details"
      code="find_shipment_detail"
      :param="shipmentParam"
      org-fields="username"
      dest-fields="popup"
      field="popup"/>
    <j-popup
      v-show="showRentPrise"
      ref="inventory_details"
      code="find_inventory"
      :param="inventoryParam"
      org-fields="username"
      dest-fields="popup"
      field="popup"/>
    <materia-item-list ref="materiaFrom"></materia-item-list>
  </a-card>
</template>

<script>
import { getMissingMaterialList, getProject } from '@api/api'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import { downFile } from '@/api/manage'
import {ajaxGetDictItems} from "../../api/api";
import MateriaItemList from "../system/modules/MateriaItemList";

export default {
  name: 'MissingMaterialsPlease',
  mixins: [JeecgListMixin],
  components: {MateriaItemList},
  data() {
    return {
      materialParam:{code:''},
      shipmentParam:{code:'',moCode:''},
      inventoryParam:{code:''},
      param1:{field0054:'',field0057:''},
      description: '菜单管理页面',
      field0056:'',
      field0054:'',
      field0055:'',
      field0057:'',
      materia_Attr:[],
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          }
        }
        ,
        {
          title: '物料名称',
          align: 'center',
          dataIndex: 'name',
          ellipsis: true
        },
        {
          title: '物料编码',
          align: 'center',
          dataIndex: 'cno',
          ellipsis: true
        },
        {
          title: '关联编码',
          align: 'center',
          dataIndex: 'linkCode',
          ellipsis: true
        },
        {
          title: '单位',
          align: 'center',
          dataIndex: 'f02'
        },
        {
          title: '型号',
          align: 'center',
          dataIndex: 'f08'
        },
        {
          title: '用量',
          align: 'center',
          dataIndex: 'bnum'
        },
        {
          title: '制造方式',
          align: 'center',
          dataIndex: 'f04'
        },
        {
          title: '领料',
          align: 'center',
          dataIndex: 'llqty',
          scopedSlots:{
            customRender:'receive'
          }
        },
        {
          title: '缺料',
          align: 'center',
          dataIndex: 'missqty',
          scopedSlots: {
            customRender: 'tradeNum'
          }
        },
        {
          title: '库存 | 锁住',
          align: 'center',
          dataIndex: 'qty',
          scopedSlots: {
            customRender:'checkQty'
          },
        }
      ],
      url: {
          list: '/config/bom/getMissingMaterialList',
        exportXlsUrl: "/config/bom/exportMaterialShortageXls"
      },
      loading: false,
      queryParam: {},
      projectNameList: ['name','workOrder'],
    }
  },
  created() {
    this.loadFrom();
    this.getMateria_attr();
  },
  methods: {
    getMateria_attr() {
      ajaxGetDictItems('materia_attr').then((res) => {
        if (res.success) {
          this.materia_Attr = res.result
        }
      })
    },
    findCarNumberClick(row){
      this.field0056=row.field0056;
      this.field0054=row.field0054;
      this.field0055=row.field0055;
      this.field0057=row.field0057;
      this.param1['field0057'] =row.field0057;
      this.param1['field0054'] =row.field0054;
    },
    findCarNumberClick2(row){
    },
    loadFrom() {
      getProject().then((res) => {
        if (res.success) {
          this.projectNameList = res.result;
        }
      })
    },
    numFormat(qty){
      if(qty==undefined){
        return '';
      }else{
        return  parseFloat(qty).toFixed(1);
      }
    },
    receiveClick(data){
      this.shipmentParam['code'] = "'"+data.cno+"'";
      this.shipmentParam['moCode'] = "'"+data.workno+"'";
      this.$refs.shipment_details.openModal();
    },
    inventoryClick(data){
      this.inventoryParam['code'] = "'"+data.cno+"'";
      this.$refs.inventory_details.openModal();
    },
    bomDetailsClick(data){
      this.materialParam['code'] = "'"+data.bomCode+"'"
      this.$refs.material_details.openModal();
    },

    checkQty(record){
      this.$refs.materiaFrom.edit(record,this.field0056,'1')
    },

    filterOption(input, option) {
      return (
        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
      );
    },

    toExportXls(fileName){
      if(!fileName || typeof fileName != "string"){
        fileName = "导出文件"
      }
      let params = {
        "field0056":this.field0056,
        "field0054":this.field0054,
        "field0055":this.field0055,
        "field0057":this.field0057,
        "cno":this.queryParam.bomCode,
        "attr":this.queryParam.attr,
        "type":'1'
      }
      downFile(this.url.exportXlsUrl,params).then((data)=>{
        if (!data) {
          this.$message.warning("文件下载失败")
          return
        }
        if (data.size<100){
          this.$message.warning("请先查询出列表,再导出")
          return
        }
        if (typeof window.navigator.msSaveBlob !== 'undefined') {
          window.navigator.msSaveBlob(new Blob([data],{type: 'application/vnd.ms-excel'}), fileName+'.xls')
        }else{
          let url = window.URL.createObjectURL(new Blob([data],{type: 'application/vnd.ms-excel'}))
          let link = document.createElement('a')
          link.style.display = 'none'
          link.href = url
          link.setAttribute('download', fileName+'.xls')
          document.body.appendChild(link)
          link.click()
          document.body.removeChild(link); //下载完成移除元素
          window.URL.revokeObjectURL(url); //释放掉blob对象
        }
      })
    },

    query()  {
      this.loading=true;
      let params = {
        "field0056":this.field0056,
        "field0054":this.field0054,
        "field0055":this.field0055,
        "field0057":this.field0057,
        "cno":this.queryParam.bomCode,
        "attr":this.queryParam.attr,
        "pno":this.queryParam.pno,
        "type":'1'

      }
      getMissingMaterialList(params).then((res) => {
        if (res.success) {
          this.loading=false;
          this.dataSource = res.result;
        }else {
          this.loading=false;
          this.$message.warning(res.message);
        }
      })
    }
  },
}
</script>

<style scoped>

</style>