expense.vue 63 KB

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