index.vue 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952
  1. <template>
  2. <div>
  3. <van-nav-bar title="费用报销" left-text="返回" @click-left="back" fixed left-arrow style="z-index:1000" />
  4. <div class="content">
  5. <van-tabs v-model="active" @change="activeChange">
  6. <van-tab title="费用报销" :name="0"></van-tab>
  7. <van-tab title="单据列表" :name="1"></van-tab>
  8. <van-tab title="单据审核" :name="2"></van-tab>
  9. </van-tabs>
  10. <!-- #region 费用报销 -->
  11. <div class="edit" v-if="active == 0">
  12. <van-form class="edit_form" label-width="140">
  13. <!-- 报销人 -->
  14. <van-field label="报销人" @click="ownerIdShow = true" readonly clickable required>
  15. <template #input>
  16. <span v-if="user.userNameNeedTranslate == 1 && formshowText.name"><ww-open-data type='userName'
  17. :openid='formshowText.name'></ww-open-data></span>
  18. <span v-else>{{ formshowText.name }}</span>
  19. </template>
  20. </van-field>
  21. <van-popup v-model="ownerIdShow" position="bottom" v-if="canExamine" style="height: 90%">
  22. <!-- <div style="minHeight:300px;">
  23. <van-radio-group v-model="userRadio" v-if="user.userNameNeedTranslate == '1'">
  24. <van-radio v-for="item in userList" :key="item.id" :name="item" class="userCheckbox">
  25. <ww-open-data type='userName' :openid='item.name'></ww-open-data>
  26. </van-radio>
  27. </van-radio-group>
  28. <van-radio-group v-model="userRadio" v-else>
  29. <van-radio v-for="item in userList" :key="item.id" :name="item" class="userCheckbox">{{
  30. item.name }}</van-radio>
  31. </van-radio-group>
  32. <van-button style="width:100%;position: -webkit-sticky;position: sticky;bottom: 0;"
  33. @click="ownerIdChange()">确定</van-button>
  34. </div> -->
  35. <div class="popupDiv paddingTop">
  36. <div class="popupCon conBorder">
  37. <van-radio-group v-model="userRadio" v-if="user.userNameNeedTranslate == '1'">
  38. <van-radio v-for="item in userList" :key="item.id" :name="item" class="popupItem marginNone borderNone">
  39. <!-- <ww-open-data type='userName' :openid='item.name'></ww-open-data> -->
  40. <span class="userNameClass_left">
  41. <ww-open-data type='userName' :openid='item.name'></ww-open-data>
  42. </span>
  43. <span class="userNameClass_right">
  44. {{ item.jobNumber }}
  45. </span>
  46. </van-radio>
  47. </van-radio-group>
  48. <van-radio-group v-model="userRadio" v-else>
  49. <van-radio v-for="item in userList" :key="item.id" :name="item" class="popupItem marginNone borderNone">
  50. <!-- {{ item.name }} -->
  51. <span class="userNameClass_left">{{item.name}}</span>
  52. <span class="userNameClass_right">{{ item.jobNumber }}</span>
  53. </van-radio>
  54. </van-radio-group>
  55. </div>
  56. <div class="popupBtn">
  57. <van-button style="width:100%;background: #1989fa;color: #ffffff;" round
  58. @click="ownerIdChange()">确定</van-button>
  59. </div>
  60. </div>
  61. </van-popup>
  62. <!-- 填报日期 -->
  63. <van-field v-model="editForm.createDate" label="填报日期" @click="createDateShow = true" readonly clickable
  64. required></van-field>
  65. <van-popup v-model="createDateShow" position="bottom">
  66. <van-datetime-picker type="date" title="选择填报日期" @confirm="createDateChange" v-model="currentDate1"
  67. @cancel="createDateShow = false; $forceUpdate();" :min-date="minDate" :max-date="maxDate" />
  68. </van-popup>
  69. <!-- 发票张数 -->
  70. <van-field label="发票张数" v-if="user.timeType.easyExpense==0">
  71. <template #input>
  72. <van-stepper v-model="editForm.ticketNum" disable-input @plus="ticNumChange(1)"
  73. @minus="ticNumChange(0)" />
  74. </template>
  75. </van-field>
  76. <!-- 费用类型 -->
  77. <van-field v-model="editForm.type" label="费用主类型" @click="typeShow = true" readonly clickable>
  78. <template #input>{{ expenseMainType.text }}</template>
  79. </van-field>
  80. <van-popup v-model="typeShow" position="bottom">
  81. <van-picker show-toolbar :columns="typeList" @confirm="typeChange"
  82. @cancel="typeShow = false; $forceUpdate();" />
  83. </van-popup>
  84. <!-- 备注 -->
  85. <van-field v-model="editForm.remark" label="备注" type="textarea" maxlength="100"></van-field>
  86. <!-- 发票 -->
  87. <van-field label="发票" readonly>
  88. <template #input>总费用: ¥{{ totalCost }}</template>
  89. </van-field>
  90. <div class="invoice" v-if="invoiceList.length != 0">
  91. <div v-for="item, index in invoiceList" :key="item.id" style="position:relative"
  92. :class="index == 0 ? '' : 'invoice_item'">
  93. <!-- <van-button class="deletebtn" size="mini" type="default" @click="deleteInvoice(index)">删除</van-button> -->
  94. <van-icon name="delete-o" class="deletebtn" v-if="index != 0" @click="deleteInvoice(index)" />
  95. <van-field label="所属项目:" v-model="item.projectId"
  96. @click="in_projectShow = true, invoiceIndex = index" readonly clickable required>
  97. <template #input>{{ formshowText.inProjectName[index] }}</template>
  98. </van-field>
  99. <van-field label="费用日期:" v-model="item.happenDate"
  100. @click="in_dateShow = true, invoiceIndex = index" readonly clickable required></van-field>
  101. <van-field label="发票种类:" v-model="item.invoiceType" v-if="user.timeType.easyExpense==0"
  102. @click="in_typeShow = true, invoiceIndex = index" readonly clickable required>
  103. <template #input>{{ inTypeList[item.invoiceType] }}</template>
  104. </van-field>
  105. <van-field label="费用类型:" v-model="item.expenseType"
  106. @click="in_exTypeShow = true, invoiceIndex = index" readonly clickable required></van-field>
  107. <van-field :label="`${user.timeType.easyExpense==0?'费用金额(含税)':'费用金额'}:`" v-model="item.amount" type="number" required></van-field>
  108. <van-field label="发票号:" v-model="item.invoiceNo" v-if="user.timeType.easyExpense==0"></van-field>
  109. <van-field label="税率%:" v-model="item.taxPercent" v-if="user.timeType.easyExpense==0"></van-field>
  110. <van-field label="税额:" readonly v-if="user.timeType.easyExpense==0">
  111. <template #input>¥{{ getTaxValue(item.amount, item.taxPercent) }}</template>
  112. </van-field>
  113. <van-field label="备注:" v-model="item.remark" autosize maxlength="100"></van-field>
  114. <van-field label="报销凭证:" @click="invoiceIndex = index" clickable>
  115. <template #input>
  116. <van-uploader v-model="uploader[index]" :before-read="beforeRead"
  117. :after-read="afterRead" @delete="item.pic = null" :max-count="1" />
  118. </template>
  119. </van-field>
  120. </div>
  121. </div>
  122. <div class="addinvoice"><van-button size="small" icon="plus" type="info" plain hairline
  123. @click="addInvoice">添加发票</van-button></div>
  124. <!-- 发票-popup -->
  125. <span>
  126. <!-- 所属项目 -->
  127. <van-popup v-model="in_projectShow" position="bottom">
  128. <van-picker value-key="projectName" show-toolbar :columns="inProjectList"
  129. @confirm="inProjectChange" @cancel="in_projectShow = false; $forceUpdate();" />
  130. </van-popup>
  131. <!-- 费用日期 -->
  132. <van-popup v-model="in_dateShow" position="bottom">
  133. <van-datetime-picker type="date" title="选择费用日期" @confirm="inDateChange" v-model="currentDate2"
  134. @cancel="in_dateShow = false; $forceUpdate();" :min-date="minDate" :max-date="maxDate" />
  135. </van-popup>
  136. <!-- 发票种类 -->
  137. <van-popup v-model="in_typeShow" position="bottom">
  138. <van-picker show-toolbar :columns="inTypeList" @confirm="inTypeChange"
  139. @cancel="in_typeShow = false; $forceUpdate();" />
  140. </van-popup>
  141. <!-- 费用类型 -->
  142. <van-popup v-model="in_exTypeShow" position="bottom">
  143. <van-picker value-key="typeName" show-toolbar :columns="inexTypeList" @confirm="inexTypeChange"
  144. @cancel="in_exTypeShow = false; $forceUpdate();" />
  145. </van-popup>
  146. </span>
  147. </van-form>
  148. <!-- 提交 -->
  149. <div class="form_btn" style="position:fixed; bottom:0px;width:100%;">
  150. <div style="padding-bottom:10px;">
  151. <van-button square block type="info" @click="submitExpense" :loading="confirmLoading"
  152. style="width:100%;float:left;">提交</van-button>
  153. </div>
  154. </div>
  155. </div>
  156. <!-- #endregion -->
  157. <!-- 单据列表 -->
  158. <div class="list" v-if="active == 1">
  159. <!-- <van-pull-refresh v-model="downLoading" @refresh="onDownRefresh">
  160. <van-list v-model="uploading" :finished="upFinished" :immediate-check="false" :offset="100" finished-text="没有更多了" @load="onLoadList"></van-list>
  161. </van-pull-refresh> -->
  162. <van-collapse v-model="activeName" accordion class="list_collapse">
  163. <van-collapse-item v-for="item in billList" :key="item.id" title="标题1" :name="item.id">
  164. <template #title>
  165. <div class="collapse_label_l">票据编号:{{ item.code }}</div>
  166. <div class="collapse_label_r">报销人:
  167. <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName'
  168. :openid='item.ownerName'></ww-open-data></span>
  169. <span v-else>{{ item.ownerName }}</span>
  170. </div>
  171. <div class="collapse_label_l">金额: ¥{{ item.totalAmount | numtosum }}</div>
  172. <div class="collapse_label_r">状态:<span :class="statusClass[item.status]">{{
  173. statusList[item.status] }}</span></div>
  174. </template>
  175. <div class="wrapper">
  176. <div><span>票据编号:</span><span>{{ item.code }}</span></div>
  177. <div><span>金额:</span><span>¥{{ item.totalAmount | numtosum }}</span></div>
  178. <div><span>报销人:</span>
  179. <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName'
  180. :openid='item.ownerName'></ww-open-data></span>
  181. <span v-else>{{ item.ownerName }}</span>
  182. </div>
  183. <div><span>填报日期:</span><span>{{ item.createDate }}</span></div>
  184. <div v-if="user.timeType.easyExpense==0"><span>发票张数:</span><span>{{ item.ticketNum }}</span></div>
  185. <div><span>费用类型:</span><span>{{ item.expenseMainTypeName }}</span></div>
  186. <!-- <div><span>状态:</span><span>{{item.status}}</span></div> -->
  187. <!-- <div><span>驳回原因:</span><span>{{item.denyReason}}</span></div> -->
  188. <div><span>备注:</span><span>{{ item.remark }}</span></div>
  189. </div>
  190. <div class="operation">
  191. <van-button size="small" type="info"
  192. :to="{ name: 'expenseDetails', params: { id: item.id, canEdit: false } }">查看</van-button>
  193. <van-button style="margin-left:10px" size="small" type="info"
  194. :to="{ name: 'expenseDetails', params: { id: item.id, canEdit: true } }">编辑</van-button>
  195. <van-button style="margin-left:10px" size="small" type="danger"
  196. @click="deleteBill(item.id)">删除</van-button>
  197. </div>
  198. </van-collapse-item>
  199. </van-collapse>
  200. </div>
  201. <!-- 单据审核 -->
  202. <div class="audit" v-if="active == 2">
  203. <van-collapse v-model="auditName" accordion class="list_collapse">
  204. <van-collapse-item v-for="item in examineList" :key="item.id" title="标题2" :name="item.id">
  205. <template #title>
  206. <div class="collapse_label_l">票据编号:{{ item.code }}</div>
  207. <div class="collapse_label_r">报销人:
  208. <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName'
  209. :openid='item.ownerName'></ww-open-data></span>
  210. <span v-else>{{ item.ownerName }}</span>
  211. </div>
  212. <div class="collapse_label_l">金额: ¥{{ item.totalAmount | numtosum }}</div>
  213. <div class="collapse_label_r">状态:<span :class="statusClass[item.status]">{{
  214. statusList[item.status] }}</span></div>
  215. <div class="operation" v-if="auditTypeItem.auditType == 0">
  216. <van-button size="small" type="info" :loading="item.approveLoading"
  217. @click.stop="approve(item)">通过</van-button>
  218. <van-button style="margin-left:15px" size="small" type="danger"
  219. @click.stop="denyToReason(item.id)">驳回</van-button>
  220. </div>
  221. <div class="operation" v-if="auditTypeItem.auditType == 1">
  222. <van-button size="small" type="info"
  223. :to="{ name: 'expenseDetails', params: { id: item.id, canEdit: false, isAudit:true } }">审核</van-button>
  224. </div>
  225. </template>
  226. <div class="wrapper">
  227. <div><span>票据编号:</span><span>{{ item.code }}</span></div>
  228. <div><span>金额:</span><span>¥{{ item.totalAmount | numtosum }}</span></div>
  229. <div><span>报销人:</span>
  230. <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName'
  231. :openid='item.ownerName'></ww-open-data></span>
  232. <span v-else>{{ item.ownerName }}</span>
  233. </div>
  234. <div><span>填报日期:</span><span>{{ item.createDate }}</span></div>
  235. <div v-if="user.timeType.easyExpense==0"><span>发票张数:</span><span>{{ item.ticketNum }}</span></div>
  236. <div><span>费用类型:</span><span>{{ item.expenseMainTypeName }}</span></div>
  237. <!-- <div><span>状态:</span><span>{{item.status}}</span></div> -->
  238. <!-- <div><span>驳回原因:</span><span>{{item.denyReason}}</span></div> -->
  239. <div><span>备注:</span><span>{{ item.remark }}</span></div>
  240. </div>
  241. <div class="lookup">
  242. <van-button size="small" type="info"
  243. :to="{ name: 'expenseDetails', params: { id: item.id, canEdit: false } }">查看单据信息</van-button>
  244. </div>
  245. </van-collapse-item>
  246. </van-collapse>
  247. <!-- <van-popup v-model="denyReasonDialog" position="bottom" closeable >
  248. <van-cell>请输入原因</van-cell>
  249. <van-field class="form_input"
  250. v-model="denyParm.denyReason" name="reason" type="textarea" placeholder="请输入您决定驳回的原因"
  251. rows="3" autosize />
  252. <van-button style="width:100%;" type="info" :loading="denyLoading" @click="deny()">提交</van-button>
  253. </van-popup> -->
  254. </div>
  255. </div>
  256. </div>
  257. </template>
  258. <script>
  259. export default {
  260. data() {
  261. return {
  262. auditTypeItem: {auditType: 0},
  263. active: sessionStorage.page ? JSON.parse(sessionStorage.page) : 0,
  264. user: JSON.parse(localStorage.userInfo),
  265. userList: [],
  266. canExamine: false,
  267. currentDate1: new Date(),
  268. currentDate2: new Date(),
  269. minDate: new Date(2020, 0, 1),
  270. maxDate: new Date(2025, 11, 31),
  271. confirmLoading: false,
  272. denyLoading: false,
  273. formshowText: {
  274. name: '',
  275. inProjectName: []
  276. },
  277. // #region 费用报销
  278. editForm: {
  279. ownerId: '',
  280. createDate: this.formatDate(new Date()),
  281. ticketNum: 0,
  282. type: 0,
  283. remark: ''
  284. },
  285. userRadio: null,
  286. ownerIdShow: false,
  287. createDateShow: false,
  288. typeShow: false,
  289. typeList: [],
  290. invoiceIndex: 0,
  291. invoiceList: [
  292. {
  293. projectId: '',
  294. happenDate: '',
  295. invoiceType: '',
  296. expenseType: '',
  297. amount: '',
  298. invoiceNo: '',
  299. taxPercent: '',
  300. taxValue: '',
  301. remark: '',
  302. pic: '',
  303. }
  304. ],
  305. in_projectShow: false,
  306. in_dateShow: false,
  307. in_typeShow: false,
  308. in_exTypeShow: false,
  309. inProjectList: [],
  310. inTypeList: ['增值税专用发票', '增值税普通发票'],
  311. allexTypeList: [],
  312. inexTypeList: [],
  313. uploader: [[]],
  314. // #endregion
  315. // 单据列表
  316. activeName: '',
  317. billList: [],
  318. statusList: ['审核通过', '待审核', '已驳回', '已撤销'],
  319. statusClass: ['', 'waiting', 'rejected', ''],
  320. uploading: false,
  321. // 单据审核
  322. auditName: '',
  323. examineList: [],
  324. denyReasonDialog: false,
  325. denyParm: {
  326. id: '',
  327. denyReason: ''
  328. },
  329. expenseMainType: {
  330. text: ''
  331. }
  332. }
  333. },
  334. computed: {
  335. totalCost() {
  336. let costnum = 0
  337. for (let i in this.invoiceList) {
  338. costnum += (this.invoiceList[i].amount ? parseFloat(this.invoiceList[i].amount) : 0)
  339. }
  340. return costnum.toFixed(2)
  341. }
  342. },
  343. filters: {
  344. numtosum(value) {
  345. if (value == undefined || !value) return '0.00'
  346. value = value.toFixed(2)
  347. const intPart = Math.trunc(value)
  348. const intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
  349. let floatPart = '.00'
  350. const valueArray = value.toString().split('.')
  351. if (valueArray.length === 2) { // 有小数部分
  352. floatPart = valueArray[1].toString() // 取得小数部分
  353. return intPartFormat + '.' + floatPart
  354. }
  355. return intPartFormat + floatPart
  356. },
  357. },
  358. mounted() {
  359. this.formshowText.name = this.user.name;
  360. this.editForm.ownerId = this.user.id;
  361. this.userRadio = {
  362. name: this.user.name,
  363. id: this.user.id
  364. }
  365. this.activeChange()
  366. for (let i in this.user.functionList) {
  367. if (this.user.functionList[i].name == '费用审核') {
  368. this.canExamine = true
  369. }
  370. }
  371. if (!this.canExamine) {
  372. this.editForm.ownerId = this.user.id
  373. this.formshowText.name = this.user.name
  374. } else {
  375. this.getUserList()
  376. }
  377. this.getProjectList()
  378. this.getExpensMainTypes()
  379. this.getExTypeList()
  380. this.getAuditType();
  381. },
  382. methods: {
  383. back() {
  384. sessionStorage.removeItem("page");
  385. history.back();
  386. },
  387. formatDate(date) {
  388. let mon = date.getMonth() + 1
  389. return `${date.getFullYear()}-${mon < 10 ? '0' + mon : mon}-${date.getDate() < 10 ? '0' + date.getDate() : date.getDate()}`;
  390. },
  391. getTaxValue(amount, percent) {
  392. let per = percent / 100
  393. let amo = amount / (1 + per) * per
  394. return amo.toFixed(2)
  395. },
  396. activeChange() {
  397. sessionStorage.setItem('page', JSON.stringify(this.active))
  398. if (this.active == 1) {
  399. this.getBillList()
  400. }
  401. if (this.active == 2) {
  402. this.getExamineList()
  403. }
  404. },
  405. // #region 费用报销
  406. ownerIdChange() {
  407. this.editForm.ownerId = this.userRadio.id
  408. this.formshowText.name = this.userRadio.name
  409. this.ownerIdShow = false
  410. },
  411. createDateChange(value, key) {
  412. this.editForm.createDate = this.formatDate(value)
  413. this.createDateShow = false
  414. },
  415. typeChange(value, key) {
  416. this.editForm.type = value.id
  417. this.expenseMainType.text = value.name
  418. this.typeShow = false
  419. for (let i in this.invoiceList) {
  420. this.invoiceList[i].expenseType = ''
  421. }
  422. this.inexTypeList = this.allexTypeList.filter(a => a.mainType == this.editForm.type)
  423. },
  424. ticNumChange(value) {
  425. if (value) {
  426. this.invoiceList.push({
  427. projectId: '',
  428. happenDate: '',
  429. invoiceType: '',
  430. expenseType: '',
  431. amount: '',
  432. invoiceNo: '',
  433. taxPercent: '',
  434. taxValue: '',
  435. remark: '',
  436. pic: '',
  437. })
  438. } else {
  439. this.invoiceList.pop()
  440. }
  441. },
  442. // 发票
  443. inProjectChange(value, key) {
  444. this.formshowText.inProjectName[this.invoiceIndex] = value.projectName
  445. this.invoiceList[this.invoiceIndex].projectId = value.id
  446. this.in_projectShow = false
  447. },
  448. inDateChange(value, key) {
  449. this.invoiceList[this.invoiceIndex].happenDate = this.formatDate(value)
  450. this.in_dateShow = false
  451. },
  452. inTypeChange(value, key) {
  453. this.invoiceList[this.invoiceIndex].invoiceType = key
  454. this.in_typeShow = false
  455. },
  456. inexTypeChange(value, key) {
  457. this.invoiceList[this.invoiceIndex].expenseType = value.typeName
  458. this.in_exTypeShow = false
  459. },
  460. addInvoice() {
  461. this.invoiceList.push({
  462. projectId: '',
  463. happenDate: '',
  464. invoiceType: '',
  465. expenseType: '',
  466. amount: '',
  467. invoiceNo: '',
  468. taxPercent: '',
  469. taxValue: '',
  470. remark: '',
  471. pic: '',
  472. })
  473. this.uploader.push([])
  474. this.editForm.ticketNum = this.invoiceList.length
  475. },
  476. deleteInvoice(index) {
  477. this.invoiceList.splice(index, 1)
  478. this.uploader.splice(index, 1)
  479. this.editForm.ticketNum = this.invoiceList.length
  480. },
  481. // 上传报销凭证
  482. beforeRead(file) {
  483. if (file.type != 'image/jpeg' && file.type != 'image/png') {
  484. this.$toast.fail('请选择jpg或png格式的图片')
  485. return false
  486. }
  487. return true
  488. },
  489. afterRead(file) {
  490. let formData = new FormData();
  491. formData.append("multipartFile", file.file);
  492. this.$axios.post("/common/uploadFile", formData)
  493. .then(res => {
  494. if (res.code == "ok") {
  495. this.invoiceList[this.invoiceIndex].pic = res.data
  496. } else {
  497. this.$toast.fail('上传失败');
  498. this.uploader[this.invoiceIndex] = []
  499. }
  500. }).catch(err => { this.$toast.clear(); console.log(err); this.uploader[this.invoiceIndex] = [] });
  501. },
  502. // 提交
  503. submitExpense() {
  504. if (!this.editForm.ownerId) {
  505. this.$toast.fail('请选择报销人')
  506. return
  507. }
  508. if (!this.editForm.createDate) {
  509. this.$toast.fail('请选择填报日期')
  510. return
  511. }
  512. let required1 = false
  513. let required2 = false
  514. let required3 = false
  515. let required4 = false
  516. let required5 = false
  517. for (let i in this.invoiceList) {
  518. if (!this.invoiceList[i].projectId) {
  519. required1 = '所属项目'
  520. }
  521. if (!this.invoiceList[i].happenDate) {
  522. required2 = '费用日期'
  523. }
  524. // if (!this.invoiceList[i].invoiceType) {
  525. // required3 = '发票种类'
  526. // }
  527. if (!this.invoiceList[i].expenseType) {
  528. required4 = '费用类型'
  529. }
  530. if (!this.invoiceList[i].amount) {
  531. required5 = this.user.timeType.easyExpense==0?'费用金额(含税)':'费用金额'
  532. }
  533. }
  534. if (required1 || required2 || required3 || required4 || required5) {
  535. let requiredStr = (required1 ? required1 + '、' : '')
  536. + (required2 ? required2 + '、' : '')
  537. + (required3 ? required3 + '、' : '')
  538. + (required4 ? required4 + '、' : '')
  539. + (required5 ? required5 + '、' : '')
  540. requiredStr = requiredStr.substring(0, requiredStr.length - 1)
  541. this.$toast.fail('请添加发票的[' + requiredStr + ']')
  542. return
  543. }
  544. if (this.invoiceList.length == 0) {
  545. this.$toast.fail('请添加发票')
  546. return
  547. }
  548. for (let i in this.invoiceList) {
  549. this.invoiceList[i].taxValue = this.getTaxValue(this.invoiceList[i].amount, this.invoiceList[i].taxPercent)
  550. }
  551. this.editForm.items = JSON.stringify(this.invoiceList)
  552. this.editForm.totalAmount = this.totalCost
  553. // 获取新的票据编号
  554. this.confirmLoading = true
  555. this.$axios.post("/expense-sheet/getNextCode", {})
  556. .then(res => {
  557. if (res.code == "ok") {
  558. this.editForm.code = res.data
  559. // 提交
  560. this.$axios.post("/expense-sheet/add", this.editForm)
  561. .then(res => {
  562. this.confirmLoading = false;
  563. if (res.code == "ok") {
  564. this.$toast.success('填报成功')
  565. this.editForm = {
  566. ownerId: '',
  567. createDate: this.formatDate(new Date()),
  568. ticketNum: 0,
  569. type: 0,
  570. remark: ''
  571. }
  572. // this.formshowText = {
  573. // name: '',
  574. // inProjectName: []
  575. // }
  576. this.formshowText.name = ''
  577. this.formshowText.inProjectName = []
  578. this.expenseMainType.text=''
  579. this.invoiceList = []
  580. this.uploader = []
  581. this.formshowText.name = this.user.name;
  582. this.editForm.ownerId = this.user.id;
  583. this.userRadio = {
  584. name: this.user.name,
  585. id: this.user.id
  586. }
  587. } else {
  588. this.$toast.fail('获取失败');
  589. }
  590. }).catch(err => { this.confirmLoading = false; this.$toast.clear(); console.log(err) });
  591. } else {
  592. this.confirmLoading = false
  593. this.$toast.fail('获取失败');
  594. }
  595. }).catch(err => {
  596. this.confirmLoading = false;
  597. this.$toast.clear();
  598. console.log(err)
  599. });
  600. },
  601. // #endregion
  602. // 单据列表
  603. deleteBill(pid) {
  604. this.$dialog.confirm({
  605. message: '确认删除?',
  606. })
  607. .then(() => {
  608. // on confirm
  609. this.$axios.post("/expense-sheet/delete", { id: pid })
  610. .then(res => {
  611. if (res.code == "ok") {
  612. this.$toast.success('删除成功')
  613. this.getBillList()
  614. } else {
  615. this.$toast.fail('获取失败');
  616. }
  617. }).catch(err => { this.$toast.clear(); console.log(err) });
  618. })
  619. .catch(() => {
  620. // on cancel
  621. });
  622. },
  623. getAuditType() {
  624. this.$axios.post("/expense-audit-setting/get", {})
  625. .then(res => {
  626. if (res.code == "ok") {
  627. this.auditTypeItem = res.data;
  628. } else {
  629. this.$message({
  630. message: res.msg,
  631. type: "error"
  632. });
  633. }
  634. }).catch(err => { this.$toast.clear(); console.log(err) });
  635. },
  636. // 单据审核
  637. approve(item) {
  638. item.approveLoading = true
  639. this.$axios.post("/expense-sheet/approve", { id: item.id })
  640. .then(res => {
  641. if (res.code == "ok") {
  642. this.$toast.success('已通过')
  643. item.approveLoading = false
  644. this.getExamineList()
  645. } else {
  646. this.$toast.fail('获取失败');
  647. }
  648. }).catch(err => { this.$toast.clear(); console.log(err) });
  649. },
  650. denyToReason(pid) {
  651. this.denyParm.id = pid
  652. this.denyReasonDialog = true
  653. this.denyParm.denyReason = ''
  654. this.deny()
  655. },
  656. deny() {
  657. this.denyLoading = true
  658. this.$axios.post("/expense-sheet/deny", this.denyParm)
  659. .then(res => {
  660. if (res.code == "ok") {
  661. this.$toast.success('已驳回')
  662. this.denyReasonDialog = false
  663. this.denyLoading = false
  664. this.getExamineList()
  665. } else {
  666. this.$toast.fail('获取失败');
  667. }
  668. }).catch(err => { this.$toast.clear(); console.log(err) });
  669. },
  670. getUserList() {
  671. this.$axios.post("/user/getSimpleActiveUserList", {})
  672. .then(res => {
  673. if (res.code == "ok") {
  674. this.userList = res.data
  675. } else {
  676. this.$toast.fail('获取失败');
  677. }
  678. }).catch(err => { this.$toast.clear(); console.log(err) });
  679. },
  680. getProjectList() {
  681. this.$axios.post("/project/getProjectList", {})
  682. .then(res => {
  683. if (res.code == "ok") {
  684. this.inProjectList = res.data
  685. } else {
  686. this.$toast.fail('获取失败');
  687. }
  688. }).catch(err => { this.$toast.clear(); console.log(err) });
  689. },
  690. getExTypeList() {
  691. this.$axios.post("/expense-type/getList", {})
  692. .then(res => {
  693. if (res.code == "ok") {
  694. this.allexTypeList = res.data
  695. this.inexTypeList = this.allexTypeList.filter(a => a.mainType == this.editForm.type)
  696. } else {
  697. this.$toast.fail('获取失败');
  698. }
  699. }).catch(err => { this.$toast.clear(); console.log(err) });
  700. },
  701. getExpensMainTypes() {
  702. this.$axios.post("/expense-main-type/list", {})
  703. .then(res => {
  704. if (res.code == "ok") {
  705. for (var i in res.data) {
  706. res.data[i].text = res.data[i].name
  707. }
  708. this.typeList = res.data
  709. this.expenseMainType.text = res.data[0].name
  710. this.editForm.type = res.data[0].id
  711. this.getExTypeList
  712. } else {
  713. this.$toast.fail('获取失败');
  714. }
  715. }).catch(err => { this.$toast.clear(); console.log(err) });
  716. },
  717. getBillList() {
  718. this.$axios.post("/expense-sheet/list", {
  719. pageSize: 999,
  720. pageIndex: 1,
  721. startDate: '',
  722. endDate: '',
  723. ownerId: '',
  724. type: ''
  725. }).then(res => {
  726. if (res.code == "ok") {
  727. this.billList = res.data.records
  728. } else {
  729. this.$toast.fail('获取失败');
  730. }
  731. }).catch(err => { this.$toast.clear(); console.log(err) });
  732. },
  733. getExamineList() {
  734. this.$axios.post("/expense-sheet/list", {
  735. pageSize: 999,
  736. pageIndex: 1,
  737. startDate: '',
  738. endDate: '',
  739. ownerId: '',
  740. type: '',
  741. status: 1
  742. }).then(res => {
  743. if (res.code == "ok") {
  744. this.examineList = res.data.records
  745. for (let i in this.examineList) {
  746. this.$set(this.examineList[i], 'approveLoading', false)
  747. }
  748. } else {
  749. this.$toast.fail('获取失败');
  750. }
  751. }).catch(err => { this.$toast.clear(); console.log(err) });
  752. }
  753. },
  754. }
  755. </script>
  756. <style lang="less" scoped>
  757. .content {
  758. margin-top: 46px;
  759. overflow: auto;
  760. .edit {
  761. .userCheckbox {
  762. padding: 10px;
  763. }
  764. padding-bottom: 46px;
  765. .form_btn {
  766. z-index: 1000;
  767. }
  768. .edit_form {
  769. .invoice {
  770. border: 0.5px solid rgb(135, 195, 255);
  771. margin: 0.2rem;
  772. .deletebtn {
  773. position: absolute;
  774. z-index: 900;
  775. font-size: 24px;
  776. right: 0.08rem;
  777. top: 0.08rem;
  778. color: #c03131;
  779. }
  780. .invoice_item {
  781. border-top: 0.5px solid rgb(135, 195, 255);
  782. }
  783. }
  784. .addinvoice {
  785. padding: 0 0.3rem 0.3rem;
  786. margin-top: 0.2rem;
  787. text-align: right;
  788. }
  789. }
  790. }
  791. .list {
  792. .list_collapse>div {
  793. margin: 4px;
  794. }
  795. .list_collapse {
  796. .collapse_label_l {
  797. width: 50%;
  798. padding: 4px;
  799. display: inline-block;
  800. }
  801. .collapse_label_r {
  802. width: 50%;
  803. padding: 4px;
  804. display: inline-block;
  805. .waiting {
  806. color: orange;
  807. }
  808. .rejected {
  809. color: red;
  810. }
  811. }
  812. .wrapper {
  813. div {
  814. margin: 8px 16px;
  815. }
  816. div span:nth-child(1) {
  817. width: 30%;
  818. display: inline-block;
  819. }
  820. div span:nth-child(2) {
  821. width: 70%;
  822. display: inline-block;
  823. }
  824. }
  825. .operation {
  826. display: flex;
  827. align-items: center;
  828. justify-content: flex-end;
  829. }
  830. }
  831. }
  832. .audit {
  833. .list_collapse>div {
  834. margin: 4px;
  835. }
  836. .list_collapse {
  837. .collapse_label_l {
  838. width: 60%;
  839. padding: 4px;
  840. display: inline-block;
  841. }
  842. .collapse_label_r {
  843. width: 40%;
  844. padding: 4px;
  845. display: inline-block;
  846. .waiting {
  847. color: orange;
  848. }
  849. .rejected {
  850. color: red;
  851. }
  852. }
  853. .operation {
  854. margin-top: 5px;
  855. padding-top: 5px;
  856. border-top: 0.5px solid #ebedf0;
  857. display: flex;
  858. align-items: center;
  859. justify-content: flex-end;
  860. button {
  861. width: 1.2rem;
  862. }
  863. }
  864. .wrapper {
  865. div {
  866. margin: 8px 16px;
  867. }
  868. div span:nth-child(1) {
  869. width: 30%;
  870. display: inline-block;
  871. }
  872. div span:nth-child(2) {
  873. width: 70%;
  874. display: inline-block;
  875. }
  876. }
  877. .lookup {
  878. display: flex;
  879. align-items: center;
  880. justify-content: flex-end;
  881. }
  882. }
  883. }
  884. }
  885. </style>
  886. <style>
  887. .edit_form .invoice .van-field__label {
  888. color: #999;
  889. }
  890. .edit_form .invoice .van-field__control {
  891. color: #999;
  892. }
  893. </style>