fix: bug修复

develop
JINGYJ 2 years ago
parent 6688672ea0
commit 3c4bc455f7

@ -1,5 +1,5 @@
{
"name": "tp-admin",
"name": "xznsh-admin",
"version": "2.0.0",
"private": true,
"scripts": {

@ -37,7 +37,7 @@ export type RefreshTokenResult = {
// return http.request<UserResult>("post", "/login", { data });
// };
export const getLogin = (data?: object) => {
return http.request<UserResult>("post", baseUrlApi("organization/login"), {
return http.request<UserResult>("post", baseUrlApi("organization/login/"), {
data
});
};

@ -8,7 +8,7 @@ import { FormProps } from "./utils/types";
const props = withDefaults(defineProps<FormProps>(), {
formInline: () => ({
higherDeptOptions: [],
parentId: 0,
parent_id: "",
name: "",
principal: "",
phone: "",
@ -16,7 +16,8 @@ const props = withDefaults(defineProps<FormProps>(), {
sort: 0,
status: 1,
remark: "",
id: ""
id: "",
is_active: true
})
});
@ -43,7 +44,7 @@ defineExpose({ getRef });
<el-form-item label="上级部门">
<el-cascader
class="w-full"
v-model="newFormInline.parentId"
v-model="newFormInline.parent_id"
:options="newFormInline.higherDeptOptions"
:props="{
value: 'id',
@ -111,22 +112,22 @@ defineExpose({ getRef });
controls-position="right"
/>
</el-form-item>
</re-col>
<re-col :value="12" :xs="24" :sm="24">
</re-col> -->
<!-- <re-col :value="12" :xs="24" :sm="24">
<el-form-item label="部门状态">
<el-switch
v-model="newFormInline.status"
v-model="newFormInline.is_active"
inline-prompt
:active-value="1"
:inactive-value="0"
:active-value="true"
:inactive-value="false"
active-text="启用"
inactive-text="停用"
:style="switchStyle"
/>
</el-form-item>
</re-col>
</re-col> -->
<re-col>
<!-- <re-col>
<el-form-item label="备注">
<el-input
v-model="newFormInline.remark"

@ -47,17 +47,17 @@ console.log(dataList);
class="!w-[200px]"
/>
</el-form-item>
<el-form-item label="状态:" prop="status">
<!-- <el-form-item label="状态:" prop="is_active">
<el-select
v-model="form.status"
v-model="form.is_active"
placeholder="请选择状态"
clearable
class="!w-[180px]"
>
<el-option label="启用" :value="1" />
<el-option label="停用" :value="0" />
<el-option label="启用" :value="true" />
<el-option label="停用" :value="false" />
</el-select>
</el-form-item>
</el-form-item> -->
<el-form-item>
<el-button
type="primary"

@ -3,7 +3,7 @@ import editForm from "../form.vue";
// import { handleTree } from "@/utils/tree";
import { message } from "@/utils/message";
import { getDeptList, addDept, updateDept, deleteDept } from "@/api/system";
import { usePublicHooks } from "../../hooks";
// import { usePublicHooks } from "../../hooks";
import { addDialog } from "@/components/ReDialog";
import { reactive, ref, onMounted, h } from "vue";
import { type FormItemProps } from "../utils/types";
@ -12,13 +12,13 @@ import { cloneDeep, isAllEmpty } from "@pureadmin/utils";
export function useDept() {
const form = reactive({
name: "",
status: null
is_active: null
});
const formRef = ref();
const dataList = ref([]);
const loading = ref(true);
const { tagStyle } = usePublicHooks();
// const { tagStyle } = usePublicHooks();
const columns: TableColumnList = [
{
@ -32,28 +32,28 @@ export function useDept() {
// prop: "sort",
// minWidth: 70
// },
{
label: "状态",
prop: "status",
minWidth: 100,
cellRenderer: ({ row, props }) => (
<el-tag size={props.size} style={tagStyle.value(row.status)}>
{row.status === 1 ? "启用" : "停用"}
</el-tag>
)
},
// {
// label: "状态",
// prop: "is_active",
// minWidth: 100,
// cellRenderer: ({ row, props }) => (
// <el-tag size={props.size} style={tagStyle.value(row.is_active ? 1 : 0)}>
// {row.is_active ? "启用" : "停用"}
// </el-tag>
// )
// },
{
label: "创建时间",
minWidth: 200,
prop: "createTime",
formatter: ({ createTime }) =>
dayjs(createTime).format("YYYY-MM-DD HH:mm:ss")
},
{
label: "备注",
prop: "remark",
minWidth: 320
prop: "insert_time",
formatter: ({ insert_time }) =>
dayjs(insert_time).format("YYYY-MM-DD HH:mm:ss")
},
// {
// label: "备注",
// prop: "remark",
// minWidth: 320
// },
{
label: "操作",
fixed: "right",
@ -103,11 +103,15 @@ export function useDept() {
// newData = newData.filter(item => item.name.includes(form.name));
newData = filterNested(newData, item => item.name.includes(form.name));
}
if (!isAllEmpty(form.status)) {
// 前端搜索状态
// newData = newData.filter(item => item.status === form.status);
newData = filterNested(newData, item => item.status === form.status);
}
// if (!isAllEmpty(form.is_active)) {
// // 前端搜索状态
// // newData = newData.filter(item => item.status === form.status);
// // newData = filterNested(
// // newData,
// // item => item.is_active === form.is_active
// // );
// newData = newData.filter(item => item.is_active === form.is_active);
// }
// dataList.value = handleTree(newData); // 处理成树结构
dataList.value = newData; // 处理成树结构
setTimeout(() => {
@ -133,7 +137,7 @@ export function useDept() {
props: {
formInline: {
higherDeptOptions: formatHigherDeptOptions(cloneDeep(dataList.value)),
parentId: row?.id ?? "",
parent_id: row?.parent_id ?? "",
name: row?.name ?? "",
principal: row?.principal ?? "",
phone: row?.phone ?? "",
@ -141,7 +145,8 @@ export function useDept() {
sort: row?.sort ?? 0,
status: row?.status ?? 1,
remark: row?.remark ?? "",
id: row?.id ?? ""
id: row?.id ?? "",
is_active: row?.is_active ?? true
}
},
width: "40%",
@ -160,8 +165,9 @@ export function useDept() {
onSearch(); // 刷新表格数据
}
FormRef.validate(valid => {
console.log("curData", curData);
if (valid) {
console.log("curData", curData);
// 表单规则校验通过
if (title === "新增") {
// 实际开发先调用新增接口,再进行下面操作
@ -183,7 +189,8 @@ export function useDept() {
// deptList.data.push(addItem);
const params = {
department_name: curData.name,
department_id: curData.parentId
department_id: curData.parent_id,
is_active: curData.is_active
};
addDept(params).then(res => {
@ -198,7 +205,9 @@ export function useDept() {
} else {
const params = {
name: curData.name,
id: curData.id
id: curData.id,
department_id: curData.parent_id ? curData.parent_id : null,
is_active: curData.is_active
};
updateDept(params)
.then(res => {

@ -1,6 +1,6 @@
interface FormItemProps {
higherDeptOptions: Record<string, unknown>[];
parentId: number;
parent_id: string | number;
name: string;
principal: string;
phone: string | number;
@ -9,6 +9,7 @@ interface FormItemProps {
status: number;
remark: string;
id: string | number;
is_active: boolean;
}
interface FormProps {
formInline: FormItemProps;

@ -47,7 +47,7 @@ defineExpose({ getRef });
emitPath: false,
checkStrictly: true,
disabled: function (data) {
if (!data.parent_id) {
if (!data.is_active) {
return true;
} else {
return false;
@ -99,7 +99,6 @@ defineExpose({ getRef });
<re-col :value="12" :xs="24" :sm="24">
<el-form-item label="性别" prop="gender">
<el-select v-model="newFormInline.gender" placeholder="请选择">
<el-option label="未知" :value="2" />
<el-option label="男" :value="1" />
<el-option label="女" :value="0" />
</el-select>

@ -134,7 +134,7 @@ export function useUser() {
function onChange({ row, index }) {
ElMessageBox.confirm(
`确认要<strong>${
row.status === 0 ? "停用" : "启用"
row.is_active === false ? "停用" : "启用"
}</strong><strong style='color:var(--el-color-primary)'>${
row.username
}</strong>?`,
@ -148,28 +148,42 @@ export function useUser() {
}
)
.then(() => {
switchLoadMap.value[index] = Object.assign(
{},
switchLoadMap.value[index],
{
loading: true
const params = {
department_id: row.department_id,
username: row.username,
phone_number: row.phone_number,
is_active: row.is_active,
gender: row.gender,
id: row.id
};
updateUser(params).then(res => {
if (res.success) {
setTimeout(() => {
switchLoadMap.value[index] = Object.assign(
{},
switchLoadMap.value[index],
{
loading: false
}
);
message("已成功修改用户状态", {
type: "success"
});
}, 300);
} else {
row.is_active === false
? (row.is_active = true)
: (row.is_active = false);
message(`${res.msg}`, {
type: "warning"
});
}
);
setTimeout(() => {
switchLoadMap.value[index] = Object.assign(
{},
switchLoadMap.value[index],
{
loading: false
}
);
message("已成功修改用户状态", {
type: "success"
});
}, 300);
});
})
.catch(() => {
row.status === 0 ? (row.status = 1) : (row.status = 0);
row.is_active === false
? (row.is_active = true)
: (row.is_active = false);
});
}

Loading…
Cancel
Save