Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #107 from Jzow/master
Browse files Browse the repository at this point in the history
Add emits success and fix bug #105
  • Loading branch information
Jzow authored Oct 22, 2023
2 parents e5ec10f + 2224a94 commit 31f678a
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 52 deletions.
11 changes: 4 additions & 7 deletions src/views/product/info/components/BatchSetPriceModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
:width="500"
v-model:open="openPriceModal"
:confirm-loading="confirmLoading"
:destroyOnClose="true"
@ok="handleOk"
@cancel="handleCancel"
style="top:30%;height: 30%;">
Expand All @@ -22,10 +23,6 @@ import { ref, reactive, UnwrapRef } from 'vue';
import {Button, Form, FormItem, InputNumber, Modal, Spin} from "ant-design-vue";
import {Rule} from 'ant-design-vue/es/form';
interface FormState {
batchPrice: number;
}
export default {
name: 'BatchSetPriceModal',
components: {
Expand Down Expand Up @@ -72,7 +69,6 @@ export default {
} else if (type === 'low') {
title.value = '最低售价-批量设置';
}
// formRef.value.resetFields();
};
const edit = (record) => {
Expand All @@ -86,12 +82,13 @@ export default {
const handleOk = () => {
const price = batchPrice.value
context.emit('ok', price, batchType.value);
openPriceModal.value = false
batchPrice.value = null;
close();
};
const handleCancel = () => {
batchPrice.value = null;
close();
};
return {
Expand Down
4 changes: 3 additions & 1 deletion src/views/product/info/components/BatchSetStockModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ export default {
const handleOk = () => {
const stockNumber = batchNumber.value
context.emit('ok', stockNumber, batchType.value);
openStockModal.value = false
batchNumber.value = null;
close();
};
const handleCancel = () => {
batchNumber.value = null;
close();
};
Expand Down
153 changes: 110 additions & 43 deletions src/views/product/info/components/ProductInfoModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export interface FormState {
export default {
name: 'ProductInfoModal',
emits: ['success', 'cancel'],
emits: ['success', 'cancel', 'error'],
components: {
'a-modal': Modal,
'a-upload': Upload,
Expand Down Expand Up @@ -592,6 +592,7 @@ export default {
function handleCancel() {
close();
clearData()
context.emit('cancel');
}
Expand All @@ -612,9 +613,46 @@ export default {
loadCategoryTreeData()
loadAttributeTreeData()
loadWarehouse()
clearData()
}
}
function clearData(){
formState.productName = undefined
formState.productStandard = undefined
formState.productModel = undefined
formState.productUnit = undefined
formState.productUnitId = undefined
formState.productColor = undefined
formState.productWeight = undefined
formState.productExpiryNum = undefined
formState.productCategoryId = undefined
formState.enableSerialNumber = undefined
formState.enableBatchNumber = undefined
formState.warehouseShelves = undefined
formState.productManufacturer = undefined
formState.otherFieldOne = undefined
formState.otherFieldTwo = undefined
formState.otherFieldThree = undefined
unitChecked.value = false
manyUnitStatus.value = false
manySkuStatus.value = false
unitStatus.value = false
switchDisabled.value = false
barCodeSwitch.value = false
// 清除所有的sku
manySkuSelected.value = 0
skuOneList.value = []
skuTwoList.value = []
skuThreeList.value = []
skuOne.value = []
skuTwo.value = []
skuThree.value = []
meTable.dataSource = []
stock.dataSource = []
fileList.value = []
}
function unitOnChange(event) {
const isChecked = event.target.checked;
if (isChecked) {
Expand Down Expand Up @@ -724,28 +762,6 @@ export default {
}
}
//修改商品明细中的价格触发计算
// function changeDecimalByValue(row) {
// let unitArr = unitList
// let basicUnit = '', otherUnit = '', ratio = 1, otherUnitTwo = '', ratioTwo = 1, otherUnitThree = '',
// ratioThree = 1
// for (let i = 0; i < unitArr.length; i++) {
// if (unitArr[i].id === this.form.getFieldValue('unitId')) {
// basicUnit = unitArr[i].basicUnit
// otherUnit = unitArr[i].otherUnit
// ratio = unitArr[i].ratio
// if (unitArr[i].otherUnitTwo) {
// otherUnitTwo = unitArr[i].otherUnitTwo
// ratioTwo = unitArr[i].ratioTwo
// }
// if (unitArr[i].otherUnitThree) {
// otherUnitThree = unitArr[i].otherUnitThree
// ratioThree = unitArr[i].ratioThree
// }
// }
// }
// }
function manyUnitOnChange(value) {
let unitArr = unitList.value
let basicUnit = '', otherUnit = '', ratio = 1, otherUnitTwo = '', ratioTwo = 1, otherUnitThree = '', ratioThree = 1
Expand Down Expand Up @@ -870,24 +886,74 @@ export default {
getProductInfoDetail(id).then(res => {
if (res && res.code === '00000') {
let data = res.data
console.info(data)
// if (stockList.length > 0) {
// stock.dataSource.splice(0);
// for (let i = 0; i < stockList.length; i++) {
// const rowData = {
// key: stockList[i].id,
// warehouseId: stockList[i].warehouseId,
// warehouseName: stockList[i].warehouseName,
// initStockQuantity: stockList[i].initStockQuantity,
// lowStockQuantity: stockList[i].lowStockQuantity,
// highStockQuantity: stockList[i].highStockQuantity
// }
// stock.dataSource.push(rowData);
// }
// stock.dataSource.forEach(row => {
// editStock(row.key);
// });
// }
if (data) {
// 将data中的数据赋值给formState
formState.productName = data.productName
formState.productStandard = data.productStandard
formState.productModel = data.productModel
formState.productUnit = data.productUnit
formState.productUnitId = data.productUnitId
formState.productColor = data.productColor
formState.productWeight = data.productWeight
formState.productExpiryNum = data.productExpiryNum
formState.productCategoryId = data.productCategoryId
formState.enableSerialNumber = data.enableSerialNumber
formState.enableBatchNumber = data.enableBatchNumber
formState.warehouseShelves = data.warehouseShelves
formState.productManufacturer = data.productManufacturer
formState.otherFieldOne = data.otherFieldOne
formState.otherFieldTwo = data.otherFieldTwo
formState.otherFieldThree = data.otherFieldThree
if (data.priceList) {
meTable.dataSource.splice(0); // 清空meTableData数组
for (let i = 0; i < data.priceList.length; i++) {
const newRowData = {
key: i,
barCode: data.priceList[i].barCode,
productUnit: data.priceList[i].productUnit,
sku: data.priceList[i].sku,
purchasePrice: data.priceList[i].purchasePrice,
retailPrice: data.priceList[i].retailPrice,
salesPrice: data.priceList[i].salesPrice,
lowSalesPrice: data.priceList[i].lowSalesPrice
}
meTable.dataSource.push(newRowData);
}
meTable.dataSource.forEach(row => {
edit(row.key);
});
}
if (data.stockList) {
stock.dataSource.splice(0);
for (let i = 0; i < data.stockList.length; i++) {
const newRowData = {
key: i,
warehouseId: data.stockList[i].warehouseId,
warehouseName: data.stockList[i].warehouseName,
initStockQuantity: data.stockList[i].initStockQuantity,
lowStockQuantity: data.stockList[i].lowStockQuantity,
highStockQuantity: data.stockList[i].highStockQuantity
}
stock.dataSource.push(newRowData);
}
stock.dataSource.forEach(row => {
editStock(row.key);
});
}
if (data.imageList) {
fileList.value.splice(0);
for (let i = 0; i < data.imageList.length; i++) {
const newRowData = {
uid: i,
name: data.imageList[i].imageName,
status: 'done',
url: data.imageList[i].imageUrl,
thumbUrl: data.imageList[i].imageUrl,
}
fileList.value.push(newRowData);
}
}
}
}
})
}
Expand All @@ -897,6 +963,7 @@ export default {
if(res && res.code === '00000') {
let warehouseList = res.data
if(warehouseList.length > 0) {
stock.dataSource.splice(0);
for(let i = 0; i < warehouseList.length; i++) {
const rowData = {
key: warehouseList[i].id,
Expand Down Expand Up @@ -1190,7 +1257,6 @@ export default {
}
imageList.push(image)
}
console.info(imageList)
const product : AddProductReq = {
productName: formState.productName,
productStandard: formState.productStandard,
Expand All @@ -1216,8 +1282,9 @@ export default {
const addProductResult = await addProduct(product);
if(addProductResult.code === 'P0010') {
createMessage.success('新增商品成功');
closeModal();
context.emit('success');
closeModal();
clearData();
} else {
createMessage.error('新增商品失败');
context.emit('error');
Expand Down
7 changes: 6 additions & 1 deletion src/views/product/info/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</template>
</template>
</BasicTable>
<ProductInfoModal ref="productModalRef" @cancel="handleCancel"/>
<ProductInfoModal ref="productModalRef" @cancel="handleCancel" @success="handleOk"/>
</div>
</template>
<div>
Expand Down Expand Up @@ -113,6 +113,10 @@ export default defineComponent({
reload();
}
async function handleOk() {
reload();
}
return {
registerTable,
handleCreate,
Expand All @@ -122,6 +126,7 @@ export default defineComponent({
handleSuccess,
handleOnStatus,
handleCancel,
handleOk,
productModalRef,
}
}
Expand Down

0 comments on commit 31f678a

Please sign in to comment.