Commit 6a07294a authored by cx49085's avatar cx49085
Browse files

Merge branch 'dev' of http://www.aishuhong.com:16356/liujiale/finance into dev

parents 6c9e5a08 d4ec6684
...@@ -3,7 +3,7 @@ ENV = 'development' ...@@ -3,7 +3,7 @@ ENV = 'development'
# base api 后端url # base api 后端url
#VUE_APP_BASE_API = 'http://192.168.10.107:7080' #VUE_APP_BASE_API = 'http://192.168.10.107:7080'
VUE_APP_BASE_API = 'http://192.168.10.109:11523' VUE_APP_BASE_API = 'http://192.168.10.109:11523'
#VUE_APP_BASE_API = 'http://www.aishuhong.com:11549/prod-api/' #VUE_APP_BASE_API = 'http://www.aishuhong.com:11549/prod-api/'
#VUE_APP_BASE_API = 'http://192.168.31.100:7081' #VUE_APP_BASE_API = 'http://192.168.31.100:7081'
File added
...@@ -43,8 +43,8 @@ const actions = { ...@@ -43,8 +43,8 @@ const actions = {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
login({ username: username.trim(), password: password }).then(response => { login({ username: username.trim(), password: password }).then(response => {
const { data } = response const { data } = response
commit('SET_TOKEN', data.token) commit('SET_TOKEN', data)
setToken(data.token) setToken(data)
resolve(response) resolve(response)
}).catch(error => { }).catch(error => {
reject(error) reject(error)
...@@ -55,7 +55,7 @@ const actions = { ...@@ -55,7 +55,7 @@ const actions = {
// get user info // get user info
getInfo({ commit, state }) { getInfo({ commit, state }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getInfo(state.token).then(response => { getInfo(state.info).then(response => {
const { data } = response const { data } = response
if (!data) { if (!data) {
reject('Verification failed, please Login again.') reject('Verification failed, please Login again.')
...@@ -83,16 +83,12 @@ const actions = { ...@@ -83,16 +83,12 @@ const actions = {
// user logout // user logout
logout({ commit, state, dispatch }) { logout({ commit, state, dispatch }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
logout(state.token).then(() => { logout().then(() => {
commit('SET_TOKEN', '') commit('SET_TOKEN', '')
commit('SET_ROLES', []) commit('SET_ROLES', [])
removeToken() removeToken()
resetRouter() resetRouter()
// reset visited views and cached views
// to fixed https://github.com/PanJiaChen/vue-element-admin/issues/2485
dispatch('tagsView/delAllViews', null, { root: true }) dispatch('tagsView/delAllViews', null, { root: true })
resolve() resolve()
}).catch(error => { }).catch(error => {
reject(error) reject(error)
......
...@@ -172,7 +172,7 @@ export function number_valid(rule, value, callback) { ...@@ -172,7 +172,7 @@ export function number_valid(rule, value, callback) {
} }
//发票号码 //发票号码
export function Invoice_No(rule, value, callback) { export function Invoice_No(rule, value, callback) {
let reg = /^\d{8,}$/ let reg = /^\d{8}$/
if (value === null || value === undefined || value === '') { if (value === null || value === undefined || value === '') {
return callback(new Error('不能为空')) return callback(new Error('不能为空'))
} else if (reg.test(value)) { } else if (reg.test(value)) {
...@@ -183,7 +183,7 @@ export function Invoice_No(rule, value, callback) { ...@@ -183,7 +183,7 @@ export function Invoice_No(rule, value, callback) {
} }
//发票代码 //发票代码
export function Invoice_code(rule, value, callback) { export function Invoice_code(rule, value, callback) {
let reg = /^\d{12,}$/ let reg = /^\d{12}$/
if (value === null || value === undefined || value === '') { if (value === null || value === undefined || value === '') {
return callback(new Error('不能为空')) return callback(new Error('不能为空'))
} else if (reg.test(value)) { } else if (reg.test(value)) {
......
...@@ -774,7 +774,6 @@ export default { ...@@ -774,7 +774,6 @@ export default {
fromList: [], //发票号码 fromList: [], //发票号码
}, },
formtripid: null, formtripid: null,
form: [],
srcList: [], srcList: [],
parm: { parm: {
tripId: null, tripId: null,
...@@ -868,6 +867,7 @@ export default { ...@@ -868,6 +867,7 @@ export default {
}, },
//查询出要添加的发票编号 //查询出要添加的发票编号
Selectinvoicelsit() { Selectinvoicelsit() {
this.invoicelistform.fromList = [];
this.insertvioiceFrom = true; this.insertvioiceFrom = true;
let param = { let param = {
companyId: this.$store.getters.companyId, companyId: this.$store.getters.companyId,
...@@ -889,25 +889,35 @@ export default { ...@@ -889,25 +889,35 @@ export default {
this.back(); this.back();
}); });
}, },
/**
* 第一次 选择两条 this.form.length = 2
* 第二次 不选择 this.form.length = 2
* 第三次 选择两条 this.form.length = 4
*
*/
// 添加发票号码 // 添加发票号码
insertInvoice() { insertInvoice() {
// 第三个方法 添加发票 // 第三个方法 添加发票
let param = []
this.invoicelistform.fromList.forEach((e) => { this.invoicelistform.fromList.forEach((e) => {
let obj = {}; let obj = {};
obj.companyId = this.$store.getters.companyId; obj.companyId = this.$store.getters.companyId;
obj.status = 1; obj.status = 1;
obj.tripId = this.formtripid; obj.tripId = this.formtripid;
obj.invoiceId = e; obj.invoiceId = e;
this.form.push(obj); param.push(obj);
}); });
if (this.form.length == 0) { if (param.length == 0) {
this.insertvioiceFrom = false; this.insertvioiceFrom = false;
} else { } else {
Addinvoice(this.form) Addinvoice(param)
.then((resu) => { .then((resu) => {
if (resu.success) { if (resu.success) {
this.$message.success("添加成功!"); this.$message.success("添加成功!");
this.insertvioiceFrom = false; this.insertvioiceFrom = false;
this.table = false
} else { } else {
this.$message.error(resu.msg); this.$message.error(resu.msg);
} }
...@@ -941,6 +951,7 @@ export default { ...@@ -941,6 +951,7 @@ export default {
type: "success", type: "success",
message: "删除成功!", message: "删除成功!",
}); });
this.table = false
// 关闭窗口 // 关闭窗口
} else { } else {
this.$message.error(result.msg); this.$message.error(result.msg);
......
...@@ -173,8 +173,10 @@ export default { ...@@ -173,8 +173,10 @@ export default {
//返回 //返回
back() { back() {
if (this.attrId == 0) { if (this.attrId == 0) {
this.$store.dispatch("tagsView/delView", this.$route);
this.$router.push("/assetslist"); this.$router.push("/assetslist");
} else { } else {
this.$store.dispatch("tagsView/delView", this.$route);
this.$router.push("/administrationlsit"); this.$router.push("/administrationlsit");
} }
}, },
......
...@@ -187,7 +187,7 @@ export default { ...@@ -187,7 +187,7 @@ export default {
getCompany() { getCompany() {
select(this.companyQurey) select(this.companyQurey)
.then(res => { .then(res => {
if ((res.status = "success")) { if (res.success) {
this.total = res.data.total; this.total = res.data.total;
this.companyList = res.data.list; this.companyList = res.data.list;
} else { } else {
......
import { money, Invoice_code, Invoice_No } from "@/utils/myValidate";
//发票状态
export const categoryOptions = [
{
value: 0,
category: "普票"
},
{
value: 1,
category: "专票"
}
]
//发票类型
export const typeOptions = [
{
value: 0,
type: "收入"
},
{
value: 1,
type: "支出"
},
{
value: 2,
type: "报销"
}
]
//发票类别
export const statusOptions = [
{
value: 0,
status: "未报销"
},
{
value: 1,
status: "已报销"
}
]
export const addRecordRules = {
time: [
{ required: true, message: "请输入发票时间", trigger: "blur" }
],
number: [
{
required: true,
validator: Invoice_No,
trigger: "blur"
}
],
code: [{ required: true, validator: Invoice_code, trigger: "blur" }],
category: [
{
required: true,
message: "请至少选择一个发票类型",
trigger: "blur"
}
],
type: [
{
required: true,
message: "请至少选择一个发票类别",
trigger: "blur"
}
],
mone: [
{
required: true,
validator: money,
trigger: "blur"
}
]
}
\ No newline at end of file
<template> <template>
<div v-loading="loading" element-loading-text="图片上传中。。。"> <el-tabs v-model="activeName" tab-position="top" @tab-click="handleClick" style="margin:15px 2%;">
<!-- 头部 --> <el-tab-pane label="发票总览" name="first">
<div class="QueryInvoice" style="margin: 10px 15px"> <Expenseselect tag="overview" ref="eaxmine" />
<el-row :gutter="30"> </el-tab-pane>
<el-col :span="30"> <el-tab-pane label="发票添加" name="second">
<el-form :inline="true" :model="invoiceQruey"> <Expenseadd @childFnGetParent="parentFn" />
<el-form-item label="发票号码" style="margin-left"> </el-tab-pane>
<el-input v-model="invoiceQruey.number" placeholder="发票号码"></el-input> </el-tabs>
</el-form-item>
<el-form-item label="发票代码">
<el-input v-model="invoiceQruey.code" placeholder="发票代码"></el-input>
</el-form-item>
<el-form-item label="发票类型">
<el-select v-model="invoiceQruey.category" placeholder="请选择">
<el-option
v-for="item in categoryOptions"
:key="item.value"
:label="item.category"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="发票类别">
<el-select v-model="invoiceQruey.type" placeholder="请选择">
<el-option
v-for="item in typeOptions"
:key="item.value"
:label="item.type"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="发票状态">
<el-select v-model="invoiceQruey.status" placeholder="请选择">
<el-option
v-for="item in statusOptions"
:key="item.value"
:label="item.status"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
</el-form>
</el-col>
<el-col :span="12" style="margin: 20px 5px">
<el-button
type="primary"
icon="el-icon-search"
style="margin: 1px 5px"
@click="selectexpend()"
>查询</el-button>
<el-button type="info" icon="el-icon-refresh-right" @click="upddlist()">重置</el-button>
<el-button
type="success"
icon="el-icon-download"
v-if="isgetid"
@click="Reimbursement()"
>添加发票单</el-button>
<el-button type="warning" v-if="!isgetid" @click="Reimbursement()">返回</el-button>
</el-col>
</el-row>
</div>
<!-- 表格区域 -->
<div class="drawer" v-show="isgetid" style="margin-left: 15px">
<el-table
:data="invoicegetList"
border
style="width: 99%"
:cell-style="{ 'text-align': 'center' }"
:header-cell-style="{ 'text-align': 'center' }"
>
<el-table-column label="序号" width="50" style>
<template slot-scope="scope">
{{
(invoiceQruey.pageNum - 1) * invoiceQruey.pageSize +
scope.$index +
1
}}
</template>
</el-table-column>
<el-table-column prop="code" label="发票代码"></el-table-column>
<el-table-column prop="number" label="发票号码" width="width"></el-table-column>
<el-table-column prop="time" label="发票时间" :formatter="getFroms"></el-table-column>
<el-table-column prop="category" label="发票类型">
<template slot-scope="scope">
<el-tag :type="scope.row.category == '0' ? 'info' : 'primary'">
{{
scope.row.category == "0" ? "普票" : "专票"
}}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="type" label="发票类别">
<template slot-scope="scope">
<el-tag
:type="
scope.row.type == '0'
? 'success'
: scope.row.type == '1'
? 'danger'
: 'warning'
"
>
{{
scope.row.type == "0"
? "收入"
: scope.row.type == "1"
? "支出"
: "报销"
}}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="mone" label="发票金额"></el-table-column>
<el-table-column prop="prop" label="发票文件" width="120px">
<template slot-scope="scope">
<div v-if="formatProtocolType(scope.row)">
<el-image
style="width: 80px; height: 80px"
:src="scope.row.fileUrl"
:preview-src-list="srcList"
></el-image>
</div>
<div v-else>
<a class="a-style" @click="handlePreView(scope.row)">点击查看文件</a>
</div>
</template>
</el-table-column>
<el-table-column prop="status" label="发票状态" width="90px">
<template slot-scope="scope">
<el-tag :type="scope.row.status == '0' ? 'info' : 'warning'">
{{
scope.row.status == 0 ? "未报销" : "已报销"
}}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="prop" label="操作">
<template slot-scope="scope">
<el-popover placement="top" width="160" v-model="scope.row.visible">
<p>确定要删除当前发票吗</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="scope.row.visible = false">取消</el-button>
<el-button type="primary" size="mini" @click="YesGet(scope.row)">确定</el-button>
</div>
<el-button
type="danger"
icon="el-icon-delete"
slot="reference"
size="mini"
:disabled="scope.row.status == 0 ? false : true"
></el-button>
</el-popover>
</template>
</el-table-column>
</el-table>
<el-row :gutter="20">
<el-col :span="24">
<!-- 分页 -->
<div class="foot_yi">
<el-pagination
@current-change="handleCurrentChange"
layout="total, prev, pager, next"
:total="total"
:current-page.sync="invoiceQruey.pageNum"
:page-size="invoiceQruey.pageSize"
></el-pagination>
</div>
</el-col>
</el-row>
</div>
<!-- 添加区域 -->
<div class="getadd" v-show="!isgetid" style="margin-left: 5%">
<el-row >
<el-col :xl="8" :lg="10" :md="8" :sm="12" :xs="24">
<el-form
style="width: 100%; margin: 30px 0px"
:model="addTO"
:rules="rules"
ref="addTO"
label-width="80px"
class="demo-ruleForm"
>
<el-form-item label="发票代码" prop="code">
<el-input
v-model="addTO.code"
maxlength="12"
minlength="12"
onkeyup="this.value=this.value.replace(/\D|^/g,'')"
></el-input>
</el-form-item>
<el-form-item label="发票号码" prop="number">
<el-input
v-model="addTO.number"
maxlength="8"
minlength="8"
onkeyup="this.value=this.value.replace(/\D|^/g,'')"
></el-input>
</el-form-item>
<el-form-item label="发票时间" required prop="time">
<el-date-picker
v-model="addTO.time"
type="datetime"
placeholder="选择日期时间"
@change="timestampToTime1()"
></el-date-picker>
</el-form-item>
<el-form-item label="发票类型" prop="category">
<el-select v-model="addTO.category" placeholder="请选择">
<el-option
v-for="item in categoryOptions"
:key="item.value"
:label="item.category"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="发票类别" prop="type">
<el-select v-model="addTO.type" placeholder="请选择">
<el-option
v-for="item in typeOptions"
:key="item.value"
:label="item.type"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="发票金额" prop="mone">
<el-input v-model="addTO.mone"></el-input>
</el-form-item>
<el-form-item>
<el-button type="success" icon="el-icon-folder-checked" @click="getlistForm()">立即创建</el-button>
<el-button type="info" icon="el-icon-refresh" @click="delectdd">重置信息</el-button>
</el-form-item>
</el-form>
</el-col>
<el-col :xs="4" :sm="6" :md="8" :lg="10" :xl="11">
<el-upload
class="upload-demo"
ref="upload"
:file-list="fileList"
:action="action"
:auto-upload="false"
:data="proutlist"
:on-change="onChange"
:on-remove="delfile"
:on-success="fileSuccess"
:limit="1"
:on-error="geterror"
style="margin-left: 90px"
>
<el-button
slot="trigger"
size="small"
type="primary"
style="margin-left: 20px; margin-top: 40px"
>选取文件</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png/pdf文件,且不超过500kb</div>
</el-upload>
</el-col>
</el-row>
</div>
</div>
</template> </template>
<script> <script>
import { insertList, queryBypageIncomeAdd, deleteexpen } from "@/api/project"; import Expenseselect from "./expenseList/expenseselect";
import { getFileUrl } from "@/api/companyFile"; import Expenseadd from "./expenseList/expenseAdd";
import { money, Invoice_code, Invoice_No } from "@/utils/myValidate";
export default { export default {
components: {
Expenseselect,
Expenseadd
},
data() { data() {
return { return {
//搜索条件 activeName: "first"
invoiceQruey: {
number: null,
code: null,
category: null,
type: null,
status: null,
pageNum: 1,
pageSize: 10,
companyId: null,
userId: null
},
categoryOptions: [
{
value: 0,
category: "普票"
},
{
value: 1,
category: "专票"
}
],
typeOptions: [
{
value: 0,
type: "收入"
},
{
value: 1,
type: "支出"
},
{
value: 2,
type: "报销"
}
],
statusOptions: [
{
value: 0,
status: "未报销"
},
{
value: 1,
status: "已报销"
}
],
total: 0,
invoicegetList: [],
srcList: [],
isgetid: true, //表格区域的切换
//添加发票的数据
addTO: {
category: null,
code: null,
companyId: null,
mone: null,
number: null,
status: 0,
time: null,
type: null
},
rules: {
time: [
{ required: true, message: "请输入发票时间", trigger: "change" }
],
number: [
{
required: true,
validator: Invoice_No,
trigger: "change"
}
],
code: [{ required: true, validator: Invoice_code, trigger: "change" }],
category: [
{
required: true,
message: "请至少选择一个发票类型",
trigger: "change"
}
],
type: [
{
required: true,
message: "请至少选择一个发票类别",
trigger: "change"
}
],
mone: [
{
required: true,
validator: money,
trigger: "change"
}
]
},
fileList: [],
action: null,
proutlist: {
Id: 1,
status: 0,
companyId: null
},
loading: false
}; };
}, },
created() {
this.proutlist.companyId = this.$store.getters.companyId;
this.invoiceQruey.companyId = this.$store.getters.companyId;
this.invoiceQruey.userId = this.$store.getters.urId;
this.action = process.env.VUE_APP_BASE_API + "/file/uploadFile";
this.getincomeSelectlist();
},
methods: { methods: {
//查询 handleClick(tab, event) {
selectexpend() {
this.invoiceQruey.pageNum = 1;
this.getincomeSelectlist();
},
//重置
upddlist() {
this.invoiceQruey.pageNum = 1;
this.invoiceQruey.number = null;
this.invoiceQruey.code = null;
this.invoiceQruey.category = null;
this.invoiceQruey.type = null;
this.invoiceQruey.status = null;
this.getincomeSelectlist();
},
//添加发票
Reimbursement() {
this.isgetid = !this.isgetid;
this.$refs.addTO.resetFields();
this.fileList = this.fileList.filter(item => item.uid !== file.uid);
},
//发票的分页查询
getincomeSelectlist() {
queryBypageIncomeAdd(this.invoiceQruey)
.then(res => {
if (res.success) {
this.total = res.data.total;
res.data.list.forEach(e => {
let fileNamepdf = e.filePath;
let fileType = fileNamepdf.substring(
fileNamepdf.lastIndexOf(".")
);
getFileUrl(e.filePath).then(res => {
if (res.success) {
let url = res.data;
e.fileUrl = url;
if (fileType != ".pdf") {
this.srcList.push(url);
}
}
});
});
this.invoicegetList = res.data.list;
} else {
this.$message.error(res.msg);
}
})
.catch(error => {
console.log(error);
this.$message.error("查询发票数据失败");
});
},
//换页
handleCurrentChange(val) {
this.invoiceQruey.pageNum = val;
this.getincomeSelectlist();
},
//图片格式
formatProtocolType(row) {
//这里判断的是是否有文件
if (row.filePath == null) {
return false;
} else {
let fileNamepdf = row.filePath;
let fileType = fileNamepdf.substring(fileNamepdf.lastIndexOf("."));
if (fileType != ".pdf") {
return true;
} else {
return false;
}
}
},
//时间处理
getFroms(value) {
var dt = new Date(value.time);
let year = dt.getFullYear();
let month = dt.getMonth() + 1;
let date = dt.getDate();
return `${year}${month}${date}日`;
},
//点击查看发票
handlePreView(row) {
const photopath = row.fileUrl;
window.open(photopath, "_blank");
}, },
//时间处理 yyyy-MM-dd hh:mm:ss parentFn(val) {
timestampToTime1() { console.log(val);
var date = this.addTO.time; this.activeName=val;
var Y = date.getFullYear() + "-";
var M =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
var D =
(date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
var h =
(date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
var m =
(date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) +
":";
var s =
date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
this.addTO.time = Y + M + D + h + m + s;
},
//发票提交页面的提交
getlistForm() {
if (this.fileTypeJpg == true) {
this.$refs.addTO.validate(valid => {
if (valid) {
this.loading = true;
this.addTO.userId = this.$store.getters.urId;
this.addTO.companyId = this.$store.getters.companyId;
insertList(this.addTO)
.then(res => {
if (res.success) {
//发票记录添加成功
//提交发票文件
this.proutlist.Id = res.data;
this.$refs.upload.submit();
this.$message.success(res.msg);
} else {
this.loading = false;
this.$message.error(res.msg);
}
})
.catch(e => {
this.loading = false;
this.$message.error("发票添加失败,检测是否重复");
});
}
});
} else {
this.$message.warning("没有发票文件,无法提交");
}
},
//数据清除
delectdd() {
this.$refs.addTO.resetFields();
},
//校验发票文件格式
onChange(file) {
const fileNamepdf = file.name;
let fileType = fileNamepdf.substring(fileNamepdf.lastIndexOf("."));
if (fileType == ".pdf" || fileType == ".png" || fileType == ".jpg") {
this.fileTypeJpg = true;
} else {
this.fileTypeJpg = false;
this.$message.warning("发票文件只能是pdf,png,jpg格式文件");
this.$refs.upload.clearFiles();
}
},
//清除发片文件
delfile() {
this.fileTypeJpg = false;
},
//文件上传成功
fileSuccess(res) {
this.loading = false;
this.isgetid = true;
this.getincomeSelectlist();
},
//发票的删除操作
YesGet(row) {
deleteexpen(row)
.then(res => {
if (res.success) {
this.visible = false;
this.$message({
message: "发票删除成功",
type: "success"
});
this.getincomeSelectlist();
} else {
this.$message.error(res.msg);
}
})
.catch(e => {
console.log(e.msg);
this.$message.error(e.msg);
});
},
geterror() {
this.loading = true;
} }
} }
}; };
</script> </script>
<style scoped>
.container { <style>
padding: 10px;
}
.QueryInvoice .el-form-item {
margin: 10px 15px;
}
.drawer .foot_yi {
margin: 10px 10px;
text-align: right;
}
</style> </style>
\ No newline at end of file
<template>
<div>
<!-- 添加区域 -->
<div class="getadd" style="margin-left: 5%">
<el-row v-loading="loading" element-loading-text="图片上传中。。。">
<el-col :xl="8" :lg="10" :md="8" :sm="12" :xs="24">
<el-form
style="width: 100%; margin: 30px 0px"
:model="addTO"
:rules="rules"
ref="addTO"
label-width="80px"
class="demo-ruleForm"
>
<el-form-item label="发票代码" prop="code">
<el-input
v-model="addTO.code"
maxlength="12"
minlength="12"
onkeyup="this.value=this.value.replace(/\D|^/g,'')"
></el-input>
</el-form-item>
<el-form-item label="发票号码" prop="number">
<el-input
v-model="addTO.number"
maxlength="8"
minlength="8"
onkeyup="this.value=this.value.replace(/\D|^/g,'')"
></el-input>
</el-form-item>
<el-form-item label="发票时间" required prop="time">
<el-date-picker
v-model="addTO.time"
type="datetime"
placeholder="选择日期时间"
@change="timestampToTime1()"
></el-date-picker>
</el-form-item>
<el-form-item label="发票类型" prop="category">
<el-select v-model="addTO.category" placeholder="请选择">
<el-option
v-for="item in categoryOptions"
:key="item.value"
:label="item.category"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="发票类别" prop="type">
<el-select v-model="addTO.type" placeholder="请选择">
<el-option
v-for="item in typeOptions"
:key="item.value"
:label="item.type"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="发票金额" prop="mone">
<el-input v-model="addTO.mone"></el-input>
</el-form-item>
<el-form-item label="发票文件">
<el-upload
class="upload-demo"
ref="upload"
:headers="fileUploadHeader"
:file-list="fileList"
:action="action"
:auto-upload="false"
:data="addTO"
:on-change="onChange"
:on-remove="delfile"
:on-success="fileSuccess"
:limit="1"
:on-error="geterror"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div class="el-upload__tip" slot="tip">只能上传jpg/png/pdf文件,且不超过500kb</div>
</el-upload>
</el-form-item>
<el-form-item>
<el-col>
<el-button type="success" icon="el-icon-folder-checked" @click="getlistForm()">立即创建</el-button>
<el-button type="info" icon="el-icon-refresh" @click="delectdd">重置信息</el-button>
</el-col>
</el-form-item>
</el-form>
</el-col>
</el-row>
</div>
</div>
</template>
<script>
import { mapGetters } from "vuex";
import { getFileUrl } from "@/api/companyFile";
import { insertList } from "@/api/project";
import {
addRecordRules as rules,
categoryOptions,
typeOptions,
statusOptions
} from "../expense";
export default {
created() {
this.action = process.env.VUE_APP_BASE_API + "/invoice/insert";
this.fileUploadHeader["X-Token"] = this.$store.getters.token;
},
computed: {
...mapGetters(["companyId", "urId"])
},
data() {
return {
rules: rules,
//添加发票的数据
addTO: {
category: null,
code: null,
mone: null,
number: null,
status: 0,
time: null,
type: null
},
categoryOptions,
typeOptions,
statusOptions,
fileList: [],
loading: false,
action: null,
fileUploadHeader: {
"X-Token": null
},
dataValue: "first"
};
},
methods: {
//校验发票文件格式
onChange(file) {
const fileNamepdf = file.name;
let fileType = fileNamepdf.substring(fileNamepdf.lastIndexOf("."));
if (fileType == ".pdf" || fileType == ".png" || fileType == ".jpg") {
this.fileTypeJpg = true;
} else {
this.fileTypeJpg = false;
this.$message.warning("发票文件只能是pdf,png,jpg格式文件");
this.$refs.upload.clearFiles();
}
},
//清除发片文件
delfile() {
this.fileTypeJpg = false;
},
//文件上传成功
fileSuccess(res) {
this.loading = false;
if (res.success) {
//发票提交
this.delectdd();
console.log("123456");
this.$emit("childFnGetParent", "first");
this.$message.success(res.msg);
} else {
this.loading = false;
this.$message.error(res.msg);
if (res.code == 4) {
//执行退出功能
this.$store.dispatch("user/logout");
this.$router.push(`/login?redirect=${this.$route.fullPath}`);
}
}
this.isgetid = true;
},
geterror() {
this.loading = true;
},
//时间处理 yyyy-MM-dd hh:mm:ss
timestampToTime1() {
var date = this.addTO.time;
var Y = date.getFullYear() + "-";
var M =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
var D =
(date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
var h =
(date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
var m =
(date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) +
":";
var s =
date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
this.addTO.time = Y + M + D + h + m + s;
},
//发票提交页面的提交
getlistForm() {
if (this.fileTypeJpg == true) {
this.$refs.addTO.validate(valid => {
if (valid) {
this.addTO.companyId = this.companyId;
this.addTO.userId = this.urId;
this.$refs.upload.submit();
}
});
} else {
this.$message.warning("没有发票文件,无法提交");
}
},
//数据清除
delectdd() {
this.$refs.addTO.resetFields();
this.fileList = this.fileList.filter(item => item.uid !== file.uid);
}
}
};
</script>
<style scoped lang="scss">
</style>
\ No newline at end of file
<template>
<div>
<!-- 头部 -->
<div class="QueryInvoice" style="margin: 10px 15px">
<el-row :gutter="30">
<el-col :span="30">
<el-form :inline="true" :model="invoiceQruey">
<el-form-item>
<el-input v-model="invoiceQruey.number" placeholder="请输入发票号码"></el-input>
</el-form-item>
<el-form-item>
<el-input v-model="invoiceQruey.code" placeholder="请输入发票代码"></el-input>
</el-form-item>
<el-form-item>
<el-select v-model="invoiceQruey.category" placeholder="请选择发票类型">
<el-option
v-for="item in categoryOptions"
:key="item.value"
:label="item.category"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-select v-model="invoiceQruey.type" placeholder="请选择发票类别">
<el-option
v-for="item in typeOptions"
:key="item.value"
:label="item.type"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-select v-model="invoiceQruey.status" placeholder="请选择发票状态">
<el-option
v-for="item in statusOptions"
:key="item.value"
:label="item.status"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
</el-form>
</el-col>
<el-col :span="30">
<el-button type="primary" icon="el-icon-search" @click="selectexpend()">查询</el-button>
<el-button type="info" icon="el-icon-refresh-right" @click="upddlist()">重置</el-button>
</el-col>
</el-row>
</div>
<div class="drawer">
<el-table
:data="invoicegetList"
border
style="width:100%"
:cell-style="{ 'text-align': 'center' }"
:header-cell-style="{ 'text-align': 'center' }"
>
<el-table-column label="序号" width="50" style>
<template slot-scope="scope">
{{
(invoiceQruey.pageNum - 1) * invoiceQruey.pageSize +
scope.$index +
1
}}
</template>
</el-table-column>
<el-table-column prop="code" label="发票代码"></el-table-column>
<el-table-column prop="number" label="发票号码" width="width"></el-table-column>
<el-table-column prop="time" label="发票时间" :formatter="getFroms"></el-table-column>
<el-table-column prop="category" label="发票类型">
<template slot-scope="scope">
<el-tag :type="scope.row.category == '0' ? 'info' : 'primary'">
{{
scope.row.category == "0" ? "普票" : "专票"
}}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="type" label="发票类别">
<template slot-scope="scope">
<el-tag
:type="
scope.row.type == '0'
? 'success'
: scope.row.type == '1'
? 'danger'
: 'warning'
"
>
{{
scope.row.type == "0"
? "收入"
: scope.row.type == "1"
? "支出"
: "报销"
}}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="mone" label="发票金额"></el-table-column>
<el-table-column prop="prop" label="发票文件" width="120px">
<template slot-scope="scope">
<div v-if="formatProtocolType(scope.row)">
<el-image
style="width: 80px; height: 80px"
:src="scope.row.fileUrl"
:preview-src-list="srcList"
></el-image>
</div>
<div v-else>
<a class="a-style" @click="handlePreView(scope.row)">点击查看文件</a>
</div>
</template>
</el-table-column>
<el-table-column prop="status" label="发票状态" width="90px">
<template slot-scope="scope">
<el-tag :type="scope.row.status == '0' ? 'info' : 'warning'">
{{
scope.row.status == 0 ? "未报销" : "已报销"
}}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="prop" label="操作">
<template slot-scope="scope">
<el-popover placement="top" width="160" v-model="scope.row.visible">
<p>确定要删除当前发票吗</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="scope.row.visible = false">取消</el-button>
<el-button type="primary" size="mini" @click="YesGet(scope.row)">确定</el-button>
</div>
<el-button
type="danger"
icon="el-icon-delete"
slot="reference"
size="mini"
:disabled="scope.row.status == 0 ? false : true"
></el-button>
</el-popover>
</template>
</el-table-column>
</el-table>
<el-row :gutter="20">
<el-col :span="24">
<!-- 分页 -->
<div class="foot_yi">
<el-pagination
@current-change="handleCurrentChange"
layout="total, prev, pager, next"
:total="total"
:current-page.sync="invoiceQruey.pageNum"
:page-size="invoiceQruey.pageSize"
></el-pagination>
</div>
</el-col>
</el-row>
</div>
</div>
</template>
<script>
import { mapGetters } from "vuex";
import { insertList, queryBypageIncomeAdd, deleteexpen } from "@/api/project";
import { getFileUrl } from "@/api/companyFile";
import { categoryOptions, typeOptions, statusOptions } from "../expense";
export default {
computed: {
...mapGetters(["companyId", "urId"])
},
created() {
this.action = process.env.VUE_APP_BASE_API + "/file/uploadFile";
this.getincomeSelectlist();
},
data() {
return {
invoiceQruey: {
pageNum: 1,
pageSize: 10
},
invoicegetList: [],
categoryOptions,
typeOptions,
statusOptions,
total: 0,
srcList: []
};
},
methods: {
//发票的分页查询
getincomeSelectlist() {
const params = {
...this.invoiceQruey,
companyId: this.companyId,
userId: this.urId
};
queryBypageIncomeAdd(params)
.then(res => {
if (res.success) {
this.total = res.data.total;
res.data.list.forEach(e => {
let fileNamepdf = e.filePath;
let fileType = fileNamepdf.substring(
fileNamepdf.lastIndexOf(".")
);
getFileUrl(e.filePath).then(res => {
if (res.success) {
let url = res.data;
e.fileUrl = url;
if (fileType != ".pdf") {
this.srcList.push(url);
}
}
});
});
this.invoicegetList = res.data.list;
} else {
this.$message.error(res.msg);
}
})
.catch(error => {
console.log(error);
this.$message.error("查询发票数据失败");
});
},
//换页
handleCurrentChange(val) {
this.invoiceQruey.pageNum = val;
this.getincomeSelectlist();
},
//时间处理
getFroms(value) {
var dt = new Date(value.time);
let year = dt.getFullYear();
let month = dt.getMonth() + 1;
let date = dt.getDate();
return `${year}${month}${date}日`;
},
//图片与pdf文件的处理
formatProtocolType(row) {
//这里判断的是是否有文件
if (row.filePath == null) {
return false;
} else {
let fileNamepdf = row.filePath;
let fileType = fileNamepdf.substring(fileNamepdf.lastIndexOf("."));
if (fileType != ".pdf") {
return true;
} else {
return false;
}
}
},
//查询
selectexpend() {
this.invoiceQruey.pageNum = 1;
this.getincomeSelectlist();
},
//重置
upddlist() {
this.invoiceQruey.pageNum = 1;
this.invoiceQruey.number = null;
this.invoiceQruey.code = null;
this.invoiceQruey.category = null;
this.invoiceQruey.type = null;
this.invoiceQruey.status = null;
this.getincomeSelectlist();
},
//发票的删除操作
YesGet(row) {
deleteexpen(row)
.then(res => {
if (res.success) {
this.visible = false;
this.$message({
message: "发票删除成功",
type: "success"
});
this.getincomeSelectlist();
} else {
this.$message.error(res.msg);
}
})
.catch(e => {
console.log(e.msg);
this.$message.error(e.msg);
});
},
//点击查看发票
handlePreView(row) {
const photopath = row.fileUrl;
window.open(photopath, "_blank");
}
}
};
</script>
<style>
.foot_yi {
text-align: right;
}
</style>
\ No newline at end of file
...@@ -148,11 +148,12 @@ export default { ...@@ -148,11 +148,12 @@ export default {
.then((res) => { .then((res) => {
// 登录成功 // 登录成功
// 路由到首页,指定query参数 // 路由到首页,指定query参数
if (res.status == "success") { if (res.success) {
this.$router.push({ this.$router.push({
path: "/", path: "/",
query: this.otherQuery, query: this.otherQuery,
}); });
this.loading = false; this.loading = false;
} else { } else {
this.$message({ this.$message({
......
...@@ -229,15 +229,6 @@ ...@@ -229,15 +229,6 @@
> >
撤回</el-button 撤回</el-button
> >
<!-- <el-popconfirm title="这是一段内容确定删除吗?">
<el-button slot="reference"
style="margin: 5px"
size="mini"
type="info"
@click="withdraw(scope.row)"
v-if="scope.row.reimbursementState == 0"
>删除</el-button>
</el-popconfirm> -->
<el-button <el-button
style="margin: 5px" style="margin: 5px"
size="mini" size="mini"
...@@ -736,7 +727,7 @@ export default { ...@@ -736,7 +727,7 @@ export default {
this.getinvoive({ this.getinvoive({
reimbursementId: this.invoiceQurey.reimbursementId, reimbursementId: this.invoiceQurey.reimbursementId,
}); });
this.$refs.form.resetFields(); this.this.$refs.form.resetFields();
this.$message.success(res.msg); this.$message.success(res.msg);
} else { } else {
this.$message.error("发票上传失败!"); this.$message.error("发票上传失败!");
...@@ -792,10 +783,16 @@ export default { ...@@ -792,10 +783,16 @@ export default {
}, },
//删除关系 //删除关系
delinvoice(data) { delinvoice(data) {
deletBystatus(data).then((res) => { this.$confirm("是否同意删除?", "提示", {
if (res.success) { confirmButtonText: "确定",
this.getinvoive(data); cancelButtonText: "取消",
} type: "warning",
}).then(() => {
deletBystatus(data).then((res) => {
if (res.success) {
this.getinvoive(data);
}
});
}); });
}, },
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=s, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.24.0/axios.min.js"></script>
</head>
<body> <body>
<button onclick="download()">下载(跨域)</button> <input type="file" id="fileInput">
<script> <button id="uploadBtn">上传</button>
function download() { </body>
var url = 'http://39.174.37.19:11538/finance2/36f95c32cb9421b5df30aa99a99c788.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=1N6XFL78EG190UUFHM53%2F20221115%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20221115T065613Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=0e3420279405fd4e88fbf33c997d12f13766dc7ffd9e4378fc5e43a229aa6236'; <script>
var xhr = new XMLHttpRequest(); // 请求基准地址
xhr.open('GET', url, true); // 异步 axios.defaults.baseURL = 'http://localhost:3000'
xhr.responseType = 'blob'; // blob 类型 // 选中的文件
xhr.onload = function () { var file = null
if (xhr.status != 200) { // 选择文件
alert('下载异常!'); document.getElementById('fileInput').onchange = function ({ target: { files } }) {
return; file = files[0]
} }
if (window.navigator.msSaveOrOpenBlob) { // 开始上传
navigator.msSaveBlob(xhr.response, filename); document.getElementById('uploadBtn').onclick = function () {
} else { if (!file) return
var newUrl = window.URL.createObjectURL(xhr.response); // 创建切片
var a = document.createElement('a'); // let size = 1024 * 1024 * 10; //10MB 切片大小
a.setAttribute('href', newUrl); let size = 1024 * 50; //50KB 切片大小
a.setAttribute('target', '_blank'); let fileChunks = []
a.setAttribute('download', 'hh.jpg'); // 自定义文件名(有效) let index = 0 //切片序号
document.body.appendChild(a); for (let cur = 0; cur < file.size; cur += size) {
a.click(); fileChunks.push({
document.body.removeChild(a); hash: index++,
chunk: file.slice(cur, cur + size)
})
}
// 控制并发和断点续传
const uploadFileChunks = async function (list) {
if (list.length === 0) {
//所有任务完成,合并切片
await axios({
method: 'get',
url: '/merge',
params: {
filename: file.name
}
});
console.log('上传完成')
// TODO
return
}
let pool = []//并发池
let max = 3 //最大并发量
let finish = 0//完成的数量
let failList = []//失败的列表
for (let i = 0; i < list.length; i++) {
let item = list[i]
let formData = new FormData()
formData.append('filename', file.name)
formData.append('hash', item.hash)
formData.append('chunk', item.chunk)
// 上传切片
// let task = axios({
// method: 'post',
// url: '/upload',
// data: formData
// })
task.then((data) => {
//请求结束后将该Promise任务从并发池中移除
let index = pool.findIndex(t => t === task)
pool.splice(index)
}).catch(() => {
failList.push(item)
}).finally(() => {
finish++
//所有请求都请求完成
if (finish === list.length) {
uploadFileChunks(failList)
}
})
pool.push(task)
if (pool.length === max) {
//每当并发池跑完一个任务,就再塞入一个任务
await Promise.race(pool)
} }
}; }
xhr.send();
} }
</script> uploadFileChunks(fileChunks)
</body>
\ No newline at end of file }
</script>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment