From cfce577132832b5291c5bd3b171d7f4397d44643 Mon Sep 17 00:00:00 2001
From: 819527061@qq.com <123456>
Date: 星期二, 14 五月 2024 17:06:53 +0800
Subject: [PATCH] docs:参数加密

---
 src/views/your/sign-manage/signManage.vue | 1254 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1,254 insertions(+), 0 deletions(-)

diff --git a/src/views/your/sign-manage/signManage.vue b/src/views/your/sign-manage/signManage.vue
new file mode 100644
index 0000000..b4ef75c
--- /dev/null
+++ b/src/views/your/sign-manage/signManage.vue
@@ -0,0 +1,1254 @@
+<style lang="less">
+@import "@/styles/table-common.less";
+@import "@/styles/drawer-common.less";
+@import "./signManage.less";
+</style>
+<template>
+  <div class="search">
+    <Card>
+      <Row class="operation">
+        <Date-picker v-model="value" @on-change="getDataByDate" value-format="yyyy-MM-dd" type="daterange"
+                     placement="bottom-start" placeholder="璇烽�夋嫨鏃ユ湡"
+                     style="width: 240px;padding-left: 20px;margin-right: 20px">
+        </Date-picker>
+        <Input v-model="carNo" suffix="ios-search" @on-change="getSign" placeholder="杈撳叆杞︾墝鍙锋悳绱�" clearable
+               style="width: 250px;margin-right: 20px"/>
+        <Input v-model="line" suffix="ios-search" @on-change="getSign" placeholder="杈撳叆鍖哄煙鎼滅储" clearable
+               style="width: 250px"/>
+        <Button @click="exportExcel" class="init-button export-button">瀵煎嚭鏁版嵁</Button>
+        <!-- <Button @click="exportAllExcel" class="init-button export-button">瀵煎嚭鍏ㄩ儴鏁版嵁</Button> -->
+        <Button @click="init" icon="md-refresh" class="init-button">鍒锋柊</Button>
+        <Button type="dashed" @click="openTip = !openTip">{{
+            openTip ? "鍏抽棴鎻愮ず" : "寮�鍚彁绀�"
+          }}
+        </Button>
+      </Row>
+      <Alert show-icon v-show="openTip">
+        宸查�夋嫨
+        <span class="select-count">{{ selectList.length }}</span> 椤�
+        <a class="select-clear" @click="clearSelectAll">娓呯┖</a>
+      </Alert>
+      <!-- 绛炬敹鐜囩殑琛� -->
+      <div>
+        <Table :loading="loading" border :columns="columns" :data="data" ref="table" sortable="custom"
+               :span-method="handleSpan" @on-sort-change="changeSort" @on-selection-change="changeSelect"
+               height="615"></Table>
+      </div>
+      <div>
+        <Row type="flex" justify="end" class="page">
+          <Page :current="pageNum" :total="total" :page-size="pageSize" @on-change="changePage"
+                @on-page-size-change="changePageSize" :page-size-opts="[60, 120]" size="small" show-total show-elevator
+                show-sizer></Page>
+        </Row>
+      </div>
+    </Card>
+
+    <!-- 缂栬緫 -->
+    <Modal :title="modalTitle" v-model="roleModalVisible" :mask-closable="false" :width="500">
+      <Form ref="carForm" :model="carForm" :label-width="80" :rules="carFormValidate">
+        <FormItem label="鍝佺墝" prop="brand">
+          <Input v-model="carForm.brand"/>
+        </FormItem>
+        <FormItem label="鍨嬪彿" prop="model">
+          <Input v-model="carForm.model"/>
+        </FormItem>
+        <FormItem label="鎺掗噺" prop="displacement">
+          <Input v-model="carForm.displacement"/>
+        </FormItem>
+        <Form-item label="璐疆骞翠唤">
+          <Row>
+            <Col span="11">
+              <Date-picker @on-change="change1" type="date" value="yyyy-MM-dd" placeholder="閫夋嫨鏃ユ湡"
+                           v-model="carForm.buyYear"></Date-picker>
+            </Col>
+          </Row>
+        </Form-item>
+        <FormItem label="鐗岀収" prop="carNo">
+          <Input v-model="carForm.carNo"/>
+        </FormItem>
+        <FormItem label="鍔犳补鍗″彿" prop="addOilCode">
+          <Input v-model="carForm.addOilCode"/>
+        </FormItem>
+        <FormItem label="杞﹁締缂栧彿" prop="code">
+          <Input v-model="carForm.code"/>
+        </FormItem>
+        <FormItem label="鍙告満" prop="userId">
+          <Select v-model="carForm.userId" filterable>
+            <Option :value="0">璇烽�夋嫨</Option>
+            <Option v-for="item in userList" :value="item.id" :key="item.id">{{ item.nickname }}</Option>
+          </Select>
+        </FormItem>
+        <FormItem label="閰嶉�佸憳" prop="followUserId">
+          <Select v-model="carForm.followUserId" filterable>
+            <Option :value="0" :key="0">璇烽�夋嫨</Option>
+            <Option v-for="item in driverList" :value="item.id" :key="item.id">{{ item.nickname }}</Option>
+          </Select>
+        </FormItem>
+      </Form>
+      <div slot="footer">
+        <Button type="text" @click="carRole">鍙栨秷</Button>
+        <Button type="primary" :loading="submitLoading" @click="submitCar">鎻愪氦
+        </Button>
+      </div>
+    </Modal>
+    <Modal :title="modalTitle" v-model="equipmentVisible" :mask-closable="false" :width="1044">
+      <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>
+    <Modal :title="modalTitle" v-model="addEquipmentVisible" :mask-closable="false" :width="500">
+      <Form ref="equipmentForm" :model="equipmentForm" :label-width="80" :rules="equipmentFormValidate">
+        <FormItem label="璁惧绫诲瀷" prop="type">
+          <Select v-model="equipmentForm.type">
+            <Option :value="0">杞︽満</Option>
+            <Option :value="1">鎽勫儚鏈�</Option>
+            <Option :value="2">鎶撴媿鏈�</Option>
+            <Option :value="3">pad</Option>
+          </Select>
+        </FormItem>
+        <FormItem label="鐘舵��" prop="status">
+          <Select v-model="equipmentForm.status">
+            <Option :value="0">姝e父</Option>
+            <Option :value="1">寮傚父</Option>
+          </Select>
+        </FormItem>
+        <FormItem label="缂栧彿" prop="code">
+          <Input v-model="equipmentForm.code"/>
+        </FormItem>
+        <FormItem label="ip鍦板潃" prop="ip">
+          <Input v-model="equipmentForm.ip"/>
+        </FormItem>
+        <FormItem label="绔彛鍙�" prop="port">
+          <Input v-model="equipmentForm.port"/>
+        </FormItem>
+
+      </Form>
+      <div slot="footer">
+        <Button type="text" @click="carRole">鍙栨秷</Button>
+        <Button type="primary" :loading="submitLoading" @click="submitEquipment">鎻愪氦
+        </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 {editRoleDep, editRolePerm, getAllPermissionList, loadDepartment, setDefaultRole,} from "@/api/index";
+
+import {
+  addCar,
+  addEquipment,
+  deleteCar,
+  deleteEquipment,
+  editCar,
+  getDriver,
+  getEquipment,
+  getNewSignList,
+  outExcel
+} 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,
+      equipmentVisible: false,
+      carModalVisible: false,
+      permModalVisible: false,
+      depModalVisible: false,
+      modalTitle: "",
+      searchForm: {
+        // 鎼滅储妗嗗垵濮嬪寲瀵硅薄
+        pageNumber: 1, // 褰撳墠椤垫暟
+        pageSize: 60, // 椤甸潰澶у皬
+        sort: "createTime", // 榛樿鎺掑簭瀛楁
+        order: "desc", // 榛樿鎺掑簭鏂瑰紡
+        key: "",
+      },
+      carForm: {
+        status: 0
+      },
+      type: {
+        type: 0
+      },
+      equipmentForm: {
+        status: 0
+      },
+      removeForm: {
+        status: 1
+      },
+      carFormValidate: {
+        name: [
+          {required: true, message: "瑙掕壊鍚嶇О涓嶈兘涓虹┖", trigger: "change"},
+        ],
+      },
+      submitLoading: false,
+      selectList: [],
+      columns: [
+        {
+          type: "selection",
+          width: 60,
+          align: "center",
+        },
+        {
+          type: "index",
+          title: "搴忓彿",
+          width: 80,
+          align: "center",
+        },
+        {
+          title: "杞︾墝鍙�",
+          key: "carName",
+          width: 120,
+          align: "center",
+        },
+        {
+          title: "鍙告満",
+          key: "userName",
+          width: 100,
+          align: "center",
+        },
+        {
+          title: "鍖哄煙",
+          key: "line",
+          width: 100,
+          align: "center",
+        },
+        {
+          title: "01娈�",
+          key: "oneBatch",
+          minWidth: 140,
+          align: "center",
+
+        },
+        {
+          title: "02娈�",
+          key: "twoBatch",
+          minWidth: 140,
+          align: "center",
+        },
+        {
+          title: "03娈�",
+          key: "threeBatch",
+          minWidth: 140,
+          align: "center",
+        },
+        {
+          title: "04娈�",
+          key: "fourBatch",
+          minWidth: 140,
+          align: "center",
+          tooltip: true,
+        },
+        {
+          title: "05娈�",
+          key: "fiveBatch",
+          minWidth: 140,
+          align: "center",
+        },
+        {
+          title: "鎬�(骞冲潎)绛炬敹鐜�",
+          key: "sendMonth",
+          minWidth: 140,
+          align: "center",
+        }
+      ],
+      columns2: [
+        {
+          type: "selection",
+          width: 60,
+          align: "center",
+        },
+        {
+          type: "index",
+          width: 60,
+          align: "center",
+        },
+        {
+          title: "璁惧绫诲瀷",
+          key: "type",
+          width: 130,
+          sortable: true,
+          render: (h, params) => {
+            let re = "";
+            if (params.row.type == 0) {
+              return h("div", [
+                h("Badge", {
+                  props: {
+                    text: "杞︽満",
+                  },
+                }),
+              ]);
+            } else if (params.row.type == 1) {
+              return h("div", [
+                h("Badge", {
+                  props: {
+                    text: "鎽勫儚鏈�",
+                  },
+                }),
+              ]);
+            } else if (params.row.type == 2) {
+              return h("div", [
+                h("Badge", {
+                  props: {
+                    text: "鎶撴媿鏈�",
+                  },
+                }),
+              ]);
+            } else if (params.row.type == 3) {
+              return h("div", [
+                h("Badge", {
+                  props: {
+                    text: "pad",
+                  },
+                }),
+              ]);
+            }
+          },
+        },
+        {
+          title: "缂栧彿",
+          key: "code",
+          width: 120,
+        },
+        {
+          title: "鐘舵��",
+          key: "status",
+          width: 120,
+          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: "ip鍦板潃",
+          key: "ip",
+          width: 120,
+        },
+        {
+          title: "绔彛鍙�",
+          key: "port",
+          width: 120,
+          sortable: true,
+        },
+        {
+          title: "鎿嶄綔",
+          key: "action",
+          align: "center",
+          width: 280,
+          render: (h, params) => {
+            return h("div", [
+              h(
+                  "a",
+                  {
+                    on: {
+                      click: () => {
+                        this.editEquipment(params.row);
+                      },
+                    },
+                  },
+                  "缂栬緫"
+              ),
+              h("Divider", {
+                props: {
+                  type: "vertical",
+                },
+              }),
+              h(
+                  "a",
+                  {
+                    on: {
+                      click: () => {
+                        this.removeEquipment(params.row);
+                      },
+                    },
+                  },
+                  "鍒犻櫎"
+              ),
+            ]);
+          },
+        },
+      ],
+      data: [],
+      data2: [],
+      total: 0,
+      total2: 0,
+      totalmonth: 0,
+      permData: [],
+      editRolePermId: "",
+      selectAllFlag: false,
+      depData: [],
+      dataType: 0,
+      carId: '',
+      driverList: [],
+      userList: [],
+      editDepartments: [],
+      buyYear: '',
+      //閫夋嫨鏃ユ湡
+      value: [],
+      //  椤电爜
+      pageNum: 1,
+      // 姣忛〉鏉℃暟
+      pageSize: 60,
+      // 杞︾墝鍙�
+      carNo: "",
+      // 绾胯矾
+      line: "",
+      // 寮�濮嬫棩鏈�
+      beginTime: "",
+      // 缁撴潫鏃ユ湡
+      endTime: "",
+      // 鎸夋湀鏌ヨ鐨刣ata
+      // monthData: [],
+      // 瀵煎嚭鐨勬暟鎹�
+      exportData: "",
+      dateOption: {
+        disabledDate(date) {
+          const now = new Date();
+          const year = now.getFullYear();
+          const month = now.getMonth();
+          return date.getFullYear() !== year || date.getMonth() !== month;
+        }
+      }
+    };
+  },
+  computed: {
+    firstDate() {
+      let y = new Date().getFullYear(); //鑾峰彇骞翠唤
+      let m = new Date().getMonth() + 1; //鑾峰彇鏈堜唤
+      let d = '01';
+      m = m < 10 ? '0' + m : m; //鏈堜唤琛� 0
+      return [y, m, d].join('-')
+    },
+    lastDate() {
+      let y = new Date().getFullYear(); //鑾峰彇骞翠唤
+      let m = new Date().getMonth() + 1; //鑾峰彇鏈堜唤
+      let d = new Date(y, m, 0).getDate(); //鑾峰彇褰撴湀鏈�鍚庝竴鏃�
+      m = m < 10 ? '0' + m : m; //鏈堜唤琛� 0
+      d = d < 10 ? '0' + d : d; //鏃ユ暟琛� 0
+      return [y, m, d].join('-')
+    },
+  },
+  created() {
+    this.beginTime = this.firstDate
+    this.endTime = this.lastDate
+    this.value = [this.firstDate, this.lastDate]
+    //璇锋眰鏁版嵁
+    this.getSign()
+  },
+  methods: {
+    getSign() {
+      this.loading = true;
+      getNewSignList(this.pageNum, this.pageSize, this.carNo, this.beginTime, this.endTime, this.line, '', '', '').then(result => {
+        this.loading = false;
+        if (result.success) {
+          let reg = /\d/g;
+          this.data = result.result.records.map(v => {
+            return {
+              ...v,
+              sendMonth: v.sendMonth.length >= 6 ? v.sendMonth.slice(0, 5) + '%' : v.sendMonth,
+              proportion: v.proportion.length >= 6 ? v.proportion.slice(0, 5) + '%' : v.proportion,
+              line: v.line.replace(reg, '').replace('杞�', '')
+            }
+          })
+          this.total = result.result.total;
+          this.data = this.merge(this.data)
+
+        }
+      })
+    },
+    merge(data) {
+      return Object.values(data.reduce((acc, cur) => {
+        if (!acc[cur.userName]) {
+          acc[cur.userName] = [cur];
+        } else {
+          acc[cur.userName].push(cur);
+        }
+        return acc;
+      }, {})).map(group => {
+        return group.reduce((acc, cur) => {
+          acc.sendMonth = cur.sendMonth;
+          acc.carName = cur.carName;
+          acc.line = cur.line
+          if (cur.oneBatch) {
+            acc.oneBatch = cur.proportion;
+          }
+          if (cur.twoBatch) {
+            acc.twoBatch = cur.proportion;
+          }
+          if (cur.threeBatch) {
+            acc.threeBatch = cur.proportion;
+          }
+          if (cur.fourBatch) {
+            acc.fourBatch = cur.proportion;
+          }
+          if (cur.fiveBatch) {
+            acc.fiveBatch = cur.proportion;
+          }
+          return acc;
+        }, {userName: group[0].userName});
+      });
+
+    },
+    handleSummary({columns, data}) {
+      const sums = {};
+      columns.forEach((column, index) => {
+        const key = column.key;
+        if (index === 0) {
+          sums[key] = {
+            key,
+            value: '鎬讳环'
+          };
+          return;
+        }
+        const values = data.map(item => Number(item[key]));
+        if (!values.every(value => isNaN(value))) {
+          const v = values.reduce((prev, curr) => {
+            const value = Number(curr);
+            if (!isNaN(value)) {
+              return prev + curr;
+            } else {
+              return prev;
+            }
+          }, 0);
+          sums[key] = {
+            key,
+            value: v + ' 鍏�'
+          };
+        } else {
+          sums[key] = {
+            key,
+            value: 'N/A'
+          };
+        }
+      });
+      console.log(sums)
+      return sums;
+    },
+    // 瀵煎嚭涓篹xcel
+    exportExcel() {
+      outExcel(this.pageNum, this.pageSize, this.carNo, this.beginTime, this.endTime, this.line).then((res) => {
+        let blob = new Blob([res], {type: 'application/vnd.ms-excel'});
+        let url = URL.createObjectURL(blob);
+        const link = document.createElement('a'); //鍒涘缓a鏍囩
+        link.href = url;
+        link.download = '閰嶉�佷俊鎭�.xlsx'; //閲嶅懡鍚嶆枃浠�
+        link.click();
+        URL.revokeObjectURL(url);
+      })
+    },
+    handleSpan({row, column, rowIndex, columnIndex}) {
+      if (rowIndex || !rowIndex) {
+        return {}
+      }
+    },
+    change1(e) {
+      this.buyYear = e;
+    },
+    init() {
+      this.getDataList();
+      // 鑾峰彇鎵�鏈夎彍鍗曟潈闄愭爲
+    },
+    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.loading = true;
+      this.pageNum = v
+      this.getSign();
+      this.clearSelectAll();
+    },
+    changePageSize(v) {
+      this.loading = true;
+      this.pageSize = v;
+      this.getSign();
+    },
+    getAllUser() {
+      getDriver({type: 0}).then((res) => {
+        if (res.success) {
+          this.userList = res.result;
+        }
+      });
+      //this.type.type=1;
+      getDriver({type: 1}).then((res) => {
+        if (res.success) {
+          this.driverList = res.result;
+        }
+      });
+      this.type.type = 0;
+      console.log(this.userList);
+      console.log(this.driverList);
+    },
+    changeSort(e) {
+      this.searchForm.sort = e.key;
+      this.searchForm.order = e.order;
+      if (e.order == "normal") {
+        this.searchForm.order = "";
+      }
+      this.getDataList();
+    },
+    //鏍煎紡鍖栨椂闂�
+    selectDate(dateData) {
+      let date = new Date(dateData)
+      let y = date.getFullYear()
+      let m = date.getMonth() + 1
+      m = m < 10 ? ('0' + m) : m
+      let d = date.getDate()
+      d = d < 10 ? ('0' + d) : d
+      return y + '-' + m + '-' + d
+    },
+    //鏍规嵁閫夋嫨鐨勬棩鏈熻繑鍥炴暟鎹�
+    getDataByDate() {
+      this.loading = true;
+      if (this.value[0] != "" && this.value[1] != "") {
+        console.log(this.value)
+        this.beginTime = this.selectDate(this.value[0]);
+        this.endTime = this.selectDate(this.value[1]);
+      } else {
+        this.beginTime = this.firstDate;
+        this.endTime = this.lastDate;
+        this.value = [this.firstDate, this.lastDate]
+      }
+      this.getSign();
+    },
+    // 鑾峰彇琛ㄦ牸鏁版嵁
+    getDataList() {
+      // this.loading = true;
+      // getCarList(this.searchForm).then((res) => {
+      //   this.loading = false;
+      //   if (res.success) {
+      //     console.log(res)
+      //     this.data = res.result.records;
+      //     this.total = res.result.total;
+      //   }
+      // });
+    },
+    getEquipmentList(carId) {
+      this.loading = true;
+      this.searchForm.carId = carId;
+      getEquipment(this.searchForm).then((res) => {
+        this.loading = false;
+        if (res.success) {
+          this.data2 = res.result.records;
+        }
+      });
+    },
+    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;
+    },
+    submitCar() {
+      if (this.carForm.userId == undefined || this.carForm.userId == 0) {
+        this.carForm.userId = "";
+      }
+      if (this.carForm.followUserId == undefined || this.carForm.followUserId == 0) {
+        this.carForm.followUserId = "";
+      }
+      this.carForm.buyYear = this.buyYear;
+      this.$refs.carForm.validate((valid) => {
+        if (valid) {
+          if (this.modalType == 0) {
+            // 娣诲姞
+            this.submitLoading = true;
+            addCar(this.carForm).then((res) => {
+              this.submitLoading = false;
+              if (res.success) {
+                this.$Message.success("鎿嶄綔鎴愬姛");
+                this.getDataList();
+                this.roleModalVisible = false;
+              }
+            });
+          } else {
+            this.submitLoading = true;
+            editCar(this.carForm).then((res) => {
+              this.submitLoading = false;
+              if (res.success) {
+                this.$Message.success("鎿嶄綔鎴愬姛");
+                this.getDataList();
+                this.roleModalVisible = false;
+              }
+            });
+          }
+        }
+      });
+    },
+    submitEquipment() {
+      this.$refs.equipmentForm.validate((valid) => {
+        this.equipmentForm.carId = this.carId;
+        if (valid) {
+          if (this.modalType == 0) {
+            // 娣诲姞
+            this.submitLoading = true;
+            addEquipment(this.equipmentForm).then((res) => {
+              this.submitLoading = false;
+              if (res.success) {
+                this.$Message.success("鎿嶄綔鎴愬姛");
+                this.getEquipmentList(this.carId);
+                this.addEquipmentVisible = false;
+                this.getEquipmentList(this.carId);
+              }
+            });
+          } else {
+            this.submitLoading = true;
+            addEquipment(this.equipmentForm).then((res) => {
+              this.submitLoading = false;
+              if (res.success) {
+                this.$Message.success("鎿嶄綔鎴愬姛");
+                this.getEquipmentList(this.carId);
+                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.carId = row.id
+      this.getEquipmentList(row.id);
+      this.modalType = 0;
+      this.modalTitle = "璁惧淇℃伅";
+      this.$refs.carForm.resetFields();
+      delete this.carForm.id;
+      this.equipmentVisible = true;
+    },
+    addCar() {
+      this.carForm = {};
+      this.getAllUser();
+      this.modalType = 0;
+      this.modalTitle = "娣诲姞杞﹁締";
+      this.$refs.carForm.resetFields();
+      delete this.carForm.id;
+      this.roleModalVisible = true;
+    },
+    addEquipment() {
+      this.equipmentForm = {};
+      this.modalType = 0;
+      this.modalTitle = "娣诲姞璁惧";
+      this.$refs.carForm.resetFields();
+      delete this.carForm.id;
+      this.addEquipmentVisible = true;
+    },
+    edit(v) {
+      this.getAllUser();
+      this.buyYear = v.buyYear;
+      this.modalType = 1;
+      this.modalTitle = "缂栬緫";
+      this.$refs.carForm.resetFields();
+      // 杞崲null涓�""
+      for (let attr in v) {
+        if (v[attr] == null) {
+          v[attr] = "";
+        }
+      }
+      let str = JSON.stringify(v);
+      let roleInfo = JSON.parse(str);
+      this.carForm = roleInfo;
+      this.roleModalVisible = true;
+    },
+    editEquipment(v) {
+      this.modalType = 1;
+      this.modalTitle = "缂栬緫璁惧";
+      this.$refs.equipmentForm.resetFields();
+      // 杞崲null涓�""
+      for (let attr in v) {
+        if (v[attr] == null) {
+          v[attr] = "";
+        }
+      }
+      let str = JSON.stringify(v);
+      let roleInfo = JSON.parse(str);
+      this.equipmentForm = roleInfo;
+      this.addEquipmentVisible = true;
+    },
+    removeCar(v) {
+      this.dataType = 0;
+      this.modalTitle = "绉婚櫎杞﹁締";
+      this.$refs.carForm.resetFields();
+      // 杞崲null涓�""
+      for (let attr in v) {
+        if (v[attr] == null) {
+          v[attr] = "";
+        }
+      }
+      let str = JSON.stringify(v);
+      let roleInfo = JSON.parse(str);
+      roleInfo.status = 1
+      this.removeForm = roleInfo;
+      this.carModalVisible = true;
+
+    },
+    remove(v) {
+      this.$Modal.confirm({
+        title: "纭鍒犻櫎",
+        content: "鎮ㄧ‘璁よ鍒犻櫎鍚� ",
+        loading: true,
+        onOk: () => {
+          deleteCar({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: () => {
+          deleteEquipment({ids: v.id}).then((res) => {
+            this.$Modal.remove();
+            if (res.success) {
+              this.clearSelectAll();
+              this.$Message.success("鍒犻櫎鎴愬姛");
+              this.getEquipmentList(this.carId);
+            }
+          });
+        },
+      });
+    },
+    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>

--
Gitblit v1.9.1