Browse Source

Merge remote-tracking branch 'origin/dev' into dev

pangqijun 3 tháng trước cách đây
mục cha
commit
7889c56141
2 tập tin đã thay đổi với 358 bổ sung0 xóa
  1. 50 0
      src/api/facility/facility.js
  2. 308 0
      src/views/facility/facility.vue

+ 50 - 0
src/api/facility/facility.js

@@ -0,0 +1,50 @@
+import request from '@/router/axios';
+
+export const getList = (current, size, params) => {
+  return request({
+    url: '/api/facility/list',
+    method: 'get',
+    params: {
+      ...params,
+      current,
+      size,
+    }
+  })
+}
+
+export const getDetail = (id) => {
+  return request({
+    url: '/api/facility/detail',
+    method: 'get',
+    params: {
+      id
+    }
+  })
+}
+
+export const remove = (ids) => {
+  return request({
+    url: '/api/facility/remove',
+    method: 'post',
+    params: {
+      ids,
+    }
+  })
+}
+
+export const add = (row) => {
+  return request({
+    url: '/api/facility/submit',
+    method: 'post',
+    data: row
+  })
+}
+
+export const update = (row) => {
+  return request({
+    url: '/api/facility/submit',
+    method: 'post',
+    data: row
+  })
+}
+

+ 308 - 0
src/views/facility/facility.vue

