index.vue 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932
  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" v-if="canExamine"></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"></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></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">
  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. </template>
  222. <div class="wrapper">
  223. <div><span>票据编号:</span><span>{{ item.code }}</span></div>
  224. <div><span>金额:</span><span>¥{{ item.totalAmount | numtosum }}</span></div>
  225. <div><span>报销人:</span>
  226. <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName'
  227. :openid='item.ownerName'></ww-open-data></span>
  228. <span v-else>{{ item.ownerName }}</span>
  229. </div>
  230. <div><span>填报日期:</span><span>{{ item.createDate }}</span></div>
  231. <div v-if="user.timeType.easyExpense==0"><span>发票张数:</span><span>{{ item.ticketNum }}</span></div>
  232. <div><span>费用类型:</span><span>{{ item.expenseMainTypeName }}</span></div>
  233. <!-- <div><span>状态:</span><span>{{item.status}}</span></div> -->
  234. <!-- <div><span>驳回原因:</span><span>{{item.denyReason}}</span></div> -->
  235. <div><span>备注:</span><span>{{ item.remark }}</span></div>
  236. </div>
  237. <div class="lookup">
  238. <van-button size="small" type="info"
  239. :to="{ name: 'expenseDetails', params: { id: item.id, canEdit: false } }">查看单据信息</van-button>
  240. </div>
  241. </van-collapse-item>
  242. </van-collapse>
  243. <!-- <van-popup v-model="denyReasonDialog" position="bottom" closeable >
  244. <van-cell>请输入原因</van-cell>
  245. <van-field class="form_input"
  246. v-model="denyParm.denyReason" name="reason" type="textarea" placeholder="请输入您决定驳回的原因"
  247. rows="3" autosize />
  248. <van-button style="width:100%;" type="info" :loading="denyLoading" @click="deny()">提交</van-button>
  249. </van-popup> -->
  250. </div>
  251. </div>
  252. </div>
  253. </template>
  254. <script>
  255. export default {
  256. data() {
  257. return {
  258. active: sessionStorage.page ? JSON.parse(sessionStorage.page) : 0,
  259. user: JSON.parse(localStorage.userInfo),
  260. userList: [],
  261. canExamine: false,
  262. currentDate1: new Date(),
  263. currentDate2: new Date(),
  264. minDate: new Date(2020, 0, 1),
  265. maxDate: new Date(2025, 11, 31),
  266. confirmLoading: false,
  267. denyLoading: false,
  268. formshowText: {
  269. name: '',
  270. inProjectName: []
  271. },
  272. // #region 费用报销
  273. editForm: {
  274. ownerId: '',
  275. createDate: this.formatDate(new Date()),
  276. ticketNum: 0,
  277. type: 0,
  278. remark: ''
  279. },
  280. userRadio: null,
  281. ownerIdShow: false,
  282. createDateShow: false,
  283. typeShow: false,
  284. typeList: [],
  285. invoiceIndex: 0,
  286. invoiceList: [
  287. {
  288. projectId: '',
  289. happenDate: '',
  290. invoiceType: '',
  291. expenseType: '',
  292. amount: '',
  293. invoiceNo: '',
  294. taxPercent: '',
  295. taxValue: '',
  296. remark: '',
  297. pic: '',
  298. }
  299. ],
  300. in_projectShow: false,
  301. in_dateShow: false,
  302. in_typeShow: false,
  303. in_exTypeShow: false,
  304. inProjectList: [],
  305. inTypeList: ['增值税专用发票', '增值税普通发票'],
  306. allexTypeList: [],
  307. inexTypeList: [],
  308. uploader: [[]],
  309. // #endregion
  310. // 单据列表
  311. activeName: '',
  312. billList: [],
  313. statusList: ['审核通过', '待审核', '已驳回', '已撤销'],
  314. statusClass: ['', 'waiting', 'rejected', ''],
  315. uploading: false,
  316. // 单据审核
  317. auditName: '',
  318. examineList: [],
  319. denyReasonDialog: false,
  320. denyParm: {
  321. id: '',
  322. denyReason: ''
  323. },
  324. expenseMainType: {
  325. text: ''
  326. }
  327. }
  328. },
  329. computed: {
  330. totalCost() {
  331. let costnum = 0
  332. for (let i in this.invoiceList) {
  333. costnum += (this.invoiceList[i].amount ? parseFloat(this.invoiceList[i].amount) : 0)
  334. }
  335. return costnum.toFixed(2)
  336. }
  337. },
  338. filters: {
  339. numtosum(value) {
  340. if (value == undefined || !value) return '0.00'
  341. value = value.toFixed(2)
  342. const intPart = Math.trunc(value)
  343. const intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
  344. let floatPart = '.00'
  345. const valueArray = value.toString().split('.')
  346. if (valueArray.length === 2) { // 有小数部分
  347. floatPart = valueArray[1].toString() // 取得小数部分
  348. return intPartFormat + '.' + floatPart
  349. }
  350. return intPartFormat + floatPart
  351. },
  352. },
  353. mounted() {
  354. this.formshowText.name = this.user.name;
  355. this.editForm.ownerId = this.user.id;
  356. this.userRadio = {
  357. name: this.user.name,
  358. id: this.user.id
  359. }
  360. this.activeChange()
  361. for (let i in this.user.functionList) {
  362. if (this.user.functionList[i].name == '费用审核') {
  363. this.canExamine = true
  364. }
  365. }
  366. if (!this.canExamine) {
  367. this.editForm.ownerId = this.user.id
  368. this.formshowText.name = this.user.name
  369. } else {
  370. this.getUserList()
  371. }
  372. this.getProjectList()
  373. this.getExpensMainTypes()
  374. this.getExTypeList()
  375. },
  376. methods: {
  377. back() {
  378. sessionStorage.removeItem("page");
  379. history.back();
  380. },
  381. formatDate(date) {
  382. let mon = date.getMonth() + 1
  383. return `${date.getFullYear()}-${mon < 10 ? '0' + mon : mon}-${date.getDate() < 10 ? '0' + date.getDate() : date.getDate()}`;
  384. },
  385. getTaxValue(amount, percent) {
  386. let per = percent / 100
  387. let amo = amount / (1 + per) * per
  388. return amo.toFixed(2)
  389. },
  390. activeChange() {
  391. sessionStorage.setItem('page', JSON.stringify(this.active))
  392. if (this.active == 1) {
  393. this.getBillList()
  394. }
  395. if (this.active == 2) {
  396. this.getExamineList()
  397. }
  398. },
  399. // #region 费用报销
  400. ownerIdChange() {
  401. this.editForm.ownerId = this.userRadio.id
  402. this.formshowText.name = this.userRadio.name
  403. this.ownerIdShow = false
  404. },
  405. createDateChange(value, key) {
  406. this.editForm.createDate = this.formatDate(value)
  407. this.createDateShow = false
  408. },
  409. typeChange(value, key) {
  410. this.editForm.type = value.id
  411. this.expenseMainType.text = value.name
  412. this.typeShow = false
  413. for (let i in this.invoiceList) {
  414. this.invoiceList[i].expenseType = ''
  415. }
  416. this.inexTypeList = this.allexTypeList.filter(a => a.mainType == this.editForm.type)
  417. },
  418. ticNumChange(value) {
  419. if (value) {
  420. this.invoiceList.push({
  421. projectId: '',
  422. happenDate: '',
  423. invoiceType: '',
  424. expenseType: '',
  425. amount: '',
  426. invoiceNo: '',
  427. taxPercent: '',
  428. taxValue: '',
  429. remark: '',
  430. pic: '',
  431. })
  432. } else {
  433. this.invoiceList.pop()
  434. }
  435. },
  436. // 发票
  437. inProjectChange(value, key) {
  438. this.formshowText.inProjectName[this.invoiceIndex] = value.projectName
  439. this.invoiceList[this.invoiceIndex].projectId = value.id
  440. this.in_projectShow = false
  441. },
  442. inDateChange(value, key) {
  443. this.invoiceList[this.invoiceIndex].happenDate = this.formatDate(value)
  444. this.in_dateShow = false
  445. },
  446. inTypeChange(value, key) {
  447. this.invoiceList[this.invoiceIndex].invoiceType = key
  448. this.in_typeShow = false
  449. },
  450. inexTypeChange(value, key) {
  451. this.invoiceList[this.invoiceIndex].expenseType = value.typeName
  452. this.in_exTypeShow = false
  453. },
  454. addInvoice() {
  455. this.invoiceList.push({
  456. projectId: '',
  457. happenDate: '',
  458. invoiceType: '',
  459. expenseType: '',
  460. amount: '',
  461. invoiceNo: '',
  462. taxPercent: '',
  463. taxValue: '',
  464. remark: '',
  465. pic: '',
  466. })
  467. this.uploader.push([])
  468. this.editForm.ticketNum = this.invoiceList.length
  469. },
  470. deleteInvoice(index) {
  471. this.invoiceList.splice(index, 1)
  472. this.uploader.splice(index, 1)
  473. this.editForm.ticketNum = this.invoiceList.length
  474. },
  475. // 上传报销凭证
  476. beforeRead(file) {
  477. if (file.type != 'image/jpeg' && file.type != 'image/png') {
  478. this.$toast.fail('请选择jpg或png格式的图片')
  479. return false
  480. }
  481. return true
  482. },
  483. afterRead(file) {
  484. let formData = new FormData();
  485. formData.append("multipartFile", file.file);
  486. this.$axios.post("/common/uploadFile", formData)
  487. .then(res => {
  488. if (res.code == "ok") {
  489. this.invoiceList[this.invoiceIndex].pic = res.data
  490. } else {
  491. this.$toast.fail('上传失败');
  492. this.uploader[this.invoiceIndex] = []
  493. }
  494. }).catch(err => { this.$toast.clear(); console.log(err); this.uploader[this.invoiceIndex] = [] });
  495. },
  496. // 提交
  497. submitExpense() {
  498. if (!this.editForm.ownerId) {
  499. this.$toast.fail('请选择报销人')
  500. return
  501. }
  502. if (!this.editForm.createDate) {
  503. this.$toast.fail('请选择填报日期')
  504. return
  505. }
  506. let required1 = false
  507. let required2 = false
  508. let required3 = false
  509. let required4 = false
  510. let required5 = false
  511. for (let i in this.invoiceList) {
  512. if (!this.invoiceList[i].projectId) {
  513. required1 = '所属项目'
  514. }
  515. if (!this.invoiceList[i].happenDate) {
  516. required2 = '费用日期'
  517. }
  518. // if (!this.invoiceList[i].invoiceType) {
  519. // required3 = '发票种类'
  520. // }
  521. if (!this.invoiceList[i].expenseType) {
  522. required4 = '费用类型'
  523. }
  524. if (!this.invoiceList[i].amount) {
  525. required5 = this.user.timeType.easyExpense==0?'费用金额(含税)':'费用金额'
  526. }
  527. }
  528. if (required1 || required2 || required3 || required4 || required5) {
  529. let requiredStr = (required1 ? required1 + '、' : '')
  530. + (required2 ? required2 + '、' : '')
  531. + (required3 ? required3 + '、' : '')
  532. + (required4 ? required4 + '、' : '')
  533. + (required5 ? required5 + '、' : '')
  534. requiredStr = requiredStr.substring(0, requiredStr.length - 1)
  535. this.$toast.fail('请添加发票的[' + requiredStr + ']')
  536. return
  537. }
  538. if (this.invoiceList.length == 0) {
  539. this.$toast.fail('请添加发票')
  540. return
  541. }
  542. for (let i in this.invoiceList) {
  543. this.invoiceList[i].taxValue = this.getTaxValue(this.invoiceList[i].amount, this.invoiceList[i].taxPercent)
  544. }
  545. this.editForm.items = JSON.stringify(this.invoiceList)
  546. this.editForm.totalAmount = this.totalCost
  547. // 获取新的票据编号
  548. this.confirmLoading = true
  549. this.$axios.post("/expense-sheet/getNextCode", {})
  550. .then(res => {
  551. if (res.code == "ok") {
  552. this.editForm.code = res.data
  553. // 提交
  554. this.$axios.post("/expense-sheet/add", this.editForm)
  555. .then(res => {
  556. this.confirmLoading = false;
  557. if (res.code == "ok") {
  558. this.$toast.success('填报成功')
  559. this.editForm = {
  560. ownerId: '',
  561. createDate: this.formatDate(new Date()),
  562. ticketNum: 0,
  563. type: 0,
  564. remark: ''
  565. }
  566. // this.formshowText = {
  567. // name: '',
  568. // inProjectName: []
  569. // }
  570. this.formshowText.name = ''
  571. this.formshowText.inProjectName = []
  572. this.expenseMainType.text=''
  573. this.invoiceList = []
  574. this.uploader = []
  575. this.formshowText.name = this.user.name;
  576. this.editForm.ownerId = this.user.id;
  577. this.userRadio = {
  578. name: this.user.name,
  579. id: this.user.id
  580. }
  581. } else {
  582. this.$toast.fail('获取失败');
  583. }
  584. }).catch(err => { this.confirmLoading = false; this.$toast.clear(); console.log(err) });
  585. } else {
  586. this.confirmLoading = false
  587. this.$toast.fail('获取失败');
  588. }
  589. }).catch(err => {
  590. this.confirmLoading = false;
  591. this.$toast.clear();
  592. console.log(err)
  593. });
  594. },
  595. // #endregion
  596. // 单据列表
  597. deleteBill(pid) {
  598. this.$dialog.confirm({
  599. message: '确认删除?',
  600. })
  601. .then(() => {
  602. // on confirm
  603. this.$axios.post("/expense-sheet/delete", { id: pid })
  604. .then(res => {
  605. if (res.code == "ok") {
  606. this.$toast.success('删除成功')
  607. this.getBillList()
  608. } else {
  609. this.$toast.fail('获取失败');
  610. }
  611. }).catch(err => { this.$toast.clear(); console.log(err) });
  612. })
  613. .catch(() => {
  614. // on cancel
  615. });
  616. },
  617. // 单据审核
  618. approve(item) {
  619. item.approveLoading = true
  620. this.$axios.post("/expense-sheet/approve", { id: item.id })
  621. .then(res => {
  622. if (res.code == "ok") {
  623. this.$toast.success('已通过')
  624. item.approveLoading = false
  625. this.getExamineList()
  626. } else {
  627. this.$toast.fail('获取失败');
  628. }
  629. }).catch(err => { this.$toast.clear(); console.log(err) });
  630. },
  631. denyToReason(pid) {
  632. this.denyParm.id = pid
  633. this.denyReasonDialog = true
  634. this.denyParm.denyReason = ''
  635. this.deny()
  636. },
  637. deny() {
  638. this.denyLoading = true
  639. this.$axios.post("/expense-sheet/deny", this.denyParm)
  640. .then(res => {
  641. if (res.code == "ok") {
  642. this.$toast.success('已驳回')
  643. this.denyReasonDialog = false
  644. this.denyLoading = false
  645. this.getExamineList()
  646. } else {
  647. this.$toast.fail('获取失败');
  648. }
  649. }).catch(err => { this.$toast.clear(); console.log(err) });
  650. },
  651. getUserList() {
  652. this.$axios.post("/user/getSimpleActiveUserList", {})
  653. .then(res => {
  654. if (res.code == "ok") {
  655. this.userList = res.data
  656. } else {
  657. this.$toast.fail('获取失败');
  658. }
  659. }).catch(err => { this.$toast.clear(); console.log(err) });
  660. },
  661. getProjectList() {
  662. this.$axios.post("/project/getProjectList", {})
  663. .then(res => {
  664. if (res.code == "ok") {
  665. this.inProjectList = res.data
  666. } else {
  667. this.$toast.fail('获取失败');
  668. }
  669. }).catch(err => { this.$toast.clear(); console.log(err) });
  670. },
  671. getExTypeList() {
  672. this.$axios.post("/expense-type/getList", {})
  673. .then(res => {
  674. if (res.code == "ok") {
  675. this.allexTypeList = res.data
  676. this.inexTypeList = this.allexTypeList.filter(a => a.mainType == this.editForm.type)
  677. } else {
  678. this.$toast.fail('获取失败');
  679. }
  680. }).catch(err => { this.$toast.clear(); console.log(err) });
  681. },
  682. getExpensMainTypes() {
  683. this.$axios.post("/expense-main-type/list", {})
  684. .then(res => {
  685. if (res.code == "ok") {
  686. for (var i in res.data) {
  687. res.data[i].text = res.data[i].name
  688. }
  689. this.typeList = res.data
  690. this.expenseMainType.text = res.data[0].name
  691. this.editForm.type = res.data[0].id
  692. this.getExTypeList
  693. } else {
  694. this.$toast.fail('获取失败');
  695. }
  696. }).catch(err => { this.$toast.clear(); console.log(err) });
  697. },
  698. getBillList() {
  699. this.$axios.post("/expense-sheet/list", {
  700. pageSize: 999,
  701. pageIndex: 1,
  702. startDate: '',
  703. endDate: '',
  704. ownerId: '',
  705. type: ''
  706. }).then(res => {
  707. if (res.code == "ok") {
  708. this.billList = res.data.records
  709. } else {
  710. this.$toast.fail('获取失败');
  711. }
  712. }).catch(err => { this.$toast.clear(); console.log(err) });
  713. },
  714. getExamineList() {
  715. this.$axios.post("/expense-sheet/list", {
  716. pageSize: 999,
  717. pageIndex: 1,
  718. startDate: '',
  719. endDate: '',
  720. ownerId: '',
  721. type: '',
  722. status: 1
  723. }).then(res => {
  724. if (res.code == "ok") {
  725. this.examineList = res.data.records
  726. for (let i in this.examineList) {
  727. this.$set(this.examineList[i], 'approveLoading', false)
  728. }
  729. } else {
  730. this.$toast.fail('获取失败');
  731. }
  732. }).catch(err => { this.$toast.clear(); console.log(err) });
  733. }
  734. },
  735. }
  736. </script>
  737. <style lang="less" scoped>
  738. .content {
  739. margin-top: 46px;
  740. overflow: auto;
  741. .edit {
  742. .userCheckbox {
  743. padding: 10px;
  744. }
  745. padding-bottom: 46px;
  746. .form_btn {
  747. z-index: 1000;
  748. }
  749. .edit_form {
  750. .invoice {
  751. border: 0.5px solid rgb(135, 195, 255);
  752. margin: 0.2rem;
  753. .deletebtn {
  754. position: absolute;
  755. z-index: 900;
  756. font-size: 24px;
  757. right: 0.08rem;
  758. top: 0.08rem;
  759. color: #c03131;
  760. }
  761. .invoice_item {
  762. border-top: 0.5px solid rgb(135, 195, 255);
  763. }
  764. }
  765. .addinvoice {
  766. padding: 0 0.3rem 0.3rem;
  767. margin-top: 0.2rem;
  768. text-align: right;
  769. }
  770. }
  771. }
  772. .list {
  773. .list_collapse>div {
  774. margin: 4px;
  775. }
  776. .list_collapse {
  777. .collapse_label_l {
  778. width: 50%;
  779. padding: 4px;
  780. display: inline-block;
  781. }
  782. .collapse_label_r {
  783. width: 50%;
  784. padding: 4px;
  785. display: inline-block;
  786. .waiting {
  787. color: orange;
  788. }
  789. .rejected {
  790. color: red;
  791. }
  792. }
  793. .wrapper {
  794. div {
  795. margin: 8px 16px;
  796. }
  797. div span:nth-child(1) {
  798. width: 30%;
  799. display: inline-block;
  800. }
  801. div span:nth-child(2) {
  802. width: 70%;
  803. display: inline-block;
  804. }
  805. }
  806. .operation {
  807. display: flex;
  808. align-items: center;
  809. justify-content: flex-end;
  810. }
  811. }
  812. }
  813. .audit {
  814. .list_collapse>div {
  815. margin: 4px;
  816. }
  817. .list_collapse {
  818. .collapse_label_l {
  819. width: 60%;
  820. padding: 4px;
  821. display: inline-block;
  822. }
  823. .collapse_label_r {
  824. width: 40%;
  825. padding: 4px;
  826. display: inline-block;
  827. .waiting {
  828. color: orange;
  829. }
  830. .rejected {
  831. color: red;
  832. }
  833. }
  834. .operation {
  835. margin-top: 5px;
  836. padding-top: 5px;
  837. border-top: 0.5px solid #ebedf0;
  838. display: flex;
  839. align-items: center;
  840. justify-content: flex-end;
  841. button {
  842. width: 1.2rem;
  843. }
  844. }
  845. .wrapper {
  846. div {
  847. margin: 8px 16px;
  848. }
  849. div span:nth-child(1) {
  850. width: 30%;
  851. display: inline-block;
  852. }
  853. div span:nth-child(2) {
  854. width: 70%;
  855. display: inline-block;
  856. }
  857. }
  858. .lookup {
  859. display: flex;
  860. align-items: center;
  861. justify-content: flex-end;
  862. }
  863. }
  864. }
  865. }
  866. </style>
  867. <style>
  868. .edit_form .invoice .van-field__label {
  869. color: #999;
  870. }
  871. .edit_form .invoice .van-field__control {
  872. color: #999;
  873. }
  874. </style>