mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-09-26 20:21:19 +08:00
优化代码生成
This commit is contained in:
1
server/.vscode/settings.json
vendored
1
server/.vscode/settings.json
vendored
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"dcloudio",
|
||||
"excelize",
|
||||
"fontsize",
|
||||
"freetype",
|
||||
|
@@ -25,9 +25,9 @@ admin:{{{.ModuleName }}}:detail
|
||||
admin:{{{.ModuleName }}}:ExportFile
|
||||
admin:{{{.ModuleName }}}:ImportFile
|
||||
|
||||
// 列表
|
||||
// 列表-先添加菜单获取菜单id
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, paths, component, is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'C', '{{{ .FunctionName }}}', '/{{{ .ModuleName }}}/index', '{{{ .ModuleName }}}/index', 0, 1, 0, now(), now());
|
||||
按钮
|
||||
按钮-替换pid参数为菜单id
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}添加','admin:{{{ .ModuleName }}}:add', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}编辑','admin:{{{ .ModuleName }}}:edit', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}删除','admin:{{{ .ModuleName }}}:del', 0, 1, 0, now(), now());
|
||||
|
@@ -1,11 +1,5 @@
|
||||
<template>
|
||||
<view class="page-content">
|
||||
<uv-navbar leftText="" :placeholder="true" title="{{{.FunctionName}}}详情" autoBack>
|
||||
<template v-slot:right>
|
||||
<uv-icon name="edit-pen" size="20" @click="edit"></uv-icon>
|
||||
</template>
|
||||
</uv-navbar>
|
||||
|
||||
<uv-form labelPosition="left" :model="form">
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsList }}}
|
||||
@@ -25,7 +19,7 @@
|
||||
v-if="$perms('admin:{{{ .ModuleName }}}:edit')"
|
||||
type="primary"
|
||||
text="编辑"
|
||||
customStyle="margin-top: 20rpx"
|
||||
customStyle="margin: 40rpx 0"
|
||||
@click="edit"
|
||||
></uv-button>
|
||||
|
||||
|
@@ -21,7 +21,7 @@
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
|
||||
<uv-button type="primary" text="提交" customStyle="margin-top: 20rpx"
|
||||
<uv-button type="primary" text="提交" customStyle="margin: 40rpx 0"
|
||||
@click="submit"></uv-button>
|
||||
</uv-form>
|
||||
</view>
|
||||
@@ -34,7 +34,8 @@
|
||||
} from "@dcloudio/uni-app";
|
||||
import {
|
||||
{{{ .ModuleName }}}_detail,
|
||||
{{{ .ModuleName }}}_edit
|
||||
{{{ .ModuleName }}}_edit,
|
||||
{{{ .ModuleName }}}_add
|
||||
} from "@/api/{{{ .ModuleName }}}";
|
||||
import type { type_{{{ .ModuleName }}}_edit } from "@/api/{{{ .ModuleName }}}";
|
||||
|
||||
@@ -81,7 +82,9 @@
|
||||
}
|
||||
onLoad((e) => {
|
||||
console.log("onLoad", e);
|
||||
getDetails(e.id);
|
||||
if (e.id) {
|
||||
getDetails(e.id);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -112,15 +115,26 @@
|
||||
function submit() {
|
||||
console.log("submit", form.value);
|
||||
formRef.value.validate().then(() => {
|
||||
{{{ .ModuleName }}}_edit(form.value).then((res) => {
|
||||
if (res.code == 200) {
|
||||
toast("编辑成功");
|
||||
|
||||
getDetails(form.value?.id);
|
||||
} else {
|
||||
toast(res.message);
|
||||
}
|
||||
});
|
||||
if (form.value.id) {
|
||||
{{{ .ModuleName }}}_edit(form.value).then((res) => {
|
||||
if (res.code == 200) {
|
||||
toast("编辑成功");
|
||||
getDetails(form.value?.id);
|
||||
} else {
|
||||
toast(res.message);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
{{{ .ModuleName }}}_add(form.value).then((res) => {
|
||||
if (res.code == 200) {
|
||||
toast("添加成功");
|
||||
uni.navigateBack();
|
||||
} else {
|
||||
toast(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<view>
|
||||
|
||||
<!--
|
||||
<uv-sticky :customNavHeight="0" bgColor="#fff">
|
||||
<uv-status-bar></uv-status-bar>
|
||||
<uv-navbar
|
||||
@@ -16,7 +16,7 @@
|
||||
</uv-navbar>
|
||||
|
||||
</uv-sticky>
|
||||
|
||||
-->
|
||||
<uv-list>
|
||||
<uv-list-item
|
||||
v-for="item of pager.lists"
|
||||
@@ -24,12 +24,18 @@
|
||||
clickable
|
||||
show-arrow
|
||||
:title="item.id"
|
||||
:note="item.id"
|
||||
:right-text="item.id"
|
||||
@click="toDetails(item)"
|
||||
></uv-list-item>
|
||||
</uv-list>
|
||||
|
||||
<wd-fab v-model:active="activeFab" :draggable="true">
|
||||
<wd-button v-if="!fromSearch" custom-class="fab-button" type="primary" round @click="moreSearch" >
|
||||
<wd-icon name="search" size="20px"></wd-icon>
|
||||
</wd-button>
|
||||
<wd-button v-if="$perms('admin:{{{ .ModuleName }}}:add')" custom-class="fab-button" type="primary" round @click="add">
|
||||
<wd-icon name="add" size="20px"></wd-icon>
|
||||
</wd-button>
|
||||
</wd-fab>
|
||||
<uv-back-top :scroll-top="scrollTop"></uv-back-top>
|
||||
|
||||
<uv-empty v-if="pager.loading =='nomore'&&pager.lists.length == 0" marginTop="150" mode="data"></uv-empty>
|
||||
@@ -74,6 +80,7 @@ const queryParams = reactive<type_{{{.ModuleName}}}_query>({
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
});
|
||||
let activeFab = ref(false);
|
||||
let fromSearch=ref(false);
|
||||
onLoad((e) => {
|
||||
console.log("{{{ .ModuleName }}} onLoad", e);
|
||||
@@ -108,8 +115,18 @@ function toDetails(item) {
|
||||
function moreSearch() {
|
||||
toPath("/pages/{{{ .ModuleName }}}/search");
|
||||
}
|
||||
function add() {
|
||||
toPath("/pages/{{{ .ModuleName }}}/edit");
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
:deep(.fab-button) {
|
||||
min-width: auto !important;
|
||||
box-sizing: border-box;
|
||||
width: 40px !important;
|
||||
height: 40px !important;
|
||||
border-radius: 40px !important;
|
||||
margin: 8rpx;
|
||||
}
|
||||
</style>
|
||||
|
@@ -6,16 +6,14 @@
|
||||
"style": {
|
||||
"navigationBarTitleText": "{{{.FunctionName}}}",
|
||||
"enablePullDownRefresh": true,
|
||||
"onReachBottomDistance": 100,
|
||||
"navigationStyle": "custom"
|
||||
"onReachBottomDistance": 100
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/{{{ .ModuleName }}}/details",
|
||||
"style": {
|
||||
"navigationBarTitleText": "{{{.FunctionName}}}详情",
|
||||
"enablePullDownRefresh": true,
|
||||
"navigationStyle": "custom"
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@@ -43,7 +43,7 @@ func (adminSrv systemAuthAdminService) Self(adminId uint) (res SystemAuthAdminSe
|
||||
// 管理员信息
|
||||
var sysAdmin system_model.SystemAuthAdmin
|
||||
err := adminSrv.db.Where("id = ? AND is_delete = ?", adminId, 0).Limit(1).First(&sysAdmin).Error
|
||||
if e = response.CheckErr(err, "Self First err"); e != nil {
|
||||
if e = response.CheckErr(err, "获取用户信息失败"); e != nil {
|
||||
return
|
||||
}
|
||||
// 角色权限
|
||||
@@ -59,18 +59,21 @@ func (adminSrv systemAuthAdminService) Self(adminId uint) (res SystemAuthAdminSe
|
||||
err := adminSrv.db.Where(
|
||||
"id in ? AND is_disable = ? AND menu_type in ?", menuIds, 0, []string{"C", "A"}).Order(
|
||||
"menu_sort, id").Find(&menus).Error
|
||||
if e = response.CheckErr(err, "Self SystemAuthMenu Find err"); e != nil {
|
||||
if e = response.CheckErr(err, "查找权限失败"); e != nil {
|
||||
return
|
||||
}
|
||||
if len(menus) > 0 {
|
||||
for _, v := range menus {
|
||||
if v.Perms == "" {
|
||||
continue
|
||||
}
|
||||
auths = append(auths, strings.Trim(v.Perms, " "))
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(auths) > 0 {
|
||||
auths = append(auths, "")
|
||||
}
|
||||
// if len(auths) > 0 {
|
||||
// auths = append(auths, "")
|
||||
// }
|
||||
} else {
|
||||
auths = append(auths, "*")
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ func (service systemAuthPermService) CacheRoleMenusByRoleId(roleId uint) (e erro
|
||||
err = service.db.Where(
|
||||
"is_disable = ? and id in ? and menu_type in ?", 0, menuIds, []string{"C", "A"}).Order(
|
||||
"menu_sort, id").Find(&menus).Error
|
||||
if e = response.CheckErr(err, "CacheRoleMenusByRoleId Find menus err"); e != nil {
|
||||
if e = response.CheckErr(err, "查找角色菜单失败"); e != nil {
|
||||
return
|
||||
}
|
||||
var menuArray []string
|
||||
|
@@ -143,12 +143,14 @@ func (roleSrv systemAuthRoleService) Edit(editReq SystemAuthRoleEditReq) (e erro
|
||||
err = roleSrv.db.Transaction(func(tx *gorm.DB) error {
|
||||
txErr := tx.Model(&role).Updates(roleMap).Error
|
||||
var te error
|
||||
if te = response.CheckErr(txErr, "Edit Updates in tx err"); te != nil {
|
||||
if te = response.CheckErr(txErr, "编辑角色失败"); te != nil {
|
||||
return te
|
||||
}
|
||||
// 删除角色菜单
|
||||
if te = PermService.BatchDeleteByRoleId(editReq.ID, tx); te != nil {
|
||||
return te
|
||||
}
|
||||
// 重新保存角色菜单
|
||||
if te = PermService.BatchSaveByMenuIds(editReq.ID, editReq.MenuIds, tx); te != nil {
|
||||
return te
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"version" : "1.0",
|
||||
"configurations" : [
|
||||
{
|
||||
"playground" : "standard",
|
||||
"playground" : "custom",
|
||||
"type" : "uni-app:app-android"
|
||||
},
|
||||
{
|
||||
|
@@ -1,14 +1,16 @@
|
||||
<template>
|
||||
<uv-input
|
||||
:modelValue="selectItem?.[props.labelKey]"
|
||||
placeholder="请选择"
|
||||
readonly
|
||||
@click="openPicker"
|
||||
>
|
||||
</uv-input>
|
||||
<!-- 在微信小程序readonly后无法click,所以套一层view -->
|
||||
<view style="flex: 1" @click="openPicker">
|
||||
<uv-input
|
||||
:modelValue="selectItem?.[props.labelKey]"
|
||||
placeholder="请选择"
|
||||
readonly
|
||||
>
|
||||
</uv-input>
|
||||
</view>
|
||||
|
||||
<uv-picker
|
||||
ref="picker"
|
||||
ref="pickerRef"
|
||||
:columns="columns"
|
||||
:keyName="props.labelKey"
|
||||
:defaultIndex="pickerIndex"
|
||||
@@ -19,7 +21,7 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, computed, watch } from "vue";
|
||||
|
||||
const emit = defineEmits(["update:modelValue"])
|
||||
const emit = defineEmits(["update:modelValue"]);
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
@@ -40,18 +42,18 @@ const props = defineProps({
|
||||
},
|
||||
});
|
||||
const model = computed({
|
||||
get() {
|
||||
return props.modelValue
|
||||
},
|
||||
set(value) {
|
||||
emit('update:modelValue', value)
|
||||
}
|
||||
})
|
||||
get() {
|
||||
return props.modelValue;
|
||||
},
|
||||
set(value) {
|
||||
emit("update:modelValue", value);
|
||||
},
|
||||
});
|
||||
|
||||
const columns = computed(() => {
|
||||
return [props.columns];
|
||||
});
|
||||
const picker = ref(null);
|
||||
const pickerRef = ref(null);
|
||||
|
||||
// const model = defineModel('modelValue');
|
||||
const pickerIndex = ref([0]);
|
||||
@@ -59,7 +61,8 @@ const pickerIndex = ref([0]);
|
||||
const selectItem = ref({});
|
||||
|
||||
function openPicker() {
|
||||
picker.value.open();
|
||||
|
||||
pickerRef.value.open();
|
||||
}
|
||||
function handleConfirm(e) {
|
||||
// debugger;
|
||||
@@ -73,7 +76,7 @@ function handleConfirm(e) {
|
||||
}
|
||||
}
|
||||
function updateSelectItem() {
|
||||
console.log("updateSelectItem", model.value, props.columns);
|
||||
|
||||
if (!model.value) {
|
||||
pickerIndex.value = [0];
|
||||
selectItem.value = {};
|
||||
@@ -101,13 +104,13 @@ function updateSelectItem() {
|
||||
}
|
||||
}
|
||||
onMounted(() => {
|
||||
console.log("onMounted");
|
||||
|
||||
updateSelectItem();
|
||||
});
|
||||
watch(
|
||||
() => [model.value, props.columns],
|
||||
(newVal) => {
|
||||
console.log("watch", newVal);
|
||||
|
||||
updateSelectItem();
|
||||
}
|
||||
);
|
||||
|
@@ -22,8 +22,8 @@
|
||||
"style": {
|
||||
"navigationBarTitleText": "项目监控",
|
||||
"enablePullDownRefresh": true,
|
||||
"onReachBottomDistance": 100,
|
||||
"navigationStyle": "custom"
|
||||
"onReachBottomDistance": 100
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
@@ -31,8 +31,7 @@
|
||||
"path": "pages/monitor_project/details",
|
||||
"style": {
|
||||
"navigationBarTitleText": "项目监控详情",
|
||||
"enablePullDownRefresh": true,
|
||||
"navigationStyle": "custom"
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@@ -1,109 +1,91 @@
|
||||
<template>
|
||||
<view class="page-content">
|
||||
<uv-navbar leftText="" :placeholder="true" title="监控项目详情" autoBack>
|
||||
<template v-slot:right>
|
||||
<uv-icon name="edit-pen" size="20" @click="edit"></uv-icon>
|
||||
</template>
|
||||
</uv-navbar>
|
||||
<view class="page-content">
|
||||
|
||||
<uv-form labelPosition="left" labelWidth="80" :model="form">
|
||||
<uv-form-item label="项目uuid" prop="projectKey" borderBottom>
|
||||
{{form.projectKey}}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="项目名称" prop="projectName" borderBottom>
|
||||
{{form.projectName}}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="项目类型" prop="projectType" borderBottom>
|
||||
{{form.projectType}}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="创建时间" prop="createTime" borderBottom>
|
||||
{{form.createTime}}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="更新时间" prop="updateTime" borderBottom>
|
||||
{{form.updateTime}}
|
||||
</uv-form-item>
|
||||
</uv-form>
|
||||
<uv-button
|
||||
v-if="$perms('admin:monitor_project:edit')"
|
||||
type="primary"
|
||||
text="编辑"
|
||||
customStyle="margin-top: 20rpx"
|
||||
@click="edit"
|
||||
></uv-button>
|
||||
|
||||
</view>
|
||||
<uv-form labelPosition="left" labelWidth="80" :model="form">
|
||||
<uv-form-item label="项目uuid" prop="projectKey" borderBottom>
|
||||
{{ form.projectKey }}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="项目名称" prop="projectName" borderBottom>
|
||||
{{ form.projectName }}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="项目类型" prop="projectType" borderBottom>
|
||||
{{ form.projectType }}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="创建时间" prop="createTime" borderBottom>
|
||||
{{ form.createTime }}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="更新时间" prop="updateTime" borderBottom>
|
||||
{{ form.updateTime }}
|
||||
</uv-form-item>
|
||||
</uv-form>
|
||||
<uv-button
|
||||
v-if="$perms('admin:monitor_project:edit')"
|
||||
type="primary"
|
||||
text="编辑"
|
||||
customStyle="margin: 40rpx 0"
|
||||
@click="edit"
|
||||
></uv-button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
reactive,
|
||||
ref,
|
||||
computed
|
||||
} from "vue";
|
||||
import {
|
||||
onLoad,
|
||||
onShow,
|
||||
onPullDownRefresh
|
||||
} from "@dcloudio/uni-app";
|
||||
import { reactive, ref, computed } from "vue";
|
||||
import { onLoad, onShow, onPullDownRefresh } from "@dcloudio/uni-app";
|
||||
|
||||
import {
|
||||
useDictData
|
||||
} from "@/hooks/useDictOptions";
|
||||
import {
|
||||
monitor_project_detail
|
||||
} from "@/api/monitor_project";
|
||||
import type {type_monitor_project} from "@/api/monitor_project";
|
||||
import { useDictData } from "@/hooks/useDictOptions";
|
||||
import { monitor_project_detail } from "@/api/monitor_project";
|
||||
import type { type_monitor_project } from "@/api/monitor_project";
|
||||
|
||||
import {
|
||||
toast,
|
||||
alert,
|
||||
toPath
|
||||
} from "@/utils/utils";
|
||||
import { toast, alert, toPath } from "@/utils/utils";
|
||||
|
||||
let form = ref<type_monitor_project>({
|
||||
id: 0,
|
||||
projectKey: "",
|
||||
projectName: "",
|
||||
projectType: "",
|
||||
createTime: "",
|
||||
updateTime: "",
|
||||
});
|
||||
onLoad((e) => {
|
||||
console.log("onLoad", e);
|
||||
getDetails(e.id);
|
||||
});
|
||||
onShow((e) => {
|
||||
if (form.value?.id) {
|
||||
getDetails(form.value.id);
|
||||
}
|
||||
});
|
||||
onPullDownRefresh(() => {
|
||||
getDetails(form.value.id);
|
||||
});
|
||||
function getDetails(id) {
|
||||
monitor_project_detail(id).then((res) => {
|
||||
uni.stopPullDownRefresh();
|
||||
if (res.code == 200) {
|
||||
if (res.data) {
|
||||
form.value = res?.data
|
||||
}
|
||||
} else {
|
||||
toast(res.message);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
uni.stopPullDownRefresh();
|
||||
toast(err.message||"网络错误");
|
||||
});
|
||||
}
|
||||
let form = ref<type_monitor_project>({
|
||||
id: 0,
|
||||
projectKey: "",
|
||||
projectName: "",
|
||||
projectType: "",
|
||||
createTime: "",
|
||||
updateTime: "",
|
||||
});
|
||||
onLoad((e) => {
|
||||
console.log("onLoad", e);
|
||||
if (e.id) {
|
||||
getDetails(e.id);
|
||||
}
|
||||
});
|
||||
onShow((e) => {
|
||||
if (form.value?.id) {
|
||||
getDetails(form.value.id);
|
||||
}
|
||||
});
|
||||
onPullDownRefresh(() => {
|
||||
getDetails(form.value.id);
|
||||
});
|
||||
function getDetails(id) {
|
||||
monitor_project_detail(id)
|
||||
.then((res) => {
|
||||
uni.stopPullDownRefresh();
|
||||
if (res.code == 200) {
|
||||
if (res.data) {
|
||||
form.value = res?.data;
|
||||
}
|
||||
} else {
|
||||
toast(res.message);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
uni.stopPullDownRefresh();
|
||||
toast(err.message || "网络错误");
|
||||
});
|
||||
}
|
||||
|
||||
function edit() {
|
||||
toPath("/pages/monitor_project/edit", { id: form.value.id });
|
||||
}
|
||||
function edit() {
|
||||
toPath("/pages/monitor_project/edit", { id: form.value.id });
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-content {
|
||||
padding: 10rpx 20rpx 300rpx;
|
||||
}
|
||||
</style>
|
||||
.page-content {
|
||||
padding: 10rpx 20rpx 300rpx;
|
||||
}
|
||||
</style>
|
||||
|
@@ -1,110 +1,132 @@
|
||||
<template>
|
||||
<view class="page-content">
|
||||
<uv-form labelPosition="left" labelWidth="80" :model="form" :rules="formRules" ref="formRef">
|
||||
<view class="page-content">
|
||||
<uv-form
|
||||
labelPosition="left"
|
||||
labelWidth="80"
|
||||
:model="form"
|
||||
:rules="formRules"
|
||||
ref="formRef"
|
||||
>
|
||||
<uv-form-item label="项目uuid" prop="projectKey" borderBottom>
|
||||
<uv-input v-model="form.projectKey" border="surround"></uv-input>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="项目名称" prop="projectName" borderBottom>
|
||||
<uv-input v-model="form.projectName" border="surround"></uv-input>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="项目类型" prop="projectType" borderBottom>
|
||||
<x-picker
|
||||
v-model="form.projectType"
|
||||
valueKey="value"
|
||||
labelKey="name"
|
||||
:columns="dictData.project_type"
|
||||
></x-picker>
|
||||
</uv-form-item>
|
||||
|
||||
<uv-form-item label="项目uuid" prop="projectKey" borderBottom>
|
||||
<uv-input v-model="form.projectKey" border="surround"></uv-input>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="项目名称" prop="projectName" borderBottom>
|
||||
<uv-input v-model="form.projectName" border="surround"></uv-input>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="项目类型" prop="projectType" borderBottom>
|
||||
<x-picker v-model="form.projectType" valueKey="value" labelKey="name"
|
||||
:columns="dictData.project_type"></x-picker>
|
||||
</uv-form-item>
|
||||
|
||||
<uv-button type="primary" text="提交" customStyle="margin-top: 20rpx" @click="submit"></uv-button>
|
||||
</uv-form>
|
||||
</view>
|
||||
<uv-button
|
||||
type="primary"
|
||||
text="提交"
|
||||
customStyle="margin: 40rpx 0"
|
||||
@click="submit"
|
||||
></uv-button>
|
||||
</uv-form>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
reactive,
|
||||
ref,
|
||||
computed
|
||||
} from "vue";
|
||||
import {
|
||||
onLoad
|
||||
} from "@dcloudio/uni-app";
|
||||
import {
|
||||
monitor_project_detail,
|
||||
monitor_project_edit,
|
||||
} from "@/api/monitor_project";
|
||||
import type {type_monitor_project_edit} from "@/api/monitor_project";
|
||||
import {
|
||||
toast,
|
||||
alert
|
||||
} from "@/utils/utils";
|
||||
import {
|
||||
useDictData
|
||||
} from "@/hooks/useDictOptions";
|
||||
const {
|
||||
dictData
|
||||
} = useDictData(['project_type'])
|
||||
let formRef = ref();
|
||||
let form = ref<type_monitor_project_edit>({
|
||||
id: null,
|
||||
projectKey: "",
|
||||
projectName: "",
|
||||
projectType: "",
|
||||
});
|
||||
const formRules = {
|
||||
projectKey: [{
|
||||
required: true,
|
||||
message: "请输入项目uuid",
|
||||
trigger: ["blur"],
|
||||
}, ],
|
||||
projectName: [{
|
||||
required: true,
|
||||
message: "请输入项目名称",
|
||||
trigger: ["blur"],
|
||||
}, ],
|
||||
projectType: [{
|
||||
required: true,
|
||||
message: "请选择项目类型",
|
||||
trigger: ["blur"],
|
||||
}, ],
|
||||
};
|
||||
onLoad((e) => {
|
||||
console.log("onLoad", e);
|
||||
getDetails(e.id);
|
||||
});
|
||||
import { reactive, ref, computed } from "vue";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import {
|
||||
monitor_project_detail,
|
||||
monitor_project_edit,
|
||||
monitor_project_add,
|
||||
} from "@/api/monitor_project";
|
||||
import type { type_monitor_project_edit } from "@/api/monitor_project";
|
||||
import { toast, alert } from "@/utils/utils";
|
||||
import { useDictData } from "@/hooks/useDictOptions";
|
||||
const { dictData } = useDictData(["project_type"]);
|
||||
let formRef = ref();
|
||||
let form = ref<type_monitor_project_edit>({
|
||||
id: null,
|
||||
projectKey: "",
|
||||
projectName: "",
|
||||
projectType: "",
|
||||
});
|
||||
const formRules = {
|
||||
projectKey: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入项目uuid",
|
||||
trigger: ["blur"],
|
||||
},
|
||||
],
|
||||
projectName: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入项目名称",
|
||||
trigger: ["blur"],
|
||||
},
|
||||
],
|
||||
projectType: [
|
||||
{
|
||||
required: true,
|
||||
message: "请选择项目类型",
|
||||
trigger: ["blur"],
|
||||
},
|
||||
],
|
||||
};
|
||||
onLoad((e) => {
|
||||
console.log("onLoad", e);
|
||||
|
||||
function getDetails(id) {
|
||||
monitor_project_detail(id)
|
||||
.then((res) => {
|
||||
if (res.code == 200) {
|
||||
if (res.data) {
|
||||
form.value = res?.data;
|
||||
}
|
||||
} else {
|
||||
toast(res.message);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toast(err.message || "网络错误");
|
||||
});
|
||||
}
|
||||
if (e.id) {
|
||||
getDetails(e.id);
|
||||
}
|
||||
});
|
||||
|
||||
function submit() {
|
||||
console.log("submit", form);
|
||||
formRef.value.validate().then(() => {
|
||||
monitor_project_edit(form.value).then((res) => {
|
||||
if (res.code == 200) {
|
||||
toast("编辑成功");
|
||||
function getDetails(id) {
|
||||
monitor_project_detail(id)
|
||||
.then((res) => {
|
||||
if (res.code == 200) {
|
||||
if (res.data) {
|
||||
form.value = res?.data;
|
||||
}
|
||||
} else {
|
||||
toast(res.message);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toast(err.message || "网络错误");
|
||||
});
|
||||
}
|
||||
|
||||
getDetails(form.value?.id);
|
||||
} else {
|
||||
toast(res.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
function submit() {
|
||||
console.log("submit", form);
|
||||
formRef.value.validate().then(() => {
|
||||
if (form.value.id) {
|
||||
monitor_project_edit(form.value).then((res) => {
|
||||
if (res.code == 200) {
|
||||
toast("编辑成功");
|
||||
|
||||
getDetails(form.value?.id);
|
||||
} else {
|
||||
toast(res.message);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
monitor_project_add(form.value).then((res) => {
|
||||
if (res.code == 200) {
|
||||
toast("添加成功");
|
||||
uni.navigateBack();
|
||||
} else {
|
||||
toast(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-content {
|
||||
padding: 10rpx 20rpx 300rpx;
|
||||
}
|
||||
</style>
|
||||
.page-content {
|
||||
padding: 10rpx 20rpx 300rpx;
|
||||
}
|
||||
</style>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view>
|
||||
|
||||
<uv-sticky :customNavHeight="0" bgColor="#fff">
|
||||
<!-- <uv-sticky :customNavHeight="0" bgColor="#fff">
|
||||
<uv-status-bar></uv-status-bar>
|
||||
<uv-navbar
|
||||
leftText=""
|
||||
@@ -15,7 +15,7 @@
|
||||
</template>
|
||||
</uv-navbar>
|
||||
|
||||
</uv-sticky>
|
||||
</uv-sticky> -->
|
||||
|
||||
<uv-list>
|
||||
<uv-list-item
|
||||
@@ -24,12 +24,20 @@
|
||||
clickable
|
||||
show-arrow
|
||||
:title="item.id"
|
||||
:note="item.id"
|
||||
:right-text="item.id"
|
||||
|
||||
:right-text="item.projectType"
|
||||
@click="toDetails(item)"
|
||||
></uv-list-item>
|
||||
</uv-list>
|
||||
|
||||
<wd-fab v-model:active="activeFab" :draggable="true">
|
||||
<wd-button v-if="!fromSearch" custom-class="fab-button" type="primary" round @click="moreSearch" >
|
||||
<wd-icon name="search" size="20px"></wd-icon>
|
||||
</wd-button>
|
||||
<wd-button v-if="$perms('admin:monitor_project:add')" custom-class="fab-button" type="primary" round @click="add">
|
||||
<wd-icon name="add" size="20px"></wd-icon>
|
||||
</wd-button>
|
||||
</wd-fab>
|
||||
<uv-back-top :scroll-top="scrollTop"></uv-back-top>
|
||||
|
||||
<uv-empty v-if="pager.loading =='nomore'&&pager.lists.length == 0" marginTop="150" mode="data"></uv-empty>
|
||||
@@ -71,6 +79,8 @@
|
||||
updateTimeStart: '',
|
||||
updateTimeEnd: '',
|
||||
});
|
||||
let activeFab = ref(false);
|
||||
|
||||
let fromSearch=ref(false);
|
||||
onLoad((e) => {
|
||||
console.log("monitor_project onLoad", e);
|
||||
@@ -105,9 +115,21 @@
|
||||
function moreSearch() {
|
||||
toPath("/pages/monitor_project/search");
|
||||
}
|
||||
|
||||
function add() {
|
||||
toPath("/pages/monitor_project/edit");
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
:deep(.fab-button) {
|
||||
min-width: auto !important;
|
||||
box-sizing: border-box;
|
||||
width: 40px !important;
|
||||
height: 40px !important;
|
||||
border-radius: 40px !important;
|
||||
margin: 8rpx;
|
||||
}
|
||||
</style>
|
||||
|
@@ -8,12 +8,12 @@
|
||||
<uv-input v-model="form.projectName"> </uv-input>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="项目类型" prop="projectType" borderBottom>
|
||||
<!-- <x-picker
|
||||
<x-picker
|
||||
v-model="form.projectType"
|
||||
valueKey="value"
|
||||
labelKey="name"
|
||||
:columns="dictData.project_type"
|
||||
></x-picker> -->
|
||||
></x-picker>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="创建时间" prop="createTime" borderBottom>
|
||||
<xDateRange
|
||||
|
@@ -10,8 +10,8 @@ export const useUserStore = defineStore("user", {
|
||||
username: "",
|
||||
avatar: "",
|
||||
userInfo: {},
|
||||
menu: [],
|
||||
auth: [],
|
||||
// menu: [],
|
||||
permissions: [],
|
||||
};
|
||||
},
|
||||
// 也可以这样定义
|
||||
@@ -33,7 +33,7 @@ export const useUserStore = defineStore("user", {
|
||||
|
||||
this.avatar = data.user.avatar ||"";
|
||||
// this.menu = data.menu;
|
||||
// this.auth = data.auth;
|
||||
this.permissions = data.permissions;
|
||||
this.userInfo = data.user;
|
||||
resolve(data);
|
||||
} else {
|
||||
|
@@ -1,12 +1,12 @@
|
||||
import { useUserStore } from "@/stores/user";
|
||||
|
||||
export const perms = (perms:string) => {
|
||||
if (!perms) return true;
|
||||
if (!perms) return false;
|
||||
const userStore = useUserStore();
|
||||
const auth = userStore.auth;
|
||||
const permissions = userStore.permissions;
|
||||
|
||||
let find = auth.find((item) => {
|
||||
return item.action === perms;
|
||||
let find = permissions.find((item) => {
|
||||
return item === perms|| item === "*";
|
||||
});
|
||||
return !!find;
|
||||
};
|
||||
|
Reference in New Issue
Block a user