This commit is contained in:
zmj 2024-05-11 18:35:16 +08:00
parent dc24336da2
commit 18cfc3426a
4 changed files with 197 additions and 1 deletions

View File

@ -23,4 +23,9 @@ export function apiGoodsDelete(params: any) {
// 商品表详情 // 商品表详情
export function apiGoodsDetail(params: any) { export function apiGoodsDetail(params: any) {
return request.get({ url: '/goods/goods/detail', params }) return request.get({ url: '/goods/goods/detail', params })
}
// 商品绑定
export function apiBindGodds(params: any) {
return request.post({ url: '/merchat/merchant/bind_goods', params })
} }

View File

@ -0,0 +1,136 @@
<template>
<div>
<el-card class="!border-none mb-4" shadow="never">
<el-form class="mb-[-16px]" :model="queryParams" inline>
<el-form-item label="商品名称" prop="name">
<el-input class="w-[280px]" v-model="queryParams.name" clearable placeholder="请输入商品名称" />
</el-form-item>
<el-form-item label="商品品牌" prop="brand">
<el-input class="w-[280px]" v-model="queryParams.brand" clearable placeholder="请输入商品品牌" />
</el-form-item>
<el-form-item label="商品单位" prop="unit">
<el-input class="w-[280px]" v-model="queryParams.unit" clearable placeholder="请输入商品单位" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetParams">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="ID" prop="id" width="55" />
<el-table-column label="商品图片" prop="imgs">
<template #default="{ row }">
<el-image style="width:50px;height:50px;" :src="row.imgs" />
</template>
</el-table-column>
<el-table-column label="商品名称" prop="name" show-overflow-tooltip />
<el-table-column label="规格型号" prop="spec" show-overflow-tooltip />
<el-table-column label="商品分类" prop="class_name" show-overflow-tooltip />
<el-table-column label="商品品牌" prop="brand_name" show-overflow-tooltip />
<el-table-column label="商品单位" prop="unit_name" show-overflow-tooltip />
<el-table-column label="购货价格" prop="buy" show-overflow-tooltip />
<el-table-column label="销货价格" prop="sell" show-overflow-tooltip />
<el-table-column label="零售价格" prop="retail" show-overflow-tooltip />
<el-table-column label="标签" prop="sys_labels_text" show-overflow-tooltip />
<!-- <el-table-column label="条形码" prop="code" show-overflow-tooltip /> -->
<!-- <el-table-column label="库存阈值" prop="stocktip" show-overflow-tooltip /> -->
<!-- <el-table-column label="备注信息" prop="data" show-overflow-tooltip /> -->
<!-- <el-table-column label="排序" prop="sort" show-overflow-tooltip /> -->
<el-table-column label="数量" prop="num" width="170">
<template #default="{ row }">
<!-- <el-image style="width:50px;height:50px;" :src="row.imgs" /> -->
<el-input type="number" v-model="row.num" clearable placeholder="请输入数量" />
</template>
</el-table-column>
</el-table>
</div>
<div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" />
</div>
<div class="flex mt-4 justify-end">
<el-button type="primary" @click="bindFn">确认绑定</el-button>
<el-button @click="canceFn">取消</el-button>
</div>
</el-card>
</div>
</template>
<script lang="ts" setup name="goodsLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiGoodsLists, apiGoodsDelete, apiBindGodds } from '@/api/goods'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
import { defineProps } from "vue"
let props = defineProps({
mer_id: Number
})
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const detailRef = shallowRef<InstanceType<typeof DetailPopup>>()
//
const showEdit = ref(false)
const showDetail = ref(false)
const emits = defineEmits(["offPop"]);
//
const queryParams = reactive({
name: '',
class: '',
brand: '',
unit: '',
code: '',
warehouse: '',
retail_name: '',
sort: ''
})
//
const selectData = ref<any[]>([])
//
const handleSelectionChange = (val: any[]) => {
selectData.value = val.map(({ id }) => id)
}
//
const { dictData } = useDictData('')
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiGoodsLists,
params: queryParams
})
const bindFn = async () => {
let list = pager.lists.filter(item => selectData.value.includes(item.id))
let data = {
mer_id: props.mer_id,
bind_data: []
}
list.forEach(item => {
data.bind_data.push({
goods_id: item.id,
nums: item.num
})
})
await apiBindGodds(data)
emits("offPop");
}
const canceFn = () => {
emits("offPop");
}
getLists()
</script>

View File

@ -147,6 +147,9 @@
<el-button link @click="handleDetail(row)"> <el-button link @click="handleDetail(row)">
详情 详情
</el-button> </el-button>
<el-button link @click="showDialog = true, mer_id = row.mer_id">
商品绑定
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -158,13 +161,16 @@
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" /> <edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
<DetailPopup v-if="showDetail" ref="detailRef" :dict-data="dictData" @success="getLists" <DetailPopup v-if="showDetail" ref="detailRef" :dict-data="dictData" @success="getLists"
@close="showDetail = false" /> @close="showDetail = false" />
<el-dialog v-model="showDialog" title="绑定商品" width="70%">
<goodsPop @offPop="showDialog = false" :mer_id="mer_id"></goodsPop>
</el-dialog>
</div> </div>
</template> </template>
<script lang="ts" setup name="merchantLists"> <script lang="ts" setup name="merchantLists">
import { usePaging } from '@/hooks/usePaging' import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions' import { useDictData } from '@/hooks/useDictOptions'
import { apiMerchantLists, apiMerchantDelete, apiMerchantDetail } from '@/api/merchant' import { apiMerchantLists, apiMerchantDelete } from '@/api/merchant'
import feedback from '@/utils/feedback' import feedback from '@/utils/feedback'
import EditPopup from './edit.vue' import EditPopup from './edit.vue'
import DetailPopup from './detail.vue' import DetailPopup from './detail.vue'
@ -174,7 +180,9 @@ const detailRef = shallowRef<InstanceType<typeof EditPopup>>()
// //
const showEdit = ref(false) const showEdit = ref(false)
const showDetail = ref(false) const showDetail = ref(false)
const showDialog = ref(false)
let mer_id;
// //
@ -240,6 +248,8 @@ const handleDetail = async (data) => {
detailRef.value?.setFormData(data) detailRef.value?.setFormData(data)
} }
getLists() getLists()
</script> </script>

View File

@ -225,6 +225,36 @@ const formRules = reactive<any>({
trigger: ["blur"], trigger: ["blur"],
}, },
], ],
spec: [
{
required: true,
message: "请输入规格型号",
trigger: ["blur"],
},
],
sys_labels: [
{
required: true,
message: "请选择标签",
trigger: ["blur"],
},
],
buy: [
{
required: true,
message: "请输入购货价格",
trigger: ["blur"],
},
],
stocktip: [
{
required: true,
message: "请输入库存阈值",
trigger: ["blur"],
},
],
py: [ py: [
{ {
required: true, required: true,
@ -239,6 +269,21 @@ const formRules = reactive<any>({
trigger: ["blur"], trigger: ["blur"],
}, },
], ],
warehouse: [
{
required: true,
message: "请输入库存阈值",
trigger: ["blur"],
},
],
imgs: [
{
required: true,
message: "请上传商品图片",
trigger: ["blur"],
},
],
// brand: [ // brand: [
// { // {
// required: true, // required: true,