feat: 解决上架问题

This commit is contained in:
duan
2025-03-07 18:30:30 +08:00
parent 8e52613f08
commit 0bd38e29c5
5 changed files with 30 additions and 25 deletions

View File

@@ -743,6 +743,7 @@ function handleOperat(data: IOperatData) {
// 属性修改 // 属性修改
function handleModify(field: string, value: boolean | string | number, row: Record<string, any>) { function handleModify(field: string, value: boolean | string | number, row: Record<string, any>) {
console.log(1111111111111111111111111)
if (props.contentConfig.modifyAction) { if (props.contentConfig.modifyAction) {
props.contentConfig.modifyAction({ props.contentConfig.modifyAction({
[pk]: row[pk], [pk]: row[pk],

View File

@@ -26,6 +26,7 @@ const contentConfig: IContentConfig<UserPageQuery> = {
// }, // },
// exportAction: UserAPI.export, // exportAction: UserAPI.export,
modifyAction: function (params) { modifyAction: function (params) {
console.log(1111112222222222222)
let obj = { sort: "1", ...params } let obj = { sort: "1", ...params }
return UserAPI.update(obj); return UserAPI.update(obj);
}, },

View File

@@ -11,20 +11,20 @@
<page-content ref="contentRef" :content-config="contentConfig" @add-click="handleAddClick" <page-content ref="contentRef" :content-config="contentConfig" @add-click="handleAddClick"
@edit-click="handleEditClick" @export-click="handleExportClick" @search-click="handleSearchClick" @edit-click="handleEditClick" @export-click="handleExportClick" @search-click="handleSearchClick"
@toolbar-click="handleToolbarClick" @operat-click="handleOperatClick" @filter-change="handleFilterChange"> @toolbar-click="handleToolbarClick" @operat-click="handleOperatClick" @filter-change="handleFilterChange">
<template #status="scope"> <!-- <template #status="scope">
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'"> <el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }} {{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
</el-tag> </el-tag>
</template> </template> -->
<template #type="scope"> <template #type="scope">
{{ typeFilter(scope.row[scope.prop]) }} {{ typeFilter(scope.row[scope.prop]) }}
</template> </template>
<template #gender="scope"> <template #gender="scope">
<DictLabel v-model="scope.row[scope.prop]" code="gender" /> <DictLabel v-model="scope.row[scope.prop]" code="gender" />
</template> </template>
<template #switchs="scope"> <template #shangjia="scope">
<el-switch v-model="scope.row[scope.prop]" :active-value="1" :inactive-value="0" active-text="启用" <el-switch v-model="scope.row[scope.prop]" :active-value="1" :inactive-value="0"
inactive-text="禁用" @change="handleSwitchChange"></el-switch> @click="handleSwitchChange(scope.row)"></el-switch>
</template> </template>
<template #mobile="scope"> <template #mobile="scope">
<el-text>{{ scope.row[scope.prop] }}</el-text> <el-text>{{ scope.row[scope.prop] }}</el-text>
@@ -56,13 +56,13 @@
</MyDialog> </MyDialog>
</template> </template>
<template v-else> <template v-else>
<page-content ref="contentRef" :content-config="contentConfig2" @operat-click="handleOperatClick"> <!-- <page-content ref="contentRef" :content-config="contentConfig2" @operat-click="handleOperatClick">
<template #status="scope"> <template #status="scope">
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'"> <el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }} {{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
</el-tag> </el-tag>
</template> </template>
</page-content> </page-content> -->
</template> </template>
</div> </div>
</template> </template>
@@ -108,9 +108,14 @@ async function handleAddClick() {
// addModalConfig.formItems[4]!.options = await RoleAPI.getOptions(); // addModalConfig.formItems[4]!.options = await RoleAPI.getOptions();
} }
// 上架 // 上架
function handleSwitchChange(val: boolean, row: IObject) { function handleSwitchChange(data: any) {
console.log(val, row); console.log(data, '条似乎22222')
// UserAPI.updateById({ id: row.id, isSale: val ? 1 : 0 }); let obj = {
type: data.isGrounding ? 'sku' : 'product',
id: data.id,
isSale: data.status
}
UserAPI.onOff(obj);
} }
// 编辑 // 编辑
async function handleEditClick(row: IObject) { async function handleEditClick(row: IObject) {

View File

@@ -771,11 +771,9 @@ const submitForm = async (formEl: FormInstance | undefined) => {
"title": "新增商品", "title": "新增商品",
"path": "/product/addgoods", "path": "/product/addgoods",
"fullPath": "/product/addgoods", "fullPath": "/product/addgoods",
"affix": false,
"keepAlive": true,
"query": {} "query": {}
}) })
router.push({ name: 'productIndex' }); router.push('/product/index');
}, 500); }, 500);
} else { } else {
ElMessage.error("请填写完整信息"); ElMessage.error("请填写完整信息");

View File

@@ -37,19 +37,19 @@ const contentConfig: IContentConfig<UserPageQuery> = {
}) })
}) })
}, },
modifyAction: function (data) { // modifyAction: function (data) {
let obj = { // let obj = {
type: data.isGrounding ? 'sku' : 'product', // type: data.isGrounding ? 'sku' : 'product',
id: data.id, // id: data.id,
isSale: data.value // isSale: data.value
} // }
return UserAPI.onOff(obj); // return null
}, // },
deleteAction: UserAPI.deleteByIds, deleteAction: UserAPI.deleteByIds,
importsAction(data) { importsAction(data) {
// 模拟导入数据 // 模拟导入数据
console.log("importsAction", data); // console.log("importsAction", data);
return Promise.resolve(); // return Promise.resolve();
}, },
exportsAction: async function (params) { exportsAction: async function (params) {
// 模拟获取到的是全量数据 // 模拟获取到的是全量数据
@@ -83,8 +83,8 @@ const contentConfig: IContentConfig<UserPageQuery> = {
label: "上架", label: "上架",
align: "center", align: "center",
prop: "status", prop: "status",
templet: "switch", templet: "custom",
slotName: "status", slotName: "shangjia",
}, },
{ {
label: "操作", label: "操作",