修改计划、订单相关功能
main
zxf 3 months ago
parent 36515c326e
commit 1ab21365e8

@ -36,6 +36,18 @@ export function pmdailymenuDetailApi(id) {
})
}
/**
* 获取当天菜单详情用于修改页面
* @param params
*/
export function pmdailymenuDayDetailApi(params) {
return request({
url: `autogencode/pmdailymenu/listByAll`,
method: 'GET',
params
})
}
/**
* pmdailymenu批量删除
* @param ids
@ -60,6 +72,52 @@ export function pmdailymenuBatchCreateApi(menus) {
})
}
/**
* pmdailymenu批量更新
* @param menus
*/
export function pmdailymenuBatchUpdateApi(menus) {
return request({
url: `autogencode/pmdailymenu/batchUpdate`,
method: 'POST',
data: menus
})
}
/**
* pmdailymenu发布
* @param id
*/
export function pmdailymenuPublishApi(id) {
return request({
url: `autogencode/pmdailymenu/publish/${id}`,
method: 'POST'
})
}
/**
* pmdailymenu撤销发布
* @param id
*/
export function pmdailymenuCancelPublishApi(id) {
return request({
url: `autogencode/pmdailymenu/cancelPublish/${id}`,
method: 'POST'
})
}
/**
* pmdailymenu复制
* @param params
*/
export function pmdailymenuCopyApi(params) {
return request({
url: `autogencode/pmdailymenu/copy`,
method: 'POST',
data: params
})
}
/**
* pmdailymenu列表

@ -202,28 +202,31 @@
header-align="center"
align="center"
label="单位"
width="80">
>
<template slot-scope="scope">
<DictTag :options="dict.type.sys_measurement_unit" :value="scope.row.unit" />
</template>
</el-table-column>
<el-table-column
prop="orderQuantity"
header-align="center"
align="center"
label="订单数量"
width="100">
>
</el-table-column>
<el-table-column
prop="orderPrice"
header-align="center"
align="center"
label="订单单价"
width="100">
>
</el-table-column>
<el-table-column
prop="orderAmount"
header-align="center"
align="center"
label="订单金额"
width="120">
>
</el-table-column>
</el-table>
</div>
@ -239,7 +242,7 @@
<el-table-column label="预计配送日期" prop="deliveryDate" ></el-table-column>
<el-table-column label="订单状态" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.order_status" :value="scope.row.status"/>
<dict-tag :options="dict.type.pm_order_status" :value="scope.row.status"/>
</template>
</el-table-column>
</el-table>
@ -286,7 +289,7 @@ export default {
props: {
},
dicts: ['bm_measuring_unit', 'sys_origin_country', 'sys_curr_type', 'order_status'],
dicts: ['bm_measuring_unit', 'sys_measurement_unit', 'sys_origin_country', 'sys_curr_type', 'pm_order_status'],
computed: {
//
tableReadonly() {
@ -901,7 +904,12 @@ export default {
//
getOrderList() {
this.orderLoading = true
pmcanteenpurchaseorderListApi(this.orderSearchForm).then(res => {
const params = {
...this.orderSearchForm,
status: 1 // 1
}
pmcanteenpurchaseorderListApi(params).then(res => {
this.orderList = res.list
this.orderTotal = res.total
this.orderLoading = false
@ -915,7 +923,8 @@ export default {
page: 1,
limit: 10,
orderNo: '',
supplierName: ''
supplierName: '',
status: 1 // 1
}
this.getOrderList()
},

@ -9,7 +9,11 @@
<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="单位"></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="demandQuantity" header-align="center" align="center" label="需求采购数量"></el-table-column>
<el-table-column prop="remark" header-align="center" align="center" label="备注" show-overflow-tooltip></el-table-column>
<el-table-column v-if="status === '0' || status === '2'" header-align="center" align="center" width="100" label="操作">
@ -34,7 +38,12 @@
<script>
import * as detailApi from '@/api/pmcanteendemanddetail.js'
import DictTag from '@/components/DictTag'
export default {
dicts: ['sys_measurement_unit'],
components: {
DictTag
},
props: {
orderId: {
type: [Number, String],

@ -37,7 +37,7 @@
<el-input v-model="dataForm.remark" type="textarea" placeholder="备注" rows="4"></el-input>
</el-form-item>
</el-form>
<!-- 商品明细部分 -->
<div style="margin-top: 20px;">
<el-card>
@ -57,7 +57,11 @@
<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="单位"></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="demandQuantity" header-align="center" align="center" label="需求采购数量">
<template slot-scope="scope">
<el-input-number v-model="scope.row.demandQuantity" placeholder="数量" :min="1" style="width: 100%"></el-input-number>
@ -76,7 +80,7 @@
</el-table>
</el-card>
</div>
<!-- 批量添加商品弹窗 -->
<el-dialog
title="批量添加商品"
@ -101,7 +105,7 @@
</el-select>
<el-button type="primary" @click="confirmBatchAdd"></el-button>
</el-dialog>
<!-- 单个添加商品弹窗 -->
<el-dialog
title="添加商品"
@ -141,7 +145,7 @@
<el-button type="primary" @click="confirmSingleAdd"></el-button>
</span>
</el-dialog>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<template v-if="!dataForm.id || dataForm.status === '0' || dataForm.status === '2'">
@ -160,8 +164,12 @@
import * as api from '@/api/pmcanteendemand.js'
import * as ebuserApi from '@/api/ebuser.js'
import * as cmcustproductApi from '@/api/cmcustproduct.js'
import DictTag from '@/components/DictTag'
export default {
dicts: ['owner_type', 'demand_status'],
dicts: ['owner_type', 'demand_status', 'sys_measurement_unit'],
components: {
DictTag
},
data () {
return {
visible: false,
@ -247,7 +255,7 @@
this.$message.warning('请选择商品')
return
}
this.selectedGoods.forEach(id => {
const selectedGoods = this.goodsList.find(goods => goods.id === id)
const existingProduct = this.productList.find(p => p.goodsName === selectedGoods.goodsName && p.goodsCode === selectedGoods.goodsCode)
@ -262,7 +270,7 @@
})
}
})
this.batchAddVisible = false
},
addSingleProduct() {
@ -324,13 +332,13 @@
this.$message.warning('请添加商品明细')
return
}
const submitData = {
...this.dataForm,
status: status || this.dataForm.status,
pmCanteenDemandDetails: this.productList
}
if (this.dataForm.id) {
api.pmcanteendemandBatchUpdateApi([submitData]).then(function(res) {
this.$message.success('保存成功')
@ -378,7 +386,7 @@
this.dataSubmit('3');
})
},
}
}
</script>

@ -56,19 +56,38 @@
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="计划采购数量" prop="planQuantity">
<el-input-number v-model="dataForm.planQuantity" placeholder="计划采购数量" style="width: 100%"></el-input-number>
<el-input-number
v-model="dataForm.planQuantity"
placeholder="计划采购数量"
style="width: 100%"
:disabled="planStatus !== '1'"
@change="calculatePlanAmount"
></el-input-number>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="计划单价" prop="planPrice">
<el-input-number v-model="dataForm.planPrice" placeholder="计划单价" style="width: 100%" :precision="2"></el-input-number>
<el-input-number
v-model="dataForm.planPrice"
placeholder="计划单价"
style="width: 100%"
:precision="2"
:disabled="planStatus !== '1'"
@change="calculatePlanAmount"
></el-input-number>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="计划金额" prop="planAmount">
<el-input-number v-model="dataForm.planAmount" placeholder="计划金额" style="width: 100%" :precision="2"></el-input-number>
<el-input-number
v-model="dataForm.planAmount"
placeholder="计划金额"
style="width: 100%"
:precision="2"
disabled
></el-input-number>
</el-form-item>
</el-col>
<el-col :span="12">
@ -108,15 +127,21 @@
import * as api from '@/api/pmcanteenpurchasedetail.js'
import * as cmcustproductApi from '@/api/cmcustproduct.js'
export default {
props: {
planStatus: {
type: String,
default: '1' // 稿
}
},
data () {
return {
visible: false,
goodsList: [],
dataForm: {
id: 0,
planId: '' ,
goodsId: '' ,
custId: '' ,
planId: 0 ,
goodsId: 0 ,
custId: 0 ,
custName: '' ,
goodsName: '' ,
goodsCode: '' ,
@ -201,13 +226,21 @@
if (this.dataForm.id) {
api.pmcanteenpurchasedetailDetailApi(id).then(function(res) {
this.dataForm = res;
this.calculatePlanAmount();
}.bind(this))
} else if (planId) {
// planId
this.dataForm.planId = planId;
this.calculatePlanAmount();
}
}.bind(this))
},
//
calculatePlanAmount () {
const planQuantity = parseFloat(this.dataForm.planQuantity) || 0
const planPrice = parseFloat(this.dataForm.planPrice) || 0
this.dataForm.planAmount = parseFloat((planQuantity * planPrice).toFixed(2))
},
//
dataSubmit () {
this.$refs['dataForm'].validate((valid) => {

@ -0,0 +1,248 @@
<template>
<div>
<div style="margin-bottom: 10px;">
<el-button type="primary" size="small" @click="addDetail"></el-button>
</div>
<el-table
:data="dataList"
border
v-loading="dataListLoading"
:row-key="'id'"
style="width: 100%;">
<el-table-column prop="planNo" header-align="center" align="center" label="计划编号"></el-table-column>
<el-table-column prop="goodsName" 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="orderQuantity" header-align="center" align="center" label="订单数量" style="width: 100px">
<template slot-scope="scope">
<template v-if="editingRow === scope.row.id">
<el-input
v-model.number="editForm.orderQuantity"
type="number"
step="0.01"
min="0.01"
@input="calculateOrderAmount"
/>
</template>
<template v-else>
{{ scope.row.orderQuantity }}
</template>
</template>
</el-table-column>
<el-table-column prop="orderPrice" header-align="center" align="center" label="订单单价" style="width: 100px" >
<template slot-scope="scope">
<template v-if="editingRow === scope.row.id">
<el-input
v-model.number="editForm.orderPrice"
type="number"
step="0.01"
min="0"
@input="calculateOrderAmount"
/>
</template>
<template v-else>
{{ scope.row.orderPrice }}
</template>
</template>
</el-table-column>
<el-table-column prop="orderAmount" header-align="center" align="center" label="订单金额">
<template slot-scope="scope">
<template v-if="editingRow === scope.row.id">
{{ Number(editForm.orderAmount || 0).toFixed(2) }}
</template>
<template v-else>
{{ Number(scope.row.orderAmount || 0).toFixed(2) }}
</template>
</template>
</el-table-column>
<el-table-column prop="remark" header-align="center" align="center" label="备注">
<template slot-scope="scope">
<template v-if="editingRow === scope.row.id">
<el-input v-model="editForm.remark" type="text" />
</template>
<template v-else>
{{ scope.row.remark }}
</template>
</template>
</el-table-column>
<el-table-column header-align="center" fixed="right" align="center" width="150" label="操作">
<template slot-scope="scope">
<template v-if="editingRow === scope.row.id">
<el-button type="text" size="small" @click="saveDetail(scope.row)"></el-button>
<el-button type="text" size="small" @click="cancelEdit"></el-button>
</template>
<template v-else>
<el-button type="text" size="small" @click="editDetail(scope.row)" :disabled="orderStatus != '0'">修改</el-button>
<el-button type="text" size="small" @click="deleteDetail(scope.row.id, scope.$index)" style="color: #f56c6c;" :disabled="orderStatus != '0'">删除</el-button>
</template>
</template>
</el-table-column>
</el-table>
<el-pagination
v-if="showSearch"
hide-on-single-page
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
</div>
</template>
<script>
import * as detailApi from '@/api/pmcanteenplanorderrel.js'
import * as orderApi from '@/api/pmcanteenpurchaseorder.js'
import DictTag from '@/components/DictTag'
export default {
dicts: ['sys_measurement_unit'],
components: {
DictTag
},
props: {
orderId: {
type: [Number, String],
required: true
},
orderStatus: {
type: String,
default: '0'
},
showSearch: {
type: Boolean,
default: true
}
},
data() {
return {
dataList: [],
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false,
editingRow: null, // ID
//
editForm: {
orderQuantity: 0,
orderPrice: 0,
orderAmount: 0,
remark: ''
}
}
},
watch: {
// ID
orderId(newVal) {
this.getDataList()
}
},
mounted() {
this.getDataList()
},
methods: {
//
addDetail() {
// addDetail
this.$emit('addDetail', this.orderId)
},
//
editDetail(row) {
this.editingRow = row.id
// editForm
this.editForm = {
orderQuantity: parseFloat(row.orderQuantity) || 0,
orderPrice: parseFloat(row.orderPrice) || 0,
orderAmount: parseFloat(row.orderAmount) || 0,
remark: row.remark || ''
}
console.log('开始编辑,表单数据:', this.editForm)
},
//
saveDetail(row) {
//
const saveData = {
id: row.id,
goodsId: row.goodsId,
orderQuantity: this.editForm.orderQuantity,
orderPrice: this.editForm.orderPrice,
orderAmount: this.editForm.orderAmount,
remark: this.editForm.remark
}
// API
detailApi.pmcanteenplanorderrelUpdateApi(saveData).then(() => {
this.$message.success('保存成功')
this.editingRow = null
this.getDataList()
}).catch(() => {
this.$message.error('保存失败')
})
},
//
cancelEdit() {
this.editingRow = null
},
//
deleteDetail(id, index) {
this.$confirm('确定要删除这条订单明细记录吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
detailApi.pmcanteenplanorderrelDeleteApi([id]).then(() => {
this.$message.success('删除成功')
this.getDataList()
}).catch(() => {
this.$message.error('删除失败')
})
}).catch(() => {})
},
//
getDataList() {
this.dataListLoading = true
// API
detailApi.pmcanteenplanorderrelListApi({ orderId: this.orderId }).then(res => {
this.dataListLoading = false
if (res && res.list) {
this.dataList = res.list || []
this.totalPage = this.dataList.length
} else {
this.dataList = []
this.totalPage = 0
}
}).catch(() => {
this.dataListLoading = false
this.dataList = []
this.totalPage = 0
})
},
//
sizeChangeHandle(val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
//
currentChangeHandle(val) {
this.pageIndex = val
this.getDataList()
},
//
calculateOrderAmount() {
this.editForm.orderAmount = (this.editForm.orderQuantity || 0) * (this.editForm.orderPrice || 0)
}
}
}
</script>
<style lang="scss" scoped>
</style>

@ -37,7 +37,19 @@
border
v-loading="dataListLoading"
@selection-change="selectionChangeHandle"
@expand-change="handleExpandChange"
:row-key="row => row.id"
style="width: 100%;">
<el-table-column type="expand">
<template slot-scope="scope">
<OrderDetailList
:order-id="scope.row.id"
:order-status="scope.row.status"
@addDetail="addOrderDetail"
@editDetail="editOrderDetail"
/>
</template>
</el-table-column>
<el-table-column
type="selection"
header-align="center"
@ -117,6 +129,7 @@
<script>
import AddOrUpdate from './pmcanteenpurchaseorder-add-and-update'
import OrderDetailList from './OrderDetailList'
import * as api from '@/api/pmcanteenpurchaseorder.js'
export default {
dicts: ['pm_order_status'],
@ -143,7 +156,8 @@
}
},
components: {
AddOrUpdate
AddOrUpdate,
OrderDetailList
},
activated () {
this.getDataList()
@ -293,6 +307,21 @@
})
})
},
//
handleExpandChange(row, expandedRows) {
// OrderDetailList
},
//
addOrderDetail(orderId) {
// ID
this.addOrUpdateHandle(orderId)
},
//
editOrderDetail(orderId, detailId) {
// IDID
console.log('编辑明细:', orderId, detailId)
},
}
}
</script>

@ -4,6 +4,7 @@
<el-dialog
:title="!dataForm.id ? '添加' : '修改'"
:close-on-click-modal="false"
width="1200px"
:visible.sync="visible">
<!-- 新增和修改表单 -->
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataSubmit()" label-width="120px">
@ -37,6 +38,7 @@
value-format="yyyy-MM-dd"
placeholder="选择日期"
style="width: 100%"
:disabled="isOrderConfirmed"
/>
</el-form-item>
</el-col>
@ -52,12 +54,29 @@
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="订单状态" prop="status">
<el-select v-model="dataForm.status" placeholder="请选择订单状态" style="width: 100%" disabled>
<el-option
v-for="dict in dict.type.pm_order_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="备注" prop="remark">
<el-input v-model="dataForm.remark" placeholder="备注" type="textarea"></el-input>
</el-form-item>
</el-form>
<!-- 选择计划明细按钮 -->
<el-button type="primary" @click="openSelectPlanModal()" style="margin-bottom: 20px">选择计划明细</el-button>
<el-button type="primary" @click="openSelectPlanModal()" style="margin-bottom: 20px; margin-right: 10px" :disabled="isOrderConfirmed">选择计划明细</el-button>
<el-button type="success" @click="openSelectGoodsModal()" style="margin-bottom: 20px; margin-right: 10px" :disabled="isOrderConfirmed">选择商品</el-button>
<!-- 已关联计划明细表格 -->
<el-collapse v-model="activeNames">
@ -102,31 +121,69 @@
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="orderQuantity"
header-align="center"
align="center"
label="订单数量">
<template slot-scope="scope">
<el-input-number
style="width: 100%"
controls-position="right"
v-model.number="scope.row.orderQuantity"
:min="0"
:precision="2"
placeholder="输入订单数量"
@change="updateOrderAmount(scope.row)"
:disabled="isOrderConfirmed"
/>
</template>
</el-table-column>
<el-table-column
prop="orderPrice"
header-align="center"
align="center"
label="订单单价">
<template slot-scope="scope">
<el-input-number
style="width: 100%"
controls-position="right"
v-model.number="scope.row.orderPrice"
:min="0"
:precision="2"
placeholder="输入订单单价"
@change="updateOrderAmount(scope.row)"
:disabled="isOrderConfirmed"
/>
</template>
</el-table-column>
<el-table-column
prop="orderAmount"
header-align="center"
align="center"
label="订单金额">
<template slot-scope="scope">
<el-input-number
style="width: 100%"
controls-position="right"
v-model.number="scope.row.orderAmount"
:min="0"
:precision="2"
placeholder="订单金额"
:disabled="true"
/>
</template>
</el-table-column>
<el-table-column
header-align="center"
align="center"
label="操作">
<template slot-scope="scope">
<el-button type="text" size="small" @click="deletePlanDetail(scope.$index)" style="color: #f56c6c;">删除关联</el-button>
<el-button type="text" size="small" @click="deletePlanDetail(scope.$index)" style="color: #f56c6c;" :disabled="isOrderConfirmed">删除关联</el-button>
</template>
</el-table-column>
</el-table>
@ -142,8 +199,8 @@
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="dataSubmit()"></el-button>
<el-button type="success" @click="orderConfirm()"></el-button>
<el-button type="primary" @click="dataSubmit()" :disabled="isOrderConfirmed">保存</el-button>
<el-button type="success" @click="orderConfirm()" :disabled="isOrderConfirmed">订单确认</el-button>
</span>
</el-dialog>
@ -222,6 +279,9 @@
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="planQuantity"
@ -241,57 +301,149 @@
align="center"
label="计划金额">
</el-table-column>
<el-table-column
header-align="center"
align="center"
label="订单数量">
label="关联状态">
<template slot-scope="scope">
<el-input-number style="width: 100%" controls-position="right" v-model.number="scope.row.orderQuantity" :min="0" :precision="2" placeholder="输入订单数量" />
<el-tag v-if="isPlanDetailAssociated(scope.row.id)" type="success"></el-tag>
<el-tag v-else type="info">未关联</el-tag>
</template>
</el-table-column>
</el-table>
<!-- 分页控件 -->
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<span slot="footer" class="dialog-footer">
<el-button @click="selectPlanVisible = false">取消</el-button>
<el-button type="primary" @click="confirm"></el-button>
</span>
</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
type="selection"
header-align="center"
align="center"
width="50">
</el-table-column>
<el-table-column
prop="goodsName"
header-align="center"
align="center"
label="订单单价">
<template slot-scope="scope">
<el-input-number style="width: 100%" controls-position="right" v-model.number="scope.row.orderPrice" :min="0" :precision="2" placeholder="输入订单单价" />
</template>
label="商品名称">
</el-table-column>
<el-table-column
prop="goodsCode"
header-align="center"
align="center"
label="订单金额">
<template slot-scope="scope">
<el-input-number style="width: 100%" controls-position="right" v-model.number="scope.row.orderAmount" :min="0" :precision="2" placeholder="输入订单金额" />
</template>
label="商品编码">
</el-table-column>
<el-table-column
prop="spec"
header-align="center"
align="center"
label="关联状态">
label="规格">
</el-table-column>
<el-table-column
prop="unit"
header-align="center"
align="center"
label="单位">
<template slot-scope="scope">
<el-tag v-if="isPlanDetailAssociated(scope.row.id)" type="success"></el-tag>
<el-tag v-else type="info">未关联</el-tag>
<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>
<!-- 分页控件 -->
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
@size-change="handleGoodsSizeChange"
@current-change="handleGoodsCurrentChange"
:current-page="goodsPage.page"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
: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="selectPlanVisible = false">取消</el-button>
<el-button type="primary" @click="confirm"></el-button>
<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>
@ -299,7 +451,10 @@
import * as api from '@/api/pmcanteenpurchaseorder.js'
import * as detailApi from '@/api/pmcanteenpurchasedetail.js'
import { cmcustListByAll as listCust } from "@/api/cmcust"
import * as cmcustproductApi from '@/api/cmcustproduct.js'
import DictTag from '@/components/DictTag'
export default {
dicts: ['sys_measurement_unit', 'pm_order_status'],
data () {
return {
visible: false,
@ -311,7 +466,7 @@
orderDate: '' ,
deliveryDate: '' ,
totalAmount: 0 ,
status: 0 ,
status: '0' ,
remark: '' ,
},
dataRule: {
@ -344,7 +499,24 @@
pageIndex: 1,
pageSize: 10,
totalPage: 0,
selectedPlanDetails: [] //
selectedPlanDetails: [], //
//
selectGoodsVisible: false, //
goodsList: [], //
tempSelectedGoods: [], //
goodsSearchForm: {
goodsName: '',
spec: ''
},
goodsPage: {
page: 1,
limit: 10,
total: 0
},
goodsLoading: false,
//
batchAddVisible: false,
selectedGoodsForBatch: []
}
},
watch: {
@ -362,8 +534,23 @@
},
mounted() {
this.getSuppliers()
this.loadGoodsList()
},
computed: {
//
isOrderConfirmed() {
return this.dataForm.status === '1'
}
},
methods: {
//
loadGoodsList() {
cmcustproductApi.cmcustproductListApi({ page: 1, limit: 9999 }).then(res => {
this.goodsList = res.list || []
}).catch(e => {
console.error('获取商品列表失败', e)
})
},
getSuppliers() {
//
listCust({custBelong:1}).then(response => {
@ -372,6 +559,122 @@
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()
},
//
handleGoodsSelectionChange(selection) {
this.tempSelectedGoods = selection
},
//
handleGoodsSizeChange(size) {
this.goodsPage.limit = size
this.getGoodsList()
},
//
handleGoodsCurrentChange(current) {
this.goodsPage.page = current
this.getGoodsList()
},
//
confirmSelectGoods() {
if (this.tempSelectedGoods.length === 0) {
this.$message.warning('请选择商品')
return
}
//
this.tempSelectedGoods.forEach(goods => {
const newDetail = {
id: 0,
orderId: this.dataForm.id,
goodsId: goods.id,
goodsName: goods.goodsName,
goodsCode: goods.goodsCode,
spec: goods.spec,
unit: goods.unit,
supplierName: goods.custName || '',
orderQuantity: 1,
orderPrice: goods.costPrice || 0,
orderAmount: goods.costPrice || 0
}
this.planDetails.push(newDetail)
})
//
this.calculateTotalAmount()
//
this.selectGoodsVisible = false
this.tempSelectedGoods = []
},
//
openBatchAddModal() {
this.selectedGoodsForBatch = []
this.batchAddVisible = true
this.getGoodsList()
},
//
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) {
const existingDetail = this.planDetails.find(detail => detail.goodsName === selectedGoods.goodsName && detail.spec === selectedGoods.spec)
if (!existingDetail) {
this.planDetails.push({
id: 0,
orderId: this.dataForm.id,
goodsId: selectedGoods.id,
goodsName: selectedGoods.goodsName,
goodsCode: selectedGoods.goodsCode,
spec: selectedGoods.spec,
unit: selectedGoods.unit,
supplierName: selectedGoods.custName || '',
orderQuantity: 1,
orderPrice: selectedGoods.costPrice || 0,
orderAmount: selectedGoods.costPrice || 0
})
}
}
})
//
this.calculateTotalAmount()
this.batchAddVisible = false
},
init (id) { //
this.dataForm.id = id || 0
this.visible = true
@ -409,9 +712,16 @@
},
calculateTotalAmount() {
this.dataForm.totalAmount = this.planDetails.reduce((total, item) => {
return total + item.orderAmount
return total + (parseFloat(item.orderAmount) || 0)
}, 0)
},
//
updateOrderAmount(row) {
const orderQuantity = parseFloat(row.orderQuantity) || 0
const orderPrice = parseFloat(row.orderPrice) || 0
row.orderAmount = parseFloat((orderQuantity * orderPrice).toFixed(2))
this.calculateTotalAmount()
},
//
isPlanDetailAssociated(detailId) {
return this.planDetails.some(detail => detail.id === detailId)
@ -496,9 +806,9 @@
const exists = this.planDetails.some(detail => detail.id === item.id)
if (!exists) {
//
const orderQuantity = parseFloat(item.orderQuantity) || 0
const orderPrice = parseFloat(item.orderPrice) || parseFloat(item.planPrice) || 0
const orderAmount = parseFloat(item.orderAmount) || (orderQuantity * orderPrice)
const orderQuantity = parseFloat(item.planQuantity) || 0
const orderPrice = parseFloat(item.orderPrice) || parseFloat(item.planPrice) || 0
const orderAmount = parseFloat(item.orderAmount) || (orderQuantity * orderPrice)
const newDetail = {
id: item.id,
@ -506,6 +816,7 @@
planNo: item.planNo,
supplierId: item.custId,
supplierName: item.custName,
goodsId: item.goodsId,
goodsName: item.goodsName,
spec: item.spec,
unit: item.unit,

@ -14,18 +14,68 @@
<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="单位"></el-table-column>
<el-table-column prop="planQuantity" header-align="center" align="center" label="计划采购数量"></el-table-column>
<el-table-column prop="planPrice" header-align="center" align="center" label="计划单价"></el-table-column>
<el-table-column prop="planAmount" 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="planQuantity" header-align="center" align="center" label="计划采购数量" style="width: 100px">
<template slot-scope="scope">
<template v-if="editingRow === scope.row.id">
<el-input v-model.number="editForm.planQuantity" type="number" step="0.01" min="0.01"
@input="calculatePlanAmount(editForm)"
/>
</template>
<template v-else>
{{ scope.row.planQuantity }}
</template>
</template>
</el-table-column>
<el-table-column prop="planPrice" header-align="center" align="center" label="计划单价" style="width: 100px" >
<template slot-scope="scope">
<template v-if="editingRow === scope.row.id">
<el-input v-model.number="editForm.planPrice" type="number" step="0.01" min="0"
@input="calculatePlanAmount(editForm)"
/>
</template>
<template v-else>
{{ scope.row.planPrice }}
</template>
</template>
</el-table-column>
<el-table-column prop="planAmount" header-align="center" align="center" label="计划金额">
<template slot-scope="scope">
<template v-if="editingRow === scope.row.id">
{{ Number(editForm.planAmount || 0).toFixed(2) }}
</template>
<template v-else>
{{ Number(scope.row.planAmount || 0).toFixed(2) }}
</template>
</template>
</el-table-column>
<el-table-column prop="actualQuantity" header-align="center" align="center" label="实际采购数量"></el-table-column>
<el-table-column prop="actualPrice" header-align="center" align="center" label="实际单价"></el-table-column>
<el-table-column prop="actualAmount" header-align="center" align="center" label="实际金额"></el-table-column>
<el-table-column prop="remark" header-align="center" align="center" label="备注" show-overflow-tooltip></el-table-column>
<el-table-column prop="remark" header-align="center" align="center" label="备注">
<template slot-scope="scope">
<template v-if="editingRow === scope.row.id">
<el-input v-model="editForm.remark" type="text" />
</template>
<template v-else>
{{ scope.row.remark }}
</template>
</template>
</el-table-column>
<el-table-column header-align="center" fixed="right" align="center" width="150" label="操作">
<template slot-scope="scope">
<el-button type="text" size="small" @click="editDetail(scope.row.id)">{{ '' }}</el-button>
<el-button type="text" size="small" @click="deleteDetail(scope.row.id, scope.$index)" style="color: #f56c6c;">删除</el-button>
<template v-if="editingRow === scope.row.id">
<el-button type="text" size="small" @click="saveDetail(scope.row.id)"></el-button>
<el-button type="text" size="small" @click="cancelEdit"></el-button>
</template>
<template v-else>
<el-button type="text" size="small" @click="editDetail(scope.row)" :disabled="planStatus !== '1'">{{ '修改' }}</el-button>
<el-button type="text" size="small" @click="deleteDetail(scope.row.id, scope.$index)" style="color: #f56c6c;" :disabled="planStatus !== '1'">{{ '删除' }}</el-button>
</template>
</template>
</el-table-column>
</el-table>
@ -43,6 +93,7 @@
<!-- 采购详情弹窗 -->
<DetailAddOrUpdate
ref="detailAddOrUpdate"
:plan-status="planStatus"
@refreshDataList="getDataList"
></DetailAddOrUpdate>
</div>
@ -51,9 +102,12 @@
<script>
import * as detailApi from '@/api/pmcanteenpurchasedetail.js'
import DetailAddOrUpdate from '../detail/pmcanteenpurchasedetail-add-and-update.vue'
import DictTag from '@/components/DictTag'
export default {
dicts: ['sys_measurement_unit'],
components: {
DetailAddOrUpdate
DetailAddOrUpdate,
DictTag
},
props: {
orderId: {
@ -63,6 +117,10 @@ export default {
showSearch: {
type: Boolean,
default: true
},
planStatus: {
type: String,
default: '1' // 稿
}
},
data() {
@ -87,7 +145,14 @@ export default {
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false
dataListLoading: false,
editingRow: null, // ID
editForm: { //
planQuantity: '',
planPrice: '',
planAmount: '',
remark: ''
}
}
},
watch: {
@ -109,11 +174,47 @@ export default {
}
},
//
editDetail(id) {
editDetail(row) {
// editDetail
this.$emit('editDetail', this.orderId, id)
if (this.$refs.detailAddOrUpdate) {
this.$refs.detailAddOrUpdate.init(id, this.orderId)
this.$emit('editDetail', this.orderId, row.id)
//
this.editingRow = row.id
//
this.editForm = {
planQuantity: row.planQuantity,
planPrice: row.planPrice,
planAmount: row.planAmount,
remark: row.remark
}
},
//
saveDetail(id) {
//
const saveData = {
id: id,
planQuantity: this.editForm.planQuantity,
planPrice: this.editForm.planPrice,
planAmount: this.editForm.planAmount,
remark: this.editForm.remark
}
// API
detailApi.pmcanteenpurchasedetailUpdateApi(saveData).then(() => {
this.$message.success('保存成功')
this.editingRow = null
this.getDataList()
}).catch(() => {
this.$message.error('保存失败')
})
},
//
cancelEdit() {
this.editingRow = null
this.editForm = {
planQuantity: '',
planPrice: '',
planAmount: '',
remark: ''
}
},
//
@ -197,6 +298,10 @@ export default {
currentChangeHandle(val) {
this.pageIndex = val
this.getDataList()
},
//
calculatePlanAmount(row) {
row.planAmount = (row.planQuantity || 0) * (row.planPrice || 0)
}
}
}

@ -63,6 +63,7 @@
<template slot-scope="scope">
<DispatchList
:orderId="scope.row.id"
:plan-status="scope.row.status"
@addDetail="addDetail"
@editDetail="editDetail"
/>
@ -249,7 +250,7 @@
import * as demandApi from '@/api/pmcanteendemand.js'
import DictTag from '@/components/DictTag'
export default {
dicts: ['plan_status', 'demand_status'],
dicts: ['plan_status', 'demand_status', 'sys_measurement_unit'],
data () {
return {
dataForm: {

@ -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 //
// pmCanteenPurchaseDetailsselectedGoods
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) {
// IDAPI
@ -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 || []
// 使listpmCanteenDemandDetails
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
)
// demandQuantity1
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
}
}
}

@ -10,18 +10,63 @@
:row-key="'id'"
style="width: 100%;">
<el-table-column prop="itemName" header-align="center" align="center" label="菜品名称"></el-table-column>
<el-table-column prop="itemName" header-align="center" align="center" label="菜品名称">
<template slot-scope="scope">
<template v-if="editingRow === scope.row.id">
<el-input v-model="editForm.itemName" size="small"></el-input>
</template>
<template v-else>
{{ scope.row.itemName }}
</template>
</template>
</el-table-column>
<el-table-column header-align="center" align="center" label="菜品类型">
<template slot-scope="scope">
<dict-tag :options="dict.type.item_type" :value="scope.row.itemType" />
<template v-if="editingRow === scope.row.id">
<el-select v-model="editForm.itemType" size="small" style="width: 100%">
<el-option
v-for="dict in dict.type.item_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</template>
<template v-else>
<dict-tag :options="dict.type.item_type" :value="scope.row.itemType" />
</template>
</template>
</el-table-column>
<el-table-column prop="itemPrice" header-align="center" align="center" label="菜品价格">
<template slot-scope="scope">
<template v-if="editingRow === scope.row.id">
<el-input-number v-model="editForm.itemPrice" size="small" :min="0" :step="0.01" :precision="2"></el-input-number>
</template>
<template v-else>
{{ scope.row.itemPrice }}
</template>
</template>
</el-table-column>
<el-table-column prop="remark" header-align="center" align="center" label="备注" show-overflow-tooltip>
<template slot-scope="scope">
<template v-if="editingRow === scope.row.id">
<el-input v-model="editForm.remark" size="small" type="textarea"></el-input>
</template>
<template v-else>
{{ scope.row.remark }}
</template>
</template>
</el-table-column>
<el-table-column prop="itemPrice" header-align="center" align="center" label="菜品价格"></el-table-column>
<el-table-column prop="remark" header-align="center" align="center" label="备注" show-overflow-tooltip></el-table-column>
<el-table-column header-align="center" align="center" width="150" label="操作" fixed="right">
<template slot-scope="scope">
<el-button type="text" size="small" @click="editDetail(scope.row.id)">{{ '' }}</el-button>
<el-button type="text" size="small" @click="deleteDetail(scope.row.id, scope.$index)" style="color: #f56c6c;">删除</el-button>
<template v-if="editingRow === scope.row.id">
<el-button type="text" size="small" @click="saveDetail(scope.row.id)"></el-button>
<el-button type="text" size="small" @click="cancelEdit"></el-button>
</template>
<template v-else>
<el-button type="text" size="small" @click="editDetail(scope.row)">{{ '' }}</el-button>
<el-button type="text" size="small" @click="deleteDetail(scope.row.id, scope.$index)" style="color: #f56c6c;">删除</el-button>
</template>
</template>
</el-table-column>
</el-table>
@ -36,22 +81,15 @@
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<!-- 明细弹窗 -->
<AddOrUpdate
ref="addOrUpdate"
@refreshDataList="getDataList"
></AddOrUpdate>
</div>
</template>
<script>
import DictTag from '@/components/DictTag'
import * as detailApi from '@/api/pmdailymenudtl.js'
import AddOrUpdate from './dtl/pmdailymenudtl-add-and-update.vue'
export default {
components: {
DictTag,
AddOrUpdate
DictTag
},
dicts: ['item_type'],
props: {
@ -77,7 +115,14 @@ export default {
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false
dataListLoading: false,
editingRow: null, // ID
editForm: { //
itemName: '',
itemType: '',
itemPrice: '',
remark: ''
}
}
},
watch: {
@ -94,16 +139,49 @@ export default {
addDetail() {
// addDetail
this.$emit('addDetail', this.menuId)
if (this.$refs.addOrUpdate) {
this.$refs.addOrUpdate.init(0, this.menuId)
}
},
//
editDetail(id) {
editDetail(row) {
// editDetail
this.$emit('editDetail', this.menuId, id)
if (this.$refs.addOrUpdate) {
this.$refs.addOrUpdate.init(id, this.menuId)
this.$emit('editDetail', this.menuId, row.id)
//
this.editingRow = row.id
//
this.editForm = {
itemName: row.itemName,
itemType: row.itemType,
itemPrice: row.itemPrice,
remark: row.remark
}
},
//
saveDetail(id) {
//
const saveData = {
id: id,
itemName: this.editForm.itemName,
itemType: this.editForm.itemType,
itemPrice: this.editForm.itemPrice,
remark: this.editForm.remark
}
// API
detailApi.pmdailymenudtlUpdateApi(saveData).then(() => {
this.$message.success('保存成功')
this.editingRow = null
this.getDataList()
}).catch(() => {
this.$message.error('保存失败')
})
},
//
cancelEdit() {
this.editingRow = null
this.editForm = {
itemName: '',
itemType: '',
itemPrice: '',
remark: ''
}
},
//

@ -5,7 +5,14 @@
<el-input v-model="dataForm.menuDate" placeholder="请输入日期" clearable></el-input>
</el-form-item>
<el-form-item label="食堂名称">
<el-input v-model="dataForm.canteenName" placeholder="请输入食堂名称" clearable></el-input>
<el-select v-model="dataForm.canteenName" placeholder="请选择食堂名称" clearable style="width: 150px">
<el-option
v-for="dict in dict.type.canteen_name"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="餐别">
<el-select v-model="dataForm.mealType" placeholder="请选择餐别" clearable style="width: 150px">
@ -68,6 +75,9 @@
header-align="center"
align="center"
label="食堂名称">
<template slot-scope="scope">
<DictTag :options="dict.type.canteen_name" :value="scope.row.canteenName"/>
</template>
</el-table-column>
<el-table-column
prop="mealType"
@ -100,6 +110,8 @@
label="操作">
<template slot-scope="scope">
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ '' }}</el-button>
<el-button v-if="scope.row.status !== '1'" type="text" size="small" @click="publishHandle(scope.row.id)" style="color: #67c23a;"></el-button>
<el-button v-if="scope.row.status === '1'" type="text" size="small" @click="cancelPublishHandle(scope.row.id)" style="color: #e6a23c;"></el-button>
<el-button v-hasPermi="['autogencode:pmdailymenu:delete']" type="text" size="small" @click="deleteHandle(scope.row.id)" style="color: #f56c6c;"></el-button>
</template>
</el-table-column>
@ -124,7 +136,7 @@
import DictTag from '@/components/DictTag'
import DispatchList from './DispatchList.vue'
export default {
dicts: ['meal_type', 'menu_status'],
dicts: ['meal_type', 'menu_status', 'canteen_name'],
data () {
return {
dataForm: {
@ -269,6 +281,34 @@
})
})
},
//
publishHandle (id) {
this.$confirm(`确定发布该菜单?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// API
api.pmdailymenuPublishApi(id).then(res => {
this.$message.success('发布成功')
this.getDataList()
})
})
},
//
cancelPublishHandle (id) {
this.$confirm(`确定撤销发布该菜单?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// API
api.pmdailymenuCancelPublishApi(id).then(res => {
this.$message.success('撤销发布成功')
this.getDataList()
})
})
},
}
}
</script>

@ -1,77 +1,181 @@
<template>
<!-- 基于 Element UI 新增和修改弹窗 -->
<el-dialog
:title="!dataForm.id ? '添加' : '修改'"
:close-on-click-modal="false"
:visible.sync="visible">
<!-- 新增和修改表单 -->
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataSubmit()" label-width="80px">
<el-form-item label="日期" prop="menuDate">
<el-date-picker v-model="dataForm.menuDate" type="date" value-format="yyyy-MM-dd" placeholder="请选择日期" style="width: 100%"></el-date-picker>
</el-form-item>
<el-form-item label="食堂名称" prop="canteenName">
<el-input v-model="dataForm.canteenName" placeholder="食堂名称"></el-input>
</el-form-item>
<el-form-item label="餐别" prop="mealType">
<el-select v-model="dataForm.mealType" placeholder="请选择餐别" style="width: 100%">
<el-option
v-for="dict in dict.type.meal_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="dataForm.status" placeholder="请选择状态" style="width: 100%">
<el-option
v-for="dict in dict.type.menu_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="dataForm.remark" type="textarea" placeholder="备注" rows="4"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<div>
<!-- 基于 Element UI 新增和修改弹窗 -->
<el-dialog
:title="!dataForm.id ? '添加' : '修改'"
:close-on-click-modal="false"
:visible.sync="visible"
width="80%">
<!-- 顶部筛选区 -->
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="100px">
<el-row :gutter="20">
<el-col :span="8">
<el-form-item label="日期" prop="menuDate">
<template v-if="dataForm.id">
<span style="color: #909399;">{{ dataForm.menuDate }}</span>
</template>
<el-date-picker v-else v-model="dataForm.menuDate" type="date" value-format="yyyy-MM-dd"
placeholder="请选择日期" style="width: 100%"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="食堂名称" prop="canteenName">
<template v-if="dataForm.id">
<span style="color: #909399;">{{ getCanteenNameLabel(dataForm.canteenName) }}</span>
</template>
<el-select v-else v-model="dataForm.canteenName" placeholder="请选择食堂名称" style="width: 100%">
<el-option
v-for="dict in dict.type.canteen_name"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<div style="margin-top: 24px;">
<el-button type="primary" @click="openCopyMenuDialog" style="margin-right: 10px;">复制菜单</el-button>
<el-button @click="resetForm"></el-button>
</div>
</el-col>
</el-row>
</el-form>
<!-- 中间主体区餐别分组表单 -->
<div style="margin-top: 20px;">
<el-collapse v-model="activeNames" style="margin-bottom: 20px;">
<el-collapse-item v-for="meal in dict.type.meal_type" :key="meal.value" :title="meal.label"
:name="meal.value">
<div style="margin-bottom: 10px;">
<el-tag :type="mealStatuses[meal.value] === '0' ? 'info' : 'success'">
{{ mealStatuses[meal.value] === '0' ? '未发布' : '已发布' }}
</el-tag>
<div style="margin-top: 10px;">
<el-button type="primary" size="small" @click="addDish(meal.value)" style="margin-right: 10px;">+ 添加菜品
</el-button>
<el-button size="small" @click="clearMeal(meal.value)"></el-button>
</div>
</div>
<el-table :data="mealDishes[meal.value]" style="width: 100%" border>
<el-table-column prop="itemName" label="菜品名称" width="200">
<template slot-scope="scope">
<el-input v-model="scope.row.itemName" placeholder="请输入菜品名称"></el-input>
</template>
</el-table-column>
<el-table-column prop="itemType" label="菜品类型" width="150">
<template slot-scope="scope">
<el-select v-model="scope.row.itemType" placeholder="请选择菜品类型" style="width: 100%">
<el-option
v-for="dict in dict.type.item_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</template>
</el-table-column>
<el-table-column prop="itemPrice" label="菜品价格" width="120">
<template slot-scope="scope">
<el-input type="number" v-model.number="scope.row.itemPrice" placeholder="0.00"
style="width: 100%"></el-input>
</template>
</el-table-column>
<el-table-column prop="remark" label="备注">
<template slot-scope="scope">
<el-input v-model="scope.row.remark" placeholder="请输入备注"></el-input>
</template>
</el-table-column>
<el-table-column label="操作" width="100" fixed="right">
<template slot-scope="scope">
<el-button type="danger" size="small" @click="deleteDish(meal.value, scope.$index)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-collapse-item>
</el-collapse>
</div>
<!-- 底部操作区 -->
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="dataSubmit()"></el-button>
<el-button type="primary" @click="dataSubmit()"></el-button>
</span>
</el-dialog>
<!-- 复制菜单弹窗 -->
<el-dialog
title="复制菜单"
:close-on-click-modal="false"
:visible.sync="copyMenuDialogVisible"
width="500px">
<div style="margin-bottom: 20px;">
<p>请选择需要复制的目标日期菜单</p>
</div>
<el-form :model="copyMenuForm" :rules="copyMenuRules" ref="copyMenuForm" label-width="120px">
<el-form-item label="来源日期" prop="sourceDate">
<el-date-picker v-model="copyMenuForm.sourceDate" type="date" value-format="yyyy-MM-dd" placeholder="请选择日期"
style="width: 100%"></el-date-picker>
</el-form-item>
<el-form-item label="食堂名称" prop="canteenName">
<el-select v-model="copyMenuForm.canteenName" placeholder="请选择食堂名称" style="width: 100%">
<el-option
v-for="dict in dict.type.canteen_name"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="copyMenuDialogVisible = false">取消</el-button>
<el-button type="primary" @click="copyMenu" :disabled="!copyMenuForm.sourceDate">确定复制</el-button>
</span>
</el-dialog>
</el-dialog>
</div>
</template>
<script>
import * as api from '@/api/pmdailymenu.js'
export default {
dicts: ['meal_type', 'menu_status'],
data () {
dicts: ['meal_type', 'menu_status', 'item_type', 'canteen_name'],
data() {
return {
visible: false,
activeNames: ['1', '2', '3'], //
dataForm: {
id: 0,
menuDate: '' ,
canteenName: '' ,
mealType: '' ,
status: '' ,
remark: '' ,
menuDate: new Date().toISOString().split('T')[0], //
canteenName: '',
remark: '',
},
dataRule: {
menuDate: [
{ required: true, message: '日期 为必填项', trigger: 'blur' }
//
mealStatuses: {},
//
mealDishes: {},
//
copyMenuDialogVisible: false,
copyMenuForm: {
sourceDate: '',
canteenName: ''
},
copyMenuRules: {
sourceDate: [
{required: true, message: '来源日期 为必填项', trigger: 'blur'}
],
canteenName: [
{ required: true, message: '食堂名称 为必填项', trigger: 'blur' }
{required: true, message: '食堂名称 为必填项', trigger: 'blur'}
],
mealType: [
{ required: true, message: '餐别 为必填项', trigger: 'blur' }
},
dataRule: {
menuDate: [
{required: true, message: '日期 为必填项', trigger: 'blur'}
],
status: [
{ required: true, message: '状态 为必填项', trigger: 'blur' }
canteenName: [
{required: true, message: '食堂名称 为必填项', trigger: 'blur'}
],
}
}
},
@ -80,30 +184,206 @@ export default {
this.dataForm.id = id || 0
this.visible = true
this.$nextTick(function() {
this.$refs['dataForm'].resetFields()
if (this.$refs['dataForm']) {
this.$refs['dataForm'].resetFields()
}
if (this.dataForm.id) {
api.pmdailymenuDetailApi(id).then(function(res) {
this.dataForm = res;
//
//
api.pmdailymenuDetailApi(id).then(function(detailRes) {
if (detailRes) {
this.dataForm = detailRes;
const menuDate = detailRes.menuDate;
const canteenName = detailRes.canteenName;
// 使
api.pmdailymenuDayDetailApi({
menuDate: menuDate,
canteenName: canteenName
}).then(function(dayRes) {
if (dayRes && dayRes.length > 0) {
//
this.mealStatuses = {};
this.mealDishes = {};
//
dayRes.forEach(menu => {
this.mealStatuses[menu.mealType] = menu.status;
this.mealDishes[menu.mealType] = menu.pmDailyMenuDtls || [];
});
} else {
//
this.resetForm();
this.dataForm.menuDate = menuDate;
this.dataForm.canteenName = canteenName;
}
}.bind(this));
} else {
this.$message.error('获取菜单数据失败');
this.visible = false;
}
}.bind(this))
} else {
// 0
this.dataForm.status = '0'
//
this.resetForm();
}
}.bind(this))
},
//
loadDayMenuData(menuDate, canteenName) {
//
const params = {
menuDate: menuDate,
canteenName: canteenName
};
//
api.pmdailymenuListByAll(params).then(function (res) {
if (res && res.data && res.data.length > 0) {
//
this.mealStatuses = {};
this.mealDishes = {};
//
res.data.forEach(menu => {
this.mealStatuses[menu.mealType] = menu.status;
this.mealDishes[menu.mealType] = menu.pmDailyMenuDtls || [];
});
} else {
//
this.resetForm();
this.dataForm.menuDate = menuDate;
this.dataForm.canteenName = canteenName;
}
}.bind(this));
},
//
resetForm() {
this.dataForm.menuDate = new Date().toISOString().split('T')[0];
this.dataForm.canteenName = '';
this.dataForm.remark = '';
//
this.mealStatuses = {};
this.mealDishes = {};
if (this.dict && this.dict.type && this.dict.type.meal_type) {
this.dict.type.meal_type.forEach(meal => {
this.mealStatuses[meal.value] = '0'; //
this.mealDishes[meal.value] = [];
});
}
},
//
openCopyMenuDialog() {
//
const yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);
this.copyMenuForm.sourceDate = yesterday.toISOString().split('T')[0];
//
if (this.dataForm.canteenName) {
this.copyMenuForm.canteenName = this.dataForm.canteenName;
}
this.copyMenuDialogVisible = true;
},
//
copyMenu() {
this.$refs['copyMenuForm'].validate((valid) => {
if (valid) {
//
api.pmdailymenuCopyApi({
sourceDate: this.copyMenuForm.sourceDate,
targetDate: this.dataForm.menuDate,
canteenName: this.copyMenuForm.canteenName
}).then(function (res) {
if (res.data && res.data.length > 0) {
//
this.mealStatuses = {};
this.mealDishes = {};
//
res.data.forEach(menu => {
this.mealStatuses[menu.mealType] = menu.status;
this.mealDishes[menu.mealType] = menu.pmDailyMenuDtls || [];
});
this.$message.success('复制成功,数据已填充到表单中')
} else {
this.$message.warning('未找到可复制的菜单数据')
}
this.copyMenuDialogVisible = false
}.bind(this));
}
})
},
//
addDish(mealType) {
const newDish = {
itemName: '',
itemType: '',
itemPrice: 0,
remark: ''
};
if (!this.mealDishes[mealType]) {
this.mealDishes[mealType] = [];
}
this.mealDishes[mealType].push(newDish);
},
//
deleteDish(mealType, index) {
if (this.mealDishes[mealType]) {
this.mealDishes[mealType].splice(index, 1);
}
},
//
clearMeal(mealType) {
if (this.mealDishes[mealType]) {
this.mealDishes[mealType] = [];
}
},
//
getCanteenNameLabel(value) {
if (!value || !this.dict || !this.dict.type || !this.dict.type.canteen_name) {
return value;
}
const dict = this.dict.type.canteen_name.find(item => item.value === value);
return dict ? dict.label : value;
},
//
dataSubmit () {
dataSubmit() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
//
const batchData = [];
if (this.dict && this.dict.type && this.dict.type.meal_type) {
this.dict.type.meal_type.forEach(meal => {
const mealType = meal.value;
batchData.push({
menuDate: this.dataForm.menuDate,
canteenName: this.dataForm.canteenName,
mealType: mealType,
status: this.mealStatuses[mealType] || '0',
remark: this.dataForm.remark,
pmDailyMenuDtls: (this.mealDishes[mealType] || []).map(dish => ({
itemName: dish.itemName,
itemType: dish.itemType,
itemPrice: dish.itemPrice,
remark: dish.remark
}))
});
});
}
//
if (this.dataForm.id) {
api.pmdailymenuUpdateApi(this.dataForm).then(function(res) {
//
api.pmdailymenuBatchUpdateApi(batchData).then(function (res) {
this.$message.success('保存成功')
this.visible = false
this.$emit('refreshDataList')
}.bind(this));
} else {
api.pmdailymenuCreateApi(this.dataForm).then(function(res) {
this.$message.success('新增成功')
//
api.pmdailymenuBatchCreateApi(batchData).then(function (res) {
this.$message.success('保存成功')
this.visible = false
this.$emit('refreshDataList')
}.bind(this));
@ -114,3 +394,10 @@ export default {
}
}
</script>
<style scoped>
.el-collapse-item__header {
font-size: 16px;
font-weight: bold;
}
</style>

@ -72,6 +72,23 @@ public class PmCanteenDemandController {
if (request.getDemandUser() != null) {
queryWrapper.eq(PmCanteenDemand::getDemandUser, request.getDemandUser());
}
// 申请人姓名搜索(虚拟字段)
if (StrUtil.isNotBlank(request.getUserNameSearch())) {
// 使用INSQL的方式进行模糊查询
List<User> users = ebUserService.list(new LambdaQueryWrapper<User>()
.like(User::getRealName, request.getUserNameSearch()));
if (!users.isEmpty()) {
List<Long> userIds = users.stream()
.map(User::getUid)
.map(Long::valueOf)
.collect(java.util.stream.Collectors.toList());
queryWrapper.in(PmCanteenDemand::getDemandUser, userIds);
} else {
// 如果没有匹配的用户添加一个永远为false的条件
queryWrapper.eq(PmCanteenDemand::getId, -1);
}
}
// 申请人类型
if (StrUtil.isNotBlank(request.getUserType())) {
@ -157,7 +174,7 @@ public class PmCanteenDemandController {
: ebUserService.listByIds(userIds).stream()
.collect(java.util.stream.Collectors.toMap(User::getUid, User::getRealName));
// 在pmCanteenDemands中进行翻译设置userName虚拟字段
// 在pmCanteenDemands中进行翻译设置userName虚拟字段并获取需求明细
page.getList().forEach(demand -> {
if (demand.getDemandUser() != null) {
String userName = userMap.get(demand.getDemandUser().intValue());
@ -165,6 +182,13 @@ public class PmCanteenDemandController {
demand.setUserName(userName);
}
}
// 获取对应的需求明细
LambdaQueryWrapper<PmCanteenDemandDetail> detailQueryWrapper = new LambdaQueryWrapper<>();
detailQueryWrapper.eq(PmCanteenDemandDetail::getDemandId, demand.getId());
detailQueryWrapper.eq(PmCanteenDemandDetail::getDelFlag, "0"); // 只查询未删除的明细
List<PmCanteenDemandDetail> details = pmCanteenDemandDetailService.list(detailQueryWrapper);
demand.setPmCanteenDemandDetails(details);
});
return CommonResult.success(page);

@ -1,5 +1,6 @@
package com.zbkj.modules.autogencode.controller;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Date;
@ -275,8 +276,9 @@ public class PmCanteenPurchasePlanController {
public CommonResult<PmCanteenPurchasePlan> info(@PathVariable("id") Long id){
PmCanteenPurchasePlan pmCanteenPurchasePlan = pmCanteenPurchasePlanService.getById(id);
// 查询计划对应的需求
// 查询计划对应的需求和明细
if (pmCanteenPurchasePlan != null) {
// 查询需求
LambdaQueryWrapper<PmCanteenDemandPurchase> demandPurchaseQueryWrapper = new LambdaQueryWrapper<>();
demandPurchaseQueryWrapper.eq(PmCanteenDemandPurchase::getPurchaseId, id);
List<PmCanteenDemandPurchase> demandPurchases = pmCanteenDemandPurchaseService.list(demandPurchaseQueryWrapper);
@ -289,6 +291,65 @@ public class PmCanteenPurchasePlanController {
// 设置需求ID列表
pmCanteenPurchasePlan.setDemandIds(demandIds);
// 查询采购明细
LambdaQueryWrapper<PmCanteenPurchaseDetail> detailQueryWrapper = new LambdaQueryWrapper<>();
detailQueryWrapper.eq(PmCanteenPurchaseDetail::getPlanId, id);
List<PmCanteenPurchaseDetail> pmCanteenPurchaseDetails = pmCanteenPurchaseDetailService.list(detailQueryWrapper);
// 设置采购明细列表
pmCanteenPurchasePlan.setPmCanteenPurchaseDetails(pmCanteenPurchaseDetails);
// 翻译字段
// 收集所有需要查询的部门ID
List<Long> deptIds = new ArrayList<>();
// 收集所有需要查询的用户ID
List<Long> userIds = new ArrayList<>();
if (pmCanteenPurchasePlan.getApplyDept() != null) {
deptIds.add(pmCanteenPurchasePlan.getApplyDept());
}
if (pmCanteenPurchasePlan.getApplyUser() != null) {
userIds.add(pmCanteenPurchasePlan.getApplyUser());
}
if (pmCanteenPurchasePlan.getAuditUser() != null) {
userIds.add(pmCanteenPurchasePlan.getAuditUser());
}
// 去重
deptIds = deptIds.stream().distinct().collect(Collectors.toList());
userIds = userIds.stream().distinct().collect(Collectors.toList());
// 批量查询部门信息
Map<Long, String> deptMap = new HashMap<>();
if (!deptIds.isEmpty()) {
List<SysDept> depts = sysDeptService.listByIds(deptIds);
for (SysDept dept : depts) {
deptMap.put(dept.getDeptId(), dept.getDeptName());
}
}
// 批量查询用户信息
Map<Long, String> userMap = new HashMap<>();
if (!userIds.isEmpty()) {
List<SystemAdmin> admins = systemAdminService.listByIds(userIds);
for (SystemAdmin admin : admins) {
userMap.put(Long.valueOf(admin.getId()), admin.getRealName());
}
}
// 翻译字段
// 翻译部门
if (pmCanteenPurchasePlan.getApplyDept() != null) {
pmCanteenPurchasePlan.setApplyDeptName(deptMap.get(pmCanteenPurchasePlan.getApplyDept()));
}
// 翻译用户
if (pmCanteenPurchasePlan.getApplyUser() != null) {
pmCanteenPurchasePlan.setApplyUserName(userMap.get(pmCanteenPurchasePlan.getApplyUser()));
}
if (pmCanteenPurchasePlan.getAuditUser() != null) {
pmCanteenPurchasePlan.setAuditUserName(userMap.get(pmCanteenPurchasePlan.getAuditUser()));
}
}
return CommonResult.success(pmCanteenPurchasePlan);
@ -301,6 +362,7 @@ public class PmCanteenPurchasePlanController {
public CommonResult<String> save(@RequestBody PmCanteenPurchasePlan pmCanteenPurchasePlan){
List<Long> demandIds = pmCanteenPurchasePlan.getDemandIds();
List<PmCanteenPurchaseDetail> pmCanteenPurchaseDetails = pmCanteenPurchasePlan.getPmCanteenPurchaseDetails();
// 保存采购计划
if (!pmCanteenPurchasePlanService.save(pmCanteenPurchasePlan)) {
@ -310,8 +372,20 @@ public class PmCanteenPurchasePlanController {
// 获取保存后的计划ID
Long planId = pmCanteenPurchasePlan.getId();
// 处理需求采购关联表
if (demandIds != null && !demandIds.isEmpty()) {
for (Long demandId : demandIds) {
// 生成需求采购关联表
PmCanteenDemandPurchase demandPurchase = new PmCanteenDemandPurchase();
demandPurchase.setDemandId(demandId);
demandPurchase.setPurchaseId(planId);
// 保存关联表
pmCanteenDemandPurchaseService.save(demandPurchase);
}
}
// 处理选中的商品
if (pmCanteenPurchaseDetails != null && !pmCanteenPurchaseDetails.isEmpty()) {
// 查询出所有的cm_cust_product做成mapkey为goodsName - goodsCode - spec - unitvalue为CmCustProduct
List<CmCustProduct> cmCustProducts = cmCustProductService.list();
Map<String, CmCustProduct> cmCustProductMap = new HashMap<>();
@ -320,50 +394,21 @@ public class PmCanteenPurchasePlanController {
cmCustProductMap.put(key, cmCustProduct);
}
for (Long demandId : demandIds) {
// 获取需求信息
PmCanteenDemand demand = pmCanteenDemandService.getById(demandId);
if (demand == null) {
continue;
}
// 获取需求明细
LambdaQueryWrapper<PmCanteenDemandDetail> detailQueryWrapper = new LambdaQueryWrapper<>();
detailQueryWrapper.eq(PmCanteenDemandDetail::getDemandId, demandId);
List<PmCanteenDemandDetail> demandDetails = pmCanteenDemandDetailService.list(detailQueryWrapper);
for (PmCanteenPurchaseDetail purchaseDetail : pmCanteenPurchaseDetails) {
// 设置采购计划ID
purchaseDetail.setPlanId(planId);
// 根据需求明细生成采购计划明细
for (PmCanteenDemandDetail demandDetail : demandDetails) {
PmCanteenPurchaseDetail purchaseDetail = new PmCanteenPurchaseDetail();
// 设置采购计划ID
purchaseDetail.setPlanId(planId);
// 复制需求明细的相关字段
purchaseDetail.setGoodsName(demandDetail.getGoodsName());
purchaseDetail.setGoodsCode(demandDetail.getGoodsCode());
purchaseDetail.setSpec(demandDetail.getSpec());
purchaseDetail.setUnit(demandDetail.getUnit());
purchaseDetail.setPlanQuantity(demandDetail.getDemandQuantity());
purchaseDetail.setRemark(demandDetail.getRemark());
// 根据key从map中获取对应的CmCustProduct并设置对应的字段
String key = demandDetail.getGoodsName() + " - " + demandDetail.getGoodsCode() + " - " + demandDetail.getSpec() + " - " + demandDetail.getUnit();
CmCustProduct cmCustProduct = cmCustProductMap.get(key);
if (cmCustProduct != null) {
purchaseDetail.setCustId(cmCustProduct.getCustId());
purchaseDetail.setCustName(cmCustProduct.getCustName());
purchaseDetail.setGoodsId(cmCustProduct.getId()); // 商品Id
}
// 保存采购计划明细
pmCanteenPurchaseDetailService.save(purchaseDetail);
// 根据key从map中获取对应的CmCustProduct并设置对应的字段
String key = purchaseDetail.getGoodsName() + " - " + purchaseDetail.getGoodsCode() + " - " + purchaseDetail.getSpec() + " - " + purchaseDetail.getUnit();
CmCustProduct cmCustProduct = cmCustProductMap.get(key);
if (cmCustProduct != null) {
purchaseDetail.setCustId(cmCustProduct.getCustId());
purchaseDetail.setCustName(cmCustProduct.getCustName());
purchaseDetail.setGoodsId(cmCustProduct.getId()); // 商品Id
}
// 生成需求采购关联表
PmCanteenDemandPurchase demandPurchase = new PmCanteenDemandPurchase();
demandPurchase.setDemandId(demandId);
demandPurchase.setPurchaseId(planId);
// 保存关联表
pmCanteenDemandPurchaseService.save(demandPurchase);
// 保存采购计划明细
pmCanteenPurchaseDetailService.save(purchaseDetail);
}
}
@ -375,10 +420,49 @@ public class PmCanteenPurchasePlanController {
*/
@RequestMapping(value = "/update", method = RequestMethod.POST)
public CommonResult<String> update(@RequestBody PmCanteenPurchasePlan pmCanteenPurchasePlan){
if (pmCanteenPurchasePlanService.updateById(pmCanteenPurchasePlan)) {
return CommonResult.success();
// 保存采购计划基本信息
if (!pmCanteenPurchasePlanService.updateById(pmCanteenPurchasePlan)) {
return CommonResult.failed();
}
return CommonResult.failed();
// 获取采购计划ID
Long planId = pmCanteenPurchasePlan.getId();
// 处理选中的商品
List<PmCanteenPurchaseDetail> pmCanteenPurchaseDetails = pmCanteenPurchasePlan.getPmCanteenPurchaseDetails();
if (pmCanteenPurchaseDetails != null && !pmCanteenPurchaseDetails.isEmpty()) {
// 删除该采购计划下的所有现有明细
LambdaQueryWrapper<PmCanteenPurchaseDetail> detailQueryWrapper = new LambdaQueryWrapper<>();
detailQueryWrapper.eq(PmCanteenPurchaseDetail::getPlanId, planId);
pmCanteenPurchaseDetailService.remove(detailQueryWrapper);
// 查询出所有的cm_cust_product做成mapkey为goodsName - goodsCode - spec - unitvalue为CmCustProduct
List<CmCustProduct> cmCustProducts = cmCustProductService.list();
Map<String, CmCustProduct> cmCustProductMap = new HashMap<>();
for (CmCustProduct cmCustProduct : cmCustProducts) {
String key = cmCustProduct.getGoodsName() + " - " + cmCustProduct.getGoodsCode() + " - " + cmCustProduct.getSpec() + " - " + cmCustProduct.getUnit();
cmCustProductMap.put(key, cmCustProduct);
}
for (PmCanteenPurchaseDetail purchaseDetail : pmCanteenPurchaseDetails) {
// 设置采购计划ID
purchaseDetail.setPlanId(planId);
// 根据key从map中获取对应的CmCustProduct并设置对应的字段
String key = purchaseDetail.getGoodsName() + " - " + purchaseDetail.getGoodsCode() + " - " + purchaseDetail.getSpec() + " - " + purchaseDetail.getUnit();
CmCustProduct cmCustProduct = cmCustProductMap.get(key);
if (cmCustProduct != null) {
purchaseDetail.setCustId(cmCustProduct.getCustId());
purchaseDetail.setCustName(cmCustProduct.getCustName());
purchaseDetail.setGoodsId(cmCustProduct.getId()); // 商品Id
}
// 保存采购计划明细
pmCanteenPurchaseDetailService.save(purchaseDetail);
}
}
return CommonResult.success();
}
/**
@ -501,7 +585,10 @@ public class PmCanteenPurchasePlanController {
}
// 描写 去吃饭之前,请求帮助 巴麻美答应帮忙,其他人也答应帮忙
// 因为枫在昨晚也帮助过其他人
// 鹤乃表示大家一起帮忙,很快就可以解决了。
// 前往中央电波塔

@ -1,8 +1,6 @@
package com.zbkj.modules.autogencode.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -132,7 +130,9 @@ public class PmDailyMenuController {
// 应用搜索条件
condition(queryWrapper, request);
queryWrapper.orderByDesc(PmDailyMenu::getMenuDate);
queryWrapper.orderByDesc(PmDailyMenu::getCanteenName);
queryWrapper.orderByDesc(PmDailyMenu::getMealType);
CommonPage<PmDailyMenu> page = CommonPage.restPage(pmDailyMenuService.pageList(queryWrapper, pageParamRequest));
return CommonResult.success(page);
}
@ -212,6 +212,18 @@ public class PmDailyMenuController {
@RequestMapping(value = "/batchSave", method = RequestMethod.POST)
public CommonResult<String> batchSave(@RequestBody List<PmDailyMenu> menus){
try {
// 检查是否已存在相同日期和食堂的菜单
for (PmDailyMenu menu : menus) {
LambdaQueryWrapper<PmDailyMenu> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PmDailyMenu::getMenuDate, menu.getMenuDate());
queryWrapper.eq(PmDailyMenu::getCanteenName, menu.getCanteenName());
queryWrapper.eq(PmDailyMenu::getMealType, menu.getMealType());
if (pmDailyMenuService.count(queryWrapper) > 0) {
return CommonResult.failed("当天该食堂的" + getMealTypeLabel(menu.getMealType()) + "菜单已存在");
}
}
// 保存菜单和明细
for (PmDailyMenu menu : menus) {
// 保存菜单
pmDailyMenuService.save(menu);
@ -230,5 +242,162 @@ public class PmDailyMenuController {
return CommonResult.failed("批量创建失败");
}
}
/**
*
*/
@RequestMapping(value = "/batchUpdate", method = RequestMethod.POST)
public CommonResult<String> batchUpdate(@RequestBody List<PmDailyMenu> menus){
try {
if (menus == null || menus.isEmpty()) {
return CommonResult.failed("菜单数据不能为空");
}
// 获取日期和食堂名称
PmDailyMenu firstMenu = menus.get(0);
Date menuDate = firstMenu.getMenuDate();
String canteenName = firstMenu.getCanteenName();
// 删除当天旧菜单
LambdaQueryWrapper<PmDailyMenu> deleteWrapper = new LambdaQueryWrapper<>();
deleteWrapper.eq(PmDailyMenu::getMenuDate, menuDate);
deleteWrapper.eq(PmDailyMenu::getCanteenName, canteenName);
List<PmDailyMenu> oldMenus = pmDailyMenuService.list(deleteWrapper);
for (PmDailyMenu oldMenu : oldMenus) {
// 删除旧菜单明细
LambdaQueryWrapper<PmDailyMenuDtl> dtlDeleteWrapper = new LambdaQueryWrapper<>();
dtlDeleteWrapper.eq(PmDailyMenuDtl::getMenuId, oldMenu.getId());
pmDailyMenuDtlService.remove(dtlDeleteWrapper);
}
// 删除旧菜单
pmDailyMenuService.remove(deleteWrapper);
// 插入新菜单
for (PmDailyMenu menu : menus) {
// 保存菜单
pmDailyMenuService.save(menu);
// 保存菜单明细
if (menu.getPmDailyMenuDtls() != null && !menu.getPmDailyMenuDtls().isEmpty()) {
for (PmDailyMenuDtl dtl : menu.getPmDailyMenuDtls()) {
dtl.setMenuId(menu.getId());
pmDailyMenuDtlService.save(dtl);
}
}
}
return CommonResult.success();
} catch (Exception e) {
e.printStackTrace();
return CommonResult.failed("批量更新失败");
}
}
/**
*
*/
private String getMealTypeLabel(String mealType) {
if ("1".equals(mealType)) {
return "早餐";
} else if ("2".equals(mealType)) {
return "中餐";
} else if ("3".equals(mealType)) {
return "晚餐";
}
return mealType;
}
/**
*
*/
@RequestMapping(value = "/publish/{id}", method = RequestMethod.POST)
public CommonResult<String> publish(@PathVariable("id") Long id) {
try {
PmDailyMenu menu = pmDailyMenuService.getById(id);
if (menu == null) {
return CommonResult.failed("菜单不存在");
}
menu.setStatus("1");
pmDailyMenuService.updateById(menu);
return CommonResult.success();
} catch (Exception e) {
e.printStackTrace();
return CommonResult.failed("发布失败");
}
}
/**
*
*/
@RequestMapping(value = "/cancelPublish/{id}", method = RequestMethod.POST)
public CommonResult<String> cancelPublish(@PathVariable("id") Long id) {
try {
PmDailyMenu menu = pmDailyMenuService.getById(id);
if (menu == null) {
return CommonResult.failed("菜单不存在");
}
menu.setStatus("0");
pmDailyMenuService.updateById(menu);
return CommonResult.success();
} catch (Exception e) {
e.printStackTrace();
return CommonResult.failed("撤销发布失败");
}
}
/**
*
*/
@RequestMapping(value = "/copy", method = RequestMethod.POST)
public CommonResult<List<PmDailyMenu>> copy(@RequestBody Map<String, String> params){
try {
String sourceDate = params.get("sourceDate");
String targetDate = params.get("targetDate");
String canteenName = params.get("canteenName");
// 查询原菜单
LambdaQueryWrapper<PmDailyMenu> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PmDailyMenu::getMenuDate, sourceDate);
queryWrapper.eq(PmDailyMenu::getCanteenName, canteenName);
List<PmDailyMenu> sourceMenus = pmDailyMenuService.list(queryWrapper);
List<PmDailyMenu> targetMenus = new ArrayList<>();
for (PmDailyMenu sourceMenu : sourceMenus) {
// 创建新菜单
PmDailyMenu targetMenu = new PmDailyMenu();
targetMenu.setMenuDate(java.sql.Date.valueOf(targetDate));
targetMenu.setCanteenName(canteenName);
targetMenu.setMealType(sourceMenu.getMealType());
targetMenu.setStatus(sourceMenu.getStatus());
targetMenu.setRemark(sourceMenu.getRemark());
targetMenu.setDelFlag("0");
// 查询原菜单明细
LambdaQueryWrapper<PmDailyMenuDtl> dtlQueryWrapper = new LambdaQueryWrapper<>();
dtlQueryWrapper.eq(PmDailyMenuDtl::getMenuId, sourceMenu.getId());
List<PmDailyMenuDtl> sourceDtls = pmDailyMenuDtlService.list(dtlQueryWrapper);
// 复制明细
List<PmDailyMenuDtl> targetDtls = new ArrayList<>();
for (PmDailyMenuDtl sourceDtl : sourceDtls) {
PmDailyMenuDtl targetDtl = new PmDailyMenuDtl();
targetDtl.setItemName(sourceDtl.getItemName());
targetDtl.setItemType(sourceDtl.getItemType());
targetDtl.setItemPrice(sourceDtl.getItemPrice());
targetDtl.setRemark(sourceDtl.getRemark());
targetDtl.setDelFlag("0");
targetDtls.add(targetDtl);
}
targetMenu.setPmDailyMenuDtls(targetDtls);
targetMenus.add(targetMenu);
}
return CommonResult.success(targetMenus);
} catch (Exception e) {
e.printStackTrace();
return CommonResult.failed("复制失败");
}
}
}

