- 添加权限检查功能,防止未授权操作 - 实现远程搜索功能优化任务选择体验 - 集成分页查询提高大数据量性能表现 - 增强批量操作界面增加搜索筛选功能 - 完善表单验证与错误处理机制 - 重构数据过滤逻辑支持多条件组合查询
47 lines
5.5 KiB
Vue
47 lines
5.5 KiB
Vue
<template>
|
|
<div class="purchase-lookup">
|
|
<el-form inline size="small">
|
|
<el-form-item label="物品"><el-input v-model="query.materialName" clearable placeholder="名称、品牌、规格" @keyup.enter.native="search"/></el-form-item>
|
|
<el-form-item label="项目"><el-select v-model="query.projectId" clearable filterable :disabled="!!projectId"><el-option v-for="p in projects" :key="p.id" :value="p.id" :label="p.projectName"/></el-select></el-form-item>
|
|
<el-form-item v-if="!unbatched" label="批次"><el-input v-model="query.purchaseBatchNo" clearable @keyup.enter.native="search"/></el-form-item>
|
|
<el-form-item v-if="!unbatched" label="供应商"><supplier-picker v-model="query.supplierId"/></el-form-item>
|
|
<el-form-item><el-button type="primary" icon="el-icon-search" @click="search">搜索</el-button><el-button @click="reset">重置</el-button></el-form-item>
|
|
</el-form>
|
|
<div v-if="unbatched" class="mb8"><el-button type="primary" plain size="small" :disabled="!selected.length" :loading="saving" @click="prepare(selected)" v-hasAllPermi="[['warehouse:purchase:add','warehouse:purchase:manage'],['warehouse:purchase:edit','warehouse:purchase:manage']]">组批并打开</el-button><span v-if="selected.length"> 已选 {{ selected.length }} 项</span><el-button v-if="selected.length" type="text" size="small" @click="clearSelection">清空选择</el-button></div>
|
|
<el-table ref="table" row-key="id" :data="rows" v-loading="loading" size="small" @selection-change="selectionChanged" @row-dblclick="open">
|
|
<el-table-column v-if="unbatched" type="selection" width="45" :reserve-selection="true" :selectable="canPrepare"/>
|
|
<el-table-column label="物品 / 规格" min-width="220"><template slot-scope="s">{{ s.row.materialName }}<div class="secondary">{{ [s.row.materialBrand,s.row.materialParams].filter(Boolean).join(' / ') }}</div></template></el-table-column>
|
|
<el-table-column prop="projectName" label="项目" min-width="130" show-overflow-tooltip/>
|
|
<el-table-column v-if="!unbatched" prop="purchaseBatchNo" label="批次" min-width="140" show-overflow-tooltip/>
|
|
<el-table-column v-if="!unbatched" prop="supplierName" label="供应商" min-width="120" show-overflow-tooltip/>
|
|
<el-table-column label="数量" width="95"><template slot-scope="s">{{ s.row.quantity }} {{ s.row.unit }}</template></el-table-column>
|
|
<el-table-column label="单价" width="100"><template slot-scope="s">{{ s.row.finalUnitPrice==null?'待报价':s.row.finalUnitPrice }}</template></el-table-column>
|
|
<el-table-column label="进度" width="150"><template slot-scope="s">已验收 {{ s.row.acceptedQuantity||0 }} / 未到 {{ s.row.remainingQuantity||0 }}</template></el-table-column>
|
|
<el-table-column label="操作" width="125" fixed="right"><template slot-scope="s"><el-button v-if="s.row.purchaseBatchId" type="text" @click="open(s.row)">打开清单</el-button><el-button v-else-if="canPrepare(s.row)" type="text" @click="prepare([s.row])" v-hasAllPermi="[['warehouse:purchase:add','warehouse:purchase:manage'],['warehouse:purchase:edit','warehouse:purchase:manage']]">组批并打开</el-button><span v-else>归档记录</span></template></el-table-column>
|
|
</el-table>
|
|
<pagination :total="total" :page.sync="query.pageNum" :limit.sync="query.pageSize" @pagination="load"/>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
import {listPurchase,preparePurchaseSheet} from '@/api/warehouse/purchase'
|
|
import {projectOptions} from '@/api/project/project'
|
|
export default {
|
|
props:{projectId:Number,unbatched:Boolean,embedded:Boolean},
|
|
components:{SupplierPicker:()=>import('@/components/SupplierPicker')},
|
|
data(){return {query:{pageNum:1,pageSize:20,materialName:'',purchaseBatchNo:'',projectId:this.projectId,supplierId:null,productionTaskId:Number(this.$route.query.productionTaskId)||undefined},rows:[],projects:[],total:0,selected:[],loading:false,saving:false}},
|
|
watch:{unbatched(){this.clearSelection();this.search()},projectId(id){this.query.projectId=id;this.clearSelection();this.search()},'$route.fullPath'(){if(!this.embedded){this.applyRoute();this.clearSelection();this.search()}}},
|
|
created(){projectOptions('',true).then(r=>this.projects=r.data||[]);this.applyRoute();this.load()},
|
|
methods:{
|
|
canPrepare(r){return !r.purchaseBatchId&&!r.priceLocked&&!r.historical&&Number(r.purchaseStatus)!==5&&Number(r.acceptedQuantity||0)<=0&&Number(r.pendingArrivalQuantity||0)<=0},
|
|
applyRoute(){if(this.embedded)return;this.query.productionTaskId=Number(this.$route.query.productionTaskId)||undefined;this.query.materialName=this.$route.query.materialName||'';this.query.requestNo=this.$route.query.requestNo||undefined},
|
|
selectionChanged(rows){this.selected=rows},clearSelection(){if(this.$refs.table)this.$refs.table.clearSelection();this.selected=[]},
|
|
async load(){const seq=this._sequence=(this._sequence||0)+1;this.loading=true;try{const r=await listPurchase({...this.query,unbatched:this.unbatched});if(seq===this._sequence){this.rows=r.rows||[];this.total=r.total||0}}finally{if(seq===this._sequence)this.loading=false}},
|
|
search(){this.query.pageNum=1;this.load()},
|
|
reset(){this.clearSelection();this.query={pageNum:1,pageSize:20,projectId:this.projectId};this.load()},
|
|
open(row){if(row.purchaseBatchId)this.$emit('open',row)},
|
|
async prepare(rows){if(this.saving)return;this.saving=true;try{const result=await preparePurchaseSheet(rows.map(r=>r.id));this.clearSelection();this.$emit('prepared',result.data)}finally{this.saving=false}}
|
|
}
|
|
}
|
|
</script>
|
|
<style scoped>.secondary{color:#909399;font-size:12px}.purchase-lookup{display:flex;flex-direction:column;flex:1;min-height:0}</style>
|