refactor: ♻️ 基础框架的实体更新逻辑 (#137)

Co-authored-by: tk <fiyne1a@dingtalk.com>
This commit is contained in:
2024-06-07 00:13:14 +08:00
committed by GitHub
parent f5bd69ef60
commit 56b111b1cf
192 changed files with 3011 additions and 1426 deletions

View File

@ -49,6 +49,17 @@ export default {
},
},
/**
* 编辑配置
*/
edit: {
url: `${config.API_URL}/api/sys/config/edit`,
name: `编辑配置`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
/**
* 获取单个配置
*/
@ -92,15 +103,4 @@ export default {
return await http.post(this.url, data, config)
},
},
/**
* 更新配置
*/
update: {
url: `${config.API_URL}/api/sys/config/update`,
name: `更新配置`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
}

View File

@ -49,6 +49,17 @@ export default {
},
},
/**
* 编辑部门
*/
edit: {
url: `${config.API_URL}/api/sys/dept/edit`,
name: `编辑部门`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
/**
* 获取单个部门
*/
@ -70,15 +81,4 @@ export default {
return await http.post(this.url, data, config)
},
},
/**
* 更新部门
*/
update: {
url: `${config.API_URL}/api/sys/dept/update`,
name: `更新部门`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
}

View File

@ -71,6 +71,28 @@ export default {
},
},
/**
* 编辑字典目录
*/
editCatalog: {
url: `${config.API_URL}/api/sys/dic/edit.catalog`,
name: `编辑字典目录`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
/**
* 编辑字典内容
*/
editContent: {
url: `${config.API_URL}/api/sys/dic/edit.content`,
name: `编辑字典内容`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
/**
* 获取单个字典目录
*/
@ -147,26 +169,4 @@ export default {
return await http.post(this.url, data, config)
},
},
/**
* 更新字典目录
*/
updateCatalog: {
url: `${config.API_URL}/api/sys/dic/update.catalog`,
name: `更新字典目录`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
/**
* 更新字典内容
*/
updateContent: {
url: `${config.API_URL}/api/sys/dic/update.content`,
name: `更新字典内容`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
}

View File

@ -49,6 +49,17 @@ export default {
},
},
/**
* 编辑菜单
*/
edit: {
url: `${config.API_URL}/api/sys/menu/edit`,
name: `编辑菜单`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
/**
* 获取单个菜单
*/
@ -71,17 +82,6 @@ export default {
},
},
/**
* 更新菜单
*/
update: {
url: `${config.API_URL}/api/sys/menu/update`,
name: `更新菜单`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
/**
* 当前用户菜单
*/

View File

@ -49,6 +49,17 @@ export default {
},
},
/**
* 编辑角色
*/
edit: {
url: `${config.API_URL}/api/sys/role/edit`,
name: `编辑角色`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
/**
* 获取单个角色
*/
@ -81,15 +92,4 @@ export default {
return await http.post(this.url, data, config)
},
},
/**
* 更新角色
*/
update: {
url: `${config.API_URL}/api/sys/role/update`,
name: `更新角色`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
}

View File

@ -49,6 +49,17 @@ export default {
},
},
/**
* 编辑站内信
*/
edit: {
url: `${config.API_URL}/api/sys/site.msg/edit`,
name: `编辑站内信`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
/**
* 站内信是否存在
*/
@ -136,15 +147,4 @@ export default {
return await http.post(this.url, data, config)
},
},
/**
* 更新站内信
*/
update: {
url: `${config.API_URL}/api/sys/site.msg/update`,
name: `更新站内信`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
}

View File

