优化修改订单

This commit is contained in:
Mrking 2025-01-19 21:10:28 +08:00
parent 1618b15b01
commit ff807e0def
11 changed files with 636 additions and 102 deletions

View File

@ -14,8 +14,10 @@ import cn.hangtag.framework.security.core.util.SecurityFrameworkUtils;
import cn.hangtag.module.oms.controller.admin.saleorder.front.vo.SaleOrderFollowerUserVO;
import cn.hangtag.module.oms.controller.admin.saleorder.vo.*;
import cn.hangtag.module.oms.convert.saleorder.SaleOrderConvert;
import cn.hangtag.module.oms.dal.dataobject.brand.BrandDO;
import cn.hangtag.module.oms.dal.dataobject.customer.CustomerDO;
import cn.hangtag.module.oms.dal.dataobject.saleorder.SaleOrderDO;
import cn.hangtag.module.oms.service.brand.BrandService;
import cn.hangtag.module.oms.service.customer.CustomerService;
import cn.hangtag.module.oms.service.saleorder.SaleOrderService;
import cn.hangtag.module.system.api.user.AdminUserApi;
@ -50,6 +52,8 @@ public class AppSaleOrderController{
@Resource
private CustomerService customerService;
@Resource
private BrandService brandService;
@Resource
private AdminUserApi adminUserApi;
@PostMapping("/create")
@ -85,11 +89,12 @@ public class AppSaleOrderController{
List<cn.hangtag.module.oms.dal.dataobject.saleorderentry.SaleOrderEntryDO> entrys = saleOrderService.getSaleOrderEntryListByParentId(id);
CustomerDO customer = customerService.getCustomer(saleOrder.getCustomerId());
BrandDO brand = brandService.getBrand(saleOrder.getBrandId());
// 1.2 获取修改人
AdminUserRespDTO updater = adminUserApi.getUser(NumberUtils.parseLong(saleOrder.getUpdater()));
AdminUserRespDTO auditor = adminUserApi.getUser(NumberUtils.parseLong(saleOrder.getAuditor()));
return success(SaleOrderConvert.INSTANCE.convert(saleOrder,entrys,customer,updater,auditor));
return success(SaleOrderConvert.INSTANCE.convert(saleOrder,entrys,customer,brand,updater,auditor));
//return success(BeanUtils.toBean(saleOrder, SaleOrderRespVO.class));
}

View File

@ -2,7 +2,9 @@ package cn.hangtag.module.oms.controller.admin.saleorder;
import cn.hangtag.framework.common.util.number.NumberUtils;
import cn.hangtag.module.oms.convert.saleorder.SaleOrderConvert;
import cn.hangtag.module.oms.dal.dataobject.brand.BrandDO;
import cn.hangtag.module.oms.dal.dataobject.customer.CustomerDO;
import cn.hangtag.module.oms.service.brand.BrandService;
import cn.hangtag.module.oms.service.customer.CustomerService;
import cn.hangtag.module.system.api.user.AdminUserApi;
import cn.hangtag.module.system.api.user.dto.AdminUserRespDTO;
@ -49,6 +51,8 @@ public class SaleOrderController {
@Resource
private CustomerService customerService;
@Resource
private BrandService brandService;
@Resource
private AdminUserApi adminUserApi;
@PostMapping("/create")
@ -88,11 +92,12 @@ public class SaleOrderController {
List<SaleOrderEntryDO> entrys = saleOrderService.getSaleOrderEntryListByParentId(id);
CustomerDO customer = customerService.getCustomer(saleOrder.getCustomerId());
BrandDO brand = brandService.getBrand(saleOrder.getBrandId());
// 1.2 获取修改人
AdminUserRespDTO updater = adminUserApi.getUser(NumberUtils.parseLong(saleOrder.getUpdater()));
AdminUserRespDTO auditor = adminUserApi.getUser(NumberUtils.parseLong(saleOrder.getAuditor()));
return success(SaleOrderConvert.INSTANCE.convert(saleOrder,entrys,customer,updater,auditor));
return success(SaleOrderConvert.INSTANCE.convert(saleOrder,entrys,customer,brand,updater,auditor));
//return success(BeanUtils.toBean(saleOrder, SaleOrderRespVO.class));
}

View File

@ -2,6 +2,7 @@ package cn.hangtag.module.oms.controller.admin.saleorder.vo;
import cn.hangtag.framework.excel.core.annotations.DictFormat;
import cn.hangtag.framework.excel.core.convert.DictConvert;
import cn.hangtag.module.oms.controller.admin.brand.vo.BrandRespVO;
import cn.hangtag.module.oms.controller.admin.customer.vo.CustomerRespVO;
import cn.hangtag.module.oms.dal.dataobject.customer.CustomerDO;
import cn.hangtag.module.oms.enums.DictTypeConstants;
@ -66,6 +67,12 @@ public class SaleOrderRespVO {
@ExcelProperty("更新时间")
private LocalDateTime updateTime;
@Schema(description = "品牌ID")
private Long brandId;
@Schema(description = "品牌名称")
private String brandName;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;

View File

@ -4,8 +4,10 @@ package cn.hangtag.module.oms.convert.saleorder;
import cn.hangtag.module.oms.controller.admin.customer.vo.CustomerRespVO;
import cn.hangtag.module.oms.controller.admin.saleorder.vo.SaleOrderRemarkReqVO;
import cn.hangtag.module.oms.controller.admin.saleorder.vo.SaleOrderRespVO;
import cn.hangtag.module.oms.dal.dataobject.brand.BrandDO;
import cn.hangtag.module.oms.dal.dataobject.customer.CustomerDO;
import cn.hangtag.module.oms.dal.dataobject.saleorder.SaleOrderDO;
import cn.hangtag.module.oms.dal.dataobject.saleorderentry.SaleOrderEntryDO;
import cn.hangtag.module.system.api.user.dto.AdminUserRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
@ -26,6 +28,7 @@ public interface SaleOrderConvert {
@Mapping(source = "emails", target = "emails"),
@Mapping(source = "contractType", target = "contractType"),
@Mapping(source = "currencyType", target = "currencyType"),
@Mapping(source = "brandId", target = "brandId"),
@Mapping(source = "saleContractCode", target = "saleContractCode")
})
SaleOrderRespVO convert(SaleOrderDO bean);
@ -38,17 +41,23 @@ public interface SaleOrderConvert {
default SaleOrderRespVO convert(SaleOrderDO saleOrder, List<cn.hangtag.module.oms.dal.dataobject.saleorderentry.SaleOrderEntryDO> entrys, CustomerDO customer, AdminUserRespDTO updater, AdminUserRespDTO auditor){
default SaleOrderRespVO convert(SaleOrderDO saleOrder, List<cn.hangtag.module.oms.dal.dataobject.saleorderentry.SaleOrderEntryDO> entrys, CustomerDO customer, BrandDO brand, AdminUserRespDTO updater, AdminUserRespDTO auditor){
SaleOrderRespVO orderVO = convert(saleOrder);
// 处理客户信息
orderVO.setCustomer(convert(customer));
if(brand!=null){
orderVO.setBrandName(brand.getName());
}
if(updater!=null){
orderVO.setUpdaterName(updater.getNickname());
}
if(auditor!=null){
orderVO.setAuditorName(auditor.getNickname());
}
for (SaleOrderEntryDO entry : entrys) {
entry.setItemKey(entry.getId()+"");
}
orderVO.setEntrys(entrys);
return orderVO;
}

View File

@ -27,6 +27,8 @@ public class SaleOrderEntryDO extends BaseDO {
*/
@TableId
private Long id;
@TableField(exist = false)
private String itemKey;
/**
* 主表id
*/
@ -35,6 +37,10 @@ public class SaleOrderEntryDO extends BaseDO {
* 物料id
*/
private Long materialId;
/**
* 物料编码
*/
private String materialNumber;
/**
* 物料名称
*/
@ -71,6 +77,10 @@ public class SaleOrderEntryDO extends BaseDO {
*/
private BigDecimal amount;
/**
* 新增类型
*/
private Integer newType;
//
private LocalDateTime deliveryDate;

View File

@ -703,6 +703,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
.id(FuncUtil.getNextId())
.parentId(order.getId())
.materialId(itemDTO.getProductId())
.materialNumber(itemDTO.getProductCode())
.materialName(itemDTO.getProductName())
.qty(itemDTO.getOrderQty())
.deliveryDate(FuncUtil.timeToLocalDate(itemDTO.getDeliveryDate())).build();

View File

@ -6,6 +6,7 @@ export interface SaleOrderVO {
customerId: number // 客户id
bizdate: Date // 业务日期
remark: string // 备注
brandId: number // 品牌
confirmdate: Date // 确认日期
plansenddate: Date // 计划日期
phone: string // 手机

View File

@ -0,0 +1,70 @@
<template>
<Dialog :title="dialogTitle" append-to-body v-model="dialogVisible">
<Form :disabled="disabled" ref="formRef" :schema="allSchemas.formSchema" :rules="rules" v-loading="formLoading" />
<template #footer>
<el-button v-if="!disabled" @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import {ProductTypeApi,ProductTypeVO} from '@/api/base/producttype'
import { rules, allSchemas } from './config.data'
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formRef = ref() // Ref
const disabled = computed(() => {
return formType.value !== 'create' && formType.value !== 'update'
})
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
//
if (id) {
formLoading.value = true
try {
const data = await ProductTypeApi.getProductType(id)
formRef.value.setValues(data)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
if (!formRef) return
const valid = await formRef.value.getElFormRef().validate()
if (!valid) return
//
formLoading.value = true
try {
const data = formRef.value.formModel as ProductTypeVO
if (formType.value === 'create') {
await ProductTypeApi.createProductType(data)
message.success(t('common.createSuccess'))
} else {
await ProductTypeApi.updateProductType(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
</script>

View File

@ -0,0 +1,50 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
import {useI18n} from "@/hooks/web/useI18n";
const {t} = useI18n()
// 表单校验
export const rules = reactive({
name: [required],
})
// CrudSchema https://doc.iocoder.cn/vue3/crud-schema/
const crudSchemas = reactive<CrudSchema[]>([
{
label: 'id',
field: 'id',
isForm: false,
isTable:false
},
{
label: t('productDialogList.colLabelCode'),
field: 'code',
isSearch: true,
},
{
label: t('productDialogList.colLabelType'),
field: 'productTypeId',
isSearch: true,
},
{
label: t('productDialogList.colLabelCover'),
field: 'cover',
isSearch: false,
},
{
label: t('productDialogList.colLabelName'),
field: 'name',
isSearch: true,
},
{
label: t('productDialogList.colLabelRemark'),
field: 'remark',
isSearch: false,
},
{
label: t('productDialogList.colLabelDetails'),
field: 'details',
isSearch: false,
}
])
export const { allSchemas } = useCrudSchemas(crudSchemas)

View File

@ -0,0 +1,287 @@
<template>
<Dialog
:title="dialogTitle"
width="80%"
append-to-body
v-model="that.visible"
@close="updateVisible(false)">
<div>
<!-- 搜索工作栏 -->
<ContentWrap>
<Search
:expand="true"
:expandField="['productTypeId','name']"
:schema="allSchemas.searchSchema"
:is-col="false"
ref="searchRef"
@search="setSearchParams"
v-model:model="that.queryInfo"
@reset="setSearchParams">
<!-- 新增等操作按钮 -->
<template #productTypeId="{data}">
<div>
<el-select class="w-full min-w-[200px]" v-model="data.productTypeId" clearable placeholder="Please select the product type">
<el-option v-for="item in that.typeList" :key="item.id" :label="item.label" :value="item.id"/>
</el-select>
</div>
</template>
</Search>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<Table
:columns="allSchemas.tableColumns"
:data="tableObject.tableList"
:loading="tableObject.loading"
:selection="true"
ref="tableRef"
@selection-change="selectionChange"
:pagination="{ total: tableObject.total }"
v-model:pageSize="tableObject.pageSize"
v-model:currentPage="tableObject.currentPage"
>
<template #productTypeId="{row}">
<div>{{ getLabel(row.productTypeId) }}</div>
</template>
<template #details="{row}">
<div v-html="row.details"></div>
</template>
<template #cover="{row}">
<div v-if="row.cover">
<el-image
:src="row.cover"
style="width: 38px; height: 38px"
:preview-src-list="[row.cover]"/>
</div>
<div v-else>-</div>
</template>
</Table>
</ContentWrap>
</div>
<template #footer>
<span class="dialog-footer">
<el-button @click="updateVisible(false,true)">{{ t('common.cancel') }}</el-button>
<el-button type="primary" @click="submit">{{ t('common.ok') }}</el-button>
</span>
</template>
</Dialog>
<!-- 表单弹窗添加/修改 -->
<DataForm ref="formRef" @success="getList"/>
</template>
<script lang="ts" setup name="ProductInfoList">
import {allSchemas} from './config.data'
import Search from '@/components/Search/src/Search.vue'
import {ProductInfoApi} from '@/api/oms/productinfo'
import DataForm from './DataForm.vue'
import {ProductTypeApi} from "@/api/base/producttype";
/** 稿件图片库 */
defineOptions({name: 'ProductInfoList'})
const emit = defineEmits(['update:modelValue', 'update:visible', 'submit']) // success
const {t} = useI18n() //
const dialogTitle = ref(t("productDialogList.title")) //
const props = defineProps({
modelValue: {
type: [String],
required: true
},
dataKey: {
type: String,
required: false,
default: 'id'
},
showKey: {
type: String,
required: false,
default: 'label'
},
multiple: {
type: Boolean,
required: false,
default: false
},
placeholder: {
type: String,
required: false,
default: '请选择'
},
width: {
type: String,
required: false,
default: '64px'
},
height: {
type: String,
required: false,
default: '64px'
},
visible: {
type: Boolean,
required: false,
default: false
}
})
const that = reactive({
inputVal: '',
showValue: '',
visible: false,
keyword: '',
typeList: [],
selectRow: [],
queryInfo: {
productTypeId: null,
}
})
const searchRef = ref(null);
const getLabel = (id) => {
const res = that.typeList.find(item => item.id === id);
return res ? res.label : id
}
const openDialog = (filter = {}) => {
that.queryInfo = {
...that.queryInfo,
...filter
}
updateVisible(true);
if (that.typeList.length === 0) {
ProductTypeApi.getProductTypePage({
pageNo: 1,
pageSize: 100,
}).then(res => {
that.typeList = res.list
})
}
}
//
const tmp = computed(() => {
setTimeout(() => {
that.inputVal = toStr(props.modelValue, that.inputVal)
if (that.inputVal) {
initInput();
}
}, 100)
return ''
}, {
deep: true
})
const toStr = (data: any) => {
if (data !== null && data !== undefined) {
return `${data}`
}
return data
}
let map = new Map();
const initInput = async () => {
const dataKey = that.inputVal + ',' + props.dataKey + ',' + props.showKey + ',' + props.multiple;
if (map.has(dataKey)) {
const data = map.get(dataKey)
if (data) {
that.inputVal = data.inputVal
that.showValue = data.showValue
console.log('缓存数据', data)
return;
}
}
const ids = that.inputVal.split(",");
let tmpInput = [];
let tmpShow = [];
debugger
for (let i = 0; i < ids.length; i++) {
debugger;
const data = await ProductTypeApi.getProductType(ids[i])
tmpInput.push(data[props.dataKey]);
tmpShow.push(data[props.showKey]);
}
that.inputVal = tmpInput.join(',');
that.showValue = tmpShow.join(',');
map.set(dataKey, {
inputVal: that.inputVal,
showValue: that.showValue
})
}
watch(() => props.visible, (newVal) => {
that.visible = newVal;
})
const updateVisible = (visible: boolean, clearInput = false) => {
that.visible = visible;
emit("update:visible", visible)
if (that.visible) {
setTimeout(() => {
searchRef.value.search()
}, 100)
}
}
defineExpose({openDialog})
const submit = () => {
updateValue();
updateVisible(false)
emit("submit", that.selectRow)
}
const updateValue = () => {
emit("update:modelValue", that.inputVal)
}
//
const selectionChange = (row) => {
that.selectRow = row
}
const {tableObject, tableMethods} = useTable({
getListApi: ProductInfoApi.getProductInfoPage, //
delListApi: ProductInfoApi.deleteProductInfo //
})
//
const {getList, setSearchParams} = tableMethods
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = (id: number) => {
tableMethods.delList(id, false)
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>
<style lang="scss" scoped>
:deep(.el-input__wrapper) {
position: relative;
.el-input__inner {
padding-right: 18px;
}
.el-input__suffix {
position: absolute;
right: 8px;
top: 50%;
transform: translateY(-50%);
}
}
</style>

View File

@ -22,25 +22,25 @@
<!-- 订单信息 -->
<el-descriptions title="订单信息">
<el-descriptions-item label="订单号: " width="1000px">{{ formData.billno }}</el-descriptions-item>
<!-- <el-descriptions-item label="合约类型: " width="1000px" v-if="formData.billStatus == 'B'">
<template v-slot:label>
<span>合约类型<span style="color: red;">*</span></span>
</template>
<el-select
v-model="formData.contractType"
placeholder="请选择合约类型"
clearable
class="!w-300px"
>
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.OMS_CONTRACT_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-descriptions-item>
<el-descriptions-item label="合约类型: " width="1000px" v-else>{{ formData.contractType }}</el-descriptions-item>-->
<!-- <el-descriptions-item label="合约类型: " width="1000px" v-if="formData.billStatus == 'B'">
<template v-slot:label>
<span>合约类型<span style="color: red;">*</span></span>
</template>
<el-select
v-model="formData.contractType"
placeholder="请选择合约类型"
clearable
class="!w-300px"
>
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.OMS_CONTRACT_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-descriptions-item>
<el-descriptions-item label="合约类型: " width="1000px" v-else>{{ formData.contractType }}</el-descriptions-item>-->
<el-descriptions-item label="销售合约号: " width="1000px" v-if="formData.billStatus == 'B'">
<template v-slot:label>
<span>销售合约号<span style="color: red;">*</span></span>
@ -48,7 +48,8 @@
<el-input v-model="formData.saleContractCode" placeholder="请输入销售合约号" class="!w-300px" />
</el-descriptions-item>
<el-descriptions-item label="销售合约号: " width="1000px" v-else>{{ formData.saleContractCode }}</el-descriptions-item>
<el-descriptions-item label="业务日期: " width="500px">{{ formatDate(formData.bizdate,'YYYY-MM-DD') }}</el-descriptions-item>
<el-descriptions-item label="品牌: " width="500px">{{ formData.brandName }}</el-descriptions-item>
<el-descriptions-item label="业务日期: ">{{ formatDate(formData.bizdate,'YYYY-MM-DD') }}</el-descriptions-item>
<el-descriptions-item label="确认日期: " >{{ formatDate(formData.confirmdate,'YYYY-MM-DD') }}</el-descriptions-item>
<el-descriptions-item label="计划日期: " >{{ formatDate(formData.plansenddate,'YYYY-MM-DD') }}</el-descriptions-item>
<el-descriptions-item label="手机: ">{{ formData.phone }}</el-descriptions-item>
@ -84,9 +85,9 @@
<el-descriptions-item label="订单状态: ">
<dict-tag :type="DICT_TYPE.OMS_BILL_STATUS" :value="formData.billStatus" />
</el-descriptions-item>
<!-- <el-descriptions-item label="订单状态: ">
<dict-tag :type="DICT_TYPE.OMS_ORDER_STATUS" :value="formData.orderStatus" />
</el-descriptions-item>-->
<!-- <el-descriptions-item label="订单状态: ">
<dict-tag :type="DICT_TYPE.OMS_ORDER_STATUS" :value="formData.orderStatus" />
</el-descriptions-item>-->
<el-descriptions-item v-if="formData.billStatus == 'AA' " label="驳回原因: ">{{ formData?.rejectReason }}</el-descriptions-item>
<el-descriptions-item v-hasPermi="['oms:sale-order:update']" label-class-name="no-colon">
<!-- 待发货 -->
@ -113,17 +114,23 @@
</el-button>
</template>
</el-descriptions-item>
<!-- <el-descriptions-item>
<template #label><span style="color: red">提醒: </span></template>
买家付款成功后货款将直接进入您的商户号微信支付宝<br />
请及时关注你发出的包裹状态确保可以配送至买家手中 <br />
如果买家表示没收到货或货物有问题请及时联系买家处理友好协商
</el-descriptions-item>-->
<!-- <el-descriptions-item>
<template #label><span style="color: red">提醒: </span></template>
买家付款成功后货款将直接进入您的商户号微信支付宝<br />
请及时关注你发出的包裹状态确保可以配送至买家手中 <br />
如果买家表示没收到货或货物有问题请及时联系买家处理友好协商
</el-descriptions-item>-->
</el-descriptions>
<!-- 商品信息 -->
<el-descriptions title="产品信息">
<template v-slot:title>
<div class="entrysContainer">
<div>产品信息</div>
<el-button type="primary" @click="addProduct" >新增行</el-button>
</div>
</template>
<el-descriptions-item labelClassName="no-colon">
<el-row :gutter="20">
<el-col :span="544">
@ -134,82 +141,94 @@
label-width="0px"
:inline-message="true"
>
<el-table :data="formData.entrys"
border
:on-cell-click="cellClick"
<el-table :data="formData.entrys"
border
:on-cell-click="cellClick"
>
>
<el-table-column label="产品编码" prop="materialName" width="150"/>
<el-table-column label="产品名称" prop="materialName" width="150"/>
<el-table-column label="产品规格" prop="materialSpec" width="150" />
<el-table-column label="数量" width="250" v-if="formData.billStatus == 'B'">
<template #header>
<span>数量</span>
<span style="color:red; margin-right:4px">*</span>
</template>
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.qty`" :rules="itemFormEntrysRules.qty" class="mb-0px!"
v-if="row.billStatus!='C'"
>
<el-table-column label="产品编码" prop="materialNumber" width="150"/>
<el-table-column label="产品名称" prop="materialName" width="150"/>
<el-table-column label="产品规格" prop="materialSpec" width="150" />
<el-table-column label="数量" width="250" v-if="formData.billStatus == 'B'">
<template #header>
<span>数量</span>
<span style="color:red; margin-right:4px">*</span>
</template>
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.qty`" :rules="itemFormEntrysRules.qty" class="mb-0px!"
v-if="row.billStatus!='C'"
>
<el-input-number
style="width: 100%"
v-model.number="row.qty"
:precision="0"
:controls="false"
@change="changeRow(row,'qty')"
placeholder="请输入数量"
/>
</el-form-item>
<span v-else @click="editRow($index)">{{ row.qty }}</span>
</template>
</el-table-column>
<el-table-column label="数量" prop="qty" width="150" v-else/>
<el-table-column label="单价" width="250" v-if="formData.billStatus == 'B'">
<template #header>
<span>单价</span>
<span style="color:red; margin-right:4px">*</span>
</template>
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.price`" :rules="itemFormEntrysRules.price" class="mb-0px!"
v-if="row.billStatus!='C'"
>
<el-input-number
style="width: 100%"
v-model.number="row.price"
:step="0.001"
:controls="false"
@change="changeRow(row,'price')"
placeholder="请输入单价"
/>
</el-form-item>
<span v-else @click="editRow($index)">{{ row.price }}</span>
</template>
</el-table-column>
<el-table-column label="单价" prop="price" width="250" v-else />
<el-table-column label="折扣(%)" prop="discount" width="250" v-if="formData.billStatus == 'B'">
<template #default="{ row, $index }">
<el-input-number
style="width: 100%"
v-model.number="row.qty"
:precision="0"
:controls="false"
@change="changeRow(row,'qty')"
placeholder="请输入数量"
/>
</el-form-item>
<span v-else @click="editRow($index)">{{ row.qty }}</span>
</template>
</el-table-column>
<el-table-column label="数量" prop="qty" width="150" v-else/>
<el-table-column label="单价" width="250" v-if="formData.billStatus == 'B'">
<template #header>
<span>单价</span>
<span style="color:red; margin-right:4px">*</span>
</template>
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.price`" :rules="itemFormEntrysRules.price" class="mb-0px!"
v-if="row.billStatus!='C'"
>
<el-input-number
style="width: 100%"
v-model.number="row.price"
:step="0.001"
:controls="false"
@change="changeRow(row,'price')"
placeholder="请输入单价"
/>
</el-form-item>
<span v-else @click="editRow($index)">{{ row.price }}</span>
</template>
</el-table-column>
<el-table-column label="单价" prop="price" width="250" v-else />
<el-table-column label="折扣(%)" prop="discount" width="250" v-if="formData.billStatus == 'B'">
<template #default="{ row, $index }">
<el-input-number
style="width: 100%"
v-if="row.billStatus!='C'"
v-model.number="row.discount"
:step="0.001"
:controls="false"
min="0"
max="100"
@change="changeRow(row,'discount')"
placeholder="请输入折扣(%)"
/>
<span v-else @click="editRow($index)">{{ row.discount }}</span>
</template>
</el-table-column>
<el-table-column label="折扣(%)" prop="discount" width="250" v-else />
v-model.number="row.discount"
:step="0.001"
:controls="false"
min="0"
max="100"
@change="changeRow(row,'discount')"
placeholder="请输入折扣(%)"
/>
<span v-else @click="editRow($index)">{{ row.discount }}</span>
</template>
</el-table-column>
<el-table-column label="折扣(%)" prop="discount" width="250" v-else />
<el-table-column label="金额" prop="amount" width="250" />
<!-- <el-table-column label="合计" prop="payPrice" width="150">
<template #default="{ row }">{{ fenToYuan(row.payPrice) }}</template>
</el-table-column>-->
</el-table>
<el-table-column label="金额" prop="amount" width="250" align="center" />
<!-- <el-table-column label="合计" prop="payPrice" width="150">
<template #default="{ row }">{{ fenToYuan(row.payPrice) }}</template>
</el-table-column>-->
<el-table-column label="操作列" width="100">
<template #default="scope">
<el-button
link
type="danger"
@click="delRow(scope.row)"
>
<Icon icon="ep:delete" />
删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-form>
</el-col>
<el-col :span="10" />
@ -217,6 +236,7 @@
</el-descriptions-item>
</el-descriptions>
<!-- 订单信息 -->
<el-descriptions title="发票信息">
<el-descriptions-item label="发票抬头: " width="1000px">{{ formData.invoiceCode }}</el-descriptions-item>
@ -240,6 +260,7 @@
<!-- 各种操作的弹窗 -->
<OrderUpdateRemarkForm ref="updateRemarkForm" @success="getDetail" />
<OrderUpdateAddressForm ref="updateAddressFormRef" @success="getDetail" />
<ProductInfoList ref="productInfoListRef" @submit="submit"/>
</template>
<script lang="ts" setup>
import { getIntDictOptions, getStrDictOptions, DICT_TYPE } from '@/utils/dict'
@ -247,6 +268,7 @@ import { fenToYuan } from '@/utils'
import { formatDate } from '@/utils/formatTime'
import OrderUpdateRemarkForm from '@/views/oms/saleorder/form/OrderUpdateRemarkForm.vue'
import OrderUpdateAddressForm from '@/views/oms/saleorder/form/OrderUpdateAddressForm.vue'
import ProductInfoList from '@/components/ProductInfoList/index.vue'
import { useTagsViewStore } from '@/store/modules/tagsView'
import { propTypes } from '@/utils/propTypes'
import {SaleOrderApi, SaleOrderVO} from "@/api/oms/saleorder";
@ -270,6 +292,7 @@ const itemFormEntrysRef = ref() // 表单 Ref
const itemFormEntrysRules = reactive({
price: [{ required: true, message: '单价不能为空', trigger: 'blur' }],
qty: [{ required: true, message: '单价不能为空', trigger: 'blur' }],
})
@ -286,6 +309,7 @@ const updateAddress = () => {
}
const changeRow = async (row,key:string) => {
debugger
if('price' == key || 'discount' == key || 'qty' == key){
let price = row.price
let qty = row.qty
@ -295,6 +319,58 @@ const changeRow = async (row,key:string) => {
//100*(1-(2/100))
}
}
const that = reactive({
tableData: [],
selectRow: null,
isBatch: true,
planDate: true,
plansenddate: true,
filterParam: {
brandId: '',
},
})
const productInfoListRef = ref(null);
const addProduct = () => {
that.filterParam.brandId = formData.value.brandId
productInfoListRef.value.openDialog(that.filterParam)
}
const submit = (data) => {
for (let i = 0; i < data.length; i++) {
addRow(data[i])
}
}
const addRow = (row) => {
for (let i = 0; i < that.tableData.length; i++) {
if (that.tableData[i].productId === row.id) {
useMessage().notifyError("已跳过重复产品")
return
}
}
// @ts-ignore
formData.value.entrys.push({
itemKey: Math.random().toString(36).substring(2),
materialId: row.id,
materialNumber: row.code,
materialName: row.name,
producer: row.producer,
newType: 1,
qty: 1,
price: 0,
amount: 0,
discount: 0,
unit: row.unit || 'pcs'
})
useMessage().notifySuccess("新增成功")
//rowChange(that.tableData[that.tableData.length - 1])
}
const delRow = async (row) => {
formData.value.entrys = formData.value.entrys.filter(item => item.itemKey !== row.itemKey)
}
const handleSave = async () => {
try {
if(!formData.value.contractType){
@ -375,6 +451,9 @@ const getDetail = async () => {
close()
}
formData.value = res
/* for (let i = 0; i < formData.value.entrys.length; i++) {
formData.value.entrys[i].itemKey = formData.value.entrys[i].id
}*/
}
}
@ -393,6 +472,16 @@ onMounted(async () => {
})
</script>
<style lang="scss" scoped>
.entrysContainer {
display: flex;
justify-content: space-between;
align-items: center;
width: 1540px; /* 宽度为父容器的80% */
padding: 0px;
margin: 0 auto; /* 可选,用于水平居中 */
}
:deep(.el-descriptions) {
&:not(:nth-child(1)) {
margin-top: 20px;