reimbursementIsNoTicketList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <div class="page">
  3. <el-form size="small" :inline="true" class="query-form" ref="searchForm" :model="searchForm"
  4. @keyup.enter.native="refreshList()" @submit.native.prevent>
  5. <el-form-item prop="userId" :rules=" [{trigger: 'blur'}]" label="人员">
  6. <SelectUserTree
  7. ref="companyTree"
  8. :props="{
  9. value: 'id', // ID字段名
  10. label: 'name', // 显示名称
  11. children: 'children' // 子级字段名
  12. }"
  13. :url="`/sys/user/treeUserDataAllOffice?type=2`"
  14. :value="searchForm.userId"
  15. :clearable="true"
  16. :accordion="true"
  17. @getValue="(value) => {searchForm.userId=value}"/>
  18. </el-form-item>
  19. <el-form-item label="年份" prop="year" :rules="[{trigger:'blur'}]">
  20. <el-date-picker
  21. v-model="searchForm.year"
  22. type="year"
  23. value-format="yyyy"
  24. placeholder="选择年份">
  25. </el-date-picker>
  26. </el-form-item>
  27. <el-form-item>
  28. <el-button type="primary" @click="refreshList()" size="small" icon="el-icon-search">查询</el-button>
  29. <el-button @click="resetSearch()" size="small" icon="el-icon-refresh-right">重置</el-button>
  30. </el-form-item>
  31. </el-form>
  32. <div class="bg-white top">
  33. <vxe-toolbar :refresh="{query: refreshList}" export print resizable custom>
  34. <template #buttons>
  35. <el-row>
  36. <el-button v-if="hasPermission('accountant:reimbursementBusinessTwo:add')" type="primary" size="small" icon="el-icon-plus"
  37. @click="addBusinessInfo()">新增
  38. </el-button>
  39. <el-button v-if="hasPermission('accountant:reimbursementBusinessTwo:binding')" type="warning" size="small" icon="el-icon-edit"
  40. @click="openDialog($refs.reimbursementUserTable.getCheckboxRecords())"
  41. :disabled="$refs.reimbursementUserTable && $refs.reimbursementUserTable.getCheckboxRecords().length === 0"
  42. plain>批量绑定
  43. </el-button>
  44. <el-button v-if="hasPermission('accountant:reimbursementBusinessTwo:del')" type="danger" size="small" icon="el-icon-delete"
  45. @click="delInvoice()"
  46. :disabled="$refs.reimbursementUserTable && $refs.reimbursementUserTable.getCheckboxRecords().length === 0"
  47. plain>删除
  48. </el-button>
  49. </el-row>
  50. </template>
  51. </vxe-toolbar>
  52. <div style="height: calc(100% - 80px);">
  53. <vxe-table
  54. border="inner"
  55. auto-resize
  56. resizable
  57. height="auto"
  58. :loading="loading"
  59. size="small"
  60. ref="reimbursementUserTable"
  61. show-header-overflow
  62. show-overflow
  63. highlight-hover-row
  64. :menu-config="{}"
  65. :print-config="{}"
  66. :export-config="{
  67. remote: true,
  68. filename: `兴光会计无票报销数据${moment(new Date()).format('YYYY-MM-DD')}`,
  69. sheetName: '兴光会计无票报销数据',
  70. exportMethod: exportMethod,
  71. types: ['xlsx'],
  72. modes: ['current', 'selected', 'all']
  73. }"
  74. :sort-config="{remote:true}"
  75. :data="dataList"
  76. :checkbox-config="{}">
  77. <vxe-column type="checkbox" width="40px"></vxe-column>
  78. <vxe-column width="172px" title="报销人" field="userName" align="center" visible></vxe-column>
  79. <vxe-column width="172px" title="报销人部门" field="userOfficeName" align="center" visible></vxe-column>
  80. <vxe-column width="172px" title="报销年份" field="year" align="center"></vxe-column>
  81. <vxe-column width="172px" title="报销类型" field="reimbursementType" align="center">
  82. <template slot-scope="scope">
  83. <el-tag v-if="scope.row.reimbursementType === '1'"> 正常报销</el-tag>
  84. <el-tag v-if="scope.row.reimbursementType === '2'"> 补差</el-tag>
  85. </template>
  86. </vxe-column>
  87. <vxe-column width="172px" title="实发类型" field="reimbursementFsalary" align="center">
  88. <template slot-scope="scope">
  89. <el-tag v-if="scope.row.reimbursementFsalary === '1'"> 登记不实发</el-tag>
  90. <el-tag v-if="scope.row.reimbursementFsalary === '2'"> 登记并实发</el-tag>
  91. </template>
  92. </vxe-column>
  93. <vxe-column width="172px" title="报销天数" field="reimbursementDay" align="center"></vxe-column>
  94. <vxe-column width="172px" title="报销额度" field="reimbursementAmount" align="center"></vxe-column>
  95. <vxe-column title="操作" width="300px" fixed="right" align="center">
  96. <template slot-scope="scope">
  97. <el-button v-if="hasPermission('accountant:reimbursementBusinessTwo:binding') && scope.row.parentId !== '0'" type="text"
  98. icon="el-icon-plus" size="small" @click="openDialog(scope.row)">绑定业务编号
  99. </el-button>
  100. <el-button v-if="hasPermission('accountant:reimbursementBusinessTwo:del') && scope.row.parentId !== '0'" type="text"
  101. icon="el-icon-delete" size="small" @click="delInvoice(scope.row.id)">删除
  102. </el-button>
  103. </template>
  104. </vxe-column>
  105. </vxe-table>
  106. <vxe-pager
  107. background
  108. size="small"
  109. :current-page="tablePage.currentPage"
  110. :page-size="tablePage.pageSize"
  111. :total="tablePage.total"
  112. :page-sizes="[10, 20, 100, 1000, {label: '全量数据', value: 1000000}]"
  113. :layouts="['PrevPage', 'JumpNumber', 'NextPage', 'FullJump', 'Sizes', 'Total']"
  114. @page-change="currentChangeHandle">
  115. </vxe-pager>
  116. </div>
  117. </div>
  118. <!-- 弹窗, 新增 / 修改 -->
  119. <reimbursementForm ref="reimbursementForm" @refreshDataList="refreshList"></reimbursementForm>
  120. <reimbursementGatheringTimeForm ref="reimbursementGatheringTimeForm"
  121. @refreshDataList="refreshList"></reimbursementGatheringTimeForm>
  122. <reimbursementRatioForm ref="reimbursementRatioForm" @refreshDataList="refreshList"></reimbursementRatioForm>
  123. <reimbursementBusinessForm ref="reimbursementBusinessForm"
  124. @refreshDataList="refreshList"></reimbursementBusinessForm>
  125. <reimbursementInvoiceForm ref="reimbursementInvoiceForm" @refreshDataList="refreshList"></reimbursementInvoiceForm>
  126. <el-dialog
  127. title="选择绑定业务编号"
  128. :visible.sync="dialogVisible"
  129. width="60%">
  130. <el-col :span="12">
  131. <label-wrap>请选择年份:</label-wrap>
  132. <el-select v-model="selectedYear" filterable placeholder="请选择年份" @change="findSelectCodeListByYear">
  133. <el-option
  134. v-for="item in selectYear"
  135. :key="item"
  136. :label="item"
  137. :value="item">
  138. </el-option>
  139. </el-select>
  140. </el-col>
  141. <el-col :span="12">
  142. <label-wrap>请选择业务编号:</label-wrap>
  143. <el-select v-model="selectedCode" filterable clearable placeholder="请选择业务编号" @change="determination($event)">
  144. <el-option
  145. v-for="item in selectCode"
  146. :key="item.id"
  147. :label="item.businessCode"
  148. :value="item.id">
  149. </el-option>
  150. </el-select>
  151. </el-col>
  152. <span slot="footer" class="dialog-footer">
  153. <el-button @click="closeDialog">取 消</el-button>
  154. <el-button type="primary" @click="bindBusinessCode">确 定</el-button>
  155. </span>
  156. </el-dialog>
  157. </div>
  158. </template>
  159. <script>
  160. import ReimbursementSys from '@/api/reimbursementSys/accountant/reimbursementIsNoTicketService'
  161. import SelectUserTree from '@/views/modules/reimbursementSys/utils/treeReimbursementBuinessUserSelect.vue'
  162. import reimbursementForm from './reimbursementForm'
  163. import reimbursementGatheringTimeForm from './reimbursementGatheringTimeForm'
  164. import reimbursementRatioForm from './reimbursementRatioForm'
  165. import reimbursementInvoiceForm from './reimbursementInvoiceForm'
  166. import reimbursementBusinessForm from './reimbursementIsNoTicketForm'
  167. import reimbursementSelect from './reimbursementSelectDialog'
  168. export default {
  169. data () {
  170. return {
  171. dataList: [],
  172. searchForm: {
  173. year: '',
  174. userId: '',
  175. officeType: '2'
  176. },
  177. tablePage: {
  178. total: 0,
  179. currentPage: 1,
  180. pageSize: 10,
  181. orders: [{column: 'a.create_date', asc: false}]
  182. },
  183. loading: false,
  184. dialogVisible: false,
  185. bindObj: [],
  186. selectCode: [],
  187. selectedCode: '',
  188. selectYear: [],
  189. selectedYear: '',
  190. reimbursementAmount: 0,
  191. canReimbursementAmount: 0
  192. }
  193. },
  194. components: {
  195. reimbursementForm,
  196. reimbursementGatheringTimeForm,
  197. reimbursementRatioForm,
  198. reimbursementInvoiceForm,
  199. reimbursementBusinessForm,
  200. reimbursementSelect,
  201. SelectUserTree
  202. },
  203. ReimbursementSys: null,
  204. created () {
  205. this.reimbursementSys = new ReimbursementSys()
  206. },
  207. activated () {
  208. this.refreshList()
  209. },
  210. methods: {
  211. // 获取数据列表
  212. refreshList () {
  213. this.loading = true
  214. this.reimbursementSys.findList({
  215. 'current': this.tablePage.currentPage,
  216. 'size': this.tablePage.pageSize,
  217. 'orders': this.tablePage.orders,
  218. ...this.searchForm
  219. }).then(({data}) => {
  220. this.dataList = data.records
  221. this.tablePage.total = data.total
  222. this.loading = false
  223. })
  224. },
  225. // 当前页
  226. currentChangeHandle ({currentPage, pageSize}) {
  227. this.tablePage.currentPage = currentPage
  228. this.tablePage.pageSize = pageSize
  229. this.refreshList()
  230. },
  231. resetSearch () {
  232. this.$refs.searchForm.resetFields()
  233. this.$nextTick(() => {
  234. this.refreshList()
  235. })
  236. },
  237. // 修改发票信息
  238. modifyInvoice (id) {
  239. this.$refs.reimbursementInvoiceModify.init('modifyInvoice', {id: id, parent: {id: '', name: ''}})
  240. },
  241. // 删除
  242. delInvoice (id) {
  243. let ids = id || this.$refs.reimbursementUserTable.getCheckboxRecords().map(item => {
  244. return item.id
  245. }).join(',')
  246. this.$confirm(`确定删除该记录吗?`, '提示', {
  247. confirmButtonText: '确定',
  248. cancelButtonText: '取消',
  249. type: 'warning'
  250. }).then(() => {
  251. this.loading = true
  252. this.reimbursementSys.deleteInvoice(ids).then(({data}) => {
  253. this.loading = false
  254. this.$message({
  255. message: data,
  256. type: 'success',
  257. duration: 1500
  258. })
  259. this.refreshList()
  260. })
  261. })
  262. },
  263. addBusinessInfo (id, businessCode) {
  264. this.$refs.reimbursementBusinessForm.init('addBusinessInfo', {
  265. id: '',
  266. businessCodeId: '',
  267. businessCode: '',
  268. parent: {id: '', name: ''}
  269. })
  270. },
  271. bindBusinessCode () {
  272. if (this.selectedCode === '') {
  273. this.$message.error('请选择业务编号')
  274. return
  275. }
  276. this.reimbursementSys.modifyBindCode({
  277. 'ids': this.bindObj,
  278. 'businessCode': this.selectedCode,
  279. 'money': this.reimbursementAmount
  280. }).then(({data}) => {
  281. if (!data) {
  282. this.$message.error('可报销额度不足')
  283. } else {
  284. this.closeDialog()
  285. }
  286. })
  287. },
  288. openDialog (obj) {
  289. // eslint-disable-next-line eqeqeq
  290. this.bindObj = obj.id || obj.map(item => {
  291. return item.id
  292. }).join(',')
  293. this.dialogVisible = true
  294. if (obj.length > 1) {
  295. obj.map(item => {
  296. this.reimbursementAmount += parseInt(item.reimbursementAmount)
  297. })
  298. } else {
  299. this.reimbursementAmount = obj.reimbursementAmount
  300. }
  301. this.reimbursementSys.findSelectYearList().then(({data}) => {
  302. this.selectYear = data
  303. this.selectedYear = this.selectYear[0]
  304. this.findSelectCodeListByYear()
  305. })
  306. },
  307. closeDialog () {
  308. this.dialogVisible = false
  309. this.selectedCode = ''
  310. this.refreshList()
  311. this.bindObj = []
  312. this.reimbursementAmount = 0
  313. },
  314. findSelectCodeListByYear () {
  315. this.selectedCode = ''
  316. this.reimbursementSys.findSelectCodeListByYear(this.selectedYear).then(({data}) => {
  317. this.selectCode = data
  318. this.selectedCode = ''
  319. })
  320. },
  321. determination (e) {
  322. for (let i = 0; i < this.selectCode.length; i++) {
  323. if (this.selectCode[i].id === e) {
  324. if (parseInt(this.selectCode[i].canReimbursementAmount) < parseInt(this.reimbursementAmount)) {
  325. this.$message.error('可报销额度不足,可报销额度为' + this.selectCode[i].canReimbursementAmount)
  326. }
  327. }
  328. }
  329. },
  330. // 自定义服务端导出
  331. exportMethod ({ options }) {
  332. // 传给服务端的参数
  333. const params = {
  334. 'current': this.tablePage.currentPage,
  335. 'size': this.tablePage.pageSize,
  336. 'orders': this.tablePage.orders,
  337. ...this.searchForm,
  338. filename: options.filename,
  339. sheetName: options.sheetName,
  340. isHeader: options.isHeader,
  341. original: options.original,
  342. mode: options.mode,
  343. selectIds: options.mode === 'selected' ? options.data.map(item => item.id) : [],
  344. exportFields: options.columns.map(column => column.property)
  345. }
  346. return this.reimbursementSys.exportExcel(params).then((res) => {
  347. // 将二进制流文件写入excel表,以下为重要步骤
  348. this.$utils.downloadExcel(res.data, options.filename)
  349. }).catch(function (err) {
  350. if (err.response) {
  351. console.log(err.response)
  352. }
  353. })
  354. }
  355. }
  356. }
  357. </script>