Merge branch 'master' of https://gitea.zianxin.com/zax/biz-pc-cloud
This commit is contained in:
commit
984718565e
7 files changed
+77
-49
No files matched your search
@@ -3,13 +3,16 @@
|
|||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
v-model="state.selectId"
|
v-model="state.selectId"
|
||||||
:placeholder="props.placeholder"
|
:placeholder="props.placeholder"
|
||||||
|
:disabled="props.disabled"
|
||||||
clearable
|
clearable
|
||||||
remote-show-suffix
|
|
||||||
filterable
|
filterable
|
||||||
remote
|
remote
|
||||||
|
reserve-keyword
|
||||||
|
default-first-option
|
||||||
|
remote-show-suffix
|
||||||
:remote-method="remoteSearch"
|
:remote-method="remoteSearch"
|
||||||
:loading="state.loading"
|
:loading="state.loading"
|
||||||
@visible-change="(e: boolean) => e && getOptions()"
|
@visible-change="handleVisibleChange"
|
||||||
@change="change"
|
@change="change"
|
||||||
>
|
>
|
||||||
<el-option v-for="item in state.options" :key="item.supplierId" :label="item.supplierName" :value="item.supplierId" />
|
<el-option v-for="item in state.options" :key="item.supplierId" :label="item.supplierName" :value="item.supplierId" />
|
||||||
@@ -18,65 +21,76 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, watch } from "vue"
|
import { reactive, watch } from "vue"
|
||||||
import { fetchList } from "/@/api/supermarketerp/smErpSupplier"
|
import { getSupplierSimpleAll } from "/@/api/supermarketerp/smErpSupplier"
|
||||||
|
|
||||||
const emit = defineEmits(["change"])
|
const emit = defineEmits(["change"])
|
||||||
|
|
||||||
const selectId = defineModel()
|
const selectId = defineModel<string | number>()
|
||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
|
disabled?: boolean
|
||||||
|
isDisplayName?: boolean
|
||||||
}
|
}
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
placeholder: "输入货商搜索",
|
placeholder: "输入供货商名称搜索",
|
||||||
})
|
disabled: false,
|
||||||
|
isDisplayName: false,
|
||||||
const queryForm = reactive<any>({
|
|
||||||
supplierName: "",
|
|
||||||
current: 1,
|
|
||||||
size: 10,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const state = reactive<any>({
|
const state = reactive<any>({
|
||||||
loading: true,
|
loading: false,
|
||||||
selectId: selectId,
|
selectId: selectId,
|
||||||
options: [],
|
options: [],
|
||||||
|
keyword: "",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let searchTimer: ReturnType<typeof setTimeout> | null = null
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
selectId,
|
selectId,
|
||||||
(newVal, oldValue) => {
|
(newVal, oldValue) => {
|
||||||
if (newVal == oldValue) return
|
if (newVal == oldValue) return
|
||||||
state.selectId = newVal
|
state.selectId = newVal
|
||||||
getOptions()
|
loadOptions(state.keyword)
|
||||||
},
|
},
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
)
|
)
|
||||||
|
|
||||||
async function getOptions() {
|
async function loadOptions(keyword = "") {
|
||||||
try {
|
try {
|
||||||
state.loading = true
|
state.loading = true
|
||||||
const _pa = {
|
const params: Record<string, any> = {}
|
||||||
supplierId: selectId.value,
|
if (keyword) {
|
||||||
...queryForm,
|
params.name = keyword
|
||||||
}
|
}
|
||||||
const { data } = await fetchList(_pa)
|
const { data } = await getSupplierSimpleAll(params)
|
||||||
state.options = data.records ?? []
|
let options = Array.isArray(data) ? data : []
|
||||||
|
if (selectId.value && !options.some((item: any) => item.supplierId == selectId.value)) {
|
||||||
|
const { data: selectedData } = await getSupplierSimpleAll({ supplierId: selectId.value })
|
||||||
|
const selected = Array.isArray(selectedData) ? selectedData : []
|
||||||
|
if (selected.length) {
|
||||||
|
options = [...selected, ...options.filter((item: any) => item.supplierId != selectId.value)]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
state.options = options
|
||||||
} finally {
|
} finally {
|
||||||
setTimeout(() => (state.loading = false), 500)
|
state.loading = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function remoteSearch(params: string) {
|
function handleVisibleChange(visible: boolean) {
|
||||||
if (params != queryForm.supplierName) {
|
if (visible) {
|
||||||
queryForm.supplierName = params
|
loadOptions(state.keyword)
|
||||||
getOptions()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clear() {
|
function remoteSearch(keyword: string) {
|
||||||
state.selectId = null
|
state.keyword = keyword
|
||||||
getOptions()
|
if (searchTimer) {
|
||||||
|
clearTimeout(searchTimer)
|
||||||
|
}
|
||||||
|
searchTimer = setTimeout(() => loadOptions(keyword), 300)
|
||||||
}
|
}
|
||||||
|
|
||||||
function change(v: any) {
|
function change(v: any) {
|
||||||
|
|||||||
@@ -368,35 +368,40 @@ const onUnitChange = (row: any) => {
|
|||||||
row.selectedUnitObj.totalAmount = Number((row.quantity * Number(row.selectedUnitObj.realPrice || 0)).toFixed(2))
|
row.selectedUnitObj.totalAmount = Number((row.quantity * Number(row.selectedUnitObj.realPrice || 0)).toFixed(2))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 数量变动
|
// 数量变动:保持实际进价不变,按 数量×实际进价 重算总金额
|
||||||
const onQuantityChange = (row: any, $rowIndex: number) => {
|
const onQuantityChange = (row: any, $rowIndex: number) => {
|
||||||
row.selectedUnitObj.totalAmount = Number(displayPrice(row.quantity * Number(row.selectedUnitObj.purchasePrice || 0), ""))
|
const realPrice = Number(row.selectedUnitObj?.realPrice || 0)
|
||||||
row.selectedUnitObj.realPrice = (row.selectedUnitObj.totalAmount / row.quantity).toFixed(2)
|
const quantity = Number(row.quantity || 0)
|
||||||
|
row.selectedUnitObj.totalAmount = Number((quantity * realPrice).toFixed(2))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 累计总金额变动
|
// 累计总金额变动:反算实际进价
|
||||||
const onTotalAmountChange = (row: any, $rowIndex: number) => {
|
const onTotalAmountChange = (row: any, $rowIndex: number) => {
|
||||||
row.selectedUnitObj.realPrice = (row.selectedUnitObj.totalAmount / row.quantity).toFixed(2)
|
const quantity = Number(row.quantity || 0)
|
||||||
|
if (quantity <= 0) return
|
||||||
|
row.selectedUnitObj.realPrice = Number((Number(row.selectedUnitObj.totalAmount || 0) / quantity).toFixed(2))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 整理数据
|
// 整理数据
|
||||||
const settledTableItems = computed(() => {
|
const settledTableItems = computed(() => {
|
||||||
return vxeTableData.value.map((item: any) => {
|
return vxeTableData.value.map((item: any) => {
|
||||||
// const unit = item.erpUnitVos.find((unitItem: any) => unitItem.id === item.unitId)
|
|
||||||
const selectedUnitObj = item.selectedUnitObj
|
const selectedUnitObj = item.selectedUnitObj
|
||||||
return {
|
const row: Record<string, any> = {
|
||||||
id: item.isNew ? "" : item.id,
|
|
||||||
erpSpuId: item.erpSpuId,
|
erpSpuId: item.erpSpuId,
|
||||||
quantity: item.quantity,
|
quantity: item.quantity,
|
||||||
productNature: item.productNature,
|
productNature: item.productNature,
|
||||||
unitPrice: selectedUnitObj.purchasePrice ? Number(selectedUnitObj?.purchasePrice) : 0,
|
unitPrice: selectedUnitObj.purchasePrice ? Number(selectedUnitObj?.purchasePrice) : 0,
|
||||||
realPrice: selectedUnitObj.realPrice ? storePrice(selectedUnitObj?.realPrice) : 0,
|
realPrice: storePrice(Number(selectedUnitObj?.realPrice || 0)),
|
||||||
retailPrice: selectedUnitObj.retailPrice ? storePrice(selectedUnitObj?.retailPrice) : 0,
|
retailPrice: selectedUnitObj.retailPrice ? storePrice(selectedUnitObj?.retailPrice) : 0,
|
||||||
totalAmount: storePrice(Number(selectedUnitObj?.totalAmount || 0)),
|
totalAmount: storePrice(Number(selectedUnitObj?.totalAmount || 0)),
|
||||||
remark: item.remark,
|
remark: item.remark,
|
||||||
unitId: selectedUnitObj.id,
|
unitId: selectedUnitObj.id,
|
||||||
orderType: baseDataForm.orderType,
|
orderType: baseDataForm.orderType,
|
||||||
}
|
}
|
||||||
|
if (!item.isNew && item.id) {
|
||||||
|
row.id = item.id
|
||||||
|
}
|
||||||
|
return row
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
value-format="YYYY-MM-DD"
|
value-format="YYYY-MM-DD"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="货商" prop="supplierId">
|
<el-form-item label="供货商" prop="supplierId">
|
||||||
<SelectSupermarketSupplier v-model="state.queryForm.supplierId" style="width: 200px" />
|
<SelectSupermarketSupplier v-model="state.queryForm.supplierId" placeholder="请选择供货商" style="width: 200px" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button icon="search" type="primary" @click="getDataList">查询</el-button>
|
<el-button icon="search" type="primary" @click="getDataList">查询</el-button>
|
||||||
@@ -111,6 +111,7 @@ const multiple = ref(true)
|
|||||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||||
queryForm: {
|
queryForm: {
|
||||||
inventoryType: "4",
|
inventoryType: "4",
|
||||||
|
supplierId: undefined,
|
||||||
},
|
},
|
||||||
pageList: fetchList,
|
pageList: fetchList,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -373,34 +373,40 @@ const onUnitChange = (row: any) => {
|
|||||||
row.selectedUnitObj.totalAmount = Number((row.quantity * Number(row.selectedUnitObj.realPrice || 0)).toFixed(2))
|
row.selectedUnitObj.totalAmount = Number((row.quantity * Number(row.selectedUnitObj.realPrice || 0)).toFixed(2))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 数量变动
|
// 数量变动:保持实际进价不变,按 数量×实际进价 重算总金额
|
||||||
const onQuantityChange = (row: any, $rowIndex: number) => {
|
const onQuantityChange = (row: any, $rowIndex: number) => {
|
||||||
row.selectedUnitObj.totalAmount = Number(displayPrice(row.quantity * Number(row.selectedUnitObj.purchasePrice || 0), ""))
|
const realPrice = Number(row.selectedUnitObj?.realPrice || 0)
|
||||||
row.selectedUnitObj.realPrice = (row.selectedUnitObj.totalAmount / row.quantity).toFixed(2)
|
const quantity = Number(row.quantity || 0)
|
||||||
|
row.selectedUnitObj.totalAmount = Number((quantity * realPrice).toFixed(2))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 累计总金额变动
|
// 累计总金额变动:反算实际进价
|
||||||
const onTotalAmountChange = (row: any, $rowIndex: number) => {
|
const onTotalAmountChange = (row: any, $rowIndex: number) => {
|
||||||
row.selectedUnitObj.realPrice = (row.selectedUnitObj.totalAmount / row.quantity).toFixed(2)
|
const quantity = Number(row.quantity || 0)
|
||||||
|
if (quantity <= 0) return
|
||||||
|
row.selectedUnitObj.realPrice = Number((Number(row.selectedUnitObj.totalAmount || 0) / quantity).toFixed(2))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 整理table数据
|
// 整理table数据
|
||||||
const settledTableItems = computed(() => {
|
const settledTableItems = computed(() => {
|
||||||
return vxeTableData.value.map((item: any) => {
|
return vxeTableData.value.map((item: any) => {
|
||||||
const selectedUnitObj = item.selectedUnitObj
|
const selectedUnitObj = item.selectedUnitObj
|
||||||
return {
|
const row: Record<string, any> = {
|
||||||
id: item.isNew ? "" : item.id,
|
|
||||||
erpSpuId: item.erpSpuId,
|
erpSpuId: item.erpSpuId,
|
||||||
quantity: item.quantity,
|
quantity: item.quantity,
|
||||||
productNature: item.productNature,
|
productNature: item.productNature,
|
||||||
unitPrice: selectedUnitObj.purchasePrice ? Number(selectedUnitObj?.purchasePrice) : 0,
|
unitPrice: selectedUnitObj.purchasePrice ? Number(selectedUnitObj?.purchasePrice) : 0,
|
||||||
realPrice: selectedUnitObj.realPrice ? storePrice(selectedUnitObj?.realPrice) : 0,
|
realPrice: storePrice(Number(selectedUnitObj?.realPrice || 0)),
|
||||||
retailPrice: selectedUnitObj.retailPrice ? storePrice(selectedUnitObj?.retailPrice) : 0,
|
retailPrice: selectedUnitObj.retailPrice ? storePrice(selectedUnitObj?.retailPrice) : 0,
|
||||||
totalAmount: storePrice(Number(selectedUnitObj?.totalAmount || 0)),
|
totalAmount: storePrice(Number(selectedUnitObj?.totalAmount || 0)),
|
||||||
remark: item.remark,
|
remark: item.remark,
|
||||||
unitId: selectedUnitObj.id,
|
unitId: selectedUnitObj.id,
|
||||||
orderType: baseDataForm.orderType,
|
orderType: baseDataForm.orderType,
|
||||||
}
|
}
|
||||||
|
if (!item.isNew && item.id) {
|
||||||
|
row.id = item.id
|
||||||
|
}
|
||||||
|
return row
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
value-format="YYYY-MM-DD"
|
value-format="YYYY-MM-DD"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="货商" prop="supplierId">
|
<el-form-item label="供货商" prop="supplierId">
|
||||||
<SelectSupermarketSupplier v-model="state.queryForm.supplierId" style="width: 200px" />
|
<SelectSupermarketSupplier v-model="state.queryForm.supplierId" placeholder="请选择供货商" style="width: 200px" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button icon="search" type="primary" @click="getDataList">查询</el-button>
|
<el-button icon="search" type="primary" @click="getDataList">查询</el-button>
|
||||||
@@ -114,6 +114,7 @@ const multiple = ref(true)
|
|||||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||||
queryForm: {
|
queryForm: {
|
||||||
inventoryType: "3",
|
inventoryType: "3",
|
||||||
|
supplierId: undefined,
|
||||||
},
|
},
|
||||||
pageList: fetchList,
|
pageList: fetchList,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
<el-col :span="14" class="mb20">
|
<el-col :span="14" class="mb20">
|
||||||
<el-form-item label="分类排序" prop="sort">
|
<el-form-item label="分类排序" prop="sort">
|
||||||
<el-input-number v-model="form.sort" :min="1" :max="1000" :precision="0" />
|
<el-input-number v-model="form.sort" :min="1" :max="1000" :precision="0" />
|
||||||
|
<div class="text-xs text-gray-400 mt-1">数值越小越靠前显示</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
<preview-image :src="scope.row.picUrl" />
|
<preview-image :src="scope.row.picUrl" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="sort" label="分类排序" show-overflow-tooltip />
|
<el-table-column prop="sort" label="分类排序(越小越靠前)" show-overflow-tooltip min-width="160" />
|
||||||
<el-table-column prop="status" label="开启状态" show-overflow-tooltip>
|
<el-table-column prop="status" label="开启状态" show-overflow-tooltip>
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<dict-tag :options="status" :value="scope.row.status" />
|
<dict-tag :options="status" :value="scope.row.status" />
|
||||||
|
|||||||
Reference in new issue
Block a user