expense.vue 61 KB

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