expense.vue 31 KB

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