|
@@ -531,7 +531,7 @@
|
|
|
:precision="0"
|
|
|
:controls="false"
|
|
|
:min="0"
|
|
|
- @change="calculationAmount()"
|
|
|
+ @change="calculationAmount('quantity')"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</div>
|
|
@@ -737,7 +737,7 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<template #shipment>
|
|
|
- <div style="width: 100%">
|
|
|
+ <!-- <div style="width: 100%">
|
|
|
<el-table
|
|
|
:data="formData.data.contractShipmentList"
|
|
|
style="width: 100%; margin-top: 16px"
|
|
@@ -799,6 +799,92 @@
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
+ </div> -->
|
|
|
+ <div style="width: 100%">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="10">
|
|
|
+ <el-form-item label="出货日期" required>
|
|
|
+ <el-date-picker
|
|
|
+ v-model="formData.data.shipmentTime"
|
|
|
+ type="date"
|
|
|
+ placeholder="请选择出货日期"
|
|
|
+ value-format="YYYY-MM-DD"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-table
|
|
|
+ :data="formData.data.contractWaitShipmentList"
|
|
|
+ @selection-change="handleSelectionChange"
|
|
|
+ ref="tableDom"
|
|
|
+ style="margin: 15px 0"
|
|
|
+ >
|
|
|
+ <el-table-column type="selection" width="55" />
|
|
|
+ <el-table-column prop="productCode" label="商品编号" />
|
|
|
+ <el-table-column prop="productName" label="商品名称" />
|
|
|
+ <el-table-column label="出货数量" width="160">
|
|
|
+ <template #default="{ row, $index }">
|
|
|
+ <div style="width: 100%">
|
|
|
+ <el-form-item
|
|
|
+ :prop="
|
|
|
+ 'contractWaitShipmentList.' + $index + '.quantity'
|
|
|
+ "
|
|
|
+ :inline-message="true"
|
|
|
+ >
|
|
|
+ <el-input-number
|
|
|
+ onmousewheel="return false;"
|
|
|
+ v-model="row.quantity"
|
|
|
+ placeholder="请输入数量"
|
|
|
+ style="width: 100%"
|
|
|
+ :precision="0"
|
|
|
+ :controls="false"
|
|
|
+ :min="0"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="waitQuantity" label="剩余数量" />
|
|
|
+ </el-table>
|
|
|
+ <div style="text-align: center">
|
|
|
+ <el-button type="primary" @click="handleAddShipment"
|
|
|
+ >添加</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="14">
|
|
|
+ <div style="padding-left: 10px">
|
|
|
+ <el-table
|
|
|
+ :data="formData.data.contractShipmentList"
|
|
|
+ :span-method="objectSpanMethod"
|
|
|
+ >
|
|
|
+ <el-table-column
|
|
|
+ prop="shipmentTime"
|
|
|
+ label="出货日期"
|
|
|
+ width="155"
|
|
|
+ >
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="productCode" label="商品编码" />
|
|
|
+ <el-table-column prop="productName" label="商品名称" />
|
|
|
+ <el-table-column prop="quantity" label="出货数量" width="160">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ label="操作"
|
|
|
+ width="80"
|
|
|
+ fixed="right"
|
|
|
+ >
|
|
|
+ <template #default="{ row, $index }">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ link
|
|
|
+ @click="clickDelete($index)"
|
|
|
+ >删除</el-button
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
</div>
|
|
|
</template>
|
|
|
</byForm>
|
|
@@ -870,6 +956,7 @@ const formData = reactive({
|
|
|
fileList: [],
|
|
|
packageFileList: [],
|
|
|
contractShipmentList: [],
|
|
|
+ contractWaitShipmentList: [],
|
|
|
},
|
|
|
});
|
|
|
const submit = ref(null);
|
|
@@ -1435,13 +1522,21 @@ const selectProduct = (goods) => {
|
|
|
},
|
|
|
];
|
|
|
}
|
|
|
- formData.data.contractShipmentList.push({
|
|
|
+ //左侧待出货列表
|
|
|
+ formData.data.contractWaitShipmentList.push({
|
|
|
productCode: goods.code,
|
|
|
productId: goods.id,
|
|
|
productName: goods.nameEnglish,
|
|
|
- shipmentTime: "",
|
|
|
quantity: undefined,
|
|
|
+ waitQuantity: "",
|
|
|
});
|
|
|
+ // formData.data.contractShipmentList.push({
|
|
|
+ // productCode: goods.code,
|
|
|
+ // productId: goods.id,
|
|
|
+ // productName: goods.nameEnglish,
|
|
|
+ // shipmentTime: "",
|
|
|
+ // quantity: undefined,
|
|
|
+ // });
|
|
|
ElMessage({
|
|
|
message: "添加成功!",
|
|
|
type: "success",
|
|
@@ -1462,7 +1557,7 @@ const handleRemove = async (index, row) => {
|
|
|
await formData.data.contractProductList.splice(index, 1);
|
|
|
totalAmount();
|
|
|
};
|
|
|
-const calculationAmount = () => {
|
|
|
+const calculationAmount = (att = "") => {
|
|
|
nextTick(() => {
|
|
|
if (
|
|
|
formData.data.contractProductList &&
|
|
@@ -1481,6 +1576,10 @@ const calculationAmount = () => {
|
|
|
}
|
|
|
formData.data.contractProductList[i].amount = money;
|
|
|
}
|
|
|
+ // 重新计算待出货数量
|
|
|
+ if (att) {
|
|
|
+ changeWaitQuantity();
|
|
|
+ }
|
|
|
}
|
|
|
nextTick(() => {
|
|
|
totalAmount();
|
|
@@ -1703,6 +1802,7 @@ const clickSplit = (item) => {
|
|
|
};
|
|
|
const clickDelete = (index) => {
|
|
|
formData.data.contractShipmentList.splice(index, 1);
|
|
|
+ changeWaitQuantity();
|
|
|
};
|
|
|
|
|
|
// 判断当前用户有无销售合同页面权限
|
|
@@ -1846,6 +1946,24 @@ onMounted(() => {
|
|
|
formData.data.contractProductList &&
|
|
|
formData.data.contractProductList.length > 0
|
|
|
) {
|
|
|
+ if (
|
|
|
+ (formData.data.contractWaitShipmentList &&
|
|
|
+ formData.data.contractWaitShipmentList.length == 0) ||
|
|
|
+ formData.data.contractWaitShipmentList == undefined
|
|
|
+ ) {
|
|
|
+ formData.data.contractWaitShipmentList = [];
|
|
|
+ for (let i = 0; i < formData.data.contractProductList.length; i++) {
|
|
|
+ const e = formData.data.contractProductList[i];
|
|
|
+ formData.data.contractWaitShipmentList.push({
|
|
|
+ productCode: e.productCode,
|
|
|
+ productId: e.productId,
|
|
|
+ productName: e.productName,
|
|
|
+ quantity: undefined,
|
|
|
+ waitQuantity: e.quantity,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ changeWaitQuantity();
|
|
|
+ }
|
|
|
for (let i = 0; i < formData.data.contractProductList.length; i++) {
|
|
|
const e = formData.data.contractProductList[i];
|
|
|
if (e.ehsdJson) {
|
|
@@ -1912,6 +2030,105 @@ const checkShow = () => {
|
|
|
showAllData.value = false;
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
+const selectShipmentData = ref([]);
|
|
|
+const tableDom = ref(null);
|
|
|
+const handleSelectionChange = (data) => {
|
|
|
+ selectShipmentData.value = data;
|
|
|
+};
|
|
|
+const handleAddShipment = () => {
|
|
|
+ if (formData.data.shipmentTime) {
|
|
|
+ if (selectShipmentData.value && selectShipmentData.value.length > 0) {
|
|
|
+ // 校验
|
|
|
+ for (let i = 0; i < selectShipmentData.value.length; i++) {
|
|
|
+ const e = selectShipmentData.value[i];
|
|
|
+ if (!Number(e.quantity)) {
|
|
|
+ return ElMessage("请输入出货数量");
|
|
|
+ }
|
|
|
+ if (Number(e.quantity) > Number(e.waitQuantity)) {
|
|
|
+ return ElMessage(`${e.productName} 出货数量不能超过剩余数量`);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // push
|
|
|
+ for (let i = 0; i < selectShipmentData.value.length; i++) {
|
|
|
+ const e = selectShipmentData.value[i];
|
|
|
+ formData.data.contractShipmentList.push({
|
|
|
+ productId: e.productId,
|
|
|
+ productCode: e.productCode,
|
|
|
+ productName: e.productName,
|
|
|
+ quantity: e.quantity,
|
|
|
+ shipmentTime: formData.data.shipmentTime,
|
|
|
+ });
|
|
|
+ e.quantity = 0;
|
|
|
+ }
|
|
|
+ // 清空选择的数据
|
|
|
+ tableDom.value.clearSelection();
|
|
|
+ formData.data.shipmentTime = "";
|
|
|
+ changeWaitQuantity();
|
|
|
+ } else {
|
|
|
+ ElMessage("请勾选数据");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ElMessage("请选择出货日期");
|
|
|
+ }
|
|
|
+};
|
|
|
+const changeWaitQuantity = () => {
|
|
|
+ for (let i = 0; i < formData.data.contractProductList.length; i++) {
|
|
|
+ if (formData.data.contractProductList[i].quantity) {
|
|
|
+ formData.data.contractWaitShipmentList[i].waitQuantity =
|
|
|
+ formData.data.contractProductList[i].quantity;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ formData.data.contractShipmentList &&
|
|
|
+ formData.data.contractShipmentList.length > 0
|
|
|
+ ) {
|
|
|
+ for (let i = 0; i < formData.data.contractWaitShipmentList.length; i++) {
|
|
|
+ const e = formData.data.contractWaitShipmentList[i];
|
|
|
+ let arr = formData.data.contractShipmentList.filter(
|
|
|
+ (x) => x.productId === e.productId
|
|
|
+ );
|
|
|
+ let quantity = 0;
|
|
|
+ for (let j = 0; j < arr.length; j++) {
|
|
|
+ quantity += arr[j].quantity;
|
|
|
+ }
|
|
|
+ e.waitQuantity = e.waitQuantity - quantity;
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+const flitterData = (arr) => {
|
|
|
+ let spanOneArr = [];
|
|
|
+ let concatOne = 0;
|
|
|
+ arr.forEach((item, index) => {
|
|
|
+ if (index === 0) {
|
|
|
+ spanOneArr.push(1);
|
|
|
+ } else {
|
|
|
+ //注意这里的quarterly是表格绑定的字段,根据自己的需求来改
|
|
|
+ if (item.shipmentTime === arr[index - 1].shipmentTime) {
|
|
|
+ //第一列需合并相同内容的判断条件
|
|
|
+ spanOneArr[concatOne] += 1;
|
|
|
+ spanOneArr.push(0);
|
|
|
+ } else {
|
|
|
+ spanOneArr.push(1);
|
|
|
+ concatOne = index;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return {
|
|
|
+ one: spanOneArr,
|
|
|
+ };
|
|
|
+};
|
|
|
+
|
|
|
+const objectSpanMethod = ({ rowIndex, columnIndex }) => {
|
|
|
+ if (columnIndex === 0) {
|
|
|
+ const _row = flitterData(formData.data.contractShipmentList).one[rowIndex];
|
|
|
+ const _col = _row > 0 ? 1 : 0;
|
|
|
+ return {
|
|
|
+ rowspan: _row,
|
|
|
+ colspan: _col,
|
|
|
+ };
|
|
|
+ }
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|