@ -23,6 +23,11 @@ import com.zbkj.common.model.system.SystemAttachment;
import com.zbkj.service.service.SystemAttachmentService;
import com.zbkj.common.model.system.SysDept;
import com.zbkj.service.service.SysDeptService;
import com.zbkj.modules.autogencode.entity.PubNoticeRel;
import com.zbkj.modules.autogencode.service.PubNoticeRelService;
import com.zbkj.common.model.user.User;
import com.zbkj.service.service.UserService;
import org.springframework.security.core.context.SecurityContextHolder;
@ -42,6 +47,12 @@ public class PubNoticeController {
@Autowired
private SysDeptService sysDeptService;
@Autowired
private PubNoticeRelService pubNoticeRelService;
@Autowired
private UserService userService;
/**
@ -164,6 +175,44 @@ public class PubNoticeController {
if (StrUtil.isNotBlank(request.getDelFlag())) {
queryWrapper.eq(PubNotice::getDelFlag, request.getDelFlag());
}
// 是否已读(虚拟字段,用于过滤)
if (StrUtil.isNotBlank(request.getIsRead())) {
// 获取当前用户Id
Integer userId = userService.getUserId();
if (userId != 0) {
// 查询用户的所有通知关联记录
List<PubNoticeRel> relList = pubNoticeRelService.list(new LambdaQueryWrapper<PubNoticeRel>()
.eq(PubNoticeRel::getUserCode, userId.toString())
.eq(PubNoticeRel::getDelFlag, "1"));
if ("1".equals(request.getIsRead())) {
// 查询已读通知筛选出isRead为1的记录
List<String> readNoticeIds = relList.stream()
.filter(rel -> "1".equals(rel.getIsRead()))
.map(PubNoticeRel::getNoticeId)
.collect(java.util.stream.Collectors.toList());
if (!readNoticeIds.isEmpty()) {
queryWrapper.in(PubNotice::getNoticeId, readNoticeIds);
} else {
// 如果没有已读记录添加一个永远为false的条件
queryWrapper.eq(PubNotice::getNoticeId, -1);
}
} else if ("0".equals(request.getIsRead())) {
// 查询未读通知:筛选出没有关联记录的通知
if (!relList.isEmpty()) {
// 提取所有已关联的通知ID
List<String> relatedNoticeIds = relList.stream()
.map(PubNoticeRel::getNoticeId)
.collect(java.util.stream.Collectors.toList());
// 查询不在已关联列表中的通知
queryWrapper.notIn(PubNotice::getNoticeId, relatedNoticeIds);
}
// 如果没有关联记录,则所有通知都是未读的,不需要添加条件
}
}
}
}
@ -182,7 +231,7 @@ public class PubNoticeController {
condition(queryWrapper, request);
List<PubNotice> pubNotices = pubNoticeService.pageList(queryWrapper, pageParamRequest);
// 设置拟稿单位名称
// 设置拟稿单位名称和已读状态
if (pubNotices != null && !pubNotices.isEmpty()) {
// 查询所有部门
List<SysDept> deptList = sysDeptService.list();
@ -193,11 +242,30 @@ public class PubNoticeController {
deptMap.put(String.valueOf(dept.getDeptId()), dept.getDeptName());
}
}
// 遍历通知列表,设置拟稿单位名称
// 获取当前用户Id
Integer userId = userService.getUserId();
// 构建通知ID到已读状态的映射
Map<String, String> readStatusMap = new HashMap<>();
if (userId != 0) {
List<PubNoticeRel> relList = pubNoticeRelService.list(new LambdaQueryWrapper<PubNoticeRel>()
.eq(PubNoticeRel::getUserCode, userId.toString())
.eq(PubNoticeRel::getDelFlag, "1"));
for (PubNoticeRel rel : relList) {
readStatusMap.put(rel.getNoticeId(), rel.getIsRead());
}
}
// 遍历通知列表,设置拟稿单位名称和已读状态
for (PubNotice notice : pubNotices) {
// 设置拟稿单位名称
if (StrUtil.isNotBlank(notice.getDraftDept())) {
notice.setDraftDeptName(deptMap.getOrDefault(notice.getDraftDept(), ""));
}
// 设置已读状态
notice.setIsRead(readStatusMap.getOrDefault(notice.getNoticeId(), "0"));
}
}
@ -291,4 +359,49 @@ public class PubNoticeController {
return CommonResult.failed();
}
/**
*
* @param noticeId ID
*/
@ApiOperation(value = "设置用户已读")
@RequestMapping(value = "/markAsRead/{noticeId}", method = RequestMethod.POST)
public CommonResult<String> markAsRead(@PathVariable("noticeId") String noticeId){
try {
// 获取当前用户Id
Integer userId = userService.getUserId();
if (userId == 0) {
return CommonResult.failed("用户不存在");
}
// 查询是否存在关联记录
LambdaQueryWrapper<PubNoticeRel> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PubNoticeRel::getNoticeId, noticeId);
queryWrapper.eq(PubNoticeRel::getUserCode, userId.toString());
PubNoticeRel pubNoticeRel = pubNoticeRelService.getOne(queryWrapper);
if (pubNoticeRel != null) {
// 更新已读状态
pubNoticeRel.setIsRead("1"); // 1表示已读
pubNoticeRel.setReadTime(new Date());
pubNoticeRelService.updateById(pubNoticeRel);
} else {
// 创建新的关联记录
pubNoticeRel = new PubNoticeRel();
pubNoticeRel.setRelId(UUID.randomUUID().toString());
pubNoticeRel.setNoticeId(noticeId);
pubNoticeRel.setRelType("U"); // U表示用户
pubNoticeRel.setUserCode(userId.toString());
pubNoticeRel.setIsRead("1"); // 1表示已读
pubNoticeRel.setReadTime(new Date());
pubNoticeRel.setDelFlag("1"); // 1表示正常
pubNoticeRelService.save(pubNoticeRel);
}
return CommonResult.success("设置已读成功");
} catch (Exception e) {
e.printStackTrace();
return CommonResult.failed("设置已读失败");
}
}
}

