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