调整前端代码格式符合ESLint规范

This commit is contained in:
zer0Black
2023-02-28 22:43:03 +08:00
parent f5e5990a3b
commit 77b1ca8f0d
48 changed files with 3199 additions and 3179 deletions
+150 -152
View File
@@ -87,158 +87,158 @@
</template>
<script>
import {fileType} from "@/utils/fileType";
import { fileType } from '@/utils/fileType'
export default {
name: "MenuManager",
data() {
return {
form: {
name: '', // 名称
href: '', // 路径
icon: '', // 图标
iconHref: '', // 图标路径
sort: '', // 排序
remarks: '', // 描述
id: '',
parentId: '',
isUrl: 0,
},
tableData: [],
dialogMenu: false,
mode: '',
pathList: [],
level: 0,
}
},
methods: {
init() {
this.sysMenuFindAllMenus();
this.getRouterPath();
},
// 菜单
sysMenuFindAllMenus() {
this.$api.menu.sysMenuFindAllMenus().then(({data}) => {
this.tableData = data.filter(item => item.id !== '6f6fafb4a7').sort((a, b) => {
return a.sort - b.sort;
});
})
},
// 新增弹窗
addMenu(row, level) {
this.mode = 'add';
this.level = level + 1;
this.form = {
name: '', // 名称
href: '', // 路径
icon: '', // 图标
iconHref: '', // 图标路径
sort: '', // 排序
remarks: '', // 描述
id: '',
parentId: '',
isUrl: 0,
};
this.form.parentId = row ? row.id : '6f6fafb4a7';
this.dialogMenu = true;
},
// 新增 修改
postOrPutSysMenu() {
if (!this.form.name) {
return this.$message.warning('请输入菜单名称');
}
if (this.level === 0 || this.level === 2) {
// if (!this.form.icon) {
// return this.$message.warning('请上传菜单图标');
// }
}
if (this.mode === 'add') {
this.$api.menu.postSysMenu(this.form).then(_ => {
this.$message.success('操作成功');
this.dialogMenu = false;
this.sysMenuFindAllMenus();
})
}
if (this.mode === 'modify') {
this.$api.menu.putSysMenu(this.form).then(_ => {
this.$message.success('操作成功');
this.dialogMenu = false;
this.sysMenuFindAllMenus();
})
}
},
// 图标上传
uploadFile(params) {
let fd = new FormData();
fd.append('file', params.file);
this.$api.report.reportUploadPicFile(fd).then(({data}) => {
this.form.icon = data.key;
this.form.iconHref = data.value;
})
},
beforeUploadFile(file) {
const isType = (file.type === fileType.png || file.type === fileType.jpg);
const isSize = file.size / 1024 / 1024 < 2;
if (!isType) {
this.$message.error('仅能上传 pngjpg 格式文件');
}
if (!isSize) {
this.$message.error('您最大可上传2M文件');
}
return isType && isSize;
},
// 删除
deleteRow(row) {
this.$confirm('此操作将删除所选数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$api.menu.sysMenuDeleteId({ids: row.id}).then(_ => {
this.$message.success('操作成功');
this.sysMenuFindAllMenus();
})
})
},
// 编辑
modifyRow(row, level) {
this.level = level;
this.mode = 'modify';
this.form = JSON.parse(JSON.stringify(row));
this.dialogMenu = true;
},
// 获取存在路径
getRouterPath() {
let pathList = [];
let pathFun = (data, url) => {
data.forEach(item => {
if (item.children) {
pathFun(item.children, item.path);
} else {
pathList.push(`${url ? (url + '/') : ''}${item.path}`);
}
})
}
pathFun(this.$router.options.routes);
this.pathList = pathList;
},
},
computed: {
dialogTitle() {
switch (this.mode) {
case 'add':
return '新增';
case 'modify':
return '编辑';
case 'view':
return '查看';
}
}
},
created() {
this.init();
}
export default {
name: 'MenuManager',
data () {
return {
form: {
name: '', // 名称
href: '', // 路径
icon: '', // 图标
iconHref: '', // 图标路径
sort: '', // 排序
remarks: '', // 描述
id: '',
parentId: '',
isUrl: 0
},
tableData: [],
dialogMenu: false,
mode: '',
pathList: [],
level: 0
}
},
methods: {
init () {
this.sysMenuFindAllMenus()
this.getRouterPath()
},
// 菜单
sysMenuFindAllMenus () {
this.$api.menu.sysMenuFindAllMenus().then(({ data }) => {
this.tableData = data.filter(item => item.id !== '6f6fafb4a7').sort((a, b) => {
return a.sort - b.sort
})
})
},
// 新增弹窗
addMenu (row, level) {
this.mode = 'add'
this.level = level + 1
this.form = {
name: '', // 名称
href: '', // 路径
icon: '', // 图标
iconHref: '', // 图标路径
sort: '', // 排序
remarks: '', // 描述
id: '',
parentId: '',
isUrl: 0
}
this.form.parentId = row ? row.id : '6f6fafb4a7'
this.dialogMenu = true
},
// 新增 修改
postOrPutSysMenu () {
if (!this.form.name) {
return this.$message.warning('请输入菜单名称')
}
if (this.level === 0 || this.level === 2) {
// if (!this.form.icon) {
// return this.$message.warning('请上传菜单图标');
// }
}
if (this.mode === 'add') {
this.$api.menu.postSysMenu(this.form).then(_ => {
this.$message.success('操作成功')
this.dialogMenu = false
this.sysMenuFindAllMenus()
})
}
if (this.mode === 'modify') {
this.$api.menu.putSysMenu(this.form).then(_ => {
this.$message.success('操作成功')
this.dialogMenu = false
this.sysMenuFindAllMenus()
})
}
},
// 图标上传
uploadFile (params) {
const fd = new FormData()
fd.append('file', params.file)
this.$api.report.reportUploadPicFile(fd).then(({ data }) => {
this.form.icon = data.key
this.form.iconHref = data.value
})
},
beforeUploadFile (file) {
const isType = (file.type === fileType.png || file.type === fileType.jpg)
const isSize = file.size / 1024 / 1024 < 2
if (!isType) {
this.$message.error('仅能上传 pngjpg 格式文件')
}
if (!isSize) {
this.$message.error('您最大可上传2M文件')
}
return isType && isSize
},
// 删除
deleteRow (row) {
this.$confirm('此操作将删除所选数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$api.menu.sysMenuDeleteId({ ids: row.id }).then(_ => {
this.$message.success('操作成功')
this.sysMenuFindAllMenus()
})
})
},
// 编辑
modifyRow (row, level) {
this.level = level
this.mode = 'modify'
this.form = JSON.parse(JSON.stringify(row))
this.dialogMenu = true
},
// 获取存在路径
getRouterPath () {
const pathList = []
const pathFun = (data, url) => {
data.forEach(item => {
if (item.children) {
pathFun(item.children, item.path)
} else {
pathList.push(`${url ? (url + '/') : ''}${item.path}`)
}
})
}
pathFun(this.$router.options.routes)
this.pathList = pathList
}
},
computed: {
dialogTitle () {
switch (this.mode) {
case 'add':
return '新增'
case 'modify':
return '编辑'
case 'view':
return '查看'
}
}
},
created () {
this.init()
}
}
</script>
<style lang="scss" scoped>
@@ -324,7 +324,6 @@
// margin-left: -1.5px;
// }
.menu-image {
display: flex;
align-items: center;
@@ -434,7 +433,6 @@
}
}
.icon-menu-text {
display: flex;
width: 36px;