@ -6,11 +6,11 @@ import config from '@/config'
import http from '@/utils/request'
export default {
/**
* 检查手机号是否可用
* 检查手机号是否可用
*/
checkMobileAvailable: {
url: `${config.API_URL}/api/sys/user/check.mobile.available`,
name: `检查手机号是否可用`,
name: `检查手机号是否可用`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
@ -60,6 +60,17 @@ export default {
},
},
/**
* 编辑用户
*/
edit: {
url: `${config.API_URL}/api/sys/user/edit`,
name: `编辑用户`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
/**
* 获取单个用户
*/
@ -149,11 +160,11 @@ export default {
},
/**
* 更新用户头像
* 设置用户头像
*/
setAvatar: {
url: `${config.API_URL}/api/sys/user/set.avatar`,
name: `更新用户头像`,
name: `设置用户头像`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
@ -182,11 +193,11 @@ export default {
},
/**
* 设置手机号
* 设置手机号
*/
setMobile: {
url: `${config.API_URL}/api/sys/user/set.mobile`,
name: `设置手机号`,
name: `设置手机号`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
@ -203,17 +214,6 @@ export default {
},
},
/**
* 更新用户
*/
update: {
url: `${config.API_URL}/api/sys/user/update`,
name: `更新用户`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
/**
* 当前用户信息
*/

View File

@ -92,15 +92,4 @@ export default {
return await http.post(this.url, data, config)
},
},
/**
* 更新示例
*/
update: {
url: `${config.API_URL}/api/tpl/example/update`,
name: `更新示例`,
post: async function (data = {}, config = {}) {
return await http.post(this.url, data, config)
},
},
}

View File

@ -34,6 +34,7 @@ import scFormTable from '@/components/scFormTable'
import scPageHeader from '@/components/scPageHeader'
import scSelect from '@/components/scSelect'
import scSelectFilter from '@/components/scSelectFilter'
import scStatistic from '@/components/scStatistic/index.vue'
import scStatusIndicator from '@/components/scMini/scStatusIndicator'
import scTable from '@/components/scTable'
import scTableColumn from '@/components/scTable/column.js'
@ -112,6 +113,7 @@ export default {
app.component('scPageHeader', scPageHeader)
app.component('scSelect', scSelect)
app.component('scSelectFilter', scSelectFilter)
app.component('scStatistic', scStatistic)
app.component('scStatusIndicator', scStatusIndicator)
app.component('scTable', scTable)
app.component('scTableColumn', scTableColumn)

View File

@ -3,7 +3,6 @@ import { ElNotification } from 'element-plus'
import config from '@/config'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import tool from '@/utils/tool'
import systemRouter from './systemRouter'
import userRoutes from '@/config/route'
import { afterEach, beforeEach } from './scrollBehavior'

View File

@ -6,12 +6,12 @@
<na-form-phone
v-model="form.verifySmsCodeReq"
:code-field="['verifySmsCodeReq.code', 'code']"
:code-label="$t('手机验证码')"
:phone-field="['verifySmsCodeReq.destDevice', 'destDevice']"
:phone-label="$t('手机号码')"
:phone-place-holder="$GLOBAL.user.mobile"
:vue="this"
code-label="$t('手机验证码')"
form-name="form"
phone-label="$t('手机号码')" />
form-name="form" />
</el-col>
<el-col :lg="10">
<na-form-email

View File

@ -143,7 +143,7 @@ export default {
//表格内开关事件
async changeSwitch(event, row) {
try {
await this.$API.sys_config.update.post(row)
await this.$API.sys_config.edit.post(row)
this.$message.success(`操作成功`)
} catch {
//

View File

@ -98,7 +98,7 @@ export default {
this.loading = true
try {
const method = this.mode === 'add' ? this.$API.sys_config.create : this.$API.sys_config.update
const method = this.mode === 'add' ? this.$API.sys_config.create : this.$API.sys_config.edit
const res = await method.post(this.form)
this.$emit('success', res.data, this.mode)
this.visible = false

View File

@ -108,7 +108,7 @@ export default {
if (valid) {
this.loading = true
try {
const method = this.mode === 'add' ? this.$API.sys_dept.create : this.$API.sys_dept.update
const method = this.mode === 'add' ? this.$API.sys_dept.create : this.$API.sys_dept.edit
const res = await method.post(this.form)
this.$emit('success', res.data, this.mode)
this.visible = false

View File

@ -77,7 +77,7 @@ export default {
this.loading = true
try {
const method = this.mode === 'add' ? this.$API.sys_dic.createContent : this.$API.sys_dic.updateContent
const method = this.mode === 'add' ? this.$API.sys_dic.createContent : this.$API.sys_dic.editContent
const res = await method.post(this.form)
this.$emit('success', res.data, this.mode)
this.visible = false

View File

@ -60,7 +60,7 @@ export default {
this.loading = true
try {
const method = this.mode === 'add' ? this.$API.sys_dic.createCatalog : this.$API.sys_dic.updateCatalog
const method = this.mode === 'add' ? this.$API.sys_dic.createCatalog : this.$API.sys_dic.editCatalog
const res = await method.post(this.form)
this.$emit('success', res.data, this.mode)
this.visible = false

View File

@ -219,9 +219,13 @@ export default {
Object.assign({}, this.form, { userId: this.form.user.id, requestHeaders: JSON.parse(this.form.requestHeader) }),
)
this.loading = false
this.$emit('success', res.data, this.mode)
if (res.data) {
this.$emit('success', res.data, this.mode)
this.$message.success('操作成功')
} else {
this.$message.error('操作失败')
}
this.visible = false
this.$message.success('操作成功')
} catch {
//
this.loading = false

View File

@ -139,7 +139,7 @@ export default {
this.loading = true
try {
const res = await this.$API.sys_menu.update.post(this.form)
const res = await this.$API.sys_menu.edit.post(this.form)
this.$message.success('保存成功')
this.$emit('success', res.data)
} catch {

View File

@ -142,7 +142,7 @@ export default {
}
try {
const method = this.mode === 'add' ? this.$API.sys_sitemsg.create : this.$API.sys_sitemsg.update
const method = this.mode === 'add' ? this.$API.sys_sitemsg.create : this.$API.sys_sitemsg.edit
this.loading = true
const res = await method.post(Object.assign({}, this.form, { userIds: this.form.userIds.map((x) => x.id) }))
this.loading = false

View File

@ -161,7 +161,7 @@ export default {
}
this.loading = true
const method = this.mode === 'add' ? this.$API.sys_role.create : this.$API.sys_role.update
const method = this.mode === 'add' ? this.$API.sys_role.create : this.$API.sys_role.edit
const postData = Object.assign({}, this.form, {
deptIds: this.$refs.dept.getCheckedKeys().concat(this.$refs.dept.getHalfCheckedKeys()),
menuIds: this.$refs.menu.getCheckedKeys().concat(this.$refs.menu.getHalfCheckedKeys()),

View File

@ -337,7 +337,7 @@ export default {
}
try {
const method = this.mode === 'add' ? this.$API.sys_user.create : this.$API.sys_user.update
const method = this.mode === 'add' ? this.$API.sys_user.create : this.$API.sys_user.edit
this.loading = true
const res = await method.post(Object.assign({}, this.form))
this.loading = false