<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 :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> <!-- table区域-begin --> <div> <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;"> <i class="anticon anticon-info-circle ant-alert-icon"></i>已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项 <a style="margin-left: 24px" @click="onClearSelected">清空</a> </div> <a-table :columns="columns" :scroll="{x: 1500}" size="middle" :pagination="pagination" :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> <a-table ref="table" bordered size="middle" rowKey="id" :columns="planColumns" :dataSource="planDataSource" :pagination="ipagination" :loading="loading" :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" @change="handleTableChange"> <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> </a-table> </div> <!-- table区域-end --> <purchase-in-modal ref="modalForm" @ok="modalFormOk"></purchase-in-modal> </a-card> </template> <script> import {JeecgListMixin} from '../../mixins/JeecgListMixin' import { getProjectName, getWorkNo, getProjectNo, getBomTree, getPurchase, getBomIdList, getBomId } from '../../api/api' import PurchaseInModal from './modules/PurchaseInModal' 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: 'PurchaseIn', mixins: [JeecgListMixin], components: { PurchaseInModal }, 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' }, planDataSource: [], queryParam: [], projectNameList: [], workNoList: [], projectNoList: [], pagination:{ defaultPageSize:5, showTotal: total => `共 ${total} 条数据`, showSizeChanger:true, pageSizeOptions: ['5', '10', '15', '20'], onShowSizeChange:(current, pageSize)=>this.pageSize = pageSize }, bomIdList: [], planColumns: [ { title: '物料编码', dataIndex: 'materialCode', key: 'materialCode' }, { title: '物料名称', dataIndex: 'materialName', key: 'materialName' },{ title: '物料单位', dataIndex: 'unit', key: 'unit' }, { title: '数量', dataIndex: 'qty', key: 'qty' // },{ // title: '公司', // dataIndex: 'vendor', // key: 'vendor' },{ title: '联系方式', dataIndex: 'phone', key: 'phone' // },{ // title: '计划开始时间', // dataIndex: 'planStartTime', // key: 'planStartTime' },{ title: '计划完成时间', dataIndex: 'planEndTime', key: 'planEndTime' // },{ // title: '实际开始时间', // dataIndex: 'actualStartTime', // key: 'actualStartTime' }, { title: '实际完成时间', dataIndex: 'actualEndTime', key: 'actualEndTime' },{ title: '操作', dataIndex: 'action', fixed: 'right', scopedSlots: { customRender: 'action' }, align: 'center', width: 150 } ] } }, 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 } }) }, handleChange(value) { console.log(`selected ${value}`); }, filterOption(input, option) { return ( option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 ); }, loadData(tree) { this.dataSource = tree; }, handleExpandedRowsChange(expandedRows) { this.expandedRowKeys = expandedRows }, handleBomChange(value) { this.initBomTree(value); }, 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]) } }) getPurchase(params).then((res) => { if (res.success) { this.planDataSource = res.result.records||res.result; if(res.result.total) { this.ipagination.total = res.result.total; }else{ this.ipagination.total = 0; } } }) }, initBomTree(bomId) { let params = { "bomId": bomId } getBomTree(params).then((res) => { if (res.success) { this.loadData(res.result) } }) getPurchase(params).then((res) => { if (res.success) { console.log(res) this.planDataSource = res.result.records; if(res.result.total) { this.ipagination.total = res.result.total; }else{ this.ipagination.total = 0; } } }) } }, computed: { importExcelUrl: function(){ return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`; } } } </script> <style scoped> </style>