123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563 |
- <template>
- <div class="billWay_container">
- <div class="title">
- <el-row>
- <el-col :span="24">
- <div class="demo-input-suffix" style="margin-left: 10px;margin-top: 15px;">
- <el-upload :action="url" :http-request="importExcel" list-type="text" :show-file-list="false" >
- <el-button type="primary">导入参数</el-button>
- <el-select style="margin-left: 120px;" v-model="noCarWayBill.billwayStatus" placeholder="运单状态">
-
- <el-option
- v-for="item in tradeStatus"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-upload>
-
- </div>
- <div class="demo-input-suffix" style="margin-top: 5px;">
- <el-input placeholder="客户名称" class="input-demo" v-model="noCarWayBill.customerName"></el-input>
- <el-input placeholder="公司名称" class="input-demo" v-model="noCarWayBill.companyName"></el-input>
- <el-input placeholder="税号" class="input-demo" v-model="noCarWayBill.taxplayerCode"></el-input>
- <el-input placeholder="运单编号" class="input-demo" v-model="noCarWayBill.billNum"></el-input>
- <el-button style="margin-right: 1%;" @click="DownloadTemplate">查询模板下载</el-button>
- <el-button type="primary" style="margin-left: 1%;" @click="exportExcel">导出报表</el-button>
- </div>
- <div class="demo-input-suffix" style="margin-top: 5px;margin-left: 10px;">
- <el-input placeholder="车牌号" class="input-demo" v-model="noCarWayBill.plateNum"></el-input>
- <el-date-picker v-model="noCarWayBill.startBegin" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss" range-separator="至" start-placeholder="运单上传开始指令始" end-placeholder="运单上传开始指令止"></el-date-picker>
- <el-date-picker v-model="noCarWayBill.endBegin" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss" range-separator="至" start-placeholder="运单上传结束指令始" end-placeholder="运单上传结束指令止"></el-date-picker>
- <!-- <el-date-picker v-model="noCarWayBill.startEnd" type="date" placeholder="开始指令上传时间止"></el-date-picker>
- <el-date-picker v-model="noCarWayBill.startBegin" type="date" placeholder="开始指令上传时间始"></el-date-picker> -->
- <!-- <el-date-picker v-model="noCarWayBill.endBegin" type="date" placeholder="结束指令上传时间始"></el-date-picker>
- <el-date-picker v-model="noCarWayBill.endEnd" type="date" placeholder="结束指令上传时间止"></el-date-picker> -->
- <el-button type="success" style="margin-left: 1%;" @click="firstLoadData">查询</el-button>
- <el-button type="success" style="margin-left: 1%;" @click="updateStatus">更新状态</el-button>
- </div>
- </el-col>
- </el-row>
- </div>
- <!-- 表格部分 -->
- <template>
- <el-table
- class="table"
- v-loading="loading"
- ref="multipleTable"
- :data="billWayTable"
- :height="heightt"
- border
- tooltip-effect="dark" @selection-change="handleSelectionChange">
- <el-table-column
- type="selection"
- width="55">
- </el-table-column>
- <el-table-column
- label="客户名称"
- prop="customerName"
- show-overflow-tooltip>
- </el-table-column>
- <el-table-column
- label="企业编号"
- prop="companyNum"
- show-overflow-tooltip>
- </el-table-column>
- <el-table-column
- prop="companyName"
- label="公司名称"
- show-overflow-tooltip>
- </el-table-column>
- <el-table-column
- prop="billNum"
- label="运单编号"
- show-overflow-tooltip>
- </el-table-column>
- <el-table-column
- prop="taxplayerCode"
- label="税号"
- show-overflow-tooltip>
- </el-table-column>
- <el-table-column
- label="车牌号码"
- prop="plateNum"
- show-overflow-tooltip>
- </el-table-column>
- <el-table-column
- prop="startTime"
- label="运单开始时间"
- width="120"
- show-overflow-tooltip>
- </el-table-column>
- <el-table-column
- prop="intfaceStartTime"
- label="开始指令时间"
- width="120"
- show-overflow-tooltip>
- </el-table-column>
- <el-table-column
- prop="predictEndTime"
- label="运单结束时间"
- width="120"
- show-overflow-tooltip>
- </el-table-column>
- <el-table-column
- prop="interfaceEndTime"
- label="结束指令时间"
- width="120"
- show-overflow-tooltip>
- </el-table-column>
- <el-table-column
- prop="sourceAddr"
- label="运单开始地址"
- width="120"
- show-overflow-tooltip>
- </el-table-column>
- <el-table-column
- prop="destAddr"
- label="运单结束地址"
- width="120"
- show-overflow-tooltip>
- </el-table-column>
- <el-table-column
- prop="fee"
- label="运单费用"
- show-overflow-tooltip>
- <template slot-scope="scope">
- <span>{{scope.row.fee/100| rounding}}</span>
- </template>
- </el-table-column>
- <el-table-column
- label="运单状态"
- show-overflow-tooltip>
- <template slot-scope="scope">
- <span v-if="scope.row.billwayStatus == 1" style="color: green">未结束</span>
- <span v-else-if="scope.row.billwayStatus == -2" style="color: red">上传失败</span>
- <span v-else-if="scope.row.billwayStatus == -3" style="color: red">结束指令上传失败</span>
- <span v-else-if="scope.row.billwayStatus == 2" style="color: green">开票中</span>
- <span v-else-if="scope.row.billwayStatus == 3" style="color: green">开票完成</span>
- <span v-else-if="scope.row.billwayStatus == 4" style="color: red">超时运单</span>
- </template>
- </el-table-column>
- <el-table-column
- label="是否成功"
- show-overflow-tooltip>
- <template slot-scope="scope">
- <span v-if="scope.row.billwayStatus == -2 || scope.row.billwayStatus == -3" style="color: red">失败</span>
- <span v-else-if="scope.row.billwayStatus != -2 && scope.row.billwayStatus != -3" style="color: green">成功</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="failReason"
- label="失败原因"
- show-overflow-tooltip>
- </el-table-column>
- <el-table-column
- prop="updateTime"
- label="最后更新时间"
- width="120"
- show-overflow-tooltip>
- </el-table-column>
- <el-table-column
- prop="hisFlag"
- label="运单类型"
- show-overflow-tooltip>
- <template slot-scope="scope">
- <span v-if="scope.row.hisFlag == 0" >实时运单</span>
- <span v-else-if="scope.row.hisFlag == 1">历史运单</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="interType"
- label="对接方式"
- show-overflow-tooltip>
- <template slot-scope="scope">
- <span v-if="scope.row.interType == 0">接口</span>
- <span v-if="scope.row.interType == 1">平台</span>
- <span v-if="scope.row.interType == 3">迁移数据</span>
- </template>
- </el-table-column>
- </el-table>
- </template>
- <!-- 分页 -->
- <div class="block">
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="current"
- :page-sizes="[6, 8, 10, 20, 50, 100]"
- :page-size="pagesize"
- layout="total, sizes, prev, pager, next, jumper"
- :total="total">
- </el-pagination>
- </div>
- </div>
- </template>
- <script type="text/javascript">
- import FileSaver from "file-saver";
- import CsvExportor from "csv-exportor";
- import XLSX from "xlsx";
- export default {
- data(){
- return{
- noCarWayBill:{
- billNum:''
- },
- formUserList: {
- "file": ""
- },
- tradeStatus:[
- {"label":"上传失败","value":"-2"},
- {"label":"结束指令上传失败","value":"-3"},
- {"label":"未结束","value":"1"},
- {"label":"开票中","value":"2"},
- {"label":"开票完成","value":"3"},
- {"label":"超时运单","value":"4"}],
- multipleSelection: [],
- optionone: [{
- value: 0,
- label: '实时运单'
- }, {
- value: 1,
- label: '历史运单'
- }],
- billWayTable:[],
- current: 1,
- pagesize: 8,
- hightt:'0px',
- total:''
- }
- },
- created() {
- //设置表格高度
- this.heightt = '300px';
- this.loadData();
- },
- filters: {
- rounding (value) {
- return value.toFixed(2)
- }
- },
- methods:{
- firstLoadData(){
- this.current = 1;
- this.pagesize = 8;
- this.loadData();
- },
- // 列表展示
- async loadData() {
- const formData = new FormData();
- formData.append('current', this.current);
- formData.append('size', this.pagesize);
- for(var i in this.noCarWayBill){
- formData.append(i,this.noCarWayBill[i]);
- }
- const response = await this.$http.post(`noCar/findBillWay`, formData);
- if (response.data.code === 0) {
- this.billWayTable = response.data.data.records;
- this.total = response.data.data.total;
- }
- },
- importExcel (content) {
- const file = content.file
- // let file = file.files[0] // 使用传统的input方法需要加上这一步
- const filename = file.name
- if(!filename||typeof filename!='string'){
- this.$message('格式错误!请重新选择')
- return
- }
- let a = filename.split('').reverse().join('');
- let types = a.substring(0,a.search(/\./)).split('').reverse().join('');
- const fileType = ['xlsx', 'xlc', 'xlm', 'xls', 'xlt', 'xlw', 'csv'].some(item => item === types)
- if (!fileType) {
- this.$message(fileType+'格式错误!请重新选择xlsx xls格式')
- return
- }
- this.file2Xce(file).then(tabJson => {
- var billNums = '';
- if (tabJson && tabJson.length > 0) {
- this.xlsxJson = tabJson
- this.fileList = this.xlsxJson[0].sheet
- this.fileList.forEach((item, index, arr) => {
- if(item['运单编号']!=null && item['运单编号']!='' && typeof item['运单编号']!='undefined'){
- billNums+= item['运单编号'].trim()+',';
- }
- });
- }
- if(billNums!=''){
- this.noCarWayBill.billNum =billNums.substring(0,billNums.length-1);
- }
- })
- },
- file2Xce (file) {
- return new Promise(function (resolve, reject) {
- const reader = new FileReader()
- reader.onload = function (e) {
- const data = e.target.result
- this.wb = XLSX.read(data, {
- type: 'binary'
- })
- const result = []
- var are = (this.wb.Sheets.Sheet1)['!ref'];
- var areRe = are.replace('A1','A2');
- (this.wb.Sheets.Sheet1)['!ref'] = areRe;
- this.wb.SheetNames.forEach((sheetName) => {
- result.push({
- sheetName: sheetName,
- sheet: XLSX.utils.sheet_to_json(this.wb.Sheets[sheetName])
- })
- })
- resolve(result)
- }
- // reader.readAsBinaryString(file.raw)
- reader.readAsBinaryString(file) // 传统input方法
- })
- },
- // 下载模板
- DownloadTemplate() {
- var url = hostUrl+"noCar/templateDownload?fileName=5"
- window.location.href= url;
- },
- handleRemove(file, fileList) {
- },
- handlePreview(file) {
- },
- handleSuccess (a) {
- this.formUserList.file = a.raw;
- },
- handleSelectionChange(value){
- this.multipleSelection = value;
- },
- async updateStatus(){
- const formData = new FormData();
- formData.append('noCarWayBillStr', JSON.stringify(this.multipleSelection));
- const response = await this.$http.post(`noCar/updateStatus`,formData);
- if(response.data.code === 0) {
- this.loadData();
- this.$message({
- type: 'success',
- message: '更新成功'
- });
- }else {
- this.$message({
- type: 'error',
- message: '更新失败'
- });
- }
- },
- // 分页方法
- handleSizeChange(val) {
- this.pagesize = val;
- this.loadData();
- },
- handleCurrentChange(val) {
- this.current = val;
- this.loadData();
- },
- // 批量上传模板信息
- async batchUpload() {
- this.fullscreenLoading = true;
- const formData = new FormData();
- formData.append('file', this.formUserList.file);
- const response = await this.$http.post(`noCar/batchImportNocarBillWay`,formData);
- var {data: { code, msg, data }} = response;
- if(code === 0 && msg === '1') {
- this.fullscreenLoading = false;
- this.billWayTable = response.data.data;
- this.total = response.data.data.length;
- }else {
- this.fullscreenLoading = false;
- this.$message.error('数据存在错误,请检查文件中数据');
- }
- },
- formartNum(wb){
- var sheet = wb['Sheets']['Sheet1'];
- var replaceTemp = [];
- for(var i in sheet){
- if(sheet[i]['v'] == '运单费用'){
- replaceTemp.push(i.replace(/[0-9]/g,''));
- continue;
- }
- if(replaceTemp.includes(i.replace(/[0-9]/g,''))){
- sheet[i]['t']='n';
- }
- }
- },
- async exportExcel() {
- const loading = this.$loading({
- lock: true,
- text: '系统正在努力接收中,过程大概需要几分钟的时间,请您耐心等待...',
- spinner: 'el-icon-loading',
- background: 'rgba(0, 0, 0, 0.7)'
- });
- var recodes = [];
- for(var j=1;j<=this.total/10000+1;j++){
- const formData = new FormData();
- formData.append('current', j);
- formData.append('size', 10000);
- for(var i in this.noCarWayBill){
- formData.append(i,this.noCarWayBill[i]);
- }
- const response = await this.$http.post(`noCar/findBillWay`, formData);
- if (response.data.code === 0) {
- recodes = recodes.concat(response.data.data.records);
- }
- }
-
-
- // 设置当前日期
- let time = new Date();
- let year = time.getFullYear();
- let month = time.getMonth() + 1;
- let day = time.getDate();
- let name = "无车运单查询列表_"+year + "" + month + "" + day;
- let cloums = [
- {"title":"客户名称","key":"customerName"},
- {"title":"企业编号","key":"companyNum"},
- {"title":"公司名称","key":"companyName"},
- {"title":"运单号","key":"billNum"},
- {"title":"税号","key":"taxplayerCode"},
- {"title":"车牌号码","key":"plateNum"},
- {"title":"运单开始时间","key":"startTime"},
- {"title":"开始指令时间","key":"intfaceStartTime"},
- {"title":"运单结束时间","key":"predictEndTime"},
- {"title":"结束指令时间","key":"interfaceEndTime"},
- {"title":"运单开始地址","key":"sourceAddr"},
- {"title":"运单结束地址","key":"destAddr"},
- {"title":"运单费用(元)","key":"fee"},
- {"title":"运单状态","key":"billwayStatus"},
- {"title":"失败原因","key":"failReason"},
- {"title":"运单类型","key":"hisFlag"},
- ];
- await this.exportExcelComm(cloums,recodes,name,loading);
-
- },
- formatJson (filterVal, jsonData) {
- return jsonData.map(v => filterVal.map(j => {
- if(j == 'billwayStatus'){
- if(v[j] == 1){
- return "未结束";
- } else if(v[j] == -2){
- return "上传失败";
- }else if(v[j] == -3){
- return "指令结束上传失败";
- }else if(v[j] == 2){
- return "开票中";
- }else if(v[j] == 3){
- return "开票完成";
- }else {
- return "超时运单";
- }
- }else if(j =='fee'){
- return v[j]/100;
- }else if(j=='hisFlag'){
- if(v[j] == 0){
- return "实时运单";
- }else{
- return "历史运单";
- }
- }else if(j=='billNum'){
- return v[j]+'\t';
- }
- else{
- return v[j];
- }
-
- }));
- },
- // 导出Excel
- exportExcelComm(columns,list,excelName,loading){
- require.ensure([], () => {
- const { export_json_to_excel } = require('@/vendor/Export2Excel');
- let tHeader = []
- let filterVal = []
- columns.forEach(item =>{
- tHeader.push(item.title)
- filterVal.push(item.key)
- })
- // for(var i =0;i<list.length/100000;i++){
- // const data = this.formatJson(filterVal, list.slice(i*100000,(i+1)*100000>list.length?list.length:(i+1)*100000));
- // export_json_to_excel(tHeader, data, excelName+'_'+i);
- // }
- const data = this.formatJson(filterVal,list);
- data.unshift(tHeader);
- CsvExportor.downloadCsv(data, { tHeader }, excelName+".csv");
- loading.close();
- })
- }
- }
- };
- </script>
- <style>
- .billWay_container {
- border: 1px solid #d9d9d9;
- border-radius: 10px;
- }
- .billWay_container .title {
- font-size: 5px;
- margin-bottom: 20px;
- }
- .billWay_container .top {
- padding-top: 20px;
- padding-left: 20px;
- }
- .billWay_container .text {
- display: inline-block;
- color: #000;
- font-size: 16px ;
- margin-left: 1%;
- }
- .billWay_container .input-demo {
- display: inline-block;
- width: 15%;
- margin-left: 1%;
- }
- .billWay_container .block {
- font-size: 5px;
- text-align: center;
- margin-top: 25px;
- margin-bottom: 25px;
- }
- .billWay_container .el-dialog {
- width: 60%;
- }
- .billWay_container .el-dialog__header, .el-dialog__body {
- padding: 0 20px;
- }
- .billWay_container .tou {
- font-size: 20px;
- height: 30px;
- line-height: 30px;
- padding-top: 15px;
- }
- .billWay_container .line {
- margin-top: 15px;
- margin-bottom: 15px;
- width: 100%;
- height: 2px;
- background-color: #d9d9d9;
- }
- .billWay_container .xinxi {
- text-align: center;
- margin: 15px auto;
- font-size: 18px;
- }
- </style>
|