|
|
@@ -641,245 +641,7 @@
|
|
|
}
|
|
|
|
|
|
};
|
|
|
-=======
|
|
|
-import AddOrUpdate from './components/add-or-update.vue';
|
|
|
-import uploadModal from './components/uploadModal.vue';
|
|
|
-import axios from 'axios';
|
|
|
-export default {
|
|
|
- components: {
|
|
|
- AddOrUpdate,
|
|
|
- uploadModal,
|
|
|
- },
|
|
|
- data() {
|
|
|
- return {
|
|
|
- searchForm: {
|
|
|
- subNm: '',
|
|
|
- compNm: '',
|
|
|
- dateRange: [],
|
|
|
- },
|
|
|
- dataList: [],
|
|
|
- pageIndex: 1,
|
|
|
- pageSize: 10,
|
|
|
- totalPage: 0,
|
|
|
- dataListLoading: false,
|
|
|
- dataListSelections: [],
|
|
|
- layouts: ['prev', 'pager', 'next', 'sizes'],
|
|
|
- compList: [],
|
|
|
- addOrUpdateOrDetailFlag: false,
|
|
|
- };
|
|
|
- },
|
|
|
- created() {
|
|
|
- this.getCompList();
|
|
|
- this.getDataList();
|
|
|
- },
|
|
|
- methods: {
|
|
|
- // 获取公司列表
|
|
|
- async getCompList() {
|
|
|
- this.compList = [];
|
|
|
- const { data } = await this.$http({
|
|
|
- url: `/company/lists`,
|
|
|
- method: 'get',
|
|
|
- });
|
|
|
- if (data && data.code === 0) {
|
|
|
- this.compList = data.data.map(item => ({
|
|
|
- label: item.compName,
|
|
|
- value: String(item.id),
|
|
|
- }));
|
|
|
- }
|
|
|
- },
|
|
|
- importHandler() {
|
|
|
- this.$refs.uploadModal.openDialog();
|
|
|
- },
|
|
|
- downloadTemplate() {
|
|
|
- const link = document.createElement('a');
|
|
|
- link.href = '././voltageLoad_template.xlsx';
|
|
|
- link.download = 'voltageLoad_template.xlsx';
|
|
|
- document.body.appendChild(link);
|
|
|
- link.click();
|
|
|
- document.body.removeChild(link);
|
|
|
- },
|
|
|
- exportTemplate() {
|
|
|
- axios
|
|
|
- .get(this.$base.url + 'file/download?fileName=' + 'voltageLoad_template.xlsx', {
|
|
|
- headers: {
|
|
|
- token: this.$storage.get('Token'),
|
|
|
- },
|
|
|
- responseType: 'blob',
|
|
|
- })
|
|
|
- .then(({ data }) => {
|
|
|
- const blob = new Blob([data], { type: 'application/vnd.ms-excel' });
|
|
|
- const fileName = 'voltageLoad_template.xlsx';
|
|
|
- const a = document.createElement('a');
|
|
|
- a.href = URL.createObjectURL(blob);
|
|
|
- a.download = fileName;
|
|
|
- a.click();
|
|
|
- URL.revokeObjectURL(a.href);
|
|
|
- });
|
|
|
- },
|
|
|
- // 下载
|
|
|
- download(file) {
|
|
|
- let arr = file.replace(new RegExp('upload/', 'g'), '');
|
|
|
- axios
|
|
|
- .get(this.$base.url + 'file/download?fileName=' + arr, {
|
|
|
- headers: {
|
|
|
- token: this.$storage.get('Token'),
|
|
|
- },
|
|
|
- responseType: 'blob',
|
|
|
- })
|
|
|
- .then(
|
|
|
- ({ data }) => {
|
|
|
- const binaryData = [];
|
|
|
- binaryData.push(data);
|
|
|
- const objectUrl = window.URL.createObjectURL(
|
|
|
- new Blob(binaryData, {
|
|
|
- type: 'application/pdf;chartset=UTF-8',
|
|
|
- })
|
|
|
- );
|
|
|
- const a = document.createElement('a');
|
|
|
- a.href = objectUrl;
|
|
|
- a.download = arr;
|
|
|
- // a.click()
|
|
|
- // 下面这个写法兼容火狐
|
|
|
- a.dispatchEvent(
|
|
|
- new MouseEvent('click', {
|
|
|
- bubbles: true,
|
|
|
- cancelable: true,
|
|
|
- view: window,
|
|
|
- })
|
|
|
- );
|
|
|
- window.URL.revokeObjectURL(data);
|
|
|
- },
|
|
|
- err => {
|
|
|
- axios
|
|
|
- .get(
|
|
|
- (location.href.split(this.$base.name).length > 1 ? location.href.split(this.$base.name)[0] : '') +
|
|
|
- this.$base.name +
|
|
|
- '/file/download?fileName=' +
|
|
|
- arr,
|
|
|
- {
|
|
|
- headers: {
|
|
|
- token: this.$storage.get('Token'),
|
|
|
- },
|
|
|
- responseType: 'blob',
|
|
|
- }
|
|
|
- )
|
|
|
- .then(({ data }) => {
|
|
|
- const binaryData = [];
|
|
|
- binaryData.push(data);
|
|
|
- const objectUrl = window.URL.createObjectURL(
|
|
|
- new Blob(binaryData, {
|
|
|
- type: 'application/pdf;chartset=UTF-8',
|
|
|
- })
|
|
|
- );
|
|
|
- const a = document.createElement('a');
|
|
|
- a.href = objectUrl;
|
|
|
- a.download = arr;
|
|
|
- // a.click()
|
|
|
- // 下面这个写法兼容火狐
|
|
|
- a.dispatchEvent(
|
|
|
- new MouseEvent('click', {
|
|
|
- bubbles: true,
|
|
|
- cancelable: true,
|
|
|
- view: window,
|
|
|
- })
|
|
|
- );
|
|
|
- window.URL.revokeObjectURL(data);
|
|
|
- });
|
|
|
- }
|
|
|
- );
|
|
|
- },
|
|
|
- search() {
|
|
|
- this.pageIndex = 1;
|
|
|
- this.getDataList();
|
|
|
- },
|
|
|
- // 获取数据列表
|
|
|
- getDataList() {
|
|
|
- this.dataListLoading = true;
|
|
|
- let params = {
|
|
|
- page: this.pageIndex,
|
|
|
- limit: this.pageSize,
|
|
|
- sort: 'id',
|
|
|
- order: 'desc',
|
|
|
- };
|
|
|
- if (this.searchForm.subNm != '' && this.searchForm.subNm != undefined) {
|
|
|
- params['subNm'] = '%' + this.searchForm.subNm + '%';
|
|
|
- }
|
|
|
- if (this.searchForm.compNm != '' && this.searchForm.compNm != undefined) {
|
|
|
- params['compNm'] = '%' + this.searchForm.compNm + '%';
|
|
|
- }
|
|
|
- if (this.searchForm.dateRange != '' && this.searchForm.dateRange != undefined) {
|
|
|
- params['data_date_start'] = this.searchForm.dateRange[0];
|
|
|
- params['data_date_end'] = this.searchForm.dateRange[1];
|
|
|
- }
|
|
|
- this.$http({
|
|
|
- url: '/subLoad/page',
|
|
|
- method: 'get',
|
|
|
- params: params,
|
|
|
- }).then(({ data }) => {
|
|
|
- if (data && data.code === 0) {
|
|
|
- this.dataList = data.data.list;
|
|
|
- this.totalPage = data.data.total;
|
|
|
- } else {
|
|
|
- this.dataList = [];
|
|
|
- this.totalPage = 0;
|
|
|
- }
|
|
|
- this.dataListLoading = false;
|
|
|
- });
|
|
|
- },
|
|
|
- // 每页数
|
|
|
- sizeChangeHandle(val) {
|
|
|
- this.pageSize = val;
|
|
|
- this.pageIndex = 1;
|
|
|
- this.getDataList();
|
|
|
- },
|
|
|
- // 当前页
|
|
|
- currentChangeHandle(val) {
|
|
|
- this.pageIndex = val;
|
|
|
- this.getDataList();
|
|
|
- },
|
|
|
- // 多选
|
|
|
- selectionChangeHandler(val) {
|
|
|
- this.dataListSelections = val;
|
|
|
- },
|
|
|
- // 添加/修改
|
|
|
- addOrUpdateHandler(id, type) {
|
|
|
- this.addOrUpdateOrDetailFlag = true;
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.addOrUpdate.openDialog(id, type);
|
|
|
- });
|
|
|
- },
|
|
|
- // 删除
|
|
|
- async deleteHandler(id) {
|
|
|
- var ids = id
|
|
|
- ? [Number(id)]
|
|
|
- : this.dataListSelections.map(item => {
|
|
|
- return Number(item.id);
|
|
|
- });
|
|
|
- await this.$confirm(`确定进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning',
|
|
|
- }).then(async () => {
|
|
|
- await this.$http({
|
|
|
- url: 'subLoad/delete',
|
|
|
- method: 'post',
|
|
|
- data: ids,
|
|
|
- }).then(async ({ data }) => {
|
|
|
- if (data && data.code === 0) {
|
|
|
- this.$message({
|
|
|
- message: '操作成功',
|
|
|
- type: 'success',
|
|
|
- });
|
|
|
- this.search();
|
|
|
- } else {
|
|
|
- this.$message.error(data.msg);
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
->>>>>>> 4d62baf422410d85bb1b46e1bc897b761f51beb8
|
|
|
+
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
//导出excel
|