feat:区域树点击

dev
kongyeqing 2023-09-18 17:40:39 +08:00
parent d63b99c802
commit 51b9f8c87e
3 changed files with 93 additions and 53 deletions

View File

@ -11,7 +11,6 @@
<TableComponent :tableData="tableData" :tableColumn="tableColumn" @tabCallback="callback($event)" <TableComponent :tableData="tableData" :tableColumn="tableColumn" @tabCallback="callback($event)"
@actionCallback="callback($event)" @pageNumberChange="callback($event,'pageNum')" @actionCallback="callback($event)" @pageNumberChange="callback($event,'pageNum')"
@pageSizeChange="callback($event,'pageSize')" :footerActions="footerActions" :actions="tableActions"> @pageSizeChange="callback($event,'pageSize')" :footerActions="footerActions" :actions="tableActions">
<el-table ref="multipleTable" :data="tableData.datas" height="100%" border row-key="checked" <el-table ref="multipleTable" :data="tableData.datas" height="100%" border row-key="checked"
@selection-change="handleSelectionChange" style="width: 100%"> @selection-change="handleSelectionChange" style="width: 100%">
<el-table-column type="selection" fixed label="全选" width="40"> <el-table-column type="selection" fixed label="全选" width="40">
@ -52,7 +51,7 @@
<TableComponent :tableData="tableData" :tableColumn="subTableColumn" <TableComponent :tableData="tableData" :tableColumn="subTableColumn"
@actionCallback="projectCallback($event)" :actions="!isReadonly?tableActions:[]" @actionCallback="projectCallback($event)" :actions="!isReadonly?tableActions:[]"
actionPosition="flex-start" :showFooter="false" style="margin-bottom: 20px;"> actionPosition="flex-start" :showFooter="false" style="margin-bottom: 20px;">
<el-table ref="multipleTable" :data="updateParams.items" tooltip-effect="dark" height="250" border <el-table ref="submultipleTable" :data="updateParams.items" tooltip-effect="dark" height="250" border
@selection-change="handleSelectionChange" style="width: 100%"> @selection-change="handleSelectionChange" style="width: 100%">
<el-table-column type="selection" fixed label="全选" width="40" v-if="!isReadonly"> <el-table-column type="selection" fixed label="全选" width="40" v-if="!isReadonly">
</el-table-column> </el-table-column>
@ -69,7 +68,8 @@
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" @click="showSubmodal(scope.row,true)">查看</el-button> <el-button type="text" @click="showSubmodal(scope.row,true)">查看</el-button>
<el-button type="text" v-if="!isReadonly" @click="showSubmodal(scope.row)">修改</el-button> <el-button type="text" v-if="!isReadonly" @click="showSubmodal(scope.row)">修改</el-button>
<el-button type="text" v-if="!isReadonly" @click="deleteProData([scope.row.index - 1])">删除</el-button> <el-button type="text" v-if="!isReadonly"
@click="deleteProData([scope.row.index - 1])">删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -89,8 +89,7 @@
:before-close="handleClosePro" destroy-on-close> :before-close="handleClosePro" destroy-on-close>
<TableComponent :tableData="currentProTableData" :tableColumn="subTableColumn" :showFooter="false" <TableComponent :tableData="currentProTableData" :tableColumn="subTableColumn" :showFooter="false"
style="margin-bottom: 20px;"> style="margin-bottom: 20px;">
<el-table ref="multipleTable" :data="currentProTableData.datas" tooltip-effect="dark" height="250" border <el-table :data="currentProTableData.datas" tooltip-effect="dark" height="250" border style="width: 100%">
style="width: 100%">
<template v-for="item in subTableColumn"> <template v-for="item in subTableColumn">
<el-table-column :prop="item.key" :show-overflow-tooltip="item.showTip" :label="item.name" <el-table-column :prop="item.key" :show-overflow-tooltip="item.showTip" :label="item.name"
:width="item.width" :key="item.key"> :width="item.width" :key="item.key">

View File

