From 97e678e54cf2bf66aae0ffd8119da6b01be2aaec Mon Sep 17 00:00:00 2001 From: zhangzeli <123456> Date: 星期一, 08 十一月 2021 08:28:42 +0800 Subject: [PATCH] 车辆 --- src/views/your/area-manage/areaManage.vue | 1288 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/views/your/car-manage/carManage.vue | 25 src/views/your/area-manage/areaManage.less | 13 src/api/open.js | 52 ++ 4 files changed, 1,374 insertions(+), 4 deletions(-) diff --git a/src/api/open.js b/src/api/open.js index b59e538..e749972 100644 --- a/src/api/open.js +++ b/src/api/open.js @@ -110,4 +110,54 @@ // 鍒犻櫎璁惧淇℃伅 export const deleteEquipment = (params) => { return postRequest('/equipment/delByIds', params) -} \ No newline at end of file +} + +// 鏌ヨ鐢ㄦ埛淇℃伅 +export const getUser = (params) => { + return getRequest('/user/getAll', params) +} + +// 鏌ヨ鐗囧尯淇℃伅 +export const getArea = (params) => { + return getRequest('/area/getByPage', params) +} + +// 娣诲姞閰嶉�佺墖鍖轰俊鎭� +export const addArea = (params) => { + return postRequest('/area/insertOrUpdate', params) +} + +// 鍒犻櫎閰嶉�佺墖鍖轰俊鎭� +export const deleteArea = (params) => { + return postRequest('/area/delByIds', params) +} + +// 鏌ヨ鐗囧尯淇℃伅 +export const getAreaSection = (params) => { + return getRequest('/areaSection/getByPage', params) +} + +//娣诲姞鐗囧尯娈典俊鎭� +export const addAreaSection = (params) => { + return postRequest('/areaSection/insertOrUpdate', params) +} + +// 鍒犻櫎閰嶉�佺墖鍖轰俊鎭� +export const deleteAreaSection = (params) => { + return postRequest('/areaSection/delByIds', params) +} + +// 鏌ヨ鐗囧尯淇℃伅 +export const getCustomer = (params) => { + return getRequest('/customer/getByPage', params) +} + +//娣诲姞鍟嗘埛淇℃伅 +export const addCustomer = (params) => { + return postRequest('/customer/insertOrUpdate', params) +} + +// 鍒犻櫎鍟嗘埛淇℃伅 +export const deleteCustomer = (params) => { + return postRequest('/customer/delByIds', params) +} diff --git a/src/views/your/area-manage/areaManage.less b/src/views/your/area-manage/areaManage.less new file mode 100644 index 0000000..789f8db --- /dev/null +++ b/src/views/your/area-manage/areaManage.less @@ -0,0 +1,13 @@ +.permModal { + .ivu-modal-body { + max-height: 560px; + overflow: auto; + } +} + +.depModal { + .ivu-modal-body { + max-height: 500px; + overflow: auto; + } +} \ No newline at end of file diff --git a/src/views/your/area-manage/areaManage.vue b/src/views/your/area-manage/areaManage.vue new file mode 100644 index 0000000..d3dd999 --- /dev/null +++ b/src/views/your/area-manage/areaManage.vue @@ -0,0 +1,1288 @@ +<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="searchForm.name" + suffix="ios-search" + @on-change="getDataList" + 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 v-for="item in userList" :value="item.id">{{ item.nickname }}</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" + sortable="custom" @on-sort-change="changeSort" @on-selection-change="changeSelect"> + + + </Table> + </Modal>05 + <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.name" 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="searchForm.pageNumber" :total="total2" + :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> + </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.code" /> + </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="80" :rules="areaSectionFormValidate"> + <FormItem label="鍟嗘埛鍚嶇О" prop="name"> + <Input v-model="customerForm.name" /> + </FormItem> + <FormItem label="鍟嗘埛缂栧彿" prop="code"> + <Input v-model="customerForm.code" /> + </FormItem> + <FormItem label="鑱旂郴鏂瑰紡" prop="phone"> + <Input v-model="customerForm.phone" /> + </FormItem> + <FormItem label="缁忓害" prop="lng"> + <Input v-model="customerForm.lng" /> + </FormItem> + <FormItem label="绾害" prop="lat"> + <Input v-model="customerForm.lat" /> + </FormItem> + <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> + <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, + 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: "", + searchForm: { + // 鎼滅储妗嗗垵濮嬪寲瀵硅薄 + 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, + }, + { + title: "閰嶉�佷汉", + key: "nickName", + 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: "code", + }, + { + 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", + width: 100, + }, + { + title: "鍟嗘埛缂栧彿", + key: "code", + minWidth: 120, + }, + { + title: "鑱旂郴鏂瑰紡", + key: "phone", + width: 140, + }, + { + title: "鐘舵��", + key: "status", + width:100, + sortable: true, + render: (h, params) => { + let re = ""; + if (params.row.status == 0) { + return h("div", [ + h("Badge", { + props: { + status: "success", + text: "姝e父", + }, + }), + ]); + } else if (params.row.status == 1) { + return h("div", [ + h("Badge", { + props: { + status: "error", + text: "涓嶆椿璺�", + }, + }), + ]); + } + }, + }, + { + title: "涓婃閰嶉�佹棩鏈�", + key: "lastTime", + width: 150, + }, + { + title: "鍟嗘埛娉ㄥ唽鍦板潃", + key: "registeredAddress", + width: 180, + }, + { + 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, + + 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(); + }, + 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; + } + }); + }, + getCustList() { + this.loading = true; + getCustomer(this.searchForm).then((res) => { + this.loading = false; + if (res.success) { + this.data3 = res.result.records; + this.total2 = res.result.total; + } + }); + }, + getAllUser(){ + getUser().then((res)=>{ + if (res.success){ + this.userList=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; + } + }); + }, + 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() { + 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; + } + }); + } else { + this.submitLoading = true; + addArea(this.areaForm).then((res) => { + this.submitLoading = false; + if (res.success) { + this.$Message.success("鎿嶄綔鎴愬姛"); + this.getDataList(); + this.roleModalVisible = false; + } + }); + } + } + }); + }, + submitCustomer() { + this.$refs.areaSectionForm.validate((valid) => { + this.customerForm.lastTime = this.lastTime; + this.customerForm.areaSectionId = this.areaSectionId; + if (valid) { + if (this.modalType == 0) { + // 娣诲姞 + this.submitLoading = true; + 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.getAreaSectionList(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; + }, + addCar() { + this.getAllUser(); + 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.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; + 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> \ No newline at end of file diff --git a/src/views/your/car-manage/carManage.vue b/src/views/your/car-manage/carManage.vue index 0ef24a5..0af821c 100644 --- a/src/views/your/car-manage/carManage.vue +++ b/src/views/your/car-manage/carManage.vue @@ -81,7 +81,16 @@ <FormItem label="鐗岀収" prop="carNo"> <Input v-model="carForm.carNo" /> </FormItem> - + <FormItem label="椹鹃┒浜�" prop="userId"> + <Select v-model="carForm.userId" filterable> + <Option v-for="item in userList" :value="item.id">{{ item.nickname }}</Option> + </Select> + </FormItem> + <FormItem label="璺熻溅浜�" prop="followUserId"> + <Select v-model="carForm.followUserId" filterable> + <Option v-for="item in userList" :value="item.id">{{ item.nickname }}</Option> + </Select> + </FormItem> </Form> <div slot="footer"> <Button type="text" @click="carRole">鍙栨秷</Button> @@ -234,6 +243,7 @@ deleteCar, getEquipment, addEquipment, + getUser, deleteEquipment, } from "@/api/open"; import util from "@/libs/util.js"; @@ -572,10 +582,12 @@ depData: [], dataType: 0, carId: '', + userList: [], editDepartments: [], buyYear:'' }; }, + methods: { change1(e){ this.buyYear = e; @@ -583,7 +595,6 @@ init() { this.getDataList(); // 鑾峰彇鎵�鏈夎彍鍗曟潈闄愭爲 - this.getPermList(); }, renderContent(h, { root, node, data }) { let icon = ""; @@ -639,6 +650,13 @@ changePageSize(v) { this.searchForm.pageSize = v; this.getDataList(); + }, + getAllUser(){ + getUser().then((res)=>{ + if (res.success){ + this.userList=res.result; + } + }); }, changeSort(e) { this.searchForm.sort = e.key; @@ -780,6 +798,7 @@ this.equipmentVisible = true; }, addCar() { + this.getAllUser(); this.modalType = 0; this.modalTitle = "娣诲姞杞﹁締"; this.$refs.carForm.resetFields(); @@ -797,7 +816,7 @@ edit(v) { this.buyYear = v.buyYear; this.modalType = 1; - this.modalTitle = "缂栬緫瑙掕壊"; + this.modalTitle = "缂栬緫"; this.$refs.carForm.resetFields(); // 杞崲null涓�"" for (let attr in v) { -- Gitblit v1.9.1