BomList.vue 8.56 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="项目名称">
              <a-select
              show-search
              placeholder="请输入项目名称"
              option-filter-prop="children"
              :filter-option="filterOption"
              @change="handleChange"
              v-model="queryParam.projectName"
              >
              <a-select-option v-for="item in projectNameList" :key="item" :value="item">{{ item }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="项目编码">
              <a-select
                show-search
                placeholder="请输入项目编码"
                option-filter-prop="children"
                :filter-option="filterOption"
                @change="handleChange"
                v-model="queryParam.projectNo"
              >
                <a-select-option v-for="item in projectNoList" :key="item" :value="item">{{ item }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="工作令号">
              <a-select
                show-search
                placeholder="请输入工作令号"
                option-filter-prop="children"
                :filter-option="filterOption"
                @change="handleChange"
                v-model="queryParam.workNo"
              >
                <a-select-option v-for="item in workNoList" :key="item" :value="item">{{ item }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="bomId">
              <a-select
                show-search
                placeholder="请选择BOM"
                option-filter-prop="children"
                :filter-option="filterOption"
                @change="handleBomChange"
                v-model="queryParam.bomId"
              >
                <a-select-option v-for="item in bomIdList" :key="item" :value="item">{{ item }}</a-select-option>
              </a-select>
            </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>
            </span>
          </a-col>

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


    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</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>
    </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
        :columns="columns"
        :scroll="{x: 1500}"
        size="middle"
        :pagination="false"
        :dataSource="dataSource"
        :loading="loading"
        :expandedRowKeys="expandedRowKeys"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @expandedRowsChange="handleExpandedRowsChange">

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical"/>
          <a-dropdown>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
        <!-- 字符串超长截取省略号显示 -->
        <span slot="url" slot-scope="text">
          <j-ellipsis :value="text" :length="25"/>
        </span>
        <!-- 字符串超长截取省略号显示-->
        <span slot="component" slot-scope="text">
          <j-ellipsis :value="text"/>
        </span>
      </a-table>

    </div>
    <!-- table区域-end -->

    <bom-modal ref="modalForm" @ok="modalFormOk"></bom-modal>
  </a-card>

</template>

<script>
import {JeecgListMixin} from '../../mixins/JeecgListMixin'
import { getBomId, getBomTree, getProjectName, getWorkNo, getProjectNo, getBomIdList } from '../../api/api'
import BomModal from './modules/BomModal'

const columns = [
  {
    title: '图号',
    dataIndex: 'drawingNo',
    key: 'drawingNo'
  },
  {
  //   title: 'BOM',
  //   dataIndex: 'bomId',
  //   key: 'bomId'
  // }, {
    title: '物料编码',
    dataIndex: 'code',
    key: 'code'
  }, {
    title: '物料名称',
    dataIndex: 'name',
    key: 'name'
  },{
    title: '物料单位',
    dataIndex: 'unit',
    key: 'unit'
  }, {
    title: '用量',
    dataIndex: 'number',
    key: 'number'
  },{
    title: '状态',
    dataIndex: 'status',
    key: 'status'
  },{
    title: '制造方式',
    dataIndex: 'method',
    key: 'method'
  },{
    title: '设计类型',
    dataIndex: 'designType',
    key: 'designType'
  },{
    title: 'WIP属性',
    dataIndex: 'wipType',
    key: 'wipType'
  },{
    title: '品牌',
    dataIndex: 'brand',
    key: 'brand'
  }, {
    title: '分类',
    dataIndex: 'categories',
    key: 'categories'
  },{
    title: '操作',
    dataIndex: 'action',
    fixed: 'right',
    scopedSlots: { customRender: 'action' },
    align: 'center',
    width: 150
  }
]
export default {
  name: 'BomList',
  mixins: [JeecgListMixin],
  components: {
    BomModal
  },
  data() {
    return {
      description: '这是菜单管理页面',
      // 表头
      columns: columns,
      loading: false,
      // 展开的行,受控属性
      expandedRowKeys: [],
      url: {
        list: '/config/bom/list',
        delete: '/config/bom/delete',
        deleteBatch: '/config/bom/deleteBatch',
        importExcelUrl: '/config/bom/importExcel'
      },
      queryParam: {},
      projectNameList: [],
      workNoList: [],
      projectNoList: [],
      bomIdList: []
    }
  },
  created() {
    this.loadFrom()
  },
  methods: {
    loadFrom() {
      getProjectName().then((res) => {
        if (res.success) {
          this.projectNameList = res.result
        }
      })
      getWorkNo().then((res) => {
        if (res.success) {
          this.workNoList = res.result
        }
      })
      getProjectNo().then((res) => {
        if (res.success) {
          this.projectNoList = res.result
        }
      })
      getBomIdList().then((res) => {
        if (res.success) {
          this.bomIdList = res.result
        }
      })
    },
    filterOption(input, option) {
      return (
        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
      );
    },
    loadData(tree) {
      this.dataSource = tree;
    },

    handleExpandedRowsChange(expandedRows) {
      this.expandedRowKeys = expandedRows
    },

    query()  {
      let params = {
        "bomId": this.queryParam.bomId,
        "projectName": this.queryParam.projectName,
        "projectNo": this.queryParam.projectNo,
        "workNo": this.queryParam.workNo
      }
      getBomId(params).then((res) => {
        if (res.success) {
          this.bomIdList.push(res.result)
          this.initBomTree(this.bomIdList[0])
        }
      })
    },

    /**
     * @function 任务类型文本框的值变化时的回调
     * @author ***
     * @time 2020-08-17
     **/
    handleSearch (value) {
      this.handleChange(value);
    },

    handleBomChange(value) {
      this.initBomTree(value);
    },
    initBomTree(bomId) {
      let params = {
        "bomId": bomId
      }
      getBomTree(params).then((res) => {
        if (res.success) {
          this.loadData(res.result)
        }
      })
    }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  }
}
</script>

<style scoped>

</style>