<style lang="less">
|
@import "@/styles/table-common.less";
|
@import "@/styles/drawer-common.less";
|
@import "src/views/your/area-manage/areaManage.less";
|
</style>
|
<template>
|
<div class="search">
|
<Card>
|
<Row class="operation">
|
<Button @click="addCar" type="primary" icon="md-add">添加配送片区</Button>
|
<Button @click="init" icon="md-refresh">刷新</Button>
|
<Button type="dashed" @click="openTip = !openTip">{{
|
openTip ? "关闭提示" : "开启提示"
|
}}</Button>
|
<Input
|
v-model="searchForm2.name"
|
suffix="ios-search"
|
@on-change="getDataList2"
|
placeholder="输入配送地区搜索"
|
clearable
|
style="width: 250px"
|
/>
|
</Row>
|
<Alert show-icon v-show="openTip">
|
已选择
|
<span class="select-count">{{ selectList.length }}</span> 项
|
<a class="select-clear" @click="clearSelectAll">清空</a>
|
</Alert>
|
<Table
|
:loading="loading"
|
border
|
:columns="columns"
|
:data="data"
|
ref="table"
|
sortable="custom"
|
@on-sort-change="changeSort"
|
@on-selection-change="changeSelect"
|
></Table>
|
<Row type="flex" justify="end" class="page">
|
<Page
|
:current="searchForm.pageNumber"
|
:total="total"
|
:page-size="searchForm.pageSize"
|
@on-change="changePage"
|
@on-page-size-change="changePageSize"
|
:page-size-opts="[10, 20, 50]"
|
size="small"
|
show-total
|
show-elevator
|
show-sizer
|
></Page>
|
</Row>
|
</Card>
|
|
<!-- 编辑 -->
|
<Modal
|
:title="modalTitle"
|
v-model="roleModalVisible"
|
:mask-closable="false"
|
:width="500"
|
>
|
<Form ref="areaForm" :model="areaForm" :label-width="80" :rules="areaFormValidate">
|
<FormItem label="片区名称" prop="name">
|
<Input v-model="areaForm.name"/>
|
</FormItem>
|
<FormItem label="片区描述" prop="description">
|
<Input v-model="areaForm.description" />
|
</FormItem>
|
<!--<FormItem label="配送员" prop="userId">-->
|
<!--<Select v-model="areaForm.userId" filterable>-->
|
<!--<Option :value="0" :key="0" selected>请选择</Option>-->
|
<!--<Option v-for="item in userList" :value="item.id">{{ item.nickname }}</Option>-->
|
<!--</Select>-->
|
<!--</FormItem>-->
|
<FormItem label="配送车辆" prop="carId">
|
<Select v-model="areaForm.carId" filterable>
|
<Option value="" key="" selected>请选择</Option>
|
<Option v-for="item in carList" :value="item.id">{{ item.carNo }}</Option>
|
</Select>
|
</FormItem>
|
</Form>
|
<div slot="footer">
|
<Button type="text" @click="carRole">取消</Button>
|
<Button type="primary" :loading="submitLoading" @click="submitArea"
|
>提交</Button
|
>
|
</div>
|
</Modal>
|
<Modal :title="modalTitle2" v-model="equipmentVisible" :mask-closable="false" :width="1120">
|
<Row class="operation" style="padding-bottom: 20px">
|
<Button @click="addEquipment" type="primary" icon="md-add">添加片区段</Button>
|
<Button @click="init" icon="md-refresh">刷新</Button>
|
</Row>
|
<Table :loading="loading" border :columns="columns2" :data="data2" ref="table" style="height: 400px" >
|
sortable="custom" @on-sort-change="changeSort" @on-selection-change="changeSelect" >
|
</Table>
|
</Modal>
|
<Modal :title="modalTitle3" v-model="customerVisible" :mask-closable="false" :width="1050">
|
<Row class="operation" style="padding-bottom: 20px">
|
<Button @click="addCustomer" type="primary" icon="md-add">添加</Button>
|
<Button @click="init" icon="md-refresh">刷新</Button>
|
<Input v-model="searchForm.customerName" suffix="ios-search" @on-change="getCustList" placeholder="输入商户名称搜索" clearable style="width: 250px"
|
/>
|
</Row>
|
<Table :loading="loading" border :columns="columns3" :data="data3" ref="table"
|
sortable="custom" @on-sort-change="changeSort" @on-selection-change="changeSelect">
|
</Table>
|
<Row type="flex" justify="end" class="page">
|
<Page :current.sync="searchForm.pageNumber" :total="total2"
|
:page-size="searchForm.pageSize"
|
@on-change="changePage1"
|
@on-page-size-change="changePageSize"
|
:page-size-opts="[10, 20, 50]"
|
size="small"
|
show-total
|
show-elevator
|
></Page>
|
</Row>
|
</Modal>
|
<Modal :title="modalTitle" v-model="addEquipmentVisible" :mask-closable="false" :width="500" >
|
<Form ref="areaSectionForm" :model="areaSectionForm" :label-width="80" :rules="areaSectionFormValidate">
|
<FormItem label="片区名称" prop="code">
|
<Input v-model="areaSectionForm.name" />
|
</FormItem>
|
|
</Form>
|
<div slot="footer">
|
<Button type="text" @click="carRole">取消</Button>
|
<Button type="primary" :loading="submitLoading" @click="submitEquipment"
|
>提交</Button
|
>
|
</div>
|
</Modal>
|
<Modal :title="modalTitle" v-model="addCustomerVisible" :mask-closable="false" :width="550">
|
<Form ref="customerForm" :model="customerForm" :label-width="120" :rules="areaSectionFormValidate">
|
<FormItem label="商户名称" prop="name">
|
<Input v-model="customerForm.name" />
|
</FormItem>
|
<!--<FormItem label="商户编号" prop="code">-->
|
<!--<Input v-model="customerForm.code" />-->
|
<!--</FormItem>-->
|
|
<Row :gutter="0">
|
<Col span="12">
|
<FormItem label="经度" prop="lng">
|
<Input v-model="customerForm.lng" />
|
</FormItem>
|
</Col>
|
<Col span="12">
|
<FormItem label="纬度" prop="lat">
|
<Input v-model="customerForm.lat" />
|
</FormItem>
|
</Col>
|
</Row>
|
<Row :gutter="0">
|
<!--<Col span="12">-->
|
<!--<Form-item label="上次配送日期" prop="lastTime">-->
|
<!--<Row>-->
|
<!--<Col>-->
|
<!--<Date-picker @on-change="change1" type="date" value="yyyy-MM-dd" placeholder="选择日期" v-model="customerForm.lastTime"></Date-picker>-->
|
<!--</Col>-->
|
<!--</Row>-->
|
<!--</Form-item>-->
|
<!--</Col>-->
|
<Col span="12">
|
<FormItem label="联系方式" prop="phone">
|
<Input v-model="customerForm.phone"/>
|
</FormItem>
|
</Col>
|
</Row>
|
|
<FormItem label="商户注册地址" prop="registeredAddress">
|
<Input v-model="customerForm.registeredAddress" />
|
</FormItem>
|
<FormItem label="联系人" prop="linker">
|
<Input v-model="customerForm.linker" />
|
</FormItem>
|
<FormItem label="零售许可证信息" prop="licence" >
|
<Input v-model="customerForm.licence" />
|
</FormItem>
|
</Form>
|
<div slot="footer">
|
<Button type="text" @click="carRole">取消</Button>
|
<Button type="primary" :loading="submitLoading" @click="submitCustomer"
|
>提交</Button
|
>
|
</div>
|
</Modal>
|
<!-- 菜单权限 -->
|
<Drawer
|
:title="modalTitle"
|
v-model="permModalVisible"
|
:mask-closable="false"
|
:width="500"
|
draggable
|
>
|
<div :style="{ maxHeight: maxHeight }" class="drawer-content">
|
<div style="position: relative">
|
<Tree
|
ref="tree"
|
:data="permData"
|
show-checkbox
|
:render="renderContent"
|
:check-strictly="true"
|
></Tree>
|
<Spin size="large" fix v-if="treeLoading"></Spin>
|
</div>
|
</div>
|
<div class="drawer-footer br">
|
<Button
|
type="primary"
|
:loading="submitPermLoading"
|
@click="submitPermEdit"
|
>提交</Button
|
>
|
<Button @click="selectTreeAll">全选/反选</Button>
|
<Select
|
v-model="openLevel"
|
@on-change="changeOpen"
|
style="width: 110px"
|
transfer
|
>
|
<Option value="0">展开所有</Option>
|
<Option value="1">收合所有</Option>
|
<Option value="2">仅展开一级</Option>
|
<Option value="3">仅展开两级</Option>
|
</Select>
|
<Button type="text" @click="cancelPermEdit">取消</Button>
|
</div>
|
</Drawer>
|
<!-- 数据权限 -->
|
<Modal
|
:title="modalTitle"
|
v-model="carModalVisible"
|
:mask-closable="false"
|
:width="500"
|
class="depModal"
|
>
|
<Form :label-width="85" ref="removeForm" :model="removeForm">
|
<FormItem label="移除原因" prop="removeReason">
|
<Input v-model="removeForm.removeReason"/>
|
</FormItem>
|
</Form>
|
<div v-show="dataType == 1" style="margin-top: 15px">
|
<div style="position: relative">
|
<Tree
|
ref="depTree"
|
:data="depData"
|
:load-data="loadData"
|
@on-toggle-expand="expandCheckDep"
|
multiple
|
style="margin-top: 15px"
|
></Tree>
|
<Spin size="large" fix v-if="depTreeLoading"></Spin>
|
</div>
|
</div>
|
<div slot="footer">
|
<Button type="text" @click="depModalVisible = false">取消</Button>
|
<Button
|
type="primary"
|
:loading="submitDepLoading"
|
@click="submitRemove"
|
>提交</Button
|
>
|
</div>
|
</Modal>
|
</div>
|
</template>
|
|
<script>
|
import {
|
getAllPermissionList,
|
setDefaultRole,
|
editRolePerm,
|
initDepartment,
|
loadDepartment,
|
editRoleDep,
|
} from "@/api/index";
|
|
import {
|
getAll,
|
getArea,
|
addCar,
|
getCarList,
|
getUser,
|
getDriver,
|
addArea,
|
deleteArea,
|
getAreaSection,
|
getCustomer,
|
addAreaSection,
|
deleteAreaSection,
|
addCustomer,
|
deleteCustomer,
|
|
} from "@/api/open";
|
import util from "@/libs/util.js";
|
export default {
|
name: "car-manage",
|
data() {
|
return {
|
maxHeight: 510,
|
openTip: true,
|
openLevel: "0",
|
loading: true,
|
treeLoading: true,
|
depTreeLoading: true,
|
submitPermLoading: false,
|
submitDepLoading: false,
|
searchKey: "",
|
sortColumn: "createTime",
|
sortType: "desc",
|
modalType: 0,
|
roleModalVisible: false,
|
addEquipmentVisible: false,
|
addCustomerVisible: false,
|
equipmentVisible: false,
|
customerVisible: false,
|
carModalVisible: false,
|
permModalVisible: false,
|
depModalVisible: false,
|
modalTitle: "",
|
modalTitle2: "",
|
modalTitle3: "",
|
carList:[],
|
searchForm: {
|
// 搜索框初始化对象
|
pageNumber: 1, // 当前页数
|
pageSize: 10, // 页面大小
|
sort: "createTime", // 默认排序字段
|
order: "desc", // 默认排序方式
|
key: "",
|
},
|
searchForm2: {
|
// 搜索框初始化对象
|
pageNumber: 1, // 当前页数
|
pageSize: 10, // 页面大小
|
sort: "createTime", // 默认排序字段
|
order: "desc", // 默认排序方式
|
key: "",
|
},
|
areaForm: {
|
},
|
customerForm: {
|
},
|
areaSectionForm: {
|
},
|
|
removeForm: {
|
status : 1
|
},
|
areaFormValidate: {
|
|
},
|
submitLoading: false,
|
selectList: [],
|
columns: [
|
{
|
type: "selection",
|
width: 60,
|
align: "center",
|
},
|
{
|
type: "index",
|
width: 60,
|
align: "center",
|
},
|
{
|
title: "片区名称",
|
key: "name",
|
width: 200,
|
sortable: true,
|
},
|
{
|
title: "片区描述",
|
key: "description",
|
width: 442,
|
render: (h, params) => {
|
return h("div",params.row.description=="undefined" ? '':params.row.description);
|
}
|
},
|
{
|
title: "配送车辆",
|
key: "carNo",
|
width: 200,
|
},
|
{
|
title: "操作",
|
key: "action",
|
align: "center",
|
width: 280,
|
render: (h, params) => {
|
return h("div", [
|
h(
|
"a",
|
{
|
on: {
|
click: () => {
|
this.equipment(params.row);
|
},
|
},
|
},
|
"片区段"
|
),
|
h("Divider", {
|
props: {
|
type: "vertical",
|
},
|
}),
|
h(
|
"a",
|
{
|
on: {
|
click: () => {
|
this.edit(params.row);
|
},
|
},
|
},
|
"编辑"
|
),
|
h("Divider", {
|
props: {
|
type: "vertical",
|
},
|
}),
|
h(
|
"a",
|
{
|
on: {
|
click: () => {
|
this.remove(params.row);
|
},
|
},
|
},
|
"删除"
|
),
|
]);
|
},
|
},
|
],
|
columns2: [
|
{
|
type: "selection",
|
width: 60,
|
align: "center",
|
},
|
{
|
type: "index",
|
width: 60,
|
align: "center",
|
},
|
{
|
title: "分段名称",
|
key: "name",
|
},
|
{
|
title: "操作",
|
key: "action",
|
align: "center",
|
render: (h, params) => {
|
return h("div", [
|
h(
|
"a",
|
{
|
on: {
|
click: () => {
|
this.area(params.row);
|
},
|
},
|
},
|
"商户"
|
),
|
h("Divider", {
|
props: {
|
type: "vertical",
|
},
|
}),
|
h(
|
"a",
|
{
|
on: {
|
click: () => {
|
this.editEquipment(params.row);
|
},
|
},
|
},
|
"编辑"
|
),
|
h("Divider", {
|
props: {
|
type: "vertical",
|
},
|
}),
|
h(
|
"a",
|
{
|
on: {
|
click: () => {
|
this.removeEquipment(params.row);
|
},
|
},
|
},
|
"删除"
|
),
|
]);
|
},
|
},
|
],
|
columns3: [
|
{
|
type: "selection",
|
width: 60,
|
align: "center",
|
},
|
{
|
type: "index",
|
width: 60,
|
align: "center",
|
},
|
{
|
title: "商户名称",
|
key: "name",
|
tooltip:true,
|
width: 200,
|
},
|
{
|
title: "商户编号",
|
key: "licence",
|
minWidth: 140,
|
},
|
{
|
title: "联系方式",
|
key: "phone",
|
width: 135,
|
},
|
// {
|
// title: "状态",
|
// key: "status",
|
// width:100,
|
// render: (h, params) => {
|
// let re = "";
|
// if (params.row.status == 0) {
|
// return h("div", [
|
// h("Badge", {
|
// props: {
|
// status: "success",
|
// text: "正常",
|
// },
|
// }),
|
// ]);
|
// } else if (params.row.status == 1) {
|
// return h("div", [
|
// h("Badge", {
|
// props: {
|
// status: "error",
|
// text: "不活跃",
|
// },
|
// }),
|
// ]);
|
// }
|
// },
|
// },
|
{
|
title: "联系人",
|
key: "linker",
|
width: 120,
|
},
|
{
|
title: "操作",
|
key: "action",
|
align: "center",
|
width: 150,
|
render: (h, params) => {
|
return h("div", [
|
h(
|
"a",
|
{
|
on: {
|
click: () => {
|
this.editCustomer(params.row);
|
},
|
},
|
},
|
"编辑"
|
),
|
h("Divider", {
|
props: {
|
type: "vertical",
|
},
|
}),
|
h(
|
"a",
|
{
|
on: {
|
click: () => {
|
this.removeCustomer(params.row);
|
},
|
},
|
},
|
"删除"
|
),
|
]);
|
},
|
},
|
],
|
data: [],
|
data2: [],
|
data3: [],
|
total: 0,
|
type: {
|
type : 1
|
},
|
total2: 0,
|
permData: [],
|
editRolePermId: "",
|
selectAllFlag: false,
|
depData: [],
|
userList: [],
|
dataType: 0,
|
areaId: '',
|
areaSectionId:'',
|
editDepartments: [],
|
};
|
},
|
methods: {
|
change1(e){
|
this.lastTime = e;
|
},
|
init() {
|
this.getDataList();
|
// 获取所有菜单权限树
|
this.getPermList();
|
},
|
renderContent(h, { root, node, data }) {
|
let icon = "";
|
if (data.level == 0) {
|
icon = "ios-navigate";
|
} else if (data.level == 1) {
|
icon = "md-list-box";
|
} else if (data.level == 2) {
|
icon = "md-list";
|
} else if (data.level == 3) {
|
icon = "md-radio-button-on";
|
} else {
|
icon = "md-radio-button-off";
|
}
|
return h(
|
"span",
|
{
|
style: {
|
display: "inline-block",
|
cursor: "pointer",
|
},
|
on: {
|
click: () => {
|
if (data.status == -1) {
|
return;
|
}
|
data.checked = !data.checked;
|
},
|
},
|
},
|
[
|
h("span", [
|
h("Icon", {
|
props: {
|
type: icon,
|
size: "16",
|
},
|
style: {
|
"margin-right": "8px",
|
"margin-bottom": "3px",
|
},
|
}),
|
h("span", data.title),
|
]),
|
]
|
);
|
},
|
changePage(v) {
|
this.searchForm.pageNumber = v;
|
this.getDataList();
|
this.clearSelectAll();
|
},
|
changePage1(v) {
|
this.searchForm.pageNumber = v;
|
this.getCustomerList(this.areaSectionId);
|
},
|
changePageSize(v) {
|
this.searchForm.pageSize = v;
|
this.getDataList();
|
},
|
changeSort(e) {
|
this.searchForm.sort = e.key;
|
this.searchForm.order = e.order;
|
if (e.order == "normal") {
|
this.searchForm.order = "";
|
}
|
this.getDataList();
|
},
|
getDataList() {
|
this.loading = true;
|
getArea(this.searchForm).then((res) => {
|
this.loading = false;
|
if (res.success) {
|
this.data = res.result.records;
|
this.total = res.result.total;
|
}
|
});
|
},
|
getDataList2() {
|
this.loading = true;
|
getArea(this.searchForm2).then((res) => {
|
this.loading = false;
|
if (res.success) {
|
this.data = res.result.records;
|
this.total = res.result.total;
|
}
|
});
|
},
|
getCustList() {
|
this.loading = true;
|
this.searchForm.pageNumber=1;
|
getCustomer(this.searchForm).then((res) => {
|
this.loading = false;
|
if (res.success) {
|
this.data3 = res.result.records;
|
this.total2 = res.result.total;
|
}
|
});
|
this.$emit('update:current',this.searchForm.pageNumber);
|
},
|
getAllUser(){
|
getDriver({type:1}).then((res)=>{
|
if (res.success){
|
this.userList=res.result;
|
}
|
});
|
},
|
getAllCar(){
|
getAll().then((res)=>{
|
if (res.success){
|
this.carList=res.result;
|
}
|
});
|
},
|
getAreaSectionList(areaId) {
|
this.loading = true;
|
this.searchForm.areaId=areaId;
|
getAreaSection(this.searchForm).then((res) => {
|
this.loading = false;
|
if (res.success) {
|
this.data2 = res.result.records;
|
}
|
});
|
},
|
getAreaSectionList2(areaId) {
|
this.loading = true;
|
this.searchForm2.areaId=areaId;
|
getAreaSection(this.searchForm2).then((res) => {
|
this.loading = false;
|
if (res.success) {
|
this.data2 = res.result.records;
|
}
|
});
|
},
|
getCustomerList(areaSectionId) {
|
this.loading = true;
|
this.searchForm.areaSectionId=areaSectionId;
|
getCustomer(this.searchForm).then((res) => {
|
this.loading = false;
|
if (res.success) {
|
this.data3 = res.result.records;
|
this.total2 = res.result.total;
|
}
|
});
|
},
|
getPermList() {
|
this.treeLoading = true;
|
getAllPermissionList().then((res) => {
|
if (res.success) {
|
this.deleteDisableNode(res.result);
|
this.permData = res.result;
|
this.treeLoading = false;
|
}
|
this.treeLoading = false;
|
});
|
},
|
// 递归标记禁用节点
|
deleteDisableNode(permData) {
|
let that = this;
|
permData.forEach(function (e) {
|
if (e.status == -1) {
|
e.title = "[已禁用] " + e.title;
|
e.disabled = true;
|
}
|
if (e.children && e.children.length > 0) {
|
that.deleteDisableNode(e.children);
|
}
|
});
|
},
|
carRole() {
|
this.roleModalVisible = false;
|
},
|
submitArea() {
|
if(this.areaForm.userId==undefined){
|
this.areaForm.userId=0;
|
}
|
if(this.areaForm.description==undefined){
|
this.areaForm.description="";
|
}
|
if(this.areaForm.carId==undefined){
|
this.areaForm.carId="";
|
}
|
this.$refs.areaForm.validate((valid) => {
|
if (valid) {
|
if (this.modalType == 0) {
|
// 添加
|
this.submitLoading = true;
|
addArea(this.areaForm).then((res) => {
|
this.submitLoading = false;
|
if (res.success) {
|
this.$Message.success("操作成功");
|
this.getDataList();
|
this.roleModalVisible = false;
|
this.areaForm={};
|
}
|
});
|
} else {
|
this.submitLoading = true;
|
this.$delete(this.areaForm,'children')
|
addArea(this.areaForm).then((res) => {
|
this.submitLoading = false;
|
if (res.success) {
|
this.$Message.success("操作成功");
|
this.getDataList();
|
this.roleModalVisible = false;
|
this.areaForm={};
|
}
|
});
|
}
|
}
|
});
|
},
|
submitCustomer() {
|
this.$refs.areaSectionForm.validate((valid) => {
|
//this.customerForm.lastTime = this.lastTime;
|
this.customerForm.areaSectionId = this.areaSectionId;
|
this.customerForm.areaId = this.areaId;
|
|
if (valid) {
|
this.$delete(this.customerForm,'receives')
|
if (this.modalType == 0) {
|
// 添加
|
this.submitLoading = true;
|
this.customerForm.kstatus = 0;
|
addCustomer(this.customerForm).then((res) => {
|
this.submitLoading = false;
|
if (res.success) {
|
this.$Message.success("操作成功");
|
this.addCustomerVisible = false;
|
this.getCustomerList(this.areaSectionId);
|
}
|
});
|
} else {
|
this.submitLoading = true;
|
addCustomer(this.customerForm).then((res) => {
|
this.submitLoading = false;
|
if (res.success) {
|
this.$Message.success("操作成功");
|
this.getCustomerList(this.areaSectionId);
|
this.addCustomerVisible = false;
|
}
|
});
|
}
|
}
|
|
});
|
},
|
submitEquipment() {
|
this.$refs.areaSectionForm.validate((valid) => {
|
this.areaSectionForm.areaId = this.areaId;
|
if (valid) {
|
if (this.modalType == 0) {
|
// 添加
|
this.submitLoading = true;
|
addAreaSection(this.areaSectionForm).then((res) => {
|
this.submitLoading = false;
|
if (res.success) {
|
this.$Message.success("操作成功");
|
this.addEquipmentVisible = false;
|
this.getAreaSectionList(this.areaId);
|
}
|
});
|
} else {
|
this.submitLoading = true;
|
addAreaSection(this.areaSectionForm).then((res) => {
|
this.submitLoading = false;
|
if (res.success) {
|
this.$Message.success("操作成功");
|
this.getAreaSectionList(this.areaId);
|
this.addEquipmentVisible = false;
|
}
|
});
|
}
|
}
|
|
});
|
},
|
submitRemove(){
|
this.$refs.removeForm.validate((valid) => {
|
if (valid) {
|
this.submitLoading = true;
|
editCar(this.removeForm).then((res) => {
|
this.submitLoading = false;
|
if (res.success) {
|
this.$Message.success("操作成功");
|
this.getDataList();
|
this.carModalVisible = false;
|
}
|
});
|
}
|
});
|
},
|
equipment(row) {
|
this.areaId = row.id
|
this.getAreaSectionList2(row.id);
|
this.modalType = 0;
|
this.modalTitle2 = "片区段信息";
|
this.$refs.areaForm.resetFields();
|
delete this.areaForm.id;
|
this.equipmentVisible = true;
|
},
|
area(row) {
|
this.areaSectionId = row.id
|
this.getCustomerList(row.id);
|
this.modalType = 0;
|
this.modalTitle3 = "商户信息";
|
this.$refs.areaForm.resetFields();
|
delete this.areaForm.id;
|
this.customerVisible = true;
|
console.log(this.areaSectionId);
|
},
|
addCar() {
|
//this.getAllUser();
|
this.getAllCar();
|
this.modalType = 0;
|
this.modalTitle = "添加";
|
this.$refs.areaForm.resetFields();
|
delete this.areaForm.id;
|
this.roleModalVisible = true;
|
},
|
addEquipment() {
|
this.areaSectionForm={};
|
this.modalType = 0;
|
this.modalTitle = "添加";
|
this.$refs.areaForm.resetFields();
|
delete this.areaForm.id;
|
this.addEquipmentVisible = true;
|
},
|
addCustomer() {
|
this.customerForm={};
|
this.modalType = 0;
|
this.modalTitle = "添加";
|
this.$refs.areaForm.resetFields();
|
delete this.areaForm.id;
|
this.addCustomerVisible = true;
|
},
|
edit(v) {
|
//this.getAllUser();
|
this.getAllCar()
|
this.modalType = 1;
|
this.modalTitle = "编辑";
|
this.$refs.areaForm.resetFields();
|
// 转换null为""
|
for (let attr in v) {
|
if (v[attr] == null) {
|
v[attr] = "";
|
}
|
}
|
let str = JSON.stringify(v);
|
let roleInfo = JSON.parse(str);
|
this.areaForm = roleInfo;
|
console.log(this.areaForm);
|
this.roleModalVisible = true;
|
},
|
editEquipment(v) {
|
this.modalType = 1;
|
this.modalTitle = "编辑设备";
|
this.$refs.areaSectionForm.resetFields();
|
// 转换null为""
|
for (let attr in v) {
|
if (v[attr] == null) {
|
v[attr] = "";
|
}
|
}
|
let str = JSON.stringify(v);
|
let roleInfo = JSON.parse(str);
|
this.areaSectionForm = roleInfo;
|
this.addEquipmentVisible = true;
|
},
|
editCustomer(v) {
|
this.customerForm.lastTime = this.lastTime;
|
this.modalType = 1;
|
this.modalTitle = "编辑";
|
this.$refs.customerForm.resetFields();
|
// 转换null为""
|
for (let attr in v) {
|
if (v[attr] == null) {
|
v[attr] = "";
|
}
|
}
|
let str = JSON.stringify(v);
|
let roleInfo = JSON.parse(str);
|
this.customerForm = roleInfo;
|
this.addCustomerVisible = true;
|
},
|
bindUser(v) {
|
this.dataType = 0;
|
this.modalTitle = "片区段";
|
this.$refs.areaForm.resetFields();
|
// 转换null为""
|
for (let attr in v) {
|
if (v[attr] == null) {
|
v[attr] = "";
|
}
|
}
|
let str = JSON.stringify(v);
|
let roleInfo = JSON.parse(str);
|
this.removeForm = roleInfo;
|
this.carModalVisible = true;
|
|
},
|
remove(v) {
|
this.$Modal.confirm({
|
title: "确认删除",
|
content: "您确认要删除吗 ",
|
loading: true,
|
onOk: () => {
|
deleteArea({ ids: v.id }).then((res) => {
|
this.$Modal.remove();
|
if (res.success) {
|
this.clearSelectAll();
|
this.$Message.success("删除成功");
|
this.getDataList();
|
}
|
});
|
},
|
});
|
},
|
removeEquipment(v) {
|
this.$Modal.confirm({
|
title: "确认删除",
|
content: "您确认要删除吗 ",
|
loading: true,
|
onOk: () => {
|
deleteAreaSection({ ids: v.id }).then((res) => {
|
this.$Modal.remove();
|
if (res.success) {
|
this.clearSelectAll();
|
this.$Message.success("删除成功");
|
this.getAreaSectionList(this.areaId);
|
}
|
});
|
},
|
});
|
},
|
removeCustomer(v) {
|
this.$Modal.confirm({
|
title: "确认删除",
|
content: "您确认要删除吗 ",
|
loading: true,
|
onOk: () => {
|
deleteCustomer({ ids: v.id }).then((res) => {
|
this.$Modal.remove();
|
if (res.success) {
|
this.clearSelectAll();
|
this.$Message.success("删除成功");
|
this.getCustomerList(this.areaSectionId);
|
}
|
});
|
},
|
});
|
},
|
setDefault(v) {
|
this.loading = true;
|
let params = {
|
id: v.id,
|
isDefault: true,
|
};
|
setDefaultRole(params).then((res) => {
|
this.loading = false;
|
if (res.success) {
|
this.$Message.success("操作成功");
|
this.getDataList();
|
}
|
});
|
},
|
cancelDefault(v) {
|
this.loading = true;
|
let params = {
|
id: v.id,
|
isDefault: false,
|
};
|
setDefaultRole(params).then((res) => {
|
this.loading = false;
|
if (res.success) {
|
this.$Message.success("操作成功");
|
this.getDataList();
|
}
|
});
|
},
|
clearSelectAll() {
|
this.$refs.table.selectAll(false);
|
},
|
changeSelect(e) {
|
this.selectList = e;
|
},
|
delAll() {
|
if (this.selectList.length <= 0) {
|
this.$Message.warning("您还未选择要删除的数据");
|
return;
|
}
|
this.$Modal.confirm({
|
title: "确认删除",
|
content: "您确认要删除所选的 " + this.selectList.length + " 条数据?",
|
loading: true,
|
onOk: () => {
|
let ids = "";
|
this.selectList.forEach(function (e) {
|
ids += e.id + ",";
|
});
|
ids = ids.substring(0, ids.length - 1);
|
deleteCar({ ids: ids }).then((res) => {
|
this.$Modal.remove();
|
if (res.success) {
|
this.$Message.success("删除成功");
|
this.clearSelectAll();
|
this.getDataList();
|
}
|
});
|
},
|
});
|
},
|
editPerm(v) {
|
this.editRolePermId = v.id;
|
this.modalTitle = "分配 " + v.name + " 的菜单权限";
|
// 匹配勾选
|
let rolePerms = v.permissions;
|
if (this.treeLoading) {
|
this.$Message.warning("菜单权限数据加载中,请稍后点击查看");
|
return;
|
}
|
// 递归判断子节点
|
this.checkPermTree(this.permData, rolePerms);
|
this.permModalVisible = true;
|
},
|
// 递归判断子节点
|
checkPermTree(permData, rolePerms) {
|
let that = this;
|
permData.forEach(function (p) {
|
if (that.hasPerm(p, rolePerms) && p.status != -1) {
|
p.checked = true;
|
} else {
|
p.checked = false;
|
}
|
if (p.children && p.children.length > 0) {
|
that.checkPermTree(p.children, rolePerms);
|
}
|
});
|
},
|
// 判断角色拥有的权限节点勾选
|
hasPerm(p, rolePerms) {
|
let flag = false;
|
for (let i = 0; i < rolePerms.length; i++) {
|
if (p.id == rolePerms[i].permissionId) {
|
flag = true;
|
break;
|
}
|
}
|
if (flag) {
|
return true;
|
}
|
return false;
|
},
|
// 全选反选
|
selectTreeAll() {
|
this.selectAllFlag = !this.selectAllFlag;
|
let select = this.selectAllFlag;
|
this.selectedTreeAll(this.permData, select);
|
},
|
// 递归全选节点
|
selectedTreeAll(permData, select) {
|
let that = this;
|
permData.forEach(function (e) {
|
e.checked = select;
|
if (e.children && e.children.length > 0) {
|
that.selectedTreeAll(e.children, select);
|
}
|
});
|
},
|
submitPermEdit() {
|
this.submitPermLoading = true;
|
let permIds = "";
|
let selectedNodes = this.$refs.tree.getCheckedNodes();
|
selectedNodes.forEach(function (e) {
|
permIds += e.id + ",";
|
});
|
permIds = permIds.substring(0, permIds.length - 1);
|
editRolePerm({
|
roleId: this.editRolePermId,
|
permIds: permIds,
|
}).then((res) => {
|
this.submitPermLoading = false;
|
if (res.success) {
|
this.$Message.success("操作成功");
|
// 标记重新获取菜单数据
|
this.$store.commit("setAdded", false);
|
util.initRouter(this);
|
this.getDataList();
|
this.permModalVisible = false;
|
}
|
});
|
},
|
cancelPermEdit() {
|
this.permModalVisible = false;
|
},
|
loadData(item, callback) {
|
loadDepartment(item.id, { openDataFilter: false }).then((res) => {
|
if (res.success) {
|
res.result.forEach(function (e) {
|
e.selected = false;
|
if (e.isParent) {
|
e.loading = false;
|
e.children = [];
|
}
|
if (e.status == -1) {
|
e.title = "[已禁用] " + e.title;
|
e.disabled = true;
|
}
|
});
|
callback(res.result);
|
}
|
});
|
},
|
expandCheckDep(v) {
|
// 判断展开子节点
|
this.checkDepTree(v.children, this.editDepartments);
|
},
|
// 判断子节点
|
checkDepTree(depData, roleDepIds) {
|
let that = this;
|
depData.forEach(function (p) {
|
if (that.hasDepPerm(p, roleDepIds)) {
|
p.selected = true;
|
} else {
|
p.selected = false;
|
}
|
});
|
},
|
// 判断角色拥有的权限节点勾选
|
hasDepPerm(p, roleDepIds) {
|
let flag = false;
|
for (let i = 0; i < roleDepIds.length; i++) {
|
if (p.id == roleDepIds[i].departmentId) {
|
flag = true;
|
break;
|
}
|
}
|
if (flag) {
|
return true;
|
}
|
return false;
|
},
|
submitDepEdit() {
|
let depIds = "";
|
if (this.dataType == 1) {
|
let selectedNodes = this.$refs.depTree.getSelectedNodes();
|
selectedNodes.forEach(function (e) {
|
depIds += e.id + ",";
|
});
|
depIds = depIds.substring(0, depIds.length - 1);
|
}
|
this.submitDepLoading = true;
|
editRoleDep({
|
roleId: this.editRolePermId,
|
dataType: this.dataType,
|
depIds: depIds,
|
}).then((res) => {
|
this.submitDepLoading = false;
|
if (res.success) {
|
this.$Message.success("操作成功");
|
this.getDataList();
|
this.depModalVisible = false;
|
}
|
});
|
},
|
changeOpen(v) {
|
if (v == "0") {
|
this.permData.forEach((e) => {
|
e.expand = true;
|
if (e.children && e.children.length > 0) {
|
e.children.forEach((c) => {
|
c.expand = true;
|
if (c.children && c.children.length > 0) {
|
c.children.forEach(function (b) {
|
b.expand = true;
|
});
|
}
|
});
|
}
|
});
|
} else if (v == "1") {
|
this.permData.forEach((e) => {
|
e.expand = false;
|
if (e.children && e.children.length > 0) {
|
e.children.forEach((c) => {
|
c.expand = false;
|
if (c.children && c.children.length > 0) {
|
c.children.forEach(function (b) {
|
b.expand = false;
|
});
|
}
|
});
|
}
|
});
|
} else if (v == "2") {
|
this.permData.forEach((e) => {
|
e.expand = true;
|
if (e.children && e.children.length > 0) {
|
e.children.forEach((c) => {
|
c.expand = false;
|
if (c.children && c.children.length > 0) {
|
c.children.forEach(function (b) {
|
b.expand = false;
|
});
|
}
|
});
|
}
|
});
|
} else if (v == "3") {
|
this.permData.forEach((e) => {
|
e.expand = true;
|
if (e.children && e.children.length > 0) {
|
e.children.forEach((c) => {
|
c.expand = true;
|
if (c.children && c.children.length > 0) {
|
c.children.forEach(function (b) {
|
b.expand = false;
|
});
|
}
|
});
|
}
|
});
|
}
|
},
|
},
|
mounted() {
|
this.maxHeight = Number(document.documentElement.clientHeight - 121) + "px";
|
this.init();
|
},
|
};
|
</script>
|