@@ -3,4 +3,4 @@ ENV = 'development' | |||
# .env.development | |||
# base api | |||
VITE_APP_BASE_URL = 'http://10.52.0.172:10389/csms' | |||
VITE_APP_BASE_URL = 'http://10.52.0.172:10389/csms' |
@@ -3,4 +3,4 @@ ENV = 'production' | |||
# .env.production | |||
# base api | |||
VITE_APP_BASE_URL = 'http://10.52.0.172:10389/csms' | |||
VITE_APP_BASE_URL = 'http://10.52.0.172:10389/csms' |
@@ -3,7 +3,7 @@ | |||
<el-button ref="hwcell" size="small" type="primary" @click="exportExcel" v-if="isShow">文件导出</el-button> | |||
<el-table :data="tableData" style="width: 100%" border> | |||
<el-table-column type="index" label="序号" width="60" /> | |||
<el-table-column prop="etcCardNumber" label="ETC卡号" width="190" /> | |||
<el-table-column prop="etcCardNumber" label="ETC卡号" width="145" /> | |||
<el-table-column prop="licensePlateNumber" label="车牌号" width="100" /> | |||
<el-table-column prop="consumptionType" label="消费类型" width="90" /> | |||
<el-table-column prop="entranceTime" label="入口时间" width="110" /> |
@@ -26,6 +26,10 @@ export function mergeOptions(src: any, opts: any) { | |||
return optsRet; | |||
} | |||
/** | |||
* 返回当前时间 | |||
* @returns | |||
*/ | |||
export function barkTime() { | |||
const nowdate = new Date(); | |||
const year = nowdate.getFullYear(), | |||
@@ -41,10 +45,40 @@ export function barkTime() { | |||
ss = checkTime(s); | |||
return (year + checkTime(month) + checkTime(date) + hs + ms + ss) + '' | |||
} | |||
function checkTime(i: number) { | |||
let s = i + '' | |||
if (i < 10) { | |||
s = "0" + i; | |||
} | |||
return s; | |||
} | |||
/** | |||
* 文件上传处理 | |||
* @param uploadFile 文件对象 | |||
* @param fileName 文件名称 | |||
* @param fileSize 文件大小限制 | |||
* @returns | |||
*/ | |||
export function barkFileName(uploadFile: any, fileName: string, fileSize: number = 0) { | |||
const size: number = Number((uploadFile.size / 1024).toFixed(2)); //KB大小 | |||
return new Promise((resolve, reject) => { | |||
if (fileName) { | |||
if (fileSize !== 0) { | |||
if (size > fileSize) { | |||
reject('超出文件大小限制') | |||
} | |||
} | |||
//截取后缀名 | |||
const suffix = (uploadFile.name + '').split('.')[1] | |||
// 修改文件名称 | |||
uploadFile.name = fileName + barkTime() + '.' + suffix | |||
resolve(uploadFile) | |||
} else { | |||
reject('模块名不能为空') | |||
} | |||
}) | |||
} |
@@ -1,6 +1,6 @@ | |||
<template> | |||
<!-- 卡签补办 --> | |||
<CRUD ref="crudRef" :homeData="datas"> | |||
<crud-template ref="crudRef" :homeData="datas"> | |||
<!-- 自定义搜索 --> | |||
<template #search="{ searchCondition }"> | |||
<!-- 搜索 监听回车 @keyup.enter.native="search"--> | |||
@@ -37,11 +37,11 @@ | |||
<el-button type="primary">提交</el-button> | |||
</span> | |||
</template> | |||
</CRUD> | |||
</crud-template> | |||
</template> | |||
<script setup lang="ts"> | |||
// @ts-ignore crudFrom模板 | |||
import CRUD from "@/crud/index.vue" | |||
import CrudTemplate from "@/crud/index.vue" | |||
import { | |||
Data | |||
} from '@/data/cardAfter/cardFillDo' //表单配置 |
@@ -1,262 +1,394 @@ | |||
<template> | |||
<div class="app_container"> | |||
<div class="menu"> | |||
<el-form :inline="true" :model="formInline" class="demo-form-inline"> | |||
<el-form-item label="导入时间"> | |||
<div class="block"> | |||
<el-date-picker v-model="value1" type="datetime" placeholder="请选择申请开始时间" /> | |||
</div> | |||
<el-icon> | |||
<semi-select /> | |||
</el-icon> | |||
<div class="block"> | |||
<el-date-picker v-model="value2" type="datetime" placeholder="请选择申请结束时间" /> | |||
</div> | |||
</el-form-item> | |||
<el-form-item label="对方账号"> | |||
<el-input v-model="formInline.user" placeholder="对方账号" /> | |||
</el-form-item> | |||
<el-form-item label="对方户名"> | |||
<el-input v-model="formInline.user" placeholder="对方户名" /> | |||
</el-form-item> | |||
<el-form-item label="交易流水编号"> | |||
<el-input v-model="formInline.user" placeholder="交易流水编号" /> | |||
</el-form-item> | |||
<el-form-item> | |||
<el-button :icon="Search" type="primary">查询</el-button> | |||
<el-button type="info">重置</el-button> | |||
<el-button type="primary">导入Excel</el-button> | |||
<el-button type="primary">下载导入模板</el-button> | |||
</el-form-item> | |||
</el-form> | |||
</div> | |||
<el-table :data="tableData" border style="width: 100%" class="table_box" stripe > | |||
<el-table-column prop="date" label="交易流水号" width="200px"/> | |||
<el-table-column prop="name" label="交易时间" width="200px"/> | |||
<el-table-column prop="address" label="支出金额" width="200px"/> | |||
<el-table-column prop="number" label="收入金额" width="200px"/> | |||
<el-table-column prop="time" label="对方账号" width="200px"/> | |||
<el-table-column prop="type" label="对方户名" width="200px"/> | |||
<el-table-column prop="regname" label="对方行名" width="200px"/> | |||
<el-table-column prop="nonumber" label="对公账户账号" width="200px"/> | |||
<el-table-column prop="use" label="用途" width="200px"/> | |||
<el-table-column prop="nonumbers" label="附言" width="200px"/> | |||
<el-table-column prop="usetype" label="摘要" width="200px"/> | |||
<el-table-column label="操作" class="table_btn" width="500px" align="center"> | |||
<el-tooltip content="拒绝" placement="top"> | |||
<el-button type="warning" @click="опровергать">拒绝</el-button> | |||
</el-tooltip> | |||
<el-tooltip content="同意" placement="top"> | |||
<el-button type="warning" @click="agree">同意</el-button> | |||
</el-tooltip> | |||
<el-tooltip content="请输入对公账号" placement="top"> | |||
<el-button type="warning" @click="dialogFormVisible = true">请输入对公账号</el-button> | |||
</el-tooltip> | |||
</el-table-column> | |||
</el-table> | |||
<div class="page_box"> | |||
<el-pagination :page-size="20" :pager-count="11" layout="prev, pager, next" :total="1000" /> | |||
</div> | |||
<el-dialog v-model="dialogFormVisible" :title="title"> | |||
<el-form :model="form"> | |||
<el-form-item label="输入对方对公账号" :label-width="formLabelWidth"> | |||
<el-input v-model="form.phone" autocomplete="off" disabled /> | |||
</el-form-item> | |||
</el-form> | |||
<template #footer> | |||
<span class="dialog-footer"> | |||
<el-button @click="dialogFormVisible = false">确定</el-button> | |||
<el-button type="primary" @click="dialogFormVisible = false">关闭</el-button> | |||
</span> | |||
</template> | |||
</el-dialog> | |||
</div> | |||
<div class="app_container"> | |||
<div class="menu"> | |||
<el-form :inline="true" :model="formInline" class="demo-form-inline"> | |||
<el-form-item label="导入时间"> | |||
<div class="block"> | |||
<el-date-picker v-model="start_time" type="datetime" placeholder="请选择申请开始时间"/> | |||
</div> | |||
<el-icon> | |||
<semi-select/> | |||
</el-icon> | |||
<div class="block"> | |||
<el-date-picker v-model="end_time" type="datetime" placeholder="请选择申请结束时间"/> | |||
</div> | |||
</el-form-item> | |||
<el-form-item label="对方账号"> | |||
<el-input v-model="formInline.Number" placeholder="对方账号"/> | |||
</el-form-item> | |||
<el-form-item label="对方户名"> | |||
<el-input v-model="formInline.coNumber" placeholder="对方户名"/> | |||
</el-form-item> | |||
<el-form-item label="交易流水编号"> | |||
<el-input v-model="formInline.user" placeholder="交易流水编号"/> | |||
</el-form-item> | |||
<el-form-item> | |||
<el-button :icon="Search" type="primary" @click="grabble">查询</el-button> | |||
<el-button type="info" @click="resive">重置</el-button> | |||
<el-button type="primary">导入Excel</el-button> | |||
<el-button type="primary">下载导入模板</el-button> | |||
</el-form-item> | |||
</el-form> | |||
</div> | |||
<el-table :data="tableData" border style="width: 100%" class="table_box" stripe> | |||
<el-table-column prop="serialNo" label="交易流水号" width="200px"/> | |||
<el-table-column prop="createTime" label="交易时间" width="200px"/> | |||
<el-table-column prop="outFee" label="支出金额" width="200px"/> | |||
<el-table-column prop="incomeFee" label="收入金额" width="200px"/> | |||
<el-table-column prop="reciprocalAccount" label="对方账号" width="200px"/> | |||
<el-table-column prop="reciprocalAccountName" label="对方户名" width="200px"/> | |||
<el-table-column prop="reciprocalBankName" label="对方行名" width="200px"/> | |||
<el-table-column prop="reciprocalAccountName" label="对公账户账号" width="200px"/> | |||
<el-table-column prop="useage" label="用途" width="200px"/> | |||
<el-table-column prop="remarks" label="附言" width="200px"/> | |||
<el-table-column prop="snippet" label="摘要" width="200px"/> | |||
<el-table-column label="操作" class="table_btn" width="500px" align="center"> | |||
<template v-slot="scope"> | |||
<el-tooltip content="拒绝" placement="top"> | |||
<el-button type="warning" @click="опровергать(scope.row)">拒绝</el-button> | |||
</el-tooltip> | |||
<el-tooltip content="同意" placement="top"> | |||
<el-button type="warning" @click="agree(scope.row)">同意</el-button> | |||
</el-tooltip> | |||
<el-tooltip content="请输入对公账号" placement="top"> | |||
<el-button type="warning" @click="opendialo">请输入对公账号</el-button> | |||
</el-tooltip> | |||
</template> | |||
</el-table-column> | |||
</el-table> | |||
<div class="page_box"> | |||
<el-pagination :page-size="20" :pager-count="11" layout="prev, pager, next" :total="pageCount" @current-change="pagechange"/> | |||
</div> | |||
<el-dialog v-model="dialogFormVisible" :title="title"> | |||
<el-form :model="form"> | |||
<el-form-item label="输入对方对公账号" :label-width="formLabelWidth"> | |||
<el-input v-model="form.phone" autocomplete="off"/> | |||
</el-form-item> | |||
</el-form> | |||
<template #footer> | |||
<span class="dialog-footer"> | |||
<el-button @click="account">确定</el-button> | |||
<el-button type="primary" @click="dialogFormVisible = false">关闭</el-button> | |||
</span> | |||
</template> | |||
</el-dialog> | |||
<el-dialog v-model="dialogFormVisibles" title="驳回申请"> | |||
<el-form :model="form"> | |||
<el-form-item label="驳回原因" :label-width="formLabelWidth"> | |||
<el-input v-model="form.data_msg" autocomplete="off" placeholder="请输入驳回原因"/> | |||
</el-form-item> | |||
</el-form> | |||
<template #footer> | |||
<span class="dialog-footer"> | |||
<el-button @click="dialogFormVisibles = false">关闭</el-button> | |||
<el-button type="primary" @click="getMsg">确定</el-button> | |||
</span> | |||
</template> | |||
</el-dialog> | |||
</div> | |||
</template> | |||
<script lang="ts" setup> | |||
//模块导入 | |||
import { | |||
Search | |||
} from '@element-plus/icons-vue' | |||
import { | |||
reactive, | |||
ref | |||
} from 'vue' | |||
import {ElMessage, ElMessageBox} from 'element-plus' | |||
//模块导入 | |||
import { Search } from '@element-plus/icons-vue' | |||
import { reactive, ref, getCurrentInstance, onMounted } from 'vue' | |||
import { ElMessage, ElMessageBox } from 'element-plus' | |||
//变量声明 | |||
const formInline = reactive({ | |||
user: '', | |||
region: '', | |||
}) | |||
const onSubmit = () => { | |||
console.log('submit!') | |||
} | |||
let title = ref("对公账户信息") | |||
const options = [{ | |||
value: '', | |||
label: '全部', | |||
}, | |||
{ | |||
value: '1', | |||
label: '驳回', | |||
}, | |||
{ | |||
value: '0', | |||
label: '待审核', | |||
}, | |||
{ | |||
value: '1', | |||
label: '已启用', | |||
}, | |||
{ | |||
value: '2', | |||
label: '待修改初始密码', | |||
}, | |||
] | |||
let value1 = ref('') | |||
let value2 = ref('') | |||
let value3 = ref('') | |||
let value4 = ref('') | |||
let dialogTableVisible = ref(false) | |||
let dialogFormVisible = ref(false) | |||
let formLabelWidth = '140px' | |||
let form = reactive({ | |||
phone: '13078580843',//手机号 | |||
region: '',//验证码 | |||
delivery: false,//是否展示详细 | |||
number:''//对公账户资金账户编号 | |||
}) | |||
const optiones = [{ | |||
value: '2', | |||
label: '2', | |||
}, | |||
{ | |||
value: '6', | |||
label: '6', | |||
}, | |||
{ | |||
value: '10', | |||
label: '10', | |||
}, | |||
{ | |||
value: '15', | |||
label: '15', | |||
}, | |||
{ | |||
value: '30', | |||
label: '30', | |||
}, | |||
] | |||
const defaultTime = new Date(2000, 1, 1, 12, 0, 0) | |||
const shortcuts = [{ | |||
text: 'Today', | |||
value: new Date(), | |||
}, | |||
{ | |||
text: 'Yesterday', | |||
value: () => { | |||
const date = new Date() | |||
date.setTime(date.getTime() - 3600 * 1000 * 24) | |||
return date | |||
}, | |||
}, | |||
{ | |||
text: 'A week ago', | |||
value: () => { | |||
const date = new Date() | |||
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7) | |||
return date | |||
}, | |||
}, | |||
] | |||
const tableData = [ | |||
{ | |||
date: '34625032', | |||
name: '2022-05-07', | |||
address: '0.0', | |||
number: "5000.0", | |||
time: "2021-06-22T12:52:17", | |||
type: "23921001040002085", | |||
regname: "贵州省黔西南州水文水资源局", | |||
regtime: "中国农业银行股份有限公司兴义南盘江支行", | |||
nonumber:"szm123456", | |||
nonumbers:"贵E15389充ETC", | |||
use:"测试", | |||
usetype:"小额来账自动入账" | |||
} | |||
] | |||
//变量声明 | |||
const { proxy } = getCurrentInstance() | |||
const formInline = ref({ | |||
user:'', | |||
region: '', | |||
number:'', | |||
coNumber:'', | |||
user:'', | |||
}) | |||
const onSubmit = () => { | |||
console.log('submit!') | |||
} | |||
let title = ref('对公账户信息') | |||
const options = [ | |||
{ | |||
value: '', | |||
label: '全部' | |||
}, | |||
{ | |||
value: '1', | |||
label: '驳回' | |||
}, | |||
{ | |||
value: '0', | |||
label: '待审核' | |||
}, | |||
{ | |||
value: '1', | |||
label: '已启用' | |||
}, | |||
{ | |||
value: '2', | |||
label: '待修改初始密码' | |||
} | |||
] | |||
let start_time = ref('') //申请选择开始时间 | |||
let end_time = ref('') //申请选择结束时间 | |||
let value3 = ref('') | |||
let value4 = ref('') | |||
let pageNo = ref(1) | |||
let dialogTableVisible = ref(false) | |||
let dialogFormVisible = ref(false) | |||
let dialogFormVisibles = ref(false) | |||
let pageCount = ref(0) //总页数 | |||
let formLabelWidth = '140px' | |||
let form = reactive({ | |||
phone: '13078580843', //手机号 | |||
region: '', //验证码 | |||
delivery: false, //是否展示详细 | |||
number: '', //对公账户资金账户编号 | |||
data_msg:'',//驳回原因 | |||
data_id:''//点击表格获取的id | |||
}) | |||
const optiones = [ | |||
{ | |||
value: '2', | |||
label: '2' | |||
}, | |||
{ | |||
value: '6', | |||
label: '6' | |||
}, | |||
{ | |||
value: '10', | |||
label: '10' | |||
}, | |||
{ | |||
value: '15', | |||
label: '15' | |||
}, | |||
{ | |||
value: '30', | |||
label: '30' | |||
} | |||
] | |||
const defaultTime = new Date(2000, 1, 1, 12, 0, 0) | |||
const shortcuts = [ | |||
{ | |||
text: 'Today', | |||
value: new Date() | |||
}, | |||
{ | |||
text: 'Yesterday', | |||
value: () => { | |||
const date = new Date() | |||
date.setTime(date.getTime() - 3600 * 1000 * 24) | |||
return date | |||
} | |||
}, | |||
{ | |||
text: 'A week ago', | |||
value: () => { | |||
const date = new Date() | |||
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7) | |||
return date | |||
} | |||
} | |||
] | |||
const tableData = ref([ | |||
{ | |||
accountId: 11, | |||
channelId: 53, | |||
channelName: 'LMJVTSCAA', | |||
createTime: '1984/01/11 16:42:41', | |||
fileName: 'LGCRFGITS', | |||
filePath: 'MHWXGWCPR', | |||
id: '820000199611275614', | |||
incomeFee: 78, | |||
outFee: 91, | |||
reason: 'JMQOEDBRD', | |||
reciprocalAccount: 'CUCUQBHPR', | |||
reciprocalAccountName: 'SGUUYJEIJ', | |||
reciprocalBankName: 'JIUPWBXSY', | |||
remarks: 'HVLJOFURE', | |||
serialNo: 'MBBHHKVNX', | |||
snippet: 'PPFAKYCKG', | |||
staffId: 'MQWJVIMRO', | |||
staffName: 'JQLOMWANP', | |||
status: 1, | |||
transTime: 'MYHFJBLCP', | |||
updateTime: '1982/10/14 13:50:50', | |||
useage: 'OYQYKVWPG' | |||
} | |||
]) | |||
//事件 | |||
//同意申请 | |||
const agree = (row) => { | |||
console.log(row.id) | |||
dialogFormVisible.value = false; | |||
ElMessageBox.confirm('确定通过这个申请?', '警告', { | |||
confirmButtonText: '确定', | |||
cancelButtonText: '取消', | |||
type: 'warning' | |||
}) | |||
.then(() => { | |||
proxy.$request.post('/advancepayment/confirm', {}, { | |||
baseURL: 'http://localhost:8089', | |||
id:row.id, | |||
// message:form.data_msg, | |||
value:0 | |||
}).then((res) => { | |||
console.log(res,form.data_id,form.value); | |||
if(res.data.success){ | |||
ElMessage({ | |||
type: 'success', | |||
message: '操作成功!' | |||
}) | |||
grabble() | |||
} | |||
}).catch((err) => { | |||
console.log(err); | |||
}) | |||
}) | |||
.catch(() => { | |||
ElMessage({ | |||
type: '取消', | |||
message: '已取消' | |||
}) | |||
}) | |||
} | |||
//驳回申请 | |||
const опровергать = (row) => { | |||
dialogFormVisible.value = false; | |||
form.data_id = row.id | |||
ElMessageBox.confirm('确定驳回这个申请?', '警告', { | |||
confirmButtonText: '确定', | |||
cancelButtonText: '取消', | |||
type: 'warning' | |||
}) | |||
.then(() => { | |||
dialogFormVisibles.value = true; | |||
}) | |||
.catch(() => { | |||
ElMessage({ | |||
type: '取消', | |||
message: '已取消' | |||
}) | |||
}) | |||
} | |||
//驳回申请原因 | |||
const getMsg=()=>{ | |||
proxy.$request.post('/advancepayment/confirm', {}, { | |||
baseURL: 'http://localhost:8089', | |||
id:form.data_id, | |||
message:form.data_msg, | |||
value:1 | |||
}).then((res) => { | |||
console.log(res,form.data_id,form.data_msg); | |||
if(res.data.success){ | |||
ElMessage({ | |||
type: 'success', | |||
message: '操作成功!' | |||
}) | |||
dialogFormVisibles.value = false; | |||
grabble() | |||
} | |||
}).catch((err) => { | |||
console.log(err); | |||
}) | |||
} | |||
//事件 | |||
//同意申请 | |||
const agree = (id:any) => { | |||
ElMessageBox.confirm( | |||
'确定同意?', | |||
'警告', { | |||
confirmButtonText: '确定', | |||
cancelButtonText: '取消', | |||
type: 'warning', | |||
} | |||
) | |||
.then(() => { | |||
ElMessage({ | |||
type: 'success', | |||
message: '操作成功!', | |||
}) | |||
}) | |||
.catch(() => { | |||
ElMessage({ | |||
type: '取消', | |||
message: '已取消', | |||
}) | |||
}) | |||
} | |||
//驳回申请 | |||
const опровергать = (id:any) => { | |||
ElMessageBox.confirm( | |||
'确定拒绝?', | |||
'警告', { | |||
confirmButtonText: '确定', | |||
cancelButtonText: '取消', | |||
type: 'warning', | |||
} | |||
) | |||
.then(() => { | |||
ElMessage({ | |||
type: 'success', | |||
message: '操作成功!', | |||
}) | |||
}) | |||
.catch(() => { | |||
ElMessage({ | |||
type: '取消', | |||
message: '已取消', | |||
}) | |||
}) | |||
//搜索 | |||
const grabble = () => { | |||
let data = { | |||
corporateAccountId: 'string', | |||
endTime: '2020/01/01 00:00:00', | |||
pageNo: 0, | |||
pageSize: 0, | |||
startTime: '2020/01/01 00:00:00', | |||
type: 0, | |||
baseURL: 'http://localhost:8089' | |||
} | |||
proxy.$request | |||
.post('/advancepayment/queryPage', {}, data) | |||
.then((res) => { | |||
console.log(res, form.data_id, form.value) | |||
if (res.data.success) { | |||
tableData.value = res.data.result | |||
console.log('res', tableData) | |||
pageCount.value = res.data.pageCount | |||
} | |||
}) | |||
.catch((err) => { | |||
console.log(err) | |||
}) | |||
} | |||
onMounted(() => { | |||
grabble() | |||
}) | |||
//获取当前页数据 | |||
const pagechange = (el) => { | |||
console.log('el', el) | |||
pageNo.value = el | |||
grabble() | |||
} | |||
//重置 | |||
const resive = () => { | |||
console.log('重置') | |||
start_time.value = ''; | |||
end_time.value = ''; | |||
formInline.value.number= ''; | |||
formInline.value.coNumber = ''; | |||
formInline.value.user= ''; | |||
} | |||
//填入对方对公账号 | |||
const account = ()=>{ | |||
let data = { | |||
id:form.data_id, | |||
accountId:form.phone, | |||
baseURL: 'http://localhost:8089' | |||
} | |||
proxy.$request.post('/advancepayment/account', {}, data).then((res) => { | |||
console.log(res, form.data_id, form.value) | |||
if (res.data.success) { | |||
dialogFormVisible.value = false; | |||
grabble(); | |||
} | |||
}) | |||
.catch((err) => { | |||
console.log(err) | |||
}) | |||
} | |||
//打开填写对公账户的弹窗 | |||
const opendialo = (row)=>{ | |||
form.data_id = row.id; | |||
dialogFormVisible.value = true; | |||
} | |||
</script> | |||
<style lang="scss"> | |||
.app_container { | |||
padding: 20px; | |||
display: flex; | |||
flex-direction: column; | |||
.app_container { | |||
padding: 20px; | |||
display: flex; | |||
flex-direction: column; | |||
.table_box { | |||
margin-top: 25px; | |||
.table_btn{ | |||
display: flex; | |||
flex-direction: column; | |||
align-self: stretch; | |||
align-content: space-around; | |||
align-items: flex-start; | |||
} | |||
} | |||
.table_box { | |||
margin-top: 25px; | |||
.table_btn { | |||
display: flex; | |||
flex-direction: column; | |||
align-self: stretch; | |||
align-content: space-around; | |||
align-items: flex-start; | |||
} | |||
} | |||
.page_box { | |||
margin-top: 25px; | |||
} | |||
} | |||
.page_box { | |||
margin-top: 25px; | |||
} | |||
} | |||
</style> |
@@ -4,13 +4,13 @@ | |||
<el-form :inline="true" :model="formInline" class="demo-form-inline"> | |||
<el-form-item label="申请时间"> | |||
<div class="block"> | |||
<el-date-picker v-model="start_time" type="datetime" placeholder="请选择申请开始时间"/> | |||
<el-date-picker v-model="start_time" type="datetime" placeholder="请选择申请开始时间" format="YYYY/MM/DD" value-format="YYYY/MM/DD"/> | |||
</div> | |||
<el-icon> | |||
<semi-select/> | |||
</el-icon> | |||
<div class="block"> | |||
<el-date-picker v-model="end_time" type="datetime" placeholder="请选择申请结束时间"/> | |||
<el-date-picker v-model="end_time" type="datetime" placeholder="请选择申请结束时间" format="YYYY/MM/DD" value-format="YYYY/MM/DD"/> | |||
</div> | |||
</el-form-item> | |||
<el-form-item label="账号状态"> | |||
@@ -74,7 +74,7 @@ | |||
</el-table> | |||
<div class="page_box"> | |||
<el-pagination :page-size="pageSize" :pager-count="15" layout="prev, pager, next" :total="pageCount"/> | |||
<el-pagination :page-size="20" :pager-count="11" layout="prev, pager, next" :total="pageCount" @current-change="pagechange"/> | |||
</div> | |||
<el-dialog v-model="dialogFormVisible" :title="title" :show-close="false"> | |||
@@ -462,10 +462,10 @@ const search = () => { | |||
bankCardId:"", | |||
corporateIdNum:formInline.number, | |||
corporateName: formInline.user, | |||
endApplyTime:end_time, | |||
endApplyTime:end_time.value, | |||
pageNo:pageNo, | |||
pageSize:номер, | |||
startApplyTime:start_time, | |||
startApplyTime:start_time.value, | |||
status:cтатус_счета, | |||
baseURL:'http://localhost:8089', | |||
} | |||
@@ -479,7 +479,9 @@ const search = () => { | |||
proxy.$request.post('/corporateaccount/queryPage', {},data).then((res) => { | |||
console.log(res); | |||
if(res.data.success){ | |||
tableData.value = res.data.result | |||
console.log("res",tableData) | |||
pageCount.value = res.data.pageCount; | |||
} | |||
}).catch((err) => { | |||
console.log(err,form.delivery); | |||
@@ -539,37 +541,26 @@ const regcode = () => { | |||
} | |||
onMounted(() => { | |||
getList() | |||
}) | |||
//获取详细信息,打开弹窗 | |||
const getDetil=(val)=>{ | |||
// form.value.data_id = id; | |||
dialogFormVisible.value = true; | |||
try { | |||
form.data_id = val.id; | |||
console.log("dedil_id",form.data_id); | |||
} catch (error) { | |||
} | |||
} | |||
search() | |||
}) | |||
//获取查询数据 | |||
const getList = ()=>{ | |||
proxy.$request.post('/corporateaccount/queryPage', {}, { | |||
baseURL:'http://localhost:8089', | |||
}).then((res) => { | |||
console.log(res.data.result,res.data.success); | |||
if(res.data.success){ | |||
tableData.value = res.data.result | |||
console.log("res",tableData) | |||
pageCount.value = res.data.pageCount; | |||
} | |||
}).catch((err) => { | |||
console.log(err); | |||
}) | |||
//获取详细信息,打开弹窗 | |||
const getDetil=(val)=>{ | |||
// form.value.data_id = id; | |||
dialogFormVisible.value = true; | |||
try { | |||
form.data_id = val.id; | |||
console.log("dedil_id",form.data_id); | |||
} catch (error) { | |||
} | |||
} | |||
//获取当前页数据 | |||
const pagechange = (el)=>{ | |||
console.log("el",el) | |||
pageNo.value = el; | |||
search() | |||
} | |||
</script> | |||
<style lang="scss"> |
@@ -1,12 +1,13 @@ | |||
<template> | |||
<div style="font-size: 13px; color: rgb(209, 65, 65); margin-left: 16px"> | |||
<div class="OBU-query content-warpper"> | |||
<div style="font-size: 10px; color: rgb(209, 65, 65);margin-left: 15px;"> | |||
注:目前仅支持中国工商银行贵州省分行、中国工商银行股份有限公司贵州省分行、农业银行、部互联网发行、 | |||
世纪恒通、工行微ETC、工总行直连模式三、贵州农信联社、贵州工行微ETC、世纪恒通GH查询下黑原因! | |||
</div> | |||
<div class="top"> | |||
<!-- 输入框 --> | |||
<div class="topstyle"> | |||
<span style="margin-right: 10px; width: 40px">卡号</span> | |||
<span style="width: 40px">卡号</span> | |||
<el-input v-model="formdata.ardNumber" placeholder="请输入卡号" style="width: 220px"> | |||
</el-input> | |||
</div> | |||
@@ -40,11 +41,11 @@ | |||
<div class="topstyle"> | |||
<el-button type="success" :icon="Search" @click="search">搜索</el-button> | |||
<el-button type="warning" :icon="Refresh" @click="reset">重置</el-button> | |||
<el-button type="primary" :icon="Plus" @click="addTo">添加</el-button> | |||
<!-- <el-button type="primary" :icon="Plus" @click="addTo">添加</el-button> --> | |||
</div> | |||
</div> | |||
<!-- 弹窗 --> | |||
<div> | |||
<!-- <div> | |||
<el-dialog v-model="dialogFormVisible"> | |||
<span class="as-gravity-center" style="font-size: 25px">卡黑名单-操作(下黑反白)</span> | |||
@@ -80,18 +81,18 @@ | |||
</span> | |||
</template> | |||
</el-dialog> | |||
</div> | |||
</div> --> | |||
<div style="padding-top: 12px"> | |||
<el-table :data="tableData" border style="width: 100%"> | |||
<el-table-column type="index" label="序号" width="60" /> | |||
<el-table-column prop="ardNumber" label="卡号" width="120" /> | |||
<el-table-column prop="ardNumber" label="卡号" width="110" /> | |||
<el-table-column prop="blacklistType" label="黑名单类型" width="100" /> | |||
<el-table-column prop="effectiveTimeOfBlacklist" label="黑名单生效时间" width="170" /> | |||
<el-table-column prop="effectiveTimeOfBlacklist" label="黑名单生效时间" width="160" /> | |||
<el-table-column prop="state" label="状态" width="60" /> | |||
<el-table-column prop="blacklistAntiWhiteTime" label="黑名单反白时间" width="130" /> | |||
<el-table-column prop="xiaheiOperatorNo" label="下黑操作工号" width="110" /> | |||
<el-table-column prop="causeOfBlack" label="下黑原因" width="200" /> | |||
<el-table-column prop="antiWhiteOperatorNo" label="反白操作工号" width="130" /> | |||
<el-table-column prop="antiWhiteOperatorNo" label="反白操作工号" width="110" /> | |||
<el-table-column prop="negativeeasons" label="反白原因" width="110" /> | |||
<el-table-column label="操作" width="90"> | |||
<el-button @click="dialogFormVisible1 = true" style="border-style: none">详情</el-button> | |||
@@ -135,6 +136,7 @@ | |||
</template> | |||
</el-dialog> | |||
</div> | |||
</div> | |||
<!-- <div style="padding-top: 12px" class="as-gravity-center-end"> | |||
<el-pagination :page-sizes="[10, 20, 30, 40]" layout="sizes, prev, pager, next" :total="1000" /> | |||
</div> --> | |||
@@ -165,9 +167,9 @@ const addtodata = reactive({ | |||
//搜索 | |||
function search() { | |||
proxy.$request | |||
.post('api/user',{}, | |||
.post('/blacklistquery/queryBlackList',{}, | |||
{ | |||
baseURL: 'http://192.168.101.123:8080', | |||
baseURL: 'http://10.52.0.172:10389', | |||
} | |||
) | |||
.then((res: {}) => { | |||
@@ -259,7 +261,7 @@ const tableData: User[] = [ | |||
{ | |||
ardNumber: '52011640230217310678', | |||
blacklistType: '账户透支', | |||
effectiveTimeOfBlacklist: '2020-12-19T03:41:04', | |||
effectiveTimeOfBlacklist: '2020-12-19 3:41:04', | |||
state: '在黑', | |||
blacklistAntiWhiteTime: '', | |||
xiaheiOperatorNo: 'ETCGsyh002', | |||
@@ -270,7 +272,7 @@ const tableData: User[] = [ | |||
{ | |||
ardNumber: '52011640230217310678', | |||
blacklistType: '账户透支', | |||
effectiveTimeOfBlacklist: '2020-12-19T03:41:04', | |||
effectiveTimeOfBlacklist: '2020-12-19 3:41:04', | |||
state: '在黑', | |||
blacklistAntiWhiteTime: '', | |||
xiaheiOperatorNo: 'ETCGsyh002', | |||
@@ -281,7 +283,7 @@ const tableData: User[] = [ | |||
{ | |||
ardNumber: '52011640230217310678', | |||
blacklistType: '账户透支', | |||
effectiveTimeOfBlacklist: '2020-12-19T03:41:04', | |||
effectiveTimeOfBlacklist: '2020-12-19 3:41:04', | |||
state: '在黑', | |||
blacklistAntiWhiteTime: '', | |||
xiaheiOperatorNo: 'ETCGsyh002', | |||
@@ -292,7 +294,7 @@ const tableData: User[] = [ | |||
{ | |||
ardNumber: '52011640230217310678', | |||
blacklistType: '账户透支', | |||
effectiveTimeOfBlacklist: '2020-12-19T03:41:04', | |||
effectiveTimeOfBlacklist: '2020-12-19 3:41:04', | |||
state: '在黑', | |||
blacklistAntiWhiteTime: '', | |||
xiaheiOperatorNo: 'ETCGsyh002', | |||
@@ -322,12 +324,13 @@ const tableData: User[] = [ | |||
antiWhiteOperatorNo: '', | |||
negativeeasons: '', | |||
}, | |||
] | |||
</script> | |||
<style lang="scss" scoped> | |||
.top { | |||
display: flex; | |||
margin-left: 10px; | |||
//margin-left: 10px; | |||
} | |||
.topstyle { | |||
display: flex; |
@@ -1,76 +1,63 @@ | |||
<template> | |||
<div class="top"> | |||
<!-- 输入框 --> | |||
<div class="topstyle"> | |||
<el-input v-model="formData.etcCardNumber" placeholder="请输入ETC卡号" style="width: 200px"> | |||
</el-input> | |||
</div> | |||
<div class="topstyle"> | |||
<el-input | |||
v-model="formData.licensePlateNumber" | |||
placeholder="请输入车牌号" | |||
style="width: 200px" | |||
> | |||
</el-input> | |||
</div> | |||
<!-- 日期框 --> | |||
<div class="topstyle"> | |||
<el-date-picker | |||
v-model="formData.startDate" | |||
type="datetime" | |||
placeholder="开始日期" | |||
value-format="YYYY-MM-DD hh:mm:ss" | |||
/> | |||
<!-- <span>-</span> --> | |||
<!-- <el-button>至</el-button> --> | |||
<el-date-picker | |||
v-model="formData.endDate" | |||
type="datetime" | |||
placeholder="结束日期" | |||
value-format="YYYY-MM-DD hh:mm:ss" | |||
style="margin-left: 5px" | |||
/> | |||
</div> | |||
<!-- 按钮 --> | |||
<div class="topstyle"> | |||
<el-button type="success" :icon="Search" @click="search">搜索</el-button> | |||
<el-button type="warning" :icon="Refresh" @click="reset">重置</el-button> | |||
<el-button type="primary" plain @click="exportCurrentPage">导出当前页</el-button> | |||
<div class="OBU-query content-warpper"> | |||
<div class="top"> | |||
<!-- 输入框 --> | |||
<div class="topstyle"> | |||
<el-input v-model="formData.etcCardNumber" placeholder="请输入ETC卡号" style="width: 200px"> | |||
</el-input> | |||
</div> | |||
<div class="topstyle"> | |||
<el-input | |||
v-model="formData.licensePlateNumber" | |||
placeholder="请输入车牌号" | |||
style="width: 200px" | |||
> | |||
</el-input> | |||
</div> | |||
<!-- 日期框 --> | |||
<div class="topstyle" style="width: 410px"> | |||
<el-date-picker | |||
v-model="formData.startDate" | |||
type="datetime" | |||
placeholder="开始日期" | |||
value-format="YYYY-MM-DD hh:mm:ss" | |||
/> | |||
<!-- <span>-</span> --> | |||
<!-- <el-button>至</el-button> --> | |||
<el-date-picker | |||
v-model="formData.endDate" | |||
type="datetime" | |||
placeholder="结束日期" | |||
value-format="YYYY-MM-DD hh:mm:ss" | |||
style="margin-left: 5px" | |||
/> | |||
</div> | |||
<!-- 按钮 --> | |||
<div class="topstyle"> | |||
<el-button type="success" :icon="Search" @click="search">搜索</el-button> | |||
<el-button type="warning" :icon="Refresh" @click="reset">重置</el-button> | |||
<el-button type="primary" plain @click="exportAll">导出所有</el-button> | |||
<el-button type="primary" plain @click="exportCurrentPage">导出当前页</el-button> | |||
<el-button type="primary" plain @click="exportAll">导出所有</el-button> | |||
</div> | |||
</div> | |||
</div> | |||
<div style="padding-top: 12px"> | |||
<exportTable ref="exportTS"></exportTable> | |||
<!-- <el-table :data="tableData1" style="width: 100%" border> | |||
<el-table-column type="index" label="序号" width="60" /> | |||
<el-table-column prop="etcCardNumber" label="ETC卡号" width="190" /> | |||
<el-table-column prop="licensePlateNumber" label="车牌号" width="100" /> | |||
<el-table-column prop="consumptionType" label="消费类型" width="90" /> | |||
<el-table-column prop="entranceTime" label="入口时间" width="110" /> | |||
<el-table-column prop="entryStationName" label="入口站名" width="110" /> | |||
<el-table-column prop="exportTime" label="出口时间" width="110" /> | |||
<el-table-column prop="exitStationName" label="出口站名" width="110" /> | |||
<el-table-column prop="balanceBeforeTransaction" label="交易前余额(元)" width="140" /> | |||
<el-table-column prop="transactionAmount" label="交易金额(元)" width="125" /> | |||
<el-table-column prop="postransactionalance" label="交易后余额(元)" width="140" /> | |||
</el-table> --> | |||
</div> | |||
<div style="padding-top: 12px" class="as-gravity-center-end"> | |||
<el-pagination :page-sizes="[10, 20, 30, 40]" :total="1000" /> | |||
<div style="padding-top: 12px"> | |||
<exportTable ref="exportTS"></exportTable> | |||
</div> | |||
<div style="padding-top: 12px" class="as-gravity-center-end"> | |||
<el-pagination :page-sizes="[10, 20, 30, 40]" :total="1000" /> | |||
</div> | |||
</div> | |||
</template> | |||
<script lang="ts" setup> | |||
import { reactive, ref, toRaw,getCurrentInstance, onMounted } from 'vue' | |||
import { reactive, ref, toRaw, getCurrentInstance, onMounted } from 'vue' | |||
import { useRoute, useRouter } from 'vue-router' | |||
import { Calendar, Search, Refresh } from '@element-plus/icons-vue' | |||
import type { ElTable } from 'element-plus' | |||
import exportTable from'../../../components/exportTable/exportTable.vue' | |||
import exportTable from '../../../components/exportTable/exportTable.vue' | |||
const { proxy }: any = getCurrentInstance() | |||
const formData = reactive({ | |||
@@ -81,7 +68,7 @@ const formData = reactive({ | |||
}) | |||
const exportTS = ref() | |||
const tableData = reactive({ | |||
title: "xx公司表格", | |||
title: 'xx公司表格', | |||
serialNumber: '', //序号 | |||
etcCardNumber: '', //ETC卡号 | |||
licensePlateNumber: '', //车牌号 | |||
@@ -110,23 +97,22 @@ const tableData = reactive({ | |||
//搜索 | |||
function search() { | |||
if(formData.etcCardNumber !=''){ | |||
if (formData.etcCardNumber != '') { | |||
proxy.$request | |||
.post('/uc/trafficrecord/query',{}, | |||
{ | |||
baseURL: 'http://localhost:8080', | |||
} | |||
) | |||
.then((res: {}) => { | |||
console.log(res) | |||
}) | |||
.catch((err: {}) => { | |||
console.log(err) | |||
}) | |||
}else{ | |||
.post('/uc/trafficrecord/query',{}, | |||
{ | |||
baseURL: 'http://10.52.0.172:10389', | |||
} | |||
) | |||
.then((res: {}) => { | |||
console.log(res) | |||
}) | |||
.catch((err: {}) => { | |||
console.log(err) | |||
}) | |||
} else { | |||
} | |||
console.log(toRaw(formData)) | |||
console.log('发送搜索请求') | |||
} | |||
@@ -138,14 +124,14 @@ function reset() { | |||
formData.endDate = '' | |||
} | |||
//导出当前页 | |||
const exportCurrentPage=()=>{ | |||
const exportCurrentPage = () => { | |||
exportTS.value.exportExcel() | |||
// childRef.value.exportExcel() | |||
console.log('导出当前页的表格数据') | |||
console.log('导出当前页的表格数据') | |||
} | |||
//导出所有 | |||
function exportAll() { | |||
proxy.$refs.exportTable.exportExcel(); | |||
proxy.$refs.exportTable.exportExcel() | |||
console.log('导出所有数据') | |||
} | |||
@@ -1,50 +0,0 @@ | |||
<template> | |||
<!-- accept 限制上传文件格式 .text--> | |||
<el-upload | |||
ref="uploadRef" | |||
action="https://jsonplaceholder.typicode.com/posts/" | |||
:auto-upload="false" | |||
:on-change="handleChange" | |||
:file-list="fileList" | |||
> | |||
<template #trigger> | |||
<el-button type="primary">select file</el-button> | |||
</template> | |||
<el-button class="ml-3" type="success" @click="submitUpload"> upload to server </el-button> | |||
<template #tip> | |||
<div class="el-upload__tip">jpg/png files with a size less than 500kb</div> | |||
</template> | |||
</el-upload> | |||
</template> | |||
<script lang="ts" setup> | |||
import { ref } from 'vue' | |||
import { barkTime } from '@/utils/utils' | |||
import { UploadProps, UploadUserFile } from 'element-plus' | |||
const uploadRef = ref() | |||
const fileList = ref<UploadUserFile[]>([]) | |||
console.log(barkTime()) //时间戳 | |||
const submitUpload = () => { | |||
uploadRef.value.submit() | |||
} | |||
const handleChange: UploadProps['onChange'] = (uploadFile, uploadFiles) => { | |||
// console.log(uploadFile, fileList.value.slice(-1)); | |||
fileList.value = fileList.value.slice(-1) | |||
// let imgSize = Number(uploadFile.size / 1024).toFixed(2); // / 1024 | |||
// //截取后缀名 | |||
// const suffix = (uploadFile.name + '').split('.')[1] | |||
// //修改文件名称 | |||
// uploadFile.name = barkTime() + '.' + suffix | |||
// if (uploadFiles) { | |||
// uploadFiles.value.split(uploadFiles.value.length, 1) | |||
// } | |||
console.log(fileList.value) | |||
} | |||
</script> |
@@ -0,0 +1,136 @@ | |||
<template> | |||
<div class="app-content"> | |||
<el-row> | |||
<el-col :span="7"> | |||
<el-upload | |||
action="/" | |||
:on-change="onChange" | |||
:auto-upload="false" | |||
:show-file-list="false" | |||
accept=".xls, .xlsx" | |||
> | |||
<el-button size="small" type="primary">选择文件</el-button> | |||
</el-upload> | |||
</el-col> | |||
<el-col :span="7"> | |||
<el-button size="small" type="primary" @click="exportExcel">文件导出</el-button> | |||
</el-col> | |||
</el-row> | |||
<el-table | |||
style="margin:20px 0;" | |||
:data="outputs" | |||
border | |||
:header-cell-style="{background:'#f1f1f1',color:'#606266'}" | |||
> | |||
<el-table-column label="姓名" prop="name"></el-table-column> | |||
<!-- <el-table-column label="年龄" prop="age"></el-table-column> --> | |||
</el-table> | |||
</div> | |||
</template> | |||
<script> | |||
import * as XLSX from "xlsx"; | |||
export default { | |||
data() { | |||
return { | |||
outputs: [], // 保存读取出来的数据列表 | |||
fileData: "" // 保存选择的文件数据 | |||
}; | |||
}, | |||
create() { | |||
console.log(XLSX); | |||
}, | |||
methods: { | |||
//文件选择时 | |||
onChange(file, fileList) { | |||
this.fileData = file; // 保存当前选择文件 | |||
this.readExcel(); // 调用读取数据的方法 | |||
}, | |||
//读取文件数据 | |||
readExcel(e) { | |||
let that = this; | |||
const files = that.fileData; | |||
if (!files) { | |||
//如果没有文件 | |||
return false; | |||
} else if (!/\.(xls|xlsx)$/.test(files.name.toLowerCase())) { | |||
this.$message.error("上传格式不正确,请上传xls或者xlsx格式"); | |||
return false; | |||
} | |||
const fileReader = new FileReader(); | |||
fileReader.onload = ev => { | |||
try { | |||
const data = ev.target.result; | |||
const workbook = XLSX.read(data, { | |||
type: "binary" | |||
}); | |||
//导入的文件名称 | |||
console.log(workbook.SheetNames); | |||
const wsname = workbook.SheetNames[0]; //取第一张表 | |||
const ws = XLSX.utils.sheet_to_json(workbook.Sheets[wsname]); //生成json表格内容 | |||
that.outputs = []; //清空接收数据 | |||
for (var i = 0; i < ws.length; i++) { | |||
var sheetData = { | |||
// 键名为绑定 el 表格的关键字,值则是 ws[i][对应表头名] | |||
//此处的字段名对应 上面表格数据的字段名 | |||
age: ws[i]["年龄"], | |||
name: ws[i]["姓名"] | |||
}; | |||
that.outputs.push(sheetData); | |||
} | |||
} catch (e) { | |||
console.log(e); | |||
return false; | |||
} | |||
}; | |||
// 如果为原生 input 则应是 files[0] | |||
fileReader.readAsBinaryString(files.raw); | |||
}, | |||
//导出文件 | |||
exportExcel() { | |||
if (!this.outputs.length) { | |||
this.$message.warning("暂无数据导出"); | |||
return false; | |||
} | |||
import("@/utils/Export2Excel").then(excel => { | |||
//导出表格头部内容(要与下面字段对照) | |||
const tHeader = ["姓名", "年龄"]; | |||
const filterVal = ["name", "age"]; | |||
const data = this.formatJson(filterVal); | |||
//保存excel | |||
excel.export_json_to_excel({ | |||
header: tHeader, | |||
data, | |||
//导出的文件名 | |||
filename: "table-list" | |||
}); | |||
}); | |||
}, | |||
//格式转换 | |||
formatJson(filterVal) { | |||
return this.outputs.map(v => | |||
// obj = { | |||
// name:'', | |||
// age:'' | |||
// } | |||
filterVal.map(j => { | |||
// obj[name] | |||
// obj[age] | |||
console.log(v[j]); | |||
return v[j]; | |||
}) | |||
); | |||
// [[name,age],[name,age],[name,age]] | |||
} | |||
} | |||
}; | |||
</script> | |||
<style> | |||
</style> |
@@ -1,135 +1,45 @@ | |||
<template> | |||
<div class="app-content"> | |||
<el-row> | |||
<el-col :span="7"> | |||
<el-upload | |||
action="/" | |||
:on-change="onChange" | |||
:auto-upload="false" | |||
:show-file-list="false" | |||
accept=".xls, .xlsx" | |||
> | |||
<el-button size="small" type="primary">选择文件</el-button> | |||
</el-upload> | |||
</el-col> | |||
<el-col :span="7"> | |||
<el-button size="small" type="primary" @click="exportExcel">文件导出</el-button> | |||
</el-col> | |||
</el-row> | |||
<el-table | |||
style="margin:20px 0;" | |||
:data="outputs" | |||
:header-cell-style="{background:'#f1f1f1',color:'#606266'}" | |||
> | |||
<el-table-column label="姓名" prop="name"></el-table-column> | |||
<!-- <el-table-column label="年龄" prop="age"></el-table-column> --> | |||
</el-table> | |||
</div> | |||
<!-- accept 限制上传文件格式 .text :auto-upload="false"--> | |||
<el-upload ref="uploadRef" action="https://jsonplaceholder.typicode.com/posts/" | |||
:before-upload="beforeAvatarUpload" :on-success="handleAvatarSuccess" :show-file-list="false" :file-list="fileList"> | |||
<template #trigger> | |||
<el-button type="primary">select file</el-button> | |||
</template> | |||
<el-button class="ml-3" type="success"> upload to server </el-button> | |||
<template #tip> | |||
<div class="el-upload__tip">jpg/png files with a size less than 500kb</div> | |||
</template> | |||
</el-upload> | |||
</template> | |||
<script lang="ts" setup> | |||
import { ref } from 'vue' | |||
import { barkFileName } from '@/utils/utils' | |||
import { UploadProps, UploadUserFile } from 'element-plus' | |||
import { ElMessage } from 'element-plus' | |||
<script> | |||
const uploadRef = ref() | |||
const imageUrl = ref('') | |||
const fileList = ref<UploadUserFile[]>([]) | |||
import * as XLSX from "xlsx"; | |||
const handleAvatarSuccess: UploadProps['onSuccess'] = ( | |||
response, | |||
uploadFile | |||
) => { | |||
imageUrl.value = URL.createObjectURL(uploadFile.raw!) | |||
} | |||
export default { | |||
data() { | |||
return { | |||
outputs: [], // 保存读取出来的数据列表 | |||
fileData: "" // 保存选择的文件数据 | |||
}; | |||
}, | |||
create() { | |||
console.log(XLSX); | |||
}, | |||
methods: { | |||
//文件选择时 | |||
onChange(file, fileList) { | |||
this.fileData = file; // 保存当前选择文件 | |||
this.readExcel(); // 调用读取数据的方法 | |||
}, | |||
//读取文件数据 | |||
readExcel(e) { | |||
let that = this; | |||
const files = that.fileData; | |||
if (!files) { | |||
//如果没有文件 | |||
return false; | |||
} else if (!/\.(xls|xlsx)$/.test(files.name.toLowerCase())) { | |||
this.$message.error("上传格式不正确,请上传xls或者xlsx格式"); | |||
return false; | |||
} | |||
const fileReader = new FileReader(); | |||
fileReader.onload = ev => { | |||
try { | |||
const data = ev.target.result; | |||
const workbook = XLSX.read(data, { | |||
type: "binary" | |||
}); | |||
//导入的文件名称 | |||
console.log(workbook.SheetNames); | |||
const wsname = workbook.SheetNames[0]; //取第一张表 | |||
const ws = XLSX.utils.sheet_to_json(workbook.Sheets[wsname]); //生成json表格内容 | |||
that.outputs = []; //清空接收数据 | |||
for (var i = 0; i < ws.length; i++) { | |||
var sheetData = { | |||
// 键名为绑定 el 表格的关键字,值则是 ws[i][对应表头名] | |||
//此处的字段名对应 上面表格数据的字段名 | |||
age: ws[i]["年龄"], | |||
name: ws[i]["姓名"] | |||
}; | |||
that.outputs.push(sheetData); | |||
} | |||
} catch (e) { | |||
console.log(e); | |||
return false; | |||
} | |||
}; | |||
// 如果为原生 input 则应是 files[0] | |||
fileReader.readAsBinaryString(files.raw); | |||
}, | |||
//导出文件 | |||
exportExcel() { | |||
if (!this.outputs.length) { | |||
this.$message.warning("暂无数据导出"); | |||
return false; | |||
} | |||
import("@/utils/Export2Excel").then(excel => { | |||
//导出表格头部内容(要与下面字段对照) | |||
const tHeader = ["姓名", "年龄"]; | |||
const filterVal = ["name", "age"]; | |||
const data = this.formatJson(filterVal); | |||
//保存excel | |||
excel.export_json_to_excel({ | |||
header: tHeader, | |||
data, | |||
//导出的文件名 | |||
filename: "table-list" | |||
}); | |||
}); | |||
}, | |||
//格式转换 | |||
formatJson(filterVal) { | |||
return this.outputs.map(v => | |||
// obj = { | |||
// name:'', | |||
// age:'' | |||
// } | |||
filterVal.map(j => { | |||
// obj[name] | |||
// obj[age] | |||
console.log(v[j]); | |||
return v[j]; | |||
}) | |||
); | |||
// [[name,age],[name,age],[name,age]] | |||
} | |||
//文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用 | |||
const beforeAvatarUpload: UploadProps['beforeUpload'] = (rawFile) => { | |||
console.log(rawFile); | |||
if (rawFile.type !== 'image/jpeg') { | |||
ElMessage.error('头像图片必须为JPG格式!') | |||
return false | |||
} else if (rawFile.size / 1024 / 1024 > 2) { | |||
ElMessage.error('头像图片大小不能超过2MB!') | |||
return false | |||
} | |||
}; | |||
</script> | |||
<style> | |||
</style> | |||
return true | |||
// uploadRef.value.clearFiles() 默认上传成功后调用 | |||
} | |||
</script> |