- 在 .env.production 中新增 VITE_AUTH_COOKIE_NAME 配置项用于设置认证cookie名称 - 将 AcceptanceException.vue 中的表单标签宽度从固定90px改为自动适配 - 在 ActionDialog.vue 中将多个表单项标记为必填项并调整标签宽度为自动适配 - 重构 ActionHistory.vue 中的按钮布局结构并添加表格列样式类名 - 更新 api-contract-audit.cjs 添加生产任务和BOM相关接口的契约测试 - 修改 auth.js 使用动态认证cookie键名替换硬编码的Admin-Token - 调整系统角色授权用户页面的表单布局和表格样式类名 - 优化 ReceiptDialog Batch 组件的对话框尺寸、表单验证和分页功能
67 lines
7.8 KiB
Vue
67 lines
7.8 KiB
Vue
<template>
|
|
<business-list-page :error="loadError" @retry="load">
|
|
<template #header>
|
|
<el-form inline size="small">
|
|
<query-toolbar :active-count="$filterCount([dates,query.active===false?'已撤销':query.active])">
|
|
<slot name="filters" />
|
|
<el-form-item label="物品 / 任务"><el-input v-model="query.keyword" clearable placeholder="物品、任务、项目" @keyup.enter="search"/></el-form-item>
|
|
<el-form-item label="类型"><el-select v-model="query.kind" clearable placeholder="全部类型" @change="search"><el-option v-for="(label,kind) in labels" :key="kind" :label="label" :value="kind"/></el-select></el-form-item>
|
|
<template #actions><el-button type="primary" icon="el-icon-search" @click="search">搜索</el-button><el-button icon="el-icon-refresh" @click="reset">重置</el-button><el-button v-if="showRefresh" icon="el-icon-refresh" size="small" @click="load">刷新</el-button></template>
|
|
|
|
<template #advanced>
|
|
<el-form-item label="日期"><el-date-picker v-model="dates" type="daterange" value-format="YYYY-MM-DD" start-placeholder="开始" end-placeholder="结束" @change="search"/></el-form-item>
|
|
<el-form-item label="状态"><el-select v-model="query.active" clearable placeholder="全部状态" @change="search"><el-option label="有效" :value="true"/><el-option label="已撤销" :value="false"/></el-select></el-form-item>
|
|
</template>
|
|
</query-toolbar>
|
|
</el-form>
|
|
<div v-if="$slots.actions || rows.some(r=>['ISSUE','DELIVERY'].includes(r.kind))" class="list-actions">
|
|
<slot name="actions" />
|
|
<el-button v-if="(rows.some(r=>r.kind==='ISSUE')) && ($canAll([['project:inventory:use'],['warehouse:stock:out']]))" size="small" :disabled="!canBatch('RETURN')" @click="$refs.batch.open(selected,'RETURN')" >批量退料</el-button>
|
|
<el-button v-if="(rows.some(r=>r.kind==='ISSUE')) && ($canAll([['project:inventory:use'],['warehouse:stock:out']]))" size="small" :disabled="!canBatch('SCRAP_ISSUED')" @click="$refs.batch.open(selected,'SCRAP_ISSUED')" >批量零件报废</el-button>
|
|
<el-button v-if="(rows.some(r=>r.kind==='DELIVERY')) && ($canAll([['project:inventory:use'],['warehouse:stock:out']]))" size="small" :disabled="!canBatch('DELIVERY_RETURN')" @click="$refs.batch.open(selected,'DELIVERY_RETURN')" >批量交付退回</el-button>
|
|
</div>
|
|
</template>
|
|
<template #default="{tableHeight}"><business-table :height="tableHeight" :data="rows" v-loading="loading" border max-height="520" @selection-change="selected=$event">
|
|
<el-table-column type="selection" width="45" :selectable="canSelectAction"/>
|
|
<el-table-column label="类型" min-width="155" show-overflow-tooltip><template #default="s">{{ labels[s.row.kind] }}</template></el-table-column>
|
|
<el-table-column prop="task_no" label="生产任务" min-width="155" show-overflow-tooltip/>
|
|
<el-table-column prop="project_name" label="项目" min-width="130" show-overflow-tooltip/><el-table-column prop="item_name" label="物品" min-width="150" show-overflow-tooltip/><el-table-column prop="area_name" label="库区" min-width="100" show-overflow-tooltip/>
|
|
<el-table-column prop="quantity" label="数量" width="90" show-overflow-tooltip/><el-table-column label="已处理 / 可处理" width="135" show-overflow-tooltip><template #default="s"><span v-if="['ISSUE','DELIVERY'].includes(s.row.kind)">{{ s.row.handled_quantity||0 }} / {{ remaining(s.row) }}</span><span v-else>—</span></template></el-table-column><el-table-column label="成本" width="110" show-overflow-tooltip><template #default="s">{{ s.row.cost_event_id ? (s.row.effective_cost == null ? '未知' : s.row.effective_cost) : '不重复计费' }}</template></el-table-column>
|
|
<el-table-column prop="business_date" label="日期" width="105" show-overflow-tooltip/><el-table-column prop="reason" label="原因" min-width="120" show-overflow-tooltip/><el-table-column prop="recipient" label="接收方" min-width="110" show-overflow-tooltip/>
|
|
<el-table-column label="状态" width="80" align="center" class-name="business-status-cell"><template #default="s">{{ s.row.active ? '有效' : '已撤销' }}</template></el-table-column>
|
|
<el-table-column label="操作" width="190" fixed="right" align="center" class-name="business-operation-cell"><template #default="s"><template v-if="s.row.active">
|
|
<el-button v-if="(s.row.kind==='ISSUE' && remaining(s.row)>0) && ($canAll([['project:inventory:use'],['warehouse:stock:out']]))" link type="primary" @click="$refs.action.open('RETURN',{source:s.row})" >退料</el-button>
|
|
<el-button v-if="(s.row.kind==='ISSUE' && remaining(s.row)>0) && ($canAll([['project:inventory:use'],['warehouse:stock:out']]))" link type="primary" @click="$refs.action.open('SCRAP_ISSUED',{source:s.row})" >报废</el-button>
|
|
<el-button v-if="(s.row.kind==='DELIVERY' && remaining(s.row)>0) && ($canAll([['project:inventory:use'],['warehouse:stock:out']]))" link type="primary" @click="$refs.action.open('DELIVERY_RETURN',{source:s.row})" >退回</el-button>
|
|
<el-tooltip v-if="s.row.kind!=='OUTPUT'" content="请先撤销关联的退料、报废或退回记录" :disabled="Number(s.row.handled_quantity||0)===0"><span style="display:inline-block;margin-left:10px"><el-button :disabled="Number(s.row.handled_quantity||0)>0" link type="primary" @click="$refs.withdraw.open(s.row)" v-if="$canAll([['project:inventory:use'],['warehouse:stock:out']])">撤销</el-button></span></el-tooltip>
|
|
</template></template></el-table-column>
|
|
</business-table></template>
|
|
<template #footer><pagination :total="total" v-model:page="query.pageNum" v-model:limit="query.pageSize" @pagination="load"/></template>
|
|
<template #dialogs><action-dialog ref="action" @changed="changed" /><batch-actions ref="batch" @changed="changed"/><withdraw-action ref="withdraw" @changed="changed"/></template>
|
|
</business-list-page>
|
|
</template>
|
|
<script>
|
|
import { listActionPage, revokeAction } from '@/api/production/tasks'
|
|
import BatchActions from './BatchActions'
|
|
import WithdrawAction from './WithdrawAction'
|
|
import ActionDialog, { actionLabels } from './ActionDialog'
|
|
import { runLatest, invalidateQuery, queryError } from '@/utils/query-session'
|
|
export default {
|
|
name: 'ProductionHistory', components: { ActionDialog, BatchActions, WithdrawAction },
|
|
props: { projectId: Number, taskId: Number, showRefresh: { type:Boolean, default:true } },
|
|
data: () => ({ rows: [], selected: [], labels: actionLabels,loading:false,loadError:'',total:0,query:{pageNum:1,pageSize:20,kind:'',keyword:'',active:null},dates:[] }),
|
|
|
|
watch: { projectId: 'load', taskId: 'load' }, created() {if(!this.taskId){const now=new Date(),start=new Date();start.setDate(start.getDate()-30);this.dates=[this.parseTime(start,'{y}-{m}-{d}'),this.parseTime(now,'{y}-{m}-{d}')]}this.load() },
|
|
beforeUnmount(){invalidateQuery(this,'list')},
|
|
methods: {
|
|
canSelectAction(row) { return !!row.active && this.remaining(row) > 0 && ['ISSUE', 'DELIVERY'].includes(row.kind) },
|
|
canBatch(kind) { const sourceKind = kind === 'DELIVERY_RETURN' ? 'DELIVERY' : 'ISSUE'; return this.selected.length > 0 && this.selected.every(row => this.canSelectAction(row) && row.kind === sourceKind) },
|
|
search(){this.query.pageNum=1;this.load()},reset(){this.query={pageNum:1,pageSize:20,kind:'',keyword:'',active:null};this.dates=[];this.load()},
|
|
filters(){const dates=this.dates||[];return {...this.query,projectId:this.projectId,taskId:this.taskId,beginDate:dates[0],endDate:dates[1]}},
|
|
load() { const params=this.filters();return runLatest(this,'list',()=>listActionPage(params),{start:()=>{this.selected=[];this.loading=true;this.loadError=''},success:response=>{const result=response.data;this.rows=result.rows||[];this.total=result.total||0},error:error=>{this.rows=[];this.total=0;this.loadError=queryError(error)},finish:()=>{this.loading=false}}) },
|
|
remaining(row) { return Number(row.quantity) - Number(row.handled_quantity || 0) },
|
|
changed() { this.load(); this.$emit('changed') }
|
|
}
|
|
}
|
|
</script>
|