feat:硬件分组查询

This commit is contained in:
dzc committed 2025-01-14 17:27:15 +08:00
1 parent 3262e2cbd2
commit 6e32c1d4d7
9 files changed
+433 -19

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
# port 端口号
VITE_PORT = 8888
#浏览器自动打开
VITE_OPEN = true
# 本地环境
ENV = 'development'
# ADMIN 服务地址
# VITE_ADMIN_PROXY_PATH = http://123.156.230.15:8089/api/ # 线上
# VITE_ADMIN_PROXY_PATH = http://pjcloud.center.takin.cc/
# VITE_ADMIN_PROXY_PATH = http://localhost:9999
VITE_ADMIN_PROXY_PATH = http://192.168.101.29:9999/ # 邓-本地
# 图片访问基础地址
# VITE_IMAGE_BASE_PATH = http://123.156.230.15:8089/api # 线上
# VITE_IMAGE_BASE_PATH = http://pjcloud.center.takin.cc
# VITE_IMAGE_BASE_PATH = http://localhost:9999
VITE_IMAGE_BASE_PATH = http://192.168.101.29:9999 # 邓-本地
# 代码生成服务地址
VITE_GEN_PROXY_PATH = http://192.168.110.156:5003
+48
View File
@@ -0,0 +1,48 @@
import request from "/@/utils/request"
export function pageJoin(query?: Object) {
return request({
url: "/hard/hard-group/page-join",
method: "get",
params: query,
})
}
export function fetchList(query?: Object) {
return request({
url: "/hard/hard-group/page",
method: "get",
params: query,
})
}
export function addObj(obj?: Object) {
return request({
url: "/hard/hard-group",
method: "post",
data: obj,
})
}
export function getObj(id?: string) {
return request({
url: "/hard/hard-group/" + id,
method: "get",
})
}
export function delObjs(ids?: Object) {
return request({
url: "/hard/hard-group",
method: "delete",
data: ids,
})
}
export function putObj(obj?: Object) {
return request({
url: "/hard/hard-group",
method: "put",
data: obj,
})
}
+19 -19
View File
@@ -22,14 +22,14 @@
<el-button circle icon="Refresh" @click="handleRefresh()" />
</el-tooltip>
<!-- 插槽 -->
<slot></slot>
</el-row>
<!-- 插槽 -->
<slot></slot>
</el-row>
</div>
</template>
<script setup name="right-toolbar">
import { auth } from '/@/utils/authFunction';
import { auth } from "/@/utils/authFunction"
/**
* 通过 defineProps 函数定义组件 props
@@ -63,43 +63,43 @@ const props = defineProps({
type: Number,
default: 10,
},
});
})
const emits = defineEmits(['update:showSearch', 'queryTable', 'exportExcel']);
const emits = defineEmits(["update:showSearch", "queryTable", "exportExcel"])
const style = computed(() => {
const ret = {};
const ret = {}
// 如果props中有传入gutter属性,则计算出marginRight
if (props.gutter) {
ret.marginRight = `${props.gutter / 2}px`;
ret.marginRight = `${props.gutter / 2}px`
}
return ret; // 返回计算后的样式对象
});
return ret // 返回计算后的样式对象
})
// 搜索
const toggleSearch = () => {
emits('update:showSearch', !props.showSearch);
};
emits("update:showSearch", !props.showSearch)
}
// 刷新
const handleRefresh = () => {
emits('queryTable');
};
emits("queryTable")
}
// 导出excel
const handleExport = () => {
emits('exportExcel');
};
emits("exportExcel")
}
// 是否导出
const isExport = () => {
if (props.export === true) {
return true;
return true
}
// 字符串鉴权
return props.export && auth(props.export);
};
return props.export && auth(props.export)
}
</script>
<style lang="scss" scoped>
+81
View File
@@ -0,0 +1,81 @@
<template>
<el-select
style="width: 100%"
v-model="state.selectId"
:placeholder="props.placeholder"
clearable
remote-show-suffix
filterable
remote
:remote-method="remoteSearch"
:loading="state.loading"
@visible-change="(e: boolean) => e && getOptions()"
>
<el-option v-for="v in state.options" :key="v.id" :label="`${v.name}`" :value="v.id">
<div class="flex items-center">
<div class="color-primary">{{ v.name }}</div>
</div>
</el-option>
</el-select>
</template>
<script setup lang="ts" name="select-hard-group">
import { reactive, defineModel, withDefaults, defineProps } from "vue"
import * as hardGroup from "/@/api/hard/hard-group"
const selectId = defineModel()
export type Props = {
placeholder?: string
}
const props = withDefaults(defineProps<Props>(), {
placeholder: "请选择",
})
const queryForm = reactive<any>({
name: null,
current: 1,
size: 10,
})
const state = reactive<any>({
loading: true,
selectId: selectId,
options: [],
})
watch(
selectId,
(newVal, oldValue) => {
if (newVal == oldValue) return
state.selectId = newVal
getOptions()
},
{ immediate: true },
)
async function getOptions() {
try {
state.loading = true
const _pa = {
...queryForm,
}
const { data } = await hardGroup.pageJoin(_pa)
state.options = data.records ?? []
} finally {
setTimeout(() => (state.loading = false), 500)
}
}
function remoteSearch(params: string) {
if (params != queryForm.name) {
queryForm.name = params
getOptions()
}
}
function clear() {
state.selectId = null
getOptions()
}
</script>
+2
View File
@@ -20,6 +20,7 @@ import SelectMch from "/@/components/Select/SelectMch.vue"
import SelectDept from "/@/components/Select/SelectDept.vue"
import SelectCtcg from "/@/components/Select/SelectCtcg.vue"
import SelectCtcgol from "/@/components/Select/SelectCtcgol.vue"
import SelectHardGroup from "/@/components/Select/selectHardGroup.vue"
// 第三方组件
import ElementPlus from "element-plus"
@@ -61,6 +62,7 @@ export default {
app.component("SelectDept", SelectDept)
app.component("SelectCtcg", SelectCtcg)
app.component("SelectCtcgol", SelectCtcgol)
app.component("SelectHardGroup", SelectHardGroup)
// 导入全部的elmenet-plus的图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
+98
View File
@@ -0,0 +1,98 @@
<template>
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible" width="30%" :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-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="HardGroupDialog">
import { useDict } from "/@/hooks/dict"
import { useMessage } from "/@/hooks/message"
import { getObj, addObj, putObj } from "/@/api/hard/hard-group"
import { rule } from "/@/utils/validate"
const emit = defineEmits(["refresh"])
// 定义变量内容
const dataFormRef = ref()
const visible = ref(false)
const loading = ref(false)
// 定义字典
// 提交表单数据
const form = reactive({
id: "",
deptId: "",
name: "",
})
// 定义校验规则
const dataRules = ref({
name: [{ required: true, message: "分组名不能为空", trigger: "blur" }],
})
// 打开弹窗
const openDialog = (id: string) => {
visible.value = true
form.id = ""
// 重置表单数据
nextTick(() => {
dataFormRef.value?.resetFields()
})
// 获取hardGroup信息
if (id) {
form.id = id
gethardGroupData(id)
}
}
// 提交
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 ? "修改成功" : "添加成功")
visible.value = false
emit("refresh")
} catch (err: any) {
useMessage().error(err.msg)
} finally {
loading.value = false
}
}
// 初始化表单数据
const gethardGroupData = (id: string) => {
// 获取数据
loading.value = true
getObj(id)
.then((res: any) => {
Object.assign(form, res.data)
})
.finally(() => {
loading.value = false
})
}
// 暴露变量
defineExpose({
openDialog,
})
</script>
+154
View File
@@ -0,0 +1,154 @@
<template>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
<el-row :gutter="24">
<el-col :span="4">
<el-form-item class="w100" label="分组名" prop="name">
<el-input v-model="state.queryForm.name" placeholder="分组名" />
</el-form-item>
</el-col>
<el-form-item>
<el-button icon="Search" type="primary" @click="getDataList">{{ $t("common.queryBtn") }}</el-button>
<el-button icon="Refresh" @click="resetQuery">{{ $t("common.resetBtn") }}</el-button>
</el-form-item>
</el-row>
</el-form>
<el-row>
<div class="mb8" style="width: 100%">
<el-button
icon="folder-add"
type="primary"
class="ml10"
@click="formDialogRef.openDialog()"
v-auth="'hard_hardGroup_add'"
>
新 增
</el-button>
<el-button
plain
:disabled="multiple"
icon="Delete"
type="primary"
v-auth="'hard_hardGroup_del'"
@click="handleDelete(selectObjs)"
>
删除
</el-button>
<right-toolbar
v-model:showSearch="showSearch"
@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="id" label="编号" />
<el-table-column prop="name" label="分组名" />
<el-table-column v-if="false" prop="deptName" label="部门" />
<el-table-column label="操作" width="150">
<template #default="scope">
<el-button
icon="edit-pen"
text
type="primary"
v-auth="'hard_hardGroup_edit'"
@click="formDialogRef.openDialog(scope.row.id)"
>编辑</el-button
>
<el-button
icon="delete"
text
type="primary"
v-auth="'hard_hardGroup_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>
</template>
<script setup lang="ts" name="systemHardGroup">
import { BasicTableProps, useTable } from "/@/hooks/table"
import { pageJoin, delObjs } from "/@/api/hard/hard-group"
import { useMessage, useMessageBox } from "/@/hooks/message"
import { useDict } from "/@/hooks/dict"
// 引入组件
const FormDialog = defineAsyncComponent(() => import("./form.vue"))
// 定义查询字典
// 定义变量内容
const formDialogRef = ref()
// 搜索变量
const queryRef = ref()
const showSearch = ref(true)
// 多选变量
const selectObjs = ref([]) as any
const multiple = ref(true)
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {},
pageList: pageJoin,
})
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } =
useTable(state)
// 清空搜索条件
const resetQuery = () => {
// 清空搜索条件
queryRef.value?.resetFields()
// 清空多选
selectObjs.value = []
getDataList()
}
// 导出excel
const exportExcel = () => {
downBlobFile("/hard/hardGroup/export", Object.assign(state.queryForm, { ids: selectObjs }), "hardGroup.xlsx")
}
// 多选事件
const selectionChangHandle = (objs: { id: string }[]) => {
selectObjs.value = objs.map(({ id }) => id)
multiple.value = !objs.length
}
// 删除操作
const handleDelete = async (ids: string[]) => {
try {
await useMessageBox().confirm("此操作将永久删除")
} catch {
return
}
try {
await delObjs(ids)
getDataList()
useMessage().success("删除成功")
} catch (err: any) {
useMessage().error(err.msg)
}
}
</script>
+7
View File
@@ -14,6 +14,12 @@
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="分组" prop="groupId">
<select-hard-group v-model="form.groupId" placeholder="分组" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="设备类型" prop="type">
<dict-select v-model="form.type" dict-code="hard_type" clearable />
@@ -56,6 +62,7 @@ const form = reactive({
const dataRules = ref({
name: [{ required: true, message: "设备名不能为空", trigger: "blur" }],
merchantId: [{ required: true, message: "商户不能为空", trigger: "change" }],
groupId: [{ required: true, message: "分组不能为空", trigger: "change" }],
type: [{ required: true, message: "设备类型不能为空", trigger: "change" }],
})
+1
View File
@@ -72,6 +72,7 @@
<dict-tag :options="hard_type" :value="row.type" />
</template>
</el-table-column>
<el-table-column prop="hardGroupName" width="200" label="分类" />
<el-table-column prop="merchantName" width="100" label="商户" />
<el-table-column prop="deptName" width="100" label="部门" />
<el-table-column prop="uniqueCode" width="200" label="设备唯一编号" />