zhangzeli
2021-10-29 4c18dc33c4076c95190ef24632f65f20836553b6
src/views/your/car-manage/carManage.vue
@@ -17,7 +17,7 @@
          v-model="searchForm.carNo"
          suffix="ios-search"
          @on-change="getDataList"
          placeholder="输入关键词搜索"
          placeholder="输入车牌号搜索"
          clearable
          style="width: 250px"
        />
@@ -69,7 +69,6 @@
        <FormItem label="品牌" prop="brand">
          <Input v-model="carForm.brand"/>
        </FormItem>
        <FormItem label="型号" prop="model">
          <Input v-model="carForm.model" />
        </FormItem>
@@ -140,22 +139,14 @@
    <!-- 数据权限 -->
    <Modal
      :title="modalTitle"
      v-model="depModalVisible"
      v-model="carModalVisible"
      :mask-closable="false"
      :width="500"
      class="depModal"
    >
      <Alert show-icon
        >默认可查看全部数据,自定义数据范围时请勾选下方数据</Alert
      >
      <Form :label-width="85">
        <FormItem label="数据范围">
          <Select v-model="dataType" transfer>
            <Option :value="0">全部数据权限</Option>
            <Option :value="1">自定义数据权限</Option>
            <Option :value="2">本部门及以下数据权限</Option>
            <Option :value="3">本部门数据权限</Option>
          </Select>
      <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">
@@ -176,7 +167,7 @@
        <Button
          type="primary"
          :loading="submitDepLoading"
          @click="submitDepEdit"
          @click="submitRemove"
          >提交</Button
        >
      </div>
@@ -219,6 +210,7 @@
      sortType: "desc",
      modalType: 0,
      roleModalVisible: false,
      carModalVisible: false,
      permModalVisible: false,
      depModalVisible: false,
      modalTitle: "",
@@ -226,13 +218,15 @@
        // 搜索框初始化对象
        pageNumber: 1, // 当前页数
        pageSize: 10, // 页面大小
        sort: "carNo", // 默认排序字段
        sort: "createTime", // 默认排序字段
        order: "desc", // 默认排序方式
        key: "",
      },
      carForm: {
        type : 0,
        status : 0
      },
      removeForm: {
        status : 1
      },
      carFormValidate: {
        name: [
@@ -253,16 +247,20 @@
          align: "center",
        },
        {
          title: "车牌号",
          key: "carNo",
          width: 100,
          sortable: true,
        },
        {
          title: "品牌",
          key: "brand",
          width: 100,
          sortable: true,
        },
        {
          title: "型号",
          key: "model",
          width: 100,
          sortable: true,
        },
        {
          title: "排量",
@@ -273,20 +271,13 @@
        {
          title: "购置年份",
          key: "buyYear",
          minWidth: 150,
          minWidth: 120,
          sortable: true,
        },
        {
          title: "牌照",
          key: "carNo",
          width: 170,
          sortable: true,
          sortType: "desc",
        },
        {
          title: "状态",
          key: "status",
          width: 170,
          width: 100,
          sortable: true,
          render: (h, params) => {
            let re = "";
@@ -321,7 +312,6 @@
          title: "操作",
          key: "action",
          align: "center",
          fixed: "right",
          width: 280,
          render: (h, params) => {
            return h("div", [
@@ -330,27 +320,11 @@
                {
                  on: {
                    click: () => {
                      this.editPerm(params.row);
                      this.removeCar(params.row);
                    },
                  },
                },
                "菜单权限"
              ),
              h("Divider", {
                props: {
                  type: "vertical",
                },
              }),
              h(
                "a",
                {
                  on: {
                    click: () => {
                      this.editDep(params.row);
                    },
                  },
                },
                "数据权限"
                "移除车辆"
              ),
              h("Divider", {
                props: {
@@ -396,11 +370,12 @@
      depData: [],
      dataType: 0,
      editDepartments: [],
      buyYear:''
    };
  },
  methods: {
    change1(e){
      this.carForm.buyYear = e;
      this.buyYear = e;
    },
    init() {
      this.getDataList();
@@ -508,8 +483,8 @@
      this.roleModalVisible = false;
    },
    submitCar() {
      this.carForm.buyYear = this.buyYear;
      this.$refs.carForm.validate((valid) => {
        this.carForm.buyYear = this.carForm.buyYear.toString()
        if (valid) {
          if (this.modalType == 0) {
            // 添加
@@ -536,6 +511,21 @@
        }
      });
    },
    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;
              }
            });
        }
      });
    },
    addCar() {
      this.modalType = 0;
      this.modalTitle = "添加车辆";
@@ -544,8 +534,9 @@
      this.roleModalVisible = true;
    },
    edit(v) {
      this.buyYear = v.buyYear;
      this.modalType = 1;
      this.modalTitle = "编辑车辆";
      this.modalTitle = "编辑角色";
      this.$refs.carForm.resetFields();
      // 转换null为""
      for (let attr in v) {
@@ -555,13 +546,32 @@
      }
      let str = JSON.stringify(v);
      let roleInfo = JSON.parse(str);
      this.carForm = roleInfo;
      this.roleModalVisible = 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
      console.log(roleInfo);
      this.removeForm = roleInfo;
      this.carModalVisible = true;
    },
    remove(v) {
      this.$Modal.confirm({
        title: "确认删除",
        content: "您确认要删除车辆 " + v.name + " ?",
        content: "您确认要删除吗 ",
        loading: true,
        onOk: () => {
          deleteCar({ ids: v.id }).then((res) => {
@@ -735,38 +745,6 @@
          callback(res.result);
        }
      });
    },
    editDep(v) {
      this.dataType = 0;
      this.editRolePermId = v.id;
      this.modalTitle = "分配 " + v.name + " 的数据权限";
      if (v.dataType) {
        this.dataType = v.dataType;
      }
      // 匹配勾选
      let roleDepIds = v.departments;
      this.editDepartments = roleDepIds;
      this.depTreeLoading = true;
      initDepartment({ openDataFilter: false }).then((res) => {
        this.depTreeLoading = false;
        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;
            }
          });
          this.depData = res.result;
          // 判断子节点
          this.checkDepTree(this.depData, roleDepIds);
        }
      });
      this.depModalVisible = true;
    },
    expandCheckDep(v) {
      // 判断展开子节点