feat:共富商城商品类目和商品信息绑定共富商户
This commit is contained in:
1 parent
8d96247c44
commit
69e7c1f0de
5 files changed
+26
-62
No files matched your search
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<el-select
|
||||
style="width: 100%"
|
||||
v-model="state.selectId"
|
||||
v-model="selectId"
|
||||
:placeholder="props.placeholder"
|
||||
clearable
|
||||
remote-show-suffix
|
||||
@@ -54,7 +54,7 @@ const queryForm = reactive<any>({
|
||||
|
||||
const state = reactive<any>({
|
||||
loading: true,
|
||||
selectId: selectId,
|
||||
selectId: selectId.value,
|
||||
options: [],
|
||||
})
|
||||
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible" :close-on-click-modal="false" draggable>
|
||||
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="商户" prop="merchantId" required>
|
||||
<el-select v-model="form.merchantId" placeholder="请选择商户" clearable>
|
||||
<el-option v-for="merchant in merchantOptions" :key="merchant.value" :label="merchant.label" :value="merchant.value" />
|
||||
</el-select>
|
||||
<el-col :span="14" class="mb20">
|
||||
<el-form-item label="商户" prop="merchantId">
|
||||
<select-mch v-model="form.merchantId" :apiParams="{ types: '5' }" placeholder="请选择商户" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
@@ -58,8 +56,6 @@
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
import { getObj, addObj, putObj, fetchList } from "/@/api/supermarket/mallCategory"
|
||||
import { selectOption as fetchMerchantSelect } from "/@/api/supermarket/mallMerchant"
|
||||
import { rule } from "/@/utils/validate"
|
||||
import { ref, reactive, nextTick, onMounted } from "vue"
|
||||
const emit = defineEmits(["refresh"])
|
||||
|
||||
@@ -90,9 +86,6 @@ const dataRules = ref({
|
||||
// 分类选项
|
||||
const categoryOptions = ref<any[]>([])
|
||||
|
||||
// 商户选项
|
||||
const merchantOptions = ref<any[]>([])
|
||||
|
||||
// 获取所有分类(排除自身)
|
||||
const loadCategories = async () => {
|
||||
const res = await fetchList({ size: 9999 })
|
||||
@@ -102,15 +95,8 @@ const loadCategories = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 加载商户选项
|
||||
const loadMerchantOptions = async () => {
|
||||
const res = await fetchMerchantSelect()
|
||||
merchantOptions.value = res.data || []
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadCategories()
|
||||
loadMerchantOptions()
|
||||
})
|
||||
|
||||
// 打开弹窗
|
||||
@@ -132,7 +118,6 @@ const openDialog = (id: string) => {
|
||||
} else {
|
||||
// 新增时直接加载分类和商户
|
||||
loadCategories()
|
||||
loadMerchantOptions()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +148,6 @@ const getmallCategoryData = (id: string) => {
|
||||
Object.assign(form, res.data)
|
||||
// 编辑时加载分类和商户并排除自己
|
||||
loadCategories()
|
||||
loadMerchantOptions()
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
@sort-change="sortChangeHandle"
|
||||
>
|
||||
<el-table-column type="selection" width="50" align="center" />
|
||||
<el-table-column type="index" label="#" width="40" />
|
||||
<el-table-column type="index" label="#" width="50" />
|
||||
<el-table-column prop="name" label="分类名称" show-overflow-tooltip />
|
||||
<el-table-column prop="sort" label="排序" show-overflow-tooltip />
|
||||
<el-table-column prop="status" label="状态" show-overflow-tooltip>
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
<el-tab-pane label="基本信息" name="basic">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="商户" prop="merchantId" required>
|
||||
<el-select v-model="form.merchantId" placeholder="请选择商户" clearable @change="onMerchantChange">
|
||||
<el-option v-for="merchant in merchantOptions" :key="merchant.value" :label="merchant.label" :value="merchant.value" />
|
||||
</el-select>
|
||||
<el-form-item label="商户" prop="merchantId">
|
||||
<select-mch v-model="form.merchantId" :apiParams="{ types: '5' }" placeholder="请选择商户" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
@@ -232,12 +230,12 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="MallProductDialog">
|
||||
import { watch } from "vue"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
import { getObj, addObj, putObj } from "/@/api/supermarket/mallProduct"
|
||||
import { Plus } from "@element-plus/icons-vue"
|
||||
import { tree as fetchCategoryTree } from "/@/api/supermarket/mallCategory"
|
||||
import { selectOption as fetchMerchantSelect } from "/@/api/supermarket/mallMerchant"
|
||||
|
||||
const emit = defineEmits(["refresh"])
|
||||
|
||||
@@ -253,9 +251,6 @@ const { spu_status } = useDict("spu_status")
|
||||
// 分类选项
|
||||
const categoryOptions = ref<any[]>([])
|
||||
|
||||
// 商户选项
|
||||
const merchantOptions = ref<any[]>([])
|
||||
|
||||
// 加载分类树
|
||||
const loadCategoryTree = async (merchantId?: string) => {
|
||||
if (!merchantId) {
|
||||
@@ -266,20 +261,6 @@ const loadCategoryTree = async (merchantId?: string) => {
|
||||
categoryOptions.value = res.data || []
|
||||
}
|
||||
|
||||
// 加载商户选项
|
||||
const loadMerchantOptions = async () => {
|
||||
const res = await fetchMerchantSelect()
|
||||
merchantOptions.value = res.data || []
|
||||
}
|
||||
|
||||
// 商户选择变化处理
|
||||
const onMerchantChange = (merchantId: string) => {
|
||||
// 清空分类选择
|
||||
form.categoryId = ""
|
||||
// 根据商户ID加载对应的分类树
|
||||
loadCategoryTree(merchantId)
|
||||
}
|
||||
|
||||
// 提交表单数据
|
||||
const form = reactive({
|
||||
id: "",
|
||||
@@ -329,6 +310,17 @@ const dataRules = ref({
|
||||
status: [{ required: true, message: "状态不能为空", trigger: "change" }],
|
||||
})
|
||||
|
||||
// 商户选择变化处理
|
||||
watch(
|
||||
() => form.merchantId,
|
||||
(merchantId: string) => {
|
||||
// 清空分类选择
|
||||
form.categoryId = ""
|
||||
// 根据商户ID加载对应的分类树
|
||||
loadCategoryTree(merchantId)
|
||||
},
|
||||
)
|
||||
|
||||
// 添加SKU
|
||||
const addSku = () => {
|
||||
form.skuList.push({
|
||||
@@ -406,9 +398,6 @@ const openDialog = (id: string) => {
|
||||
addSku()
|
||||
})
|
||||
|
||||
// 重新加载商户选项
|
||||
loadMerchantOptions()
|
||||
|
||||
// 获取mallProduct信息
|
||||
if (id) {
|
||||
form.id = id
|
||||
@@ -548,11 +537,6 @@ function findCategoryPath(options: any[], targetId: any, path: any[] = []): any[
|
||||
return []
|
||||
}
|
||||
|
||||
// 组件挂载时加载商户选项
|
||||
onMounted(() => {
|
||||
loadMerchantOptions()
|
||||
})
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog,
|
||||
|
||||
@@ -209,16 +209,12 @@
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table"
|
||||
import { fetchList, delObjs } from "/@/api/supermarket/mallProduct"
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
import { tree as fetchCategoryTree } from "/@/api/supermarket/mallCategory"
|
||||
import { selectOption as fetchMerchantSelect } from "/@/api/supermarket/mallMerchant"
|
||||
import { select } from "/@/api/wallet/mch-manage"
|
||||
|
||||
// 引入组件
|
||||
const FormDialog = defineAsyncComponent(() => import("./form.vue"))
|
||||
|
||||
// 定义查询字典
|
||||
const { spu_status } = useDict("spu_status")
|
||||
|
||||
// 分类选项
|
||||
const categoryOptions = ref<any[]>([])
|
||||
|
||||
@@ -233,14 +229,14 @@ const loadCategoryTree = async () => {
|
||||
|
||||
// 加载商户选项
|
||||
const loadMerchantOptions = async () => {
|
||||
const res = await fetchMerchantSelect()
|
||||
merchantOptions.value = res.data || []
|
||||
const res = await select({ current: 1, size: 999999, type: 5 })
|
||||
merchantOptions.value = res.data.records || []
|
||||
}
|
||||
|
||||
// 定义变量内容
|
||||
const formDialogRef = ref()
|
||||
const skuDetailVisible = ref(false)
|
||||
const currentProduct = ref(null)
|
||||
const currentProduct = ref<any>(null)
|
||||
|
||||
// 搜索变量
|
||||
const queryRef = ref()
|
||||
@@ -297,8 +293,8 @@ const getCategoryName = (categoryId: any) => {
|
||||
// 根据商户ID查找商户名称
|
||||
const getMerchantName = (merchantId: any) => {
|
||||
if (!merchantId || !merchantOptions.value.length) return "-"
|
||||
const merchant = merchantOptions.value.find((item) => item.value === merchantId)
|
||||
return merchant ? merchant.label : "-"
|
||||
const merchant = merchantOptions.value.find((item) => item.id === merchantId)
|
||||
return merchant ? merchant.name : "-"
|
||||
}
|
||||
|
||||
// 显示SKU详情
|
||||
|
||||
Reference in new issue
Block a user