@ -50,6 +50,13 @@ public class PmCanteenDemand implements Serializable {
@ApiModelProperty(value = "申请人姓名")
@TableField(exist = false)
private String userName;
/**
*
*/
@ApiModelProperty(value = "申请人姓名搜索")
@TableField(exist = false)
private String userNameSearch;
/**
*
*/

@ -138,5 +138,8 @@ public class PmCanteenPurchasePlan implements Serializable {
@TableField(exist = false)
private List<Long> demandIds;
@TableField(exist = false)
private List<PmCanteenPurchaseDetail> pmCanteenPurchaseDetails;
}

@ -3,6 +3,7 @@ package com.zbkj.modules.autogencode.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;
@ -70,6 +71,7 @@ public class PmDailyMenu implements Serializable {
*
*/
@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
*
@ -80,6 +82,7 @@ public class PmDailyMenu implements Serializable {
*
*/
@ApiModelProperty(value = "修改时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
/**
* ID

@ -3,6 +3,7 @@ package com.zbkj.modules.autogencode.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;
@ -68,6 +69,7 @@ public class PmDailyMenuDtl implements Serializable {
*
*/
@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
*
@ -78,6 +80,7 @@ public class PmDailyMenuDtl implements Serializable {
*
*/
@ApiModelProperty(value = "修改时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
/**
* ID

@ -152,6 +152,13 @@ public class PubNotice implements Serializable {
@ApiModelProperty(value = "拟稿单位名称")
@TableField(exist = false)
private String draftDeptName;
/**
*
*/
@ApiModelProperty(value = "是否已读")
@TableField(exist = false)
private String isRead;
}

@ -3,20 +3,12 @@ package com.zbkj.modules.autogencode.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.zbkj.modules.autogencode.entity.*;
import com.zbkj.modules.autogencode.service.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.zbkj.modules.autogencode.dao.PmCanteenPurchaseOrderDao;
import com.zbkj.modules.autogencode.entity.PmCanteenPurchaseOrder;
import com.zbkj.modules.autogencode.entity.PmCanteenPlanOrderRel;
import com.zbkj.modules.autogencode.entity.PmCanteenPurchaseDetail;
import com.zbkj.modules.autogencode.entity.PmCanteenPurchasePlan;
import com.zbkj.modules.autogencode.entity.CmCust;
import com.zbkj.modules.autogencode.service.PmCanteenPurchaseOrderService;
import com.zbkj.modules.autogencode.service.PmCanteenPlanOrderRelService;
import com.zbkj.modules.autogencode.service.PmCanteenPurchaseDetailService;
import com.zbkj.modules.autogencode.service.PmCanteenPurchasePlanService;
import com.zbkj.modules.autogencode.service.CmCustService;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.PageParamRequest;
@ -44,6 +36,9 @@ public class PmCanteenPurchaseOrderServiceImpl extends ServiceImpl<PmCanteenPurc
@Resource
private CmCustService cmCustService;
@Resource
private CmCustProductService cmCustProductService;
/**
*
@ -89,10 +84,11 @@ public class PmCanteenPurchaseOrderServiceImpl extends ServiceImpl<PmCanteenPurc
List<PmCanteenPurchaseOrder.PlanDetailDTO> result = new ArrayList<>();
for (PmCanteenPlanOrderRel rel : relList) {
PmCanteenPurchaseOrder.PlanDetailDTO dto = new PmCanteenPurchaseOrder.PlanDetailDTO();
// 从采购明细表中获取完整的商品信息
PmCanteenPurchaseDetail detail = pmCanteenPurchaseDetailService.getById(rel.getDetailId());
if (detail != null) {
PmCanteenPurchaseOrder.PlanDetailDTO dto = new PmCanteenPurchaseOrder.PlanDetailDTO();
dto.setId(detail.getId());
dto.setPlanId(detail.getPlanId());
@ -120,11 +116,6 @@ public class PmCanteenPurchaseOrderServiceImpl extends ServiceImpl<PmCanteenPurc
dto.setSpec(detail.getSpec());
dto.setUnit(detail.getUnit());
// 设置订单相关信息
dto.setOrderQuantity(rel.getOrderQuantity().doubleValue());
dto.setOrderPrice(rel.getOrderPrice().doubleValue());
dto.setOrderAmount(rel.getOrderAmount().doubleValue());
// 设置计划相关信息
dto.setQuantity(detail.getPlanQuantity() != null ? detail.getPlanQuantity().doubleValue() : 0.0);
dto.setPrice(detail.getPlanPrice() != null ? detail.getPlanPrice().doubleValue() : 0.0);
@ -132,9 +123,54 @@ public class PmCanteenPurchaseOrderServiceImpl extends ServiceImpl<PmCanteenPurc
// 其他字段
dto.setItemNumber(detail.getGoodsCode()); // 使用商品编码作为商品料号
dto.setCargoNumber(detail.getGoodsCode()); // 使用商品编码作为商品自然序号
dto.setCurrType("CNY"); // 默认人民币
result.add(dto);
} else {
// 如果没有对应的明细直接根据商品Id获取供应商、规格等商品的内容
dto.setId(rel.getId());
dto.setPlanId(rel.getPlanId());
// 根据 planId 查询 planNo
if (rel.getPlanId() != null) {
PmCanteenPurchasePlan plan = pmCanteenPurchasePlanService.getById(rel.getPlanId());
if (plan != null) {
dto.setPlanNo(plan.getPlanNo());
}
}
// 设置商品相关信息 是查询商品表,然后进行设置
dto.setGoodsId(rel.getGoodsId());
dto.setGoodsName(rel.getGoodsName());
// 尝试根据商品ID查询商品信息
if (rel.getGoodsId() != null) {
// 从商品表中查询商品信息
CmCustProduct goodsDetail = cmCustProductService.getById(rel.getGoodsId());
if (goodsDetail != null) {
dto.setGoodsCode(goodsDetail.getGoodsCode());
dto.setSpec(goodsDetail.getSpec());
dto.setUnit(goodsDetail.getUnit());
dto.setSupplierId(goodsDetail.getCustId());
dto.setSupplierName(goodsDetail.getCustName());
dto.setGoodsName(goodsDetail.getGoodsName());
// 其他字段
dto.setItemNumber(goodsDetail.getGoodsCode()); // 使用商品编码作为商品料号
dto.setCargoNumber(goodsDetail.getGoodsCode()); // 使用商品编码作为商品自然序号
}
} else {
// 如果商品ID为空使用默认值
dto.setItemNumber(rel.getGoodsName()); // 使用商品名称作为商品料号
dto.setCargoNumber(rel.getGoodsName()); // 使用商品名称作为商品自然序号
}
}
// 设置订单相关信息
dto.setOrderQuantity(rel.getOrderQuantity().doubleValue());
dto.setOrderPrice(rel.getOrderPrice().doubleValue());
dto.setOrderAmount(rel.getOrderAmount().doubleValue());
// 默认人民币
dto.setCurrType("CNY");
result.add(dto);
}
return result;
@ -150,18 +186,40 @@ public class PmCanteenPurchaseOrderServiceImpl extends ServiceImpl<PmCanteenPurc
List<PmCanteenPlanOrderRel> relList = new ArrayList<>();
for (PmCanteenPurchaseOrder.PlanDetailDTO detail : planDetails) {
PmCanteenPlanOrderRel rel = new PmCanteenPlanOrderRel();
rel.setOrderId(orderId);
rel.setPlanId(detail.getPlanId());
rel.setDetailId(detail.getId());
rel.setOrderQuantity(BigDecimal.valueOf(detail.getOrderQuantity()));
rel.setOrderPrice(BigDecimal.valueOf(detail.getOrderPrice()));
rel.setOrderAmount(BigDecimal.valueOf(detail.getOrderAmount()));
rel.setDelFlag("0");
relList.add(rel);
// 只有当明细ID大于0时才创建关联关系直接添加的商品明细ID为0
if (detail.getId() != null && detail.getId() > 0) {
PmCanteenPlanOrderRel rel = new PmCanteenPlanOrderRel();
rel.setOrderId(orderId);
rel.setPlanId(detail.getPlanId());
rel.setDetailId(detail.getId());
rel.setGoodsId(detail.getGoodsId());
rel.setOrderQuantity(BigDecimal.valueOf(detail.getOrderQuantity()));
rel.setOrderPrice(BigDecimal.valueOf(detail.getOrderPrice()));
rel.setOrderAmount(BigDecimal.valueOf(detail.getOrderAmount()));
rel.setDelFlag("0");
relList.add(rel);
}
if (detail.getId() != null && detail.getId() == 0) {
PmCanteenPlanOrderRel rel = new PmCanteenPlanOrderRel();
rel.setOrderId(orderId);
rel.setPlanId(detail.getPlanId());
rel.setDetailId(detail.getId());
rel.setGoodsId(detail.getGoodsId());
rel.setOrderQuantity(BigDecimal.valueOf(detail.getOrderQuantity()));
rel.setOrderPrice(BigDecimal.valueOf(detail.getOrderPrice()));
rel.setOrderAmount(BigDecimal.valueOf(detail.getOrderAmount()));
rel.setDelFlag("0");
relList.add(rel);
}
}
return pmCanteenPlanOrderRelService.saveBatch(relList);
// 如果有需要保存的关联关系,则批量保存
if (!relList.isEmpty()) {
return pmCanteenPlanOrderRelService.saveBatch(relList);
}
// 如果没有关联关系需要保存,返回成功
return true;
}
@Override

Loading…
Cancel
Save