|
|
@@ -12,7 +12,11 @@ import { useUserStore } from '@vben/stores';
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
|
|
|
|
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|
|
-import { deleteProductApi, getProductListApi } from '#/api/product';
|
|
|
+import {
|
|
|
+ deleteProductApi,
|
|
|
+ editProductApi,
|
|
|
+ getProductListApi,
|
|
|
+} from '#/api/product';
|
|
|
import { $t } from '#/locales';
|
|
|
|
|
|
import ProductForm from './form.vue';
|
|
|
@@ -195,13 +199,56 @@ async function handleDelete(row: any) {
|
|
|
console.error(error);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+/* 移除关联 */
|
|
|
+async function handleRemoveLink(row: any) {
|
|
|
+ try {
|
|
|
+ await ElMessageBox.confirm(
|
|
|
+ '确认要移除关联吗?移除后,小程序商城中,客户将无法购买该产品,请谨慎操作',
|
|
|
+ '提示',
|
|
|
+ {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ },
|
|
|
+ );
|
|
|
+
|
|
|
+ const productsmerchantidArr = row.productsmerchantid.split(',');
|
|
|
+
|
|
|
+ const productsmerchantid = productsmerchantidArr.filter(
|
|
|
+ (item: any) => item !== userStore.userInfo?.workeruserid,
|
|
|
+ );
|
|
|
+
|
|
|
+ const newProductsmerchantid = productsmerchantid.join(',');
|
|
|
+ await editProductApi({
|
|
|
+ 'productsid.value': row.productsid,
|
|
|
+ productsmerchantid: newProductsmerchantid || '',
|
|
|
+ } as any);
|
|
|
+
|
|
|
+ ElMessage.success('取消关联成功');
|
|
|
+ gridApi.reload();
|
|
|
+ } catch {}
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
<Page auto-content-height>
|
|
|
<Grid table-title="产品列表">
|
|
|
<template #toolbar-tools>
|
|
|
- <el-button type="primary" @click="handleCreate"> 新增 </el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ @click="handleCreate"
|
|
|
+ v-if="!isNonAdminMerchant"
|
|
|
+ >
|
|
|
+ 新增
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ @click="handleCreate"
|
|
|
+ v-if="isNonAdminMerchant"
|
|
|
+ >
|
|
|
+ 新增关联
|
|
|
+ </el-button>
|
|
|
</template>
|
|
|
<template #action="{ row }">
|
|
|
<el-tooltip
|
|
|
@@ -254,7 +301,7 @@ async function handleDelete(row: any) {
|
|
|
>
|
|
|
<el-button
|
|
|
round
|
|
|
- @click="() => handleDelete(row)"
|
|
|
+ @click="() => handleRemoveLink(row)"
|
|
|
:icon="MdiDelete"
|
|
|
class="!p-2"
|
|
|
/>
|