fix: 预售商品模块更新

This commit is contained in:
lzhizhao 2025-04-27 21:33:30 +08:00
parent 8cab8c35f1
commit 8ee49aab47
1 changed files with 208 additions and 121 deletions

View File

@ -81,7 +81,7 @@
选择是用户可在付尾款前申请退定金申请后自动退无需审核或付尾款时间结束后系统自动退定金
</span>
</el-form-item>
<el-form-item v-if="isAdd" label="选择商品:">
<el-form-item v-if="isAdd" label="选择商品:" prop="productList">
<el-button type="primary" @click="selectProduct"
>点击请选择商品</el-button
>
@ -133,7 +133,7 @@
<span>{{
scope.row.attributeList
? scope.row.attributeList[0].attributeName
: "无"
: '无'
}}</span>
</template>
</el-table-column>
@ -184,7 +184,7 @@
<span v-if="scope.row.isAdvanceSell">{{
scope.row.presalePrice
? scope.row.presalePrice - scope.row.earnestMoney
: ""
: ''
}}</span>
</template>
</el-table-column>
@ -251,7 +251,7 @@
<span>{{
scope.row.attributeList
? scope.row.attributeList[0].attributeName
: "无"
: '无'
}}</span>
</template>
</el-table-column>
@ -302,7 +302,7 @@
<span v-if="scope.row.isAdvanceSell">{{
scope.row.presalePrice
? scope.row.presalePrice - scope.row.earnestMoney
: ""
: ''
}}</span>
</template>
</el-table-column>
@ -337,39 +337,39 @@
</div>
</template>
<script>
import commodity from "./commodity.vue";
import { debounce, cloneDeep } from "lodash";
import commodity from './commodity.vue'
import { debounce, cloneDeep } from 'lodash'
export default {
components: { commodity },
props: {
marketId: {
type: String,
default: "",
default: ''
},
shopId: {
type: String,
default: "",
},
default: ''
}
},
data() {
return {
isAdd: true,
//
modalConfig: {
title: "库存预警设置",
title: '库存预警设置',
show: false,
width: "1200px",
fullscreen: true,
width: '1200px',
fullscreen: true
},
modalData: {},
ruleForm: {
productList: [],
isRefundEarnestMoney: 1, //退 1 2
isRefundEarnestMoney: 1 //退 1 2
},
pickerOptions: {
disabledDate(time) {
return time.getTime() < Date.now();
},
return time.getTime() < Date.now()
}
},
orderTime: [], //
arrears: [], //
@ -379,95 +379,102 @@ export default {
startTime: [
{
required: true,
message: "请选择支付时间",
trigger: ["blur", "change"],
},
message: '请选择支付时间',
trigger: ['blur', 'change']
}
],
balancePaymentStartTime: [
{
required: true,
message: "请选择尾款支付时间",
trigger: "change",
},
message: '请选择尾款支付时间',
trigger: 'change'
}
],
estimatedStartDeliveryTime: [
{
required: true,
message: "请选择预计发货时间",
trigger: "change",
},
message: '请选择预计发货时间',
trigger: 'change'
}
],
isRefundEarnestMoney: [
{
required: true,
message: "请选择定金可退",
trigger: "change",
},
message: '请选择定金可退',
trigger: 'change'
}
],
productList: [
{
required: true,
message: '请选择预售商品',
trigger: 'change'
}
],
presalePrice: [
{
required: true,
message: "请输入预售价格",
trigger: ["blur", "change"],
},
],
},
};
message: '请输入预售价格',
trigger: ['blur', 'change']
}
]
}
}
},
watch: {
"modalConfig.show"(newVal) {
'modalConfig.show'(newVal) {
if (newVal) {
//
setTimeout(() => {
this.$refs.ruleForm.resetFields();
});
this.$refs.ruleForm.resetFields()
})
}
}
},
},
methods: {
queryTableData(pageNo, pageSize) {},
toggle(e) {
if (this.modalConfig.show == false) {
this.modalConfig.show = true;
this.modalConfig.show = true
} else {
this.modalConfig.show = false;
this.modalConfig.show = false
}
if (e) {
this.init(cloneDeep(e));
this.init(cloneDeep(e))
}
return {
add: () => {
this.orderTime = [];
this.arrears = [];
this.delivery = [];
this.orderTime = []
this.arrears = []
this.delivery = []
this.ruleForm = {
startTime: "",
endTime: "",
balancePaymentStartTime: "",
balancePaymentEndTime: "",
estimatedStartDeliveryTime: "",
estimatedEndDeliveryTime: "",
startTime: '',
endTime: '',
balancePaymentStartTime: '',
balancePaymentEndTime: '',
estimatedStartDeliveryTime: '',
estimatedEndDeliveryTime: '',
productList: [],
isRefundEarnestMoney: 1, //退 1 2
};
this.modalConfig.title = "新增预售";
this.isAdd = true;
isRefundEarnestMoney: 1 //退 1 2
}
this.modalConfig.title = '新增预售'
this.isAdd = true
},
update: () => {
this.modalConfig.title = "编辑预售";
this.isAdd = false;
},
};
this.modalConfig.title = '编辑预售'
this.isAdd = false
}
}
},
init(row) {
console.log(row.startTime, row.endTime);
this.orderTime = [row.startTime, row.endTime];
this.arrears = [row.balancePaymentStartTime, row.balancePaymentEndTime];
console.log(row.startTime, row.endTime)
this.orderTime = [row.startTime, row.endTime]
this.arrears = [row.balancePaymentStartTime, row.balancePaymentEndTime]
this.delivery = [
row.estimatedStartDeliveryTime,
row.estimatedEndDeliveryTime,
];
(this.ruleForm = {
row.estimatedEndDeliveryTime
]
this.$set(this, 'ruleForm', {
productId: row.id,
advanceSellId: row.advanceSellId,
startTime: row.startTime,
@ -478,116 +485,196 @@ export default {
estimatedStartDeliveryTime: row.estimatedStartDeliveryTime,
estimatedEndDeliveryTime: row.estimatedEndDeliveryTime,
isRefundEarnestMoney: row.isRefundEarnestMoney,
productSpecificationList: row.productSpecificationList,
}),
console.log(this.orderTime, this.arrears, this.delivery);
productSpecificationList: row.productSpecificationList
})
// (this.ruleForm = {
// productId: row.id,
// advanceSellId: row.advanceSellId,
// startTime: row.startTime,
// name: row.name,
// endTime: row.endTime,
// balancePaymentStartTime: row.balancePaymentStartTime,
// balancePaymentEndTime: row.balancePaymentEndTime,
// estimatedStartDeliveryTime: row.estimatedStartDeliveryTime,
// estimatedEndDeliveryTime: row.estimatedEndDeliveryTime,
// isRefundEarnestMoney: row.isRefundEarnestMoney,
// productSpecificationList: row.productSpecificationList,
// }),
console.log(this.orderTime, this.arrears, this.delivery)
// this.ruleForm = row;
},
//
getOrderTime(e) {
if (e) {
console.log(e);
this.ruleForm.startTime = e[0];
this.ruleForm.endTime = e[1];
console.log(e)
this.ruleForm.startTime = e[0]
this.ruleForm.endTime = e[1]
} else {
this.ruleForm.startTime = "";
this.ruleForm.endTime = "";
this.ruleForm.startTime = ''
this.ruleForm.endTime = ''
}
},
//
getArrearsTime(e) {
if (e) {
console.log(e);
this.ruleForm.balancePaymentStartTime = e[0];
this.ruleForm.balancePaymentEndTime = e[1];
console.log(e)
this.ruleForm.balancePaymentStartTime = e[0]
this.ruleForm.balancePaymentEndTime = e[1]
} else {
this.ruleForm.balancePaymentStartTime = "";
this.ruleForm.balancePaymentEndTime = "";
this.ruleForm.balancePaymentStartTime = ''
this.ruleForm.balancePaymentEndTime = ''
}
},
//
deliveryTime(e) {
if (e) {
console.log(e);
this.ruleForm.estimatedStartDeliveryTime = e[0];
this.ruleForm.estimatedEndDeliveryTime = e[1];
console.log(e)
this.ruleForm.estimatedStartDeliveryTime = e[0]
this.ruleForm.estimatedEndDeliveryTime = e[1]
} else {
this.ruleForm.estimatedStartDeliveryTime = "";
this.ruleForm.estimatedEndDeliveryTime = "";
this.ruleForm.estimatedStartDeliveryTime = ''
this.ruleForm.estimatedEndDeliveryTime = ''
}
},
selectProduct() {
console.log("选择商品", this.marketId, this.shopId);
console.log('选择商品', this.marketId, this.shopId)
this.$nextTick(() => {
this.$refs.commodity.toggle().add({
marketId: this.marketId,
shopId: this.shopId,
});
});
shopId: this.shopId
})
})
},
handleSelectionChange(e) {
console.log(e);
console.log(e)
},
getProduct(row) {
this.ruleForm.productList = row.map((item) => {
this.ruleForm.productList = row.map(item => {
return {
productId: item.id,
name: item.name,
productSpecificationList: item.productSpecificationList,
};
});
console.log(this.ruleForm.productList, this.ruleForm.productList.length);
productSpecificationList: item.productSpecificationList
}
})
console.log(this.ruleForm.productList, this.ruleForm.productList.length)
console.log("获取商品");
},
console.log('获取商品')
}
},
computed: {
modalHandles() {
return [
{
label: "取消",
label: '取消',
handle: () => {
this.toggle();
},
this.toggle()
}
},
{
label: "确认",
type: "primary",
label: '确认',
type: 'primary',
// submit: true,
handle: () => {
if (this.isAdd) {
this.$refs.ruleForm.validate((valid) => {
this.$refs.ruleForm.validate(valid => {
if (valid) {
console.log(valid);
console.log(valid)
if (
this.ruleForm.productList &&
this.ruleForm.productList.length === 0
) {
this.$message.error('请选择商品')
return
}
let pass = true
let count = 0
this.ruleForm.productList.forEach(product => {
if (
product.productSpecificationList &&
product.productSpecificationList.length
) {
count = count + product.productSpecificationList.filter((spec) => spec.isAdvanceSell).length
product.productSpecificationList.forEach(spec => {
if (spec.isAdvanceSell) {
if (!spec.presalePrice) {
pass = false
}
if (!spec.earnestMoney) {
pass = false
}
if (!spec.advanceSellStockNum) {
pass = false
}
}
})
}
})
if (!count) {
this.$message.error('请勾选预售商品规格')
return
}
if (!pass) {
this.$message.error('请填写预售价、定金、预售库存')
return
}
this.$api.preSale
.addPreSaleProducts(this.ruleForm)
.then((res) => {
this.$emit("queryList");
this.toggle();
});
.then(res => {
this.$emit('queryList')
this.toggle()
})
}
});
})
} else {
this.$refs.ruleForm.validate((valid) => {
this.$refs.ruleForm.validate(valid => {
if (valid) {
console.log(valid);
console.log(valid)
if (
this.ruleForm.productSpecificationList &&
this.ruleForm.productSpecificationList.length === 0
) {
this.$message.error('请勾选商品规格')
return
}
let pass = true
let count = this.ruleForm.productSpecificationList.filter((spec) => spec.isAdvanceSell).length
this.ruleForm.productSpecificationList.forEach(spec => {
if (spec.isAdvanceSell) {
if (!spec.presalePrice) {
pass = false
}
if (!spec.earnestMoney) {
pass = false
}
if (!spec.advanceSellStockNum) {
pass = false
}
}
})
if (!count) {
this.$message.error('请勾选预售商品规格')
return
}
if (!pass) {
this.$message.error('请填写预售价、定金、预售库存')
return
}
this.$api.preSale
.updatePreSaleProducts(this.ruleForm)
.then((res) => {
this.$emit("queryList");
this.toggle();
});
.then(res => {
this.$emit('queryList')
this.toggle()
})
}
});
})
}
}
}
]
}
},
},
];
},
},
asyncComputed: {},
};
asyncComputed: {}
}
</script>
<style lang="scss" scoped>
</style>
<style lang="scss" scoped></style>