zenglf
2023-09-18 92ff846fb659c62037a32b1d8c15eae9df9d9b54
src/views/spare/modules/sparePartInventory/SparePart2List.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,390 @@
<template>
  <a-card
    :bordered="false"
    class="card-area"
  >
    <template slot="title">
      <i
        class="action-jeecg actionsite2"
        style="font-size: 18px;"
      />
      å¤‡ä»¶ä¿¡æ¯
    </template>
    <!-- æŸ¥è¯¢åŒºåŸŸ -->
    <div class="table-page-search-wrapper">
      <!-- æœç´¢åŒºåŸŸ -->
      <a-form
        layout="inline"
        @keyup.enter.native="searchQuery"
      >
        <a-row :gutter="24">
          <a-col
            :md="8"
            :sm="8"
          >
            <a-form-item label="备件编号">
              <j-input
                placeholder="请输入备件编号查询"
                v-model="queryParam.num"
              ></j-input>
            </a-form-item>
          </a-col>
          <a-col
            :md="8"
            :sm="8"
          >
            <a-form-item label="备件名称">
              <j-input
                placeholder="请输入备件名称查询"
                v-model="queryParam.name"
              ></j-input>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- æ“ä½œæŒ‰é’®åŒºåŸŸ -->
    <div
      class="table-operator"
      style="margin-top: 5px"
    >
      <a-button
        type="primary"
        @click="searchQuery"
        icon="search"
      >查询
      </a-button>
      <a-button
        @click="searchReset"
        icon="reload"
      >重置
      </a-button>
      <a-button
        type="primary"
        icon="download"
        @click="handleExportXls('备件库存')"
      >导出
      </a-button>
      <a-upload
        name="file"
        :showUploadList="false"
        :multiple="false"
        :headers="tokenHeader"
        :action="importExcelUrl"
        @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-tag color="#55acee" style="height:15px"></a-tag>
      åº“存积压
      <a-tag color="#cd201f" style="height:15px"></a-tag>
      åº“存不足
    </div>
    <a-table
      ref="table"
      bordered
      size="middle"
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      :rowSelection="rowSelection"
      @change="handleTableChange"
      :scroll="{ x: 'calc(1500px + 50%)', y: 900 }"
      :customRow="clickThenSelect"
      :rowClassName="tableRowClass"
    >
    </a-table>
    <a-tabs
      type="card"
      defaultActiveKey="1"
    >
      <a-tab-pane key="1">
        <span slot="tab">
          <a-badge>库存明细&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a-badge>
        </span>
        <div
          class="table-operator"
          style="margin-top: 0px"
        >
          <spare-part-inventory-list ref="SparePartInventoryList"></spare-part-inventory-list>
        </div>
      </a-tab-pane>
    </a-tabs>
  </a-card>
