zhangzeli
2021-11-01 50a3487ec7940e9604b4410f70fcdec2fe85609a
设备
2个文件已修改
231 ■■■■ 已修改文件
src/api/open.js 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/your/car-manage/carManage.vue 221 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/open.js
@@ -100,4 +100,14 @@
// 查询设备信息
export const getEquipment = (params) => {
    return getRequest('/equipment/getByPage', params)
}
// 添加设备信息
export const addEquipment = (params) => {
    return postRequest('/equipment/insertOrUpdate', params)
}
// 删除设备信息
export const deleteEquipment = (params) => {
    return postRequest('/equipment/delByIds', params)
}
src/views/your/car-manage/carManage.vue
@@ -60,12 +60,7 @@
      :mask-closable="false"
      :width="500"
    >
      <Form
        ref="carForm"
        :model="carForm"
        :label-width="80"
        :rules="carFormValidate"
      >
      <Form ref="carForm" :model="carForm" :label-width="80" :rules="carFormValidate">
        <FormItem label="品牌" prop="brand">
          <Input v-model="carForm.brand"/>
        </FormItem>
@@ -95,12 +90,50 @@
        >
      </div>
    </Modal>
    <Modal :title="modalTitle" v-model="equipmentVisible" :mask-closable="false" :width="1200">
    <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">正常</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
@@ -200,6 +233,8 @@
  editCar,
  deleteCar,
  getEquipment,
  addEquipment,
  deleteEquipment,
} from "@/api/open";
import util from "@/libs/util.js";
export default {
@@ -219,6 +254,7 @@
      sortType: "desc",
      modalType: 0,
      roleModalVisible: false,
      addEquipmentVisible: false,
      equipmentVisible: false,
      carModalVisible: false,
      permModalVisible: false,
@@ -233,6 +269,9 @@
        key: "",
      },
      carForm: {
        status : 0
      },
      equipmentForm: {
        status : 0
      },
      removeForm: {
@@ -402,18 +441,54 @@
        {
          title: "设备类型",
          key: "type",
          width: 100,
          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: 100,
          width: 120,
        },
        {
          title: "状态",
          key: "status",
          width: 100,
          width: 120,
          sortable: true,
          render: (h, params) => {
            let re = "";
@@ -431,7 +506,7 @@
                h("Badge", {
                  props: {
                    status: "error",
                    text: "移除",
                    text: "停用",
                  },
                }),
              ]);
@@ -441,12 +516,12 @@
        {
          title: "ip地址",
          key: "ip",
          width: 100,
          width: 120,
        },
        {
          title: "端口号",
          key: "port",
          width: 100,
          width: 120,
          sortable: true,
        },
        {
@@ -461,39 +536,7 @@
                      {
                        on: {
                          click: () => {
                            this.equipment(params.row);
                          },
                        },
                      },
                      "设备"
              ),
              h("Divider", {
                props: {
                  type: "vertical",
                },
              }),
              h(
                      "a",
                      {
                        on: {
                          click: () => {
                            this.removeCar(params.row);
                          },
                        },
                      },
                      "移除车辆"
              ),
              h("Divider", {
                props: {
                  type: "vertical",
                },
              }),
              h(
                      "a",
                      {
                        on: {
                          click: () => {
                            this.edit(params.row);
                            this.editEquipment(params.row);
                          },
                        },
                      },
@@ -509,7 +552,7 @@
                      {
                        on: {
                          click: () => {
                            this.remove(params.row);
                            this.removeEquipment(params.row);
                          },
                        },
                      },
@@ -522,11 +565,13 @@
      data: [],
      data2: [],
      total: 0,
      total2: 0,
      permData: [],
      editRolePermId: "",
      selectAllFlag: false,
      depData: [],
      dataType: 0,
      carId: '',
      editDepartments: [],
      buyYear:''
    };
@@ -613,13 +658,13 @@
        }
      });
    },
    getEquipmentList() {
    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;
          this.total = res.result.total;
        }
      });
    },
@@ -679,6 +724,37 @@
        }
      });
    },
    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) {
@@ -694,8 +770,9 @@
        }
      });
    },
    equipment() {
      this.getEquipmentList();
    equipment(row) {
      this.carId = row.id
      this.getEquipmentList(row.id);
      this.modalType = 0;
      this.modalTitle = "设备信息";
      this.$refs.carForm.resetFields();
@@ -708,6 +785,14 @@
      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.buyYear = v.buyYear;
@@ -722,9 +807,23 @@
      }
      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;
@@ -739,7 +838,6 @@
      let str = JSON.stringify(v);
      let roleInfo = JSON.parse(str);
      roleInfo.status=1
      console.log(roleInfo);
      this.removeForm = roleInfo;
      this.carModalVisible = true;
@@ -761,6 +859,23 @@
        },
      });
    },
    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 = {