@ -32,6 +32,10 @@ export default class DeviceManagerComponent extends BaseRecordComponent<any> {
public params = { public params = {
areaName: "", areaName: "",
unitName: "", unitName: "",
areaId: '',
unitId: '',
name: '',
type: '',
} as any; } as any;
public isReadonly = false; public isReadonly = false;
public currentId = -1; public currentId = -1;
@ -283,7 +287,7 @@ export default class DeviceManagerComponent extends BaseRecordComponent<any> {
}) })
} }
// //
public loadUnitData(id?) { public loadUnitData(id?, isTree = false) {
this.unitService.selectByPage({ pageSize: 1000, areaId: id }, false).then((res: any) => { this.unitService.selectByPage({ pageSize: 1000, areaId: id }, false).then((res: any) => {
this.unitList = res.data.datas.map(item => { this.unitList = res.data.datas.map(item => {
return { return {
@ -295,18 +299,27 @@ export default class DeviceManagerComponent extends BaseRecordComponent<any> {
userName: item.chargeUserName, userName: item.chargeUserName,
} }
}); });
this.buildUpdateForm() const option = this.updateOptions.find(item => item.key === "unitId") as any;
option.datas = this.unitList
if (this.updateParams.unitId && isTree) {
this.selectUnitMethod(this.updateParams.unitId)
}
}) })
} }
// //
public handleNodeClick(data) { public handleNodeClick(data) {
this.params.unitName = "";
this.params.areaName = ""; this.params.areaName = "";
this.params.areaId = "";
this.params.unitName = "";
this.params.unitId = "";
if (data.areaId) { if (data.areaId) {
this.params.unitName = data.name this.params.unitName = data.name;
this.params.unitId = data.id;
this.params.areaId = data.areaId
} else { } else {
this.params.areaName = data.name === "全部" ? "" : data.name this.params.areaName = data.name === "全部" ? "" : data.name;
this.params.areaId = data.name === "全部" ? "" : data.id;
} }
this.getTableData() this.getTableData()
} }
@ -360,11 +373,8 @@ export default class DeviceManagerComponent extends BaseRecordComponent<any> {
public changes(data, item) { public changes(data, item) {
// //
if (item && item.key === 'unitId') { if (item && item.key === 'unitId') {
const unitData = this.unitList.find((itm: any) => itm.value === data) as any; //
this.updateParams.chargeDeptName = unitData.deptName; this.selectUnitMethod(data);
this.updateParams.chargeUserId = unitData.userId;
this.updateParams.chargeUserName = unitData.userName;
this.updateParams.chargeDeptId = unitData.deptId;
} }
// //
@ -387,6 +397,17 @@ export default class DeviceManagerComponent extends BaseRecordComponent<any> {
this.updateParams.postName = data.map(itm => this.$store.getters.post_map[itm]).join(","); this.updateParams.postName = data.map(itm => this.$store.getters.post_map[itm]).join(",");
} }
} }
/**
* 单元关联数据
* @param data 单元id
*/
public selectUnitMethod(data: any) {
const unitData = this.unitList.find((itm: any) => itm.value === data) as any;
this.updateParams.chargeDeptName = unitData.deptName;
this.updateParams.chargeUserId = unitData.userId;
this.updateParams.chargeUserName = unitData.userName;
this.updateParams.chargeDeptId = unitData.deptId;
}
public callback(data, type) { public callback(data, type) {
if (type) { if (type) {
@ -411,15 +432,8 @@ export default class DeviceManagerComponent extends BaseRecordComponent<any> {
} else if (data.value === "delete") { } else if (data.value === "delete") {
this.deleteData(this.selectData) this.deleteData(this.selectData)
} else if (data.value === "add") { } else if (data.value === "add") {
this.isReadonly = false; this.showUpdateModel();
this.currentId = -1;
this.updateParams = {
items: [], identifyUserId: this.account.userId,
identifyTime: moment().format('YYYY-MM-DD'),
} as any;
this.buildActionsForm();
this.buildUpdateForm();
this.showUpdate = true
} else if (data && data.value.indexOf("save") >= 0) { } else if (data && data.value.indexOf("save") >= 0) {
this.doSave(data.value !== "save") this.doSave(data.value !== "save")
} else if (data && data.value === "cancel") { } else if (data && data.value === "cancel") {
@ -442,32 +456,44 @@ export default class DeviceManagerComponent extends BaseRecordComponent<any> {
}) })
} }
public showUpdateModel(row, isReadonly) { public showUpdateModel(row?, isReadonly = false) {
this.updateParams = { items: [], } as any; this.updateParams = { items: [], } as any;
this.isReadonly = isReadonly;
if (!row) {
this.currentId = -1;
this.updateParams = {
items: [],
identifyUserId: this.account.userId,
identifyTime: moment().format('YYYY-MM-DD'),
chargeUserId: null,
} as any;
//
if (this.params.areaId) {
this.updateParams.areaId = this.params.areaId;
this.loadUnitData(this.params.areaId, true)
this.updateParams.unitId = this.params.unitId;
}
} else {
this.currentId = row.id; this.currentId = row.id;
this.tableService.selectById(this.currentId).then((res: any) => { this.tableService.selectById(this.currentId).then((res: any) => {
if (isReadonly) {
this.isReadonly = true;
this.updateParams = Object.assign({ this.updateParams = Object.assign({
safetyFactorName: res.data.safetyFactor.split(",").map(item => this.$store.getters.prevention_safe_reason_map[item]).join(","), safetyFactorName: res.data.safetyFactor.split(",").map(item => this.$store.getters.prevention_safe_reason_map[item]).join(","),
identifyUserName: this.$store.getters.user_map[res.data.identifyUserId], identifyUserName: this.$store.getters.user_map[res.data.identifyUserId],
typeName: this.$store.getters.prevention_device_type_map[res.data.type], typeName: this.$store.getters.prevention_device_type_map[res.data.type],
}, res.data) }, res.data)
} else {
this.isReadonly = false
this.updateParams = res.data;
this.updateParams.safetyFactor = res.data.safetyFactor.split(",").map(item => parseInt(item)) this.updateParams.safetyFactor = res.data.safetyFactor.split(",").map(item => parseInt(item))
this.updateParams.postCode = res.data.postCode.split(",").map(item => parseInt(item)) this.updateParams.postCode = res.data.postCode.split(",").map(item => parseInt(item))
this.loadUnitData(res.data.areas) this.loadUnitData(res.data.areas)
}
this.updateParams.items.forEach((item, i) => { this.updateParams.items.forEach((item, i) => {
item.index = i + 1 item.index = i + 1
}) })
this.buildUpdateForm()
this.buildActionsForm()
this.showUpdate = true;
}) })
} }
this.buildActionsForm();
this.buildUpdateForm();
this.showUpdate = true
}
public doSave(goOn?) { public doSave(goOn?) {
if ((this.$refs.basicForm as any).vaildParams()) { if ((this.$refs.basicForm as any).vaildParams()) {
@ -501,6 +527,8 @@ export default class DeviceManagerComponent extends BaseRecordComponent<any> {
if (!this.selectData.length) { if (!this.selectData.length) {
this.toggleAll() this.toggleAll()
} else { } else {
console.log('this.tableData.datas',this.tableData.datas);
this.tableData.datas.forEach((item, index) => { this.tableData.datas.forEach((item, index) => {
const find = this.selectData.find((data: any) => data.id === item.id); const find = this.selectData.find((data: any) => data.id === item.id);
if (!find) { if (!find) {

View File

@ -100,6 +100,7 @@ export default class WorkManagerComponent extends BaseRecordComponent<any> {
identifyTime: moment().format('YYYY-MM-DD'), identifyTime: moment().format('YYYY-MM-DD'),
identifyUserId: this.account.userId, identifyUserId: this.account.userId,
steps: [], steps: [],
chargeUserId: null,
} as any; } as any;
public selectData = []; public selectData = [];
@ -324,34 +325,35 @@ export default class WorkManagerComponent extends BaseRecordComponent<any> {
}) })
} }
// //
public loadUnitData(id?) { public loadUnitData(id?, isTree = false) {
this.unitService.selectByPage({ pageSize: 1000, areaId: id }, false).then((res: any) => { this.unitService.selectByPage({ pageSize: 1000, areaId: id }, false).then((res: any) => {
this.unitList = res.data.datas.map(item => { this.unitList = res.data.datas.map(item => {
return { return {
name: item.name, name: item.name,
value: item.id, value: item.id,
deptId: item.chargeDeptId, deptId: item.chargeDeptId,
userId: item.chargeUserId,
deptName: item.chargeDeptName, deptName: item.chargeDeptName,
userId: item.chargeUserId,
userName: item.chargeUserName, userName: item.chargeUserName,
} }
}); });
const option = this.updateOptions.find(item => item.key === "unitId") as any; const option = this.updateOptions.find(item => item.key === "unitId") as any;
option.datas = this.unitList option.datas = this.unitList
if (this.updateParams.unitId && isTree) {
this.selectUnitMethod(this.updateParams.unitId)
}
}) })
} }
// //
public handleNodeClick(data) { public handleNodeClick(data: any) {
this.params.areaName = ""; this.params.areaName = "";
this.params.areaId = ""; this.params.areaId = "";
this.params.unitName = ""; this.params.unitName = "";
this.params.unitId = ""; this.params.unitId = "";
console.log('data', data);
if (data.areaId) { if (data.areaId) {
this.params.unitName = data.name; this.params.unitName = data.name;
this.params.unitId = data.id; this.params.unitId = data.id;
this.params.areaId = data.areaId
} else { } else {
this.params.areaName = data.name === "全部" ? "" : data.name; this.params.areaName = data.name === "全部" ? "" : data.name;
this.params.areaId = data.name === "全部" ? "" : data.id; this.params.areaId = data.name === "全部" ? "" : data.id;
@ -402,13 +404,8 @@ export default class WorkManagerComponent extends BaseRecordComponent<any> {
public changes(data, item) { public changes(data, item) {
// //
if (item && item.key === 'unitId') { if (item && item.key === 'unitId') {
const unitData = this.unitList.find((itm: any) => itm.value === data) as any; //
this.updateParams.chargeDeptName = unitData.deptName; this.selectUnitMethod(data);
this.updateParams.chargeUserId = unitData.userId;
this.updateParams.chargeUserName = unitData.userName;
this.updateParams.chargeDeptId = unitData.deptId;
const option = this.updateOptions.find(item => item.key === "chargeUserId") as any;
option.showError = false
} }
// //
if (item && item.key === "chargeDeptId") { if (item && item.key === "chargeDeptId") {
@ -442,6 +439,20 @@ export default class WorkManagerComponent extends BaseRecordComponent<any> {
this.updateParams.postName = data.map(itm => this.$store.getters.post_map[itm]).join(","); this.updateParams.postName = data.map(itm => this.$store.getters.post_map[itm]).join(",");
} }
} }
/**
* 选择单元 填写关联数据
* @param data 单元id
*/
public selectUnitMethod(data: any) {
const unitData = this.unitList.find((itm: any) => itm.value === data) as any;
this.updateParams.chargeDeptName = unitData.deptName;
this.updateParams.chargeUserId = unitData.userId;
this.updateParams.chargeUserName = unitData.userName;
this.updateParams.chargeDeptId = unitData.deptId;
const option = this.updateOptions.find(item => item.key === "chargeUserId") as any;
option.showError = false;
}
/** /**
* 按钮操作函数 * 按钮操作函数
* @param data * @param data
@ -581,11 +592,13 @@ export default class WorkManagerComponent extends BaseRecordComponent<any> {
steps: [], steps: [],
identifyTime: moment().format('YYYY-MM-DD'), identifyTime: moment().format('YYYY-MM-DD'),
identifyUserId: this.account.userId, identifyUserId: this.account.userId,
chargeUserId: null,
} as any; } as any;
// //
if (this.params.areaId) { if (this.params.areaId) {
this.updateParams.areaId = this.params.areaId; this.updateParams.areaId = this.params.areaId;
this.loadUnitData(this.params.areaId) this.loadUnitData(this.params.areaId, true)
this.updateParams.unitId = this.params.unitId;
} }
this.updateActionsForm() this.updateActionsForm()
} else { } else {