expense.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996
  1. <template>
  2. <section>
  3. <div class="sidebars" ref="sidebars" style="width: 200px;display: block;background: #fff">
  4. <h3><i class="iconfont firerock-iconbaoxiao" style="padding-right: 10px"></i>费用报销模块</h3>
  5. <el-divider ></el-divider>
  6. <el-col :span="12">
  7. <el-menu
  8. default-active="1-1"
  9. class="el-menu-vertical-demo"
  10. @select="staffs"
  11. background-color="#ffffff"
  12. text-color="#666666"
  13. active-text-color="#20A0FF"
  14. style="width:100%">
  15. <el-submenu index="1">
  16. <template slot="title">
  17. <i class="iconfont firerock-icontianbao"></i>
  18. <span>员工费用填报</span>
  19. </template>
  20. <el-menu-item index="1-1"><p @click="ssl(0)"> 一般费用填报</p></el-menu-item>
  21. <el-menu-item index="1-2"><p @click="ssl(1)">差旅费用填报</p></el-menu-item>
  22. <el-menu-item index="1-3"><p @click="ssl(2)">外包费用填报</p></el-menu-item>
  23. </el-submenu>
  24. <el-menu-item index="2" @select="bills" @click="bills">
  25. <i class="iconfont firerock-iconbaoxiaodan"></i>
  26. <span slot="title">报销单据列表</span>
  27. </el-menu-item>
  28. </el-menu>
  29. <!-- <el-menu
  30. default-active="2"
  31. class="el-menu-vertical-demo"
  32. @select="bills"
  33. background-color="#ffffff"
  34. text-color="#666666"
  35. active-text-color="#20A0FF"
  36. style="width:100%">
  37. <el-menu-item index="2" @select="bills">
  38. <i class="iconfont firerock-iconbaoxiaodan"></i>
  39. <span slot="title">报销单据列表</span>
  40. </el-menu-item>
  41. </el-menu> -->
  42. </el-col>
  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. </div>
  54. <!-- 上面部分 -->
  55. <div ref="staff" style="margin: 20px 20px 0 220px; width: 81.5%" >
  56. <div class="staff" v-if="!displayTable">
  57. <!-- 公共 -->
  58. <div class="public">
  59. <el-form :model="addForm" label-width="80px">
  60. <!-- <el-form :model="form" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm"> -->
  61. <!-- 报销人 -->
  62. <el-form-item label="报销人">
  63. <el-select v-model="addForm.ownerId" placeholder="请选择报销人" style="width: 150px">
  64. <span v-for="(item, index) in users" :key="index">
  65. <el-option :label="item.name" :value="item.id"></el-option>
  66. </span>
  67. </el-select>
  68. </el-form-item>
  69. <!-- 填报日期 -->
  70. <el-form-item label="填报日期" style="position: relative;top: 38px;">
  71. <el-col :span="11">
  72. <el-date-picker type="date" placeholder="选择日期" v-model="addForm.createDate" value-format="yyyy-MM-dd" style="width: 200px;"></el-date-picker>
  73. </el-col>
  74. </el-form-item>
  75. <!-- 发票张数 -->
  76. <el-form-item label="发票张数">
  77. <el-input v-model="addForm.ticketNum" style="width: 150px"></el-input>
  78. </el-form-item>
  79. <!-- 费用类型 -->
  80. <el-form-item label="费用类型">
  81. <el-select v-model="addForm.type" disabled style="width: 150px" >
  82. <el-option label="一般" :value="0"></el-option>
  83. <el-option label="差旅" :value="1"></el-option>
  84. <el-option label="外包" :value="2"></el-option>
  85. </el-select>
  86. </el-form-item>
  87. <!-- 备注 -->
  88. <el-form-item label="备注" style="display: block; width: 70%; float: left;">
  89. <el-input type="textarea" v-model="addForm.remark"></el-input>
  90. </el-form-item>
  91. <!-- 总成本 -->
  92. <!-- <div style="float: left; line-height: 55px;margin-left:20px">总成本 <el-link disabled v-model="addForm.totalAmount">{{addForm.totalAmount}}</el-link> 元</div> -->
  93. </el-form>
  94. </div>
  95. <!-- 按钮 -->
  96. <div class="pu_button">
  97. <span v-if="this.addForm.totalAmount <= 0" style="color:#606266;">总成本 {{this.addForm.totalAmount}} 元</span>
  98. <span v-else style="color:#606266;">总成本 ¥{{this.addForm.totalAmount | numberToCurrency}} 元</span>
  99. <span class="pu_bu_x" style="margin-left:10px;" @click="addxz"> <i class="el-icon-circle-plus-outline"></i> 新增发票</span>
  100. </div>
  101. <!-- 表格 -->
  102. <div class="pu_table">
  103. <el-table
  104. :data="invoiceList"
  105. border
  106. style="width: 100%;height: 100%"
  107. max-height="300px"
  108. @row-dblclick="dbclick">
  109. <el-table-column prop="projectName" label="所属项目" width="180">
  110. <template slot-scope="scope">
  111. <el-select size="small" v-model="scope.row.projectId" placeholder="项目" style="width: 150px" >
  112. <el-option v-for="(item, index) in projectList" :key="index" :label="item.projectName" :value="item.id" @click="ok(item)"></el-option>
  113. </el-select>
  114. </template>
  115. </el-table-column>
  116. <el-table-column prop="happenDate" label="费用日期" width="170px">
  117. <template slot-scope="scope">
  118. <el-date-picker size="small" v-model="scope.row.happenDate" type="date" style=" width: 145px" value-format="yyyy-MM-dd" placeholder="选择日期">
  119. </el-date-picker>
  120. </template>
  121. </el-table-column>
  122. <el-table-column label="发票种类" width="175px">
  123. <template slot-scope="scope">
  124. <el-select size="small" v-model="scope.row.invoiceType" placeholder="请选择费用类型" style="width: 150px;">
  125. <el-option label="增值税专用发票" value="0"></el-option>
  126. <el-option label="增值税普通发票" value="1"></el-option>
  127. </el-select>
  128. </template>
  129. </el-table-column>
  130. <el-table-column label="费用类型" width="155px">
  131. <template slot-scope="scope">
  132. <el-select size="small" v-model="scope.row.expenseType" placeholder="费用类型" style="width: 150px" >
  133. <el-option v-for="(item, index) in expenseTypeList" :key="index" :label="item.typeName" :value="item.typeName" ></el-option>
  134. </el-select>
  135. </template>
  136. </el-table-column>
  137. <el-table-column label="费用金额" width="135px">
  138. <template slot-scope="scope">
  139. <el-input size="small" v-model="scope.row.amount" @change="shiqu(scope.row.amount)"></el-input>
  140. </template>
  141. </el-table-column>
  142. <el-table-column prop="invoiceNo" label="发票号" width="135px">
  143. <template slot-scope="scope">
  144. <el-input size="small" v-model.number="scope.row.invoiceNo"></el-input>
  145. </template>
  146. </el-table-column>
  147. <el-table-column label="税率%" width="135px">
  148. <template slot-scope="scope">
  149. <el-input size="small" v-model="scope.row.taxPercent"></el-input>
  150. </template>
  151. </el-table-column>
  152. <el-table-column label="税额" width="135px">
  153. <template slot-scope="scope">
  154. <el-input size="small" v-model="scope.row.taxValue"></el-input>
  155. </template>
  156. </el-table-column>
  157. <el-table-column label="备注" width="135px">
  158. <template slot-scope="scope">
  159. <el-input size="small" v-model="scope.row.remark"></el-input>
  160. </template>
  161. </el-table-column>
  162. <el-table-column fixed="right"
  163. label="操作">
  164. <template slot-scope="scope">
  165. <el-button type="default" size="mini" style="display: inline-block;margin-left:0;margin-top: 3px" @click="chanc(scope.$index)">删除</el-button>
  166. </template>
  167. </el-table-column>
  168. </el-table>
  169. </div>
  170. <!-- <el-button class="submits" type="warning" @click="submits">提交</el-button> -->
  171. </div>
  172. </div>
  173. </div>
  174. <!-- 下面部分 -->
  175. <div class="xiamian" ref="xiaomian" style="width: 85%;float:right;background: #fff;position: relative;">
  176. <div v-if="displayTable">
  177. <div style="padding-left:10px;padding-right:10px;">
  178. <div>
  179. <el-form label-width="80px" inline >
  180. <!-- 填报日期 -->
  181. <el-form-item label="单据编号" >
  182. <el-input v-model="code" size="small" placeholder="单据编号" clearable="true"></el-input>
  183. </el-form-item>
  184. <!-- 填报日期 -->
  185. <el-form-item label="填报日期" >
  186. <el-date-picker type="date" size="small" clearable="true" placeholder="选择日期" value-format="yyyy-MM-dd" v-model="date" style="width: 200px;"></el-date-picker>
  187. </el-form-item>
  188. <!-- 费用类型 -->
  189. <el-form-item label="费用类型">
  190. <el-select v-model="type" size="small" placeholder="请选择费用类型" clearable="true" style="width: 150px">
  191. <el-option label="一般费用" value="0"></el-option>
  192. <el-option label="差旅费用" value="1"></el-option>
  193. <el-option label="外包费用" value="2"></el-option>
  194. </el-select>
  195. </el-form-item>
  196. <el-form-item>
  197. <el-button @click="getList" size="small">查找</el-button>
  198. </el-form-item>
  199. </el-form>
  200. </div>
  201. <el-divider ></el-divider>
  202. <!--列表-->
  203. <el-table :data="list" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;">
  204. <el-table-column prop="code" label="票据编号"></el-table-column>
  205. <el-table-column prop="totalAmount" label="金额(元)" ></el-table-column>
  206. <el-table-column prop="ownerName" label="报销人" ></el-table-column>
  207. <el-table-column prop="createDate" label="填报日期" ></el-table-column>
  208. <el-table-column prop="ticketNum" label="发票张数" ></el-table-column>
  209. <el-table-column prop="type" label="票据类型" >
  210. <template slot-scope="scope">
  211. {{feeType[scope.row.type]}}
  212. </template>
  213. </el-table-column>
  214. <el-table-column prop="remark" label="备注" width="250">
  215. <template slot-scope="scope">
  216. <span style="font-size:12px;">{{scope.row.remark}}</span>
  217. </template>
  218. </el-table-column>
  219. <el-table-column label="操作" width="160">
  220. <template slot-scope="scope">
  221. <el-button icon="el-icon-view" circle size="mini" @click.stop.native="downloadByA(scope.row)"></el-button>
  222. <el-button icon="el-icon-edit" circle size="mini" style="margin-left:10px;" @click.stop.native="showEditName(scope.row)"></el-button>
  223. <el-button icon="el-icon-delete" circle size="mini" style="margin-left:10px;" @click.stop.native="deleteItem(scope.row)"></el-button>
  224. </template>
  225. </el-table-column>
  226. </el-table>
  227. <!--工具条-->
  228. <el-col :span="24" class="toolbar">
  229. <el-pagination
  230. @size-change="handleSizeChange"
  231. @current-change="handleCurrentChange"
  232. :page-sizes="[20 , 50 , 80 , 100]"
  233. :page-size="20"
  234. layout="total, sizes, prev, pager, next"
  235. :total="total"
  236. style="float:right;"
  237. ></el-pagination>
  238. </el-col>
  239. </div>
  240. </div>
  241. </div>
  242. <!-- 我的单据报销展示 -->
  243. <el-dialog title="报销单据详情" :visible.sync="dialog" width="1000px">
  244. <!-- 内容主体 -->
  245. <div class="informant"><!-- 报销人 -->
  246. <el-form :model="ParticularsList" label-width="80px">
  247. <el-form-item label="报销人">
  248. <el-input v-show="flg" v-model="ParticularsList.ownerName" disabled ></el-input>
  249. <el-select v-show="!flg" v-model="ParticularsList.ownerId" placeholder="请选择报销人" style="width: 150px" :disabled="flg">
  250. <span v-for="(item, index) in users" :key="index">
  251. <el-option :label="item.name" :value="item.id"></el-option>
  252. </span>
  253. </el-select>
  254. </el-form-item>
  255. <el-form-item label="填报日期">
  256. <!-- <el-input v-model="ParticularsList.createDate" :disabled="flg"></el-input> -->
  257. <el-date-picker type="date" :disabled="flg" placeholder="选择日期" v-model="ParticularsList.createDate" value-format="yyyy-MM-dd" style="width: 200px;"></el-date-picker>
  258. </el-form-item>
  259. <el-form-item label="发票张数">
  260. <el-input v-enter-number v-model="ParticularsList.ticketNum" :disabled="flg"></el-input>
  261. </el-form-item>
  262. <el-form-item label="费用类型" style="width: 270px">
  263. <el-select v-model="ParticularsList.type" placeholder="请选择" :disabled="flg">
  264. <el-option label="一般" :value="0"></el-option>
  265. <el-option label="差旅" :value="1"></el-option>
  266. <el-option label="外包" :value="2"></el-option>
  267. </el-select>
  268. </el-form-item>
  269. <el-form-item label="备注" style="width: 280px">
  270. <el-input v-model="ParticularsList.remark" :disabled="flg"></el-input>
  271. </el-form-item>
  272. <el-form-item label="总成本">
  273. ¥{{ParticularsList.totalAmount | numberToCurrency}}&nbsp;&nbsp;元
  274. </el-form-item>
  275. <!-- <template slot-scope="scope">
  276. <el-input v-model="scope.row.totalAmount" v-if="!flg"></el-input> 元
  277. <span v-else>{{scope.row.totalAmount}} 元</span>
  278. </template> -->
  279. </el-form>
  280. <el-table :data="ParticularsList.invoiceList" border style="width: 100%">
  281. <el-table-column prop="projectId" label="项目" width="155">
  282. <template slot-scope="scope">
  283. <el-select size="small" v-if="!flg" v-model="scope.row.projectId" placeholder="项目" style="width: 130px">
  284. <el-option v-for="(item, index) in projectList" :key="index" :label="item.projectName" :value="item.id" @click="ok(item)"></el-option>
  285. </el-select>
  286. <span v-else>{{projectIdName[scope.$index].projectName}}</span>
  287. </template>
  288. </el-table-column>
  289. <el-table-column prop="happenDate" label="费用日期" width="172">
  290. <template slot-scope="scope">
  291. <el-date-picker size="small" v-if="!flg" v-model="scope.row.happenDate" type="date" style=" width: 145px" value-format="yyyy-MM-dd" placeholder="选择日期">
  292. </el-date-picker>
  293. <span v-else>{{scope.row.happenDate}}</span>
  294. </template>
  295. </el-table-column>
  296. <el-table-column prop="invoiceType" label="发票种类" width="172">
  297. <template slot-scope="scope">
  298. <el-select size="small" v-if="!flg" v-model="scope.row.invoiceType" placeholder="请选择费用类型" style="width: 150px;">
  299. <el-option label="增值税专用发票" :value="0"></el-option>
  300. <el-option label="增值税普通发票" :value="1"></el-option>
  301. </el-select>
  302. <span v-else>{{typeInvoic[scope.row.invoiceType]}}</span>
  303. </template>
  304. </el-table-column>
  305. <el-table-column prop="invoiceType" label="费用类型" width="172">
  306. <template slot-scope="scope">
  307. <el-select v-if="!flg" size="small" v-model="scope.row.expenseType" placeholder="请选择费用类型" style="width: 150px" >
  308. <el-option v-for="(item, index) in expenseTypeList" :key="index" :label="item.typeName" :value="item.typeName" ></el-option>
  309. </el-select>
  310. <span v-else>{{scope.row.expenseType}}</span>
  311. </template>
  312. </el-table-column>
  313. <el-table-column prop="amount" label="费用金额(元)" width="172">
  314. <template slot-scope="scope">
  315. <el-input size="small" v-if="!flg" v-model="scope.row.amount" @change="kan"></el-input>
  316. <span v-else>¥{{scope.row.amount}}</span>
  317. </template>
  318. </el-table-column>
  319. <el-table-column prop="invoiceNo" label="发票号" width="172">
  320. <template slot-scope="scope">
  321. <el-input size="small" v-if="!flg" v-model.number="scope.row.invoiceNo"></el-input>
  322. <span v-else>{{scope.row.invoiceNo}}</span>
  323. </template>
  324. </el-table-column>
  325. <el-table-column prop="taxPercent" label="税率%" width="172">
  326. <template slot-scope="scope">
  327. <el-input size="small" v-if="!flg" v-model="scope.row.taxPercent"></el-input>
  328. <span v-else>{{scope.row.taxPercent}}</span>
  329. </template>
  330. </el-table-column>
  331. <el-table-column prop="taxValue" label="税额(元)" width="172">
  332. <template slot-scope="scope">
  333. <el-input size="small" v-if="!flg" v-model="scope.row.taxValue"></el-input>
  334. <span v-else>¥{{scope.row.taxValue}}</span>
  335. </template>
  336. </el-table-column>
  337. <el-table-column prop="remark" label="备注" width="300">
  338. <template slot-scope="scope">
  339. <el-input size="small" v-if="!flg" v-model="scope.row.remark"></el-input>
  340. <span v-else>{{scope.row.remark}}</span>
  341. </template>
  342. </el-table-column>
  343. <!-- 删除 -->
  344. <el-table-column fixed="right"
  345. label="操作" v-if="!flg">
  346. <template slot-scope="scope">
  347. <el-button type="default" size="mini" style="display: inline-block;margin-left:0;margin-top: 3px" @click="delec(scope.$index)">删除</el-button>
  348. </template>
  349. </el-table-column>
  350. </el-table>
  351. </div>
  352. <!-- 取消和确定 -->
  353. <span slot="footer" class="dialog-footer">
  354. <el-button @click="dialog = false">取 消</el-button>
  355. <el-button v-if="!flg" type="primary" @click="present()">确 定</el-button>
  356. <el-button v-else type="primary" @click="dialog = false">确 定</el-button>
  357. </span>
  358. </el-dialog>
  359. </section>
  360. </template>
  361. <script>
  362. import util from "../../common/js/util";
  363. export default {
  364. name: "expense",
  365. components: {},
  366. props: {},
  367. data() {
  368. return {
  369. expireDate:'2021-08-31',
  370. isTrial:true,
  371. allExpList:[],
  372. expenseTypeList:[],
  373. tian:{a: null,b: null,c: null,d: null,e: null,f: null,g: null,h: null,},
  374. feeType:["一般费用","差旅费用","外包费用"],
  375. typeInvoic: ['增值税专用发票', '增值税普通发票'],
  376. listLoading:false,
  377. tableHeight:0,
  378. list:[],
  379. total:0,
  380. code:null,
  381. date:null,
  382. type:null,
  383. ownerId: null,
  384. users: [], // 人员信息
  385. displayTable: false,
  386. getLists: [],
  387. ProjectList: [], // 项目列表
  388. companyId: [], // 人员的id
  389. dialogVisible: false,
  390. code: null,
  391. addForm:{code:null,ownerId:null,createDate: null, ticketNum:1,type:0,remark:null,totalAmount:0,},
  392. page: 1,
  393. size:20,
  394. form: {happenDate: null,invoiceType:null,amount:null,invoiceNo:null,taxPercent:null,taxValue:null,remark:null},
  395. invoiceList: [],
  396. kkk: null, //
  397. ddId: null,
  398. dldl: [],
  399. isOK: false,
  400. z : null,
  401. value: null,
  402. dialog: false, // 单据查看展示
  403. ParticularsList: [],
  404. projectIdName: [], // 点击查看的项目名
  405. flg: false, // 是否禁用
  406. shuz: ['一般费用填报', '差旅费用填报', '外包费用填报'],
  407. ins: 0
  408. };
  409. },
  410. computed: {},
  411. watch: {},
  412. created() {
  413. let height = window.innerHeight;
  414. this.tableHeight = height - 195;
  415. const that = this;
  416. window.onresize = function temp() {
  417. that.tableHeight = window.innerHeight - 195;
  418. };
  419. },
  420. mounted() {
  421. this.getNextCode();
  422. this.getUsers() // 获取人员信息
  423. this.getList() // 获取单据列表
  424. this.getProjectList();
  425. this.getExpList();
  426. if (this.isTrial) {
  427. this.$message({
  428. message: "当前为体验版,有效期至2021-08-31.",
  429. type: "warning"
  430. });
  431. }
  432. },
  433. filters: {
  434. numberToCurrency(value) {
  435. if (!value) return '0.00'
  436. console.log('v=='+value);
  437. value = value.toFixed(2)
  438. const intPart = Math.trunc(value)
  439. const intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
  440. let floatPart = '.00'
  441. const valueArray = value.toString().split('.')
  442. if (valueArray.length === 2) { // 有小数部分
  443. floatPart = valueArray[1].toString() // 取得小数部分
  444. return intPartFormat + '.' + floatPart
  445. }
  446. return intPartFormat + floatPart
  447. }
  448. },
  449. methods: {
  450. getExpList() {
  451. this.http.post('/expense-type/getList', {
  452. },
  453. res => {
  454. if (res.code == "ok") {
  455. this.allExpList = res.data;
  456. this.expenseTypeList = this.allExpList.filter(a=>a.mainType == 0);
  457. } else {
  458. this.$message({
  459. message: res.msg,
  460. type: "error"
  461. });
  462. }
  463. },
  464. error => {
  465. this.$message({
  466. message: error,
  467. type: "error"
  468. });
  469. });
  470. },
  471. // 单据查看
  472. downloadByA(val) {
  473. this.dialog = true
  474. this.flg = true;
  475. this.getParticulars(val.id);
  476. this.expenseTypeList = this.allExpList.filter(a=>a.mainType == val.type);
  477. },
  478. // 单据编辑
  479. showEditName(val) {
  480. this.dialog = true,
  481. this.flg = false,
  482. delete val.invoiceList
  483. this.getParticulars(val.id)
  484. this.expenseTypeList = this.allExpList.filter(a=>a.mainType == val.type);
  485. },
  486. staffs() { // 控制员工费用报表
  487. this.displayTable = false;
  488. },
  489. bills() { // 控制
  490. this.displayTable = true
  491. this.getList()
  492. },
  493. present(){
  494. this.dialog = false
  495. this.adds();
  496. },
  497. // 删除操作
  498. delec(ids) {
  499. // console.log('删除操作', ids);
  500. this.ParticularsList.invoiceList.splice(ids, 1)
  501. },
  502. adds() {
  503. // happenDate
  504. this.ParticularsList.items = JSON.stringify(this.ParticularsList.invoiceList)//这里要传发票列表的json转string
  505. delete this.ParticularsList.invoiceList
  506. this.http.post('/expense-sheet/add', this.ParticularsList,
  507. res => {
  508. if (res.code == "ok") {
  509. this.bills()
  510. this.$message({
  511. message: '编辑成功',
  512. type: "success"
  513. });
  514. } else {
  515. this.$message({
  516. message: res.msg,
  517. type: "error"
  518. });
  519. }
  520. },
  521. error => {
  522. this.$message({
  523. message: error,
  524. type: "error"
  525. });
  526. });
  527. },
  528. // 获取人员信息
  529. getUsers() {
  530. this.http.post(this.port.manage.list, {
  531. departmentId: -1,
  532. pageIndex: 1,
  533. pageSize: 99999
  534. },
  535. res => {
  536. if (res.code == "ok") {
  537. this.users = res.data.records;
  538. } else {
  539. this.$message({
  540. message: res.msg,
  541. type: "error"
  542. });
  543. }
  544. },
  545. error => {
  546. this.$message({
  547. message: error,
  548. type: "error"
  549. });
  550. });
  551. },
  552. // 提交事件
  553. submits() {
  554. this.add()
  555. this.addForm = {code:null,ownerId:null,createDate: null,type:this.z, ticketNum:1,remark:null,totalAmount:0,}
  556. this.invoiceList = []
  557. },
  558. // 点击新增
  559. addxz() {
  560. this.form = {happenDate: null,invoiceType:null,amount:null,invoiceNo:null,taxPercent:null,taxValue:null,remark:null},
  561. this.invoiceList.push(this.form)
  562. },
  563. //获取项目列表
  564. getProjectList() {
  565. this.http.post( this.port.project.list, {},
  566. res => {
  567. if (res.code == "ok") {
  568. this.projectList = res.data;
  569. } else {
  570. this.$message({
  571. message: res.msg,
  572. type: "error"
  573. });
  574. }
  575. },
  576. error => {
  577. this.$message({
  578. message: error,
  579. type: "error"
  580. });
  581. });
  582. },
  583. //获取单据列表
  584. getList() {
  585. this.http.post('/expense-sheet/list', {pageIndex: this.page,
  586. pageSize: this.size,
  587. code: this.code,
  588. createDate: this.date,
  589. ownerId:this.ownerId,
  590. type:this.type,
  591. },
  592. res => {
  593. if (res.code == "ok") {
  594. this.list = res.data.records;
  595. this.total = res.data.total;
  596. } else {
  597. this.$message({
  598. message: res.msg,
  599. type: "error"
  600. });
  601. }
  602. },
  603. error => {
  604. this.$message({
  605. message: error,
  606. type: "error"
  607. });
  608. });
  609. },
  610. //删除单据
  611. deletes(id) {
  612. this.http.post('/expense-sheet/delete', {id: id},
  613. res => {
  614. if (res.code == "ok") {
  615. this.getList()
  616. this.$message({
  617. message: '删除成功',
  618. type: "success"
  619. });
  620. } else {
  621. this.$message({
  622. message: res.msg,
  623. type: "error"
  624. });
  625. }
  626. },
  627. error => {
  628. this.$message({
  629. message: error,
  630. type: "error"
  631. });
  632. });
  633. },
  634. //创建单据
  635. add() {
  636. if (this.isTrial) {
  637. var date = new Date();
  638. var dateStr = util.formatDate.format(date, 'yyyy-MM-dd');
  639. console.log('date=='+dateStr);
  640. if (dateStr >= this.expireDate) {
  641. this.$message({type:"error", message:'试用版已到期,请联系客服'});
  642. return;
  643. }
  644. }
  645. if (this.invoiceList.length == 0) {
  646. this.$message({type:"error", message:"发票列表不能为空"});
  647. return;
  648. }
  649. if (this.addForm.createDate == null || this.addForm.createDate == '') {
  650. this.$message({type:"error", message:"填报日期不能为空"});
  651. return;
  652. }
  653. // happenDate
  654. this.addForm.items = JSON.stringify(this.invoiceList)//这里要传发票列表的json转string
  655. this.http.post('/expense-sheet/add', this.addForm,
  656. res => {
  657. if (res.code == "ok") {
  658. this.$message({
  659. message: '填报成功',
  660. type: "success"
  661. });
  662. } else {
  663. this.$message({
  664. message: res.msg,
  665. type: "error"
  666. });
  667. }
  668. },
  669. error => {
  670. this.$message({
  671. message: error,
  672. type: "error"
  673. });
  674. });
  675. },
  676. //获取单据编码
  677. getNextCode() {
  678. this.http.post('/expense-sheet/getNextCode', {
  679. },
  680. res => {
  681. if (res.code == "ok") {
  682. this.addForm.code = res.data;
  683. } else {
  684. this.$message({
  685. message: res.msg,
  686. type: "error"
  687. });
  688. }
  689. },
  690. error => {
  691. this.$message({
  692. message: error,
  693. type: "error"
  694. });
  695. });
  696. },
  697. // 获取查看单据的数据
  698. getParticulars(id) {
  699. this.http.post('/expense-sheet/getDetail', {id: id},
  700. res => {
  701. if (res.code == "ok") {this
  702. this.ParticularsList = res.data
  703. var s = []
  704. for(var i = 0; i <= this.ParticularsList.invoiceList.length - 1; i++) {
  705. s.push(this.ParticularsList.invoiceList[i].projectId)
  706. }
  707. this.projectIdName = this.projectList.filter( item => {return s.indexOf(item.id) !== -1})
  708. // this.projectIdName = this.projectList.filter(p => p.id == this.ParticularsList.invoiceList[0].projectId)[0].projectName
  709. console.log(res.data, '查看当前状态');
  710. } else {
  711. this.$message({
  712. message: res.msg,
  713. type: "error"
  714. });
  715. }
  716. },
  717. error => {
  718. this.$message({
  719. message: error,
  720. type: "error"
  721. });
  722. })
  723. },
  724. //分页
  725. handleCurrentChange(val) {
  726. this.page = val;
  727. this.getList();
  728. },
  729. handleSizeChange(val) {
  730. this.size = val;
  731. this.getList();
  732. },
  733. deleteItem(item) {
  734. this.$confirm("确认要删除吗?", "提示", {
  735. //type: 'warning'
  736. }).then(() => {
  737. this.http.post('/expense-sheet/delete', {id:item.id},
  738. res => {
  739. if (res.code == "ok") {
  740. this.getList();
  741. } else {
  742. this.$message({
  743. message: res.msg,
  744. type: "error"
  745. });
  746. }
  747. },
  748. error => {
  749. this.$message({
  750. message: error,
  751. type: "error"
  752. });
  753. });
  754. });
  755. },
  756. // 点击删除
  757. chanc(k) {
  758. this.invoiceList.splice(k, 1)
  759. },
  760. // 双击
  761. dbclick(row, event, column){
  762. this.isOK = true
  763. },
  764. oosk(s){
  765. this.isOK = false
  766. },
  767. ssl(index) {
  768. this.z = index
  769. this.addForm.type = index
  770. this.ins = index;
  771. this.expenseTypeList = this.allExpList.filter(a=>a.mainType == this.ins);
  772. this.getNextCode();
  773. },
  774. // 点击侧边栏事件
  775. side() {
  776. if(this.$refs.side.style.left < '0px') {
  777. this.$refs.sidebars.style.display = 'none'
  778. this.$refs.sid.style.left = '230px'
  779. this.$refs.side.style.left = '1px'
  780. this.$refs.sideI.className = 'el-icon-arrow-right'
  781. this.$refs.staff.style.margin = '20px 20px 0 20px'
  782. this.$refs.staff.style.width = '95%'
  783. this.$refs.xiaomian.style.width = '100%'
  784. this.$refs.headHe.style.paddingLeft = '20px'
  785. } else {
  786. this.$refs.sidebars.style.display = 'block'
  787. this.$refs.sid.style.left = '430px'
  788. this.$refs.side.style.left = '-19px'
  789. this.$refs.sideI.className = 'el-icon-arrow-left'
  790. this.$refs.staff.style.margin = '20px 20px 0 220px'
  791. this.$refs.staff.style.width = '81%'
  792. this.$refs.xiaomian.style.width = '85%'
  793. this.$refs.headHe.style.paddingLeft = '220px'
  794. }
  795. },
  796. // 费用金额失去焦点时触发
  797. shiqu(){
  798. this.addForm.totalAmount = this.invoiceList.reduce((prev, next) => {
  799. return prev + Number(next.amount);
  800. }, 0)
  801. },
  802. kan(){
  803. this.ParticularsList.totalAmount = this.ParticularsList.invoiceList.reduce((prev, next) => {
  804. return prev + Number(next.amount)
  805. }, 0)
  806. }
  807. },
  808. };
  809. </script>
  810. <style scoped>
  811. /* 费用报销标题 */
  812. .headine {
  813. width: 100%;
  814. height: 46.4px;
  815. line-height: 46.4px;
  816. background: #fff;
  817. box-sizing: border-box;
  818. }
  819. .headine h3 {
  820. margin: 0;
  821. display: inline-block;
  822. box-sizing: border-box;
  823. color: #999;
  824. }
  825. .headine p {
  826. display: inline-block;
  827. margin: 0;
  828. }
  829. /* /费用报销标题 */
  830. .sidebars {
  831. height: 100%;
  832. position: absolute;
  833. border-right: 1px solid #E6E6E6;
  834. z-index: 2;
  835. top: 0;
  836. }
  837. .sidebars h3 {
  838. margin: 0;
  839. line-height: 45px;
  840. background: #ffffff;
  841. font-weight: normal;
  842. color: #666;
  843. padding-left: 20px;
  844. }
  845. .sidebars .el-col-12 {
  846. width: 100%
  847. }
  848. .public {
  849. height: 230px;
  850. border-bottom: 1px solid #ddd;
  851. }
  852. .public .el-form-item {
  853. display: inline-block;
  854. }
  855. .pu_button {
  856. text-align: right;
  857. width: 100%;
  858. padding: 24px 30px;
  859. box-sizing: border-box;
  860. }
  861. .pu_bu_x .pu_bu_t {
  862. display: inline-block;
  863. }
  864. .pu_bu_x {
  865. margin-right: 20px;
  866. color: #20A0F7;
  867. cursor: pointer;
  868. }
  869. .pu_bu_t {
  870. color: #20A0F7;
  871. cursor: pointer;
  872. display: block;
  873. float: right;
  874. position:
  875. relative;
  876. top: -20px;
  877. right: 63px;
  878. }
  879. .pu_table {
  880. margin-left: 10px;
  881. }
  882. .pu_bu_t:hover {
  883. color: #7bbcff;
  884. }
  885. .pu_bu_x:hover {
  886. color: #7bbcff;
  887. }
  888. /* 我的单据报销凭证 */
  889. .staff{
  890. border-left: 1px solid #fff;
  891. border-top: 1px solid #fff;
  892. border-right: 1px solid #fff;
  893. background: #fff;
  894. }
  895. /* */
  896. .sdat{
  897. display: inline-block;
  898. width: 260px;
  899. margin-left: 13px;
  900. }
  901. .messages .el-form-item{
  902. display: inline-block;
  903. }
  904. .messages .el-date-editor.el-input, .el-date-editor.el-input__inner{
  905. width: 190px;
  906. }
  907. /* 我的报销单据 */
  908. .search {
  909. position: relative;
  910. top: 20px;
  911. left: 20px;
  912. }
  913. .tables {
  914. margin-top: 50px;
  915. box-sizing: border-box;
  916. padding: 10px;
  917. }
  918. .informant .el-form-item {
  919. display: inline-block;
  920. }
  921. /* 侧边栏收索 */
  922. .side {
  923. position: absolute;
  924. z-index: 2;
  925. border-right: 2px solid #DDDDDD;
  926. height: 100%;
  927. top: 0;
  928. width: 0;
  929. }
  930. .side .spans {
  931. width: 20px;
  932. height: 30px;
  933. border: 1px solid #DDDDDD;
  934. box-sizing: border-box;
  935. position: absolute;
  936. top: 50%;
  937. margin-top: -50%;
  938. text-align: center;
  939. z-index: 1;
  940. background: #fff;
  941. }
  942. .side .spans i{
  943. margin-top: 7px;
  944. color: #C0BFBF
  945. }
  946. .side:hover {
  947. border-right: 2px solid #20A0FF;
  948. }
  949. .side:hover .spans {
  950. border: 1px solid #20A0FF;
  951. background: #20A0FF;
  952. }
  953. .side:hover .spans i{
  954. color: #fff;
  955. }
  956. /* 右边整体页面 */
  957. .contents {
  958. height: 100%;
  959. /* padding: 30px; */
  960. background: #F7F7F7;
  961. /* position: absolute; */
  962. }
  963. .submits {
  964. margin-left: 50%;
  965. }
  966. </style>