123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104 |
- <template>
- <div>
- <van-nav-bar title="费用报销" left-text="返回" @click-left="back" fixed left-arrow style="z-index:1000" />
- <div class="content">
- <van-tabs v-model="active" @change="activeChange">
- <van-tab title="费用报销" :name="0"></van-tab>
- <van-tab title="单据列表" :name="1"></van-tab>
- <van-tab title="单据审核" :name="2"></van-tab>
- </van-tabs>
- <!-- #region 费用报销 -->
- <div class="edit" v-if="active == 0">
- <van-form class="edit_form" label-width="140">
- <!-- 报销人 -->
- <van-field label="报销人" @click="ownerIdShowCli(1)" readonly clickable required>
- <template #input>
- <span v-if="user.userNameNeedTranslate == 1 && formshowText.name"><ww-open-data type='userName'
- :openid='formshowText.name'></ww-open-data></span>
- <span v-else>{{ formshowText.name }}</span>
- </template>
- </van-field>
- <div v-if="auditTypeItem.auditType == 2">
- <van-field label="第一审核人" @click="ownerIdShowCli(2)" readonly clickable required>
- <template #input>
- <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName'
- :openid='firstCheckerText.name'></ww-open-data></span>
- <span v-else>{{ firstCheckerText.name }}</span>
- </template>
- </van-field>
- <van-field label="第二审核人" @click="ownerIdShowCli(3)" readonly clickable required>
- <template #input>
- <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName'
- :openid='secondCheckerText.name'></ww-open-data></span>
- <span v-else>{{ secondCheckerText.name }}</span>
- </template>
- </van-field>
- </div>
- <van-popup v-model="ownerIdShow" position="bottom" v-if="canExamine" style="height: 90%">
- <div class="popupDiv paddingTop">
- <div class="popupCon conBorder">
- <van-radio-group v-model="userRadio" v-if="user.userNameNeedTranslate == '1'">
- <div v-for="item in userList" :key="item.id">
- <van-radio :name="item" class="popupItem marginNone borderNone" v-if="item.id != user.id || ownerIdShowType == 1">
- <!-- <ww-open-data type='userName' :openid='item.name'></ww-open-data> -->
- <span class="userNameClass_left">
- <ww-open-data type='userName' :openid='item.name'></ww-open-data>
- </span>
- <span class="userNameClass_right">
- {{ item.jobNumber }}
- </span>
- </van-radio>
- </div>
- </van-radio-group>
- <van-radio-group v-model="userRadio" v-else>
- <div v-for="item in userList" :key="item.id">
- <van-radio :name="item" class="popupItem marginNone borderNone" v-if="item.id != user.id || ownerIdShowType == 1">
- <!-- {{ item.name }} -->
- <span class="userNameClass_left">{{item.name}}</span>
- <span class="userNameClass_right">{{ item.jobNumber }}</span>
- </van-radio>
- </div>
- </van-radio-group>
- </div>
- <div class="popupBtn">
- <van-button style="width:100%;background: #1989fa;color: #ffffff;" round
- @click="ownerIdChange()">确定</van-button>
- </div>
- </div>
- </van-popup>
- <!-- 填报日期 -->
- <van-field v-model="editForm.createDate" label="填报日期" @click="createDateShow = true" readonly clickable
- required></van-field>
- <van-popup v-model="createDateShow" position="bottom">
- <van-datetime-picker type="date" title="选择填报日期" @confirm="createDateChange" v-model="currentDate1"
- @cancel="createDateShow = false; $forceUpdate();" :min-date="minDate" :max-date="maxDate" />
- </van-popup>
- <!-- 发票张数 -->
- <van-field label="发票张数" v-if="user.timeType.easyExpense==0">
- <template #input>
- <van-stepper v-model="editForm.ticketNum" disable-input @plus="ticNumChange(1)"
- @minus="ticNumChange(0)" />
- </template>
- </van-field>
- <!-- 费用类型 -->
- <van-field v-model="editForm.type" label="费用主类型" @click="typeShow = true" readonly clickable>
- <template #input>{{ expenseMainType.text }}</template>
- </van-field>
- <van-popup v-model="typeShow" position="bottom">
- <van-picker show-toolbar :columns="typeList" @confirm="typeChange"
- @cancel="typeShow = false; $forceUpdate();" />
- </van-popup>
- <!-- 备注 -->
- <van-field v-model="editForm.remark" label="备注" type="textarea" maxlength="100"></van-field>
- <!-- 发票 -->
- <van-field label="发票" readonly>
- <template #input>总费用: ¥{{ totalCost }}</template>
- </van-field>
- <div class="invoice" v-if="invoiceList.length != 0">
- <div v-for="item, index in invoiceList" :key="item.id" style="position:relative"
- :class="index == 0 ? '' : 'invoice_item'">
- <!-- <van-button class="deletebtn" size="mini" type="default" @click="deleteInvoice(index)">删除</van-button> -->
- <van-icon name="delete-o" class="deletebtn" v-if="index != 0" @click="deleteInvoice(index)" />
- <van-field label="所属项目:" v-model="item.projectId"
- @click="in_projectShow = true, invoiceIndex = index" readonly clickable required>
- <template #input>{{ formshowText.inProjectName[index] }}</template>
- </van-field>
- <van-field label="费用日期:" v-model="item.happenDate"
- @click="in_dateShow = true, invoiceIndex = index" readonly clickable required></van-field>
- <van-field label="发票种类:" v-model="item.invoiceType" v-if="user.timeType.easyExpense==0"
- @click="in_typeShow = true, invoiceIndex = index" readonly clickable required>
- <template #input>{{ inTypeList[item.invoiceType] }}</template>
- </van-field>
- <van-field label="费用类型:" v-model="item.expenseType"
- @click="in_exTypeShow = true, invoiceIndex = index" readonly clickable required></van-field>
- <van-field :label="`${user.timeType.easyExpense==0?'费用金额(含税)':'费用金额'}:`" v-model="item.amount" type="number" required></van-field>
- <van-field label="发票号:" v-model="item.invoiceNo" v-if="user.timeType.easyExpense==0"></van-field>
- <van-field label="税率%:" v-model="item.taxPercent" v-if="user.timeType.easyExpense==0"></van-field>
- <van-field label="税额:" readonly v-if="user.timeType.easyExpense==0">
- <template #input>¥{{ getTaxValue(item.amount, item.taxPercent) }}</template>
- </van-field>
- <van-field label="备注:" v-model="item.remark" autosize maxlength="100"></van-field>
- <!-- <van-field label="报销凭证:" @click="invoiceIndex = index" clickable>
- <template #input>
- <van-uploader v-model="uploader[index]" :before-read="beforeRead"
- :after-read="afterRead" @delete="item.pic = null" :max-count="1" />
- </template>
- </van-field> -->
- <van-field @click="invoiceIndex = index" clickable label-width="0em">
- <template #input>
- <div class="imgListVan">
- <div>报销凭证:</div>
- <div class="vanUploaderImg">
- <van-uploader v-model="uploader[index]" :before-read="beforeRead" multiple
- :after-read="afterRead" @delete="(file, Item) => {deteleImg(file, Item, index)}" :max-count="10" />
- </div>
- </div>
-
- </template>
- </van-field>
- </div>
- </div>
- <div class="addinvoice"><van-button size="small" icon="plus" type="info" plain hairline
- @click="addInvoice">添加发票</van-button></div>
- <!-- 发票-popup -->
- <span>
- <!-- 所属项目 -->
- <!-- <van-popup v-model="in_projectShow" position="bottom">
- <van-picker value-key="projectName" show-toolbar :columns="inProjectList"
- @confirm="inProjectChange" @cancel="in_projectShow = false; $forceUpdate();" />
- </van-popup> -->
- <van-popup v-model="in_projectShow" position="bottom" style="height: 84%">
- <div class="popupDiv">
- <div class="popupSearch">
- <van-search v-model.trim="projectSelectVal" shape="round" background="#F4F4F4" placeholder="请输入项目名称/编号" @clear="projectSelect()" @blur="projectSelect()" @search="projectSelect()" @input="projectSelect()"/>
- </div>
- <div class="popupCon">
- <div v-for="(item, index) in inProjectList" :key="item.id" class="popupItem paddingDiv" @click="inProjectChange(item, index)">
- <p class="popupItemOne" v-if="item.projectName">{{item.projectName}}</p>
- <p class="popupItemTwo" v-if="item.projectCode">{{item.projectCode}}</p>
- </div>
- </div>
- </div>
- </van-popup>
- <!-- 费用日期 -->
- <van-popup v-model="in_dateShow" position="bottom">
- <van-datetime-picker type="date" title="选择费用日期" @confirm="inDateChange" v-model="currentDate2"
- @cancel="in_dateShow = false; $forceUpdate();" :min-date="minDate" :max-date="maxDate" />
- </van-popup>
- <!-- 发票种类 -->
- <van-popup v-model="in_typeShow" position="bottom">
- <van-picker show-toolbar :columns="inTypeList" @confirm="inTypeChange"
- @cancel="in_typeShow = false; $forceUpdate();" />
- </van-popup>
- <!-- 费用类型 -->
- <van-popup v-model="in_exTypeShow" position="bottom">
- <van-picker value-key="typeName" show-toolbar :columns="inexTypeList" @confirm="inexTypeChange"
- @cancel="in_exTypeShow = false; $forceUpdate();" />
- </van-popup>
- </span>
- </van-form>
- <!-- 提交 -->
- <div class="form_btn" style="position:fixed; bottom:0px;width:100%;">
- <div style="padding-bottom:10px;">
- <van-button square block type="info" @click="submitExpense" :loading="confirmLoading"
- style="width:100%;float:left;">提交</van-button>
- </div>
- </div>
- </div>
- <!-- #endregion -->
- <!-- 单据列表 -->
- <div class="list" v-if="active == 1">
- <!-- <van-pull-refresh v-model="downLoading" @refresh="onDownRefresh">
- <van-list v-model="uploading" :finished="upFinished" :immediate-check="false" :offset="100" finished-text="没有更多了" @load="onLoadList"></van-list>
- </van-pull-refresh> -->
- <van-collapse v-model="activeName" accordion class="list_collapse">
- <van-collapse-item v-for="item in billList" :key="item.id" title="标题1" :name="item.id">
- <template #title>
- <div class="collapse_label_l">票据编号:{{ item.code }}</div>
- <div class="collapse_label_r">报销人:
- <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName'
- :openid='item.ownerName'></ww-open-data></span>
- <span v-else>{{ item.ownerName }}</span>
- </div>
- <div class="collapse_label_l">金额: ¥{{ item.totalAmount | numtosum }}</div>
- <div class="collapse_label_r">状态:<span :class="statusClass[item.status]">{{
- statusList[item.status] }}</span></div>
- </template>
- <div class="wrapper">
- <div><span>票据编号:</span><span>{{ item.code }}</span></div>
- <div><span>金额:</span><span>¥{{ item.totalAmount | numtosum }}</span></div>
- <div><span>报销人:</span>
- <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName'
- :openid='item.ownerName'></ww-open-data></span>
- <span v-else>{{ item.ownerName }}</span>
- </div>
- <div><span>填报日期:</span><span>{{ item.createDate }}</span></div>
- <div v-if="user.timeType.easyExpense==0"><span>发票张数:</span><span>{{ item.ticketNum }}</span></div>
- <div><span>费用类型:</span><span>{{ item.expenseMainTypeName }}</span></div>
- <!-- <div><span>状态:</span><span>{{item.status}}</span></div> -->
- <!-- <div><span>驳回原因:</span><span>{{item.denyReason}}</span></div> -->
- <div><span>备注:</span><span>{{ item.remark }}</span></div>
- </div>
- <div class="operation">
- <van-button size="small" type="info"
- :to="{ name: 'expenseDetails', params: { id: item.id, canEdit: false } }">查看</van-button>
- <van-button style="margin-left:10px" size="small" type="info"
- :to="{ name: 'expenseDetails', params: { id: item.id, canEdit: true } }">编辑</van-button>
- <van-button style="margin-left:10px" size="small" type="danger"
- @click="deleteBill(item.id)">删除</van-button>
- </div>
- </van-collapse-item>
- </van-collapse>
- </div>
- <!-- 单据审核 -->
- <div class="audit" v-if="active == 2">
- <van-collapse v-model="auditName" accordion class="list_collapse">
- <van-collapse-item v-for="item in examineList" :key="item.id" title="标题2" :name="item.id">
- <template #title>
- <div class="collapse_label_l">票据编号:{{ item.code }}</div>
- <div class="collapse_label_r">报销人:
- <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName'
- :openid='item.ownerName'></ww-open-data></span>
- <span v-else>{{ item.ownerName }}</span>
- </div>
- <div class="collapse_label_l">金额: ¥{{ item.totalAmount | numtosum }}</div>
- <div class="collapse_label_r">状态:<span :class="statusClass[item.status]">{{
- statusList[item.status] }}</span></div>
- <div class="operation" v-if="auditTypeItem.auditType == 0">
- <van-button size="small" type="info" :loading="item.approveLoading"
- @click.stop="approve(item)">通过</van-button>
- <van-button style="margin-left:15px" size="small" type="danger"
- @click.stop="denyToReason(item.id)">驳回</van-button>
- </div>
- <div class="operation" v-if="auditTypeItem.auditType == 1">
- <van-button size="small" type="info"
- :to="{ name: 'expenseDetails', params: { id: item.id, canEdit: false, isAudit:true } }">审核</van-button>
- </div>
- <div class="operation" v-if="auditTypeItem.auditType == 2">
- <van-button size="small" type="info" :loading="item.approveLoading"
- @click.stop="approve(item)">通过</van-button>
- <van-button style="margin-left:15px" size="small" type="danger"
- @click.stop="denyToReason(item.id)">驳回</van-button>
- </div>
- </template>
- <div class="wrapper">
- <div><span>票据编号:</span><span>{{ item.code }}</span></div>
- <div><span>金额:</span><span>¥{{ item.totalAmount | numtosum }}</span></div>
- <div><span>报销人:</span>
- <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName'
- :openid='item.ownerName'></ww-open-data></span>
- <span v-else>{{ item.ownerName }}</span>
- </div>
- <div><span>填报日期:</span><span>{{ item.createDate }}</span></div>
- <div v-if="user.timeType.easyExpense==0"><span>发票张数:</span><span>{{ item.ticketNum }}</span></div>
- <div><span>费用类型:</span><span>{{ item.expenseMainTypeName }}</span></div>
- <div>
- <span>审核流程:</span>
- <span v-if="item.reviewProcess == 0">待第一审核人审核</span>
- <span v-if="item.reviewProcess == 1">待第二审核人审核</span>
- <span v-if="item.reviewProcess == 2">审核完成</span>
- </div>
- <!-- <div><span>状态:</span><span>{{item.status}}</span></div> -->
- <!-- <div><span>驳回原因:</span><span>{{item.denyReason}}</span></div> -->
- <div><span>备注:</span><span>{{ item.remark }}</span></div>
- </div>
- <div class="lookup">
- <van-button size="small" type="info"
- :to="{ name: 'expenseDetails', params: { id: item.id, canEdit: false } }">查看单据信息</van-button>
- </div>
- </van-collapse-item>
- </van-collapse>
- <!-- <van-popup v-model="denyReasonDialog" position="bottom" closeable >
- <van-cell>请输入原因</van-cell>
- <van-field class="form_input"
- v-model="denyParm.denyReason" name="reason" type="textarea" placeholder="请输入您决定驳回的原因"
- rows="3" autosize />
- <van-button style="width:100%;" type="info" :loading="denyLoading" @click="deny()">提交</van-button>
- </van-popup> -->
- </div>
- </div>
- </div>
- </template>
- <script>
- export default {
- data() {
- return {
- auditTypeItem: {auditType: 0},
- active: sessionStorage.page ? JSON.parse(sessionStorage.page) : 0,
- user: JSON.parse(localStorage.userInfo),
- userList: [],
- canExamine: false,
- currentDate1: new Date(),
- currentDate2: new Date(),
- minDate: new Date(2020, 0, 1),
- maxDate: new Date(2025, 11, 31),
- confirmLoading: false,
- denyLoading: false,
- formshowText: {
- name: '',
- inProjectName: []
- },
- // #region 费用报销
- editForm: {
- ownerId: '',
- createDate: this.formatDate(new Date()),
- ticketNum: 0,
- type: 0,
- remark: ''
- },
- userRadio: null,
- ownerIdShow: false,
- ownerIdShowType: 1, // 1,报销人, 2第一审核人, 3第二审核人
- createDateShow: false,
- typeShow: false,
- typeList: [],
- invoiceIndex: 0,
- invoiceList: [
- {
- projectId: '',
- happenDate: '',
- invoiceType: '',
- expenseType: '',
- amount: '',
- invoiceNo: '',
- taxPercent: '',
- taxValue: '',
- remark: '',
- pic: '',
- }
- ],
- in_projectShow: false,
- in_dateShow: false,
- in_typeShow: false,
- in_exTypeShow: false,
- inProjectList: [],
- inProjectListCopy: [],
- inTypeList: ['增值税专用发票', '增值税普通发票'],
- allexTypeList: [],
- inexTypeList: [],
- uploader: [[]],
- // #endregion
- // 单据列表
- activeName: '',
- billList: [],
- statusList: ['审核通过', '待审核', '已驳回', '已撤销'],
- statusClass: ['', 'waiting', 'rejected', ''],
- uploading: false,
- // 单据审核
- auditName: '',
- examineList: [],
- denyReasonDialog: false,
- denyParm: {
- id: '',
- denyReason: ''
- },
- expenseMainType: {
- text: ''
- },
- projectSelectVal: '',
- firstCheckerText: {},
- secondCheckerText: {}
- }
- },
- computed: {
- totalCost() {
- let costnum = 0
- for (let i in this.invoiceList) {
- costnum += (this.invoiceList[i].amount ? parseFloat(this.invoiceList[i].amount) : 0)
- }
- return costnum.toFixed(2)
- }
- },
- filters: {
- numtosum(value) {
- if (value == undefined || !value) return '0.00'
- value = value.toFixed(2)
- const intPart = Math.trunc(value)
- const intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
- let floatPart = '.00'
- const valueArray = value.toString().split('.')
- if (valueArray.length === 2) { // 有小数部分
- floatPart = valueArray[1].toString() // 取得小数部分
- return intPartFormat + '.' + floatPart
- }
- return intPartFormat + floatPart
- },
- },
- mounted() {
- this.formshowText.name = this.user.name;
- this.editForm.ownerId = this.user.id;
- this.userRadio = {
- name: this.user.name,
- id: this.user.id
- }
- this.activeChange()
- for (let i in this.user.functionList) {
- if (this.user.functionList[i].name == '费用审核') {
- this.canExamine = true
- }
- }
- if (!this.canExamine) {
- this.editForm.ownerId = this.user.id
- this.formshowText.name = this.user.name
- }
-
- this.getUserList()
- this.getProjectList()
- this.getExpensMainTypes()
- this.getExTypeList()
- this.getAuditType();
- },
- methods: {
- // 项目搜索
- projectSelect() {
- if(this.projectSelectVal.length > 0) {
- let data = this.inProjectListCopy.filter(item => {return item.projectName && item.projectName.includes(this.projectSelectVal)});
- let dataList = this.inProjectListCopy.filter(item => {return item.projectCode && item.projectCode.includes(this.projectSelectVal)});
- let dataTree = data.concat(dataList)
- let arrList = Array.from(new Set(dataTree))
- this.inProjectList = arrList
- } else {
- this.inProjectList = JSON.parse(JSON.stringify(this.inProjectListCopy))
- }
- },
- back() {
- sessionStorage.removeItem("page");
- history.back();
- },
- formatDate(date) {
- let mon = date.getMonth() + 1
- return `${date.getFullYear()}-${mon < 10 ? '0' + mon : mon}-${date.getDate() < 10 ? '0' + date.getDate() : date.getDate()}`;
- },
- getTaxValue(amount, percent) {
- let per = percent / 100
- let amo = amount / (1 + per) * per
- return amo.toFixed(2)
- },
- activeChange() {
- sessionStorage.setItem('page', JSON.stringify(this.active))
- if (this.active == 1) {
- this.getBillList()
- }
- if (this.active == 2) {
- this.getExamineList()
- }
- },
- // #region 费用报销
- ownerIdChange() {
- if(this.ownerIdShowType == 1) {
- this.editForm.ownerId = this.userRadio.id
- this.formshowText.name = this.userRadio.name
- } else if(this.ownerIdShowType == 2) {
- this.$set(this.firstCheckerText, 'id', this.userRadio.id)
- this.$set(this.firstCheckerText, 'name', this.userRadio.name)
- } else if(this.ownerIdShowType == 3) {
- this.$set(this.secondCheckerText, 'id', this.userRadio.id)
- this.$set(this.secondCheckerText, 'name', this.userRadio.name)
- }
- this.ownerIdShow = false
- },
- createDateChange(value, key) {
- this.editForm.createDate = this.formatDate(value)
- this.createDateShow = false
- },
- typeChange(value, key) {
- this.editForm.type = value.id
- this.expenseMainType.text = value.name
- this.typeShow = false
- for (let i in this.invoiceList) {
- this.invoiceList[i].expenseType = ''
- }
- this.inexTypeList = this.allexTypeList.filter(a => a.mainType == this.editForm.type)
- },
- ticNumChange(value) {
- if (value) {
- this.invoiceList.push({
- projectId: '',
- happenDate: '',
- invoiceType: '',
- expenseType: '',
- amount: '',
- invoiceNo: '',
- taxPercent: '',
- taxValue: '',
- remark: '',
- pic: '',
- })
- } else {
- this.invoiceList.pop()
- }
- },
- // 发票
- inProjectChange(value, key) {
- this.formshowText.inProjectName[this.invoiceIndex] = value.projectName
- this.invoiceList[this.invoiceIndex].projectId = value.id
- this.in_projectShow = false
- },
- inDateChange(value, key) {
- this.invoiceList[this.invoiceIndex].happenDate = this.formatDate(value)
- this.in_dateShow = false
- },
- inTypeChange(value, key) {
- this.invoiceList[this.invoiceIndex].invoiceType = key
- this.in_typeShow = false
- },
- inexTypeChange(value, key) {
- this.invoiceList[this.invoiceIndex].expenseType = value.typeName
- this.in_exTypeShow = false
- },
- addInvoice() {
- this.invoiceList.push({
- projectId: '',
- happenDate: '',
- invoiceType: '',
- expenseType: '',
- amount: '',
- invoiceNo: '',
- taxPercent: '',
- taxValue: '',
- remark: '',
- pic: '',
- })
- this.uploader.push([])
- this.editForm.ticketNum = this.invoiceList.length
- },
- deleteInvoice(index) {
- this.invoiceList.splice(index, 1)
- this.uploader.splice(index, 1)
- this.editForm.ticketNum = this.invoiceList.length
- },
- // 上传报销凭证
- beforeRead(file) {
- // console.log(file, file.length)
- // console.log(Array.isArray(file))
- // if (file.type != 'image/jpeg' && file.type != 'image/png' && file.type != 'image/jpg') {
- // this.$toast.fail('请选择jpg或png格式的图片')
- // return false
- // }
- // return true
- let newFile = Array.isArray(file) ? file : [file]
- for(var i in newFile) {
- const fileItem = newFile[i]
- if (fileItem.type != 'image/jpeg' && fileItem.type != 'image/png' && fileItem.type != 'image/jpg') {
- this.$toast.fail('请选择jpg或png格式的图片')
- return false
- }
- }
- return true
- },
- afterRead(file) {
- // let formData = new FormData();
- // formData.append("multipartFile", file.file);
- // this.$axios.post("/common/uploadFile", formData)
- // .then(res => {
- // if (res.code == "ok") {
- // this.invoiceList[this.invoiceIndex].pic = res.data
- // } else {
- // this.$toast.fail('上传失败');
- // this.uploader[this.invoiceIndex] = []
- // }
- // }).catch(err => { this.$toast.clear(); console.log(err); this.uploader[this.invoiceIndex] = [] });
- let newFile = Array.isArray(file) ? file : [file]
- let formData = new FormData();
- for(var i in newFile) {
- formData.append("multipartFiles", newFile[i].file);
- }
- this.$axios.post("/common/uploadFileArray", formData)
- .then(res => {
- if (res.code == "ok") {
- let newPic = this.invoiceList[this.invoiceIndex].pic || []
- let newData = res.data.split(';')
- this.invoiceList[this.invoiceIndex].pic = [...newPic, ...newData]
- console.log(this.invoiceList[this.invoiceIndex].pic, '<=== 合计图片')
- } else {
- this.$toast.fail('上传失败');
- this.uploader[this.invoiceIndex] = []
- }
- }).catch(err => { this.$toast.clear(); console.log(err); this.uploader[this.invoiceIndex] = [] });
- },
- // 删除图片
- deteleImg(file, item, arrIndex) {
- let index = item.index
- this.invoiceList[arrIndex].pic = this.invoiceList[arrIndex].pic.filter((item,i) => i != index)
- },
- // 提交
- submitExpense() {
- if (!this.editForm.ownerId) {
- this.$toast.fail('请选择报销人')
- return
- }
- if (!this.editForm.createDate) {
- this.$toast.fail('请选择填报日期')
- return
- }
- if(this.auditTypeItem.auditType == 2) {
- if(!this.firstCheckerText.id || !this.secondCheckerText.id) {
- this.$toast.fail(`${!this.firstCheckerText.id ? '请选择第一审核人' : '请选择第二审核人'}`)
- return
- } else {
- this.editForm.firstCheckerId = this.firstCheckerText.id
- this.editForm.secondCheckerId = this.secondCheckerText.id
- }
- }
- let required1 = false
- let required2 = false
- let required3 = false
- let required4 = false
- let required5 = false
- for (let i in this.invoiceList) {
- if (!this.invoiceList[i].projectId) {
- required1 = '所属项目'
- }
- if (!this.invoiceList[i].happenDate) {
- required2 = '费用日期'
- }
- // if (!this.invoiceList[i].invoiceType) {
- // required3 = '发票种类'
- // }
- if (!this.invoiceList[i].expenseType) {
- required4 = '费用类型'
- }
- if (!this.invoiceList[i].amount) {
- required5 = this.user.timeType.easyExpense==0?'费用金额(含税)':'费用金额'
- }
- }
- if (required1 || required2 || required3 || required4 || required5) {
- let requiredStr = (required1 ? required1 + '、' : '')
- + (required2 ? required2 + '、' : '')
- + (required3 ? required3 + '、' : '')
- + (required4 ? required4 + '、' : '')
- + (required5 ? required5 + '、' : '')
- requiredStr = requiredStr.substring(0, requiredStr.length - 1)
- this.$toast.fail('请添加发票的[' + requiredStr + ']')
- return
- }
- if (this.invoiceList.length == 0) {
- this.$toast.fail('请添加发票')
- return
- }
- for (let i in this.invoiceList) {
- this.invoiceList[i].taxValue = this.getTaxValue(this.invoiceList[i].amount, this.invoiceList[i].taxPercent)
- }
-
- let newList = JSON.parse(JSON.stringify(this.invoiceList))
- for(let i in newList) {
- if(newList[i].pic) {
- newList[i].pic = newList[i].pic.join(',')
- }
- }
- // this.editForm.items = JSON.stringify(this.invoiceList)
- this.editForm.items = JSON.stringify(newList)
- this.editForm.totalAmount = this.totalCost
- // 获取新的票据编号
- this.confirmLoading = true
- this.$axios.post("/expense-sheet/getNextCode", {})
- .then(res => {
- if (res.code == "ok") {
- this.editForm.code = res.data
- // 提交
- this.$axios.post("/expense-sheet/add", this.editForm)
- .then(res => {
- this.confirmLoading = false;
- if (res.code == "ok") {
- this.$toast.success('填报成功')
- this.editForm = {
- ownerId: '',
- createDate: this.formatDate(new Date()),
- ticketNum: 0,
- type: 0,
- remark: ''
- }
- // this.formshowText = {
- // name: '',
- // inProjectName: []
- // }
- this.$set(this, 'firstCheckerText', {})
- this.$set(this, 'secondCheckerText', {})
- this.formshowText.name = ''
- this.formshowText.inProjectName = []
- this.expenseMainType.text=''
- this.invoiceList = []
- this.uploader = []
- this.formshowText.name = this.user.name;
- this.editForm.ownerId = this.user.id;
- this.userRadio = {
- name: this.user.name,
- id: this.user.id
- }
- } else {
- this.$toast.fail(res.msg || res.code || '填报失败');
- }
- }).catch(err => { this.confirmLoading = false; this.$toast.clear(); console.log(err) });
- } else {
- this.confirmLoading = false
- this.$toast.fail('获取失败');
- }
- }).catch(err => {
- this.confirmLoading = false;
- this.$toast.clear();
- console.log(err)
- });
- },
- // #endregion
- // 单据列表
- deleteBill(pid) {
- this.$dialog.confirm({
- message: '确认删除?',
- })
- .then(() => {
- // on confirm
- this.$axios.post("/expense-sheet/delete", { id: pid })
- .then(res => {
- if (res.code == "ok") {
- this.$toast.success('删除成功')
- this.getBillList()
- } else {
- this.$toast.fail(res.msg || res.code || '删除失败');
- }
- }).catch(err => { this.$toast.clear(); console.log(err) });
- })
- .catch(() => {
- // on cancel
- });
- },
- getAuditType() {
- this.$axios.post("/expense-audit-setting/get", {})
- .then(res => {
- if (res.code == "ok") {
- this.auditTypeItem = res.data;
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- }).catch(err => { this.$toast.clear(); console.log(err) });
- },
-
- // 单据审核
- approve(item) {
- item.approveLoading = true
- this.$axios.post("/expense-sheet/approve", { id: item.id })
- .then(res => {
- if (res.code == "ok") {
- this.$toast.success('已通过')
- item.approveLoading = false
- this.getExamineList()
- } else {
- this.$toast.fail('操作失败');
-
- }
- }).catch(err => { this.$toast.clear(); console.log(err) });
- },
- denyToReason(pid) {
- this.denyParm.id = pid
- this.denyReasonDialog = true
- this.denyParm.denyReason = ''
- this.deny()
- },
- deny() {
- this.denyLoading = true
- this.$axios.post("/expense-sheet/deny", this.denyParm)
- .then(res => {
- if (res.code == "ok") {
- this.$toast.success('已驳回')
- this.denyReasonDialog = false
- this.denyLoading = false
- this.getExamineList()
- } else {
- this.$toast.fail(res.msg || res.code || '操作失败');
- }
- }).catch(err => { this.$toast.clear(); console.log(err) });
- },
- getUserList() {
- this.$axios.post("/user/getSimpleActiveUserList", {})
- .then(res => {
- if (res.code == "ok") {
- this.userList = res.data
- } else {
- this.$toast.fail(res.msg || res.code || '获取失败');
- }
- }).catch(err => { this.$toast.clear(); console.log(err) });
- },
- getProjectList() {
- this.$axios.post("/project/getProjectList", {})
- .then(res => {
- if (res.code == "ok") {
- this.inProjectList = res.data
- this.inProjectListCopy = JSON.parse(JSON.stringify(res.data))
- } else {
- this.$toast.fail(res.msg || res.code || '获取失败');
- }
- }).catch(err => { this.$toast.clear(); console.log(err) });
- },
- getExTypeList() {
- this.$axios.post("/expense-type/getList", {})
- .then(res => {
- if (res.code == "ok") {
- this.allexTypeList = res.data
- this.inexTypeList = this.allexTypeList.filter(a => a.mainType == this.editForm.type)
- } else {
- this.$toast.fail(res.msg || res.code || '获取失败');
- }
- }).catch(err => { this.$toast.clear(); console.log(err) });
- },
- getExpensMainTypes() {
- this.$axios.post("/expense-main-type/list", {})
- .then(res => {
- if (res.code == "ok") {
- for (var i in res.data) {
- res.data[i].text = res.data[i].name
- }
- this.typeList = res.data
- this.expenseMainType.text = res.data[0].name
- this.editForm.type = res.data[0].id
- this.getExTypeList
- } else {
- this.$toast.fail(res.msg || res.code || '获取失败');
- }
- }).catch(err => { this.$toast.clear(); console.log(err) });
- },
- getBillList() {
- this.$axios.post("/expense-sheet/list", {
- pageSize: 999,
- pageIndex: 1,
- startDate: '',
- endDate: '',
- ownerId: '',
- type: ''
- }).then(res => {
- if (res.code == "ok") {
- this.billList = res.data.records
- } else {
- this.$toast.fail(res.msg || res.code || '获取失败');
- }
- }).catch(err => { this.$toast.clear(); console.log(err) });
- },
- getExamineList() {
- this.$axios.post("/expense-sheet/list", {
- pageSize: 999,
- pageIndex: 1,
- startDate: '',
- endDate: '',
- ownerId: '',
- type: '',
- status: 1
- }).then(res => {
- if (res.code == "ok") {
- this.examineList = res.data.records
- for (let i in this.examineList) {
- this.$set(this.examineList[i], 'approveLoading', false)
- }
- } else {
- this.$toast.fail(res.msg || res.code || '获取失败');
- }
- }).catch(err => { this.$toast.clear(); console.log(err) });
- },
- ownerIdShowCli(type) {
- console.log('执行')
- this.ownerIdShowType = type
- this.userRadio = ''
- this.ownerIdShow = true
- if(type > 1) {
- this.canExamine = true
- }
- }
- },
- }
- </script>
- <style lang="less" scoped>
- .content {
- margin-top: 46px;
- overflow: auto;
- .edit {
- .userCheckbox {
- padding: 10px;
- }
- padding-bottom: 46px;
- .form_btn {
- z-index: 1000;
- }
- .edit_form {
- .invoice {
- border: 0.5px solid rgb(135, 195, 255);
- margin: 0.2rem;
- .deletebtn {
- position: absolute;
- z-index: 900;
- font-size: 24px;
- right: 0.08rem;
- top: 0.08rem;
- color: #c03131;
- }
- .invoice_item {
- border-top: 0.5px solid rgb(135, 195, 255);
- }
- }
- .addinvoice {
- padding: 0 0.3rem 0.3rem;
- margin-top: 0.2rem;
- text-align: right;
- }
- }
- .imgListVan {
- display: flex;
- flex-direction: column;
- }
- .vanUploaderImg {
- // display: flex;
- margin-top: 6px;
- /deep/ .van-uploader__preview-image {
- width: 70px;
- height: 70px;
- }
- }
- /deep/ .van-uploader__upload {
- width: 70px;
- height: 70px;
- }
- }
- .list {
- .list_collapse>div {
- margin: 4px;
- }
- .list_collapse {
- .collapse_label_l {
- width: 50%;
- padding: 4px;
- display: inline-block;
- }
- .collapse_label_r {
- width: 50%;
- padding: 4px;
- display: inline-block;
- .waiting {
- color: orange;
- }
- .rejected {
- color: red;
- }
- }
- .wrapper {
- div {
- margin: 8px 16px;
- }
- div span:nth-child(1) {
- width: 30%;
- display: inline-block;
- }
- div span:nth-child(2) {
- width: 70%;
- display: inline-block;
- }
- }
- .operation {
- display: flex;
- align-items: center;
- justify-content: flex-end;
- }
- }
- }
- .audit {
- .list_collapse>div {
- margin: 4px;
- }
- .list_collapse {
- .collapse_label_l {
- width: 60%;
- padding: 4px;
- display: inline-block;
- }
- .collapse_label_r {
- width: 40%;
- padding: 4px;
- display: inline-block;
- .waiting {
- color: orange;
- }
- .rejected {
- color: red;
- }
- }
- .operation {
- margin-top: 5px;
- padding-top: 5px;
- border-top: 0.5px solid #ebedf0;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- button {
- width: 1.2rem;
- }
- }
- .wrapper {
- div {
- margin: 8px 16px;
- }
- div span:nth-child(1) {
- width: 30%;
- display: inline-block;
- }
- div span:nth-child(2) {
- width: 70%;
- display: inline-block;
- }
- }
- .lookup {
- display: flex;
- align-items: center;
- justify-content: flex-end;
- }
- }
- }
- }
- </style>
- <style>
- .edit_form .invoice .van-field__label {
- color: #999;
- }
- .edit_form .invoice .van-field__control {
- color: #999;
- }
- </style>
|