feat:智能柜商品
This commit is contained in:
1 parent
24d03cf88e
commit
6e56d167de
15 files changed
+522
-197
No files matched your search
@@ -1,49 +1,56 @@
|
||||
import request from "/@/utils/request"
|
||||
|
||||
export function select(query?: Object) {
|
||||
return request({
|
||||
url: "/hard/hard-manager/select",
|
||||
method: "get",
|
||||
params: query,
|
||||
})
|
||||
}
|
||||
|
||||
export function pageJoin(query?: Object) {
|
||||
return request({
|
||||
url: '/hard/hard-manager/page-join',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
return request({
|
||||
url: "/hard/hard-manager/page-join",
|
||||
method: "get",
|
||||
params: query,
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchList(query?: Object) {
|
||||
return request({
|
||||
url: '/hard/hard-manager/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
return request({
|
||||
url: "/hard/hard-manager/page",
|
||||
method: "get",
|
||||
params: query,
|
||||
})
|
||||
}
|
||||
|
||||
export function addObj(obj?: Object) {
|
||||
return request({
|
||||
url: '/hard/hard-manager',
|
||||
method: 'post',
|
||||
data: obj
|
||||
})
|
||||
return request({
|
||||
url: "/hard/hard-manager",
|
||||
method: "post",
|
||||
data: obj,
|
||||
})
|
||||
}
|
||||
|
||||
export function getObj(id?: string) {
|
||||
return request({
|
||||
url: '/hard/hard-manager/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
return request({
|
||||
url: "/hard/hard-manager/" + id,
|
||||
method: "get",
|
||||
})
|
||||
}
|
||||
|
||||
export function delObjs(ids?: Object) {
|
||||
return request({
|
||||
url: '/hard/hard-manager',
|
||||
method: 'delete',
|
||||
data: ids
|
||||
})
|
||||
return request({
|
||||
url: "/hard/hard-manager",
|
||||
method: "delete",
|
||||
data: ids,
|
||||
})
|
||||
}
|
||||
|
||||
export function putObj(obj?: Object) {
|
||||
return request({
|
||||
url: '/hard/hard-manager',
|
||||
method: 'put',
|
||||
data: obj
|
||||
})
|
||||
return request({
|
||||
url: "/hard/hard-manager",
|
||||
method: "put",
|
||||
data: obj,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
import request from "/@/utils/request"
|
||||
|
||||
export function select(query?: Object) {
|
||||
return request({
|
||||
url: "/hard/hard-spu-category/select",
|
||||
method: "get",
|
||||
params: query,
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchList(query?: Object) {
|
||||
return request({
|
||||
url: "/hard/hard-spu-category/page",
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
import request from "/@/utils/request"
|
||||
|
||||
export function pageJoin(query?: Object) {
|
||||
return request({
|
||||
url: "/hard/hard-spu/page-join",
|
||||
method: "get",
|
||||
params: query,
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchList(query?: Object) {
|
||||
return request({
|
||||
url: "/hard/hard-spu/page",
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
<template>
|
||||
<el-select
|
||||
style="width: 100%"
|
||||
v-model="state.selectId"
|
||||
:placeholder="props.placeholder"
|
||||
:clearable="props.clearable"
|
||||
remote-show-suffix
|
||||
filterable
|
||||
remote
|
||||
:disabled="props.disabled"
|
||||
:remote-method="remoteSearch"
|
||||
:loading="state.loading"
|
||||
@visible-change="(e: boolean) => e && getOptions()"
|
||||
@change="change"
|
||||
>
|
||||
<el-option v-for="v in state.options" :key="v.id" :label="`${v.name}`" :value="v.id">
|
||||
<div class="flex items-center">
|
||||
<div class="color-primary">{{ v.name }}</div>
|
||||
<div class="flex items-center justify-center ml5">
|
||||
<dict-tag :options="state.hardType" :value="v.type" />
|
||||
</div>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="select-hard">
|
||||
import { reactive } from "vue"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
import * as hardManager from "/@/api/hard/hard-manager"
|
||||
|
||||
const emit = defineEmits(["change"])
|
||||
|
||||
const selectId = defineModel()
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
placeholder?: string
|
||||
disabled?: boolean
|
||||
clearable?: boolean
|
||||
autoFirst?: boolean
|
||||
apiParams?: any
|
||||
}>(),
|
||||
{
|
||||
placeholder: "请选择",
|
||||
disabled: false,
|
||||
clearable: true,
|
||||
autoFirst: false,
|
||||
apiParams: {},
|
||||
},
|
||||
)
|
||||
|
||||
const queryForm = reactive<any>({
|
||||
name: "",
|
||||
current: 1,
|
||||
size: 10,
|
||||
})
|
||||
|
||||
const state = reactive<any>({
|
||||
loading: true,
|
||||
selectId: selectId,
|
||||
options: [],
|
||||
hardType: [],
|
||||
})
|
||||
|
||||
watch(
|
||||
selectId,
|
||||
(newVal, oldValue) => {
|
||||
if (newVal == oldValue) return
|
||||
state.selectId = newVal
|
||||
getOptions()
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
async function getOptions() {
|
||||
try {
|
||||
state.loading = true
|
||||
const _pa = {
|
||||
...queryForm,
|
||||
...props.apiParams,
|
||||
}
|
||||
const { data } = await hardManager.select(_pa)
|
||||
state.options = data.records ?? []
|
||||
if (props.autoFirst && state.options.length != 0) {
|
||||
state.selectId = state.options[0].id
|
||||
emit("change", state.selectId)
|
||||
}
|
||||
const { hard_type } = useDict("hard_type")
|
||||
state.hardType = hard_type
|
||||
} finally {
|
||||
setTimeout(() => (state.loading = false), 500)
|
||||
}
|
||||
}
|
||||
|
||||
function remoteSearch(params: string) {
|
||||
if (params != queryForm.name) {
|
||||
queryForm.name = params
|
||||
getOptions()
|
||||
}
|
||||
}
|
||||
|
||||
function clear() {
|
||||
state.selectId = null
|
||||
getOptions()
|
||||
}
|
||||
|
||||
function change() {
|
||||
emit("change", selectId)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
props.autoFirst && getOptions()
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,117 @@
|
||||
<template>
|
||||
<el-select
|
||||
style="width: 100%"
|
||||
v-model="state.selectId"
|
||||
:placeholder="props.placeholder"
|
||||
:clearable="props.clearable"
|
||||
remote-show-suffix
|
||||
filterable
|
||||
remote
|
||||
:disabled="props.disabled"
|
||||
:remote-method="remoteSearch"
|
||||
:loading="state.loading"
|
||||
@visible-change="(e: boolean) => e && getOptions()"
|
||||
@change="change"
|
||||
>
|
||||
<el-option v-for="v in state.options" :key="v.id" :label="`${v.name}`" :value="v.id">
|
||||
<div class="flex items-center">
|
||||
<div class="color-primary">{{ v.name }}</div>
|
||||
<div class="flex items-center justify-center ml5">
|
||||
<el-tag size="small"> {{ v.merchantName }} </el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="select-hard-spu-category">
|
||||
import { reactive } from "vue"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
import * as hardSpuCategory from "/@/api/hard/hard-spu-category"
|
||||
|
||||
const emit = defineEmits(["change"])
|
||||
|
||||
const selectId = defineModel()
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
placeholder?: string
|
||||
disabled?: boolean
|
||||
clearable?: boolean
|
||||
autoFirst?: boolean
|
||||
apiParams?: any
|
||||
}>(),
|
||||
{
|
||||
placeholder: "请选择",
|
||||
disabled: false,
|
||||
clearable: true,
|
||||
autoFirst: false,
|
||||
apiParams: {},
|
||||
},
|
||||
)
|
||||
|
||||
const queryForm = reactive<any>({
|
||||
name: "",
|
||||
current: 1,
|
||||
size: 10,
|
||||
})
|
||||
|
||||
const state = reactive<any>({
|
||||
loading: true,
|
||||
selectId: selectId,
|
||||
options: [],
|
||||
walletType: [],
|
||||
})
|
||||
|
||||
watch(
|
||||
selectId,
|
||||
(newVal, oldValue) => {
|
||||
console.log(newVal, "newVal")
|
||||
|
||||
if (newVal == oldValue) return
|
||||
state.selectId = newVal
|
||||
getOptions()
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
async function getOptions() {
|
||||
try {
|
||||
state.loading = true
|
||||
const _pa = {
|
||||
...queryForm,
|
||||
...props.apiParams,
|
||||
}
|
||||
const { data } = await hardSpuCategory.select(_pa)
|
||||
state.options = data.records ?? []
|
||||
if (props.autoFirst && state.options.length != 0) {
|
||||
state.selectId = state.options[0].id
|
||||
emit("change", state.selectId)
|
||||
}
|
||||
const { wallet_type } = useDict("wallet_type")
|
||||
state.walletType = wallet_type
|
||||
} finally {
|
||||
setTimeout(() => (state.loading = false), 500)
|
||||
}
|
||||
}
|
||||
|
||||
function remoteSearch(params: string) {
|
||||
if (params != queryForm.name) {
|
||||
queryForm.name = params
|
||||
getOptions()
|
||||
}
|
||||
}
|
||||
|
||||
function clear() {
|
||||
state.selectId = null
|
||||
getOptions()
|
||||
}
|
||||
|
||||
function change() {
|
||||
emit("change", selectId)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
props.autoFirst && getOptions()
|
||||
})
|
||||
</script>
|
||||
@@ -15,7 +15,7 @@
|
||||
<el-option v-for="v in state.options" :key="v.id" :label="`${v.name}`" :value="v.id">
|
||||
<div class="flex items-center">
|
||||
<div class="color-primary">{{ v.name }}</div>
|
||||
<div class="flex items-center just ml5">
|
||||
<div class="flex items-center justify-center ml5">
|
||||
<el-tag size="small">
|
||||
{{ v.deptName }}
|
||||
</el-tag>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
>
|
||||
<el-option v-for="v in state.options" :key="v.id" :label="getDictById(v.rulePriceType, v)" :value="v.id">
|
||||
<div class="flex items-center">
|
||||
<div class="flex items-center ml5">
|
||||
<div class="flex items-center justify-center ml5">
|
||||
<dict-tag :options="state.walletRulePriceType" :value="v.rulePriceType" />
|
||||
<div class="ml-2">
|
||||
<span>超过</span>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<el-option v-for="v in state.options" :key="v.id" :label="`${v.name}`" :value="v.id">
|
||||
<div class="flex items-center">
|
||||
<div class="color-primary">{{ v.name }}</div>
|
||||
<div class="flex items-center just ml5">
|
||||
<div class="flex items-center justify-center ml5">
|
||||
<el-tag size="small">
|
||||
{{ state.walletType.find((i: any) => i.value == v.uniqueCode)?.label }}
|
||||
</el-tag>
|
||||
@@ -68,8 +68,6 @@ const state = reactive<any>({
|
||||
watch(
|
||||
selectId,
|
||||
(newVal, oldValue) => {
|
||||
console.log(newVal, "newVal")
|
||||
|
||||
if (newVal == oldValue) return
|
||||
state.selectId = newVal
|
||||
getOptions()
|
||||
@@ -88,7 +86,7 @@ async function getOptions() {
|
||||
state.options = data.records ?? []
|
||||
if (props.autoFirst && state.options.length != 0) {
|
||||
state.selectId = state.options[0].id
|
||||
emit("change", state.selectId)
|
||||
emit("change", selectId)
|
||||
}
|
||||
const { wallet_type } = useDict("wallet_type")
|
||||
state.walletType = wallet_type
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
@visible-change="(e: boolean) => e && getOptions()"
|
||||
>
|
||||
<el-option v-for="v in state.options" :key="v.id" :label="`${v.name}`" :value="v.id">
|
||||
<div class="flex items-center">
|
||||
<div class="flex items-center justify-center">
|
||||
<div class="color-primary">{{ v.name }}</div>
|
||||
</div>
|
||||
</el-option>
|
||||
|
||||
@@ -21,10 +21,12 @@ import SelectMch from "/@/components/Select/SelectMch.vue"
|
||||
import SelectDept from "/@/components/Select/SelectDept.vue"
|
||||
import SelectCtcg from "/@/components/Select/SelectCtcg.vue"
|
||||
import SelectCtcgol from "/@/components/Select/SelectCtcgol.vue"
|
||||
import SelectHardGroup from "/@/components/Select/selectHardGroup.vue"
|
||||
import SelectHardGroup from "/@/components/Select/SelectHardGroup.vue"
|
||||
import SelectHandlerUser from "/@/components/Select/SelectHandlerUser.vue"
|
||||
import SelectSupplier from "/@/components/Select/SelectSupplier.vue"
|
||||
import SelectMchRule from "/@/components/Select/SelectMchRule.vue"
|
||||
import SelectHardSpuCategory from "/@/components/Select/SelectHardSpuCategory.vue"
|
||||
import SelectHard from "/@/components/Select/SelectHard.vue"
|
||||
import TreeMultipleSelect from "/@/components/TreeMultipleSelect/index.vue"
|
||||
|
||||
// 第三方组件
|
||||
@@ -63,6 +65,8 @@ export default {
|
||||
app.component("PreviewImage", PreviewImage)
|
||||
app.component("DraggableDepTree", DraggableDepTree)
|
||||
app.component("TreeMultipleSelect", TreeMultipleSelect)
|
||||
app.component("SelectHard", SelectHard)
|
||||
app.component("SelectHardSpuCategory", SelectHardSpuCategory)
|
||||
|
||||
app.component("SelectUser", SelectUser)
|
||||
app.component("SelectWalletType", SelectWalletType)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<template #label>
|
||||
<span>排序:</span>
|
||||
<span>排序</span>
|
||||
<tip content="越大越在前" />
|
||||
</template>
|
||||
<el-input-number :min="0" :step="1" v-model="form.sort" placeholder="" />
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<el-row>
|
||||
<div class="mb8" style="width: 100%">
|
||||
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()" v-auth="'hard_hardSpuRepertory_add'">
|
||||
新 增
|
||||
更新库存
|
||||
</el-button>
|
||||
<el-button
|
||||
plain
|
||||
|
||||
@@ -1,52 +1,70 @@
|
||||
<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-dialog :title="form.id ? '编辑' : '新增'" width="40%" v-model="visible" :close-on-click-modal="false" draggable>
|
||||
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="100px" v-loading="loading">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="商品分类id" prop="spuCategoryId">
|
||||
<el-input v-model="form.spuCategoryId" placeholder="请输入商品分类id" />
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="设备" prop="hardId">
|
||||
<select-hard v-model="form.hardId" :apiParams="{ type: '4' }" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item prop="hardDoorNumber">
|
||||
<template #label>
|
||||
<span>商品层数</span>
|
||||
<tip content="商品在智能柜的层数,按层数放置会提高识别率" />
|
||||
</template>
|
||||
<el-input-number :min="0" :step="1" v-model="form.hardDoorNumber" placeholder="" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="商品名" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入商品名" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="分类" prop="spuCategoryId">
|
||||
<select-hard-spu-category v-model="form.spuCategoryId" :apiParams="{ hardId: form.hardId }" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="商品图片" prop="pic">
|
||||
<el-input v-model="form.pic" placeholder="请输入商品图片" />
|
||||
<upload-imgs v-model="form.pic" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="单价(分)" prop="price">
|
||||
<el-input v-model="form.price" placeholder="请输入单价(分)" />
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="单价" prop="price">
|
||||
<el-input-number :precision="2" :min="0" :step="1" v-model="form.price" placeholder="" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="销量" prop="salesCount">
|
||||
<el-input v-model="form.salesCount" placeholder="请输入销量" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="库存" prop="repertoryCount">
|
||||
<el-input v-model="form.repertoryCount" placeholder="请输入库存" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input v-model="form.sort" placeholder="请输入排序" />
|
||||
<template #label>
|
||||
<span>排序</span>
|
||||
<tip content="越大越在前" />
|
||||
</template>
|
||||
<el-input-number :min="0" :step="1" v-model="form.sort" placeholder="" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="是否启用" prop="status">
|
||||
<el-input v-model="form.status" placeholder="请输入是否启用" />
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio v-for="v in yes_no_type" :key="v.value" :label="v.value" border>
|
||||
{{ v.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item prop="isDefault">
|
||||
<template #label>
|
||||
<span>是否标品</span>
|
||||
<tip content="选择是,该商品将会根据商品图片建模" />
|
||||
</template>
|
||||
<el-radio-group v-model="form.isDefault">
|
||||
<el-radio v-for="v in yes_no_type" :key="v.value" :label="v.value" border>
|
||||
{{ v.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@@ -63,8 +81,7 @@
|
||||
<script setup lang="ts" name="HardSpuDialog">
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
import { getObj, addObj, putObj } from "/@/api/hard/hard-spu"
|
||||
import { rule } from "/@/utils/validate"
|
||||
import * as hardSpu from "/@/api/hard/hard-spu"
|
||||
const emit = defineEmits(["refresh"])
|
||||
|
||||
// 定义变量内容
|
||||
@@ -72,22 +89,34 @@ const dataFormRef = ref()
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
// 定义字典
|
||||
|
||||
const { yes_no_type } = useDict("yes_no_type")
|
||||
// 提交表单数据
|
||||
const form = reactive({
|
||||
id: "",
|
||||
hardId: "",
|
||||
spuCategoryId: "",
|
||||
name: "",
|
||||
pic: "",
|
||||
price: "",
|
||||
salesCount: "",
|
||||
repertoryCount: "",
|
||||
sort: "",
|
||||
status: "",
|
||||
price: 0,
|
||||
salesCount: 0,
|
||||
repertoryCount: 0,
|
||||
sort: 0,
|
||||
hardDoorNumber: "",
|
||||
status: "1",
|
||||
isDefault: "0",
|
||||
})
|
||||
|
||||
// 定义校验规则
|
||||
const dataRules = ref({})
|
||||
const dataRules = ref({
|
||||
name: [{ required: true, message: "请输入商品名", trigger: "blur" }],
|
||||
hardId: [{ required: true, message: "请选择设备", trigger: "blur" }],
|
||||
spuCategoryId: [{ required: true, message: "请选择分类", trigger: "change" }],
|
||||
pic: [{ required: true, message: "请选择图片", trigger: "change" }],
|
||||
price: [{ required: true, message: "请输入价格", trigger: "blur" }],
|
||||
sort: [{ required: true, message: "请输入排序", trigger: "blur" }],
|
||||
status: [{ required: true, message: "请选择是否启用", trigger: "change" }],
|
||||
isDefault: [{ required: true, message: "请选择是否标品", trigger: "change" }],
|
||||
})
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (id: string) => {
|
||||
@@ -113,7 +142,7 @@ const onSubmit = async () => {
|
||||
|
||||
try {
|
||||
loading.value = true
|
||||
form.id ? await putObj(form) : await addObj(form)
|
||||
form.id ? await hardSpu.putObj(form) : await hardSpu.addObj(form)
|
||||
useMessage().success(form.id ? "修改成功" : "添加成功")
|
||||
visible.value = false
|
||||
emit("refresh")
|
||||
@@ -128,7 +157,8 @@ const onSubmit = async () => {
|
||||
const gethardSpuData = (id: string) => {
|
||||
// 获取数据
|
||||
loading.value = true
|
||||
getObj(id)
|
||||
hardSpu
|
||||
.getObj(id)
|
||||
.then((res: any) => {
|
||||
Object.assign(form, res.data)
|
||||
})
|
||||
|
||||
@@ -29,21 +29,58 @@
|
||||
@sort-change="sortChangeHandle"
|
||||
>
|
||||
<el-table-column type="selection" width="40" align="center" />
|
||||
<el-table-column type="index" label="#" width="40" />
|
||||
<el-table-column prop="spuCategoryId" label="商品分类id" show-overflow-tooltip />
|
||||
<el-table-column prop="name" label="商品名" show-overflow-tooltip />
|
||||
<el-table-column prop="pic" label="商品图片" show-overflow-tooltip />
|
||||
<el-table-column prop="price" label="单价(分)" show-overflow-tooltip />
|
||||
<el-table-column prop="salesCount" label="销量" show-overflow-tooltip />
|
||||
<el-table-column prop="repertoryCount" label="库存" show-overflow-tooltip />
|
||||
<el-table-column prop="sort" label="排序" show-overflow-tooltip />
|
||||
<el-table-column prop="status" label="是否启用" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="150">
|
||||
<el-table-column type="index" label="#" width="80" />
|
||||
<el-table-column prop="name" width="120" label="商品名" />
|
||||
<el-table-column prop="pic" width="120" label="商品图片">
|
||||
<template #default="{ row }">
|
||||
<preview-image width="50px" height="50px" :src="row.pic" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="categoryName" width="120" label="分类" />
|
||||
<el-table-column width="150" label="商户">
|
||||
<template #default="{ row }">
|
||||
<span>{{ row.merchantName }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="150" label="设备名">
|
||||
<template #default="{ row }">
|
||||
<span>{{ row.hardName }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="price" label="单价">
|
||||
<template #default="{ row }">
|
||||
<span class="color-success">{{ displayPrice(row.price) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="salesCount" label="销量">
|
||||
<template #default="{ row }">
|
||||
<span class="color-primary">{{ row.salesCount }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="repertoryCount" label="库存">
|
||||
<template #default="{ row }">
|
||||
<span class="color-primary">{{ row.repertoryCount }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="sort" label="排序" />
|
||||
<el-table-column prop="status" label="是否启用">
|
||||
<template #default="{ row }">
|
||||
<dict-tag :options="yes_no_type" :value="row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="isDefault" label="是否标品">
|
||||
<template #default="{ row }">
|
||||
<dict-tag :options="yes_no_type" :value="row.isDefault" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" fixed="right" width="150">
|
||||
<template #default="scope">
|
||||
<el-button icon="edit-pen" text type="primary" v-auth="'hard_hardSpu_edit'" @click="formDialogRef.openDialog(scope.row.id)"
|
||||
>编辑</el-button
|
||||
>
|
||||
<el-button icon="delete" text type="primary" v-auth="'hard_hardSpu_del'" @click="handleDelete([scope.row.id])">删除</el-button>
|
||||
<el-button icon="edit-pen" text type="primary" v-auth="'hard_hardSpu_edit'" @click="formDialogRef.openDialog(scope.row.id)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button icon="delete" text type="primary" v-auth="'hard_hardSpu_del'" @click="handleDelete([scope.row.id])">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -57,14 +94,15 @@
|
||||
|
||||
<script setup lang="ts" name="systemHardSpu">
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table"
|
||||
import { fetchList, delObjs } from "/@/api/hard/hard-spu"
|
||||
import * as hardSpu from "/@/api/hard/hard-spu"
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
import { displayPrice } from "/@/utils/formatMoney"
|
||||
|
||||
// 引入组件
|
||||
const FormDialog = defineAsyncComponent(() => import("./form.vue"))
|
||||
// 定义查询字典
|
||||
|
||||
const { yes_no_type } = useDict("yes_no_type")
|
||||
// 定义变量内容
|
||||
const formDialogRef = ref()
|
||||
// 搜索变量
|
||||
@@ -76,7 +114,7 @@ const multiple = ref(true)
|
||||
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {},
|
||||
pageList: fetchList,
|
||||
pageList: hardSpu.pageJoin,
|
||||
})
|
||||
|
||||
// table hook
|
||||
@@ -111,7 +149,7 @@ const handleDelete = async (ids: string[]) => {
|
||||
}
|
||||
|
||||
try {
|
||||
await delObjs(ids)
|
||||
await hardSpu.delObjs(ids)
|
||||
getDataList()
|
||||
useMessage().success("删除成功")
|
||||
} catch (err: any) {
|
||||
|
||||
@@ -1,130 +1,130 @@
|
||||
<template>
|
||||
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible" width="30%" :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="24" class="mb20">
|
||||
<el-form-item label="套餐名" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入套餐名" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible" width="30%" :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="24" class="mb20">
|
||||
<el-form-item label="套餐名" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入套餐名" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="支付金额" prop="payPrice">
|
||||
<el-input-number v-model="form.payPrice" :min="0" :precision="2" :step="0.01" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="支付金额" prop="payPrice">
|
||||
<el-input-number v-model="form.payPrice" :min="0" :precision="2" :step="0.01" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="赠送金额" prop="bonusPrice">
|
||||
<el-input-number v-model="form.bonusPrice" :min="0" :precision="2" :step="0.01" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="赠送金额" prop="bonusPrice">
|
||||
<el-input-number v-model="form.bonusPrice" :min="0" :precision="2" :step="0.01" />
|
||||
</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 v-for="v in yes_no_type" :key="v.value" :label="v.value">
|
||||
{{ v.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
</el-row>
|
||||
</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-col :span="24" class="mb20">
|
||||
<el-form-item label="是否启用" prop="status">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio v-for="v in yes_no_type" :key="v.value" :label="v.value">
|
||||
{{ v.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</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>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="WalletRechargePackageDialog">
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
import { useMessage } from "/@/hooks/message";
|
||||
import { getObj, addObj, putObj } from "/@/api/wallet/wallet-recharge-package";
|
||||
import { rule } from '/@/utils/validate';
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
import { getObj, addObj, putObj } from "/@/api/wallet/wallet-recharge-package"
|
||||
import { rule } from "/@/utils/validate"
|
||||
import { storePrice } from "/@/utils/formatMoney"
|
||||
const emit = defineEmits(['refresh']);
|
||||
const emit = defineEmits(["refresh"])
|
||||
|
||||
// 定义变量内容
|
||||
const dataFormRef = ref();
|
||||
const dataFormRef = ref()
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
// 定义查询字典
|
||||
const { yes_no_type } = useDict('yes_no_type');
|
||||
const { yes_no_type } = useDict("yes_no_type")
|
||||
// 提交表单数据
|
||||
const form = reactive({
|
||||
id: '',
|
||||
name: '',
|
||||
payPrice: '',
|
||||
bonusPrice: '',
|
||||
status: "1",
|
||||
});
|
||||
id: "",
|
||||
name: "",
|
||||
payPrice: "",
|
||||
bonusPrice: "",
|
||||
status: "1",
|
||||
})
|
||||
|
||||
// 定义校验规则
|
||||
const dataRules = ref({
|
||||
name: [{ required: true, message: '套餐名不能为空', trigger: 'blur' }],
|
||||
payPrice: [{ required: true, message: '支付金额不能为空', trigger: 'blur' }],
|
||||
bonusPrice: [{ required: true, message: '赠送金额不能为空', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }]
|
||||
name: [{ required: true, message: "套餐名不能为空", trigger: "blur" }],
|
||||
payPrice: [{ required: true, message: "支付金额不能为空", trigger: "blur" }],
|
||||
bonusPrice: [{ required: true, message: "赠送金额不能为空", trigger: "blur" }],
|
||||
status: [{ required: true, message: "状态不能为空", trigger: "blur" }],
|
||||
})
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (id: string) => {
|
||||
visible.value = true
|
||||
form.id = ''
|
||||
visible.value = true
|
||||
form.id = ""
|
||||
|
||||
// 重置表单数据
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
// 获取walletRechargePackage信息
|
||||
if (id) {
|
||||
form.id = id
|
||||
getwalletRechargePackageData(id)
|
||||
}
|
||||
};
|
||||
// 重置表单数据
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields()
|
||||
})
|
||||
// 获取walletRechargePackage信息
|
||||
if (id) {
|
||||
form.id = id
|
||||
getwalletRechargePackageData(id)
|
||||
}
|
||||
}
|
||||
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => { });
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
loading.value = true;
|
||||
const pa = {
|
||||
...form,
|
||||
payPrice: storePrice(form.payPrice),
|
||||
bonusPrice: storePrice(form.bonusPrice),
|
||||
}
|
||||
form.id ? await putObj(pa) : await addObj(pa);
|
||||
useMessage().success(form.id ? '修改成功' : '添加成功');
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
const valid = await dataFormRef.value.validate().catch(() => {})
|
||||
if (!valid) return false
|
||||
|
||||
try {
|
||||
loading.value = true
|
||||
const pa = {
|
||||
...form,
|
||||
payPrice: storePrice(form.payPrice),
|
||||
bonusPrice: storePrice(form.bonusPrice),
|
||||
}
|
||||
form.id ? await putObj(pa) : await addObj(pa)
|
||||
useMessage().success(form.id ? "修改成功" : "添加成功")
|
||||
visible.value = false
|
||||
emit("refresh")
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化表单数据
|
||||
const getwalletRechargePackageData = (id: string) => {
|
||||
// 获取数据
|
||||
loading.value = true
|
||||
getObj(id).then((res: any) => {
|
||||
Object.assign(form, res.data)
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
};
|
||||
// 获取数据
|
||||
loading.value = true
|
||||
getObj(id)
|
||||
.then((res: any) => {
|
||||
Object.assign(form, res.data)
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog
|
||||
});
|
||||
</script>
|
||||
openDialog,
|
||||
})
|
||||
</script>
|
||||
Reference in new issue
Block a user