This commit is contained in:
zengmingjie 2025-06-26 02:07:23 +08:00
parent d057a5df47
commit 4457c08192
2 changed files with 22 additions and 31 deletions

View File

@ -50,7 +50,7 @@
<el-option <el-option
v-for="(element, i) in item.options" v-for="(element, i) in item.options"
:label="element.label" :label="element.label"
:value="`${element.key}`" :value="element.key"
:key="i" :key="i"
/> />
</el-select> </el-select>

View File

@ -80,9 +80,9 @@
</template> </template>
<script> <script>
"use script";
import { userList, userAdd, userUpdate, userDelete } from "@/api/user.js"; import { userList, userAdd, userUpdate, userDelete } from "@/api/user.js";
import { devPositionList } from "@/api/position.js"; import { devPositionList } from "@/api/position.js";
export default { export default {
name: "webDevice", name: "webDevice",
data() { data() {
@ -146,7 +146,7 @@ export default {
}, },
{ {
label: "是否管理员", label: "是否管理员",
prop: "isAdmin", prop: "isAdminDisplay", // 使
align: "center" align: "center"
}, },
{ {
@ -195,15 +195,12 @@ export default {
color: value == 0 ? "green" : "red" color: value == 0 ? "green" : "red"
}; };
}, },
//
onMountedForm() { onMountedForm() {
this.$forceUpdate(); this.$forceUpdate();
}, },
//
handleClose() { handleClose() {
this.drawer = false; this.drawer = false;
}, },
//
headdenForm(value, type) { headdenForm(value, type) {
let params = {}; let params = {};
if (type === "add") { if (type === "add") {
@ -221,29 +218,29 @@ export default {
params.pageSize = this.paginationParam.size; params.pageSize = this.paginationParam.size;
userList(params).then((res) => { userList(params).then((res) => {
if (res.code === 0) { if (res.code === 0) {
this.tableData = res.data.items.map((item) => { let items = JSON.parse(JSON.stringify(res.data.items));
this.tableData = items.map((item) => {
const { ...rest } = item; const { ...rest } = item;
return { return {
...rest, ...rest,
isAdmin: item.isAdmin ? "是" : "否" isAdminDisplay: item.isAdmin ? "是" : "否", //
isAdmin: item.isAdmin //
}; };
}); });
this.paginationParam.total = res.data.total; this.paginationParam.total = res.data.total;
} }
}); });
} }
console.log(value);
}, },
//
handleClick(value, type) { handleClick(value, type) {
if (type === "edit") { if (type === "edit") {
this.isType = "edit"; this.isType = "edit";
this.title = "编辑人员"; this.title = "编辑人员";
this.fromItem = value; this.fromItem = JSON.parse(JSON.stringify(value));
console.log(value, "value.positionId"); // isAdmin
this.fromItem.positionId = value.positionId.map((item) => { console.log(this.fromItem, "value");
return String(item); this.fromItem.isAdmin = value.isAdmin; // 使
}); this.fromItem.positionId = value.positionId.map((item) => String(item));
this.initPosition(); this.initPosition();
this.formDrawerList[0].disabled = true; this.formDrawerList[0].disabled = true;
this.formDrawerList[1].disabled = true; this.formDrawerList[1].disabled = true;
@ -271,23 +268,18 @@ export default {
}); });
} }
}, },
//
determine(value) { determine(value) {
let params = {}; let params = JSON.parse(JSON.stringify(value));
params = value;
console.log(params, "params"); console.log(params, "params");
// isAdmin
params.isAdmin = params.isAdmin === true || params.isAdmin === "true";
if (this.isType === "add") { if (this.isType === "add") {
// console.log(""); userAdd(params).then((res) => {
userAdd(params) if (res.code === 0) {
.then((res) => { this.$message.success("新增成功");
if (res.code === 0) { this.headdenForm({}, "search");
this.$message.success("新增成功"); }
this.headdenForm({}, "search"); });
}
})
.catch((err) => {
console.log(err);
});
} else if (this.isType === "edit") { } else if (this.isType === "edit") {
userUpdate(params).then((res) => { userUpdate(params).then((res) => {
if (res.code === 0) { if (res.code === 0) {
@ -299,18 +291,17 @@ export default {
this.drawer = false; this.drawer = false;
}, },
handleSizeChange(value) { handleSizeChange(value) {
console.log(value);
this.paginationParam.size = value; this.paginationParam.size = value;
this.headdenForm({}, "search"); this.headdenForm({}, "search");
}, },
handlePageChange(value) { handlePageChange(value) {
console.log(value);
this.paginationParam.currentPage = value; this.paginationParam.currentPage = value;
this.headdenForm({}, "search"); this.headdenForm({}, "search");
} }
} }
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.user { .user {
width: 95%; width: 95%;