移除旧线上超市
This commit is contained in:
1 parent
d0fee85f00
commit
6f7e4446db
2 files changed
-412
No files matched your search
@@ -1,255 +0,0 @@
|
|||||||
<template>
|
|
||||||
<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="14" class="mb20">
|
|
||||||
<el-form-item label="商户" prop="merchantId">
|
|
||||||
<select-mch v-model="form.merchantId" :apiParams="{ types: '3' }" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="14" class="mb20">
|
|
||||||
<el-form-item label="库存商品" prop="erpSpuId">
|
|
||||||
<el-input
|
|
||||||
v-model="form.erpSpuId"
|
|
||||||
placeholder="请选择库存商品"
|
|
||||||
:value="form.erpSpuName"
|
|
||||||
readonly
|
|
||||||
:suffix-icon="Search"
|
|
||||||
@click="handleClickSelectSpu"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="24" class="mb20">
|
|
||||||
<el-form-item label="商品轮播图" prop="sliderPicUrls">
|
|
||||||
<upload-imgs v-model="form.sliderPicUrls" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
|
||||||
<el-form-item label="排序" prop="sort">
|
|
||||||
<el-input-number :min="0" :max="1000" :precision="0" v-model="form.sort" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="24" class="mb20">
|
|
||||||
<el-form-item label="商品状态" prop="status">
|
|
||||||
<el-radio-group v-model="form.status">
|
|
||||||
<el-radio :label="item.value" v-for="(item, index) in spu_status" border :key="index">{{ item.label }} </el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<!-- <el-col :span="12" class="mb20">-->
|
|
||||||
<!-- <el-form-item label="赠送积分" prop="giveIntegral">-->
|
|
||||||
<!-- <el-input-number :min="0" :max="1000" v-model="form.giveIntegral" placeholder="请输入赠送积分"></el-input-number>-->
|
|
||||||
<!-- </el-form-item>-->
|
|
||||||
<!-- </el-col>-->
|
|
||||||
</el-row>
|
|
||||||
<el-col :span="24" class="mb20">
|
|
||||||
<el-form-item label="商品详情" prop="description">
|
|
||||||
<editor v-if="visible" v-model:get-html="form.description" placeholder="请输入商品详情"></editor>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<span class="dialog-footer">
|
|
||||||
<el-button @click="visible = false">取消</el-button>
|
|
||||||
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
|
|
||||||
<!-- 库存商品选择对话框 -->
|
|
||||||
<el-dialog v-model="spuSelectDialogVisible" title="选择商品" width="60%" :close-on-click-modal="false" draggable @close="">
|
|
||||||
<el-row>
|
|
||||||
<el-form :inline="true" @keyup.enter="getDataList">
|
|
||||||
<el-form-item label="商品名称" prop="name">
|
|
||||||
<el-input placeholder="请输入商品名称" v-model="state.queryForm.productName" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button icon="search" type="primary" @click="getDataList">查询</el-button>
|
|
||||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-table v-loading="state.loading" :data="state.dataList" @row-click="handleRowClick" :row-style="{ cursor: 'pointer' }">
|
|
||||||
<el-table-column type="index" label="#" width="50" align="center" />
|
|
||||||
<el-table-column prop="productName" label="商品名称" width="100px" align="center" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="productCode" label="货号" width="100px" align="center" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="barcode" label="商品条码" width="100px" align="center" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="brandId" label="商品品牌" width="100px" align="center" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="categoryId" label="商品分类" width="100px" align="center" show-overflow-tooltip>
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag>{{ categoryOptions.find((item: any) => item.id == row.categoryId)?.name }}</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="picUrl" label="商品图" align="center" show-overflow-tooltip>
|
|
||||||
<template #default="scope">
|
|
||||||
<preview-image @click.stop :src="scope.row.picUrl" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="productNature" label="商品性质" align="center" show-overflow-tooltip width="150">
|
|
||||||
<template #default="scope">
|
|
||||||
<dict-tag :options="supermarket_nature" :value="scope.row.productNature" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="status" label="上架状态" align="center" show-overflow-tooltip>
|
|
||||||
<template #default="scope">
|
|
||||||
<dict-tag :options="spu_status" :value="scope.row.status" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<!-- <el-table-column prop="supplierId" label="供货商" width="100px" align="center" show-overflow-tooltip /> -->
|
|
||||||
<!-- <el-table-column prop="sort" label="排序字段" align="center" show-overflow-tooltip /> -->
|
|
||||||
<!-- <el-table-column prop="price" label="商品价格" align="center" show-overflow-tooltip>
|
|
||||||
<template #default="scope">
|
|
||||||
{{ displayPrice(scope.row.price) }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="marketPrice" label="市场价" align="center" show-overflow-tooltip>
|
|
||||||
<template #default="scope">
|
|
||||||
{{ displayPrice(scope.row.marketPrice) }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="costPrice" label="成本价" align="center" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="stock" label="库存" align="center" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="salesCount" label="商品销量" align="center" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="createTime" label="创建时间" align="center" show-overflow-tooltip /> -->
|
|
||||||
</el-table>
|
|
||||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
|
||||||
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="spuSelectDialogVisible = false">取消</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts" name="SmSpuDialog">
|
|
||||||
import { useDict } from "/@/hooks/dict"
|
|
||||||
import { useMessage } from "/@/hooks/message"
|
|
||||||
import { getObj, addObj, putObj, getOnlineSpuPage } from "/@/api/supermarket/smSpu"
|
|
||||||
import { BasicTableProps, useTable } from "/@/hooks/table"
|
|
||||||
import { Search } from "@element-plus/icons-vue"
|
|
||||||
import { getSupermarketCategory } from "/@/api/supermarketerp/supermarketSpu"
|
|
||||||
const emit = defineEmits(["refresh"])
|
|
||||||
|
|
||||||
// 定义变量内容
|
|
||||||
const dataFormRef = ref()
|
|
||||||
const visible = ref(false)
|
|
||||||
const loading = ref(false)
|
|
||||||
// 定义字典
|
|
||||||
const { supermarket_nature, spu_status } = useDict("supermarket_nature", "spu_status")
|
|
||||||
const spuSelectDialogVisible = ref<boolean>(false)
|
|
||||||
|
|
||||||
// 提交表单数据
|
|
||||||
const form = reactive({
|
|
||||||
merchantId: "",
|
|
||||||
id: "",
|
|
||||||
erpSpuId: "",
|
|
||||||
description: "<p></p>",
|
|
||||||
sliderPicUrls: "",
|
|
||||||
sort: "",
|
|
||||||
status: "0",
|
|
||||||
giveIntegral: 0,
|
|
||||||
deptId: "",
|
|
||||||
salesCount: "",
|
|
||||||
erpSpuName: "",
|
|
||||||
})
|
|
||||||
const categoryOptions = ref<any>([])
|
|
||||||
|
|
||||||
// 定义校验规则
|
|
||||||
const dataRules = ref({
|
|
||||||
merchantId: [{ required: true, message: "请选择商户", trigger: "blur" }],
|
|
||||||
erpSpuId: [{ required: true, message: "请选择库存商品", trigger: "change" }],
|
|
||||||
})
|
|
||||||
|
|
||||||
// 打开弹窗
|
|
||||||
const openDialog = (id: string) => {
|
|
||||||
visible.value = true
|
|
||||||
form.id = ""
|
|
||||||
|
|
||||||
dataFormRef.value?.resetFields()
|
|
||||||
form.erpSpuName = ""
|
|
||||||
|
|
||||||
// 获取smSpu信息
|
|
||||||
if (id) {
|
|
||||||
form.id = id
|
|
||||||
getsmSpuData(id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 提交
|
|
||||||
const onSubmit = async () => {
|
|
||||||
console.log(form)
|
|
||||||
const valid = await dataFormRef.value.validate().catch(() => {})
|
|
||||||
if (!valid) return false
|
|
||||||
|
|
||||||
try {
|
|
||||||
loading.value = true
|
|
||||||
form.id ? await putObj(form) : await addObj(form)
|
|
||||||
useMessage().success(form.id ? "修改成功" : "添加成功")
|
|
||||||
visible.value = false
|
|
||||||
emit("refresh")
|
|
||||||
} catch (err: any) {
|
|
||||||
useMessage().error(err.msg)
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 初始化表单数据
|
|
||||||
const getsmSpuData = (id: string) => {
|
|
||||||
// 获取数据
|
|
||||||
loading.value = true
|
|
||||||
getObj(id)
|
|
||||||
.then((res: any) => {
|
|
||||||
Object.assign(form, res.data)
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
loading.value = false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
|
||||||
queryForm: {},
|
|
||||||
pageList: getOnlineSpuPage,
|
|
||||||
})
|
|
||||||
|
|
||||||
const { getDataList, currentChangeHandle, sizeChangeHandle } = useTable(state)
|
|
||||||
|
|
||||||
const resetQuery = () => {
|
|
||||||
state.queryForm.productName = ""
|
|
||||||
getDataList()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 点击选择库存商品
|
|
||||||
const handleClickSelectSpu = async () => {
|
|
||||||
loading.value = true
|
|
||||||
state.queryForm.productName = ""
|
|
||||||
spuSelectDialogVisible.value = true
|
|
||||||
try {
|
|
||||||
getDataList()
|
|
||||||
const res = await getSupermarketCategory()
|
|
||||||
categoryOptions.value = res.data
|
|
||||||
} catch (error) {
|
|
||||||
state.dataList = []
|
|
||||||
categoryOptions.value = []
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// 线上商品列表表格行点击
|
|
||||||
const handleRowClick = (row: any) => {
|
|
||||||
spuSelectDialogVisible.value = false
|
|
||||||
form.erpSpuId = row.id
|
|
||||||
form.erpSpuName = row.productName
|
|
||||||
}
|
|
||||||
|
|
||||||
// 暴露变量
|
|
||||||
defineExpose({
|
|
||||||
openDialog,
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
@@ -1,157 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="layout-padding">
|
|
||||||
<div class="layout-padding-auto layout-padding-view">
|
|
||||||
<el-row v-show="showSearch">
|
|
||||||
<el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList">
|
|
||||||
<el-form-item label="商品名称" prop="productName">
|
|
||||||
<el-input v-model="state.queryForm.productName" placeholder="请输入商品名称" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button icon="search" type="primary" @click="getDataList">查询</el-button>
|
|
||||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</el-row>
|
|
||||||
<el-row>
|
|
||||||
<div class="mb8" style="width: 100%">
|
|
||||||
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()" v-auth="'supermarket_smSpu_add'">
|
|
||||||
新 增
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
plain
|
|
||||||
:disabled="multiple"
|
|
||||||
icon="Delete"
|
|
||||||
type="primary"
|
|
||||||
v-auth="'supermarket_smSpu_del'"
|
|
||||||
@click="handleDelete(selectObjs)"
|
|
||||||
>
|
|
||||||
删 除
|
|
||||||
</el-button>
|
|
||||||
<right-toolbar
|
|
||||||
v-model:showSearch="showSearch"
|
|
||||||
:export="'supermarket_smSpu_export'"
|
|
||||||
@exportExcel="exportExcel"
|
|
||||||
class="ml10 mr20"
|
|
||||||
style="float: right"
|
|
||||||
@queryTable="getDataList"
|
|
||||||
></right-toolbar>
|
|
||||||
</div>
|
|
||||||
</el-row>
|
|
||||||
<el-table
|
|
||||||
:data="state.dataList"
|
|
||||||
v-loading="state.loading"
|
|
||||||
border
|
|
||||||
:cell-style="tableStyle.cellStyle"
|
|
||||||
:header-cell-style="tableStyle.headerCellStyle"
|
|
||||||
@selection-change="selectionChangHandle"
|
|
||||||
@sort-change="sortChangeHandle"
|
|
||||||
>
|
|
||||||
<el-table-column type="selection" width="40" align="center" />
|
|
||||||
<el-table-column type="index" label="#" width="50" />
|
|
||||||
<el-table-column prop="productName" label="商品名称" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="productCode" label="货号" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="categoryName" label="商品分类" width="100px" align="center" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="picUrl" label="商品封面图" align="center" show-overflow-tooltip>
|
|
||||||
<template #default="scope">
|
|
||||||
<preview-image @click.stop :src="scope.row.picUrl" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="status" label="商品状态" show-overflow-tooltip>
|
|
||||||
<template #default="scope">
|
|
||||||
<dict-tag :options="spu_status" :value="scope.row.status" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<!-- <el-table-column prop="barcode" label="商品条码" width="100px" align="center" show-overflow-tooltip />-->
|
|
||||||
<el-table-column prop="sort" label="排序" show-overflow-tooltip />
|
|
||||||
<!-- <el-table-column prop="giveIntegral" label="赠送积分" show-overflow-tooltip />-->
|
|
||||||
<el-table-column prop="salesCount" label="销量" show-overflow-tooltip />
|
|
||||||
<el-table-column label="操作" width="150">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-button
|
|
||||||
icon="edit-pen"
|
|
||||||
text
|
|
||||||
type="primary"
|
|
||||||
v-auth="'supermarket_smSpu_edit'"
|
|
||||||
@click="formDialogRef.openDialog(scope.row.id)"
|
|
||||||
>
|
|
||||||
编辑
|
|
||||||
</el-button>
|
|
||||||
<el-button icon="delete" text type="primary" v-auth="'supermarket_smSpu_del'" @click="handleDelete([scope.row.id])">
|
|
||||||
删除
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 编辑、新增 -->
|
|
||||||
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts" name="systemSmSpu">
|
|
||||||
import { BasicTableProps, useTable } from "/@/hooks/table"
|
|
||||||
import { fetchList, delObjs } from "/@/api/supermarket/smSpu"
|
|
||||||
import { useMessage, useMessageBox } from "/@/hooks/message"
|
|
||||||
import { useDict } from "/@/hooks/dict"
|
|
||||||
|
|
||||||
// 引入组件
|
|
||||||
const FormDialog = defineAsyncComponent(() => import("./form.vue"))
|
|
||||||
// 定义查询字典
|
|
||||||
|
|
||||||
const { spu_status } = useDict("spu_status")
|
|
||||||
// 定义变量内容
|
|
||||||
const formDialogRef = ref()
|
|
||||||
// 搜索变量
|
|
||||||
const queryRef = ref()
|
|
||||||
const showSearch = ref(true)
|
|
||||||
// 多选变量
|
|
||||||
const selectObjs = ref([]) as any
|
|
||||||
const multiple = ref(true)
|
|
||||||
|
|
||||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
|
||||||
queryForm: {},
|
|
||||||
pageList: fetchList,
|
|
||||||
})
|
|
||||||
|
|
||||||
// table hook
|
|
||||||
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state)
|
|
||||||
|
|
||||||
// 清空搜索条件
|
|
||||||
const resetQuery = () => {
|
|
||||||
// 清空搜索条件
|
|
||||||
queryRef.value?.resetFields()
|
|
||||||
// 清空多选
|
|
||||||
selectObjs.value = []
|
|
||||||
getDataList()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 导出excel
|
|
||||||
const exportExcel = () => {
|
|
||||||
downBlobFile("/supermarket/smSpu/export", Object.assign(state.queryForm, { ids: selectObjs }), "线上超市商品.xlsx")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 多选事件
|
|
||||||
const selectionChangHandle = (objs: { id: string }[]) => {
|
|
||||||
selectObjs.value = objs.map(({ id }) => id)
|
|
||||||
multiple.value = !objs.length
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除操作
|
|
||||||
const handleDelete = async (ids: string[]) => {
|
|
||||||
try {
|
|
||||||
await useMessageBox().confirm("此操作将永久删除")
|
|
||||||
} catch {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await delObjs(ids)
|
|
||||||
getDataList()
|
|
||||||
useMessage().success("删除成功")
|
|
||||||
} catch (err: any) {
|
|
||||||
useMessage().error(err.msg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
Reference in new issue
Block a user