|
@@ -365,6 +365,22 @@
|
|
@click="handleMultiDelete()"
|
|
@click="handleMultiDelete()"
|
|
>删除</el-button
|
|
>删除</el-button
|
|
>
|
|
>
|
|
|
|
+ <el-button
|
|
|
|
+ type="warning"
|
|
|
|
+ icon="el-icon-download"
|
|
|
|
+ :loading="downloadLoading"
|
|
|
|
+ style="margin-top: 15px"
|
|
|
|
+ @click="exportExcel"
|
|
|
|
+ >导出</el-button
|
|
|
|
+ >
|
|
|
|
+ <el-button
|
|
|
|
+ type="success"
|
|
|
|
+ icon="el-icon-upload"
|
|
|
|
+ :loading="downloadLoading"
|
|
|
|
+ style="margin-top: 15px"
|
|
|
|
+ @click="importExcel"
|
|
|
|
+ >导入</el-button
|
|
|
|
+ >
|
|
<el-pagination
|
|
<el-pagination
|
|
background
|
|
background
|
|
class="pagination-container"
|
|
class="pagination-container"
|
|
@@ -387,12 +403,64 @@
|
|
@sendVal="closeDrawer"
|
|
@sendVal="closeDrawer"
|
|
:record="detail"
|
|
:record="detail"
|
|
/>
|
|
/>
|
|
|
|
+ <!-- 导入弹框 -->
|
|
|
|
+ <el-dialog
|
|
|
|
+ title="导入液压泵"
|
|
|
|
+ append-to-body
|
|
|
|
+ width="400px"
|
|
|
|
+ :visible.sync="uploadDialogVisible"
|
|
|
|
+ custom-class="upload-dialog"
|
|
|
|
+ >
|
|
|
|
+ <el-cascader
|
|
|
|
+ v-model="selectedDepartId"
|
|
|
|
+ class="filter-item form-search-input fl"
|
|
|
|
+ :options="departments"
|
|
|
|
+ :props="{ checkStrictly: true, label: 'department_name', value: 'id' }"
|
|
|
|
+ style="margin-bottom: 10px"
|
|
|
|
+ @change="changeCards"
|
|
|
|
+ ></el-cascader>
|
|
|
|
+ <el-upload
|
|
|
|
+ class="upload-demo"
|
|
|
|
+ drag
|
|
|
|
+ :action="actionUrl"
|
|
|
|
+ :headers="headers"
|
|
|
|
+ :before-upload="beforeUpload"
|
|
|
|
+ :show-file-list="true"
|
|
|
|
+ :on-change="onchange"
|
|
|
|
+ :on-remove="onremove"
|
|
|
|
+ :on-exceed="onexeced"
|
|
|
|
+ :limit="1"
|
|
|
|
+ ref="upload"
|
|
|
|
+ >
|
|
|
|
+ <i class="el-icon-upload"></i>
|
|
|
|
+ <div class="el-upload__text">
|
|
|
|
+ 将文件拖到此处,或
|
|
|
|
+ <em>点击上传</em>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="el-upload__tip upload-tips" slot="tip">
|
|
|
|
+ 只能上传xls/xlsx文件
|
|
|
|
+ </div>
|
|
|
|
+ </el-upload>
|
|
|
|
+ <el-link
|
|
|
|
+ type="primary"
|
|
|
|
+ href="https://rlfd.oss-cn-hangzhou.aliyuncs.com/wxt_school/cards.xls"
|
|
|
|
+ style="margin-top: 10px"
|
|
|
|
+ >下载模板</el-link
|
|
|
|
+ >
|
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
|
+ <el-button @click="uploadDialogVisible = false">取 消</el-button>
|
|
|
|
+ <el-button type="primary" @click="importCards" :loading="loadings">{{
|
|
|
|
+ submitText
|
|
|
|
+ }}</el-button>
|
|
|
|
+ </span>
|
|
|
|
+ </el-dialog>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import rlListOperate from "@/layout/rl-list-operate/rlListOperate";
|
|
import rlListOperate from "@/layout/rl-list-operate/rlListOperate";
|
|
import { action } from "@/directive/permission/index.js";
|
|
import { action } from "@/directive/permission/index.js";
|
|
|
|
+import { getToken } from "../../../utils/auth";
|
|
import detail from "./detail.vue"
|
|
import detail from "./detail.vue"
|
|
import formModel from './formModel.vue'
|
|
import formModel from './formModel.vue'
|
|
export default {
|
|
export default {
|
|
@@ -445,7 +513,15 @@ export default {
|
|
model_name: true,
|
|
model_name: true,
|
|
is_used:true,
|
|
is_used:true,
|
|
online_time: true
|
|
online_time: true
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ //导入请求url
|
|
|
|
+ actionUrl: process.env.VUE_APP_BASE_API + "/upload/file_excel",
|
|
|
|
+ headers: { authorization: "Bearer " + getToken() },
|
|
|
|
+ excel_url: "", //上传学生Excel返回的url
|
|
|
|
+ uploadDialogVisible: false, //下发配置显示与否
|
|
|
|
+ selectedDepartId: "",
|
|
|
|
+ loadings: false,
|
|
|
|
+ submitText: "确 定",
|
|
};
|
|
};
|
|
},
|
|
},
|
|
created() {
|
|
created() {
|
|
@@ -507,7 +583,71 @@ export default {
|
|
// this.$emit('rowClick', row)
|
|
// this.$emit('rowClick', row)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ importExcel() {
|
|
|
|
+ this.uploadDialogVisible = true;
|
|
|
|
+ },
|
|
|
|
+ changeCards(v) {
|
|
|
|
+ this.selectedDepartId = v[v.length - 1];
|
|
|
|
+ },
|
|
|
|
+ beforeUpload(file) {
|
|
|
|
+ if (!/\.(xlsx|xls|XLSX|XLS)$/.test(file.name)) {
|
|
|
|
+ this.$notify.error({
|
|
|
|
+ title: "错误",
|
|
|
|
+ message: "上传文件只能为excel文件,且为xlsx,xls格式",
|
|
|
|
+ });
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ },
|
|
|
|
+ onremove() {
|
|
|
|
+ //移除文件钩子
|
|
|
|
+ this.excel_url = "";
|
|
|
|
+ },
|
|
|
|
+ onexeced(files) {
|
|
|
|
+ if (files.length == 1) {
|
|
|
|
+ this.$message.error("只能上传一个文件");
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ onchange(file, fileList) {
|
|
|
|
+ if (file.response) {
|
|
|
|
+ this.$message.success(file.response.data.msg);
|
|
|
|
+ this.excel_url = file.response.data.excel_url;
|
|
|
|
+ } else {
|
|
|
|
+ // console.log(file);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ importCards() {
|
|
|
|
+ // console.log(this.excel_url);
|
|
|
|
+ var url = this.excel_url,
|
|
|
|
+ depart_id = this.selectedDepartId;
|
|
|
|
+ if (depart_id == "") {
|
|
|
|
+ this.$message.error("请选择部门");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (url == "") {
|
|
|
|
+ this.$message.error("请上传文件");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.loadings = true;
|
|
|
|
+ this.submitText = "导入中";
|
|
|
|
+ this.$http
|
|
|
|
+ .post("cardDevice/import", { url: url, depart_id: depart_id })
|
|
|
|
+ .then((response) => {
|
|
|
|
+ if (response.data.error) {
|
|
|
|
+ this.$message.error(response.data.msg);
|
|
|
|
+ } else {
|
|
|
|
+ this.$message.success(response.data);
|
|
|
|
+ }
|
|
|
|
+ this.excel_url = "";
|
|
|
|
+ this.selectedDepartId = "";
|
|
|
|
+ this.$refs.upload.clearFiles();
|
|
|
|
+ this.loadings = false;
|
|
|
|
+ this.submitText = "确定";
|
|
|
|
+ this.uploadDialogVisible = false;
|
|
|
|
+ this.getList();
|
|
|
|
+ });
|
|
|
|
+ },
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
// 监听复选框配置列所有的变化
|
|
// 监听复选框配置列所有的变化
|