(修改商品管理页面,添加商品分类、商品单位、商品来源等字段,并优化部分代码)
This commit is contained in:
parent
855f6fa070
commit
f62f956914
|
@ -23,4 +23,9 @@ export function apiSystemStoreDelete(params: any) {
|
|||
// 门店列表详情
|
||||
export function apiSystemStoreDetail(params: any) {
|
||||
return request.get({ url: '/system_store/systemstore/detail', params })
|
||||
}
|
||||
|
||||
// 根据商品来源获取门店
|
||||
export function apiSourceProductStoreLists(params: any) {
|
||||
return request.get({ url: '/system_store/systemstore/source_product_store_lists', params })
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-form class="mb-[-16px]" :model="queryParams" inline>
|
||||
<el-form-item label="门店名称" prop="name">
|
||||
<el-input class="w-[200px]" v-model="queryParams.name" clearable placeholder="请输入门店名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号码" prop="phone">
|
||||
<el-input class="w-[200px]" v-model="queryParams.phone" 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>
|
||||
<div class="mt-4" v-loading="pager.loading">
|
||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange" :height="300">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="ID" prop="id" show-overflow-tooltip />
|
||||
<el-table-column label="门店名称" prop="name" show-overflow-tooltip />
|
||||
<el-table-column label="手机号码" prop="phone" show-overflow-tooltip />
|
||||
<el-table-column label="详细地址" prop="detailed_address" show-overflow-tooltip />
|
||||
<el-table-column label="门店logo" prop="image" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-image :src="row.image" class="w-[50px] h-[50px]" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否显示" prop="is_show" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ row.is_show ? '显示' : '隐藏' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="flex mt-4 justify-end">
|
||||
<pagination v-model="pager" @change="getLists" />
|
||||
</div>
|
||||
<el-button class="w-full mt-4" type="primary" @click="bindStore">添加门店</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="systemStoreLists">
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
import { useDictData } from '@/hooks/useDictOptions'
|
||||
import { apiSystemStoreLists, apiSystemStoreDelete } from '@/api/system_store'
|
||||
import { timeFormat } from '@/utils/util'
|
||||
import feedback from '@/utils/feedback'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
|
||||
// 查询条件
|
||||
const queryParams = reactive({
|
||||
name: '',
|
||||
phone: ''
|
||||
})
|
||||
|
||||
// 选中数据
|
||||
const selectData = ref<any[]>([])
|
||||
|
||||
// 表格选择后回调事件
|
||||
const handleSelectionChange = (val: any[]) => {
|
||||
selectData.value = val.map(({ id }) => id)
|
||||
}
|
||||
|
||||
// 获取字典数据
|
||||
const { dictData } = useDictData('')
|
||||
|
||||
// 分页相关
|
||||
const { pager, getLists, resetParams, resetPage } = usePaging({
|
||||
fetchFun: apiSystemStoreLists,
|
||||
params: queryParams
|
||||
})
|
||||
|
||||
getLists();
|
||||
|
||||
const emits = defineEmits(["onBindStore"]);
|
||||
// 绑定用户
|
||||
const bindStore = () => {
|
||||
let list = pager.lists.filter(item => selectData.value.includes(item.id));
|
||||
if (!list.length) return ElMessage.error('请先选择门店');
|
||||
emits('onBindStore', list)
|
||||
};
|
||||
</script>
|
|
@ -3,10 +3,12 @@ const defaultSetting = {
|
|||
showLogo: true, // 是否显示logo
|
||||
isUniqueOpened: false, //只展开一个一级菜单
|
||||
sideWidth: 200, //侧边栏宽度
|
||||
sideTheme: 'light', //侧边栏主题
|
||||
// sideTheme: 'light', //侧边栏主题
|
||||
sideTheme: 'dark', //侧边栏主题
|
||||
sideDarkColor: '#1d2124', //侧边栏深色主题颜色
|
||||
openMultipleTabs: true, // 是否开启多标签tab栏
|
||||
theme: '#4A5DFF', //主题色
|
||||
// theme: '#4A5DFF', //主题色
|
||||
theme: '#20B128', //主题色
|
||||
successTheme: '#67c23a', //成功主题色
|
||||
warningTheme: '#e6a23c', //警告主题色
|
||||
dangerTheme: '#f56c6c', //危险主题色
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
<el-form-item label="转账状态" prop="pay_status">
|
||||
<el-input class="w-[280px]" v-model="queryParams.pay_status" clearable placeholder="请输入转账状态" />
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="create_time">
|
||||
<!-- <el-form-item label="创建时间" prop="create_time">
|
||||
<el-input class="w-[280px]" v-model="queryParams.create_time" clearable placeholder="请输入创建时间" />
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||
<el-button @click="resetParams">重置</el-button>
|
||||
|
@ -28,7 +28,7 @@
|
|||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
|
||||
<el-button v-perms="['store_extract.store_extract/add']" type="primary" @click="handleAdd">
|
||||
<!-- <el-button v-perms="['store_extract.store_extract/add']" type="primary" @click="handleAdd">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Plus" />
|
||||
</template>
|
||||
|
@ -40,7 +40,7 @@
|
|||
@click="handleDelete(selectData)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</el-button> -->
|
||||
<div class="mt-4">
|
||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" />
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
<el-form-item label="用户id" prop="uid">
|
||||
<el-input class="w-[280px]" v-model="queryParams.uid" clearable placeholder="请输入用户id" />
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="create_time">
|
||||
<!-- <el-form-item label="创建时间" prop="create_time">
|
||||
<el-input class="w-[280px]" v-model="queryParams.create_time" clearable placeholder="请输入创建时间" />
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||
<el-button @click="resetParams">重置</el-button>
|
||||
|
@ -22,7 +22,7 @@
|
|||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
|
||||
<el-button v-perms="['store_finance_flow.store_finance_flow/add']" type="primary" @click="handleAdd">
|
||||
<!-- <el-button v-perms="['store_finance_flow.store_finance_flow/add']" type="primary" @click="handleAdd">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Plus" />
|
||||
</template>
|
||||
|
@ -34,7 +34,7 @@
|
|||
@click="handleDelete(selectData)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</el-button> -->
|
||||
<div class="mt-4">
|
||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" />
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
<el-form-item label="用户uid" prop="uid">
|
||||
<el-input class="w-[280px]" v-model="queryParams.uid" clearable placeholder="请输入用户uid" />
|
||||
</el-form-item>
|
||||
<el-form-item label="明细类型" prop="type">
|
||||
<!-- <el-form-item label="明细类型" prop="type">
|
||||
<el-input class="w-[280px]" v-model="queryParams.type" clearable placeholder="请输入明细类型" />
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="create_time">
|
||||
</el-form-item> -->
|
||||
<!-- <el-form-item label="创建时间" prop="create_time">
|
||||
<el-input class="w-[280px]" v-model="queryParams.create_time" clearable placeholder="请输入创建时间" />
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||
<el-button @click="resetParams">重置</el-button>
|
||||
|
@ -22,7 +22,7 @@
|
|||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
|
||||
<el-button v-perms="['user_bill.user_bill/add']" type="primary" @click="handleAdd">
|
||||
<!-- <el-button v-perms="['user_bill.user_bill/add']" type="primary" @click="handleAdd">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Plus" />
|
||||
</template>
|
||||
|
@ -34,7 +34,7 @@
|
|||
@click="handleDelete(selectData)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</el-button> -->
|
||||
<div class="mt-4">
|
||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" />
|
||||
|
|
|
@ -1,34 +1,59 @@
|
|||
<template>
|
||||
<div class="edit-popup">
|
||||
<popup ref="popupRef" title="详情" :async="true" width="1000px" :cancelButtonText="false"
|
||||
:confirmButtonText="false">
|
||||
<el-descriptions class="margin-top" title="商品详情" :column="2" border>
|
||||
<el-descriptions-item label="商品名称">
|
||||
{{ formData.store_name }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="商品图片">
|
||||
<el-image :src="formData.image" class="w-20 h-20" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="商品条码">
|
||||
{{ formData.bar_code }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="商品分类">{{ formData.cate_name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="商品售价">{{ formData.price }}</el-descriptions-item>
|
||||
<el-descriptions-item label="商品单位">{{ formData.unit_name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="库存">{{ formData.stock }}</el-descriptions-item>
|
||||
<el-descriptions-item label="成本">{{ formData.cost }}</el-descriptions-item>
|
||||
<el-descriptions-item label="采购价">{{ formData.purchase }}</el-descriptions-item>
|
||||
<el-descriptions-item label="上浮比例">{{ formData.rose }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</popup>
|
||||
<el-drawer title="商品详情" :size="1000" v-model="isOpen">
|
||||
<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
|
||||
<el-tab-pane label="基础信息" name="first">
|
||||
<el-descriptions class="margin-top" :column="2" border>
|
||||
<el-descriptions-item label="商品名称">
|
||||
{{ formData.store_name }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="商品图片">
|
||||
<el-image :src="formData.image" class="w-20 h-20" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="商品条码">
|
||||
{{ formData.bar_code }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="商品分类">{{ formData.cate_name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="商品售价">{{ formData.price }}</el-descriptions-item>
|
||||
<el-descriptions-item label="商品单位">{{ formData.unit_name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="库存">{{ formData.stock }}</el-descriptions-item>
|
||||
<el-descriptions-item label="成本">{{ formData.cost }}</el-descriptions-item>
|
||||
<el-descriptions-item label="采购价">{{ formData.purchase }}</el-descriptions-item>
|
||||
<el-descriptions-item label="上浮比例">{{ formData.rose }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="适用门店" name="second">
|
||||
<el-table :data="pager.lists" border>
|
||||
<el-table-column label="门店ID" prop="id" width="70" show-overflow-tooltip />
|
||||
<el-table-column label="门店名称" prop="system_store_name" min-width="200" />
|
||||
<el-table-column label="商品图" prop="image" width="80" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-image :src="row.image" class="w-[50px] h-[50px]" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="商品名称" prop="store_name" min-width="150" />
|
||||
<el-table-column label="商品库存" prop="stock" show-overflow-tooltip />
|
||||
<el-table-column label="商品价格" prop="price" show-overflow-tooltip />
|
||||
<el-table-column label="商品销量" prop="sales" show-overflow-tooltip />
|
||||
|
||||
</el-table>
|
||||
<div class="flex mt-4 justify-end" v-if="pager.count>pager.lists.length">
|
||||
<pagination v-model="pager" @change="getLists" />
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="storeProductDETAILS">
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import Popup from '@/components/popup/index.vue'
|
||||
import { apiStoreProductAdd, apiStoreProductEdit, apiStoreProductDetail } from '@/api/store_product'
|
||||
import { timeFormat } from '@/utils/util'
|
||||
import { apiSourceProductStoreLists } from '@/api/system_store'
|
||||
import type { PropType } from 'vue'
|
||||
defineProps({
|
||||
dictData: {
|
||||
|
@ -39,10 +64,15 @@ defineProps({
|
|||
const emit = defineEmits(['success', 'close'])
|
||||
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
||||
const mode = ref('add')
|
||||
|
||||
const isOpen = ref(false);
|
||||
const activeName = ref('first');
|
||||
const handleClick = (tab: any) => {
|
||||
if (tab.paneName == "second") getLists();
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
id: "",
|
||||
image: "",
|
||||
store_name: "",
|
||||
bar_code: "",
|
||||
|
@ -61,17 +91,18 @@ const formData = reactive({
|
|||
|
||||
// 获取详情
|
||||
const setFormData = async (data: Record<any, any>) => {
|
||||
queryParams.product_id = data.id;
|
||||
if(activeName.value == "second") getLists();
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
const getDetail = async (row: Record<string, any>) => {
|
||||
queryParams.product_id = row.id
|
||||
const data = await apiStoreProductDetail({
|
||||
id: row.id
|
||||
})
|
||||
|
@ -80,7 +111,7 @@ const getDetail = async (row: Record<string, any>) => {
|
|||
|
||||
//打开弹窗
|
||||
const open = () => {
|
||||
popupRef.value?.open()
|
||||
isOpen.value = true;
|
||||
}
|
||||
|
||||
// 关闭回调
|
||||
|
@ -88,7 +119,15 @@ const handleClose = () => {
|
|||
emit('close')
|
||||
}
|
||||
|
||||
|
||||
// 查询条件
|
||||
const queryParams = reactive({
|
||||
product_id: "",
|
||||
})
|
||||
// 分页相关
|
||||
const { pager, getLists, resetParams, resetPage } = usePaging({
|
||||
fetchFun: apiSourceProductStoreLists,
|
||||
params: queryParams
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
|
|
|
@ -13,14 +13,19 @@
|
|||
<el-form-item label="商品条码" prop="bar_code">
|
||||
<el-input v-model="formData.bar_code" clearable placeholder="请输入商品条码" :readonly="false" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类" prop="cate_id">
|
||||
<el-input v-model="formData.cate_id" clearable placeholder="请输入商品分类" :readonly="false" />
|
||||
<el-form-item label="商品分类" prop="cate_arr">
|
||||
<el-cascader style="width: 100%" v-model="formData.cate_arr" class="caser" filterable
|
||||
:before-filter="beforeFilter" :props="props" placeholder="请选择商品分类" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商品价格" prop="price">
|
||||
<el-input v-model="formData.price" clearable placeholder="请输入商品价格" :readonly="false" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商品单位" prop="unit">
|
||||
<el-input v-model="formData.unit" clearable placeholder="请输入商品单位" :readonly="false" />
|
||||
<el-cascader style="width: 100%" v-model="formData.unit" :options="unitList" :props="{
|
||||
value: 'id',
|
||||
label: 'name',
|
||||
emitPath: false,
|
||||
}" placeholder="请选择商品单位" />
|
||||
</el-form-item>
|
||||
<el-form-item label="库存" prop="stock">
|
||||
<el-input v-model="formData.stock" clearable placeholder="请输入库存" :readonly="false" />
|
||||
|
@ -34,10 +39,51 @@
|
|||
<el-form-item label="上浮比例" prop="rose">
|
||||
<el-input v-model="formData.rose" clearable placeholder="请输入上浮比例" :readonly="false" />
|
||||
</el-form-item>
|
||||
<el-form-item label="所属门店" prop="store_id" v-if="mode=='add'">
|
||||
<el-radio-group v-model="formData.is_store_all" >
|
||||
<el-radio :label="1">全部门店</el-radio>
|
||||
<el-radio :label="0">部分门店</el-radio>
|
||||
</el-radio-group>
|
||||
<div class="w-full" style="color:#64748b">可选择将商品同步到哪些门店使用</div>
|
||||
<div class="mb-2">
|
||||
<el-button type="primary" v-if="formData.is_store_all==0" @click="showStore=true">添加门店</el-button>
|
||||
</div>
|
||||
<el-table :data="storeList" v-if="formData.is_store_all==0">
|
||||
<el-table-column label="ID" prop="id" show-overflow-tooltip />
|
||||
<el-table-column label="门店名称" prop="name" show-overflow-tooltip />
|
||||
<el-table-column label="手机号码" prop="phone" show-overflow-tooltip />
|
||||
<el-table-column label="详细地址" prop="detailed_address" show-overflow-tooltip />
|
||||
<el-table-column label="门店logo" prop="image" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-image :src="row.image" class="w-[50px] h-[50px]" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否显示" prop="is_show" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ row.is_show ? '显示' : '隐藏' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-perms="['system_store.system_store/delete']"
|
||||
type="danger"
|
||||
link
|
||||
@click="handleDelete(row.id)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form-item>
|
||||
<el-form-item label="">
|
||||
<el-button @click="handleSubmit" type="primary" class="w-40">提交</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-dialog v-model="showStore" title="选择门店" width="70%">
|
||||
<store-pop @onBindStore="onBindStore"></store-pop>
|
||||
</el-dialog>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
|
@ -51,7 +97,10 @@ import {
|
|||
} from "@/api/store_product";
|
||||
import { timeFormat } from "@/utils/util";
|
||||
import type { PropType } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { onMounted } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { apiStoreCategoryLists } from "@/api/store_category";
|
||||
import { apiStoreProductUnitLists } from "@/api/store_product_unit";
|
||||
defineProps({
|
||||
dictData: {
|
||||
type: Object as PropType<Record<string, any[]>>,
|
||||
|
@ -65,9 +114,11 @@ const mode = ref("add");
|
|||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
id: "",
|
||||
image: "",
|
||||
store_name: "",
|
||||
bar_code: "",
|
||||
cate_arr: [],
|
||||
cate_id: "",
|
||||
price: "",
|
||||
unit: "",
|
||||
|
@ -75,8 +126,93 @@ const formData = reactive({
|
|||
cost: "",
|
||||
purchase: "",
|
||||
rose: "0",
|
||||
is_store_all: 1, //门店类型 1 全部门店 2 部分门店
|
||||
});
|
||||
|
||||
const showStore = ref(false); // 选择门店列表是否显示
|
||||
// 门店列表
|
||||
const storeList = ref([]);
|
||||
// 删除已有门店
|
||||
const handleDelete = (id: number) => {
|
||||
storeList.value = storeList.value.filter((item: any) => item.id !== id);
|
||||
};
|
||||
// 选择门店
|
||||
const onBindStore = (e:any[])=>{
|
||||
e.forEach((item:any) => {
|
||||
if(!storeList.value.find((t:any)=>t.id==item.id)){
|
||||
storeList.value.push(item);
|
||||
}
|
||||
});
|
||||
showStore.value = false;
|
||||
}
|
||||
|
||||
let resolves;
|
||||
let nodes;
|
||||
let flag = ref(false);
|
||||
let name;
|
||||
onMounted(() => {
|
||||
// setTimeout(() => {
|
||||
// let dom = document.getElementsByClassName('caser')[0]
|
||||
// let ipt = dom.getElementsByClassName('el-input__inner')[0]
|
||||
// ipt.addEventListener('input', (e) => {
|
||||
// beforeFilter(e.target.value)
|
||||
// })
|
||||
// })
|
||||
})
|
||||
|
||||
const beforeFilter = (value) => {
|
||||
name = value
|
||||
flag.value = true
|
||||
props.lazyLoad(nodes, resolves)
|
||||
return false
|
||||
}
|
||||
const props = {
|
||||
value: "id",
|
||||
label: "name",
|
||||
emitPath: false,
|
||||
lazy: true,
|
||||
checkStrictly: true, //选择任意一级
|
||||
lazyLoad(node, resolve) {
|
||||
if (!resolves) resolves = resolve;
|
||||
if (!nodes) nodes = node;
|
||||
let pid = node.value || 0;
|
||||
let data = {}
|
||||
if (flag.value) {
|
||||
data = { name: name }
|
||||
if (!name) {
|
||||
data = {
|
||||
pid: pid,
|
||||
page_size: 10000,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
data = {
|
||||
pid: pid,
|
||||
page_size: 10000,
|
||||
}
|
||||
}
|
||||
apiStoreCategoryLists({
|
||||
...data
|
||||
}).then((res) => {
|
||||
resolve(
|
||||
res.lists.map((item: any) => {
|
||||
item.leaf = item.is_children == 0;
|
||||
flag.value = false
|
||||
return item;
|
||||
})
|
||||
);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const unitList = ref([]);
|
||||
const getUnitList = () => {
|
||||
apiStoreProductUnitLists({}).then((res) => {
|
||||
unitList.value = res.lists;
|
||||
});
|
||||
};
|
||||
getUnitList();
|
||||
|
||||
// 表单验证
|
||||
const formRules = reactive<any>({
|
||||
store_name: [
|
||||
|
@ -152,6 +288,9 @@ const setFormData = async (data: Record<any, any>) => {
|
|||
formData[key] = data[key];
|
||||
}
|
||||
}
|
||||
if(formData.cate_arr[0]){
|
||||
formData.cate_arr = formData.cate_arr.map((item:any)=>Number(item));
|
||||
}
|
||||
};
|
||||
|
||||
const getDetail = async (row: Record<string, any>) => {
|
||||
|
@ -162,21 +301,33 @@ const getDetail = async (row: Record<string, any>) => {
|
|||
};
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
// 提交按钮
|
||||
const handleSubmit = async () => {
|
||||
await formRef.value?.validate();
|
||||
let data:any = { ...formData };
|
||||
if (formData.is_store_all==0&&mode.value=='add'){
|
||||
data.store_arr = storeList.value.map((item:any)=>item.id);
|
||||
} else if(mode.value=='edit') data.is_store_all = 0;
|
||||
|
||||
data.cate_id = data.cate_arr;
|
||||
delete data.cate_arr;
|
||||
mode.value == "edit"
|
||||
? await apiStoreProductEdit(data)
|
||||
: await apiStoreProductAdd(data);
|
||||
|
||||
removeTab();
|
||||
router.push({
|
||||
path: "/store/store_product",
|
||||
});
|
||||
await formRef.value?.validate();
|
||||
const data = { ...formData };
|
||||
mode.value == "edit"
|
||||
? await apiStoreProductEdit(data)
|
||||
: await apiStoreProductAdd(data);
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
setFormData,
|
||||
getDetail,
|
||||
});
|
||||
if(route.query.id&&route.query.mode=='edit'){
|
||||
mode.value = 'edit';
|
||||
getDetail({
|
||||
id: route.query.id,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
|
||||
<el-button v-perms="['store_product.store_product/add']" type="primary" icon="Plus">
|
||||
<router-link :to="{
|
||||
path: 'store_product_edit',
|
||||
query: { id: 0, mode: 'add' },
|
||||
}">
|
||||
<router-link :to="{
|
||||
path: 'store_product_edit',
|
||||
query: { id: 0, mode: 'add' },
|
||||
}" class="mr-4" v-perms="['store_product.store_product/add']">
|
||||
<el-button type="primary" icon="Plus">
|
||||
新增
|
||||
</router-link>
|
||||
</el-button>
|
||||
</el-button>
|
||||
</router-link>
|
||||
<el-button v-perms="['store_product.store_product/delete']" :disabled="!selectData.length"
|
||||
@click="handleDelete(selectData)">
|
||||
删除
|
||||
|
@ -28,31 +28,36 @@
|
|||
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="商品ID" prop="id" show-overflow-tooltip />
|
||||
<el-table-column label="商品图片" prop="image">
|
||||
<el-table-column label="商品图片" prop="image" min-width="80">
|
||||
<template #default="{ row }">
|
||||
<el-image style="width: 50px; height: 50px" :src="row.image" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="商品名称" prop="store_name" show-overflow-tooltip />
|
||||
<el-table-column label="分类" prop="cate_name" show-overflow-tooltip />
|
||||
<el-table-column label="商品价格" prop="price" show-overflow-tooltip />
|
||||
<el-table-column label="单位名" prop="unit_name" show-overflow-tooltip />
|
||||
<el-table-column label="成本价" prop="cost" show-overflow-tooltip />
|
||||
<el-table-column label="采购价" prop="purchase" show-overflow-tooltip />
|
||||
<el-table-column label="销量" prop="sales" show-overflow-tooltip />
|
||||
<el-table-column label="库存" prop="stock" show-overflow-tooltip />
|
||||
<el-table-column label="商品名称" prop="store_name" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column label="分类" prop="cate_name" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="单位" prop="unit_name" min-width="80" show-overflow-tooltip />
|
||||
<el-table-column label="商品价格" prop="price" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column label="成本价" prop="cost" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column label="采购价" prop="purchase" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column label="库存" prop="stock" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column label="销量" prop="sales" min-width="100" show-overflow-tooltip />
|
||||
<!-- <el-table-column label="商品来源" prop="system_store_name" min-width="200" show-overflow-tooltip /> -->
|
||||
<el-table-column label="条码" prop="bar_code" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column label="状态" prop="is_show" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ row.is_show ? "上架" : "未上架" }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="添加时间" prop="create_time" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="180" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button v-perms="['store_product.store_product/edit']" type="primary" link
|
||||
@click="handleEdit(row)">
|
||||
编辑
|
||||
</el-button>
|
||||
<router-link :to="{
|
||||
path: 'store_product_edit',
|
||||
query: { id: row.id, mode: 'edit' },
|
||||
}" class="mr-4" v-perms="['store_product.store_product/edit']">
|
||||
<el-button type="primary" link>
|
||||
编辑
|
||||
</el-button>
|
||||
</router-link>
|
||||
<el-button v-perms="['store_product.store_product/edit']" type="primary" link
|
||||
@click="handleDetail(row)">
|
||||
详情
|
||||
|
@ -97,6 +102,8 @@ const selectData = ref<any[]>([]);
|
|||
|
||||
// 表格选择后回调事件
|
||||
const handleSelectionChange = (val: any[]) => {
|
||||
console.log(val);
|
||||
|
||||
selectData.value = val.map(({ id }) => id);
|
||||
};
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
<!-- <el-form-item label="拼音信息" prop="py">
|
||||
<el-input class="w-[280px]" v-model="queryParams.py" clearable placeholder="请输入拼音信息" />
|
||||
</el-form-item> -->
|
||||
<el-form-item label="单位编号" prop="number">
|
||||
<!-- <el-form-item label="单位编号" prop="number">
|
||||
<el-input class="w-[280px]" v-model="queryParams.number" clearable placeholder="请输入单位编号" />
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
<!-- <el-form-item label="备注信息" prop="data">
|
||||
<el-input class="w-[280px]" v-model="queryParams.data" clearable placeholder="请输入备注信息" />
|
||||
</el-form-item>
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
|
||||
<!-- <el-segmented v-model="storeType" :options="['全部', '营业中', '未营业']" size="large" /> -->
|
||||
<el-button v-perms="['system_store.system_store/add']" type="primary" @click="handleAdd">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Plus" />
|
||||
|
@ -95,8 +96,10 @@ const showEdit = ref(false)
|
|||
// 查询条件
|
||||
const queryParams = reactive({
|
||||
name: '',
|
||||
phone: ''
|
||||
phone: '',
|
||||
is_show: ''
|
||||
})
|
||||
const storeType = ref('全部');
|
||||
|
||||
// 选中数据
|
||||
const selectData = ref<any[]>([])
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
|
||||
<el-button v-perms="['user.user/add']" type="primary" @click="handleAdd">
|
||||
<!-- <el-button v-perms="['user.user/add']" type="primary" @click="handleAdd">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Plus" />
|
||||
</template>
|
||||
|
@ -34,7 +34,7 @@
|
|||
@click="handleDelete(selectData)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</el-button> -->
|
||||
<div class="mt-4">
|
||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" />
|
||||
|
|
Loading…
Reference in New Issue