</template>
<script>
import { requestPut, deleteAction, getFileAccessHttpUrl, getAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JInput from '@/components/jeecg/JInput'
import JEllipsis from '@/components/jeecg/JEllipsis'
import Tooltip from 'ant-design-vue/es/tooltip'
import Vue from 'vue'
import SparePartInventoryList from './SparePartInventoryList'
export default {
  name: 'SparePart2List.',
  mixins: [JeecgListMixin],
  components: {
    JInput,
    JEllipsis,
    SparePartInventoryList,
    Tooltip
  },
  props: {
    nodeSelected: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {
      mainId: '',
      ipagination: {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['5', '10', '20'],
        showTotal: (total, range) => {
          return range[0] + '-' + range[1] + ' å…±' + total + '条'
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      selectedRowKeys: [],
      selectionRows: [],
      //默认排序
      isorter: {
        column: 'num',
        order: 'asc'
      },
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          },
          width: 50
        },
        {
          title: '备件编码',
          align: 'center',
          dataIndex: 'num'
        },
        {
          title: '备件名称',
          align: 'center',
          dataIndex: 'name'
        },
        {
          title: '型号',
          align: 'center',
          dataIndex: 'model'
        },
        {
          title: '规格',
          align: 'center',
          dataIndex: 'specification'
        },
        {
          title: '制造商',
          align: 'center',
          dataIndex: 'constructorId_dictText'
        },
        {
          title: '单位',
          align: 'center',
          dataIndex: 'mainUnitId_dictText'
        },
        /*   {
            title: '辅单位',
            align: "center",
            dataIndex: 'auxiliaryUnitId_dictText',
          }, */
        {
          title: '总数量',
          align: 'center',
          dataIndex: 'totalMainQuantity'
        },
        /*  {
           title: '总辅数量',
           align: "center",
           dataIndex: 'totalAuxiliaryQuantity',
         }, */
        {
          title: '有效期',
          align: 'center',
          dataIndex: 'validityPeriod'
        },
        {
          title: '有效单位',
          align: 'center',
          dataIndex: 'validityPeriodUnitId_dictText'
        },
        {
          title: '库存上限值',
          align: 'center',
          dataIndex: 'inventoryUpperLimit'
        },
        {
          title: '库存下限值',
          align: 'center',
          dataIndex: 'inventoryLowerLimit'
        },
        {
          title: '经济订货量',
          align: 'center',
          dataIndex: 'economicOrderQuantity'
        },
        {
          title: '采购提前期',
          align: 'center',
          dataIndex: 'purchaseLeadTime'
        }
      ],
      url: {
        list: '/spare/sparePart/sparePartInventoryList',
        importUrl: '/spare/SparesPartInventory/importExcel',
        exportXlsUrl: '/spare/sparePart/exportXls',
      },
      //新增、编辑、删除、批量删除操作改变数据后刷新关联的组件的监听属性
      alterFlag: ''
    }
  },
  computed: {
    rowSelection() {
      return {
        type: 'radio',
        onChange: (selectedRowKeys, selectedRows) => {
          this.selectedRowKeys = selectedRowKeys
          this.onSelectChange(selectedRowKeys, selectedRows)
        },
        selectedRowKeys: this.selectedRowKeys
      }
    },
    importExcelUrl: function() {
      console.log(this.mainId)
      /* return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`; */
      return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.mainId}`
    }
  },
  methods: {
    clickThenSelect(record) {
      return {
        on: {
          click: () => {
            this.onSelectChange(record.id.split(','), [record])
          }
        }
      }
    },
    onSelectChange(selectedRowKeys, selectionRows) {
      if (selectedRowKeys.length == 1) {
        this.$refs.SparePartInventoryList.sparePartId = selectedRowKeys[0]
        this.mainId = selectedRowKeys[0]
      } else {
        this.$refs.SparePartInventoryList.sparePartId = '-1'
      }
      this.selectedRowKeys = selectedRowKeys
      this.selectionRows = selectionRows
    },
    //禁用状态样式
    tableRowClass(record, index) {
      if (record.totalMainQuantity < record.inventoryLowerLimit) {
        return 'downLimit'
      } else if (record.totalMainQuantity > record.inventoryUpperLimit) {
        return 'upLimit'
      }
    },
    searchReset() {
      this.queryParam = {}
      if (this.nodeSelected.key != -1) {
        this.queryParam.sparePartCategoryId = this.nodeSelected.key
      }
      this.selectedRowKeys = []
      this.selectionRows = []
      this.$refs.SparePartInventoryList.sparePartId = '-1'
      this.loadData(1)
    },
    searchQuery() {
      this.selectedRowKeys = []
      this.selectionRows = []
      this.$refs.SparePartInventoryList.sparePartId = '-1'
      this.loadData(1)
    }
  },
  watch: {
    alterFlag() {
      this.$bus.$emit('queryTreeData')
    },
    nodeSelected() {
      this.queryParam = {}
      if (this.nodeSelected.key != -1) {
        this.queryParam.sparePartCategoryId = this.nodeSelected.key
      }
      this.selectedRowKeys = []
      this.selectionRows = []
      this.$refs.SparePartInventoryList.sparePartId = '-1'
      this.loadData(1)
    }
  },
  created() {
    this.queryParam = {}
    this.queryParam.sparePartCategoryId = this.nodeSelected.key
    this.selectedRowKeys = []
    this.selectionRows = []
    this.loadData(1)
  }
}
</script>
<style lang="less">
@import '~@assets/less/common.less';
.frozenRowClass {
  color: #c9c9c9;
}
.success {
  color: green;
}
.error {
  color: red;
}
.yellow {
  color: yellow;
}
.downLimit {
  color: red;
}
.upLimit {
  color: blue;
}
.fontweight {
  font-weight: bold;
}
.ant-table-tbody .red {
  background-color: red !important
}
</style>