@@ -0,0 +1,308 @@
+<template>
+  <basic-container>
+    <avue-crud :option="option"
+               :table-loading="loading"
+               :data="data"
+               :page.sync="page"
+               :permission="permissionList"
+               :before-open="beforeOpen"
+               v-model="form"
+               ref="crud"
+               @row-update="rowUpdate"
+               @row-save="rowSave"
+               @row-del="rowDel"
+               @search-change="searchChange"
+               @search-reset="searchReset"
+               @selection-change="selectionChange"
+               @current-change="currentChange"
+               @size-change="sizeChange"
+               @refresh-change="refreshChange"
+               @on-load="onLoad">
+      <template slot="menuLeft">
+        <el-button type="danger"
+                   size="small"
+                   icon="el-icon-delete"
+                   plain
+                   v-if="permission.facility_delete"
+                   @click="handleDelete">删 除
+        </el-button>
+      </template>
+    </avue-crud>
+  </basic-container>
+</template>
+
+<script>
+  import {getList, getDetail, add, update, remove} from "@/api/facility/facility";
+  import {mapGetters} from "vuex";
+
+  export default {
+    data() {
+      return {
+        form: {},
+        query: {},
+        loading: true,
+        page: {
+          pageSize: 10,
+          currentPage: 1,
+          total: 0
+        },
+        selectionList: [],
+        option: {
+          height:'auto',
+          calcHeight: 30,
+          tip: false,
+          searchShow: true,
+          searchMenuSpan: 6,
+          border: true,
+          index: true,
+          viewBtn: true,
+          selection: true,
+          dialogClickModal: false,
+          column: [
+            {
+              label: "设备编号",
+              prop: "facilityNo",
+              rules: [{
+                required: true,
+                message: "请输入设备编号",
+                trigger: "blur"
+              }]
+            },
+            {
+              label: "所属门店",
+              prop: "shopName",
+              search: true,
+              addDisplay: false,
+              editDisplay: false,
+              rules: [{
+                required: true,
+                message: "请输入门店id",
+                trigger: "blur"
+              }]
+            },
+            {
+              label: "所属门店",
+              prop: "shopId",
+              hide: true,
+              type: "select",
+              dicUrl: "/api/business/shop/list?status=0&current=1&size=100",
+              dicFormatter: function (res) {
+                return res.data.records;
+              },
+              props: {
+                label: "storeName",
+                value: "id",
+              },
+              rules: [{
+                required: true,
+                message: "请选择门店",
+                trigger: "blur"
+              }]
+            },
+            {
+              label: "设备名称",
+              search: true,
+              prop: "facilityName",
+              rules: [{
+                required: true,
+                message: "请输入设备名称",
+                trigger: "blur"
+              }]
+            },
+            {
+              label: "设备型号",
+              prop: "facilityType",
+              rules: [{
+                required: true,
+                message: "请输入设备型号",
+                trigger: "blur"
+              }]
+            },
+            {
+              label: "设备经度",
+              prop: "longitude",
+              rules: [{
+                required: true,
+                message: "请输入设备经度",
+                trigger: "blur"
+              }]
+            },
+            {
+              label: "设备纬度",
+              prop: "latitude",
+              rules: [{
+                required: true,
+                message: "请输入设备纬度",
+                trigger: "blur"
+              }]
+            },
+            {
+              label: "设备状态",
+              prop: "facilityStatus",
+              rules: [{
+                required: true,
+                message: "请输入设备状态",
+                trigger: "blur"
+              }]
+            },
+            {
+              label: "最新上传数据时间",
+              prop: "heartbeatTime",
+              addDisplay: false,
+              editDisplay: false,
+              rules: [{
+                required: true,
+                message: "请输入最新上传数据时间",
+                trigger: "blur"
+              }]
+            },
+            {
+              label: "添加时间",
+              prop: "addTime",
+              addDisplay: false,
+              editDisplay: false,
+              rules: [{
+                required: true,
+                message: "请输入添加时间",
+                trigger: "blur"
+              }]
+            },
+          ]
+        },
+        data: []
+      };
+    },
+    computed: {
+      ...mapGetters(["permission"]),
+      permissionList() {
+        return {
+          addBtn: this.vaildData(this.permission.facility_add, false),
+          viewBtn: this.vaildData(this.permission.facility_view, false),
+          delBtn: this.vaildData(this.permission.facility_delete, false),
+          editBtn: this.vaildData(this.permission.facility_edit, false)
+        };
+      },
+      ids() {
+        let ids = [];
+        this.selectionList.forEach(ele => {
+          ids.push(ele.id);
+        });
+        return ids.join(",");
+      }
+    },
+    methods: {
+      rowSave(row, done, loading) {
+        add(row).then(() => {
+          this.onLoad(this.page);
+          this.$message({
+            type: "success",
+            message: "操作成功!"
+          });
+          done();
+        }, error => {
+          loading();
+          window.console.log(error);
+        });
+      },
+      rowUpdate(row, index, done, loading) {
+        update(row).then(() => {
+          this.onLoad(this.page);
+          this.$message({
+            type: "success",
+            message: "操作成功!"
+          });
+          done();
+        }, error => {
+          loading();
+          console.log(error);
+        });
+      },
+      rowDel(row) {
+        this.$confirm("确定将选择数据删除?", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        })
+          .then(() => {
+            return remove(row.id);
+          })
+          .then(() => {
+            this.onLoad(this.page);
+            this.$message({
+              type: "success",
+              message: "操作成功!"
+            });
+          });
+      },
+      handleDelete() {
+        if (this.selectionList.length === 0) {
+          this.$message.warning("请选择至少一条数据");
+          return;
+        }
+        this.$confirm("确定将选择数据删除?", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        })
+          .then(() => {
+            return remove(this.ids);
+          })
+          .then(() => {
+            this.onLoad(this.page);
+            this.$message({
+              type: "success",
+              message: "操作成功!"
+            });
+            this.$refs.crud.toggleSelection();
+          });
+      },
+      beforeOpen(done, type) {
+        if (["edit", "view"].includes(type)) {
+          getDetail(this.form.id).then(res => {
+            this.form = res.data.data;
+          });
+        }
+        done();
+      },
+      searchReset() {
+        this.query = {};
+        this.onLoad(this.page);
+      },
+      searchChange(params, done) {
+        this.query = params;
+        this.page.currentPage = 1;
+        this.onLoad(this.page, params);
+        done();
+      },
+      selectionChange(list) {
+        this.selectionList = list;
+      },
+      selectionClear() {
+        this.selectionList = [];
+        this.$refs.crud.toggleSelection();
+      },
+      currentChange(currentPage){
+        this.page.currentPage = currentPage;
+      },
+      sizeChange(pageSize){
+        this.page.pageSize = pageSize;
+      },
+      refreshChange() {
+        this.onLoad(this.page, this.query);
+      },
+      onLoad(page, params = {}) {
+        this.loading = true;
+        getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
+          const data = res.data.data;
+          this.page.total = data.total;
+          this.data = data.records;
+          this.loading = false;
+          this.selectionClear();
+        });
+      }
+    }
+  };
+</script>
+
+<style>
+</style>