liuyg
2021-09-24 c4e67a8942e514b65ab41bb19781d50576c15725
src/views/securityEquipment/car.vue
@@ -25,8 +25,35 @@
            @click="handleDelete"
            >删 除
          </el-button>
          <el-button
            style="display:none"
            type="success"
            size="small"
            plain
            icon="el-icon-upload2"
            @click="handleImport"
            >批量导入
          </el-button>
        </template>
      </avue-crud>
      <el-dialog
        title="车辆导入"
        append-to-body
        :visible.sync="excelBox"
        width="555px"
      >
        <avue-form
          :option="excelOption"
          v-model="excelForm"
          :upload-after="uploadAfter"
        >
          <template slot="excelTemplate">
            <el-button type="primary" @click="handleTemplate">
              点击下载<i class="el-icon-download el-icon--right"></i>
            </el-button>
          </template>
        </avue-form>
      </el-dialog>
    </div>
  </basic-container>
</template>
@@ -36,8 +63,37 @@
import { getdata, adddata, update, remove } from "@/api/car/car";
export default {
  props: ["fromDeptId"],
  data() {
    return {
      excelBox: false,
      excelForm: {},
      excelOption: {
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: "文件上传",
            prop: "excelFile",
            type: "upload",
            drag: true,
            loadText: "文件上传中,请稍等",
            span: 24,
            propsHttp: {
              res: "data",
            },
            tip: "请上传 .xls,.xlsx 标准格式文件",
            action: "/api/car/import-examSubject",
          },
          {
            label: "模板下载",
            prop: "excelTemplate",
            formslot: true,
            span: 24,
          },
        ],
      },
      loading: true,
      selectionList: [],
      page: {
@@ -52,11 +108,13 @@
        tip: false,
        index: true,
        searchSize: "mini",
        border: true,
        searchMenuSpan: 6,
        height: 583,
        menuWidth: 160,
        align: "center",
        selection: true,
        labelWidth:110,
        column: column,
      },
    };
@@ -71,6 +129,18 @@
    },
  },
  methods: {
    handleImport() {
      this.excelBox = true;
    },
    uploadAfter(res, done, loading, column) {
      window.console.log(column);
      this.excelBox = false;
      this.refreshChange();
      done();
    },
    handleTemplate() {
      window.open(`/api/car/export-template`);
    },
    sizeChange(val) {
      this.page1.currentPage = 1;
      this.page1.pageSize = val;
@@ -88,8 +158,12 @@
      //   delete form.id;
      //   for (var k = 0; k < 13; k++) {
      // console.log
      form["deptId"] = form.tenantName;
      delete form.tenantName;
      // form["deptId"] = form.tenantName;
      // delete form.tenantName;
      // console.log(form);
      if (this.fromDeptId != undefined) {
        form["deptId"] = this.fromDeptId;
      }
      adddata(form).then(
        (res) => {
          this.onLoad(this.page);
@@ -117,9 +191,12 @@
      this.onLoad(this.page);
    },
    rowUpdate(row, index, done, loading) {
      console.log(row);
      row["deptId"] = row.tenantName;
      delete row.tenantName;
      // console.log(row);
      // row["deptId"] = row.tenantName;
      // delete row.tenantName;
      if (this.fromDeptId != undefined) {
        row["deptId"] = this.fromDeptId;
      }
      update(row).then(
        () => {
          this.onLoad(this.page);
@@ -182,6 +259,19 @@
    },
    onLoad(page, params = {}) {
      this.loading = true;
      // console.log(params.deptId);
      if (this.fromDeptId != undefined) {
        params["deptId"] = this.fromDeptId;
        this.option.column[4].search = false;
        this.option.column[4].hide = true;
        this.option.column[4].addDisplay = false;
        this.option.column[4].editDisplay = false;
      } else {
        this.option.column[4].search = true;
        this.option.column[4].hide = false;
        this.option.column[4].addDisplay = true;
        this.option.column[4].editDisplay = true;
      }
      getdata(
        page.currentPage,
        page.pageSize,