|
@@ -17,14 +17,21 @@
|
|
|
@current-change="dataList"
|
|
|
@selection-change="selectionChange"
|
|
|
>
|
|
|
+ <template #menu-right="{}">
|
|
|
+ <el-button
|
|
|
+ class="ml-3"
|
|
|
+ @click="handleExport"
|
|
|
+ >
|
|
|
+ <template #icon> <i-ep-download /> </template>导出
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
</avue-crud>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script setup>
|
|
|
import { ref, getCurrentInstance } from "vue";
|
|
|
import { useCrud } from "@/hooks/userCrud";
|
|
|
-import buttonPermission from "@/common/configs/buttonPermission";
|
|
|
-import {queryDeviceList,queryTypeAliasList} from "@/api/device";
|
|
|
+import {queryDeviceList,queryTypeAliasList,exportDataList} from "@/api/device";
|
|
|
import { useCommonStoreHook } from "@/store";
|
|
|
const { isShowTable, tableType } = toRefs(useCommonStoreHook());
|
|
|
const loading = ref(false);
|
|
@@ -42,6 +49,32 @@ const { selectionChange, multipleDelete } = Methords; //选中和批量删除事
|
|
|
const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
|
|
|
const crudRef = ref(null); //crudRef.value 获取avue-crud对象
|
|
|
const deviceList = ref([])
|
|
|
+const handleExport = () => {
|
|
|
+ exportDataList(search.value).then((response) => {
|
|
|
+ downFile(response);
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+/** 文件下载 */
|
|
|
+const downFile = (response) => {
|
|
|
+ const fileData = response.data;
|
|
|
+ const fileName = decodeURI(
|
|
|
+ response.headers["content-disposition"].split(";")[1].split("=")[1]
|
|
|
+ );
|
|
|
+ const fileType =
|
|
|
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8";
|
|
|
+ const blob = new Blob([fileData], { type: fileType });
|
|
|
+ const downloadUrl = window.URL.createObjectURL(blob);
|
|
|
+ const downloadLink = document.createElement("a");
|
|
|
+ downloadLink.href = downloadUrl;
|
|
|
+ downloadLink.download = fileName;
|
|
|
+ document.body.appendChild(downloadLink);
|
|
|
+ downloadLink.click();
|
|
|
+ document.body.removeChild(downloadLink);
|
|
|
+ window.URL.revokeObjectURL(downloadUrl);
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
const searchPage = (params, done) =>{
|
|
|
if(!search.value.deviceNo){
|
|
|
ElMessage.warning("请先选择设备进行查询");
|