Merge branch 'master' of https://codeup.aliyun.com/bsdtec/biz-pc-cloud
This commit is contained in:
commit
8624e81f6d
11 files changed
+861
-260
No files matched your search
@@ -1,101 +1,99 @@
|
||||
<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-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="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-form-item label="餐段类型" prop="categoryType">
|
||||
<el-select v-model="form.categoryType" placeholder="请选择餐段类型" multiple>
|
||||
<el-option :value="item.value" :label="item.label" v-for="(item, index) in daily_menu" :key="index"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="分类图" prop="picUrl">
|
||||
<upload-img v-model="form.picUrl"></upload-img>
|
||||
</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-form-item label="餐段类型" prop="categoryType">
|
||||
<el-select v-model="form.categoryType" placeholder="请选择餐段类型">
|
||||
<el-option :value="item.value" :label="item.label" v-for="(item, index) in daily_menu" :key="index"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="分类图" prop="picUrl">
|
||||
<upload-img v-model="form.picUrl"></upload-img>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="分类排序" prop="sort">
|
||||
<el-input v-model="form.sort" placeholder="请输入分类排序" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="分类排序" prop="sort">
|
||||
<el-input v-model="form.sort" placeholder="请输入分类排序"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<!-- <el-col :span="12" class="mb20">-->
|
||||
<!-- <el-form-item label="开启状态" prop="status">-->
|
||||
<!-- <el-radio-group v-model="form.status">-->
|
||||
<!-- <el-radio label="开启状态" border>开启状态</el-radio>-->
|
||||
<!-- </el-radio-group>-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="12" class="mb20">-->
|
||||
<!-- <el-form-item label="开启状态" prop="status">-->
|
||||
<!-- <el-radio-group v-model="form.status">-->
|
||||
<!-- <el-radio label="开启状态" border>开启状态</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-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="CanteenCategoryDialog">
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
import { useMessage } from "/@/hooks/message";
|
||||
import { getObj, addObj, putObj } from '/@/api/canteen/canteenCategory'
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
import { getObj, addObj, putObj } from '/@/api/canteen/canteenCategory';
|
||||
import { rule } from '/@/utils/validate';
|
||||
const emit = defineEmits(['refresh']);
|
||||
|
||||
// 定义变量内容
|
||||
const dataFormRef = ref();
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const visible = ref(false);
|
||||
const loading = ref(false);
|
||||
// 定义字典
|
||||
const { daily_menu } = useDict('daily_menu')
|
||||
const { daily_menu } = useDict('daily_menu');
|
||||
// 提交表单数据
|
||||
const form = reactive({
|
||||
id:'',
|
||||
parentId: '',
|
||||
name: '',
|
||||
picUrl: '',
|
||||
sort: '',
|
||||
status: '',
|
||||
creator: '',
|
||||
updater: '',
|
||||
deleted: '',
|
||||
deptId: '',
|
||||
categoryType: '',
|
||||
id: '',
|
||||
parentId: '',
|
||||
name: '',
|
||||
picUrl: '',
|
||||
sort: '',
|
||||
status: '',
|
||||
creator: '',
|
||||
updater: '',
|
||||
deleted: '',
|
||||
deptId: '',
|
||||
categoryType: [],
|
||||
});
|
||||
|
||||
// 定义校验规则
|
||||
const dataRules = ref({
|
||||
name: [{required: true, message: '分类名称不能为空', trigger: 'blur'}],
|
||||
categoryType: [{required: true, message: '餐段类型不能为空', trigger: 'blur'}],
|
||||
sort: [{required: true, message: '分类排序不能为空', trigger: 'blur'}],
|
||||
})
|
||||
name: [{ required: true, message: '分类名称不能为空', trigger: 'blur' }],
|
||||
categoryType: [{ required: true, message: '餐段类型不能为空', trigger: 'blur' }],
|
||||
sort: [{ required: true, message: '分类排序不能为空', trigger: 'blur' }],
|
||||
});
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (id: string) => {
|
||||
visible.value = true
|
||||
form.id = ''
|
||||
visible.value = true;
|
||||
form.id = '';
|
||||
|
||||
// 重置表单数据
|
||||
// 重置表单数据
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
|
||||
// 获取canteenCategory信息
|
||||
if (id) {
|
||||
form.id = id
|
||||
getcanteenCategoryData(id)
|
||||
}
|
||||
// 获取canteenCategory信息
|
||||
if (id) {
|
||||
form.id = id;
|
||||
getcanteenCategoryData(id);
|
||||
}
|
||||
};
|
||||
|
||||
// 提交
|
||||
@@ -104,32 +102,35 @@ const onSubmit = async () => {
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
loading.value = true;
|
||||
form.id ? await putObj(form) : await addObj(form);
|
||||
loading.value = true;
|
||||
form.id
|
||||
? await putObj({ ...form, categoryType: form.categoryType.join(',') })
|
||||
: await addObj({ ...form, categoryType: form.categoryType.join(',') });
|
||||
useMessage().success(form.id ? '修改成功' : '添加成功');
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 初始化表单数据
|
||||
const getcanteenCategoryData = (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, { categoryType: res.data.categoryType.split(',') });
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog
|
||||
openDialog,
|
||||
});
|
||||
</script>
|
||||
@@ -1,135 +1,134 @@
|
||||
<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="name" >
|
||||
<el-input placeholder="请输入分类名称" v-model="state.queryForm.name" />
|
||||
</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="'canteen_canteenCategory_add'">
|
||||
新 增
|
||||
</el-button>
|
||||
<el-button plain :disabled="multiple" icon="Delete" type="primary"
|
||||
v-auth="'canteen_canteenCategory_del'" @click="handleDelete(selectObjs)">
|
||||
删除
|
||||
</el-button>
|
||||
<right-toolbar v-model:showSearch="showSearch" :export="'canteen_canteenCategory_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"
|
||||
<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="name">
|
||||
<el-input placeholder="请输入分类名称" v-model="state.queryForm.name" />
|
||||
</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="'canteen_canteenCategory_add'">
|
||||
新 增
|
||||
</el-button>
|
||||
<el-button plain :disabled="multiple" icon="Delete" type="primary" v-auth="'canteen_canteenCategory_del'" @click="handleDelete(selectObjs)">
|
||||
删除
|
||||
</el-button>
|
||||
<right-toolbar
|
||||
v-model:showSearch="showSearch"
|
||||
:export="'canteen_canteenCategory_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="40" />
|
||||
<el-table-column prop="name" label="分类名称" show-overflow-tooltip/>
|
||||
<el-table-column prop="categoryType" label="餐段类型" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<dict-tag :options="daily_menu" :value="scope.row.categoryType"></dict-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="picUrl" label="分类图" show-overflow-tooltip/>
|
||||
<el-table-column prop="createBy" label="创建者" show-overflow-tooltip/>
|
||||
<el-table-column prop="updateBy" label="更新者" show-overflow-tooltip/>
|
||||
<el-table-column prop="createTime" label="创建时间" show-overflow-tooltip/>
|
||||
<el-table-column label="操作" width="150">
|
||||
<template #default="scope">
|
||||
<el-button icon="edit-pen" text type="primary" v-auth="'canteen_canteenCategory_edit'"
|
||||
@click="formDialogRef.openDialog(scope.row.id)">编辑</el-button>
|
||||
<el-button icon="delete" text type="primary" v-auth="'canteen_canteenCategory_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>
|
||||
@sort-change="sortChangeHandle"
|
||||
>
|
||||
<el-table-column type="selection" width="40" align="center" />
|
||||
<el-table-column type="index" label="#" width="40" />
|
||||
<el-table-column prop="name" label="分类名称" show-overflow-tooltip />
|
||||
<el-table-column prop="categoryType" label="餐段类型" show-overflow-tooltip width="180">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="daily_menu" :value="scope.row.categoryType?.split(',')"></dict-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="picUrl" label="分类图" show-overflow-tooltip />
|
||||
<el-table-column prop="createBy" label="创建者" show-overflow-tooltip />
|
||||
<el-table-column prop="updateBy" label="更新者" show-overflow-tooltip />
|
||||
<el-table-column prop="createTime" label="创建时间" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="150">
|
||||
<template #default="scope">
|
||||
<el-button icon="edit-pen" text type="primary" v-auth="'canteen_canteenCategory_edit'" @click="formDialogRef.openDialog(scope.row.id)"
|
||||
>编辑</el-button
|
||||
>
|
||||
<el-button icon="delete" text type="primary" v-auth="'canteen_canteenCategory_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>
|
||||
<!-- 编辑、新增 -->
|
||||
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="systemCanteenCategory">
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import { fetchList, delObjs } from "/@/api/canteen/canteenCategory";
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||
import { fetchList, delObjs } from '/@/api/canteen/canteenCategory';
|
||||
import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
|
||||
// 引入组件
|
||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
// 定义查询字典
|
||||
const { daily_menu } = useDict('daily_menu')
|
||||
const { daily_menu } = useDict('daily_menu');
|
||||
// 定义变量内容
|
||||
const formDialogRef = ref()
|
||||
const formDialogRef = ref();
|
||||
// 搜索变量
|
||||
const queryRef = ref()
|
||||
const showSearch = ref(true)
|
||||
const queryRef = ref();
|
||||
const showSearch = ref(true);
|
||||
// 多选变量
|
||||
const selectObjs = ref([]) as any
|
||||
const multiple = ref(true)
|
||||
const selectObjs = ref([]) as any;
|
||||
const multiple = ref(true);
|
||||
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {},
|
||||
pageList: fetchList
|
||||
})
|
||||
queryForm: {},
|
||||
pageList: fetchList,
|
||||
});
|
||||
|
||||
// table hook
|
||||
const {
|
||||
getDataList,
|
||||
currentChangeHandle,
|
||||
sizeChangeHandle,
|
||||
sortChangeHandle,
|
||||
downBlobFile,
|
||||
tableStyle
|
||||
} = useTable(state)
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state);
|
||||
|
||||
// 清空搜索条件
|
||||
const resetQuery = () => {
|
||||
// 清空搜索条件
|
||||
queryRef.value?.resetFields()
|
||||
// 清空多选
|
||||
selectObjs.value = []
|
||||
getDataList()
|
||||
}
|
||||
// 清空搜索条件
|
||||
queryRef.value?.resetFields();
|
||||
// 清空多选
|
||||
selectObjs.value = [];
|
||||
getDataList();
|
||||
};
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
downBlobFile('/canteen/canteenCategory/export', Object.assign(state.queryForm, { ids: selectObjs }), 'canteenCategory.xlsx')
|
||||
}
|
||||
downBlobFile('/canteen/canteenCategory/export', Object.assign(state.queryForm, { ids: selectObjs }), 'canteenCategory.xlsx');
|
||||
};
|
||||
|
||||
// 多选事件
|
||||
const selectionChangHandle = (objs: { id: string }[]) => {
|
||||
selectObjs.value = objs.map(({ id }) => id);
|
||||
multiple.value = !objs.length;
|
||||
selectObjs.value = objs.map(({ id }) => id);
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm('此操作将永久删除');
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await useMessageBox().confirm('此操作将永久删除');
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObjs(ids);
|
||||
getDataList();
|
||||
useMessage().success('删除成功');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
try {
|
||||
await delObjs(ids);
|
||||
getDataList();
|
||||
useMessage().success('删除成功');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -50,10 +50,10 @@
|
||||
<el-table-column prop="categoryId" label="商品分类编号" width="120px" show-overflow-tooltip />
|
||||
<el-table-column prop="picUrl" label="商品封面图" align="center" width="160px" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<el-image style="width: 100px; height: 100px" :src="imageBaseUrl + scope.row.picUrl" fit="cover" />
|
||||
<preview-image style="width: 50px; height: 50px" :src="imageBaseUrl + scope.row.picUrl" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column prop="sliderPicUrls" label="商品轮播图" show-overflow-tooltip/>-->
|
||||
<!-- <el-table-column prop="sliderPicUrls" label="商品轮播图" show-overflow-tooltip /> -->
|
||||
<el-table-column prop="sort" label="排序字段" show-overflow-tooltip />
|
||||
<el-table-column prop="status" label="上架状态" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
@@ -64,9 +64,9 @@
|
||||
<el-table-column prop="marketPrice" label="市场价" show-overflow-tooltip />
|
||||
<el-table-column prop="costPrice" label="成本价" show-overflow-tooltip />
|
||||
<el-table-column prop="stock" label="库存" show-overflow-tooltip />
|
||||
<!-- <el-table-column prop="giveIntegral" 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 prop="virtualSalesCount" label="虚拟销量" show-overflow-tooltip />-->
|
||||
<!-- <el-table-column prop="virtualSalesCount" label="虚拟销量" show-overflow-tooltip /> -->
|
||||
<el-table-column prop="createTime" label="创建时间" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="150" fixed="right">
|
||||
<template #default="scope">
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
<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="12" class="mb20">
|
||||
<el-form-item label="条码" prop="barCode">
|
||||
<el-input v-model="form.barCode" placeholder="请输入条码" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<!-- <el-col :span="12" class="mb20">
|
||||
<el-form-item label="spuID" prop="spuId">
|
||||
<el-select v-model="form.spuId" placeholder="请选择spuID">
|
||||
<el-option label="1234" value="1234"></el-option>
|
||||
<el-option label="5678" value="5678"></el-option>
|
||||
</el-select>
|
||||
</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="SupermarketAuxiliaryCodeDialog">
|
||||
import { nanoid } from 'nanoid';
|
||||
|
||||
// import { useMessage } from '/@/hooks/message';
|
||||
// import { getObj, addObj, putObj } from '/@/api/supermarket/supermarketAuxiliaryCode';
|
||||
const emit = defineEmits(['refresh']);
|
||||
|
||||
// 定义变量内容
|
||||
const dataFormRef = ref();
|
||||
const visible = ref(false);
|
||||
const loading = ref(false);
|
||||
|
||||
// 提交表单数据
|
||||
const form = reactive<any>({
|
||||
id: '',
|
||||
barCode: '',
|
||||
});
|
||||
|
||||
// 定义校验规则
|
||||
const dataRules = ref({
|
||||
barCode: [{ required: true, message: '条码不能为空', trigger: 'blur' }],
|
||||
spuId: [{ required: true, message: 'spuID不能为空', trigger: 'blur' }],
|
||||
});
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (rowData: any = null) => {
|
||||
visible.value = true;
|
||||
form.id = nanoid(5);
|
||||
|
||||
// 重置表单数据
|
||||
dataFormRef.value?.resetFields();
|
||||
|
||||
if (rowData) {
|
||||
Object.assign(form, rowData);
|
||||
}
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
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 ? '修改成功' : '添加成功');
|
||||
emit('refresh', { ...form });
|
||||
visible.value = false;
|
||||
// } catch (err: any) {
|
||||
// useMessage().error(err.msg);
|
||||
// } finally {
|
||||
// loading.value = false;
|
||||
// }
|
||||
};
|
||||
|
||||
// 初始化表单数据
|
||||
// const getsupermarketAuxiliaryCodeData = (id: string) => {
|
||||
// // 获取数据
|
||||
// loading.value = true;
|
||||
// getObj(id)
|
||||
// .then((res: any) => {
|
||||
// Object.assign(form, res.data);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// loading.value = false;
|
||||
// });
|
||||
// };
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog,
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,163 @@
|
||||
<template>
|
||||
<div style="width: 100%">
|
||||
<!-- <el-row v-show="showSearch">
|
||||
<el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList">
|
||||
<el-form-item label="条码" prop="barCode">
|
||||
<el-input placeholder="请输入条码" v-model="state.queryForm.barCode" />
|
||||
</el-form-item>
|
||||
<el-form-item label="spuID" prop="spuId">
|
||||
<el-input v-model="state.queryForm.spuId" placeholder="请输入spuID" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="search" type="primary" v-auth="'supermarket_supermarketAuxiliaryCode_view'" @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_supermarketAuxiliaryCode_add'"
|
||||
>
|
||||
新 增
|
||||
</el-button>
|
||||
<!-- <el-button
|
||||
plain
|
||||
:disabled="multiple"
|
||||
icon="Delete"
|
||||
type="primary"
|
||||
v-auth="'supermarket_supermarketAuxiliaryCode_del'"
|
||||
@click="handleDelete(selectedCodeIds)"
|
||||
>
|
||||
删 除
|
||||
</el-button>
|
||||
<right-toolbar
|
||||
v-model:showSearch="showSearch"
|
||||
:export="'supermarket_supermarketAuxiliaryCode_export'"
|
||||
@exportExcel="exportExcel"
|
||||
class="ml10 mr20"
|
||||
style="float: right"
|
||||
@queryTable="getDataList"
|
||||
></right-toolbar> -->
|
||||
</div>
|
||||
</el-row>
|
||||
<el-table :data="supermarketAuxiliaryCodeEntityList" border :cell-style="tableStyle.cellStyle" :header-cell-style="tableStyle.headerCellStyle">
|
||||
<!-- <el-table-column type="selection" width="40" align="center" fixed /> -->
|
||||
<el-table-column type="index" label="#" width="50" />
|
||||
<el-table-column prop="barCode" label="条码" show-overflow-tooltip />
|
||||
<!-- <el-table-column prop="spuId" label="spuID" show-overflow-tooltip /> -->
|
||||
<el-table-column label="操作" width="150" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
icon="edit-pen"
|
||||
text
|
||||
type="primary"
|
||||
v-auth="'supermarket_supermarketAuxiliaryCode_edit'"
|
||||
@click="formDialogRef.openDialog(scope.row)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button icon="delete" text type="primary" v-auth="'supermarket_supermarketAuxiliaryCode_del'" @click="handleDelete(scope.row)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- <pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" /> -->
|
||||
|
||||
<!-- 编辑、新增 -->
|
||||
<form-dialog ref="formDialogRef" @refresh="getDataList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||
// import { fetchList, delObjs } from '/@/api/supermarket/supermarketAuxiliaryCode';
|
||||
// import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
|
||||
const supermarketAuxiliaryCodeEntityList = defineModel<any>('supermarketAuxiliaryCodeEntityList', { default: [] });
|
||||
|
||||
// 定义变量内容
|
||||
const formDialogRef = ref();
|
||||
// 搜索变量
|
||||
// const queryRef = ref();
|
||||
// const showSearch = ref(true);
|
||||
// 多选变量
|
||||
// const selectedCodeIds = ref<any>([]); // 已勾选的行的id集合
|
||||
// const multiple = ref(true);
|
||||
|
||||
// const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
// queryForm: {},
|
||||
// pageList: fetchList,
|
||||
// });
|
||||
|
||||
// table hook
|
||||
// const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state);
|
||||
|
||||
const tableStyle = {
|
||||
cellStyle: { textAlign: 'center' },
|
||||
headerCellStyle: {
|
||||
textAlign: 'center',
|
||||
background: 'var(--el-table-row-hover-bg-color)',
|
||||
color: 'var(--el-text-color-primary)',
|
||||
},
|
||||
};
|
||||
|
||||
const getDataList = (formData: any) => {
|
||||
console.log(formData);
|
||||
const index = supermarketAuxiliaryCodeEntityList.value.findIndex((item: any) => item.id === formData.id);
|
||||
if (index === -1) {
|
||||
supermarketAuxiliaryCodeEntityList.value.push(formData);
|
||||
} else {
|
||||
supermarketAuxiliaryCodeEntityList.value[index] = formData;
|
||||
}
|
||||
console.log('a', supermarketAuxiliaryCodeEntityList.value);
|
||||
};
|
||||
// 清空搜索条件
|
||||
// const resetQuery = () => {
|
||||
// // 清空搜索条件
|
||||
// queryRef.value?.resetFields();
|
||||
// // 清空多选
|
||||
// selectedCode.value = [];
|
||||
// selectedCodeIds.value = [];
|
||||
// getDataList();
|
||||
// };
|
||||
|
||||
// 导出excel
|
||||
// const exportExcel = () => {
|
||||
// downBlobFile(
|
||||
// '/supermarket/supermarketAuxiliaryCode/export',
|
||||
// Object.assign(state.queryForm, { ids: selectedCodeIds.value }),
|
||||
// 'supermarketAuxiliaryCode.xlsx'
|
||||
// );
|
||||
// };
|
||||
|
||||
// 多选事件
|
||||
// const selectionChangHandle = (objs: { id: string }[]) => {
|
||||
// selectedCode.value = objs;
|
||||
// selectedCodeIds.value = objs.map(({ id }) => id);
|
||||
// multiple.value = !objs.length;
|
||||
// };
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = async (rowData: any) => {
|
||||
supermarketAuxiliaryCodeEntityList.value = supermarketAuxiliaryCodeEntityList.value.filter((item: any) => item.id !== rowData.id);
|
||||
// try {
|
||||
// await useMessageBox().confirm('此操作将永久删除');
|
||||
// } catch {
|
||||
// return;
|
||||
// }
|
||||
// try {
|
||||
// await delObjs(ids);
|
||||
// getDataList();
|
||||
// useMessage().success('删除成功');
|
||||
// } catch (err: any) {
|
||||
// useMessage().error(err.msg);
|
||||
// }
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,134 @@
|
||||
<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="12" class="mb20">
|
||||
<el-form-item label="条码" prop="barCode">
|
||||
<el-input placeholder="请输入条码" v-model="form.barCode" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="规格" prop="spec">
|
||||
<el-input placeholder="请输入规格" v-model="form.spec" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="单位" prop="unit">
|
||||
<el-input placeholder="请输入单位" v-model="form.unit" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="form.status" placeholder="请选择状态">
|
||||
<el-option label="正常" :value="0"></el-option>
|
||||
<el-option label="停销" :value="1"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="内装数量" prop="packageNum">
|
||||
<el-input-number v-model="form.packageNum" placeholder="请输入内装数量" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<!-- <el-col :span="12" class="mb20">
|
||||
<el-form-item label="spuId" prop="spuId">
|
||||
<el-input placeholder="请输入spuId" v-model="form.spuId" />
|
||||
</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="SupermarketAuxiliaryCodeDialog">
|
||||
import { nanoid } from 'nanoid';
|
||||
|
||||
// import { useMessage } from '/@/hooks/message';
|
||||
// import { getObj, addObj, putObj } from '/@/api/supermarket/supermarketUnit';
|
||||
const emit = defineEmits(['refresh']);
|
||||
|
||||
// 定义变量内容
|
||||
const dataFormRef = ref();
|
||||
const visible = ref(false);
|
||||
const loading = ref(false);
|
||||
|
||||
// 提交表单数据
|
||||
const form = reactive({
|
||||
id: '',
|
||||
barCode: '',
|
||||
spec: '',
|
||||
unit: '',
|
||||
status: '',
|
||||
packageNum: 0,
|
||||
});
|
||||
|
||||
// 定义校验规则
|
||||
const dataRules = ref({
|
||||
barCode: [{ required: true, message: '条码不能为空', trigger: 'blur' }],
|
||||
spec: [{ required: true, message: 'spec不能为空', trigger: 'blur' }],
|
||||
unit: [{ required: true, message: '单位不能为空', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }],
|
||||
packageNum: [{ required: true, message: '内装数量不能为空', trigger: 'blur' }],
|
||||
spuId: [{ required: true, message: 'spuId不能为空', trigger: 'blur' }],
|
||||
});
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (rowData: any = null) => {
|
||||
visible.value = true;
|
||||
form.id = nanoid(5);
|
||||
|
||||
// 重置表单数据
|
||||
dataFormRef.value?.resetFields();
|
||||
|
||||
if (rowData) {
|
||||
Object.assign(form, rowData);
|
||||
}
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
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 ? '修改成功' : '添加成功');
|
||||
emit('refresh', { ...form });
|
||||
visible.value = false;
|
||||
// } catch (err: any) {
|
||||
// useMessage().error(err.msg);
|
||||
// } finally {
|
||||
// loading.value = false;
|
||||
// }
|
||||
};
|
||||
|
||||
// 初始化表单数据
|
||||
// const getSupermarketUnitData = (id: string) => {
|
||||
// // 获取数据
|
||||
// loading.value = true;
|
||||
// getObj(id)
|
||||
// .then((res: any) => {
|
||||
// Object.assign(form, res.data);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// loading.value = false;
|
||||
// });
|
||||
// };
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog,
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,172 @@
|
||||
<template>
|
||||
<div style="width: 100%">
|
||||
<!-- <el-row v-show="showSearch">
|
||||
<el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList">
|
||||
<el-form-item label="条码" prop="barCode">
|
||||
<el-input placeholder="请输入条码" v-model="state.queryForm.barCode" />
|
||||
</el-form-item>
|
||||
<el-form-item label="规格" prop="spec">
|
||||
<el-input placeholder="请输入规格" v-model="state.queryForm.spec" />
|
||||
</el-form-item>
|
||||
<el-form-item label="单位" prop="unit">
|
||||
<el-input placeholder="请输入单位" v-model="state.queryForm.unit" />
|
||||
</el-form-item>
|
||||
<el-form-item label="内装数量" prop="packageNum">
|
||||
<el-input placeholder="请输入内装数量" v-model="state.queryForm.packageNum" />
|
||||
</el-form-item>
|
||||
<el-form-item label="spuId" prop="spuId">
|
||||
<el-input placeholder="请输入spuId" v-model="state.queryForm.spuId" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="state.queryForm.status" placeholder="请选择状态">
|
||||
<el-option label="正常" :value="0" />
|
||||
<el-option label="停销" :value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="search" type="primary" v-auth="'supermarket_supermarketUnit_view'" @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" v-auth="'supermarket_supermarketUnit_add'" @click="formDialogRef.openDialog()"
|
||||
>新 增</el-button
|
||||
>
|
||||
<!-- <el-button
|
||||
plain
|
||||
:disabled="multiple"
|
||||
icon="Delete"
|
||||
type="primary"
|
||||
v-auth="'supermarket_supermarketUnit_del'"
|
||||
@click="handleDelete(selectedUnitIds)"
|
||||
>删 除</el-button
|
||||
> -->
|
||||
<!-- <right-toolbar
|
||||
v-model:showSearch="showSearch"
|
||||
:export="'supermarket_supermarketUnit_export'"
|
||||
@exportExcel="exportExcel"
|
||||
class="ml10 mr20"
|
||||
style="float: right"
|
||||
@queryTable="getDataList"
|
||||
></right-toolbar> -->
|
||||
</div>
|
||||
</el-row>
|
||||
<el-table :data="supermarketUnitEntityList" border :cell-style="tableStyle.cellStyle" :header-cell-style="tableStyle.headerCellStyle">
|
||||
<!-- <el-table-column type="selection" width="40" align="center" fixed /> -->
|
||||
<el-table-column type="index" label="#" width="50" />
|
||||
<el-table-column prop="barCode" label="条码" show-overflow-tooltip />
|
||||
<el-table-column prop="spec" label="规格" show-overflow-tooltip />
|
||||
<el-table-column prop="unit" label="单位" show-overflow-tooltip />
|
||||
<el-table-column prop="status" label="状态" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<el-tag v-if="scope.row.status == 0" type="success">正常</el-tag>
|
||||
<el-tag v-if="scope.row.status == 1" type="danger">停销</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="packageNum" label="内装数量" show-overflow-tooltip />
|
||||
<el-table-column prop="purchasePrice" label="进价/单位分" show-overflow-tooltip />
|
||||
<el-table-column prop="retailPrice" label="零售价/单位分" show-overflow-tooltip />
|
||||
<!-- <el-table-column prop="spuId" label="spuId" show-overflow-tooltip /> -->
|
||||
<el-table-column prop="promotionPrice" label="促销价" show-overflow-tooltip />
|
||||
<el-table-column prop="costPrice" label="成本价" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="150" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button icon="edit-pen" text type="primary" v-auth="'supermarket_supermarketUnit_edit'" @click="formDialogRef.openDialog(scope.row)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button icon="delete" text type="primary" v-auth="'supermarket_supermarketUnit_del'" @click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- <pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" /> -->
|
||||
|
||||
<!-- 编辑、新增 -->
|
||||
<form-dialog ref="formDialogRef" @refresh="getDataList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||
// import { fetchList, delObjs } from '/@/api/supermarket/supermarketUnit';
|
||||
// import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
|
||||
const supermarketUnitEntityList = defineModel<any>('supermarketUnitEntityList', { default: [] });
|
||||
|
||||
const formDialogRef = ref();
|
||||
// 搜索变量
|
||||
// const queryRef = ref();
|
||||
// const showSearch = ref(true);
|
||||
// 多选变量
|
||||
// const selectedUnitIds = ref<any>([]); // 已勾选的行的id集合
|
||||
// const multiple = ref(true);
|
||||
|
||||
// const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
// queryForm: {},
|
||||
// pageList: fetchList,
|
||||
// });
|
||||
|
||||
// table hook
|
||||
// const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state);
|
||||
|
||||
const tableStyle = {
|
||||
cellStyle: { textAlign: 'center' },
|
||||
headerCellStyle: {
|
||||
textAlign: 'center',
|
||||
background: 'var(--el-table-row-hover-bg-color)',
|
||||
color: 'var(--el-text-color-primary)',
|
||||
},
|
||||
};
|
||||
|
||||
const getDataList = (formData: any) => {
|
||||
console.log(formData);
|
||||
const index = supermarketUnitEntityList.value.findIndex((item: any) => item.id === formData.id);
|
||||
if (index === -1) {
|
||||
supermarketUnitEntityList.value.push(formData);
|
||||
} else {
|
||||
supermarketUnitEntityList.value[index] = formData;
|
||||
}
|
||||
console.log('a', supermarketUnitEntityList.value);
|
||||
};
|
||||
|
||||
// 清空搜索条件
|
||||
// const resetQuery = () => {
|
||||
// // 清空搜索条件
|
||||
// queryRef.value?.resetFields();
|
||||
// // 清空多选
|
||||
// // selectedUnitIds.value = [];
|
||||
// // selectedUnit.value = [];
|
||||
// getDataList();
|
||||
// };
|
||||
|
||||
// 导出excel
|
||||
// const exportExcel = () => {
|
||||
// downBlobFile('/supermarket/supermarketUnit/export', Object.assign(state.queryForm, { ids: selectedUnitIds.value }), 'supermarketUnit.xlsx');
|
||||
// };
|
||||
|
||||
// 多选事件
|
||||
// const selectionChangHandle = (objs: { id: string }[]) => {
|
||||
// selectedUnit.value = objs;
|
||||
// selectedUnitIds.value = objs.map(({ id }) => id);
|
||||
// multiple.value = !objs.length;
|
||||
// };
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = async (rowData: any) => {
|
||||
supermarketUnitEntityList.value = supermarketUnitEntityList.value.filter((item: any) => item.id !== rowData.id);
|
||||
// try {
|
||||
// await useMessageBox().confirm('此操作将永久删除');
|
||||
// } catch {
|
||||
// return;
|
||||
// }
|
||||
// try {
|
||||
// await delObjs(ids);
|
||||
// // getDataList();
|
||||
// useMessage().success('删除成功');
|
||||
// } catch (err: any) {
|
||||
// useMessage().error(err.msg);
|
||||
// }
|
||||
};
|
||||
</script>
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible" :close-on-click-modal="true" draggable>
|
||||
<el-dialog width="60%" :title="form.id ? '编辑' : '新增'" v-model="visible" :close-on-click-modal="false" draggable>
|
||||
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="auto" v-loading="loading">
|
||||
<el-tabs v-model="tabPaneActiveName">
|
||||
<el-tab-pane label="基础信息" name="基础信息" disabled style="overflow-y: scroll; height: 50vh">
|
||||
<el-tabs v-model="tabPaneActiveName" @tab-change="handleTabChange">
|
||||
<el-tab-pane label="基础信息" name="基础信息" style="overflow-y: auto; height: 60vh">
|
||||
<el-row style="padding: 10px">
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="货号" prop="productCode">
|
||||
@@ -27,7 +27,7 @@
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="商品分类" prop="categoryId">
|
||||
<el-select v-model="form.categoryId" placeholder="请选择商品分类">
|
||||
<el-option v-for="item in categoryOptions" :key="item.id" :label="item.name" :value="item.id" />
|
||||
<el-option v-for="item in categoryOptions" :key="item?.id" :label="item?.name" :value="item?.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -75,13 +75,13 @@
|
||||
<el-input-number v-model="form.giveIntegral" placeholder="请输入赠送积分"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<!-- <el-col :span="12" class="mb20">
|
||||
<el-form-item label="商户编号" prop="merchantId">
|
||||
<el-select v-model="form.merchantId" placeholder="请选择商户编号">
|
||||
<el-option label="请选择" value="">???</el-option>
|
||||
<el-option label="请选择" :value="1">1???</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-col> -->
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="规格" prop="specification">
|
||||
<el-input v-model="form.specification" placeholder="请输入规格" />
|
||||
@@ -110,7 +110,7 @@
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="货商" prop="supplierId">
|
||||
<el-select v-model="form.supplierId" placeholder="请选择货商">
|
||||
<el-option label="请选择" value="">???</el-option>
|
||||
<el-option v-for="item in supplierOptions" :key="item.supplierId" :label="item.supplierName" :value="item.supplierId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -183,24 +183,11 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="包装单位" name="包装单位" disabled style="overflow-y: scroll; height: 50vh"> aaaa </el-tab-pane>
|
||||
<el-tab-pane label="辅助条码" name="辅助条码" disabled style="overflow-y: scroll; height: 50vh">
|
||||
<el-table
|
||||
ref="auxiliaryCodeTableRef"
|
||||
:data="auxiliaryCodeState.dataList"
|
||||
v-loading="auxiliaryCodeState.loading"
|
||||
border
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle"
|
||||
:row-style="{ cursor: 'pointer' }"
|
||||
@selection-change="auxiliaryCodeSelectionChangHandle"
|
||||
@row-click="HandleAuxiliaryCodeRowClick"
|
||||
>
|
||||
<el-table-column type="selection" width="40" align="center" />
|
||||
<el-table-column type="index" label="#" width="40" />
|
||||
<el-table-column prop="barCode" label="条码" show-overflow-tooltip />
|
||||
<el-table-column prop="spuId" label="spuID" show-overflow-tooltip />
|
||||
</el-table>
|
||||
<el-tab-pane label="包装单位" name="包装单位" style="overflow-y: auto; height: 60vh">
|
||||
<supermarketUnit v-model:supermarketUnitEntityList="form.supermarketUnitEntityList" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="辅助条码" name="辅助条码" style="overflow-y: auto; height: 60vh">
|
||||
<supermarketAuxiliaryCode v-model:supermarketAuxiliaryCodeEntityList="form.supermarketAuxiliaryCodeEntityList" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-form>
|
||||
@@ -220,9 +207,14 @@
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
import { getObj, addObj, putObj, getSupermarketCategory, getSupermarketBrand } from '/@/api/supermarket/supermarketSpu';
|
||||
import { getObj as getSupermarketUnit } from '/@/api/supermarket/supermarketUnit';
|
||||
import { getObj as getSupermarketAuxiliaryCode } from '/@/api/supermarket/supermarketAuxiliaryCode';
|
||||
import { fetchList } from '/@/api/supermarketerp/smErpSupplier';
|
||||
import { rule } from '/@/utils/validate';
|
||||
import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||
import { fetchList } from '/@/api/supermarket/supermarketAuxiliaryCode';
|
||||
import supermarketAuxiliaryCode from './components/supermarketAuxiliaryCode/index.vue';
|
||||
import supermarketUnit from './components/supermarketUnit/index.vue';
|
||||
import { TabPaneName } from 'element-plus';
|
||||
|
||||
const emit = defineEmits(['refresh']);
|
||||
|
||||
const tabPaneEnum = ['基础信息', '包装单位', '辅助条码'];
|
||||
@@ -268,6 +260,8 @@ const form = reactive({
|
||||
inventoryUpperLimit: 0,
|
||||
inventoryLowerLimit: 0,
|
||||
grossMargin: 0,
|
||||
supermarketUnitEntityList: [],
|
||||
supermarketAuxiliaryCodeEntityList: [],
|
||||
});
|
||||
// 定义校验规则
|
||||
const dataRules = {
|
||||
@@ -285,24 +279,7 @@ const dataRules = {
|
||||
const { supermarket_nature, status } = useDict('supermarket_nature', 'status');
|
||||
const categoryOptions = ref<any>([]); // 商品分类的下拉选项
|
||||
const brandOptions = ref<any>([]); // 超市品牌的下拉选项
|
||||
|
||||
// 辅助条码state
|
||||
const auxiliaryCodeState: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {},
|
||||
pageList: fetchList,
|
||||
});
|
||||
const auxiliaryCodeTableRef = ref();
|
||||
// 辅助条码多选变量
|
||||
const auxiliaryCodeSelectObjs = ref([]) as any;
|
||||
const { getDataList: getAuxiliaryCodeList, tableStyle } = useTable(auxiliaryCodeState);
|
||||
// 辅助条码多选事件
|
||||
const auxiliaryCodeSelectionChangHandle = (objs: { id: string }[]) => {
|
||||
auxiliaryCodeSelectObjs.value = objs;
|
||||
};
|
||||
// 表格行点击事件
|
||||
const HandleAuxiliaryCodeRowClick = (row: any) => {
|
||||
auxiliaryCodeTableRef.value.toggleRowSelection(row);
|
||||
};
|
||||
const supplierOptions = ref<any>([]); // 货商的下拉选项
|
||||
|
||||
// 初始化表单数据
|
||||
const getsupermarketSpuData = (id: string) => {
|
||||
@@ -315,12 +292,29 @@ const getsupermarketSpuData = (id: string) => {
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
getSupermarketUnit(id)
|
||||
.then((res: any) => {
|
||||
form.supermarketUnitEntityList = res.data;
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
getSupermarketAuxiliaryCode(id)
|
||||
.then((res: any) => {
|
||||
form.supermarketAuxiliaryCodeEntityList = res.data;
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = async (id: string) => {
|
||||
visible.value = true;
|
||||
currentTabPaneIndex.value = 0;
|
||||
form.id = '';
|
||||
form.supermarketUnitEntityList = [];
|
||||
form.supermarketAuxiliaryCodeEntityList = [];
|
||||
|
||||
// 重置表单数据
|
||||
nextTick(() => {
|
||||
@@ -353,18 +347,42 @@ const openDialog = async (id: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取辅助条码列表
|
||||
getAuxiliaryCodeList();
|
||||
// 获取货商选项
|
||||
if (supplierOptions.value.length <= 0) {
|
||||
try {
|
||||
const res = await fetchList();
|
||||
supplierOptions.value = res.data.records;
|
||||
} catch (error) {
|
||||
supplierOptions.value = [];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// tab栏切换
|
||||
const handleTabChange = (name: TabPaneName) => {
|
||||
currentTabPaneIndex.value = tabPaneEnum.findIndex((item) => item === name);
|
||||
};
|
||||
|
||||
// 提交
|
||||
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);
|
||||
if (form.id) {
|
||||
await putObj(form);
|
||||
} else {
|
||||
form.supermarketUnitEntityList.map((item: any) => {
|
||||
item.id = '';
|
||||
});
|
||||
form.supermarketAuxiliaryCodeEntityList.map((item: any) => {
|
||||
item.id = '';
|
||||
});
|
||||
await addObj(form);
|
||||
}
|
||||
useMessage().success(form.id ? '修改成功' : '添加成功');
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
@@ -380,10 +398,3 @@ defineExpose({
|
||||
openDialog,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
:deep(.el-tabs__item.is-disabled) {
|
||||
color: #2e5cf6;
|
||||
cursor: default;
|
||||
}
|
||||
</style>
|
||||
@@ -53,36 +53,44 @@
|
||||
@sort-change="sortChangeHandle"
|
||||
>
|
||||
<el-table-column type="selection" width="40" align="center" fixed="left" />
|
||||
<el-table-column type="index" label="#" width="40" />
|
||||
<el-table-column type="index" label="#" width="50" />
|
||||
<el-table-column prop="productCode" label="货号" show-overflow-tooltip />
|
||||
<el-table-column prop="barcode" label="自编码/条码" show-overflow-tooltip width="100" />
|
||||
<el-table-column prop="productName" label="商品名称" show-overflow-tooltip width="100" />
|
||||
<el-table-column prop="unit" label="单位" show-overflow-tooltip />
|
||||
<el-table-column prop="categoryId" label="商品分类" show-overflow-tooltip width="100" />
|
||||
<el-table-column prop="picUrl" label="封面图" show-overflow-tooltip />
|
||||
<el-table-column prop="status" label="商品状态" show-overflow-tooltip width="100">
|
||||
<el-table-column prop="categoryId" label="商品分类" show-overflow-tooltip width="100">
|
||||
<template #default="scope">
|
||||
{{ supermarketCategory?.find((item: any) => item.id === scope.row.categoryId)?.name }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="picUrl" label="封面图" width="100">
|
||||
<template #default="scope">
|
||||
<preview-image style="width: 50px; height: 50px" :src="imageBaseUrl + scope.row.picUrl" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="商品状态" width="100">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="status" :value="scope.row.status"></dict-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="costPrice" label="成本单价" show-overflow-tooltip width="100" />
|
||||
<el-table-column prop="stock" label="库存" show-overflow-tooltip />
|
||||
<!-- <el-table-column prop="giveIntegral" label="赠送积分" show-overflow-tooltip/>-->
|
||||
<!-- <el-table-column prop="merchantId" label="商户编号" show-overflow-tooltip/>-->
|
||||
<!-- <el-table-column prop="giveIntegral" label="赠送积分" show-overflow-tooltip /> -->
|
||||
<!-- <el-table-column prop="merchantId" label="商户编号" show-overflow-tooltip /> -->
|
||||
<el-table-column prop="specification" label="规格" show-overflow-tooltip />
|
||||
<!-- <el-table-column prop="origin" label="产地" show-overflow-tooltip/>-->
|
||||
<!-- <el-table-column prop="origin" label="产地" show-overflow-tooltip /> -->
|
||||
<el-table-column prop="packingQuantity" label="装数" show-overflow-tooltip />
|
||||
<el-table-column prop="purchasePrice" label="进价)" show-overflow-tooltip />
|
||||
<el-table-column prop="retailPrice" label="零售价" show-overflow-tooltip />
|
||||
<el-table-column prop="promotionPrice" label="促销价" show-overflow-tooltip />
|
||||
<el-table-column prop="productNature" label="商品性质" show-overflow-tooltip width="100">
|
||||
<el-table-column prop="productNature" label="商品性质" show-overflow-tooltip width="150">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="supermarket_nature" :value="scope.row.productNature"></dict-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column prop="inventoryUpperLimit" label="库存上限" show-overflow-tooltip/>-->
|
||||
<!-- <el-table-column prop="inventoryLowerLimit" label="库存下限" show-overflow-tooltip/>-->
|
||||
<!-- <el-table-column prop="grossMargin" label="毛利率" show-overflow-tooltip/>-->
|
||||
<!-- <el-table-column prop="inventoryUpperLimit" label="库存上限" show-overflow-tooltip /> -->
|
||||
<!-- <el-table-column prop="inventoryLowerLimit" label="库存下限" show-overflow-tooltip /> -->
|
||||
<!-- <el-table-column prop="grossMargin" label="毛利率" show-overflow-tooltip /> -->
|
||||
<el-table-column prop="brandId" label="品牌" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="150" fixed="right">
|
||||
<template #default="scope">
|
||||
@@ -105,13 +113,13 @@
|
||||
|
||||
<script setup lang="ts" name="systemSupermarketSpu">
|
||||
import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||
import { fetchList, delObjs } from '/@/api/supermarket/supermarketSpu';
|
||||
import { fetchList, delObjs, getSupermarketCategory } from '/@/api/supermarket/supermarketSpu';
|
||||
import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
const imageBaseUrl = import.meta.env.VITE_IMAGE_BASE_PATH;
|
||||
|
||||
// 引入组件
|
||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
// 定义查询字典
|
||||
|
||||
const { supermarket_nature, status } = useDict('supermarket_nature', 'status');
|
||||
// 定义变量内容
|
||||
@@ -122,6 +130,8 @@ const showSearch = ref(true);
|
||||
// 多选变量
|
||||
const selectObjs = ref([]) as any;
|
||||
const multiple = ref(true);
|
||||
// 商品分类
|
||||
const supermarketCategory = ref<any>([]);
|
||||
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {},
|
||||
@@ -167,4 +177,13 @@ const handleDelete = async (ids: string[]) => {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const res = await getSupermarketCategory();
|
||||
supermarketCategory.value = res.data;
|
||||
} catch (error) {
|
||||
supermarketCategory.value = [];
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Reference in new issue
Block a user