mineadmin / mineadmin-vue Goto Github PK
View Code? Open in Web Editor NEWMineAdmin Vue 是一个开源免费专门适配于 MineAdmin 后台权限管理系统的前端中后台模板,使用了 vue3, vite5, pinia, arco design, javascript 等主流开发技术,未使用Typescript,我们选择了简单。
License: MIT License
MineAdmin Vue 是一个开源免费专门适配于 MineAdmin 后台权限管理系统的前端中后台模板,使用了 vue3, vite5, pinia, arco design, javascript 等主流开发技术,未使用Typescript,我们选择了简单。
License: MIT License
@input-value-change="rv('onInputValueChange', $event)"
以及@search="rv('onSearch', $event)"
此处可以抛出给外部处理,但是应该优先内部尝试更新远程字典才更合适。
事实上,当用户在下拉框手动写关键字时,应该把关键字带上,给后端去过虑。
现在,整个业务逻辑上没有这一块的处理。我尝试去写这样一个方法。但是未成功。
因为后端目前暂使用官网演示的方式使用会报错。请处理一下这个问题。
username: [ 'like', 'a' ]
这样的方法会报对应字段要求必需为字符串。
{
title: '发布者',
dataIndex: 'user_id',
formType: 'select',
dict: {
// 远程通用接口请求,新版代码生成都有一个 remote 接口
remote: 'system/user/remote',
// 指定组件接收的props
props: { label: 'username', value: 'id' },
// 开启分页
openPage: true,
// 远程请求配置项
remoteOption: {
// 按用户名排序
sort: { username: 'desc' }, // 如果不指定排序方式,默认为正序排序
// 设置查询的字段
select: [ 'id', 'username' ],
// 设置数据过滤
filter: {
// 查找 id 大于 2 的数据
id: [ '>', 2],
// 并且用户名包含字母 a 的用户
username: [ 'like', 'a' ]
},
// 关联模型
relations: [
// 定义关联,关联该用户的登录日志信息
{
name: 'loginLog', // 关联名
model: 'App.System.Model.LoginLog', // 关联模型的命名空间,使用 . 代替 \,可咨询后端人员
type: 'hasMany', // 关联类型,hasOne:一对一,hasMany:一对多,belongsTo:一对多(反向),belongsToMany:多对多
foreignKey: 'username', // 日志表关联键
localKey: 'username', // 本表外键
},
// 其他关联....其他可查看 MapperTiart.php 的源代码自行参考
]
}
}
},
请问大概还需要多久生产环境可用?
或者发布rc版本
最近有个新项目,想使用,所以了解一下情况
在使用组合表头的时候,设置columns搜索和表格都没问题,但是from无法获取到表单字段
配置如下
//此处省略...
const columns = reactive([
{
title: "名称",
dataIndex: "name",
formType: "input",
search: true
},
{
title:"状态组",align: 'content',addDisplay: false, editDisplay: false,
children:[
{
title: "状态1",
dataIndex: "status_1",
formType: "input",
search: true,
addDisplay: false,
editDisplay: false,width:100,
},
{
title: "状态2",
dataIndex: `"status_2",`
formType: "input",
addDisplay: false,
editDisplay: false,width:100,
},
]
},
{
dataIndex:'remark',title:"备注",
},
])
//此处省略...
我已进行了如下修复
src/components/ma-crud/components/form.vue
第194行,把原来的代码替换成
//此处省略...
columns.value.map(async item => {
if (item.children && item.children.length > 0){
await item.children.map(async (childItem) => {
await columnItemHandle(childItem)
})
}else {
await columnItemHandle(item)
}
})
//此处省略...
联动 FORM 组件 cascaderItem,初始化回显时有问题
正常A下拉框选择联动加载B是没问题的,但是如果是编辑界面,初始化A的后,B需要手动切换一次A才会有 {{key}}
路由地址是多级的时候点击面包屑的仪表盘 路由地址会出错
当前路由
/system/loginlog
点击面包屑仪表盘后应该是
/dashboard
而不是
/system/dashboard
这次提交增加的 setTimeout 意图是什么呢?
重现方法:
const columns = reactive([
{
title: "序号",
dataIndex: "id",
formType: "input",
addDisplay: false,
editDisplay: false,
hide: true,
commonRules: {
required: true,
message: "请输入序号"
}
},
{
title: "数字",
dataIndex: "n",
formType: "input-number",
search: true,
commonRules: {
required: true,
message: "请输入数字"
}
},
]};
add模式中,当必选时,输入数字后,切换出该组件(失去焦点)应该是没有触发变更检测,还是会提示请输入数字
。
使用步进
加减时,就可以触发变更,满足必选要求。
如果自己在组件页面写逻辑,会非常麻烦。建议在select组件里面写一下搜索,重载remote可能会更合适。
按照官方菜单示例代码
onControl: (value, maFormObject) => {
const service = maFormObject.getColumnService()
const dataIndexList = ['icon', 'route', 'component', 'redirect', 'sort', 'is_hidden', 'restful']
if ( value === 'B' ) {
dataIndexList.map(name => service.get(name).setAttr('display', false))
return
}
if ( ['I', 'L'].includes(value) ) {
dataIndexList.map(name => service.get(name).setAttr('display', ['icon', 'route', 'sort', 'is_hidden'].includes(name)) )
return
}
dataIndexList.map(name => service.get(name).setAttr('display', true))
},
没有任何问题,但是当我要隐藏的字段类型为children-form类型时,操作隐藏children-form的字段不生效,需要关闭model弹窗再开才生效
配置代码如下
const columns = reactive([
{
title: "付平台", dataIndex: "support_platforms",
formType: "radio", search: true,
dict: {
data(){
return [
{label: "微信", value: 1},
{label: "支付宝", value: 2},
{label: "网银", value: 3},
];
}
},
commonRules: {required: true, message: "请选择支持平台"},
onControl: (value, maFormObject) => {
const service = maFormObject.getColumnService()
const dataIndexList = ['mch_id', 'mch_secret_key', 'mch_secret_cert', 'mch_public_cert_path', 'wechat_public_cert_path']
if ( value === 1 ) {
dataIndexList.map(name => service.get(name).setAttr('display', false))
}
},
},
{
title: "支付配置", dataIndex: "config_data",
formType: "children-form", hide: true,
hideDelete:true, hideAdd:true, required: true,
type: 'group',
formList:[
{dataIndex: "mch_id",title:"商户号", required: true,labelWidth:'130px'},
{dataIndex: "mch_secret_key",title:"商户秘钥", required: true,labelWidth:'130px'},
{dataIndex: "mch_secret_cert",title:"商户私钥证书", required: true,labelWidth:'130px'},
{dataIndex: "mch_public_cert_path",title:"商户公钥证书", required: true,labelWidth:'130px'},
{dataIndex: "wechat_public_cert_path",title:"微信公钥证书", required: true,labelWidth:'130px'},
]
}
])
a-table可以支持body-cell-class,希望crud能加上,有些业务需要定制单元格样式
select回显
export const handlerProps = (allowType, item, tmpArr) => {
let data = []
let tran = {} // 应该是翻译吧
let colors = {} // 这个不清楚
if (allowType.includes(item.formType)) {
data = tmpArr.map(dicItem => {
const label = get(dicItem, (item.dict.props && item.dict.props.label) || 'label')
let tmp = get(dicItem, (item.dict.props && item.dict.props.value) || 'value' )
let value = tmp + '' // 这里吧tmp强制转成了字符串
...
比如编辑用户的时候,角色回显,不正确,因为没匹配上吗
是否考虑
title: '角色', dataIndex: 'role_ids', width: 120, span: 12, formType: 'select', multiple: true,
dict: { url: 'system/role/list', props: { label: 'name', value: 'id' }, valueType: Number, }, hide: true,
rules: [{ required: true, message: '角色必选' }],
editDefaultValue: async (record) => {
const response = await user.read(record.id)
const ids = response.data.roleList.map(item => item.id )
return ids
}
对dict增加 valueType: Number 限定, 类型
export const handlerProps = (allowType, item, tmpArr) => {
let data = []
let tran = {}
let colors = {}
if (allowType.includes(item.formType)) {
data = tmpArr.map(dicItem => {
const label = get(dicItem, (item.dict.props && item.dict.props.label) || 'label')
let tmp = get(dicItem, (item.dict.props && item.dict.props.value) || 'value' )
let value = tmp + ''
if (item.dict.valueType === Number) { // 这里增加判断,如果是数字转回数字
value = Number(value)
}
....
新增的时候表单可以修改,关掉,再点修改,所有只读的表单就变成可以修改的了,反过来一样,比如先点编辑,表单是不可修改的,再点新增,表单本来可以填写的地方,都变成了编辑里面只读的
上传组件编辑的时候不显示
请问下 目前项目路由是接口生成的 但如果不使用接口 用本地的js 怎么配置
后端返回的是 时间戳,格式, 显示的时间想格式化。 value-format
{
title: "订单状态",
dataIndex: "order_status",
formType: "select",
search: true,
commonRules: {
required: true,
message: "请输入订单状态"
},
dict: {
name: "order_status",
props: {
label: "title",
value: "key"
},
translation: true
}
}
data
2 : 已支付
怎么在页面打开的时候默认选中指定的值,尝试添加searchDefaultValue
属性(2),但是搜索框出来了填写的数字并非已支付
相同的option在ele旧版上正常运行,现在版本上无法正常显示
<template>
<div class="ma-content-block p-3 mt-3">
<ma-chart height="420px" :option="chartOptions" />
</div>
</template>
<script setup>
import { reactive } from "vue"
const chartOptions = reactive({
height:'320px',
legend: {
selected: {'收益': true}
},
tooltip: {
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'line' // 默认为直线,可选为:'line' | 'shadow'
},
formatter: function (params) {
if (params.componentType == 'series') {
let date = new Date(params.value[0] * 1000);
let tip = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
let i = params.seriesIndex + 1;
return tip + '<br/>' + params.seriesName + ":" + params.value[i];
}
}
},
dataset: [
{
source: [
['时间', '收益'],
[1676476800, '-2.43'],
[1676563200, '-4.35']
]
},
],
xAxis: {
type: "category",
axisLabel: {
formatter: function (val, index) {
let date = new Date(val * 1000);
return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
}
}
},
yAxis: {},
series: [
{type: 'line'},
],
dataZoom: [
{type: 'slider', start: 0, end: 100}
],
grid: {
x: 60, y: 60, x2: 60, y2: 60,
backgroundColor: 'rgba(0,0,0,0)',
borderWidth: 1,
borderColor: '#ccc'
},
})
</script>
字段类型是 date, 提交数据后,希望转换为时间戳 在提交
先感谢开源了这么好用的后台管理框架,易用也好看。不过在使用 crud 组件时,我发现一个尴尬的问题,应该可以使用插槽解决,场景是这样的:
假如表格的搜索表单有个创建时间字段 created_at,我想在搜索的时候使用时间范围搜索,配置如下:
// ...
{
title: "创建日期",
width: 140,
search: true,
formType: "range",
rangeSearch: true,
dataIndex: "created_at",
addDisplay: true,
editDisplay: false,
},
// ...
这个时候我就发现添加表单的创建时间也变成了时间范围选择(实际需求不需要),我目前的做法是给crud组件自定义了一个prop,将自定义的表单列传入form组件实现的,不知道有没有更好的解决方法。
有尝试过自己自定义表单组件,但是感觉有点为了这口醋包了顿饺子的感觉。table 表格和表单字段差异比较大,如果分开设置不同的字段配置,form的组件操作空间是不是会更大些?个人拙见。
已经解决
在使用ma-table时,有时需要使用自定义的增加修改界面,这时就只能关闭原有的增加修改按纽显示,再在扩展slot中增加按纽,有点麻烦,如能直接在功能配置时写action,不调用默认处理就好
const options = reactive({ // 设置列表API接口 api: foo.getList, // 设置新增接口 add: { show: true, // 显示新增按钮 action: ()=>{addRef.value.open()} auth: ['foo:save'] // 需要有新增的权限列表 } })
{
title: "数字",
dataIndex: "n",
formType: "input-number",
search: false, // 如果设置为搜索,则载入页面时,提示 预期外的错误
commonRules: {
required: true,
message: "请输入数字"
}
},
会提示以下信息:
[Vue warn]: Invalid prop: type check failed for prop "modelValue". Expected Number with value 0, got String with value "".
使用用户选择器,
当选择一个用户时,设置单选时,获取到的数据是`[id]',这样的数组。
但实际上往后台传输时,仅需要传输一个数字id值即可。
事实上,我认为,当设置
multiple: false
时,应该直接返回用户对象,如果同时onlyId: true,
时,应该仅返回一个id。
考虑到此类需求,当修改信息时,需要加载显示用户名等其他信息,那么,更合适的处理是,直接返回用户对象(修改时直接加载对应的用户对象)。不论是目前的返回数组的情况,还是返回对象,合理的方案应该是可以做为辅助字段,来修改真实字段。
这时,有两种情况:
1:当选择用户确认选中后,应该可以直接修改真实用户id对应的字段。但我暂时未在项目中发现有类似实现。
2:提交前,在beforeEdit及beforeAdd中,对真实用户id字段进行修改。类似下面的代码:
const beforeEdit = (formData) => {
crudRef.value.crudFormRef.form.account_owner_id = crudRef.value.crudFormRef.form.account_owner_id_helper[0].toString();
return formData;
}
所以请大家提示一下,目前最合理的方案应该是什么 ?还是有哪个地方可以实现这样的需求而我没有发现?
在使用ma-form时,如下代码
<template>
<ma-form ref="formRef" v-model="form" v-model:columns="form_columns">
</ma-form>
</template>
<script setup>
import {ref, reactive, nextTick, onMounted} from 'vue'
const formRef=ref()
const form = ref({
name: 'test',
config: {
mode: 1,
price: 88
}
})
const form_columns = ref([
{
"title": "名称",
"formType": "input",
"dataIndex": "name",
"rules": [{"message": "请输入", "required": true}],
}, {
"rules": [{"message": "请选择动态调参", "required": true}],
"title": "动态调参",
"tooltip": "开启后会根据结果自动调整",
"formType": "switch",
"dataIndex": "config.mode",
"checkedValue": 1,
"uncheckedValue": 0
}, {
"title": "价格",
"tooltip": "价格系数",
"formType": "inputNumber",
"dataIndex": "config.price",
"rules": [{"message": "请输入价格", "required": true}],
}
])
测试,界面后两个config下的字段,没有默认值
在ma-form/index.vue中增加输出日志
watch(
() => props.modelValue,
vl => {
form.value = vl
console.log('set form.value',vl) //增加日志
},
{ immediate: true, deep: true }
)
watch(
() => form.value,
vl => {
interactiveControl(vl, flatteningColumns.value)
console.log('update:modelValue',vl) ////增加日志
emit('update:modelValue', vl)
},
{ deep: true }
)
增加以下代码,界面显示默认值
onMounted(() => {
form.value['config.mode']=1;
form.value['config.price']=88;
})
但如不设置config对象数据,form校验无法通过,
1、希望与a-form表现类似,直接更新子对象数据,校验子数据
2、columns可以动态加载处理
加载图片的路径都是带有 /system/showFile这个 导致没有这个文件 , 而顶部右上方的个人头像加载的是本地127.0.0.1的路径
1、系统的字典,短时间内一般不会变动,可以缓存处理,减少请求
2、ma-table组件,有时要定制显示字段,如是字典字段,不太好获取字典数据
ma-crud 怎么使用 <template #cardExtra-字段名>
可以将crud中的beforeAdd和beforeEdit改为同步操作吗 因为在提交之前可能会在其中进行一些操作 会消耗一些时间 比如说提交的时候进行上传操作 上传完成后改变form的值 但是现在还在上传就执行了上传函数
在代码生成器编辑提交请求后端,返回错误信息后 不关闭表单弹窗是不是好一些呢?
其他地方应该也有这样的情况
您好!
咱现在MineAdmin前端提供了多种风格,都非常友好。但我参考了很多开源前端中后台项目,甚至一些收费项目,都有这么一种布局:
1.一级菜单在顶端,二三级在左侧
2.顶层部门颜色可根据喜好自己设置
现在政府、银行、学校等企事业单位,一般要求顶层有个logo,项目名称,且一级菜单在顶层,二三级在左侧。如果把这种布局实现了,咱们的风格没有任何项目可以跟咱的MinAdmin相媲美了。在群里也有其他朋友支持此种风格。请作者认真考虑,建议实现,多谢!
可参考若依、jeesite,特别是eleadmin: https://plus.eleadmin.com/login
eleadmin风格如下:
我有一个列表页面, 每次切换tabs 再回来, 就会刷新是为什么?
{
title: "pageId",
dataIndex: "extend.pageId",
formType: "input",
search: true,
commonRules: {
required: true,
message: "请输入pageId"
}
}
在新增或者编辑的情况下,弹出输入框立刻往里面粘贴内容,然后提交数据。粘贴内容不会发送出去。
经测试,粘贴后过两秒重新输入一个字符才会触发双向绑定。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.