解决合并冲突

This commit is contained in:
2025-12-10 14:20:24 +08:00
parent e1385cb3e6
commit 18f6a845e6
804 changed files with 61881 additions and 13577 deletions

View File

@@ -54,7 +54,7 @@
placeholder=""
clearable
filterable
:disabled="viewStatus == 'view'"
:disabled="viewStatus == 'view' || viewStatus == 'apply'"
style="width: 150px"
>
<el-option
@@ -70,7 +70,7 @@
v-model="receiptHeaderForm.occurrenceTime"
value-format="YYYY-MM-DD HH:mm:ss"
type="datetime"
:disabled="viewStatus == 'view'"
:disabled="viewStatus == 'view' || viewStatus == 'apply'"
/>
</el-form-item>
<el-form-item label="供应商:" prop="supplierId">
@@ -80,7 +80,8 @@
clearable
filterable
style="width: 150px"
:disabled="viewStatus == 'view'"
:disabled="viewStatus == 'view' || viewStatus == 'apply'"
v-if="viewStatus != 'apply' && viewStatus != 'view'"
>
<el-option
v-for="supplier in supplierListOptions"
@@ -89,6 +90,13 @@
:value="supplier.value"
/>
</el-select>
<el-input
placeholder="供应商名称"
v-model="receiptHeaderForm.supplierName"
clearable
disabled
v-else-if="viewStatus == 'view' || viewStatus == 'apply'"
/>
</el-form-item>
<el-form-item label="药品类型:" prop="medicationType">
<el-select
@@ -209,17 +217,17 @@
<el-table-column
label="厂家/产地"
align="center"
key="manufacturer"
prop="manufacturer"
key="manufacturerText"
prop="manufacturerText"
:show-overflow-tooltip="true"
width="160"
>
<template #default="scope">
<el-form-item
:prop="`purchaseinventoryList.${scope.$index}.manufacturer`"
:rules="tableRules.manufacturer"
:prop="`purchaseinventoryList.${scope.$index}.manufacturerText`"
:rules="tableRules.manufacturerText"
>
<el-input v-model="scope.row.manufacturer" placeholder="" disabled />
<el-input v-model="scope.row.manufacturerText" placeholder="" disabled />
</el-form-item>
</template>
</el-table-column>
@@ -503,6 +511,7 @@
<el-input
v-model="scope.row.invoiceNo"
placeholder=""
style="text-align: center !important"
:disabled="viewStatus == 'view'"
/>
</el-form-item>
@@ -632,7 +641,6 @@ import {
getPharmacyList,
getCount,
getDispensaryList,
getMedicineList,
getInitBusNo,
purchaseInventoryApproved,
reject,
@@ -682,7 +690,6 @@ const multiple = ref(true);
const total = ref(0);
const title = ref('');
const visible = ref(false);
const row = ref({});
const openTraceNoDialog = ref(false);
const ypName = ref('');
const rowIndex = ref(-1);
@@ -698,6 +705,7 @@ const forms = reactive({
const receiptHeaderForm = reactive({
busNo: undefined,
occurrenceTime: formatDate(new Date()),
practitionerId: userUserStore.practitionerId,
});
const data = reactive({
@@ -724,11 +732,7 @@ const data = reactive({
statusEnum_enumText: [{ required: true, message: '规格不能为空', trigger: 'blur' }],
unitCode: [{ required: true, message: '计量单位不能为空', trigger: 'blur' }],
purposeLocationId: [{ required: true, message: '目的仓库不能为空', trigger: 'blur' }],
// purposeLocationStoreId: [
// { required: true, message: "货位不能为空", trigger: "blur" },
// ],
lotNumber: [{ required: true, message: '产品批号不能为空', trigger: 'change' }],
// traceNo: [{ required: true, message: "追溯码不能为空", trigger: "blur" }],
startTime: [{ required: true, message: '开始时间不能为空', trigger: 'blur' }],
endTime: [{ required: true, message: '结束时间不能为空', trigger: 'blur' }],
price: [{ required: true, message: '单价不能为空', trigger: 'blur' }],
@@ -761,7 +765,6 @@ const saveRowObject = ref({});
watch(
() => store.currentData,
(newVlaue) => {
console.log(newVlaue, '11212121212121');
if (newVlaue) {
editData.value.editRow = newVlaue?.editRow;
editData.value.item = newVlaue?.item;
@@ -803,26 +806,6 @@ watch(
{ immediate: true }
);
onMounted(() => {
document.addEventListener("click", handleClickOutside);
// 获取源仓库列表(假设 getPharmacyList 返回仓库数据)
getPharmacyList({ type: 'source' }).then(res => {
if (res.code === 200) {
sourceTypeListOptions.value = res.data; // 格式需为 [{id, name}, ...]
}
});
// 获取目的仓库列表
getPharmacyList({ type: 'purpose' }).then(res => {
if (res.code === 200) {
purposeTypeListOptions.value = res.data;
}
});
// 初始化默认仓库数据,使用药房类型(16)
handleChangeLocationType(16);
console.log(route, '!1212');
if (route.query.view) {
viewStatus.value = route.query.view;
// 查看模式下不要清空store数据让watch监听器自然处理
@@ -844,42 +827,138 @@ onUnmounted(() => {
});
function addNewRow() {
// 先校验表头表单
proxy.$refs['receiptHeaderRef'].validate((valid) => {
if (valid) {
// if (data.isAdding) {
// proxy.$message.warning('请先保存当前行后再新增!');
// return;
// }
const newRow = {
rowKey: Date.now(),
id: '',
itemTable: '',
itemQuantity: '',
itemId: '',
unitCode: '',
remake: '',
supplierId: '',
purposeTypeEnum: '',
// 使用表头的仓库作为新增行默认值,减少重复选择
purposeLocationId: receiptHeaderForm.purposeLocationId || null,
purposeLocationStoreId: null,
practitionerId: '',
traceNo: '',
invoiceNo: '',
startTime: '',
endTime: '',
price: '',
totalPrice: '',
sellPrice: '',
minSellPrice: '',
// locationInventoryList: [], // 库房列表
unitList: {}, // 单位列表
isEditing: true, // 标记当前行是否正在编辑
error: false, // 新增 error 字段
isSave: false, // 当前行是否保存
};
form.purchaseinventoryList.push(newRow);
data.isAdding = true; // 设置标志位为 true表示有未保存的
// 检查表格中是否有未保存的行
const unsavedRows = form.purchaseinventoryList.filter((row) => !row.isSave);
if (unsavedRows.length > 0) {
// 校验表格中未保存的行
proxy.$refs['formRef'].validate((tableValid) => {
if (!tableValid) {
proxy.$message.warning('请先完善当前行的必填信息后再添加新行');
return;
}
// 手动检查未保存行的必填字段
const invalidRows = [];
unsavedRows.forEach((row, index) => {
const rowIndex = form.purchaseinventoryList.indexOf(row);
const errors = [];
// 检查必填字段
if (!row.itemId || !row.name) {
errors.push('项目');
}
if (!row.volume) {
errors.push('规格');
}
if (!row.unitCode) {
errors.push('计量单位');
}
if (!row.purposeLocationId) {
errors.push('仓库');
}
if (!row.itemQuantity || row.itemQuantity === '' || row.itemQuantity === 0) {
errors.push('采购数量');
}
if (!row.lotNumber) {
errors.push('产品批号');
}
if (!row.startTime) {
errors.push('生产日期');
}
if (!row.endTime) {
errors.push('有效期至');
}
if (!row.price || row.price === '' || row.price === 0) {
errors.push('采购单价');
}
if (!row.invoiceNo || row.invoiceNo === '') {
errors.push('发票号');
}
if (!row.totalPrice || row.totalPrice === '' || row.totalPrice === 0) {
errors.push('合计金额');
}
if (errors.length > 0) {
invalidRows.push({
rowIndex: rowIndex + 1,
errors: errors.join('、'),
});
}
});
if (invalidRows.length > 0) {
const errorMsg = invalidRows
.map((item) => `${item.rowIndex}行缺少:${item.errors}`)
.join('');
proxy.$message.warning(errorMsg + ',请完善后再添加新行');
return;
}
// 所有校验通过,允许新增
const newRow = {
rowKey: Date.now(),
id: '',
itemTable: '',
itemQuantity: '',
itemId: '',
unitCode: '',
remake: '',
supplierId: '',
purposeTypeEnum: '',
purposeLocationId: null,
purposeLocationStoreId: null,
practitionerId: '',
traceNo: '',
invoiceNo: '-',
startTime: '',
endTime: '',
price: '',
totalPrice: '',
sellPrice: '',
minSellPrice: '',
unitList: {}, // 单位列表
isEditing: true, // 标记当前行是否正在编辑
error: false, // 新增 error 字段
isSave: false, // 当前行是否保存
};
form.purchaseinventoryList.push(newRow);
data.isAdding = true; // 设置标志位为 true表示有未保存的
});
} else {
// 没有未保存的行,直接新增
const newRow = {
rowKey: Date.now(),
id: '',
itemTable: '',
itemQuantity: '',
itemId: '',
unitCode: '',
remake: '',
supplierId: '',
purposeTypeEnum: '',
purposeLocationId: null,
purposeLocationStoreId: null,
practitionerId: '',
traceNo: '',
invoiceNo: '-',
startTime: '',
endTime: '',
price: '',
totalPrice: '',
sellPrice: '',
minSellPrice: '',
unitList: {}, // 单位列表
isEditing: true, // 标记当前行是否正在编辑
error: false, // 新增 error 字段
isSave: false, // 当前行是否保存
};
form.purchaseinventoryList.push(newRow);
data.isAdding = true; // 设置标志位为 true表示有未保存的
}
}
});
}
@@ -899,36 +978,9 @@ function handleBlur(row, index) {
row.supplierId = receiptHeaderForm.supplierId;
row.purposeTypeEnum = receiptHeaderForm.purposeTypeEnum;
}
const handleMouseEnter = (row, column, cell, event) => {
// console.log('鼠标移入行', row);
};
const handleMouseEnter = (row, column, cell, event) => {};
const handleMouseLeave = (row, column, cell, event) => {
// handleBlur(row)
// if(row.id){ // 编辑
// let rows = JSON.parse(JSON.stringify(saveRowObject.value))
// delete rows.unitList
// let rowss= JSON.parse(JSON.stringify(row))
// delete rowss.unitList
// let purchaseinventoryIndex = form.purchaseinventoryList.findIndex(k=>k.id==row.id)
// if(!areObjectsEqual(rowss,rows)){
// handleSave(rowss,purchaseinventoryIndex)
// }
// }else{
// let rows = JSON.parse(JSON.stringify(saveRowObject.value))
// delete rows.unitList
// let rowss= JSON.parse(JSON.stringify(row))
// delete rowss.unitList
// console.log(form.purchaseinventoryList.length,form.purchaseinventoryList,"211111111")
// if(form.purchaseinventoryList.length==1){
// handleSave(row,0)
// }else if(form.purchaseinventoryList.length>1&&saveRowObject.value){
// if(!areObjectsEqual(rowss,rows)){
// handleSave(rowss,form.purchaseinventoryList.length-1)
// }
// }
// }
};
const handleMouseLeave = (row, column, cell, event) => {};
// 点击行时记录当前行
function handleRowClick(row) {
@@ -942,66 +994,9 @@ function handleRowClick(row) {
} else {
currentIndex.value = form.purchaseinventoryList.length - 1;
}
// handleBlur(row);
// if (row.id) {
// // 编辑
// let purchaseinventoryIndex = form.purchaseinventoryList.findIndex((k) => k.id == row.id);
// let rows = JSON.parse(JSON.stringify(forms.purchaseinventoryList[purchaseinventoryIndex]));
// delete rows.unitList;
// let rowss = JSON.parse(JSON.stringify(row));
// delete rowss.unitList;
// console.log(
// purchaseinventoryIndex,
// '编辑',
// forms.purchaseinventoryList[purchaseinventoryIndex],
// rowss,
// rows
// );
// if (!areObjectsEqual(rowss, rows)) {
// handleSave(rowss, purchaseinventoryIndex);
// }
// } else {
// let rows = JSON.parse(JSON.stringify(saveRowObject.value));
// delete rows.unitList;
// let rowss = JSON.parse(JSON.stringify(row));
// delete rowss.unitList;
// console.log(form.purchaseinventoryList.length, form.purchaseinventoryList, '211111111');
// if (form.purchaseinventoryList.length == 1) {
// handleSave(row, 0);
// } else if (form.purchaseinventoryList.length > 1 && saveRowObject.value) {
// if (!areObjectsEqual(rowss, rows)) {
// handleSave(rowss, form.purchaseinventoryList.length - 1);
// }
// }
// }
currentRow.value = row;
}
function areObjectsEqual(obj1, obj2) {
const keys1 = Object.keys(obj1);
const keys2 = Object.keys(obj2);
if (keys1.length !== keys2.length) {
return false;
}
for (let key of keys1) {
if (obj1[key] !== obj2[key]) {
return false;
}
}
return true;
}
// 监听表格外的点击事件
// function handleClickOutside(event) {
// if (tableRef.value && !tableRef.value.$el.contains(event.target)) {
// if (currentRow.value) {
// // handleSave(currentRow.value);
// currentRow.value = null; // 清空当前行
// }
// }
// }
function saveRow(row, index) {
form.purchaseinventoryList[index] = row;
addPurchaseinventory(row).then((response) => {
@@ -1060,12 +1055,12 @@ function selectRow(rowValue, index) {
form.purchaseinventoryList[index].volume = rowValue.volume;
form.purchaseinventoryList[index].minUnitCode = rowValue.minUnitCode;
form.purchaseinventoryList[index].unitCode = rowValue.unitCode;
form.purchaseinventoryList[index].manufacturer = rowValue.manufacturer;
form.purchaseinventoryList[index].manufacturerText = rowValue.manufacturerText;
form.purchaseinventoryList[index].partPercent = rowValue.partPercent;
form.purchaseinventoryList[index].invoiceNo = '-';
form.purchaseinventoryList[index].price = (rowValue.purchaseAmount || 0).toFixed(2);
price.value = (rowValue.purchaseAmount || 0).toFixed(2);
form.purchaseinventoryList[index].unitList = rowValue.unitList[0];
// form.purchaseinventoryList[index].locationInventoryList = locationList.value;
unitMap.value['unitCode'] = rowValue.unitCode;
unitMap.value['minUnitCode'] = rowValue.minUnitCode;
unitMap.value['currentCode'] = rowValue.unitCode;
@@ -1092,9 +1087,7 @@ function handleLocationClick(item, row, index) {
row.unitList.unitCode_dictText,
row.unitList.minUnitCode_dictText
) || 0;
// form.purchaseinventoryList[index].price = (res.data[0].price || 0).toFixed(2);
// price.value = (res.data[0].price || 0).toFixed(2);
// form.purchaseinventoryList[index].traceNo = res.data[0].traceNo || '';
form.purchaseinventoryList[index].itemTable = res.data[0].itemTable || '';
form.purchaseinventoryList[index].startTime = formatDateymd(res.data[0].productionDate) || '';
form.purchaseinventoryList[index].endTime = formatDateymd(res.data[0].expirationDate) || '';
@@ -1106,10 +1099,6 @@ function handleLocationClick(item, row, index) {
: '';
}
});
// form.purchaseinventoryList[index].purposeLocationStoreId =
// item.locationStoreId;
// form.purchaseinventoryList[index].locationStoreName = item.locationStoreName;
//
}
// 处理总数量不整时显示的情况,例 10盒2片
@@ -1234,21 +1223,13 @@ function handleUnitCodeChange(row, index, value) {
unitMap.value['unitCode'] != value &&
unitMap.value['currentCode'] == unitMap.value['unitCode']
) {
console.log(1212121, row, index, value);
// 总库存数
form.purchaseinventoryList[index].quantity = totalQuantity;
// // 采购数量
// form.purchaseinventoryList[index].itemQuantity =
// form.purchaseinventoryList[index].itemQuantity * row.partPercent || 0;
// // 采购单价
// form.purchaseinventoryList[index].price = (price.value / row.partPercent).toFixed(4);
// 采购数量
form.purchaseinventoryList[index].itemQuantity = undefined;
// 采购单价
// form.purchaseinventoryList[index].price = undefined;
} else {
//大单位
console.log(12121212, row, index, value);
form.purchaseinventoryList[index].quantity =
handleTotalQuantity(
totalQuantity,
@@ -1256,11 +1237,8 @@ function handleUnitCodeChange(row, index, value) {
row.unitList.unitCode_dictText,
row.unitList.minUnitCode_dictText
) || 0;
// form.purchaseinventoryList[index].itemQuantity =
// form.purchaseinventoryList[index].itemQuantity / row.partPercent || 0;
// form.purchaseinventoryList[index].price = price.value;
form.purchaseinventoryList[index].itemQuantity = undefined;
// form.purchaseinventoryList[index].price = undefined;
}
form.purchaseinventoryList[index].totalPrice = undefined;
unitMap.value['currentCode'] = value;
@@ -1323,74 +1301,22 @@ function handleSave(row, index) {
}
function addPurchaseinventorys(rowList) {
addPurchaseinventory(JSON.parse(JSON.stringify(rowList))).then((res) => {
// 当前行没有id视为首次新增
// if (!row.id) {
// data.isAdding = false; // 允许新增下一行
// }
if (res.data) {
proxy.$message.success('保存成功!');
form.purchaseinventoryList.map((row, index) => {
console.log(row, 'res.data');
form.purchaseinventoryList[index].id = res.data[index];
form.purchaseinventoryList[index].isSave = true;
});
// forms.purchaseinventoryList[index] = JSON.parse(
// JSON.stringify(form.purchaseinventoryList[index])
// );
// currentEditRow.value = {};
// currentIndex.value = -1;
// saveRowObject.value = JSON.parse(JSON.stringify(row));
console.log(saveRowObject.value, '!@121211');
}
});
}
function handleTraceNoInput(value, row) {
row.traceNo = value.concat(',');
// row.traceNo = row.traceNo.startsWith(',') ? row.traceNo.substring(1) : row.traceNo;
}
// function handleSave(row, index) {
// handleBlur(row);
// proxy.$refs['receiptHeaderRef'].validate((valid) => {
// if (valid) {
// proxy.$refs['formRef'].validate((valid) => {
// if (valid) {
// if (row.itemQuantity == 0) {
// proxy.$message.warning('采购数量不能为0');
// return;
// }
// addPurchaseinventory(row).then((res) => {
// // 当前行没有id视为首次新增
// if (!row.id) {
// data.isAdding = false; // 允许新增下一行
// }
// if (res.data) {
// proxy.$message.success('保存成功!');
// form.purchaseinventoryList[index].id = res.data;
// form.purchaseinventoryList[index].isSave = true;
// // form.purchaseinventoryList[index].isEditing = false;
// forms.purchaseinventoryList[index] = JSON.parse(
// JSON.stringify(form.purchaseinventoryList[index])
// );
// currentEditRow.value = {};
// currentIndex.value = -1;
// saveRowObject.value = JSON.parse(JSON.stringify(row));
// // saveRowObject.value = JSON.parse(JSON.stringify(form.purchaseinventoryList[index]))
// console.log(saveRowObject.value, '!@121211');
// }
// });
// }
// });
// }
// });
// // 保存逻辑...
// }
/** 选择条数 */
function handleSelectionChange(selection) {
console.log(selection, 'selection');
// selectedData.value = selection.map((item) => ({ ...item })); // 存储选择的行数据
ids.value = selection.map((item) => item.id);
selectedRows.value = selection;
single.value = selection.length != 1;
@@ -1442,148 +1368,15 @@ function handlePrintPreview() {
const simpleData = {
supplierName: supplierName || '',
totalAmount: totalAmount.toFixed(2),
receiptNumber: receiptHeaderForm.receiptNumber || '',
receiptDate: receiptHeaderForm.receiptDate || '',
organizationName: receiptHeaderForm.organizationName || '',
// 重新添加药品清单数组,但确保格式安全
purchaseinventoryList: Array.isArray(form.purchaseinventoryList) ? form.purchaseinventoryList.map(item => ({
id: item.id || '',
name: item.name || '',
itemQuantity: item.itemQuantity || 0,
price: item.price || 0,
totalPrice: item.totalPrice || 0,
// 保留其他可能需要的字段
...item
})) : []
};
console.log('简化后的预览数据:', simpleData);
try {
// 直接使用templateJson创建打印
// 避免复杂的模板创建和数据处理逻辑
setTimeout(() => {
try {
// 最简单的方式使用hiprint - 直接调用print2方法
// 只传递必要的数据,不传递复杂嵌套的数组
const printOptions = {
preview: true,
title: '药品采购入库清单',
printer: ''
};
// 方法1: 尝试直接使用templateJson
console.log('尝试直接使用templateJson');
if (typeof hiprint.template !== 'undefined' && typeof hiprint.template.print === 'function') {
hiprint.template.print(templateJson, simpleData, printOptions);
}
// 方法2: 尝试创建简单模板
else if (typeof hiprint.PrintTemplate === 'function') {
console.log('尝试使用PrintTemplate');
const template = new hiprint.PrintTemplate({template: templateJson});
template.print(simpleData, printOptions);
}
// 方法3: 最直接的方式
else {
console.log('尝试最直接的打印方式');
hiprint.print(templateJson, simpleData, printOptions);
}
ElMessage.success('正在生成单据预览,请等待...');
} catch (e) {
console.error('预览执行失败:', e);
ElMessage.error('预览功能执行失败,请稍后重试');
}
}, 50);
} catch (error) {
console.error('预览准备失败:', error);
ElMessage.error('预览失败,请检查配置');
}
}
// 打印单据函数 - 简化实现,与预览函数保持一致
function handlePrint() {
// 检查是否存在数据
if (!form.purchaseinventoryList || form.purchaseinventoryList.length === 0) {
ElMessage.warning('没有数据可打印');
return;
}
// 检查是否所有必填字段都已填写
const hasEmptyFields = form.purchaseinventoryList.some(row => {
return !row.name || !row.itemQuantity || !row.price || !row.totalPrice;
...receiptHeaderForm,
purchaseinventoryList: form.purchaseinventoryList,
});
if (hasEmptyFields) {
ElMessage.warning('请确保所有药品信息完整后再打印');
return;
}
// 安全获取供应商名称
let supplierName = '';
if (supplierListOptions.value && receiptHeaderForm.supplierId) {
const filteredSuppliers = supplierListOptions.value.filter((item) => {
return item.value == receiptHeaderForm.supplierId;
});
supplierName = filteredSuppliers.length > 0 ? filteredSuppliers[0].label : '';
}
// 计算总金额
const totalAmount = form.purchaseinventoryList.reduce((accumulator, currentRow) => {
return accumulator + (Number(currentRow.totalPrice) || 0);
}, 0);
// 重新构建包含药品清单的数据结构
const simpleData = {
supplierName: supplierName || '',
totalAmount: totalAmount.toFixed(2),
receiptNumber: receiptHeaderForm.receiptNumber || '',
receiptDate: receiptHeaderForm.receiptDate || '',
organizationName: receiptHeaderForm.organizationName || '',
// 重新添加药品清单数组,但确保格式安全
purchaseinventoryList: Array.isArray(form.purchaseinventoryList) ? form.purchaseinventoryList.map(item => ({
id: item.id || '',
name: item.name || '',
itemQuantity: item.itemQuantity || 0,
price: item.price || 0,
totalPrice: item.totalPrice || 0,
// 保留其他可能需要的字段
...item
})) : []
};
try {
// 使用与预览函数相同的简化打印逻辑
setTimeout(() => {
try {
const printOptions = {
preview: false, // 直接打印模式
title: '药品采购入库清单',
printer: ''
};
// 尝试多种可能的API调用方式
if (typeof hiprint.template !== 'undefined' && typeof hiprint.template.print === 'function') {
hiprint.template.print(templateJson, simpleData, printOptions);
}
else if (typeof hiprint.PrintTemplate === 'function') {
const template = new hiprint.PrintTemplate({template: templateJson});
template.print(simpleData, printOptions);
}
else {
hiprint.print(templateJson, simpleData, printOptions);
}
ElMessage.success('打印请求已发送');
} catch (e) {
console.error('打印执行失败:', e);
ElMessage.error('打印执行失败,请稍后重试');
}
}, 50);
} catch (error) {
console.error('打印失败:', error);
ElMessage.error('打印失败,请检查配置');
}
const printElements = templateJson;
var hiprintTemplate = new hiprint.PrintTemplate({ template: printElements }); // 定义模板
hiprintTemplate.print2(result, {
printer: 'EPSON LQ-80KFII',
title: '打印标题',
}); //开始打印
}
function deleteSelectedRows() {
@@ -1651,47 +1444,20 @@ function show() {
receiptHeaderForm.busNo = res.data.busNo;
}
});
// supplierListOptions.value = props.supplierListOptions;
// itemTypeOptions.value = props.itemTypeOptions;
// practitionerListOptions.value = props.practitionerListOptions;
// receiptHeaderForm.busNo = props.busNoAdd;
// console.log(purchase_type.value, "purchase_type.value")
// // 设置默认值为字典中的第一个值
// if (purchase_type.value.length > 0) {
// form.value.medicationType = purchase_type.value[0].value;
// }
}
// 显示弹框
function edit() {
data.isAdding = false;
data.isEdit = true;
// reset();
visible.value = true;
// supplierListOptions.value = props.supplierListOptions;
// itemTypeOptions.value = props.itemTypeOptions;
// practitionerListOptions.value = props.practitionerListOptions;
// receiptHeaderForm.busNo = props.busNoAdd;
// 确保数据存在
if (!editData.value.item || editData.value.item.length === 0) {
proxy.$message.warning('没有可编辑的数据');
return;
}
receiptHeaderForm.value = editData.value.item.length > 0 ? editData.value.item[0] : {};
receiptHeaderForm.busNo = editData.value.editRow.supplyBusNo;
// 修改这里优先从详情数据中获取供应商ID如果不存在则从列表数据中获取
receiptHeaderForm.supplierId = (editData.value.item[0] && editData.value.item[0].supplierId) || editData.value.editRow.supplierId;
receiptHeaderForm.supplierId = editData.value.editRow.supplierId;
receiptHeaderForm.supplierName = editData.value.item[0].supplierName;
receiptHeaderForm.practitionerId = editData.value.editRow.practitionerId;
console.log(editData.value.editRow, editData.value, 'editData.value.editRow');
receiptHeaderForm.occurrenceTime = editData.value.item[0].occurrenceTime
? formatDate(editData.value.item[0].occurrenceTime)
: formatDate(new Date());
console.log(editData.value.item[0].occurrenceTime);
console.log(
editData.value.editRow.purposeTypeEnum,
editData.value,
'editData.value.editRow.purposeTypeEnum'
);
//仓库类型
receiptHeaderForm.purposeTypeEnum = editData.value.editRow.purposeTypeEnum
? editData.value.editRow.purposeTypeEnum.toString()
@@ -1710,13 +1476,8 @@ function edit() {
...item,
name: item.itemName,
volume: item.totalVolume,
manufacturer: item.supplierName,
// manufacturerText: item.supplierName,
quantity: item.totalQuantity,
// 确保仓库字段回显
purposeLocationId: item.purposeLocationId || editData.value.editRow?.purposeLocationId || null,
locationStoreName: item.locationStoreName || '',
purposeLocationStoreId: item.purposeLocationStoreId || null,
// locationInventoryList: locationList.value,
startTime: formatDateymd(item.startTime),
endTime: formatDateymd(item.endTime),
applyTime: formatDate(item.applyTime),
@@ -1725,8 +1486,6 @@ function edit() {
});
}, 100);
console.log(form.purchaseinventoryList, 'purchaseinventoryList.value');
console.log(receiptHeaderForm, 'receiptHeaderForm');
loading.value = false;
// 使用 Promise 确保数据加载完成
Promise.resolve().then(() => {
@@ -1794,23 +1553,7 @@ function handelApply() {
pageLoading.value = false;
});
}
function toLastView(visitedViews, view) {
const latestView = visitedViews.slice(-1)[0];
if (latestView) {
router.push(latestView.fullPath);
} else {
if (view.name === 'Dashboard') {
router.replace({ path: '/redirect' + view.fullPath });
} else {
router.push('/');
}
}
}
/** 取消按钮 */
function cancel() {
open.value = false;
reset();
}
/** 提交审核 */
function submitAudit() {
let length = form.purchaseinventoryList.length;
@@ -1832,29 +1575,6 @@ function submitAudit() {
});
}
}
/** 修改按钮操作 */
function handleUpdate(row) {
reset();
form.value = JSON.parse(JSON.stringify(row));
form.value.fwTypeCode = form.value.typeCode;
open.value = true;
title.value = '编辑';
}
/** 删除按钮操作 */
function handleDelete(row) {
const delId = row.id || ids.value;
data.isAdding = false;
proxy.$modal
.confirm('是否确认删除以上数据?')
.then(function () {
return delPurchaseinventory({ ids: delId.join(',') });
})
.then(() => {
proxy.$modal.msgSuccess('删除成功');
})
.catch(() => {});
}
function handleClickOutside() {
if (
currentIndex.value != -1 &&