Commit 590631b9 by qinjianhui

fix: 备货单打开弹框修改

parent 63026784
...@@ -259,12 +259,13 @@ ...@@ -259,12 +259,13 @@
</template> </template>
<script setup lang="tsx"> <script setup lang="tsx">
import { ref, computed, watch } from 'vue' import { ref, computed } from 'vue'
import type { ElFormItem, FormInstance, FormRules } from 'element-plus' import type { ElFormItem, FormInstance, FormRules } from 'element-plus'
import { Plus } from '@element-plus/icons-vue' import { Plus } from '@element-plus/icons-vue'
import type { import type {
AddStockingOrderForm, AddStockingOrderForm,
StockingOrderProduct, StockingOrderProduct,
TableData,
} from '@/types/api/supply/stockingOrder' } from '@/types/api/supply/stockingOrder'
import type { CurrencyCodeData, SupplierItem, WarehouseListData } from '@/types' import type { CurrencyCodeData, SupplierItem, WarehouseListData } from '@/types'
import type { userData } from '@/types/api/user' import type { userData } from '@/types/api/user'
...@@ -286,25 +287,19 @@ const calcRowTotalPrice = (row: StockingOrderProduct): string => { ...@@ -286,25 +287,19 @@ const calcRowTotalPrice = (row: StockingOrderProduct): string => {
} }
const props = defineProps<{ const props = defineProps<{
modelValue: boolean
supplierList: SupplierItem[] supplierList: SupplierItem[]
stockKeeperList: userData[] stockKeeperList: userData[]
warehouseList: WarehouseListData[] warehouseList: WarehouseListData[]
currencyList: CurrencyCodeData[] currencyList: CurrencyCodeData[]
editId: number | undefined
editOrderType: string
}>() }>()
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'update:modelValue', value: boolean): void
(e: 'refresh'): void (e: 'refresh'): void
}>() }>()
const visible = computed({ const visible = ref(false)
get: () => props.modelValue, const editOrderType = ref<string>('add')
set: (val) => emit('update:modelValue', val), const editId = ref<number | undefined>(undefined)
})
const formRef = ref<FormInstance>() const formRef = ref<FormInstance>()
const formData = ref<AddStockingOrderForm>({ const formData = ref<AddStockingOrderForm>({
stockingUpManageNo: '', stockingUpManageNo: '',
...@@ -560,9 +555,9 @@ const handleSave = async (isSubmit: boolean = false) => { ...@@ -560,9 +555,9 @@ const handleSave = async (isSubmit: boolean = false) => {
(item) => item.id === stockingUpUserId, (item) => item.id === stockingUpUserId,
)?.account )?.account
const url = const url =
props.editOrderType === 'add' editOrderType.value === 'add'
? 'factory/supply/stockingUpManage/add' ? 'factory/supply/stockingUpManage/add'
: props.editOrderType === 'edit' : editOrderType.value === 'edit'
? `factory/supply/stockingUpManage/update` ? `factory/supply/stockingUpManage/update`
: `factory/supply/stockingUpManage/examine` : `factory/supply/stockingUpManage/examine`
const loading = ElLoading.service({ const loading = ElLoading.service({
...@@ -573,12 +568,12 @@ const handleSave = async (isSubmit: boolean = false) => { ...@@ -573,12 +568,12 @@ const handleSave = async (isSubmit: boolean = false) => {
try { try {
const res = await addStockingOrderApi(url, { const res = await addStockingOrderApi(url, {
...formData.value, ...formData.value,
id: props.editId, id: editId.value,
supplierName, supplierName,
warehouseName, warehouseName,
stockingUpUserName, stockingUpUserName,
totalPrice: totalAmount.value, totalPrice: totalAmount.value,
submission: props.editOrderType === 'audit' ? undefined : isSubmit, submission: editOrderType.value === 'audit' ? undefined : isSubmit,
}) })
if (res.code !== 200) { if (res.code !== 200) {
ElMessage.warning(res.message) ElMessage.warning(res.message)
...@@ -599,7 +594,7 @@ const handleSaveAndSubmit = async () => { ...@@ -599,7 +594,7 @@ const handleSaveAndSubmit = async () => {
} }
const handleReject = async () => { const handleReject = async () => {
if (!props.editId) return if (!editId.value) return
try { try {
const { value: rejectReason } = await ElMessageBox.prompt( const { value: rejectReason } = await ElMessageBox.prompt(
'请输入驳回原因', '请输入驳回原因',
...@@ -626,7 +621,7 @@ const handleReject = async () => { ...@@ -626,7 +621,7 @@ const handleReject = async () => {
try { try {
const res = await rejectedStockingOrderApi({ const res = await rejectedStockingOrderApi({
id: props.editId, id: editId.value,
turnDownReason: rejectReason.trim(), turnDownReason: rejectReason.trim(),
}) })
if (res.code !== 200) return if (res.code !== 200) return
...@@ -658,6 +653,8 @@ const resetForm = () => { ...@@ -658,6 +653,8 @@ const resetForm = () => {
productSku.value = '' productSku.value = ''
productList.value = [] productList.value = []
popoverVisible.value = false popoverVisible.value = false
editId.value = undefined
editOrderType.value = 'add'
} }
const handleSupplierChange = () => { const handleSupplierChange = () => {
formData.value.currencyCode = '' formData.value.currencyCode = ''
...@@ -676,21 +673,24 @@ const getStockingOrderDetailById = async (id: number) => { ...@@ -676,21 +673,24 @@ const getStockingOrderDetailById = async (id: number) => {
return return
} }
formData.value = res.data formData.value = res.data
visible.value = true
} catch (error) { } catch (error) {
console.error(error) console.error(error)
} finally { } finally {
loading.close() loading.close()
} }
} }
watch(visible, (val) => { const open = (row: TableData | null, type: string) => {
if (val) { if (row) {
if (!props.editId) { editId.value = row.id
resetForm() editOrderType.value = type
getStockingOrderDetailById(row.id)
} else { } else {
getStockingOrderDetailById(props.editId) visible.value = true
} resetForm()
} }
}) }
defineExpose({ open })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
v-model="visible" v-model="visible"
title="供应商发货" title="供应商发货"
width="1400px" width="1400px"
top="10vh" top="15vh"
:close-on-click-modal="false" :close-on-click-modal="false"
destroy-on-close destroy-on-close
> >
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
</template> </template>
<script setup lang="tsx"> <script setup lang="tsx">
import { ref, computed, watch } from 'vue' import { ref } from 'vue'
import type { FormInstance } from 'element-plus' import type { FormInstance } from 'element-plus'
import type { import type {
TableData, TableData,
...@@ -129,21 +129,16 @@ import ImageView from '@/components/ImageView.vue' ...@@ -129,21 +129,16 @@ import ImageView from '@/components/ImageView.vue'
import TableView from '@/components/TableView.vue' import TableView from '@/components/TableView.vue'
import { BigNumber } from 'bignumber.js' import { BigNumber } from 'bignumber.js'
const props = defineProps<{ defineProps<{
visible: boolean
selectedRow: TableData | null
warehouseList: WarehouseListData[] warehouseList: WarehouseListData[]
}>() }>()
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'update:visible', value: boolean): void
(e: 'refresh'): void (e: 'refresh'): void
}>() }>()
const visible = computed({ const visible = ref(false)
get: () => props.visible, const currentRow = ref<TableData | null>(null)
set: (val) => emit('update:visible', val),
})
const formRef = ref<FormInstance>() const formRef = ref<FormInstance>()
const formData = ref<AddStockingOrderForm>({ const formData = ref<AddStockingOrderForm>({
...@@ -300,7 +295,7 @@ const handleDispatch = async () => { ...@@ -300,7 +295,7 @@ const handleDispatch = async () => {
}) })
try { try {
const res = await supplierDispatchApi({ const res = await supplierDispatchApi({
manageId: props.selectedRow?.id as number, manageId: currentRow.value?.id as number,
manageNo: formData.value.stockingUpManageNo as string, manageNo: formData.value.stockingUpManageNo as string,
warehouseId: formData.value.warehouseId as number, warehouseId: formData.value.warehouseId as number,
warehouseName: formData.value.warehouseName as string, warehouseName: formData.value.warehouseName as string,
...@@ -324,8 +319,8 @@ const handleDispatch = async () => { ...@@ -324,8 +319,8 @@ const handleDispatch = async () => {
} }
} }
const loadProductList = async () => { const open = async (row: TableData) => {
if (!props.selectedRow?.id) return if (!row?.id) return
const loading = ElLoading.service({ const loading = ElLoading.service({
lock: true, lock: true,
...@@ -334,7 +329,7 @@ const loadProductList = async () => { ...@@ -334,7 +329,7 @@ const loadProductList = async () => {
}) })
try { try {
const res = await getStockingOrderDetailByIdApi(props.selectedRow.id) const res = await getStockingOrderDetailByIdApi(row.id)
if (res.code !== 200) { if (res.code !== 200) {
ElMessage.warning(res.message) ElMessage.warning(res.message)
return return
...@@ -353,17 +348,16 @@ const loadProductList = async () => { ...@@ -353,17 +348,16 @@ const loadProductList = async () => {
currentShipQuantity: undefined, currentShipQuantity: undefined,
})), })),
} }
currentRow.value = row
visible.value = true
} catch (error) { } catch (error) {
console.error(error) console.error(error)
} finally { } finally {
loading.close() loading.close()
} }
} }
watch(visible, (val) => {
if (val && props.selectedRow) { defineExpose({ open })
loadProductList()
}
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -210,18 +210,15 @@ ...@@ -210,18 +210,15 @@
</div> </div>
</div> </div>
<AddStockingOrderDialog <AddStockingOrderDialog
v-model="addDialogVisible" ref="addStockingOrderDialogRef"
:supplier-list="supplierList" :supplier-list="supplierList"
:stock-keeper-list="stockKeeperList" :stock-keeper-list="stockKeeperList"
:warehouse-list="warehouseList" :warehouse-list="warehouseList"
:currency-list="currencyList" :currency-list="currencyList"
:edit-order-type="editOrderType"
:edit-id="selectedRow?.id"
@refresh="onRefresh" @refresh="onRefresh"
/> />
<SupplierDispatchOrderDialog <SupplierDispatchOrderDialog
v-model:visible="supplierDispatchOrderVisible" ref="supplierDispatchOrderDialogRef"
:selected-row="selectedRow"
:warehouse-list="warehouseList" :warehouse-list="warehouseList"
@refresh="onRefresh" @refresh="onRefresh"
/> />
...@@ -456,13 +453,13 @@ const deliveryStatusList = ref([ ...@@ -456,13 +453,13 @@ const deliveryStatusList = ref([
{ label: '部分发货', value: 'partial' }, { label: '部分发货', value: 'partial' },
{ label: '全部发货', value: 'completed' }, { label: '全部发货', value: 'completed' },
]) ])
const editOrderType = ref<string>('add')
const selection = ref<TableData[]>([]) const selection = ref<TableData[]>([])
const rangeTime = ref<string[]>([]) const rangeTime = ref<string[]>([])
const [searchForm, resetSearchForm] = useValue<SearchForm>({} as SearchForm) const [searchForm, resetSearchForm] = useValue<SearchForm>({} as SearchForm)
const treeRef = ref() const treeRef = ref()
const tableRef = ref() const tableRef = ref()
const supplierDispatchOrderVisible = ref(false) const supplierDispatchOrderDialogRef = ref()
const addStockingOrderDialogRef = ref()
const loadWarehouseList = async () => { const loadWarehouseList = async () => {
try { try {
const res = await loadWarehouseListApi() const res = await loadWarehouseListApi()
...@@ -563,13 +560,10 @@ const handleRowClick = (row: TableData) => { ...@@ -563,13 +560,10 @@ const handleRowClick = (row: TableData) => {
} }
const handleOrder = (row: TableData, type: string) => { const handleOrder = (row: TableData, type: string) => {
selectedRow.value = row addStockingOrderDialogRef.value.open(row, type)
editOrderType.value = type
addDialogVisible.value = true
} }
const handleSupplierDispatchOrder = (row: TableData) => { const handleSupplierDispatchOrder = (row: TableData) => {
selectedRow.value = row supplierDispatchOrderDialogRef.value.open(row)
supplierDispatchOrderVisible.value = true
} }
const stockingComplete = async (row: TableData) => { const stockingComplete = async (row: TableData) => {
try { try {
...@@ -585,6 +579,11 @@ const stockingComplete = async (row: TableData) => { ...@@ -585,6 +579,11 @@ const stockingComplete = async (row: TableData) => {
} catch { } catch {
return return
} }
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try { try {
const res = await stockingCompleteApi(row.id) const res = await stockingCompleteApi(row.id)
if (res.code !== 200) return if (res.code !== 200) return
...@@ -593,14 +592,12 @@ const stockingComplete = async (row: TableData) => { ...@@ -593,14 +592,12 @@ const stockingComplete = async (row: TableData) => {
loadTreeData() loadTreeData()
} catch (e) { } catch (e) {
console.error(e) console.error(e)
} finally {
loading.close()
} }
} }
// 新增备货单弹窗
const addDialogVisible = ref(false)
const handleAddOrder = () => { const handleAddOrder = () => {
selectedRow.value = null addStockingOrderDialogRef.value.open(null, 'add')
editOrderType.value = 'add'
addDialogVisible.value = true
} }
const handleSubmitAudit = async () => { const handleSubmitAudit = async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment