expense.vue 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606
  1. <template>
  2. <section>
  3. <div class="sidebars" ref="sidebars" style="width: 200px;display: block;background: #fff;">
  4. <div ref="abbisd" style="width: 100%;overflow: hidden;">
  5. <h3><i class="iconfont firerock-iconbaoxiao" style="padding-right: 10px"></i>费用报销模块</h3>
  6. <el-divider ></el-divider>
  7. <el-col :span="12">
  8. <el-menu
  9. default-active="1-1"
  10. class="el-menu-vertical-demo"
  11. @select="staffs"
  12. background-color="#ffffff"
  13. text-color="#666666"
  14. active-text-color="#20A0FF"
  15. style="width:100%">
  16. <el-submenu index="1">
  17. <template slot="title">
  18. <i class="iconfont firerock-icontianbao"></i>
  19. <span>员工费用填报</span>
  20. </template>
  21. <el-menu-item index="1-1"><p @click="ssl(0)"> 一般费用填报</p></el-menu-item>
  22. <el-menu-item index="1-2"><p @click="ssl(1)">差旅费用填报</p></el-menu-item>
  23. <el-menu-item index="1-3"><p @click="ssl(2)">外包费用填报</p></el-menu-item>
  24. </el-submenu>
  25. <el-submenu index="2">
  26. <template slot="title">
  27. <i class="iconfont firerock-iconbaoxiaodan"></i>
  28. <span>{{permissions.costAll?"报销凭证列表":"我的报销凭证"}}</span>
  29. </template>
  30. <el-menu-item index="2-1" ><p @click="bills(false)" >单据列表</p></el-menu-item>
  31. <el-menu-item index="2-2" v-if="permissions.costAudit"><p @click="bills(true)">单据审核</p></el-menu-item>
  32. </el-submenu>
  33. <!-- <el-menu-item index="3" @select="bills" @click="bills(false)" v-if="user.role == 0">
  34. <i class="iconfont firerock-iconbaoxiaodan"></i>
  35. <span slot="title">{{user.role == 0?"我的报销凭证":"报销凭证列表"}}</span>
  36. </el-menu-item> -->
  37. </el-menu>
  38. </el-col>
  39. </div>
  40. <div class="side" @click="side" ref="sid" style="left: 200px">
  41. <div class="spans" ref="side" style="left: -19px;"><i ref="sideI" class="el-icon-arrow-left"></i></div>
  42. </div>
  43. </div>
  44. <!-- 侧边栏点击事件 -->
  45. <!-- <div class="side" @click="side" ref="sid" style="left: 430px">
  46. <div class="spans" ref="side" style="left: -19px;"><i ref="sideI" class="el-icon-arrow-left"></i></div>
  47. </div> -->
  48. <!-- 内容主体区域 -->
  49. <div class="contents">
  50. <div v-if="!displayTable" class="headine" ref="headine">
  51. <h3 ref="headHe" style="padding-left: 220px">{{shuz[ins]}}</h3>
  52. <p style="float: right;margin-right: 25px;"><el-button type="primary" @click="submits" size="mini">提交</el-button></p>
  53. <p style="float: right;margin-right: 25px;"><el-button type="primary" @click="submitUpload" size="mini">批量上传</el-button></p>
  54. <p style="float: right;margin-right: 25px;"><el-button type="primary" @click="customTypeOp" size="mini" v-if="permissions.costAll">费用类型管理</el-button></p>
  55. </div>
  56. <!-- 上面部分 -->
  57. <div ref="staff" style="margin: 20px 20px 0 220px; width: 81.5%" >
  58. <div class="staff" v-if="!displayTable">
  59. <!-- 公共 -->
  60. <div class="public">
  61. <el-form :model="addForm" ref="mainAddForm" label-width="80px" :rules="addFormRules">
  62. <!-- <el-form :model="form" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm"> -->
  63. <!-- 报销人 -->
  64. <el-form-item label="报销人" prop="ownerId">
  65. <!--普通员工只能自己填报自己的 -->
  66. <el-select v-model="addForm.ownerId" placeholder="请选择报销人" style="width: 150px" :disabled="!permissions.costAudit" filterable="true">
  67. <span v-for="(item, index) in users" :key="index">
  68. <el-option :label="item.name" :value="item.id"></el-option>
  69. </span>
  70. </el-select>
  71. </el-form-item>
  72. <!-- 填报日期 -->
  73. <el-form-item label="填报日期" style="position: relative;top: 38px;" prop="createDate">
  74. <el-col :span="11">
  75. <el-date-picker type="date" placeholder="选择日期" v-model="addForm.createDate" value-format="yyyy-MM-dd" style="width: 200px;"></el-date-picker>
  76. </el-col>
  77. </el-form-item>
  78. <!-- 发票张数 -->
  79. <el-form-item label="发票张数">
  80. <el-input v-model="addForm.ticketNum" style="width: 150px"></el-input>
  81. </el-form-item>
  82. <!-- 费用类型 -->
  83. <el-form-item label="费用类型">
  84. <el-select v-model="addForm.type" disabled style="width: 150px" >
  85. <el-option label="一般" :value="0"></el-option>
  86. <el-option label="差旅" :value="1"></el-option>
  87. <el-option label="外包" :value="2"></el-option>
  88. </el-select>
  89. </el-form-item>
  90. <!-- 备注 -->
  91. <el-form-item label="备注" style="display: block; width: 70%; float: left;">
  92. <el-input type="textarea" v-model="addForm.remark" :autosize="{minRows: 2, maxRows: 2}"></el-input>
  93. </el-form-item>
  94. <!-- 总费用 -->
  95. <!-- <div style="float: left; line-height: 55px;margin-left:20px">总费用 <el-link disabled v-model="addForm.totalAmount">{{addForm.totalAmount}}</el-link> 元</div> -->
  96. </el-form>
  97. </div>
  98. <!-- 按钮 -->
  99. <div class="pu_button">
  100. <span v-if="totalCost <= 0" style="color:#606266;">总费用 {{totalCost}} 元</span>
  101. <span v-else style="color:#606266;">总费用 ¥{{totalCost | numberToCurrency}} 元</span>
  102. <span class="pu_bu_x" style="margin-left:10px;" @click="addxz"> <i class="el-icon-circle-plus-outline"></i> 新增发票</span>
  103. </div>
  104. <!-- 表格 -->
  105. <div class="pu_table">
  106. <el-table
  107. :data="invoiceList"
  108. border
  109. style="width: 100%;height:100%"
  110. height="386px"
  111. @row-dblclick="dbclick">
  112. <el-table-column prop="projectName" label="所属项目" width="180">
  113. <template slot-scope="scope">
  114. <el-select size="small" v-model="scope.row.projectId" placeholder="项目" style="width: 150px" filterable>
  115. <el-option v-for="(item, index) in projectList" :key="index" :label="item.projectName + item.projectCode" :value="item.id" @click="ok(item)">
  116. <span style="float: left;color: #8492a6; font-size: 13px">{{ item.projectCode }}</span>
  117. <span style="float: right;margin-left: 20px">{{ item.projectName }}</span>
  118. </el-option>
  119. </el-select>
  120. </template>
  121. </el-table-column>
  122. <el-table-column prop="happenDate" label="费用日期" width="170px">
  123. <template slot-scope="scope">
  124. <el-date-picker size="small" v-model="scope.row.happenDate" type="date" style=" width: 145px" value-format="yyyy-MM-dd" placeholder="选择日期">
  125. </el-date-picker>
  126. </template>
  127. </el-table-column>
  128. <el-table-column label="发票种类" width="175px">
  129. <template slot-scope="scope">
  130. <el-select size="small" v-model="scope.row.invoiceType" placeholder="请选择费用类型" style="width: 150px;">
  131. <el-option label="增值税专用发票" value="0"></el-option>
  132. <el-option label="增值税普通发票" value="1"></el-option>
  133. </el-select>
  134. </template>
  135. </el-table-column>
  136. <el-table-column label="费用类型" width="175px">
  137. <template slot-scope="scope">
  138. <el-select size="small" v-model="scope.row.expenseType" placeholder="费用类型" style="width: 150px" >
  139. <el-option v-for="(item, index) in expenseTypeList" :key="index" :label="item.typeName" :value="item.typeName" ></el-option>
  140. </el-select>
  141. </template>
  142. </el-table-column>
  143. <el-table-column label="费用金额(含税)" width="135px">
  144. <template slot-scope="scope">
  145. <el-input size="small" :id="'upam'+scope.$index" v-model="scope.row.amount" @input="zhi(scope.$index)" @change="shiqu(scope.row.amount)" @keyup.native="restrictNumber('upam'+scope.$index)"></el-input>
  146. </template>
  147. </el-table-column>
  148. <el-table-column prop="invoiceNo" label="发票号" width="135px">
  149. <template slot-scope="scope">
  150. <el-input size="small" v-model.number="scope.row.invoiceNo"></el-input>
  151. </template>
  152. </el-table-column>
  153. <el-table-column label="税率%" width="135px">
  154. <template slot-scope="scope">
  155. <el-input size="small" type= "number" v-model="scope.row.taxPercent" @input="zhi(scope.$index)"></el-input>
  156. </template>
  157. </el-table-column>
  158. <el-table-column label="税额" width="135px">
  159. <template slot-scope="scope">
  160. <el-input size="small" v-model="scope.row.taxValue" @input="zhis(scope.$index)"></el-input>
  161. </template>
  162. </el-table-column>
  163. <el-table-column label="备注" width="135px">
  164. <template slot-scope="scope">
  165. <el-input size="small" v-model="scope.row.remark"></el-input>
  166. </template>
  167. </el-table-column>
  168. <el-table-column label="报销凭证" width="135px">
  169. <template slot-scope="scope">
  170. <div @click="abl(scope.$index)">
  171. <el-upload :class="!scope.row.pic ? 'upload-demo' : 'upload-demo icl'" :before-remove="beforeRemove" :http-request="fileonLoad" limit="1" name="multipartFile">
  172. <el-button size="small" type="primary" v-if="!scope.row.pic">点击上传</el-button>
  173. </el-upload>
  174. </div>
  175. </template>
  176. </el-table-column>
  177. <el-table-column fixed="right"
  178. label="操作">
  179. <template slot-scope="scope">
  180. <el-button type="default" size="mini" style="display: inline-block;margin-left:0;margin-top: 3px" @click="chanc(scope.$index)">删除</el-button>
  181. </template>
  182. </el-table-column>
  183. </el-table>
  184. </div>
  185. <!-- <el-button class="submits" type="warning" @click="submits">提交</el-button> -->
  186. </div>
  187. </div>
  188. </div>
  189. <!-- 下面部分 -->
  190. <div class="xiamian" ref="xiaomian" style="width: 85%;float:right;background: #fff;position: relative;">
  191. <div v-if="displayTable">
  192. <div style="padding-left:10px;padding-right:10px;">
  193. <div>
  194. <el-form label-width="70px" inline >
  195. <!-- 报销人 -->
  196. <el-form-item label="报销人">
  197. <el-select v-model="ownerId" size="small" clearable placeholder="选择报销人" style="width: 120px" :disabled="!permissions.costAudit" filterable="true">
  198. <span v-for="(item, index) in users" :key="index">
  199. <el-option :label="item.name" :value="item.id"></el-option>
  200. </span>
  201. </el-select>
  202. </el-form-item>
  203. <!-- 单据编号 -->
  204. <el-form-item label="单据编号" >
  205. <el-input v-model="code" size="small" placeholder="单据编号" clearable="true" style="width: 120px"></el-input>
  206. </el-form-item>
  207. <!-- 费用类型 -->
  208. <el-form-item label="费用类型">
  209. <el-select v-model="type" size="small" placeholder="请选择费用类型" clearable="true" style="width: 150px">
  210. <el-option label="一般费用" value="0"></el-option>
  211. <el-option label="差旅费用" value="1"></el-option>
  212. <el-option label="外包费用" value="2"></el-option>
  213. </el-select>
  214. </el-form-item>
  215. <!-- 填报日期 -->
  216. <el-form-item label="填报日期" >
  217. <el-date-picker
  218. v-model="date"
  219. type="daterange"
  220. value-format="yyyy-MM-dd"
  221. size="small"
  222. range-separator="至"
  223. start-placeholder="开始日期"
  224. end-placeholder="结束日期"
  225. style="width: 280px">
  226. </el-date-picker>
  227. </el-form-item>
  228. <el-form-item>
  229. <el-button @click="getList" size="small">查找</el-button>
  230. </el-form-item>
  231. </el-form>
  232. </div>
  233. <el-divider ></el-divider>
  234. <!--列表-->
  235. <el-table ref="tab" :data="list" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;" :summary-method="getSummaries" show-summary>
  236. <el-table-column prop="code" label="票据编号"></el-table-column>
  237. <el-table-column prop="totalAmount" label="金额(元)" align="center">
  238. <template slot-scope="scope" >
  239. <span style="float:right;margin-right:20px">{{scope.row.totalAmount ? scope.row.totalAmount.toFixed(2) : '0'}}</span>
  240. </template>
  241. </el-table-column>
  242. <el-table-column prop="ownerName" label="报销人" ></el-table-column>
  243. <el-table-column prop="createDate" label="填报日期" ></el-table-column>
  244. <el-table-column prop="ticketNum" label="发票张数" ></el-table-column>
  245. <el-table-column prop="type" label="票据类型" >
  246. <template slot-scope="scope">
  247. {{feeType[scope.row.type]}}
  248. </template>
  249. </el-table-column>
  250. <el-table-column prop="remark" label="备注" width="250">
  251. <template slot-scope="scope">
  252. <span style="font-size:12px;">{{scope.row.remark}}</span>
  253. </template>
  254. </el-table-column>
  255. <el-table-column prop="status" label="状态" width="100">
  256. <template slot-scope="scope">
  257. <span v-if="scope.row.status == 1" class="waiting">{{statusTxt[scope.row.status]}}</span>
  258. <span v-if="scope.row.status == 2" class="rejected">{{statusTxt[scope.row.status]}}</span>
  259. <span v-if="scope.row.status == 0 || scope.row.status == 3" >{{statusTxt[scope.row.status]}}</span>
  260. </template>
  261. </el-table-column>
  262. <el-table-column label="操作" :width="isAuditList?220:160">
  263. <template slot-scope="scope" >
  264. <div v-if="!isAuditList">
  265. <el-button icon="el-icon-view" circle size="mini" @click.stop.native="downloadByA(scope.row)" ></el-button>
  266. <el-button icon="el-icon-edit" circle size="mini" style="margin-left:10px;" @click.stop.native="showEditName(scope.row)" v-show="permissions.costAudit || scope.row.status == 1 || scope.row.status == 2 "></el-button>
  267. <el-button icon="el-icon-delete" circle size="mini" style="margin-left:10px;" @click.stop.native="deleteItem(scope.row)" v-show="permissions.costAudit || scope.row.status == 1 || scope.row.status == 2 "></el-button>
  268. </div>
  269. <div v-if="isAuditList">
  270. <el-button size="mini" @click.stop.native="downloadByA(scope.row)" >查看</el-button>
  271. <el-button size="mini" style="margin-left:5px;" @click.stop.native="approve(scope.row)" >通过</el-button>
  272. <el-button size="mini" style="margin-left:5px;" @click.stop.native="deny(scope.row)" >驳回</el-button>
  273. </div>
  274. </template>
  275. </el-table-column>
  276. </el-table>
  277. <!--工具条-->
  278. <el-col :span="24" class="toolbar">
  279. <el-pagination
  280. @size-change="handleSizeChange"
  281. @current-change="handleCurrentChange"
  282. :page-sizes="[20 , 50 , 80 , 100]"
  283. :page-size="20"
  284. layout="total, sizes, prev, pager, next"
  285. :total="total"
  286. style="float:right;"
  287. ></el-pagination>
  288. </el-col>
  289. </div>
  290. </div>
  291. </div>
  292. <!-- 我的单据报销展示 -->
  293. <el-dialog title="报销凭证详情" :visible.sync="dialog" width="1000px">
  294. <!-- 内容主体 -->
  295. <div class="informant"><!-- 报销人 -->
  296. <el-form :model="ParticularsList" label-width="80px">
  297. <el-form-item label="报销人" style="width: 270px" :rules="{ required: true, message: '请选择报销人', trigger: 'blur' }">
  298. <!-- <el-input v-show="flg" v-model="ParticularsList.ownerName" disabled ></el-input> -->
  299. <el-select v-model="ParticularsList.ownerId" placeholder="请选择报销人" style="width: 150px" :disabled="flg || ParticularsList.ownerId == ParticularsList.operatorId">
  300. <span v-for="(item, index) in users" :key="index">
  301. <el-option :label="item.name" :value="item.id"></el-option>
  302. </span>
  303. </el-select>
  304. </el-form-item>
  305. <el-form-item label="填报日期">
  306. <!-- <el-input v-model="ParticularsList.createDate" :disabled="flg"></el-input> -->
  307. <el-date-picker type="date" :disabled="flg" placeholder="选择日期" v-model="ParticularsList.createDate" value-format="yyyy-MM-dd" style="width: 200px;"></el-date-picker>
  308. </el-form-item>
  309. <el-form-item label="发票张数">
  310. <el-input v-enter-number v-model="ParticularsList.ticketNum" :disabled="flg"></el-input>
  311. </el-form-item>
  312. <el-form-item label="费用类型" style="width: 270px">
  313. <el-select v-model="ParticularsList.type" placeholder="请选择" :disabled="flg">
  314. <el-option label="一般" :value="0"></el-option>
  315. <el-option label="差旅" :value="1"></el-option>
  316. <el-option label="外包" :value="2"></el-option>
  317. </el-select>
  318. </el-form-item>
  319. <el-form-item label="备注" style="width: 280px">
  320. <el-input v-model="ParticularsList.remark" :disabled="flg"></el-input>
  321. </el-form-item>
  322. <el-form-item label="总费用">
  323. ¥{{ParticularsList.totalAmount | numberToCurrency}}&nbsp;&nbsp;元
  324. </el-form-item>
  325. <!-- <template slot-scope="scope">
  326. <el-input v-model="scope.row.totalAmount" v-if="!flg"></el-input> 元
  327. <span v-else>{{scope.row.totalAmount}} 元</span>
  328. </template> -->
  329. </el-form>
  330. <el-table :data="ParticularsList.invoiceList" border style="width: 100%">
  331. <el-table-column prop="projectId" label="项目" width="155">
  332. <template slot-scope="scope">
  333. <el-select size="small" v-if="!flg" v-model="scope.row.projectId" placeholder="项目" style="width: 130px">
  334. <el-option v-for="(item, index) in projectList" :key="index" :label="item.projectName + item.projectCode" :value="item.id" @click="ok(item)">
  335. <span style="float: left;color: #8492a6; font-size: 13px">{{ item.projectCode }}</span>
  336. <span style="float: right;margin-left: 20px">{{ item.projectName }}</span>
  337. </el-option>
  338. </el-select>
  339. <!-- <span v-else>{{projectIdName[scope.$index].projectName}}</span> -->
  340. <div v-else>
  341. <div v-for="(item, index) in projectIdName" :key="index">
  342. <span v-if="item.id == scope.row.projectId">{{item.projectName}}</span>
  343. </div>
  344. </div>
  345. </template>
  346. </el-table-column>
  347. <el-table-column prop="happenDate" label="费用日期" width="172">
  348. <template slot-scope="scope">
  349. <el-date-picker size="small" v-if="!flg" v-model="scope.row.happenDate" type="date" style=" width: 145px" value-format="yyyy-MM-dd" placeholder="选择日期">
  350. </el-date-picker>
  351. <span v-else>{{scope.row.happenDate}}</span>
  352. </template>
  353. </el-table-column>
  354. <el-table-column prop="invoiceType" label="发票种类" width="172">
  355. <template slot-scope="scope">
  356. <el-select size="small" v-if="!flg" v-model="scope.row.invoiceType" placeholder="请选择费用类型" style="width: 150px;">
  357. <el-option label="增值税专用发票" :value="0"></el-option>
  358. <el-option label="增值税普通发票" :value="1"></el-option>
  359. </el-select>
  360. <span v-else>{{typeInvoic[scope.row.invoiceType]}}</span>
  361. </template>
  362. </el-table-column>
  363. <el-table-column prop="invoiceType" label="费用类型" width="172">
  364. <template slot-scope="scope">
  365. <el-select v-if="!flg" size="small" v-model="scope.row.expenseType" placeholder="请选择费用类型" style="width: 150px" >
  366. <el-option v-for="(item, index) in expenseTypeList" :key="index" :label="item.typeName" :value="item.typeName" ></el-option>
  367. </el-select>
  368. <span v-else>{{scope.row.expenseType}}</span>
  369. </template>
  370. </el-table-column>
  371. <el-table-column prop="amount" label="费用金额(含税:元)" width="172">
  372. <template slot-scope="scope">
  373. <el-input size="small" v-if="!flg" :id="'am'+scope.$index" v-model="scope.row.amount" @input="zhiNum(scope.$index, scope)" @change="kan" @keyup.native="restrictNumber('am'+scope.$index)"></el-input>
  374. <span v-else>¥{{scope.row.amount}}</span>
  375. </template>
  376. </el-table-column>
  377. <el-table-column prop="invoiceNo" label="发票号" width="172">
  378. <template slot-scope="scope">
  379. <el-input size="small" v-if="!flg" v-model.number="scope.row.invoiceNo"></el-input>
  380. <span v-else>{{scope.row.invoiceNo}}</span>
  381. </template>
  382. </el-table-column>
  383. <el-table-column prop="taxPercent" label="税率%" width="172">
  384. <template slot-scope="scope">
  385. <el-input size="small" v-if="!flg" v-model="scope.row.taxPercent" @input="zhiNum(scope.$index, scope)"></el-input>
  386. <span v-else>{{scope.row.taxPercent}}</span>
  387. </template>
  388. </el-table-column>
  389. <el-table-column prop="taxValue" label="税额(元)" width="172">
  390. <template slot-scope="scope">
  391. <el-input size="small" v-if="!flg" v-model="scope.row.taxValue"></el-input>
  392. <span v-else>¥{{scope.row.taxValue}}</span>
  393. </template>
  394. </el-table-column>
  395. <el-table-column prop="remark" label="备注" width="300">
  396. <template slot-scope="scope">
  397. <el-input size="small" v-if="!flg" v-model="scope.row.remark"></el-input>
  398. <span v-else>{{scope.row.remark}}</span>
  399. </template>
  400. </el-table-column>
  401. <el-table-column prop="pic" label="报销凭证" width="300">
  402. <template slot-scope="scope">
  403. <div v-if="!flg">
  404. <div @click="abl(scope.$index)" style="height: 35px;overflow: hidden;">
  405. <el-upload :class="!scope.row.pic ? 'upload-demo' : 'upload-demo icl'" :file-list="scope.row.pic" :before-remove="beforeRemoves" :http-request="fileonLoads" limit="1" name="multipartFile">
  406. <el-button size="small" type="primary" v-if="!scope.row.pic">点击上传</el-button>
  407. </el-upload>
  408. </div>
  409. </div>
  410. <div v-else>
  411. <span v-if="scope.row.pic">
  412. <div class="tups">
  413. <viewer :images="scope.row.pic">
  414. <img ref="imgsa" v-for="src in scope.row.pic" :src="src.url" :key="src.title">
  415. </viewer>
  416. </div>
  417. </span>
  418. <span v-else>暂无单据</span>
  419. </div>
  420. </template>
  421. </el-table-column>
  422. <!-- 删除 -->
  423. <el-table-column fixed="right"
  424. label="操作" v-if="!flg">
  425. <template slot-scope="scope">
  426. <el-button type="default" size="mini" style="display: inline-block;margin-left:0;margin-top: 3px" @click="delec(scope.$index)">删除</el-button>
  427. </template>
  428. </el-table-column>
  429. </el-table>
  430. </div>
  431. <!-- <viewer :images="imgs">
  432. <img ref="imgsa" v-for="src in imgs" :src="src.url" :key="src.title">
  433. </viewer> -->
  434. <!-- 取消和确定 -->
  435. <span slot="footer" class="dialog-footer">
  436. <el-button @click="dialog = false">取 消</el-button>
  437. <el-button v-if="!flg" type="primary" @click="present()">确 定</el-button>
  438. <el-button v-else type="primary" @click="dialog = false">确 定</el-button>
  439. </span>
  440. </el-dialog>
  441. <!-- 批量上传 -->
  442. <el-dialog title="批量上传" v-if="importDialog" :visible.sync="importDialog" customClass="customWidth" width="500px">
  443. <p>1. 下载
  444. <el-link type="primary" style="margin-left:5px;" :underline="false" href="./upload/费用报销导入模板.xlsx" download="费用报销导入模板.xlsx">费用报销导入模板.xlsx</el-link>
  445. </p>
  446. <p>2. 填写excel模板,并上传。</p>
  447. <div style="padding-bottom:1em;">
  448. <div style="width:300px;margin:0 auto">
  449. <el-upload ref="upload" action="#" :auto-upload="false" multiple :on-change="fileListAdd" :on-remove="fileListDel">
  450. <el-button slot="trigger" size="small" type="primary" style="">选取文件</el-button>
  451. <el-button type="primary" size="small" style="margin-left:30px" :underline="false" :loading="importingData" @click="submitUploadSure" :disabled="fileList.length == 0">开始上传</el-button>
  452. <el-button size="small" style="margin-left:30px" @click="fileListClear">清空</el-button>
  453. </el-upload>
  454. </div>
  455. </div>
  456. </el-dialog>
  457. <!-- 费用类型自定义 -->
  458. <el-dialog title="费用类型管理" v-if="customTypeDialog" :visible.sync="customTypeDialog" customClass="customWidth" width="600px">
  459. <el-table :data="customTypeList" style="width:100%" height="400" :loading="customTypeListLoading">
  460. <el-table-column prop="typeName" label="费用名称" min-width="150"></el-table-column>
  461. <el-table-column label="费用类型" min-width="150">
  462. <template slot-scope="scope">
  463. <span>{{scope.row.mainType == 0 ? '一般费用' : (scope.row.mainType == 1 ? '差旅费用' : '外包费用')}}</span>
  464. </template>
  465. </el-table-column>
  466. <el-table-column label="操作" width="150">
  467. <template slot-scope="scope">
  468. <el-button @click="customTypeEditOp(scope.row)" size="small" type="primary">编辑</el-button>
  469. <el-button @click="customTypeEditDelete(scope.row)" size="small" type="danger">删除</el-button>
  470. </template>
  471. </el-table-column>
  472. </el-table>
  473. <span slot="footer" class="dialog-footer">
  474. <el-button @click="customTypeDialog = false" size="medium">取消</el-button>
  475. <el-button type="primary" @click="customTypeEditOp()" size="medium">新增类型</el-button>
  476. </span>
  477. <!-- 新增/编辑费用类型 -->
  478. <el-dialog title="新增/编辑费用类型" v-if="customTypeEditDialog" :visible.sync="customTypeEditDialog" customClass="customWidth" width="400px" append-to-body>
  479. <el-form label-width="80px" :rules="editTypeDataRules" ref="editTypeDataForm" :model="editTypeData">
  480. <el-form-item label="所属类型" style="margin:30px 0">
  481. <el-select v-model="editTypeData.mainType" size="medium" style="width:90%">
  482. <el-option label="一般费用" :value="0"></el-option>
  483. <el-option label="差旅费用" :value="1"></el-option>
  484. <el-option label="外包费用" :value="2"></el-option>
  485. </el-select>
  486. </el-form-item>
  487. <el-form-item label="类型名称" style="margin:30px 0" prop="typeName">
  488. <el-input id="editTypeDataInput" size="medium" v-model="editTypeData.typeName" placeholder="自定义费用类型名称" style="width:90%" @keyup.native="editTypeDataInput('editTypeDataInput')"></el-input>
  489. </el-form-item>
  490. </el-form>
  491. <span slot="footer" class="dialog-footer">
  492. <el-button @click="customTypeEditDialog = false" size="medium">取消</el-button>
  493. <el-button type="primary" @click="customTypeEditSure" size="medium">确认</el-button>
  494. </span>
  495. </el-dialog>
  496. </el-dialog>
  497. </section>
  498. </template>
  499. <script>
  500. export default {
  501. name: "expense",
  502. components: {},
  503. props: {},
  504. data() {
  505. return {
  506. fileList: [],
  507. muHeight: document.documentElement.clientHeight || document.body.clientHeight,
  508. imgs: [],
  509. addFormRules: {
  510. ownerId: [{ required: true, message: "请选择报销人", trigger: "blur" }],
  511. createDate: [{ required: true, message: "请选择日期", trigger: "blur" }],
  512. },
  513. isAuditList: false,
  514. statusTxt:["审核通过","待审核", "已驳回", "已撤销"],
  515. user: JSON.parse(sessionStorage.getItem("user")),
  516. permissions: JSON.parse(sessionStorage.getItem("permissions")),
  517. allExpList:[],
  518. expenseTypeList:[],
  519. tian:{a: null,b: null,c: null,d: null,e: null,f: null,g: null,h: null,},
  520. feeType:["一般费用","差旅费用","外包费用"],
  521. typeInvoic: ['增值税专用发票', '增值税普通发票'],
  522. listLoading:false,
  523. tableHeight:0,
  524. list:[],
  525. total:0,
  526. code:null,
  527. date:null,
  528. type:null,
  529. ownerId: null,
  530. users: [], // 人员信息
  531. displayTable: false,
  532. getLists: [],
  533. ProjectList: [], // 项目列表
  534. companyId: [], // 人员的id
  535. dialogVisible: false,
  536. code: null,
  537. addForm:{code:null,ownerId:null,createDate: null, ticketNum:1,type:0,remark:null,totalAmount:0,},
  538. page: 1,
  539. size:20,
  540. form: {happenDate: null,invoiceType:null,amount:null,invoiceNo:null,taxPercent:null,taxValue:null,remark:null},
  541. invoiceList: [],
  542. kkk: null, //
  543. ddId: null,
  544. dldl: [],
  545. isOK: false,
  546. z : null,
  547. value: null,
  548. dialog: false, // 单据查看展示
  549. ParticularsList: [],
  550. projectIdName: [], // 点击查看的项目名
  551. flg: false, // 是否禁用
  552. shuz: ['一般费用填报', '差旅费用填报', '外包费用填报'],
  553. ins: 0,
  554. apl: '',
  555. diz: 'http://worktime.ttkuaiban.com',
  556. importDialog: false,
  557. importingData: false,
  558. // 费用类型自定义
  559. customTypeDialog: false,
  560. customTypeList: [],
  561. customTypeListLoading: false,
  562. customTypeEditDialog: false,
  563. editTypeData: {},
  564. editTypeDataRules:{
  565. typeName: [{ required: true, message: "请输入自定义费用类型名称", trigger: "blur" }],
  566. },
  567. };
  568. },
  569. computed: {
  570. totalCost : function(){
  571. let num = 0
  572. for(let i in this.invoiceList){
  573. if(this.invoiceList[i].amount){
  574. num += this.invoiceList[i].amount*1
  575. }
  576. }
  577. return num
  578. }
  579. },
  580. watch: {},
  581. created() {
  582. let height = window.innerHeight;
  583. this.tableHeight = height - 195;
  584. const that = this;
  585. window.onresize = function temp() {
  586. that.tableHeight = window.innerHeight - 195;
  587. };
  588. },
  589. mounted() {
  590. this.getNextCode();
  591. this.getUsers() // 获取人员信息
  592. this.getList() // 获取单据列表
  593. this.getProjectList();
  594. this.getExpList();
  595. },
  596. filters: {
  597. numberToCurrency(value) {
  598. if (!value) return '0.00'
  599. // console.log('v=='+value);
  600. value = value.toFixed(2)
  601. const intPart = Math.trunc(value)
  602. const intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
  603. let floatPart = '.00'
  604. const valueArray = value.toString().split('.')
  605. if (valueArray.length === 2) { // 有小数部分
  606. floatPart = valueArray[1].toString() // 取得小数部分
  607. return intPartFormat + '.' + floatPart
  608. }
  609. return intPartFormat + floatPart
  610. }
  611. },
  612. methods: {
  613. // 费用类型自定义
  614. customTypeOp(){
  615. this.customTypeDialog = true
  616. this.customTypeListLoading = true
  617. this.getExpList()
  618. },
  619. customTypeEditOp(row){
  620. this.customTypeEditDialog = true
  621. if(row){
  622. this.editTypeData = row
  623. }else{
  624. this.editTypeData = {
  625. mainType: 0,
  626. typeName: '',
  627. companyId: this.user.companyId
  628. }
  629. }
  630. },
  631. customTypeEditSure(){
  632. this.$refs.editTypeDataForm.validate(valid => {
  633. if (valid) {
  634. this.http.post('/expense-type/addOrMod',this.editTypeData,
  635. res => {
  636. if(res.code == 'ok'){
  637. this.customTypeEditDialog = false
  638. this.customTypeOp()
  639. }else{
  640. this.$message({
  641. message: res.msg,
  642. type: 'error'
  643. })
  644. }
  645. },err => {
  646. this.$message({
  647. message: err,
  648. type: 'error'
  649. })
  650. })
  651. }})
  652. },
  653. customTypeEditDelete(row){
  654. this.$confirm('该操作可能造成已有数据丢失,确定要删除吗?','提示',{
  655. confirmButtonText: '确定',
  656. cancelButtonText: '取消',
  657. type: 'warning'
  658. }).then(()=>{
  659. this.http.post('/expense-type/delete',{
  660. id: row.id
  661. },
  662. res => {
  663. if(res.code == 'ok'){
  664. this.customTypeEditDialog = false
  665. this.customTypeOp()
  666. }else{
  667. this.$message({
  668. message: res.msg,
  669. type: 'error'
  670. })
  671. }
  672. },err => {
  673. this.$message({
  674. message: err,
  675. type: 'error'
  676. })
  677. })
  678. }).catch(()=>{
  679. this.$message({
  680. type: 'info',
  681. message: '已取消删除'
  682. })
  683. })
  684. },
  685. editTypeDataInput(typeName){
  686. let inpu = document.getElementById(typeName);
  687. inpu.value = inpu.value.replace(/^\s*|\s*$/g, '')
  688. },
  689. submitUpload(){
  690. this.importDialog = true
  691. },
  692. fileListAdd(file,fileList){
  693. let str = file.name.split(".");
  694. let format = str[str.length - 1];
  695. if (format != "xls" && format != "xlsx") {
  696. this.$message({
  697. message: "请选择.xls或.xlsx文件",
  698. type: "error"
  699. });
  700. fileList.splice(fileList.length-1)
  701. }
  702. this.fileList = fileList
  703. },
  704. fileListDel(file,fileList){
  705. this.fileList = fileList
  706. },
  707. fileListClear(){
  708. this.$refs.upload.clearFiles();
  709. this.fileList = []
  710. },
  711. submitUploadSure(){
  712. this.$confirm('确认上传?','提示',{
  713. confirmButtonText: '确定',
  714. cancelButtonText: '取消',
  715. type: 'success'
  716. }).then(()=>{
  717. let formData = new FormData();
  718. for(let i in this.fileList){
  719. formData.append("files", this.fileList[i].raw);
  720. }
  721. this.importingData = true
  722. // console.log(formData,this.fileList);
  723. // return
  724. this.http.uploadFile( '/expense-sheet/importData', formData,
  725. res => {
  726. if (res.code == "ok") {
  727. this.importingData = false
  728. this.$refs.upload.clearFiles();
  729. this.fileList = []
  730. this.$message({
  731. message: "上传成功",
  732. type: "success"
  733. });
  734. } else {
  735. this.importingData = false
  736. this.$message({
  737. message: res.msg,
  738. type: "error"
  739. });
  740. }
  741. },error => {
  742. this.importingData = false
  743. this.$message({
  744. message: error,
  745. type: "error"
  746. });
  747. });
  748. }).catch(()=>{})
  749. },
  750. restrictNumber(targetId) {
  751. let inpu = document.getElementById(targetId);
  752. inpu.value = inpu.value.replace(/[^\d.]/g, ""); //仅保留数字和"."
  753. inpu.value = inpu.value.replace(/\.{2,}/g, "."); //两个连续的"."仅保留第一个"."
  754. inpu.value = inpu.value.replace(".", "$#*").replace(/\./g,'').replace('$#*','.');//去除其他"."
  755. inpu.value = inpu.value.replace(/^(\d+)\.(\d\d).*$/, '$1.$2');;//限制只能输入两个小数
  756. if (inpu.value.indexOf(".") < 0 && inpu.value != "") { //首位是0的话去掉
  757. inpu.value = parseFloat(inpu.value);
  758. }
  759. },
  760. approve(item) {
  761. //审核通过
  762. this.http.post('/expense-sheet/approve', {id:item.id
  763. },
  764. res => {
  765. if (res.code == "ok") {
  766. this.getList();
  767. } else {
  768. this.$message({
  769. message: res.msg,
  770. type: "error"
  771. });
  772. }
  773. },
  774. error => {
  775. this.$message({
  776. message: error,
  777. type: "error"
  778. });
  779. });
  780. },
  781. deny(item) {
  782. //审核驳回
  783. this.http.post('/expense-sheet/deny', {id:item.id
  784. },
  785. res => {
  786. if (res.code == "ok") {
  787. this.getList();
  788. } else {
  789. this.$message({
  790. message: res.msg,
  791. type: "error"
  792. });
  793. }
  794. },
  795. error => {
  796. this.$message({
  797. message: error,
  798. type: "error"
  799. });
  800. });
  801. },
  802. getExpList() {
  803. this.http.post('/expense-type/getList', {
  804. },
  805. res => {
  806. this.customTypeListLoading = false
  807. if (res.code == "ok") {
  808. this.allExpList = res.data;
  809. this.customTypeList = res.data
  810. this.expenseTypeList = this.allExpList.filter(a=>a.mainType == 0);
  811. } else {
  812. this.$message({
  813. message: res.msg,
  814. type: "error"
  815. });
  816. }
  817. },
  818. error => {
  819. this.customTypeListLoading = false
  820. this.$message({
  821. message: error,
  822. type: "error"
  823. });
  824. });
  825. },
  826. // 单据查看
  827. downloadByA(val) {
  828. this.dialog = true
  829. this.flg = true;
  830. this.getParticulars(val.id);
  831. this.expenseTypeList = this.allExpList.filter(a=>a.mainType == val.type);
  832. },
  833. // 单据编辑
  834. showEditName(val) {
  835. this.dialog = true,
  836. this.flg = false,
  837. delete val.invoiceList
  838. this.getParticulars(val.id)
  839. this.expenseTypeList = this.allExpList.filter(a=>a.mainType == val.type);
  840. },
  841. staffs(key, keyPath) { // 控制员工费用报表
  842. if (keyPath[0] == '1') {
  843. this.displayTable = false;
  844. } else {
  845. this.displayTable = true;
  846. this.getList();
  847. }
  848. },
  849. bills(audit) { // 控制
  850. this.isAuditList = audit;
  851. this.getList();
  852. this.displayTable = true;
  853. },
  854. present(){
  855. this.dialog = false
  856. this.adds();
  857. },
  858. // 删除操作
  859. delec(ids) {
  860. // console.log('删除操作', ids);
  861. this.ParticularsList.invoiceList.splice(ids, 1)
  862. this.kan()
  863. },
  864. adds() {
  865. // happenDate
  866. // console.log(this.ParticularsList.invoiceList, '123')
  867. var spl = this.ParticularsList.invoiceList
  868. for(var i in spl) {
  869. if(spl[i].pic) {
  870. if(spl[i].pic[0].name) {
  871. spl[i].pic = spl[i].pic[0].name
  872. }
  873. }
  874. }
  875. // console.log(spl)
  876. // return
  877. this.ParticularsList.items = JSON.stringify(this.ParticularsList.invoiceList)//这里要传发票列表的json转string
  878. delete this.ParticularsList.invoiceList
  879. this.http.post('/expense-sheet/add', this.ParticularsList,
  880. res => {
  881. if (res.code == "ok") {
  882. this.bills(this.isAuditList);
  883. this.$message({
  884. message: '编辑成功',
  885. type: "success"
  886. });
  887. } else {
  888. this.$message({
  889. message: res.msg,
  890. type: "error"
  891. });
  892. }
  893. },
  894. error => {
  895. this.$message({
  896. message: error,
  897. type: "error"
  898. });
  899. });
  900. },
  901. // 获取人员信息
  902. getUsers() {
  903. // this.http.post(this.port.manage.list, {
  904. // departmentId: -1,
  905. // pageIndex: 1,
  906. // // pageSize: 99999
  907. // pageSize: -1
  908. // },
  909. this.http.post('/user/getSimpleActiveUserList', {},
  910. res => {
  911. if (res.code == "ok") {
  912. // this.users = res.data.records;
  913. this.users = res.data;
  914. if (!this.permissions.costAudit) {
  915. this.addForm.ownerId = this.user.id;
  916. this.addForm.status = 1;
  917. }
  918. } else {
  919. this.$message({
  920. message: res.msg,
  921. type: "error"
  922. });
  923. }
  924. },
  925. error => {
  926. this.$message({
  927. message: error,
  928. type: "error"
  929. });
  930. });
  931. },
  932. // 提交事件
  933. submits() {
  934. this.$refs.mainAddForm.validate(valid => {
  935. if (valid) {
  936. if (this.invoiceList.length == 0) {
  937. this.$message({
  938. message: '请添加发票',
  939. type: "error"
  940. });
  941. return;
  942. }
  943. this.add();
  944. this.addForm = {code:null,ownerId:null,createDate: null,type:this.z, ticketNum:1,remark:null,totalAmount:0,}
  945. this.invoiceList = []
  946. }
  947. });
  948. },
  949. // 点击新增
  950. addxz() {
  951. this.form = {happenDate: null,invoiceType:null,amount:null,invoiceNo:null,taxPercent:null,taxValue:null,remark:null,pic: null},
  952. this.invoiceList.push(this.form)
  953. },
  954. //获取项目列表
  955. getProjectList() {
  956. this.http.post( this.port.project.list, {},
  957. res => {
  958. if (res.code == "ok") {
  959. this.projectList = res.data;
  960. } else {
  961. this.$message({
  962. message: res.msg,
  963. type: "error"
  964. });
  965. }
  966. },
  967. error => {
  968. this.$message({
  969. message: error,
  970. type: "error"
  971. });
  972. });
  973. },
  974. //获取单据列表
  975. getList() {
  976. // console.log(this.date)
  977. var stat = ''
  978. var end = ''
  979. if(this.date) {
  980. stat = this.date[0]
  981. end = this.date[1]
  982. }
  983. var param = {pageIndex: this.page,
  984. pageSize: this.size,
  985. code: this.code,
  986. // createDate: this.date,
  987. startDate: stat,
  988. endDate: end,
  989. ownerId:this.ownerId,
  990. type:this.type,
  991. };
  992. if (this.isAuditList) {
  993. param.status = 1;
  994. }
  995. this.list = [];
  996. this.total = 0;
  997. this.http.post('/expense-sheet/list', param,
  998. res => {
  999. if (res.code == "ok") {
  1000. this.list = res.data.records;
  1001. this.total = res.data.total;
  1002. } else {
  1003. this.$message({
  1004. message: res.msg,
  1005. type: "error"
  1006. });
  1007. }
  1008. },
  1009. error => {
  1010. this.$message({
  1011. message: error,
  1012. type: "error"
  1013. });
  1014. });
  1015. },
  1016. //删除单据
  1017. deletes(id) {
  1018. this.http.post('/expense-sheet/delete', {id: id},
  1019. res => {
  1020. if (res.code == "ok") {
  1021. this.getList()
  1022. this.$message({
  1023. message: '删除成功',
  1024. type: "success"
  1025. });
  1026. } else {
  1027. this.$message({
  1028. message: res.msg,
  1029. type: "error"
  1030. });
  1031. }
  1032. },
  1033. error => {
  1034. this.$message({
  1035. message: error,
  1036. type: "error"
  1037. });
  1038. });
  1039. },
  1040. //创建单据
  1041. add() {
  1042. // happenDate
  1043. this.addForm.items = JSON.stringify(this.invoiceList)//这里要传发票列表的json转string
  1044. this.addForm.totalAmount = this.totalCost
  1045. this.http.post('/expense-sheet/add', this.addForm,
  1046. res => {
  1047. if (res.code == "ok") {
  1048. this.$message({
  1049. message: '填报成功',
  1050. type: "success"
  1051. });
  1052. } else {
  1053. this.$message({
  1054. message: res.msg,
  1055. type: "error"
  1056. });
  1057. }
  1058. },
  1059. error => {
  1060. this.$message({
  1061. message: error,
  1062. type: "error"
  1063. });
  1064. });
  1065. },
  1066. //获取单据编码
  1067. getNextCode() {
  1068. this.http.post('/expense-sheet/getNextCode', {
  1069. },
  1070. res => {
  1071. if (res.code == "ok") {
  1072. this.addForm.code = res.data;
  1073. } else {
  1074. this.$message({
  1075. message: res.msg,
  1076. type: "error"
  1077. });
  1078. }
  1079. },
  1080. error => {
  1081. this.$message({
  1082. message: error,
  1083. type: "error"
  1084. });
  1085. });
  1086. },
  1087. // 获取查看单据的数据
  1088. getParticulars(id) {
  1089. this.http.post('/expense-sheet/getDetail', {id: id},
  1090. res => {
  1091. if (res.code == "ok") {this
  1092. // this.ParticularsList = res.data
  1093. var s = []
  1094. // var b = []
  1095. for(var i in res.data.invoiceList) {
  1096. if(res.data.invoiceList[i].pic) {
  1097. var b = []
  1098. var j = {}
  1099. var img = this.diz + '/upload/' + res.data.invoiceList[i].pic
  1100. j.url = img
  1101. j.title = '报销凭证',
  1102. j.name = res.data.invoiceList[i].pic
  1103. b.push(j)
  1104. res.data.invoiceList[i].pic = b
  1105. // console.log(res.data.invoiceList[i].pic)
  1106. }
  1107. }
  1108. this.ParticularsList = res.data
  1109. for(var i = 0; i <= this.ParticularsList.invoiceList.length - 1; i++) {
  1110. s.push(this.ParticularsList.invoiceList[i].projectId)
  1111. }
  1112. this.projectIdName = this.projectList.filter( item => {return s.indexOf(item.id) !== -1})
  1113. // this.projectIdName = this.projectList.filter(p => p.id == this.ParticularsList.invoiceList[0].projectId)[0].projectName
  1114. // console.log(res.data, '查看当前状态');
  1115. // console.log(this.ParticularsList)
  1116. } else {
  1117. this.$message({
  1118. message: res.msg,
  1119. type: "error"
  1120. });
  1121. }
  1122. },
  1123. error => {
  1124. this.$message({
  1125. message: error,
  1126. type: "error"
  1127. });
  1128. })
  1129. },
  1130. //分页
  1131. handleCurrentChange(val) {
  1132. this.page = val;
  1133. this.getList();
  1134. },
  1135. handleSizeChange(val) {
  1136. this.size = val;
  1137. this.getList();
  1138. },
  1139. deleteItem(item) {
  1140. this.$confirm("确认要删除吗?", "提示", {
  1141. //type: 'warning'
  1142. }).then(() => {
  1143. this.http.post('/expense-sheet/delete', {id:item.id},
  1144. res => {
  1145. if (res.code == "ok") {
  1146. this.getList();
  1147. } else {
  1148. this.$message({
  1149. message: res.msg,
  1150. type: "error"
  1151. });
  1152. }
  1153. },
  1154. error => {
  1155. this.$message({
  1156. message: error,
  1157. type: "error"
  1158. });
  1159. });
  1160. });
  1161. },
  1162. // 点击删除
  1163. chanc(k) {
  1164. this.invoiceList.splice(k, 1)
  1165. },
  1166. // 双击
  1167. dbclick(row, event, column){
  1168. this.isOK = true
  1169. },
  1170. oosk(s){
  1171. this.isOK = false
  1172. },
  1173. ssl(index) {
  1174. this.z = index
  1175. this.addForm.type = index
  1176. this.ins = index;
  1177. this.expenseTypeList = this.allExpList.filter(a=>a.mainType == this.ins);
  1178. this.addForm.ownerId = this.user.id;
  1179. this.getNextCode();
  1180. },
  1181. // 点击侧边栏事件
  1182. side() {
  1183. if(this.$refs.side.style.left < '0px') {
  1184. this.$refs.sidebars.style.width = '1px'
  1185. this.$refs.sid.style.left = '1px'
  1186. this.$refs.side.style.left = '1px'
  1187. this.$refs.sideI.className = 'el-icon-arrow-right'
  1188. this.$refs.staff.style.margin = '20px 20px 0 20px'
  1189. this.$refs.staff.style.width = '95%'
  1190. this.$refs.xiaomian.style.width = '100%'
  1191. this.$refs.headHe.style.paddingLeft = '20px'
  1192. } else {
  1193. this.$refs.sidebars.style.width = '200px'
  1194. this.$refs.sid.style.left = '200px'
  1195. this.$refs.side.style.left = '-19px'
  1196. this.$refs.sideI.className = 'el-icon-arrow-left'
  1197. this.$refs.staff.style.margin = '20px 20px 0 220px'
  1198. this.$refs.staff.style.width = '81%'
  1199. this.$refs.xiaomian.style.width = '85%'
  1200. this.$refs.headHe.style.paddingLeft = '220px'
  1201. }
  1202. },
  1203. // 费用金额失去焦点时触发
  1204. shiqu(){
  1205. this.addForm.totalAmount = this.invoiceList.reduce((prev, next) => {
  1206. return prev + parseFloat(next.amount);
  1207. }, 0)
  1208. },
  1209. kan(){
  1210. this.ParticularsList.totalAmount = this.ParticularsList.invoiceList.reduce((prev, next) => {
  1211. return prev + parseFloat(next.amount)
  1212. }, 0)
  1213. },
  1214. zhi(e) {
  1215. // console.log('看看值', e)
  1216. var i = e
  1217. if(this.invoiceList[i].amount == null || this.invoiceList[i].amount == 'null' || this.invoiceList[i].taxPercent == null || this.invoiceList[i].taxPercent == 'null') {
  1218. return
  1219. }
  1220. this.invoiceList[i].taxValue = this.invoiceList[i].amount * this.invoiceList[i].taxPercent / 100
  1221. // console.log(this.invoiceList[i].amount, this.invoiceList[i].taxPercent)
  1222. var shui = this.invoiceList[i].taxPercent / 100 // 税率
  1223. var zhi = this.invoiceList[i].amount / (1 + shui) * shui
  1224. this.invoiceList[i].taxValue = zhi.toFixed(2)
  1225. },
  1226. zhiNum(i, val) {
  1227. // console.log('看看值', i, val)
  1228. // console.log(this.ParticularsList.invoiceList)
  1229. if(this.ParticularsList.invoiceList[i].amount == null || this.ParticularsList.invoiceList[i].amount == 'null' || this.ParticularsList.invoiceList[i].taxPercent == null || this.ParticularsList.invoiceList[i].taxPercent == 'null') {
  1230. return
  1231. }
  1232. var shui = this.ParticularsList.invoiceList[i].taxPercent / 100
  1233. var zhi = this.ParticularsList.invoiceList[i].amount / (1 + shui) * shui
  1234. this.ParticularsList.invoiceList[i].taxValue = zhi.toFixed(2)
  1235. },
  1236. zhis(e) {
  1237. var i = e
  1238. this.invoiceList[i].taxValue = this.invoiceList[i].taxValue.toFixed(2)
  1239. },
  1240. fileonLoad(item) {
  1241. //首先判断文件类型
  1242. let str = item.file.name.split(".");
  1243. let format = str[str.length - 1];
  1244. if (format != "jpg" && format != "png") {
  1245. this.$message({
  1246. message: "请选择图片",
  1247. type: "error"
  1248. });
  1249. } else {
  1250. this.listLoading = true;
  1251. let formData = new FormData();
  1252. formData.append("multipartFile", item.file);
  1253. this.http.uploadFile('/common/uploadFile', formData,
  1254. res => {
  1255. this.listLoading = false;
  1256. if (res.code == "ok") {
  1257. this.$message({
  1258. message: "上传成功",
  1259. type: "success"
  1260. });
  1261. // this.getList();
  1262. this.invoiceList[this.apl].pic = res.data
  1263. // console.log(this.invoiceList)
  1264. } else {
  1265. this.$message({
  1266. message: res.msg,
  1267. type: "error"
  1268. });
  1269. }
  1270. },
  1271. error => {
  1272. this.listLoading = false;
  1273. this.$message({
  1274. message: error,
  1275. type: "error"
  1276. });
  1277. });
  1278. }
  1279. },
  1280. abl(e) {
  1281. this.apl = e
  1282. },
  1283. beforeRemove(file, fileList) {
  1284. var that = this
  1285. setTimeout(function () {
  1286. that.invoiceList[that.apl].pic = null
  1287. }, 200)
  1288. },
  1289. fileonLoads(item) {
  1290. //首先判断文件类型
  1291. let str = item.file.name.split(".");
  1292. let format = str[str.length - 1];
  1293. if (format != "jpg" && format != "png") {
  1294. this.$message({
  1295. message: "请选择图片",
  1296. type: "error"
  1297. });
  1298. } else {
  1299. this.listLoading = true;
  1300. let formData = new FormData();
  1301. formData.append("multipartFile", item.file);
  1302. this.http.uploadFile('/common/uploadFile', formData,
  1303. res => {
  1304. this.listLoading = false;
  1305. if (res.code == "ok") {
  1306. this.$message({
  1307. message: "上传成功",
  1308. type: "success"
  1309. });
  1310. // this.getList();
  1311. this.ParticularsList.invoiceList[this.apl].pic = res.data
  1312. // console.log(this.invoiceList)
  1313. } else {
  1314. this.$message({
  1315. message: res.msg,
  1316. type: "error"
  1317. });
  1318. }
  1319. },
  1320. error => {
  1321. this.listLoading = false;
  1322. this.$message({
  1323. message: error,
  1324. type: "error"
  1325. });
  1326. });
  1327. }
  1328. },
  1329. beforeRemoves(file, fileList) {
  1330. var that = this
  1331. setTimeout(function () {
  1332. // this.ParticularsList.invoiceList
  1333. that.ParticularsList.invoiceList[that.apl].pic = null
  1334. }, 200)
  1335. },
  1336. imgUrl(img) {
  1337. // var imgss = this.diz + '/upload/' + img
  1338. // var sp = []
  1339. // var is = {}
  1340. // is.url = imgss
  1341. // is.title = 1
  1342. // sp.push(is)
  1343. // this.imgs = sp
  1344. // console.log(imgss)
  1345. // console.log(this.$refs.imgsa)
  1346. // this.$refs.imgsa.click()
  1347. // console.log(location.protocol, location.host)
  1348. // console.log(location.protocol + '//' + location.host + imgs)
  1349. },
  1350. // 合计
  1351. getSummaries(param) {
  1352. const { columns, data } = param;
  1353. const sums = [];
  1354. columns.forEach((column, index) => {
  1355. if (index === 0) {
  1356. sums[index] = '合计';
  1357. return;
  1358. }
  1359. if(index === 1) {
  1360. const values = data.map(item => Number(item[column.property]));
  1361. if (!values.every(value => isNaN(value))) {
  1362. sums[index] = values.reduce((prev, curr) => {
  1363. const value = Number(curr);
  1364. if (!isNaN(value)) {
  1365. return prev + curr;
  1366. } else {
  1367. return prev;
  1368. }
  1369. }, 0);
  1370. var zhi = +sums[index] + 0
  1371. var sl = zhi.toFixed(2)
  1372. sl += ' 元';
  1373. } else {
  1374. sums[index] = 'N/A';
  1375. }
  1376. } else {
  1377. sums[index] = 'N/A';
  1378. }
  1379. });
  1380. // console.log(sums, 123)
  1381. this.$nextTick(()=>{ this.$refs.tab.doLayout()})
  1382. return sums;
  1383. }
  1384. },
  1385. };
  1386. </script>
  1387. <style scoped>
  1388. .tups {
  1389. width: 100%;
  1390. height: 25px;
  1391. position: relative;
  1392. z-index: 99;
  1393. overflow: hidden;
  1394. }
  1395. .tups img {
  1396. height: 25px !important;
  1397. position: relative;
  1398. z-index: 99;
  1399. }
  1400. .viewer-canvas {
  1401. position: absolute;
  1402. z-index: 9 !important;
  1403. }
  1404. .icl {
  1405. margin-top: -25px !important;
  1406. }
  1407. /* 费用报销标题 */
  1408. .headine {
  1409. width: 100%;
  1410. height: 46.4px;
  1411. line-height: 46.4px;
  1412. background: #fff;
  1413. box-sizing: border-box;
  1414. }
  1415. .headine h3 {
  1416. margin: 0;
  1417. display: inline-block;
  1418. box-sizing: border-box;
  1419. color: #999;
  1420. }
  1421. .headine p {
  1422. display: inline-block;
  1423. margin: 0;
  1424. }
  1425. /* /费用报销标题 */
  1426. .sidebars {
  1427. height: 100%;
  1428. position: absolute;
  1429. border-right: 1px solid #E6E6E6;
  1430. z-index: 2;
  1431. top: 0;
  1432. }
  1433. .sidebars h3 {
  1434. margin: 0;
  1435. line-height: 45px;
  1436. background: #ffffff;
  1437. font-weight: normal;
  1438. color: #666;
  1439. padding-left: 20px;
  1440. }
  1441. .sidebars .el-col-12 {
  1442. width: 100%
  1443. }
  1444. .public {
  1445. height: 180px;
  1446. border-bottom: 1px solid #ddd;
  1447. }
  1448. .public .el-form-item {
  1449. display: inline-block;
  1450. }
  1451. .pu_button {
  1452. text-align: right;
  1453. width: 100%;
  1454. padding: 24px 30px;
  1455. box-sizing: border-box;
  1456. }
  1457. .pu_bu_x .pu_bu_t {
  1458. display: inline-block;
  1459. }
  1460. .pu_bu_x {
  1461. margin-right: 20px;
  1462. color: #20A0F7;
  1463. cursor: pointer;
  1464. }
  1465. .pu_bu_t {
  1466. color: #20A0F7;
  1467. cursor: pointer;
  1468. display: block;
  1469. float: right;
  1470. position:
  1471. relative;
  1472. top: -20px;
  1473. right: 63px;
  1474. }
  1475. .pu_table {
  1476. margin-left: 10px;
  1477. }
  1478. .pu_bu_t:hover {
  1479. color: #7bbcff;
  1480. }
  1481. .pu_bu_x:hover {
  1482. color: #7bbcff;
  1483. }
  1484. /* 我的单据报销凭证 */
  1485. .staff{
  1486. border-left: 1px solid #fff;
  1487. border-top: 1px solid #fff;
  1488. border-right: 1px solid #fff;
  1489. background: #fff;
  1490. }
  1491. /* */
  1492. .sdat{
  1493. display: inline-block;
  1494. width: 260px;
  1495. margin-left: 13px;
  1496. }
  1497. .messages .el-form-item{
  1498. display: inline-block;
  1499. }
  1500. .messages .el-date-editor.el-input, .el-date-editor.el-input__inner{
  1501. width: 190px;
  1502. }
  1503. /* 我的报销凭证 */
  1504. .search {
  1505. position: relative;
  1506. top: 20px;
  1507. left: 20px;
  1508. }
  1509. .tables {
  1510. margin-top: 50px;
  1511. box-sizing: border-box;
  1512. padding: 10px;
  1513. }
  1514. .informant .el-form-item {
  1515. display: inline-block;
  1516. }
  1517. /* 侧边栏收索 */
  1518. .side {
  1519. position: absolute;
  1520. z-index: 2;
  1521. border-right: 2px solid #DDDDDD;
  1522. height: 100%;
  1523. top: 0;
  1524. width: 0;
  1525. }
  1526. .side .spans {
  1527. width: 20px;
  1528. height: 30px;
  1529. border: 1px solid #DDDDDD;
  1530. box-sizing: border-box;
  1531. position: absolute;
  1532. top: 50%;
  1533. margin-top: -50%;
  1534. text-align: center;
  1535. z-index: 1;
  1536. background: #fff;
  1537. }
  1538. .side .spans i{
  1539. margin-top: 7px;
  1540. color: #C0BFBF
  1541. }
  1542. .side:hover {
  1543. border-right: 2px solid #20A0FF;
  1544. }
  1545. .side:hover .spans {
  1546. border: 1px solid #20A0FF;
  1547. background: #20A0FF;
  1548. }
  1549. .side:hover .spans i{
  1550. color: #fff;
  1551. }
  1552. /* 右边整体页面 */
  1553. .contents {
  1554. height: 100%;
  1555. /* padding: 30px; */
  1556. background: #F7F7F7;
  1557. /* position: absolute; */
  1558. }
  1559. .submits {
  1560. margin-left: 50%;
  1561. }
  1562. .waiting {
  1563. color:orange;
  1564. }
  1565. .rejected {
  1566. color:red;
  1567. }
  1568. </style>