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", "version": "2.0.0",
"private": true, "private": true,
"scripts": { "scripts": {

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

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

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

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

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

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

@ -134,7 +134,7 @@ export function useUser() {
function onChange({ row, index }) { function onChange({ row, index }) {
ElMessageBox.confirm( ElMessageBox.confirm(
`确认要<strong>${ `确认要<strong>${
row.status === 0 ? "停用" : "启用" row.is_active === false ? "停用" : "启用"
}</strong><strong style='color:var(--el-color-primary)'>${ }</strong><strong style='color:var(--el-color-primary)'>${
row.username row.username
}</strong>?`, }</strong>?`,
@ -148,13 +148,16 @@ export function useUser() {
} }
) )
.then(() => { .then(() => {
switchLoadMap.value[index] = Object.assign( const params = {
{}, department_id: row.department_id,
switchLoadMap.value[index], username: row.username,
{ phone_number: row.phone_number,
loading: true is_active: row.is_active,
} gender: row.gender,
); id: row.id
};
updateUser(params).then(res => {
if (res.success) {
setTimeout(() => { setTimeout(() => {
switchLoadMap.value[index] = Object.assign( switchLoadMap.value[index] = Object.assign(
{}, {},
@ -167,9 +170,20 @@ export function useUser() {
type: "success" type: "success"
}); });
}, 300); }, 300);
} else {
row.is_active === false
? (row.is_active = true)
: (row.is_active = false);
message(`${res.msg}`, {
type: "warning"
});
}
});
}) })
.catch(() => { .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