up.
This commit is contained in:
parent
fb9a49f85c
commit
84b8064f81
27
app/controller/admin/xm/ProductController.php
Normal file
27
app/controller/admin/xm/ProductController.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\controller\admin\xm;
|
||||||
|
|
||||||
|
use app\BaseController;
|
||||||
|
use app\service\CurdService;
|
||||||
|
use think\response\Json;
|
||||||
|
|
||||||
|
class ProductController extends BaseController
|
||||||
|
{
|
||||||
|
public function page(): Json
|
||||||
|
{
|
||||||
|
try{
|
||||||
|
$model = \app\entity\XmProduct::withSearch([], [
|
||||||
|
'productName' => $this->request->get('productName/s', ''),
|
||||||
|
'productCode' => $this->request->get('productCode/s', ''),
|
||||||
|
])->append(['company']);
|
||||||
|
|
||||||
|
$paginate = CurdService::getPaginate($this->request, $model);
|
||||||
|
}catch (\Exception $e){
|
||||||
|
return $this->writeError($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return $this->writeSuccess('success', $paginate);
|
||||||
|
}
|
||||||
|
}
|
||||||
14
app/entity/XmProduct.php
Normal file
14
app/entity/XmProduct.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\entity;
|
||||||
|
|
||||||
|
use think\Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小满数据中心-产品实体
|
||||||
|
* @see \app\model\XmProduct
|
||||||
|
*/
|
||||||
|
class XmProduct extends Entity
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
14
app/entity/XmProductGroup.php
Normal file
14
app/entity/XmProductGroup.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\entity;
|
||||||
|
|
||||||
|
use think\Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小满数据中心-产品分组实体
|
||||||
|
* @see \app\model\XmProductGroup
|
||||||
|
*/
|
||||||
|
class XmProductGroup extends Entity
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
14
app/model/XmProduct.php
Normal file
14
app/model/XmProduct.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\model;
|
||||||
|
|
||||||
|
use app\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
class XmProduct extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
|
||||||
|
protected $name = "xm_product";
|
||||||
|
protected $pk = "product_id";
|
||||||
|
}
|
||||||
14
app/model/XmProductGroup.php
Normal file
14
app/model/XmProductGroup.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\model;
|
||||||
|
|
||||||
|
use app\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
class XmProductGroup extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
|
||||||
|
protected $name = "xm_product_group";
|
||||||
|
protected $pk = "group_id";
|
||||||
|
}
|
||||||
@ -24,7 +24,8 @@ use app\controller\admin\{auth,
|
|||||||
system\RequestRecordController,
|
system\RequestRecordController,
|
||||||
system\RoleController,
|
system\RoleController,
|
||||||
system\UserController,
|
system\UserController,
|
||||||
xm\PlatformController};
|
xm\PlatformController,
|
||||||
|
xm\ProductController};
|
||||||
use app\http\middleware\AuthMiddleware;
|
use app\http\middleware\AuthMiddleware;
|
||||||
use think\facade\Route;
|
use think\facade\Route;
|
||||||
use think\middleware\AllowCrossDomain;
|
use think\middleware\AllowCrossDomain;
|
||||||
@ -186,6 +187,11 @@ Route::group("adminapi", function () {
|
|||||||
Route::get('page', [PlatformController::class, 'page'])->name("xm.pagePlatforms");
|
Route::get('page', [PlatformController::class, 'page'])->name("xm.pagePlatforms");
|
||||||
})->name('平台接口');
|
})->name('平台接口');
|
||||||
|
|
||||||
|
|
||||||
|
Route::group('product', function (){
|
||||||
|
Route::get('page', [ProductController::class, 'page'])->name("xm.pageProducts");
|
||||||
|
})->name('产品接口');
|
||||||
|
|
||||||
})->name('小满数据中心');
|
})->name('小满数据中心');
|
||||||
|
|
||||||
})->middleware([AuthMiddleware::class]);
|
})->middleware([AuthMiddleware::class]);
|
||||||
|
|||||||
101
z_ele/src/api/xm/product/index.ts
Normal file
101
z_ele/src/api/xm/product/index.ts
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
import request from '@/utils/request';
|
||||||
|
import type { ApiResult, PageResult } from '@/api';
|
||||||
|
import type { Product, ProductParam } from './model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询会员
|
||||||
|
*/
|
||||||
|
export async function pageProducts(params: ProductParam) {
|
||||||
|
const res = await request.get<ApiResult<PageResult<Product>>>(
|
||||||
|
'/xm/products/page',
|
||||||
|
{ params }
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户列表
|
||||||
|
*/
|
||||||
|
export async function listUsers(params?: ProductParam) {
|
||||||
|
const res = await request.get<ApiResult<Product[]>>('/system/user', {
|
||||||
|
params
|
||||||
|
});
|
||||||
|
if (res.data.code === 0 && res.data.data) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询用户
|
||||||
|
*/
|
||||||
|
export async function getUser(id: number) {
|
||||||
|
const res = await request.get<ApiResult<Product>>('/system/user/' + id);
|
||||||
|
if (res.data.code === 0 && res.data.data) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加用户
|
||||||
|
*/
|
||||||
|
export async function addUser(data: Product) {
|
||||||
|
const res = await request.post<ApiResult<unknown>>('/system/user', data);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户
|
||||||
|
*/
|
||||||
|
export async function updateUser(data: Product) {
|
||||||
|
const res = await request.put<ApiResult<unknown>>('/system/user', data);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户
|
||||||
|
*/
|
||||||
|
export async function removeUser(id?: number) {
|
||||||
|
const res = await request.delete<ApiResult<unknown>>('/system/user/' + id);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除用户
|
||||||
|
*/
|
||||||
|
export async function removeUsers(data: (number | undefined)[]) {
|
||||||
|
const res = await request.delete<ApiResult<unknown>>('/system/user/batch', {
|
||||||
|
data
|
||||||
|
});
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户状态
|
||||||
|
*/
|
||||||
|
export async function updateUserStatus(userId?: number, status?: number) {
|
||||||
|
const res = await request.put<ApiResult<unknown>>('/system/user/status', {
|
||||||
|
userId,
|
||||||
|
status
|
||||||
|
});
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
13
z_ele/src/api/xm/product/model/index.ts
Normal file
13
z_ele/src/api/xm/product/model/index.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import type { PageParam } from '@/api';
|
||||||
|
/**
|
||||||
|
* 会员
|
||||||
|
*/
|
||||||
|
export interface Product {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员搜索条件
|
||||||
|
*/
|
||||||
|
export interface ProductParam extends PageParam {
|
||||||
|
name?: string;
|
||||||
|
keyword?: string;
|
||||||
|
}
|
||||||
147
z_ele/src/views/xm/product/components/member-edit.vue
Normal file
147
z_ele/src/views/xm/product/components/member-edit.vue
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
<!-- 角色编辑弹窗 -->
|
||||||
|
<template>
|
||||||
|
<ele-modal
|
||||||
|
form
|
||||||
|
destroy-on-close
|
||||||
|
:width="460"
|
||||||
|
v-model="visible"
|
||||||
|
:title="isUpdate ? '修改角色' : '添加角色'"
|
||||||
|
>
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="form"
|
||||||
|
:rules="rules"
|
||||||
|
label-width="80px"
|
||||||
|
@submit.prevent=""
|
||||||
|
>
|
||||||
|
<el-form-item label="角色名称" prop="roleName">
|
||||||
|
<el-input
|
||||||
|
clearable
|
||||||
|
:maxlength="20"
|
||||||
|
v-model="form.roleName"
|
||||||
|
placeholder="请输入角色名称"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="角色标识" prop="roleCode">
|
||||||
|
<el-input
|
||||||
|
clearable
|
||||||
|
:maxlength="20"
|
||||||
|
v-model="form.roleCode"
|
||||||
|
placeholder="请输入角色标识"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注">
|
||||||
|
<el-input
|
||||||
|
:rows="4"
|
||||||
|
type="textarea"
|
||||||
|
v-model="form.comments"
|
||||||
|
placeholder="请输入备注"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="handleCancel">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="loading" @click="save">
|
||||||
|
保存
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</ele-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref, reactive, watch } from 'vue';
|
||||||
|
import type { FormInstance, FormRules } from 'element-plus';
|
||||||
|
import { EleMessage } from 'ele-admin-plus';
|
||||||
|
import { useFormData } from '@/utils/use-form-data';
|
||||||
|
import { addRole, updateRole } from '@/api/system/role';
|
||||||
|
import type { Role } from '@/api/system/role/model';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
/** 修改回显的数据 */
|
||||||
|
data?: Role | null;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'done'): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
/** 弹窗是否打开 */
|
||||||
|
const visible = defineModel({ type: Boolean });
|
||||||
|
|
||||||
|
/** 是否是修改 */
|
||||||
|
const isUpdate = ref(false);
|
||||||
|
|
||||||
|
/** 提交状态 */
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
/** 表单实例 */
|
||||||
|
const formRef = ref<FormInstance | null>(null);
|
||||||
|
|
||||||
|
/** 表单数据 */
|
||||||
|
const [form, resetFields, assignFields] = useFormData<Role>({
|
||||||
|
roleId: void 0,
|
||||||
|
roleName: '',
|
||||||
|
roleCode: '',
|
||||||
|
comments: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 表单验证规则 */
|
||||||
|
const rules = reactive<FormRules>({
|
||||||
|
roleName: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入角色名称',
|
||||||
|
type: 'string',
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
roleCode: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入角色标识',
|
||||||
|
type: 'string',
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 关闭弹窗 */
|
||||||
|
const handleCancel = () => {
|
||||||
|
visible.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 保存编辑 */
|
||||||
|
const save = () => {
|
||||||
|
formRef.value?.validate?.((valid) => {
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loading.value = true;
|
||||||
|
const saveOrUpdate = isUpdate.value ? updateRole : addRole;
|
||||||
|
saveOrUpdate(form)
|
||||||
|
.then((msg) => {
|
||||||
|
loading.value = false;
|
||||||
|
EleMessage.success({ message: msg, plain: true });
|
||||||
|
handleCancel();
|
||||||
|
emit('done');
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
loading.value = false;
|
||||||
|
EleMessage.error({ message: e.message, plain: true });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 监听弹窗打开 */
|
||||||
|
watch(visible, () => {
|
||||||
|
if (visible.value) {
|
||||||
|
if (props.data) {
|
||||||
|
assignFields(props.data);
|
||||||
|
isUpdate.value = true;
|
||||||
|
} else {
|
||||||
|
resetFields();
|
||||||
|
isUpdate.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
63
z_ele/src/views/xm/product/components/member-search.vue
Normal file
63
z_ele/src/views/xm/product/components/member-search.vue
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<!-- 搜索表单 -->
|
||||||
|
<template>
|
||||||
|
<ele-card :body-style="{ paddingBottom: '2px' }">
|
||||||
|
<el-form
|
||||||
|
label-width="82px"
|
||||||
|
@keyup.enter.prevent="search"
|
||||||
|
@submit.prevent=""
|
||||||
|
>
|
||||||
|
<el-row :gutter="8">
|
||||||
|
<el-col :lg="4" :md="8" :sm="12" :xs="24">
|
||||||
|
<el-form-item label="关键字查询">
|
||||||
|
<el-input
|
||||||
|
clearable
|
||||||
|
v-model.trim="form.keyword"
|
||||||
|
placeholder="请输入关键字(渠道名称/标识/备注)检索"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="4" :md="8" :sm="12" :xs="24">
|
||||||
|
<el-form-item label="渠道名称">
|
||||||
|
<el-input
|
||||||
|
clearable
|
||||||
|
v-model.trim="form.name"
|
||||||
|
placeholder="请输入渠道(渠道ID/渠道代码/渠道标识)"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="12" :md="8" :sm="24" :xs="24">
|
||||||
|
<el-form-item label-width="16px">
|
||||||
|
<el-button type="primary" @click="search">查询</el-button>
|
||||||
|
<el-button @click="reset">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
</ele-card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { useFormData } from '@/utils/use-form-data';
|
||||||
|
import type { ChannelParam } from '@/api/xm/channel/model';
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'search', where?: ChannelParam): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
/** 表单数据 */
|
||||||
|
const [form, resetFields] = useFormData<ChannelParam>({
|
||||||
|
name: '',
|
||||||
|
keyword: ''
|
||||||
|
});
|
||||||
|
/** 搜索 */
|
||||||
|
const search = () => {
|
||||||
|
let where: any = { ...form };
|
||||||
|
emit('search', where);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 重置 */
|
||||||
|
const reset = () => {
|
||||||
|
resetFields();
|
||||||
|
search();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
158
z_ele/src/views/xm/product/index.vue
Normal file
158
z_ele/src/views/xm/product/index.vue
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
<template>
|
||||||
|
<ele-page>
|
||||||
|
<!-- 搜索表单 -->
|
||||||
|
<member-search @search="reload" />
|
||||||
|
<ele-card :body-style="{ paddingTop: '8px' }">
|
||||||
|
<!-- 表格 -->
|
||||||
|
<ele-pro-table
|
||||||
|
ref="tableRef"
|
||||||
|
row-key="roleId"
|
||||||
|
:columns="columns"
|
||||||
|
:datasource="datasource"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
v-model:selections="selections"
|
||||||
|
:highlight-current-row="true"
|
||||||
|
cache-key="systemRoleTable"
|
||||||
|
>
|
||||||
|
<template #toolbar> </template>
|
||||||
|
<template #action="{ row }">
|
||||||
|
<el-link type="primary" underline="never" @click="openEdit(row)">
|
||||||
|
编辑
|
||||||
|
</el-link>
|
||||||
|
<el-divider direction="vertical" />
|
||||||
|
<el-link type="danger" underline="never" @click="remove(row)">
|
||||||
|
删除
|
||||||
|
</el-link>
|
||||||
|
</template>
|
||||||
|
</ele-pro-table>
|
||||||
|
</ele-card>
|
||||||
|
<!-- 编辑弹窗 -->
|
||||||
|
<member-edit v-model="showEdit" :data="current" @done="reload" />
|
||||||
|
</ele-page>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { ElMessageBox } from 'element-plus';
|
||||||
|
import { EleMessage } from 'ele-admin-plus';
|
||||||
|
import type { EleProTable } from 'ele-admin-plus';
|
||||||
|
import type {
|
||||||
|
DatasourceFunction,
|
||||||
|
Columns
|
||||||
|
} from 'ele-admin-plus/es/ele-pro-table/types';
|
||||||
|
import MemberSearch from './components/member-search.vue';
|
||||||
|
import MemberEdit from './components/member-edit.vue';
|
||||||
|
import { removeRoles } from '@/api/system/role';
|
||||||
|
import type { Product, ProductParam } from '@/api/xm/product/model';
|
||||||
|
import { pageProducts } from '@/api/xm/product';
|
||||||
|
|
||||||
|
defineOptions({ name: 'SystemRole' });
|
||||||
|
|
||||||
|
/** 表格实例 */
|
||||||
|
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||||
|
|
||||||
|
/** 表格列配置 */
|
||||||
|
const columns = ref<Columns>([
|
||||||
|
{
|
||||||
|
type: 'selection',
|
||||||
|
columnKey: 'selection',
|
||||||
|
width: 50,
|
||||||
|
align: 'center' /* ,
|
||||||
|
fixed: 'left' */
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'index',
|
||||||
|
columnKey: 'index',
|
||||||
|
width: 50,
|
||||||
|
align: 'center'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'ProductId',
|
||||||
|
label: '渠道ID',
|
||||||
|
width: 80
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'code',
|
||||||
|
label: '渠道代码',
|
||||||
|
width: 80
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'name',
|
||||||
|
label: '渠道名称',
|
||||||
|
minWidth: 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'createTime',
|
||||||
|
label: '创建时间',
|
||||||
|
width: 170,
|
||||||
|
align: 'center'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
columnKey: 'action',
|
||||||
|
label: '操作',
|
||||||
|
width: 200,
|
||||||
|
align: 'center' /* ,
|
||||||
|
fixed: 'right' */,
|
||||||
|
slot: 'action',
|
||||||
|
hideInPrint: true,
|
||||||
|
hideInExport: true
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** 表格选中数据 */
|
||||||
|
const selections = ref<Product[]>([]);
|
||||||
|
|
||||||
|
/** 当前编辑数据 */
|
||||||
|
const current = ref<Product | null>(null);
|
||||||
|
|
||||||
|
/** 是否显示编辑弹窗 */
|
||||||
|
const showEdit = ref(false);
|
||||||
|
|
||||||
|
/** 表格数据源 */
|
||||||
|
const datasource: DatasourceFunction = ({ pages, where, orders }) => {
|
||||||
|
return pageProducts({ ...where, ...orders, ...pages });
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 搜索 */
|
||||||
|
const reload = (where?: ProductParam) => {
|
||||||
|
selections.value = [];
|
||||||
|
tableRef.value?.reload?.({ page: 1, where });
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 打开编辑弹窗 */
|
||||||
|
const openEdit = (row?: Product) => {
|
||||||
|
current.value = row ?? null;
|
||||||
|
showEdit.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 删除单个 */
|
||||||
|
const remove = (row?: Product) => {
|
||||||
|
const rows = row == null ? selections.value : [row];
|
||||||
|
if (!rows.length) {
|
||||||
|
EleMessage.error({ message: '请至少选择一条数据', plain: true });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ElMessageBox.confirm(
|
||||||
|
'确定要删除“' + rows.map((d) => d.roleName).join(', ') + '”吗?',
|
||||||
|
'系统提示',
|
||||||
|
{ type: 'warning', draggable: true }
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
const loading = EleMessage.loading({
|
||||||
|
message: '请求中..',
|
||||||
|
plain: true
|
||||||
|
});
|
||||||
|
removeRoles(rows.map((d) => d.roleId))
|
||||||
|
.then((msg) => {
|
||||||
|
loading.close();
|
||||||
|
EleMessage.success({ message: msg, plain: true });
|
||||||
|
reload();
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
loading.close();
|
||||||
|
EleMessage.error({ message: e.message, plain: true });
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user