zhaoxiaoqiang1
2026-01-04 f1d30d03186c79ca2cbcfe60d6d2ce7d73fba97b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<template>
  <div class="school-main">
    <TableList
      ref="commontable"
      :condtionConfig="condtionConfig"
      :columnConfig="columnConfig"
      :condformdefConfig="condformdefConfig"
      :operateBtns="operateBtns"
      :userDefined="true"
      :isAutoIndex="false"
      :isMultipleSelect="true"
      :buttonsArr="buttonsArr"
      rowKeyName="serialNo"
      @handleSelectionChange="handleSelectionChange"
      @handleBtnClick="handleBtnClick"
      listApiName="qrySchoolDistrictHousingList"
      delApiName="deleteSchoolDistrictHousingList"
      deleteKey="serialNo"
    />
    <el-dialog
      title="批量导入"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :destroy-on-close="true"
      :show-close="false"
      width="450"
      center
      custom-class="school_dialog_footer_set"
    >
      <el-upload
        class="upload-main"
        drag
        action=""
        :headers="uploadHeader"
        :http-request="handleUpload"
        :show-file-list="false"
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
        <div class="el-upload__tip" slot="tip">
          <a @click="downloadFile">模板下载</a>
        </div>
      </el-upload>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import { mapState, mapGetters, mapActions } from "vuex";
import TableList from "../../components/TableList.vue";
import {
  SCHOOLHOUSELISTCOND,
  SCHOOLHOUSELISTCONDDEF
} from "../config/condtion.config";
import { SCHOOLHOUSELISTCOLUMN } from "../config/column.config";
import {
  downloadUploadFile,
  schoolDistrictHousingUploadExcel,
  batchDeleteSchoolDistrictHousingList
} from "@/http/api";
import { Message } from "element-ui";
export default {
  props: {},
  data() {
    return {
      condtionConfig: [...SCHOOLHOUSELISTCOND],
      columnConfig: [...SCHOOLHOUSELISTCOLUMN],
      condformdefConfig: { ...SCHOOLHOUSELISTCONDDEF },
      optionsArr: ["IsDelete", "cities"],
      buttonsArr: [
        { type: "import", value: "批量导入", icon: "el-icon-upload" },
        { type: "delete", value: "批量删除", icon: "el-icon-delete-solid" }
      ],
      operateBtns: [{ label: "删除", type: "DELETE", value: true }],
      selecteData: [],
      dialogVisible: false,
      uploadHeader: {
        "Content-Type": "multipart/form-data; boundary=ReaquestHeader"
      }
    };
  },
  computed: {
    // 获取state值
    ...mapState("rlc", {
      optionsMap: state => state.OPTIONSMAP
    }),
    // 通过getters获取值
    ...mapGetters("rlc", ["getOptionsMap"])
  },
  async created() {
    this.getOptionsData(this.optionsArr);
    this.getUserInfo();
  },
  mounted() {},
  watch: {},
  methods: {
    ...mapActions("rlc", [
      // 将 `this.setOptionsMap()` 映射为 `this.$store.dispatch('setOptionsMap')`
      "getOptionsData",
      "getUserInfo"
    ]),
    operateHandleClick() {
      this.$router.push({ name: "addImageDataConfig" });
    },
    async handleBtnClick(type) {
      if (type === "import") {
        this.dialogVisible = true;
      }
      if (type === "delete") {
        const { selecteData } = this;
        if (selecteData.length < 1) {
          this.$message.warning("请选择需要删除的楼盘!");
          return false;
        }
        const deleteSelectRes = await batchDeleteSchoolDistrictHousingList({
          qrySchoolDistrictHousingRspList: selecteData
        });
        if (deleteSelectRes && deleteSelectRes.code === "00") {
          this.$refs.commontable.getTableList();
          this.$message.success("删除成功");
        }
      }
    },
    handleSelectionChange(val) {
      this.selecteData = val;
    },
    async handleUpload(file) {
      if (file.file) {
        const formData = new FormData();
        formData.append("file", file.file);
        await schoolDistrictHousingUploadExcel(formData).then(res => {
          if (res.code === "00") {
            this.$message.success("导入成功");
            this.dialogVisible = false;
            this.$refs.commontable.getTableList();
          }
        });
      }
    },
    handleUploadFile() {},
    async downloadFile() {
      await downloadUploadFile({ fileName: "批量导入楼盘信息模板" });
      Message.closeAll();
    }
  },
  components: { TableList }
};
</script>
 
<style lang="less">
.school-main {
  & .el-upload__tip {
    color: #409eff;
    & a {
      cursor: pointer;
    }
  }
  & .school_dialog_footer_set {
    width: 400px;
    & .el-dialog__footer {
      & .dialog-footer {
        & .el-button--default {
          width: 120px;
          height: 30px;
          line-height: 7px;
          border-radius: 4px;
          border: 1px solid rgba(204, 204, 204, 1);
        }
        & .el-button--primary {
          width: 120px;
          height: 30px;
          line-height: 7px;
          background: #0081f0;
          border-color: #0081f0;
          border-radius: 4px;
          margin-left: 40px;
        }
      }
    }
  }
}
</style>