fix: 状态码使用常量避免后续变更
This commit is contained in:
@@ -11,6 +11,7 @@ import { authUserAllocatedList, authUserChecked } from '@/api/system/role';
|
||||
import { parseDateToStr } from '@/utils/date-utils';
|
||||
import useTabsStore from '@/store/modules/tabs';
|
||||
import useDictStore from '@/store/modules/dict';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
const tabsStore = useTabsStore();
|
||||
const { getDict } = useDictStore();
|
||||
const route = useRoute();
|
||||
@@ -169,7 +170,7 @@ function fnTableSize({ key }: MenuInfo) {
|
||||
}
|
||||
|
||||
/**表格斑马纹 */
|
||||
function fnTableStriped(_record: unknown, index: number) {
|
||||
function fnTableStriped(_record: unknown, index: number):any {
|
||||
return tableState.striped && index % 2 === 1 ? 'table-striped' : undefined;
|
||||
}
|
||||
|
||||
@@ -215,7 +216,7 @@ function fnModalOk(userIds: string[] | number[]) {
|
||||
roleId: roleId,
|
||||
}).then(res => {
|
||||
hide();
|
||||
if (res.code === 1) {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
modalState.visibleBySelectUser = false;
|
||||
message.success({
|
||||
content: `授权用户添加成功`,
|
||||
@@ -247,7 +248,7 @@ function fnRecordDelete(userId: string | number) {
|
||||
authUserChecked({ checked: false, userIds: userId, roleId: roleId }).then(
|
||||
res => {
|
||||
hide();
|
||||
if (res.code === 1) {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success({
|
||||
content: `取消授权成功`,
|
||||
duration: 3,
|
||||
@@ -280,7 +281,7 @@ function fnGetList() {
|
||||
if (tableState.loading) return;
|
||||
tableState.loading = true;
|
||||
authUserAllocatedList(toRaw(queryParams)).then(res => {
|
||||
if (res.code === 1 && Array.isArray(res.rows)) {
|
||||
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) {
|
||||
// 取消勾选
|
||||
if (tableState.selectedRowKeys.length > 0) {
|
||||
tableState.selectedRowKeys = [];
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ColumnsType } from 'ant-design-vue/lib/table';
|
||||
import { authUserAllocatedList } from '@/api/system/role';
|
||||
import { parseDateToStr } from '@/utils/date-utils';
|
||||
import useDictStore from '@/store/modules/dict';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
const { getDict } = useDictStore();
|
||||
const emit = defineEmits(['ok', 'cancel', 'update:visible']);
|
||||
const props = defineProps({
|
||||
@@ -150,7 +151,7 @@ function fnGetList() {
|
||||
if (tableState.loading) return;
|
||||
tableState.loading = true;
|
||||
authUserAllocatedList(toRaw(queryParams)).then(res => {
|
||||
if (res.code === 1 && Array.isArray(res.rows)) {
|
||||
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) {
|
||||
// 取消勾选
|
||||
if (tableState.selectedRowKeys.length > 0) {
|
||||
tableState.selectedRowKeys = [];
|
||||
|
||||
@@ -25,6 +25,7 @@ import { DataNode } from 'ant-design-vue/lib/tree';
|
||||
import { parseTreeKeys, parseTreeNodeKeys } from '@/utils/parse-tree-utils';
|
||||
import { hasPermissions } from '@/plugins/auth-user';
|
||||
import { MENU_PATH_INLINE } from '@/constants/menu-constants';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
const { getDict } = useDictStore();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
@@ -182,7 +183,7 @@ function fnTableSize({ key }: MenuInfo) {
|
||||
}
|
||||
|
||||
/**表格斑马纹 */
|
||||
function fnTableStriped(_record: unknown, index: number) {
|
||||
function fnTableStriped(_record: unknown, index: number):any {
|
||||
return tableState.striped && index % 2 === 1 ? 'table-striped' : undefined;
|
||||
}
|
||||
|
||||
@@ -305,9 +306,9 @@ function fnModalVisibleByVive(roleId: string | number) {
|
||||
Promise.all([getRole(roleId), roleMenuTreeSelect(roleId)]).then(resArr => {
|
||||
modalState.confirmLoading = false;
|
||||
hide();
|
||||
if (resArr[0].code === 1 && resArr[0].data) {
|
||||
if (resArr[0].code === RESULT_CODE_SUCCESS && resArr[0].data) {
|
||||
modalState.from = Object.assign(modalState.from, resArr[0].data);
|
||||
if (resArr[1].code === 1 && resArr[1].data) {
|
||||
if (resArr[1].code === RESULT_CODE_SUCCESS && resArr[1].data) {
|
||||
const { menus, checkedKeys } = resArr[1].data;
|
||||
menuTree.checkedKeys = parseTreeKeys(menus, 'id');
|
||||
menuTree.expandedKeys = parseTreeNodeKeys(menus, 'id');
|
||||
@@ -343,7 +344,7 @@ function fnModalVisibleByEdit(roleId?: string | number) {
|
||||
menuTreeSelect().then(res => {
|
||||
modalState.confirmLoading = false;
|
||||
hide();
|
||||
if (res.code === 1 && Array.isArray(res.data)) {
|
||||
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
|
||||
menuTree.checkedKeys = parseTreeKeys(res.data, 'id');
|
||||
menuTree.expandedKeys = parseTreeNodeKeys(res.data, 'id');
|
||||
menuTree.treeData = res.data;
|
||||
@@ -361,9 +362,9 @@ function fnModalVisibleByEdit(roleId?: string | number) {
|
||||
Promise.all([getRole(roleId), roleMenuTreeSelect(roleId)]).then(resArr => {
|
||||
modalState.confirmLoading = false;
|
||||
hide();
|
||||
if (resArr[0].code === 1 && resArr[0].data) {
|
||||
if (resArr[0].code === RESULT_CODE_SUCCESS && resArr[0].data) {
|
||||
modalState.from = Object.assign(modalState.from, resArr[0].data);
|
||||
if (resArr[1].code === 1 && resArr[1].data) {
|
||||
if (resArr[1].code === RESULT_CODE_SUCCESS && resArr[1].data) {
|
||||
const { menus, checkedKeys } = resArr[1].data;
|
||||
menuTree.checkedKeys = parseTreeKeys(menus, 'id');
|
||||
menuTree.expandedKeys = parseTreeNodeKeys(menus, 'id');
|
||||
@@ -396,7 +397,7 @@ function fnModalOk() {
|
||||
message.loading({ content: '请稍等...', key });
|
||||
role
|
||||
.then(res => {
|
||||
if (res.code === 1) {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success({
|
||||
content: `${modalState.title}成功`,
|
||||
key,
|
||||
@@ -507,7 +508,7 @@ function fnModalOkDataScope() {
|
||||
}
|
||||
dataScope(fromInfo)
|
||||
.then(res => {
|
||||
if (res.code === 1) {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success({
|
||||
content: `${modalState.title}成功`,
|
||||
duration: 2,
|
||||
@@ -542,9 +543,9 @@ function fnRecordDataScope(roleId: string | number) {
|
||||
// 查询角色详细同时根据角色ID查询部门树结构
|
||||
Promise.all([getRole(roleId), roleDeptTreeSelect(roleId)])
|
||||
.then(resArr => {
|
||||
if (resArr[0].code === 1 && resArr[0].data) {
|
||||
if (resArr[0].code === RESULT_CODE_SUCCESS && resArr[0].data) {
|
||||
modalState.from = Object.assign(modalState.from, resArr[0].data);
|
||||
if (resArr[1].code === 1 && resArr[1].data) {
|
||||
if (resArr[1].code === RESULT_CODE_SUCCESS && resArr[1].data) {
|
||||
const { depts, checkedKeys } = resArr[1].data;
|
||||
deptTree.checkedKeys = parseTreeKeys(depts, 'id');
|
||||
deptTree.expandedKeys = parseTreeNodeKeys(depts, 'id');
|
||||
@@ -591,7 +592,7 @@ function fnRecordStatus(row: Record<string, string>) {
|
||||
const hide = message.loading('请稍等...', 0);
|
||||
changeRoleStatus(row.roleId, row.status).then(res => {
|
||||
hide();
|
||||
if (res.code === 1) {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success({
|
||||
content: `${row.roleName} ${text}成功`,
|
||||
duration: 2,
|
||||
@@ -626,7 +627,7 @@ function fnRecordDelete(roleId: string = '0') {
|
||||
const hide = message.loading('请稍等...', 0);
|
||||
delRole(roleId).then(res => {
|
||||
hide();
|
||||
if (res.code === 1) {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success({
|
||||
content: `删除成功`,
|
||||
duration: 2,
|
||||
@@ -651,7 +652,7 @@ function fnExportList() {
|
||||
onOk() {
|
||||
const hide = message.loading('请稍等...', 0);
|
||||
exportRole(toRaw(queryParams)).then(res => {
|
||||
if (res.code === 1) {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success({
|
||||
content: `已完成导出`,
|
||||
duration: 2,
|
||||
@@ -675,7 +676,7 @@ function fnGetList() {
|
||||
queryParams.beginTime = queryRangePicker.value[0];
|
||||
queryParams.endTime = queryRangePicker.value[1];
|
||||
listRole(toRaw(queryParams)).then(res => {
|
||||
if (res.code === 1 && Array.isArray(res.rows)) {
|
||||
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) {
|
||||
// 取消勾选
|
||||
if (tableState.selectedRowKeys.length > 0) {
|
||||
tableState.selectedRowKeys = [];
|
||||
|
||||
Reference in New Issue
Block a user