|
|
|
|
@ -4,35 +4,34 @@
|
|
|
|
|
<el-dialog
|
|
|
|
|
:title="!dataForm.id ? '添加' : '修改'"
|
|
|
|
|
:close-on-click-modal="false"
|
|
|
|
|
:visible.sync="visible">
|
|
|
|
|
:visible.sync="visible"
|
|
|
|
|
width="1000px">
|
|
|
|
|
<!-- 新增和修改表单 -->
|
|
|
|
|
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataSubmit()" label-width="120px">
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="计划编号" prop="planNo">
|
|
|
|
|
<el-input v-model="dataForm.planNo" placeholder="计划编号"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="计划采购日期" prop="purchaseDate">
|
|
|
|
|
<el-date-picker v-model="dataForm.purchaseDate" type="date" value-format="yyyy-MM-dd" placeholder="计划采购日期" style="width: 100%"></el-date-picker>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="预计用餐人数" prop="expectedPersonCount">
|
|
|
|
|
<el-input v-model="dataForm.expectedPersonCount" placeholder="预计用餐人数"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="历史消耗数据" prop="historyConsumption">
|
|
|
|
|
<el-input v-model="dataForm.historyConsumption" placeholder="历史消耗数据"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="申请部门" prop="applyDept">
|
|
|
|
|
<treeselect
|
|
|
|
|
v-model="dataForm.applyDept"
|
|
|
|
|
@ -43,9 +42,9 @@
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="申请人" prop="applyUser">
|
|
|
|
|
<el-select v-model="dataForm.applyUser" placeholder="请选择申请人" style="width: 100%">
|
|
|
|
|
<el-select v-model="dataForm.applyUser" placeholder="请选择申请人" style="width: 100%" :disabled="!dataForm.applyDept">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="user in userList"
|
|
|
|
|
:key="user.id"
|
|
|
|
|
@ -57,14 +56,14 @@
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="申请日期" prop="applyDate">
|
|
|
|
|
<el-date-picker v-model="dataForm.applyDate" type="date" value-format="yyyy-MM-dd" placeholder="申请日期" style="width: 100%"></el-date-picker>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="状态" prop="status">
|
|
|
|
|
<el-select v-model="dataForm.status" placeholder="请选择状态" style="width: 100%">
|
|
|
|
|
<el-select v-model="dataForm.status" placeholder="请选择状态" style="width: 100%" disabled>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="dict in dict.type.plan_status"
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
@ -74,14 +73,14 @@
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="审核人" prop="auditUser">
|
|
|
|
|
<el-input v-model="dataForm.auditUser" placeholder="审核人"></el-input>
|
|
|
|
|
<el-input v-model="dataForm.auditUserName" placeholder="请输入审核人" disabled></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="审核时间" prop="auditDate">
|
|
|
|
|
<el-date-picker v-model="dataForm.auditDate" type="date" value-format="yyyy-MM-dd" placeholder="审核时间" style="width: 100%"></el-date-picker>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
@ -97,47 +96,107 @@
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="关联需求">
|
|
|
|
|
<el-button v-if="isAddOperation" type="primary" @click="openDemandDialog">选择需求</el-button>
|
|
|
|
|
<el-button v-if="isAddOperation || dataForm.status === '1'" type="primary" @click="openDemandDialog" style="margin-right: 10px">选择需求商品</el-button>
|
|
|
|
|
<el-button v-if="isAddOperation || dataForm.status === '1'" type="success" @click="openSelectGoodsModal" style="margin-right: 10px">选择商品</el-button>
|
|
|
|
|
<!-- <el-button v-if="isAddOperation || dataForm.status === '1'" type="warning" @click="openBatchAddModal">批量添加商品</el-button>-->
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<!-- 已关联采购需求 -->
|
|
|
|
|
<!-- 已选商品(来自需求) -->
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-collapse v-model="activeNames" class="mt20">
|
|
|
|
|
<el-collapse-item name="1">
|
|
|
|
|
<el-collapse-item name="1" title="已选商品(来自需求)">
|
|
|
|
|
<div v-if="selectedGoods.length === 0" style="text-align: center; padding: 20px; color: #999;">
|
|
|
|
|
暂无已选商品
|
|
|
|
|
</div>
|
|
|
|
|
<el-table
|
|
|
|
|
:data="selectedDemands"
|
|
|
|
|
v-else
|
|
|
|
|
:data="selectedGoods"
|
|
|
|
|
border
|
|
|
|
|
style="width: 100%">
|
|
|
|
|
<el-table-column type="expand" header-align="center" align="center">
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="goodsName"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="采购商品名称">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="goodsCode"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="商品编号">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="spec"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="规格">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="unit"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="单位">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<!-- 使用DemandDispatchList组件显示需求明细 -->
|
|
|
|
|
<DemandDispatchList
|
|
|
|
|
:orderId="scope.row.id"
|
|
|
|
|
:showSearch="false"
|
|
|
|
|
<dict-tag :options="dict.type.sys_measurement_unit" :value="scope.row.unit"/>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="planQuantity"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
label="计划采购数量">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model.number="scope.row.planQuantity"
|
|
|
|
|
type="number"
|
|
|
|
|
step="0.01"
|
|
|
|
|
min="0.01"
|
|
|
|
|
@blur="validatePlanQuantity(scope.row)"
|
|
|
|
|
@change="calculatePlanAmount(scope.row)"
|
|
|
|
|
:disabled="!isAddOperation && dataForm.status !== '1'"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="demandDate"
|
|
|
|
|
prop="planPrice"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="需求日期">
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
label="计划单价">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model.number="scope.row.planPrice"
|
|
|
|
|
type="number"
|
|
|
|
|
step="0.01"
|
|
|
|
|
min="0"
|
|
|
|
|
@change="calculatePlanAmount(scope.row)"
|
|
|
|
|
:disabled="!isAddOperation && dataForm.status !== '1'"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="userName"
|
|
|
|
|
prop="planAmount"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="申请人">
|
|
|
|
|
label="计划金额">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<span>{{ scope.row.planAmount || 0.00 }}</span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="status"
|
|
|
|
|
prop="remark"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="需求状态">
|
|
|
|
|
label="备注">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<DictTag :options="dict.type.demand_status" :value="scope.row.status"/>
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="scope.row.remark"
|
|
|
|
|
type="text"
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
@ -145,13 +204,10 @@
|
|
|
|
|
align="center"
|
|
|
|
|
label="操作">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<el-button v-if="isAddOperation" type="text" size="small" @click="removeDemand(scope.row.id)" style="color: #f56c6c;">取消关联</el-button>
|
|
|
|
|
<el-button v-if="isAddOperation || dataForm.status === '1'" type="text" size="small" @click="removeGoods(scope.$index)" style="color: #f56c6c;">删除</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
<!-- <div v-if="selectedDemands.length === 0" style="text-align: center; padding: 20px; color: #999;">-->
|
|
|
|
|
<!-- 暂无关联的采购需求-->
|
|
|
|
|
<!-- </div>-->
|
|
|
|
|
</el-collapse-item>
|
|
|
|
|
</el-collapse>
|
|
|
|
|
</el-col>
|
|
|
|
|
@ -172,17 +228,17 @@
|
|
|
|
|
>
|
|
|
|
|
<el-form :inline="true" :model="demandForm" @keyup.enter.native="getDemandList()">
|
|
|
|
|
<el-form-item label="申请人">
|
|
|
|
|
<el-input v-model="demandForm.demandUser" placeholder="请输入申请人" clearable></el-input>
|
|
|
|
|
<el-input v-model="demandForm.userNameSearch" placeholder="请输入申请人" clearable></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="状态">
|
|
|
|
|
<el-select v-model="demandForm.status" placeholder="请选择状态" clearable style="width: 150px">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in dict.type.demand_status"
|
|
|
|
|
:key="item.value"
|
|
|
|
|
:label="item.label"
|
|
|
|
|
:value="item.value"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
<el-form-item label="计划采购日期">
|
|
|
|
|
<el-date-picker
|
|
|
|
|
v-model="demandForm.demandDate"
|
|
|
|
|
type="date"
|
|
|
|
|
placeholder="选择计划采购日期"
|
|
|
|
|
format="yyyy-MM-dd"
|
|
|
|
|
value-format="yyyy-MM-dd"
|
|
|
|
|
clearable
|
|
|
|
|
></el-date-picker>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button @click="getDemandList()">查询</el-button>
|
|
|
|
|
@ -190,9 +246,12 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<el-table
|
|
|
|
|
ref="demandTable"
|
|
|
|
|
:data="demandList"
|
|
|
|
|
row-key="id"
|
|
|
|
|
border
|
|
|
|
|
@selection-change="demandSelectionChangeHandle"
|
|
|
|
|
@select="handleDemandSelect"
|
|
|
|
|
@select-all="handleDemandSelectAll"
|
|
|
|
|
style="width: 100%; margin-top: 20px;">
|
|
|
|
|
<el-table-column
|
|
|
|
|
type="selection"
|
|
|
|
|
@ -202,11 +261,54 @@
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column type="expand" header-align="center" align="center">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<!-- 使用DemandDispatchList组件 -->
|
|
|
|
|
<DemandDispatchList
|
|
|
|
|
:orderId="scope.row.id"
|
|
|
|
|
:showSearch="false"
|
|
|
|
|
/>
|
|
|
|
|
<el-table
|
|
|
|
|
:ref="`productTable_${scope.row.id}`"
|
|
|
|
|
:data="scope.row.products || []"
|
|
|
|
|
border
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
@select="(selection) => handleProductSelect(selection, scope.row)"
|
|
|
|
|
@select-all="(selection) => handleProductSelectAll(selection, scope.row)"
|
|
|
|
|
>
|
|
|
|
|
<el-table-column
|
|
|
|
|
type="selection"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
width="50">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="goodsName"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="商品名称">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="goodsCode"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="商品编号">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="spec"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="规格">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="unit"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="单位">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<dict-tag :options="dict.type.sys_measurement_unit" :value="scope.row.unit"/>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="demandQuantity"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="需求数量">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
@ -230,17 +332,126 @@
|
|
|
|
|
<DictTag :options="dict.type.demand_status" :value="scope.row.status"/>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
|
<el-button @click="demandDialogVisible = false">取消</el-button>
|
|
|
|
|
<el-button type="primary" @click="confirmSelectDemand()" :disabled="selectedGoodsTemp.length <= 0">确定选择</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
<!-- 选择商品弹窗 -->
|
|
|
|
|
<el-dialog
|
|
|
|
|
title="选择商品(支持多选)"
|
|
|
|
|
:close-on-click-modal="false"
|
|
|
|
|
:visible.sync="selectGoodsVisible" width="80%">
|
|
|
|
|
<!-- 搜索表单 -->
|
|
|
|
|
<el-form :inline="true" :model="goodsSearchForm" @keyup.enter.native="getGoodsList()">
|
|
|
|
|
<el-form-item label="商品名称">
|
|
|
|
|
<el-input v-model="goodsSearchForm.goodsName" placeholder="请输入商品名称" clearable></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="规格">
|
|
|
|
|
<el-input v-model="goodsSearchForm.spec" placeholder="请输入规格" clearable></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button @click="getGoodsList()">查询</el-button>
|
|
|
|
|
<el-button @click="resetGoodsSearchForm()">重置</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
<!-- 商品表格 -->
|
|
|
|
|
<el-table
|
|
|
|
|
:data="goodsList"
|
|
|
|
|
border
|
|
|
|
|
v-loading="goodsLoading"
|
|
|
|
|
@selection-change="handleGoodsSelectionChange"
|
|
|
|
|
style="width: 100%">
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="remark"
|
|
|
|
|
type="selection"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
width="50">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="goodsName"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="备注">
|
|
|
|
|
label="商品名称">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="goodsCode"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="商品编码">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="spec"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="规格">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="unit"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="单位">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<DictTag :options="dict.type.sys_measurement_unit" :value="scope.row.unit" />
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="custName"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="供应商">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="costPrice"
|
|
|
|
|
header-align="center"
|
|
|
|
|
align="center"
|
|
|
|
|
label="成本价">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
|
<el-button @click="demandDialogVisible = false">取消</el-button>
|
|
|
|
|
<el-button type="primary" @click="confirmSelectDemand()" :disabled="tempSelectedDemands.length <= 0">确定选择</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- 分页控件 -->
|
|
|
|
|
<el-pagination
|
|
|
|
|
@size-change="handleGoodsSizeChange"
|
|
|
|
|
@current-change="handleGoodsCurrentChange"
|
|
|
|
|
:current-page="goodsPage.page"
|
|
|
|
|
:page-sizes="[10, 20, 50, 100]"
|
|
|
|
|
:page-size="goodsPage.limit"
|
|
|
|
|
:total="goodsPage.total"
|
|
|
|
|
layout="total, sizes, prev, pager, next, jumper">
|
|
|
|
|
</el-pagination>
|
|
|
|
|
|
|
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
|
|
<el-button @click="selectGoodsVisible = false">取消</el-button>
|
|
|
|
|
<el-button type="primary" @click="confirmSelectGoods">确认选择</el-button>
|
|
|
|
|
</span>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
<!-- 批量添加商品弹窗 -->
|
|
|
|
|
<el-dialog
|
|
|
|
|
title="批量添加商品"
|
|
|
|
|
:visible.sync="batchAddVisible"
|
|
|
|
|
append-to-body
|
|
|
|
|
:close-on-click-modal="false"
|
|
|
|
|
width="70%">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="selectedGoodsForBatch"
|
|
|
|
|
multiple
|
|
|
|
|
filterable
|
|
|
|
|
allow-create
|
|
|
|
|
default-first-option
|
|
|
|
|
placeholder="请选择商品"
|
|
|
|
|
style="width: 100%; margin-bottom: 20px;">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="goods in goodsList"
|
|
|
|
|
:key="goods.id"
|
|
|
|
|
:label="goods.goodsName + '|' + goods.spec + '|' + goods.unit"
|
|
|
|
|
:value="goods.id"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
<el-button type="primary" @click="confirmBatchAdd">确认添加</el-button>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
@ -250,6 +461,7 @@
|
|
|
|
|
import * as deptApi from '@/api/sysdept.js'
|
|
|
|
|
import * as adminApi from '@/api/systemadmin.js'
|
|
|
|
|
import * as demandApi from '@/api/pmcanteendemand.js'
|
|
|
|
|
import * as cmcustproductApi from '@/api/cmcustproduct.js'
|
|
|
|
|
import Treeselect from '@riophae/vue-treeselect'
|
|
|
|
|
import DictTag from '@/components/DictTag'
|
|
|
|
|
import DemandDispatchList from './DemandDispatchList.vue'
|
|
|
|
|
@ -267,7 +479,7 @@
|
|
|
|
|
default: false
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
dicts: ['demand_status', 'plan_status'],
|
|
|
|
|
dicts: ['demand_status', 'plan_status', 'sys_measurement_unit'],
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
isAddOperation: false, // 标记是否是新增操作
|
|
|
|
|
@ -292,12 +504,31 @@
|
|
|
|
|
demandDialogVisible: false,
|
|
|
|
|
demandList: [],
|
|
|
|
|
selectedDemands: [],
|
|
|
|
|
tempSelectedDemands: [], // 临时存储弹窗中选择的需求
|
|
|
|
|
selectedGoods: [], // 已选商品列表
|
|
|
|
|
selectedGoodsTemp: [], // 临时存储弹窗中选择的商品
|
|
|
|
|
demandForm: {
|
|
|
|
|
demandUser: '',
|
|
|
|
|
status: '',
|
|
|
|
|
userNameSearch: '',
|
|
|
|
|
demandDate: '',
|
|
|
|
|
status: '1', // 默认查询已审核状态
|
|
|
|
|
},
|
|
|
|
|
activeNames: ['1'], // 控制折叠面板的展开状态
|
|
|
|
|
// 选择商品弹窗相关
|
|
|
|
|
selectGoodsVisible: false, // 选择商品弹窗
|
|
|
|
|
goodsList: [], // 商品列表
|
|
|
|
|
tempSelectedGoods: [], // 弹窗中临时选中的商品
|
|
|
|
|
goodsSearchForm: {
|
|
|
|
|
goodsName: '',
|
|
|
|
|
spec: ''
|
|
|
|
|
},
|
|
|
|
|
goodsPage: {
|
|
|
|
|
page: 1,
|
|
|
|
|
limit: 10,
|
|
|
|
|
total: 0
|
|
|
|
|
},
|
|
|
|
|
goodsLoading: false,
|
|
|
|
|
// 批量添加商品相关
|
|
|
|
|
batchAddVisible: false,
|
|
|
|
|
selectedGoodsForBatch: [],
|
|
|
|
|
dataRule: {
|
|
|
|
|
planNo: [
|
|
|
|
|
{ required: true, message: '计划编号 为必填项', trigger: 'blur' }
|
|
|
|
|
@ -322,6 +553,7 @@
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
this.loadDeptTree()
|
|
|
|
|
this.loadGoodsList()
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
// 监听isFromAdd属性的变化
|
|
|
|
|
@ -385,6 +617,23 @@
|
|
|
|
|
// 重置选中的需求数组
|
|
|
|
|
this.selectedDemands = []
|
|
|
|
|
this.tempSelectedDemands = [] // 重置临时选择的需求数组
|
|
|
|
|
this.selectedGoods = []
|
|
|
|
|
this.selectedGoodsTemp = [] // 重置临时选择的商品数组
|
|
|
|
|
// 重置表单数据
|
|
|
|
|
this.dataForm = {
|
|
|
|
|
id: id || null,
|
|
|
|
|
planNo: '' ,
|
|
|
|
|
purchaseDate: '' ,
|
|
|
|
|
expectedPersonCount: '' ,
|
|
|
|
|
historyConsumption: '' ,
|
|
|
|
|
applyUser: '' ,
|
|
|
|
|
applyDate: new Date().toISOString().split('T')[0], // 申请时间默认填写当天
|
|
|
|
|
applyDept: '' ,
|
|
|
|
|
auditUser: '' ,
|
|
|
|
|
auditDate: '' ,
|
|
|
|
|
status: '1' , // 状态默认为草稿
|
|
|
|
|
remark: '' ,
|
|
|
|
|
}
|
|
|
|
|
this.$nextTick(function() {
|
|
|
|
|
// 确保dataForm引用存在
|
|
|
|
|
if (this.$refs['dataForm']) {
|
|
|
|
|
@ -396,8 +645,21 @@
|
|
|
|
|
// 如果是编辑模式,需要重新加载选中的需求
|
|
|
|
|
this.selectedDemands = []
|
|
|
|
|
this.tempSelectedDemands = [] // 重置临时选择的需求数组
|
|
|
|
|
this.selectedGoods = []
|
|
|
|
|
this.selectedGoodsTemp = [] // 重置临时选择的商品数组
|
|
|
|
|
this.isAddOperation = false // 编辑模式下不显示需求选择
|
|
|
|
|
|
|
|
|
|
// 如果有pmCanteenPurchaseDetails,转换为selectedGoods
|
|
|
|
|
if (res.pmCanteenPurchaseDetails && res.pmCanteenPurchaseDetails.length > 0) {
|
|
|
|
|
this.selectedGoods = res.pmCanteenPurchaseDetails.map(detail => ({
|
|
|
|
|
...detail,
|
|
|
|
|
// 确保计划采购数量、计划单价和计划金额是数字类型
|
|
|
|
|
planQuantity: parseFloat(detail.planQuantity) || 0,
|
|
|
|
|
planPrice: parseFloat(detail.planPrice) || 0,
|
|
|
|
|
planAmount: parseFloat(detail.planAmount) || 0
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如果有demandIds,加载对应的需求
|
|
|
|
|
if (res.demandIds && res.demandIds.length > 0) {
|
|
|
|
|
// 对每个需求ID,单独调用详情API获取需求信息
|
|
|
|
|
@ -443,6 +705,11 @@
|
|
|
|
|
this.dataForm.demandIds = this.selectedDemands.map(item => item.id)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加选中的商品到表单数据
|
|
|
|
|
if (this.selectedGoods.length > 0) {
|
|
|
|
|
this.dataForm.pmCanteenPurchaseDetails = this.selectedGoods
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.dataForm.id) {
|
|
|
|
|
api.pmcanteenpurchaseplanUpdateApi(this.dataForm).then(function(res) {
|
|
|
|
|
this.$message.success('保存成功')
|
|
|
|
|
@ -461,8 +728,8 @@
|
|
|
|
|
},
|
|
|
|
|
// 打开需求选择弹窗
|
|
|
|
|
openDemandDialog () {
|
|
|
|
|
if (!this.isAddOperation) {
|
|
|
|
|
this.$message.warning('只有新增采购计划时才能选择需求')
|
|
|
|
|
if (!this.isAddOperation && this.dataForm.status !== '1') {
|
|
|
|
|
this.$message.warning('只有新增或草稿状态的采购计划才能选择需求')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.demandDialogVisible = true
|
|
|
|
|
@ -474,37 +741,284 @@
|
|
|
|
|
page: 1,
|
|
|
|
|
limit: 100
|
|
|
|
|
}
|
|
|
|
|
// 只传递非空参数
|
|
|
|
|
if (this.demandForm.userNameSearch) {
|
|
|
|
|
params.userNameSearch = this.demandForm.userNameSearch
|
|
|
|
|
}
|
|
|
|
|
if (this.demandForm.demandDate) {
|
|
|
|
|
params.demandDate = this.demandForm.demandDate
|
|
|
|
|
}
|
|
|
|
|
// 默认查询已审核状态
|
|
|
|
|
params.status = '1'
|
|
|
|
|
demandApi.pmcanteendemandListApi(params).then(res => {
|
|
|
|
|
this.demandList = res.list || []
|
|
|
|
|
// 直接使用list接口返回的pmCanteenDemandDetails作为商品列表
|
|
|
|
|
this.demandList.forEach(demand => {
|
|
|
|
|
demand.products = demand.pmCanteenDemandDetails || []
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 重置需求搜索表单
|
|
|
|
|
resetDemandForm () {
|
|
|
|
|
this.demandForm = {
|
|
|
|
|
demandUser: '',
|
|
|
|
|
status: '',
|
|
|
|
|
userNameSearch: '',
|
|
|
|
|
demandDate: '',
|
|
|
|
|
status: '1' // 重置后仍然默认查询已审核状态
|
|
|
|
|
}
|
|
|
|
|
this.getDemandList()
|
|
|
|
|
},
|
|
|
|
|
// 需求选择变化处理
|
|
|
|
|
demandSelectionChangeHandle (val) {
|
|
|
|
|
this.tempSelectedDemands = val
|
|
|
|
|
// 处理需求选择
|
|
|
|
|
handleDemandSelect (selection, row) {
|
|
|
|
|
// 检查当前需求是否被选中
|
|
|
|
|
const isSelected = selection.includes(row)
|
|
|
|
|
|
|
|
|
|
// 勾选或取消勾选该需求下的所有商品
|
|
|
|
|
const productTable = this.$refs[`productTable_${row.id}`]
|
|
|
|
|
if (productTable) {
|
|
|
|
|
if (isSelected) {
|
|
|
|
|
// 勾选所有商品
|
|
|
|
|
if (row.products && row.products.length > 0) {
|
|
|
|
|
row.products.forEach(product => {
|
|
|
|
|
productTable.toggleRowSelection(product, true)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 取消勾选所有商品
|
|
|
|
|
productTable.clearSelection()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新临时选择的商品
|
|
|
|
|
this.updateSelectedGoodsTemp()
|
|
|
|
|
},
|
|
|
|
|
// 处理需求全选
|
|
|
|
|
handleDemandSelectAll (selection) {
|
|
|
|
|
// 遍历所有需求
|
|
|
|
|
this.demandList.forEach(demand => {
|
|
|
|
|
const isSelected = selection.includes(demand)
|
|
|
|
|
// 勾选或取消勾选该需求下的所有商品
|
|
|
|
|
const productTable = this.$refs[`productTable_${demand.id}`]
|
|
|
|
|
if (productTable) {
|
|
|
|
|
if (isSelected) {
|
|
|
|
|
// 勾选所有商品
|
|
|
|
|
if (demand.products && demand.products.length > 0) {
|
|
|
|
|
demand.products.forEach(product => {
|
|
|
|
|
productTable.toggleRowSelection(product, true)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 取消勾选所有商品
|
|
|
|
|
productTable.clearSelection()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 更新临时选择的商品
|
|
|
|
|
this.updateSelectedGoodsTemp()
|
|
|
|
|
},
|
|
|
|
|
// 处理商品选择
|
|
|
|
|
handleProductSelect (selection, demand) {
|
|
|
|
|
// 更新需求行的选中状态
|
|
|
|
|
this.updateDemandSelection(demand)
|
|
|
|
|
// 更新临时选择的商品
|
|
|
|
|
this.updateSelectedGoodsTemp()
|
|
|
|
|
},
|
|
|
|
|
// 处理商品全选
|
|
|
|
|
handleProductSelectAll (selection, demand) {
|
|
|
|
|
// 更新需求行的选中状态
|
|
|
|
|
this.updateDemandSelection(demand)
|
|
|
|
|
// 更新临时选择的商品
|
|
|
|
|
this.updateSelectedGoodsTemp()
|
|
|
|
|
},
|
|
|
|
|
// 更新需求行的选中状态
|
|
|
|
|
updateDemandSelection (demand) {
|
|
|
|
|
const productTable = this.$refs[`productTable_${demand.id}`]
|
|
|
|
|
if (productTable) {
|
|
|
|
|
const selectedProducts = productTable.selection || []
|
|
|
|
|
const demandTable = this.$refs.demandTable
|
|
|
|
|
if (demandTable) {
|
|
|
|
|
if (selectedProducts.length === 0) {
|
|
|
|
|
// 没有选中的商品,取消需求行的选中
|
|
|
|
|
demandTable.toggleRowSelection(demand, false)
|
|
|
|
|
} else if (selectedProducts.length === demand.products.length) {
|
|
|
|
|
// 所有商品都选中,选中需求行
|
|
|
|
|
demandTable.toggleRowSelection(demand, true)
|
|
|
|
|
} else {
|
|
|
|
|
// 部分商品选中,设置需求行为半选状态
|
|
|
|
|
demandTable.toggleRowSelection(demand, null)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 更新临时选择的商品
|
|
|
|
|
updateSelectedGoodsTemp () {
|
|
|
|
|
// 清空临时选择的商品
|
|
|
|
|
this.selectedGoodsTemp = []
|
|
|
|
|
|
|
|
|
|
// 遍历所有需求
|
|
|
|
|
this.demandList.forEach(demand => {
|
|
|
|
|
const productTable = this.$refs[`productTable_${demand.id}`]
|
|
|
|
|
if (productTable) {
|
|
|
|
|
const selectedProducts = productTable.selection || []
|
|
|
|
|
// 添加选中的商品
|
|
|
|
|
selectedProducts.forEach(product => {
|
|
|
|
|
this.selectedGoodsTemp.push({ ...product, demandId: demand.id })
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 确认选择需求
|
|
|
|
|
confirmSelectDemand () {
|
|
|
|
|
if (this.tempSelectedDemands.length === 0) {
|
|
|
|
|
this.$message.warning('请选择需求')
|
|
|
|
|
if (this.selectedGoodsTemp.length === 0) {
|
|
|
|
|
this.$message.warning('请选择商品')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// 将临时选择的需求添加到正式的selectedDemands中
|
|
|
|
|
this.selectedDemands = this.tempSelectedDemands
|
|
|
|
|
// 合并相同商品
|
|
|
|
|
this.selectedGoodsTemp.forEach(goods => {
|
|
|
|
|
this.addOrMergeGoods(goods)
|
|
|
|
|
})
|
|
|
|
|
// 确保折叠面板展开
|
|
|
|
|
this.activeNames = ['1']
|
|
|
|
|
this.demandDialogVisible = false
|
|
|
|
|
},
|
|
|
|
|
// 移除需求
|
|
|
|
|
removeDemand (id) {
|
|
|
|
|
this.selectedDemands = this.selectedDemands.filter(item => item.id !== id)
|
|
|
|
|
// 合并相同商品
|
|
|
|
|
addOrMergeGoods (goods) {
|
|
|
|
|
const key = `${goods.goodsName}-${goods.goodsCode}-${goods.spec}-${goods.unit}`
|
|
|
|
|
const existingIndex = this.selectedGoods.findIndex(item =>
|
|
|
|
|
`${item.goodsName}-${item.goodsCode}-${item.spec}-${item.unit}` === key
|
|
|
|
|
)
|
|
|
|
|
// 将需求数量转换为数字类型,如果没有demandQuantity属性,则默认为1
|
|
|
|
|
const demandQuantity = parseFloat(goods.demandQuantity) || 1
|
|
|
|
|
if (existingIndex > -1) {
|
|
|
|
|
// 确保planQuantity也是数字类型
|
|
|
|
|
this.selectedGoods[existingIndex].planQuantity = (parseFloat(this.selectedGoods[existingIndex].planQuantity) || 0) + demandQuantity
|
|
|
|
|
// 重新计算计划金额
|
|
|
|
|
this.calculatePlanAmount(this.selectedGoods[existingIndex])
|
|
|
|
|
} else {
|
|
|
|
|
// 新增商品,设置默认值
|
|
|
|
|
const newGoods = {
|
|
|
|
|
...goods,
|
|
|
|
|
planQuantity: demandQuantity,
|
|
|
|
|
planPrice: goods.costPrice || 0.00,
|
|
|
|
|
planAmount: (demandQuantity * (goods.costPrice || 0.00)).toFixed(2),
|
|
|
|
|
supplierName: goods.custName || ''
|
|
|
|
|
}
|
|
|
|
|
this.selectedGoods.push(newGoods)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 计算计划金额
|
|
|
|
|
calculatePlanAmount (row) {
|
|
|
|
|
const planQuantity = parseFloat(row.planQuantity) || 0
|
|
|
|
|
const planPrice = parseFloat(row.planPrice) || 0
|
|
|
|
|
row.planAmount = parseFloat((planQuantity * planPrice).toFixed(2))
|
|
|
|
|
},
|
|
|
|
|
// 移除商品
|
|
|
|
|
removeGoods (index) {
|
|
|
|
|
if (!this.isAddOperation && this.dataForm.status !== '1') {
|
|
|
|
|
this.$message.warning('只有新增或草稿状态的采购计划才能删除商品')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.selectedGoods.splice(index, 1)
|
|
|
|
|
},
|
|
|
|
|
// 验证计划采购数量
|
|
|
|
|
validatePlanQuantity (row) {
|
|
|
|
|
if (row.planQuantity === '' || row.planQuantity === null || row.planQuantity === undefined) {
|
|
|
|
|
// 空值不做处理,允许用户清空输入框
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (isNaN(row.planQuantity) || row.planQuantity <= 0) {
|
|
|
|
|
this.$message.error('计划采购数量必须大于0')
|
|
|
|
|
row.planQuantity = 0.01
|
|
|
|
|
} else {
|
|
|
|
|
// 最多保留2位小数
|
|
|
|
|
row.planQuantity = parseFloat(row.planQuantity.toFixed(2))
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 加载商品列表(用于批量添加商品)
|
|
|
|
|
loadGoodsList() {
|
|
|
|
|
cmcustproductApi.cmcustproductListApi({ page: 1, limit: 9999 }).then(res => {
|
|
|
|
|
this.goodsList = res.list || []
|
|
|
|
|
}).catch(e => {
|
|
|
|
|
console.error('获取商品列表失败', e)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 打开选择商品弹窗
|
|
|
|
|
openSelectGoodsModal() {
|
|
|
|
|
this.selectGoodsVisible = true
|
|
|
|
|
this.getGoodsList()
|
|
|
|
|
},
|
|
|
|
|
// 获取商品列表
|
|
|
|
|
getGoodsList() {
|
|
|
|
|
this.goodsLoading = true
|
|
|
|
|
cmcustproductApi.cmcustproductListApi({
|
|
|
|
|
page: this.goodsPage.page,
|
|
|
|
|
limit: this.goodsPage.limit,
|
|
|
|
|
goodsName: this.goodsSearchForm.goodsName,
|
|
|
|
|
spec: this.goodsSearchForm.spec
|
|
|
|
|
}).then(res => {
|
|
|
|
|
this.goodsList = res.list || []
|
|
|
|
|
this.goodsPage.total = res.total || 0
|
|
|
|
|
this.goodsLoading = false
|
|
|
|
|
}).catch(e => {
|
|
|
|
|
console.error('获取商品列表失败', e)
|
|
|
|
|
this.goodsLoading = false
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 重置商品搜索表单
|
|
|
|
|
resetGoodsSearchForm() {
|
|
|
|
|
this.goodsSearchForm = {
|
|
|
|
|
goodsName: '',
|
|
|
|
|
spec: ''
|
|
|
|
|
}
|
|
|
|
|
this.getGoodsList()
|
|
|
|
|
},
|
|
|
|
|
// 处理商品分页大小变化
|
|
|
|
|
handleGoodsSizeChange(val) {
|
|
|
|
|
this.goodsPage.limit = val
|
|
|
|
|
this.getGoodsList()
|
|
|
|
|
},
|
|
|
|
|
// 处理商品分页当前页变化
|
|
|
|
|
handleGoodsCurrentChange(val) {
|
|
|
|
|
this.goodsPage.page = val
|
|
|
|
|
this.getGoodsList()
|
|
|
|
|
},
|
|
|
|
|
// 处理商品选择变化
|
|
|
|
|
handleGoodsSelectionChange(selection) {
|
|
|
|
|
this.tempSelectedGoods = selection
|
|
|
|
|
},
|
|
|
|
|
// 确认选择商品
|
|
|
|
|
confirmSelectGoods() {
|
|
|
|
|
if (this.tempSelectedGoods.length === 0) {
|
|
|
|
|
this.$message.warning('请选择商品')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.tempSelectedGoods.forEach(goods => {
|
|
|
|
|
this.addOrMergeGoods(goods)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.selectGoodsVisible = false
|
|
|
|
|
this.tempSelectedGoods = []
|
|
|
|
|
},
|
|
|
|
|
// 打开批量添加商品弹窗
|
|
|
|
|
openBatchAddModal() {
|
|
|
|
|
this.batchAddVisible = true
|
|
|
|
|
},
|
|
|
|
|
// 确认批量添加商品
|
|
|
|
|
confirmBatchAdd() {
|
|
|
|
|
if (this.selectedGoodsForBatch.length === 0) {
|
|
|
|
|
this.$message.warning('请选择商品')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.selectedGoodsForBatch.forEach(id => {
|
|
|
|
|
const selectedGoods = this.goodsList.find(goods => goods.id === id)
|
|
|
|
|
if (selectedGoods) {
|
|
|
|
|
this.addOrMergeGoods(selectedGoods)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.batchAddVisible = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|