forked from xxhjsb/hbt-prevention-ui
feat:区域树点击
parent
d63b99c802
commit
51b9f8c87e
|
@ -11,7 +11,6 @@
|
|||
<TableComponent :tableData="tableData" :tableColumn="tableColumn" @tabCallback="callback($event)"
|
||||
@actionCallback="callback($event)" @pageNumberChange="callback($event,'pageNum')"
|
||||
@pageSizeChange="callback($event,'pageSize')" :footerActions="footerActions" :actions="tableActions">
|
||||
|
||||
<el-table ref="multipleTable" :data="tableData.datas" height="100%" border row-key="checked"
|
||||
@selection-change="handleSelectionChange" style="width: 100%">
|
||||
<el-table-column type="selection" fixed label="全选" width="40">
|
||||
|
@ -52,7 +51,7 @@
|
|||
<TableComponent :tableData="tableData" :tableColumn="subTableColumn"
|
||||
@actionCallback="projectCallback($event)" :actions="!isReadonly?tableActions:[]"
|
||||
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%">
|
||||
<el-table-column type="selection" fixed label="全选" width="40" v-if="!isReadonly">
|
||||
</el-table-column>
|
||||
|
@ -69,7 +68,8 @@
|
|||
<template slot-scope="scope">
|
||||
<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="deleteProData([scope.row.index - 1])">删除</el-button>
|
||||
<el-button type="text" v-if="!isReadonly"
|
||||
@click="deleteProData([scope.row.index - 1])">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
@ -89,8 +89,7 @@
|
|||
:before-close="handleClosePro" destroy-on-close>
|
||||
<TableComponent :tableData="currentProTableData" :tableColumn="subTableColumn" :showFooter="false"
|
||||
style="margin-bottom: 20px;">
|
||||
<el-table ref="multipleTable" :data="currentProTableData.datas" tooltip-effect="dark" height="250" border
|
||||
style="width: 100%">
|
||||
<el-table :data="currentProTableData.datas" tooltip-effect="dark" height="250" border style="width: 100%">
|
||||
<template v-for="item in subTableColumn">
|
||||
<el-table-column :prop="item.key" :show-overflow-tooltip="item.showTip" :label="item.name"
|
||||
:width="item.width" :key="item.key">
|
||||
|
|
|
@ -32,6 +32,10 @@ export default class DeviceManagerComponent extends BaseRecordComponent<any> {
|
|||
public params = {
|
||||
areaName: "",
|
||||
unitName: "",
|
||||
areaId: '',
|
||||
unitId: '',
|
||||
name: '',
|
||||
type: '',
|
||||
} as any;
|
||||
public isReadonly = false;
|
||||
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.unitList = res.data.datas.map(item => {
|
||||
return {
|
||||
|
@ -295,18 +299,27 @@ export default class DeviceManagerComponent extends BaseRecordComponent<any> {
|
|||
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) {
|
||||
this.params.unitName = "";
|
||||
this.params.areaName = "";
|
||||
this.params.areaId = "";
|
||||
this.params.unitName = "";
|
||||
this.params.unitId = "";
|
||||
if (data.areaId) {
|
||||
this.params.unitName = data.name
|
||||
this.params.unitName = data.name;
|
||||
this.params.unitId = data.id;
|
||||
this.params.areaId = data.areaId
|
||||
} else {
|
||||
this.params.areaName = data.name === "全部" ? "" : data.name
|
||||
this.params.areaName = data.name === "全部" ? "" : data.name;
|
||||
this.params.areaId = data.name === "全部" ? "" : data.id;
|
||||
}
|
||||
this.getTableData()
|
||||
}
|
||||
|
@ -360,11 +373,8 @@ export default class DeviceManagerComponent extends BaseRecordComponent<any> {
|
|||
public changes(data, item) {
|
||||
//单元
|
||||
if (item && item.key === 'unitId') {
|
||||
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;
|
||||
//单元关联数据
|
||||
this.selectUnitMethod(data);
|
||||
}
|
||||
|
||||
// 部门
|
||||
|
@ -387,6 +397,17 @@ export default class DeviceManagerComponent extends BaseRecordComponent<any> {
|
|||
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) {
|
||||
if (type) {
|
||||
|
@ -411,15 +432,8 @@ export default class DeviceManagerComponent extends BaseRecordComponent<any> {
|
|||
} else if (data.value === "delete") {
|
||||
this.deleteData(this.selectData)
|
||||
} else if (data.value === "add") {
|
||||
this.isReadonly = false;
|
||||
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
|
||||
this.showUpdateModel();
|
||||
|
||||
} else if (data && data.value.indexOf("save") >= 0) {
|
||||
this.doSave(data.value !== "save")
|
||||
} 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.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.tableService.selectById(this.currentId).then((res: any) => {
|
||||
if (isReadonly) {
|
||||
this.isReadonly = true;
|
||||
this.updateParams = Object.assign({
|
||||
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],
|
||||
typeName: this.$store.getters.prevention_device_type_map[res.data.type],
|
||||
}, res.data)
|
||||
} else {
|
||||
this.isReadonly = false
|
||||
this.updateParams = res.data;
|
||||
this.updateParams.safetyFactor = res.data.safetyFactor.split(",").map(item => parseInt(item))
|
||||
this.updateParams.postCode = res.data.postCode.split(",").map(item => parseInt(item))
|
||||
this.loadUnitData(res.data.areas)
|
||||
}
|
||||
this.updateParams.items.forEach((item, i) => {
|
||||
item.index = i + 1
|
||||
})
|
||||
this.buildUpdateForm()
|
||||
this.buildActionsForm()
|
||||
this.showUpdate = true;
|
||||
})
|
||||
}
|
||||
this.buildActionsForm();
|
||||
this.buildUpdateForm();
|
||||
this.showUpdate = true
|
||||
}
|
||||
|
||||
public doSave(goOn?) {
|
||||
if ((this.$refs.basicForm as any).vaildParams()) {
|
||||
|
@ -501,6 +527,8 @@ export default class DeviceManagerComponent extends BaseRecordComponent<any> {
|
|||
if (!this.selectData.length) {
|
||||
this.toggleAll()
|
||||
} else {
|
||||
console.log('this.tableData.datas',this.tableData.datas);
|
||||
|
||||
this.tableData.datas.forEach((item, index) => {
|
||||
const find = this.selectData.find((data: any) => data.id === item.id);
|
||||
if (!find) {
|
||||
|
|
|
@ -100,6 +100,7 @@ export default class WorkManagerComponent extends BaseRecordComponent<any> {
|
|||
identifyTime: moment().format('YYYY-MM-DD'),
|
||||
identifyUserId: this.account.userId,
|
||||
steps: [],
|
||||
chargeUserId: null,
|
||||
} as any;
|
||||
|
||||
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.unitList = res.data.datas.map(item => {
|
||||
return {
|
||||
name: item.name,
|
||||
value: item.id,
|
||||
deptId: item.chargeDeptId,
|
||||
userId: item.chargeUserId,
|
||||
deptName: item.chargeDeptName,
|
||||
userId: item.chargeUserId,
|
||||
userName: item.chargeUserName,
|
||||
}
|
||||
});
|
||||
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: any) {
|
||||
this.params.areaName = "";
|
||||
this.params.areaId = "";
|
||||
this.params.unitName = "";
|
||||
this.params.unitId = "";
|
||||
|
||||
console.log('data', data);
|
||||
|
||||
if (data.areaId) {
|
||||
this.params.unitName = data.name;
|
||||
this.params.unitId = data.id;
|
||||
this.params.areaId = data.areaId
|
||||
} else {
|
||||
this.params.areaName = data.name === "全部" ? "" : data.name;
|
||||
this.params.areaId = data.name === "全部" ? "" : data.id;
|
||||
|
@ -402,13 +404,8 @@ export default class WorkManagerComponent extends BaseRecordComponent<any> {
|
|||
public changes(data, item) {
|
||||
//单元
|
||||
if (item && item.key === 'unitId') {
|
||||
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
|
||||
//选择单元
|
||||
this.selectUnitMethod(data);
|
||||
}
|
||||
// 部门
|
||||
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(",");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 选择单元 填写关联数据
|
||||
* @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
|
||||
|
@ -581,11 +592,13 @@ export default class WorkManagerComponent extends BaseRecordComponent<any> {
|
|||
steps: [],
|
||||
identifyTime: moment().format('YYYY-MM-DD'),
|
||||
identifyUserId: this.account.userId,
|
||||
chargeUserId: null,
|
||||
} as any;
|
||||
//树点击
|
||||
if (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()
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue