feat: 商品规格模块
This commit is contained in:
parent
da0888d87d
commit
964616fc41
|
|
@ -1,5 +1,4 @@
|
|||
import request from "@/utils/request";
|
||||
import { number } from "echarts";
|
||||
const baseURL = "/product/admin/prod/unit";
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import request from "@/utils/request";
|
||||
import { number } from "echarts";
|
||||
const baseURL = "/product/admin/prod/category";
|
||||
|
||||
const AuthAPI = {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
import request from "@/utils/request";
|
||||
const baseURL = "/product/admin/prod/spec";
|
||||
const AuthAPI = {
|
||||
/** 列表*/
|
||||
getPage(params: any) {
|
||||
return request<any, Responseres>({
|
||||
url: `${baseURL}/list`,
|
||||
method: "get",
|
||||
params,
|
||||
});
|
||||
},
|
||||
// 新增
|
||||
addunit(data: any) {
|
||||
return request<any, Responseres>({
|
||||
url: `${baseURL}`,
|
||||
method: "post",
|
||||
data: { ...data, sort: '1' },
|
||||
});
|
||||
},
|
||||
// 获取详情
|
||||
getunitinfo(id: number) {
|
||||
return request<any, Responseres>({
|
||||
url: `${baseURL}/${id}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
// 编辑确定
|
||||
update(data: Object) {
|
||||
return request<any, Responseres>({
|
||||
url: `${baseURL}`,
|
||||
method: "put",
|
||||
data,
|
||||
});
|
||||
},
|
||||
// 删除
|
||||
deleteByIds(id: number | String) {
|
||||
return request<any, Responseres>({
|
||||
url: `${baseURL}/${id}`,
|
||||
method: "delete",
|
||||
});
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
export interface Responseres {
|
||||
code?: number | null;
|
||||
data?: any;
|
||||
msg?: null | string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export default AuthAPI;
|
||||
|
|
@ -374,7 +374,7 @@ export const constantRoutes: RouteRecordRaw[] = [
|
|||
children: [
|
||||
{
|
||||
path: "index",
|
||||
component: () => import("@/views/product/list.vue"),
|
||||
component: () => import("@/views/product/index.vue"),
|
||||
name: "productIndex",
|
||||
meta: {
|
||||
title: "商品列表",
|
||||
|
|
|
|||
|
|
@ -81,9 +81,9 @@ const {
|
|||
async function handleAddClick() {
|
||||
addModalRef.value?.setModalVisible();
|
||||
// 加载部门下拉数据源
|
||||
addModalConfig.formItems[2]!.attrs!.data = await DeptAPI.getOptions();
|
||||
// addModalConfig.formItems[2]!.attrs!.data = await DeptAPI.getOptions();
|
||||
// 加载角色下拉数据源
|
||||
addModalConfig.formItems[4]!.options = await RoleAPI.getOptions();
|
||||
// addModalConfig.formItems[4]!.options = await RoleAPI.getOptions();
|
||||
}
|
||||
// 编辑
|
||||
async function handleEditClick(row: IObject) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
<template>123</template>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
import UserAPI from "@/api/product/commonUnits";
|
||||
|
||||
import type { IModalConfig } from "@/components/CURD/types";
|
||||
|
||||
const modalConfig: IModalConfig<UserForm> = {
|
||||
pageName: "sys:user",
|
||||
dialog: {
|
||||
title: "新增单位",
|
||||
width: 800,
|
||||
draggable: true,
|
||||
},
|
||||
form: {
|
||||
labelWidth: 100,
|
||||
},
|
||||
formAction: UserAPI.addunit,
|
||||
beforeSubmit(data) {
|
||||
console.log("提交之前处理", data);
|
||||
},
|
||||
formItems: [
|
||||
{
|
||||
label: "单位名称",
|
||||
prop: "name",
|
||||
rules: [{ required: true, message: "单位名称不能为空", trigger: "blur" }],
|
||||
type: "input",
|
||||
attrs: {
|
||||
placeholder: "请输入单位名称",
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
],
|
||||
};
|
||||
export interface UserForm {
|
||||
|
||||
}
|
||||
// 如果有异步数据会修改配置的,推荐用reactive包裹,而纯静态配置的可以直接导出
|
||||
export default reactive(modalConfig);
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
import UserAPI from "@/api/product/commonUnits";
|
||||
import RoleAPI from "@/api/system/role";
|
||||
import type { UserPageQuery } from "@/api/system/user";
|
||||
import type { IContentConfig } from "@/components/CURD/types";
|
||||
|
||||
const contentConfig: IContentConfig<UserPageQuery> = {
|
||||
pageName: "sys:user",
|
||||
table: {
|
||||
border: true,
|
||||
highlightCurrentRow: true,
|
||||
},
|
||||
pagination: {
|
||||
background: true,
|
||||
layout: "prev,pager,next,jumper,total,sizes",
|
||||
pageSize: 20,
|
||||
pageSizes: [10, 20, 30, 50],
|
||||
},
|
||||
indexActionData: { name: "", orderBy: "name asc" },
|
||||
indexAction: function (params) {
|
||||
return UserAPI.getPage(params);
|
||||
},
|
||||
deleteAction: UserAPI.deleteByIds,
|
||||
// importAction(file) {
|
||||
// return UserAPI.import(1, file);
|
||||
// },
|
||||
// exportAction: UserAPI.export,
|
||||
// importTemplate: UserAPI.downloadTemplate,
|
||||
importsAction(data) {
|
||||
// 模拟导入数据
|
||||
console.log("importsAction", data);
|
||||
return Promise.resolve();
|
||||
},
|
||||
exportsAction: async function (params) {
|
||||
// 模拟获取到的是全量数据
|
||||
const res = await UserAPI.getPage(params);
|
||||
console.log("exportsAction", res.list);
|
||||
return res.list;
|
||||
},
|
||||
pk: "id",
|
||||
toolbar: [
|
||||
"add",
|
||||
],
|
||||
cols: [
|
||||
// { type: "selection", width: 50, align: "center" },
|
||||
{ label: "单位名称", align: "center", prop: "name" },
|
||||
{ label: "排序", align: "center", prop: "id" },
|
||||
{
|
||||
label: "操作",
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
width: 280,
|
||||
templet: "tool",
|
||||
operat: ["edit", "delete"],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default contentConfig;
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
import type { IContentConfig } from "@/components/CURD/types";
|
||||
|
||||
const contentConfig: IContentConfig = {
|
||||
pageName: "sys:user",
|
||||
table: {
|
||||
showOverflowTooltip: true,
|
||||
},
|
||||
toolbar: [],
|
||||
indexAction: function (params) {
|
||||
// 模拟发起网络请求获取列表数据
|
||||
console.log("indexAction:", params);
|
||||
return Promise.resolve({
|
||||
total: 2,
|
||||
list: [
|
||||
{
|
||||
id: 1,
|
||||
username: "tom",
|
||||
avatar: "https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
|
||||
percent: 99,
|
||||
price: 10,
|
||||
url: "https://www.baidu.com",
|
||||
icon: "el-icon-setting",
|
||||
gender: 1,
|
||||
status: 1,
|
||||
status2: 1,
|
||||
sort: 99,
|
||||
createTime: 1715647982437,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
username: "jerry",
|
||||
avatar: "https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
|
||||
percent: 88,
|
||||
price: 999,
|
||||
url: "https://www.google.com",
|
||||
icon: "el-icon-user",
|
||||
gender: 0,
|
||||
status: 0,
|
||||
status2: 0,
|
||||
sort: 0,
|
||||
createTime: 1715648977426,
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
modifyAction(data) {
|
||||
// 模拟发起网络请求修改字段
|
||||
// console.log("modifyAction:", data);
|
||||
ElMessage.success(JSON.stringify(data));
|
||||
return Promise.resolve(null);
|
||||
},
|
||||
cols: [
|
||||
{ type: "index", width: 50, align: "center" },
|
||||
{ label: "ID", align: "center", prop: "id", show: false },
|
||||
{ label: "文本", align: "center", prop: "username" },
|
||||
{ label: "图片", align: "center", prop: "avatar", templet: "image" },
|
||||
{
|
||||
label: "百分比",
|
||||
align: "center",
|
||||
prop: "percent",
|
||||
templet: "percent",
|
||||
},
|
||||
{
|
||||
label: "货币符",
|
||||
align: "center",
|
||||
prop: "price",
|
||||
templet: "price",
|
||||
priceFormat: "$",
|
||||
},
|
||||
{ label: "链接", align: "center", prop: "url", width: 180, templet: "url" },
|
||||
{ label: "图标", align: "center", prop: "icon", templet: "icon" },
|
||||
{
|
||||
label: "列表值",
|
||||
align: "center",
|
||||
prop: "gender",
|
||||
templet: "list",
|
||||
selectList: { "0": "女", "1": "男" },
|
||||
},
|
||||
{
|
||||
label: "自定义",
|
||||
align: "center",
|
||||
prop: "status",
|
||||
templet: "custom",
|
||||
slotName: "status",
|
||||
},
|
||||
{
|
||||
label: "Switch",
|
||||
align: "center",
|
||||
prop: "status2",
|
||||
templet: "switch",
|
||||
activeValue: 1,
|
||||
inactiveValue: 0,
|
||||
activeText: "启用",
|
||||
inactiveText: "禁用",
|
||||
},
|
||||
{
|
||||
label: "输入框",
|
||||
align: "center",
|
||||
prop: "sort",
|
||||
templet: "input",
|
||||
inputType: "number",
|
||||
},
|
||||
{
|
||||
label: "日期格式化",
|
||||
align: "center",
|
||||
prop: "createTime",
|
||||
minWidth: 120,
|
||||
templet: "date",
|
||||
dateFormat: "YYYY/MM/DD HH:mm:ss",
|
||||
},
|
||||
{
|
||||
label: "操作栏",
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
width: 220,
|
||||
templet: "tool",
|
||||
operat: [
|
||||
{
|
||||
name: "reset_pwd",
|
||||
auth: "password:reset",
|
||||
icon: "refresh-left",
|
||||
text: "重置密码",
|
||||
type: "primary",
|
||||
render(row) {
|
||||
return row.id === 1;
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default contentConfig;
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
import UserAPI from "@/api/product/commonUnits";
|
||||
|
||||
import type { IModalConfig } from "@/components/CURD/types";
|
||||
import { DeviceEnum } from "@/enums/DeviceEnum";
|
||||
import { useAppStore } from "@/store";
|
||||
|
||||
const modalConfig: IModalConfig<UserForm> = {
|
||||
pageName: "sys:user",
|
||||
// component: "drawer",
|
||||
dialog: {
|
||||
title: "编辑单位",
|
||||
width: 800,
|
||||
draggable: true,
|
||||
},
|
||||
|
||||
pk: "id",
|
||||
formAction: function (data) {
|
||||
return UserAPI.update(data);
|
||||
},
|
||||
beforeSubmit(data) {
|
||||
console.log("提交之前处理", data);
|
||||
},
|
||||
formItems: [
|
||||
{
|
||||
label: "单位名称",
|
||||
prop: "name",
|
||||
rules: [{ required: true, message: "单位名称不能为空", trigger: "blur" }],
|
||||
type: "input",
|
||||
attrs: {
|
||||
placeholder: "请输入单位名称",
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
],
|
||||
};
|
||||
/** 用户表单类型 */
|
||||
interface UserForm {
|
||||
/** 用户头像 */
|
||||
avatar?: string;
|
||||
/** 部门ID */
|
||||
deptId?: number;
|
||||
/** 邮箱 */
|
||||
email?: string;
|
||||
/** 性别 */
|
||||
gender?: number;
|
||||
/** 用户ID */
|
||||
id?: number;
|
||||
/** 手机号 */
|
||||
mobile?: string;
|
||||
/** 昵称 */
|
||||
nickname?: string;
|
||||
/** 角色ID集合 */
|
||||
roleIds?: number[];
|
||||
/** 用户状态(1:正常;0:禁用) */
|
||||
status?: number;
|
||||
/** 用户名 */
|
||||
username?: string;
|
||||
}
|
||||
|
||||
export default reactive(modalConfig);
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
import DeptAPI from "@/api/system/dept";
|
||||
import type { ISearchConfig } from "@/components/CURD/types";
|
||||
|
||||
const searchConfig: ISearchConfig = {
|
||||
pageName: "sys:user",
|
||||
formItems: [
|
||||
{
|
||||
type: "input",
|
||||
label: "单位名称",
|
||||
prop: "name",
|
||||
attrs: {
|
||||
placeholder: "请输入单位名称",
|
||||
clearable: true,
|
||||
style: {
|
||||
width: "200px",
|
||||
},
|
||||
},
|
||||
},
|
||||
// {
|
||||
// type: "tree-select",
|
||||
// label: "设备类型",
|
||||
// prop: "deptId",
|
||||
// attrs: {
|
||||
// placeholder: "请选择设备类型",
|
||||
// data: [],
|
||||
// filterable: true,
|
||||
// "check-strictly": true,
|
||||
// "render-after-expand": false,
|
||||
// clearable: true,
|
||||
// style: {
|
||||
// width: "150px",
|
||||
// },
|
||||
// },
|
||||
// async initFn(formItem) {
|
||||
// formItem.attrs.data = await DeptAPI.getOptions();
|
||||
// // 注意:如果initFn函数不是箭头函数,this会指向此配置项对象,那么也就可以用this来替代形参formItem
|
||||
// // this.attrs!.data = await DeptAPI.getOptions();
|
||||
// },
|
||||
// },
|
||||
|
||||
],
|
||||
};
|
||||
|
||||
export default searchConfig;
|
||||
|
|
@ -1 +0,0 @@
|
|||
<template></template>
|
||||
|
|
@ -1 +1,145 @@
|
|||
<template></template>
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 列表 -->
|
||||
<template v-if="isA">
|
||||
<!-- 搜索 -->
|
||||
<page-search ref="searchRef" :search-config="searchConfig" @query-click="handleQueryClick"
|
||||
@reset-click="handleResetClick" />
|
||||
|
||||
<!-- 列表 -->
|
||||
<page-content ref="contentRef" :content-config="contentConfig" @add-click="handleAddClick"
|
||||
@edit-click="handleEditClick" @export-click="handleExportClick" @search-click="handleSearchClick"
|
||||
@toolbar-click="handleToolbarClick" @operat-click="handleOperatClick" @filter-change="handleFilterChange">
|
||||
<template #status="scope">
|
||||
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
|
||||
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template #gender="scope">
|
||||
<DictLabel v-model="scope.row[scope.prop]" code="gender" />
|
||||
</template>
|
||||
<template #mobile="scope">
|
||||
<el-text>{{ scope.row[scope.prop] }}</el-text>
|
||||
<copy-button v-if="scope.row[scope.prop]" :text="scope.row[scope.prop]" style="margin-left: 2px" />
|
||||
</template>
|
||||
</page-content>
|
||||
|
||||
<!-- 新增 -->
|
||||
<page-modal ref="addModalRef" :modal-config="addModalConfig" @submit-click="handleSubmitClick">
|
||||
<template #gender="scope">
|
||||
<Dict v-model="scope.formData[scope.prop]" code="gender" />
|
||||
</template>
|
||||
</page-modal>
|
||||
|
||||
<!-- 编辑 -->
|
||||
<page-modal ref="editModalRef" :modal-config="editModalConfig" @submit-click="handleSubmitClick">
|
||||
<template #gender="scope">
|
||||
<Dict v-model="scope.formData[scope.prop]" code="gender" v-bind="scope.attrs" />
|
||||
</template>
|
||||
</page-modal>
|
||||
</template>
|
||||
<template v-else>
|
||||
<page-content ref="contentRef" :content-config="contentConfig2" @operat-click="handleOperatClick">
|
||||
<template #status="scope">
|
||||
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
|
||||
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</page-content>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import UserAPI from "@/api/product/specificationsconfig";
|
||||
import RoleAPI from "@/api/system/role";
|
||||
import type { IObject, IOperatData } from "@/components/CURD/types";
|
||||
import usePage from "@/components/CURD/usePage";
|
||||
import addModalConfig from "./specificationsconfig/add";
|
||||
import contentConfig from "./specificationsconfig/content";
|
||||
import contentConfig2 from "./specificationsconfig/content2";
|
||||
import editModalConfig from "./specificationsconfig/edit";
|
||||
import searchConfig from "./specificationsconfig/search";
|
||||
|
||||
const {
|
||||
searchRef,
|
||||
contentRef,
|
||||
addModalRef,
|
||||
editModalRef,
|
||||
handleQueryClick,
|
||||
handleResetClick,
|
||||
// handleAddClick,
|
||||
// handleEditClick,
|
||||
handleSubmitClick,
|
||||
handleExportClick,
|
||||
handleSearchClick,
|
||||
handleFilterChange,
|
||||
} = usePage();
|
||||
|
||||
// 新增
|
||||
async function handleAddClick() {
|
||||
addModalRef.value?.setModalVisible();
|
||||
// 加载上级规格下拉数据源
|
||||
addModalConfig.formItems[2]!.attrs!.data = await UserAPI.getPage({ name: "" });
|
||||
// 加载角色下拉数据源
|
||||
// addModalConfig.formItems[4]!.options = await RoleAPI.getOptions();
|
||||
}
|
||||
// 编辑
|
||||
async function handleEditClick(row: IObject) {
|
||||
editModalRef.value?.handleDisabled(false);
|
||||
// 加载部门下拉数据源
|
||||
editModalConfig.formItems[2]!.attrs!.data = await UserAPI.getPage({ name: "" });
|
||||
// editModalConfig.formItems[2]!.attrs!.data = await DeptAPI.getOptions();
|
||||
// 加载角色下拉数据源
|
||||
// editModalConfig.formItems[4]!.options = await RoleAPI.getOptions();
|
||||
// 根据id获取数据进行填充
|
||||
const data = await UserAPI.getunitinfo(row.id);
|
||||
editModalRef.value?.setFormData(data);
|
||||
editModalRef.value?.setModalVisible();
|
||||
|
||||
}
|
||||
// 其他工具栏
|
||||
function handleToolbarClick(name: string) {
|
||||
console.log(name);
|
||||
if (name === "custom1") {
|
||||
ElMessage.success("点击了自定义1按钮");
|
||||
}
|
||||
}
|
||||
// 其他操作列
|
||||
async function handleOperatClick(data: IOperatData) {
|
||||
console.log(data);
|
||||
// 重置密码
|
||||
if (data.name === "reset_pwd") {
|
||||
ElMessageBox.prompt("请输入用户「" + data.row.username + "」的新密码", "重置密码", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
}).then(({ value }) => {
|
||||
if (!value || value.length < 6) {
|
||||
ElMessage.warning("密码至少需要6位字符,请重新输入");
|
||||
return false;
|
||||
}
|
||||
// UserAPI.resetPassword(data.row.id, value).then(() => {
|
||||
// ElMessage.success("密码重置成功,新密码是:" + value);
|
||||
// });
|
||||
});
|
||||
} else if (data.name === "detail") {
|
||||
// 禁用表单编辑
|
||||
editModalRef.value?.handleDisabled(true);
|
||||
// 打开抽屉
|
||||
editModalRef.value?.setModalVisible();
|
||||
// 修改抽屉标题
|
||||
editModalConfig.drawer = { ...editModalConfig.drawer, title: "用户详情" };
|
||||
// 加载部门下拉数据源
|
||||
// editModalConfig.formItems[2]!.attrs!.data = await DeptAPI.getOptions();
|
||||
// 加载角色下拉数据源
|
||||
// editModalConfig.formItems[4]!.options = await RoleAPI.getOptions();
|
||||
// 根据id获取数据进行填充
|
||||
// const formData = await UserAPI.getFormData(data.row.id);
|
||||
// 设置表单数据
|
||||
// editModalRef.value?.setFormData(formData);
|
||||
}
|
||||
}
|
||||
|
||||
// 切换示例
|
||||
const isA = ref(true);
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
import UserAPI from "@/api/product/specificationsconfig";
|
||||
|
||||
import type { IModalConfig } from "@/components/CURD/types";
|
||||
|
||||
const modalConfig: IModalConfig<UserForm> = {
|
||||
pageName: "sys:user",
|
||||
dialog: {
|
||||
title: "新增模板",
|
||||
width: 800,
|
||||
draggable: true,
|
||||
},
|
||||
form: {
|
||||
labelWidth: 100,
|
||||
},
|
||||
formAction: UserAPI.addunit,
|
||||
beforeSubmit(data) {
|
||||
|
||||
if (data.pid == '') {
|
||||
data.pid = 0
|
||||
}
|
||||
console.log("提交之前处理", data);
|
||||
},
|
||||
formItems: [
|
||||
{
|
||||
label: "规格名称",
|
||||
prop: "name",
|
||||
rules: [{ required: true, message: "规格名称不能为空", trigger: "blur" }],
|
||||
type: "input",
|
||||
attrs: {
|
||||
placeholder: "请输入规格名称",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "规格级别",
|
||||
prop: "level",
|
||||
rules: [{ required: true, message: "用户角色不能为空", trigger: "blur" }],
|
||||
type: "select",
|
||||
attrs: {
|
||||
placeholder: "请选择",
|
||||
},
|
||||
options: [{ label: "一级", value: 1 }, { label: "二级", value: 2 }, { label: "三级", value: 3 }],
|
||||
initialValue: [],
|
||||
}, {
|
||||
label: "上级规格",
|
||||
prop: "pid",
|
||||
type: "tree-select",
|
||||
attrs: {
|
||||
placeholder: "请选择上级规格",
|
||||
data: [],
|
||||
filterable: true,
|
||||
"check-strictly": true,
|
||||
"render-after-expand": false,
|
||||
props: {
|
||||
label: 'name', // 指定节点显示的文本字段为 name
|
||||
value: 'id' // 指定节点的值字段为 id
|
||||
}
|
||||
},
|
||||
}
|
||||
],
|
||||
};
|
||||
export interface UserForm { }
|
||||
// 如果有异步数据会修改配置的,推荐用reactive包裹,而纯静态配置的可以直接导出
|
||||
export default reactive(modalConfig);
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
import UserAPI from "@/api/product/specificationsconfig";
|
||||
|
||||
import RoleAPI from "@/api/system/role";
|
||||
import type { UserPageQuery } from "@/api/system/user";
|
||||
import type { IContentConfig } from "@/components/CURD/types";
|
||||
|
||||
const contentConfig: IContentConfig<UserPageQuery> = {
|
||||
pageName: "sys:user",
|
||||
table: {
|
||||
border: true,
|
||||
highlightCurrentRow: true,
|
||||
},
|
||||
pagination: {
|
||||
background: true,
|
||||
layout: "prev,pager,next,jumper,total,sizes",
|
||||
pageSize: 20,
|
||||
pageSizes: [10, 20, 30, 50],
|
||||
},
|
||||
indexActionData: { name: "", orderBy: "name asc" },
|
||||
indexAction: function (params) {
|
||||
return UserAPI.getPage(params);
|
||||
},
|
||||
deleteAction: UserAPI.deleteByIds,
|
||||
// importAction(file) {
|
||||
// return UserAPI.import(1, file);
|
||||
// },
|
||||
// exportAction: UserAPI.export,
|
||||
modifyAction: UserAPI.update,
|
||||
|
||||
// importTemplate: UserAPI.downloadTemplate,
|
||||
// importsAction(data) {
|
||||
// // 模拟导入数据
|
||||
// console.log("importsAction", data);
|
||||
// return Promise.resolve();
|
||||
// },
|
||||
// exportsAction: async function (params) {
|
||||
// // 模拟获取到的是全量数据
|
||||
// const res = await UserAPI.getPage(params);
|
||||
// console.log("exportsAction", res.list);
|
||||
// return res.list;
|
||||
// },
|
||||
pk: "id",
|
||||
toolbar: [
|
||||
"add",
|
||||
],
|
||||
cols: [
|
||||
// { type: "selection", width: 50, align: "center" },
|
||||
{ label: "模板名称", align: "center", prop: "name" },
|
||||
{ label: "完整名称", align: "center", prop: "fullName" },
|
||||
{
|
||||
label: "操作",
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
width: 280,
|
||||
templet: "tool",
|
||||
operat: ["edit", "delete"],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default contentConfig;
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
import type { IContentConfig } from "@/components/CURD/types";
|
||||
|
||||
const contentConfig: IContentConfig = {
|
||||
pageName: "sys:user",
|
||||
table: {
|
||||
showOverflowTooltip: true,
|
||||
},
|
||||
toolbar: [],
|
||||
indexAction: function (params) {
|
||||
// 模拟发起网络请求获取列表数据
|
||||
console.log("indexAction:", params);
|
||||
return Promise.resolve({
|
||||
total: 2,
|
||||
list: [
|
||||
{
|
||||
id: 1,
|
||||
username: "tom",
|
||||
avatar: "https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
|
||||
percent: 99,
|
||||
price: 10,
|
||||
url: "https://www.baidu.com",
|
||||
icon: "el-icon-setting",
|
||||
gender: 1,
|
||||
status: 1,
|
||||
status2: 1,
|
||||
sort: 99,
|
||||
createTime: 1715647982437,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
username: "jerry",
|
||||
avatar: "https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
|
||||
percent: 88,
|
||||
price: 999,
|
||||
url: "https://www.google.com",
|
||||
icon: "el-icon-user",
|
||||
gender: 0,
|
||||
status: 0,
|
||||
status2: 0,
|
||||
sort: 0,
|
||||
createTime: 1715648977426,
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
modifyAction(data) {
|
||||
// 模拟发起网络请求修改字段
|
||||
// console.log("modifyAction:", data);
|
||||
ElMessage.success(JSON.stringify(data));
|
||||
return Promise.resolve(null);
|
||||
},
|
||||
cols: [
|
||||
{ type: "index", width: 50, align: "center" },
|
||||
{ label: "ID", align: "center", prop: "id", show: false },
|
||||
{ label: "文本", align: "center", prop: "username" },
|
||||
{ label: "图片", align: "center", prop: "avatar", templet: "image" },
|
||||
{
|
||||
label: "百分比",
|
||||
align: "center",
|
||||
prop: "percent",
|
||||
templet: "percent",
|
||||
},
|
||||
{
|
||||
label: "货币符",
|
||||
align: "center",
|
||||
prop: "price",
|
||||
templet: "price",
|
||||
priceFormat: "$",
|
||||
},
|
||||
{ label: "链接", align: "center", prop: "url", width: 180, templet: "url" },
|
||||
{ label: "图标", align: "center", prop: "icon", templet: "icon" },
|
||||
{
|
||||
label: "列表值",
|
||||
align: "center",
|
||||
prop: "gender",
|
||||
templet: "list",
|
||||
selectList: { "0": "女", "1": "男" },
|
||||
},
|
||||
{
|
||||
label: "自定义",
|
||||
align: "center",
|
||||
prop: "status",
|
||||
templet: "custom",
|
||||
slotName: "status",
|
||||
},
|
||||
{
|
||||
label: "Switch",
|
||||
align: "center",
|
||||
prop: "status2",
|
||||
templet: "switch",
|
||||
activeValue: 1,
|
||||
inactiveValue: 0,
|
||||
activeText: "启用",
|
||||
inactiveText: "禁用",
|
||||
},
|
||||
{
|
||||
label: "输入框",
|
||||
align: "center",
|
||||
prop: "sort",
|
||||
templet: "input",
|
||||
inputType: "number",
|
||||
},
|
||||
{
|
||||
label: "日期格式化",
|
||||
align: "center",
|
||||
prop: "createTime",
|
||||
minWidth: 120,
|
||||
templet: "date",
|
||||
dateFormat: "YYYY/MM/DD HH:mm:ss",
|
||||
},
|
||||
{
|
||||
label: "操作栏",
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
width: 220,
|
||||
templet: "tool",
|
||||
operat: [
|
||||
{
|
||||
name: "reset_pwd",
|
||||
auth: "password:reset",
|
||||
icon: "refresh-left",
|
||||
text: "重置密码",
|
||||
type: "primary",
|
||||
render(row) {
|
||||
return row.id === 1;
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default contentConfig;
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
import UserAPI from "@/api/product/specificationsconfig";
|
||||
|
||||
import type { IModalConfig } from "@/components/CURD/types";
|
||||
import { DeviceEnum } from "@/enums/DeviceEnum";
|
||||
import { useAppStore } from "@/store";
|
||||
|
||||
const modalConfig: IModalConfig<UserForm> = {
|
||||
pageName: "sys:user",
|
||||
// component: "drawer",
|
||||
dialog: {
|
||||
title: "编辑单位",
|
||||
width: 800,
|
||||
draggable: true,
|
||||
},
|
||||
|
||||
pk: "id",
|
||||
formAction: function (data) {
|
||||
return UserAPI.update({ ...data, sort: '1' });
|
||||
},
|
||||
beforeSubmit(data) {
|
||||
console.log("提交之前处理", data);
|
||||
},
|
||||
formItems: [
|
||||
{
|
||||
label: "规格名称",
|
||||
prop: "name",
|
||||
rules: [{ required: true, message: "规格名称不能为空", trigger: "blur" }],
|
||||
type: "input",
|
||||
attrs: {
|
||||
placeholder: "请输入规格名称",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "规格级别",
|
||||
prop: "level",
|
||||
rules: [{ required: true, message: "用户角色不能为空", trigger: "blur" }],
|
||||
type: "select",
|
||||
attrs: {
|
||||
placeholder: "请选择",
|
||||
},
|
||||
options: [{ label: "一级", value: 1 }, { label: "二级", value: 2 }, { label: "三级", value: 3 }],
|
||||
initialValue: [],
|
||||
}, {
|
||||
label: "上级规格",
|
||||
prop: "pid",
|
||||
type: "tree-select",
|
||||
attrs: {
|
||||
placeholder: "请选择上级规格",
|
||||
data: [],
|
||||
filterable: true,
|
||||
"check-strictly": true,
|
||||
"render-after-expand": false,
|
||||
props: {
|
||||
label: 'name', // 指定节点显示的文本字段为 name
|
||||
value: 'id' // 指定节点的值字段为 id
|
||||
}
|
||||
},
|
||||
}
|
||||
],
|
||||
};
|
||||
/** 用户表单类型 */
|
||||
interface UserForm {
|
||||
/** 用户头像 */
|
||||
avatar?: string;
|
||||
/** 部门ID */
|
||||
deptId?: number;
|
||||
/** 邮箱 */
|
||||
email?: string;
|
||||
/** 性别 */
|
||||
gender?: number;
|
||||
/** 用户ID */
|
||||
id?: number;
|
||||
/** 手机号 */
|
||||
mobile?: string;
|
||||
/** 昵称 */
|
||||
nickname?: string;
|
||||
/** 角色ID集合 */
|
||||
roleIds?: number[];
|
||||
/** 用户状态(1:正常;0:禁用) */
|
||||
status?: number;
|
||||
/** 用户名 */
|
||||
username?: string;
|
||||
}
|
||||
|
||||
export default reactive(modalConfig);
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
import DeptAPI from "@/api/system/dept";
|
||||
import type { ISearchConfig } from "@/components/CURD/types";
|
||||
|
||||
const searchConfig: ISearchConfig = {
|
||||
pageName: "sys:user",
|
||||
formItems: [
|
||||
{
|
||||
type: "input",
|
||||
label: "模板名称",
|
||||
prop: "name",
|
||||
attrs: {
|
||||
placeholder: "请输入模板名称",
|
||||
clearable: true,
|
||||
style: {
|
||||
width: "200px",
|
||||
},
|
||||
},
|
||||
},
|
||||
// {
|
||||
// type: "tree-select",
|
||||
// label: "设备类型",
|
||||
// prop: "deptId",
|
||||
// attrs: {
|
||||
// placeholder: "请选择设备类型",
|
||||
// data: [],
|
||||
// filterable: true,
|
||||
// "check-strictly": true,
|
||||
// "render-after-expand": false,
|
||||
// clearable: true,
|
||||
// style: {
|
||||
// width: "150px",
|
||||
// },
|
||||
// },
|
||||
// async initFn(formItem) {
|
||||
// formItem.attrs.data = await DeptAPI.getOptions();
|
||||
// // 注意:如果initFn函数不是箭头函数,this会指向此配置项对象,那么也就可以用this来替代形参formItem
|
||||
// // this.attrs!.data = await DeptAPI.getOptions();
|
||||
// },
|
||||
// },
|
||||
|
||||
],
|
||||
};
|
||||
|
||||
export default searchConfig;
|
||||
Loading…
Reference in New Issue