expense.vue 32 KB

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