Browse Source

site功能

master
Yangzz 7 months ago
parent
commit
160ea74c76
  1. 1
      src/api/factory/site.js
  2. 69
      src/views/modules/factory/tblbasedata.vue

1
src/api/factory/site.js

@ -9,3 +9,4 @@ export const updateSite = data => createAPI(`/site/update`,'post',data)
export const getSiteDetail = data => createAPI(`/site/${data}`,'post',data) export const getSiteDetail = data => createAPI(`/site/${data}`,'post',data)
export const exportSite = (data) => createAPI(`/site/export`,'post',data,'download')

69
src/views/modules/factory/tblbasedata.vue

@ -1,5 +1,5 @@
<script> <script>
import {generateSiteId, getSiteList, removeSite, saveSite, updateSite} from '../../../api/factory/site'
import {generateSiteId, getSiteList, removeSite, saveSite, updateSite, exportSite} from '../../../api/factory/site'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { import {
getTableDefaultListGroupLanguage, getTableDefaultListGroupLanguage,
@ -109,6 +109,24 @@ export default {
fixed: '', fixed: '',
columnWidth: 120 columnWidth: 120
}, },
{
userId: this.$store.state.user.name,
functionId: 998001,
serialNumber: '998001TableSiteCode',
tableId: "998001Table",
tableName: "Site Info Table",
columnProp: "siteCode",
headerAlign: "center",
align: "left",
columnLabel: "Site Code",
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 20,
status: true,
fixed: '',
columnWidth: 80
},
{ {
userId: this.$store.state.user.name, userId: this.$store.state.user.name,
functionId: 998001, functionId: 998001,
@ -254,6 +272,7 @@ export default {
columnWidth: 120 columnWidth: 120
}, },
], ],
exportLoading:false,
countryList:[], countryList:[],
} }
}, },
@ -520,11 +539,56 @@ export default {
}).catch((error)=>{ }).catch((error)=>{
this.$message.error(error) this.$message.error(error)
}) })
}
},
handleExport(){
if (this.siteList.length === 0){
this.$message.warning('Site data does not exist')
return
}
this.exportLoading = true;
exportSite(this.site).then(response => {
const contentType = response.headers['content-type'];
if (contentType && contentType.includes('application/json')) {
//
const reader = new FileReader();
reader.onload = () => {
const result = JSON.parse(reader.result);
this.$message.warning(result.msg);
};
reader.readAsText(response.data);
this.exportLoading = false;
} else if (response.status === 200){
const blob = new Blob([response.data], { type: response.headers['content-type'] });
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
//
//const contentDisposition = response.headers['content-disposition'];
//const fileName = contentDisposition ? decodeURIComponent(contentDisposition.split('filename*=utf-8')[1]) : 'pallet_data.xlsx';
a.download = "Site.xlsx";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
this.exportLoading = false;
}
}).catch((error)=>{
this.exportLoading = false;
this.$message.error(error);
})
},
}, },
watch:{ watch:{
'siteForm.siteCode'(newVal, oldVal){ 'siteForm.siteCode'(newVal, oldVal){
this.siteForm.siteCode = newVal.toUpperCase() this.siteForm.siteCode = newVal.toUpperCase()
},
exportLoading(newVal,oldVal){
if (newVal === true){
setTimeout(()=>{
this.exportLoading = false
},30000)
}
} }
}, },
created () { created () {
@ -556,6 +620,7 @@ export default {
<el-form-item label=" "> <el-form-item label=" ">
<el-button type="primary" v-if="!ofComponent" @click="handleSave">New</el-button> <el-button type="primary" v-if="!ofComponent" @click="handleSave">New</el-button>
<el-button type="primary" @click="getSiteList">Query</el-button> <el-button type="primary" @click="getSiteList">Query</el-button>
<el-button type="primary" :loading="exportLoading" icon="el-icon-printer" @click="handleExport">Export</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table <el-table

Loading…
Cancel
Save