reimbursementIsNoTicketList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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/treeUserDataByOfficeName?type=2&officeName=兴光评估`"
  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="year" align="center"></vxe-column>
  80. <vxe-column width="172px" title="报销类型" field="reimbursementType" align="center">
  81. <template slot-scope="scope">
  82. <el-tag v-if="scope.row.reimbursementType === '1'"> 正常报销</el-tag>
  83. <el-tag v-if="scope.row.reimbursementType === '2'"> 补差</el-tag>
  84. </template>
  85. </vxe-column>
  86. <vxe-column width="172px" title="报销天数" field="reimbursementDay" align="center"></vxe-column>
  87. <vxe-column width="172px" title="报销额度" field="reimbursementAmount" align="center"></vxe-column>
  88. <vxe-column title="操作" width="300px" fixed="right" align="center">
  89. <template slot-scope="scope">
  90. <el-button v-if="hasPermission('accountant:reimbursementBusinessTwo:binding') && scope.row.parentId !== '0'" type="text"
  91. icon="el-icon-plus" size="small" @click="openDialog(scope.row)">绑定业务编号
  92. </el-button>
  93. <el-button v-if="hasPermission('accountant:reimbursementBusinessTwo:del') && scope.row.parentId !== '0'" type="text"
  94. icon="el-icon-delete" size="small" @click="delInvoice(scope.row.id)">删除
  95. </el-button>
  96. </template>
  97. </vxe-column>
  98. </vxe-table>
  99. <vxe-pager
  100. background
  101. size="small"
  102. :current-page="tablePage.currentPage"
  103. :page-size="tablePage.pageSize"
  104. :total="tablePage.total"
  105. :page-sizes="[10, 20, 100, 1000, {label: '全量数据', value: 1000000}]"
  106. :layouts="['PrevPage', 'JumpNumber', 'NextPage', 'FullJump', 'Sizes', 'Total']"
  107. @page-change="currentChangeHandle">
  108. </vxe-pager>
  109. </div>
  110. </div>
  111. <!-- 弹窗, 新增 / 修改 -->
  112. <reimbursementForm ref="reimbursementForm" @refreshDataList="refreshList"></reimbursementForm>
  113. <reimbursementGatheringTimeForm ref="reimbursementGatheringTimeForm"
  114. @refreshDataList="refreshList"></reimbursementGatheringTimeForm>
  115. <reimbursementRatioForm ref="reimbursementRatioForm" @refreshDataList="refreshList"></reimbursementRatioForm>
  116. <reimbursementBusinessForm ref="reimbursementBusinessForm"
  117. @refreshDataList="refreshList"></reimbursementBusinessForm>
  118. <reimbursementInvoiceForm ref="reimbursementInvoiceForm" @refreshDataList="refreshList"></reimbursementInvoiceForm>
  119. <el-dialog
  120. title="选择绑定业务编号"
  121. :visible.sync="dialogVisible"
  122. width="60%">
  123. <el-col :span="12">
  124. <label-wrap>请选择年份:</label-wrap>
  125. <el-select v-model="selectedYear" filterable placeholder="请选择年份" @change="findSelectCodeListByYear">
  126. <el-option
  127. v-for="item in selectYear"
  128. :key="item"
  129. :label="item"
  130. :value="item">
  131. </el-option>
  132. </el-select>
  133. </el-col>
  134. <el-col :span="12">
  135. <label-wrap>请选择业务编号:</label-wrap>
  136. <el-select v-model="selectedCode" filterable clearable placeholder="请选择业务编号" @change="determination($event)">
  137. <el-option
  138. v-for="item in selectCode"
  139. :key="item.id"
  140. :label="item.businessCode"
  141. :value="item.id">
  142. </el-option>
  143. </el-select>
  144. </el-col>
  145. <span slot="footer" class="dialog-footer">
  146. <el-button @click="closeDialog">取 消</el-button>
  147. <el-button type="primary" @click="bindBusinessCode">确 定</el-button>
  148. </span>
  149. </el-dialog>
  150. </div>
  151. </template>
  152. <script>
  153. import ReimbursementSys from '@/api/reimbursementSys/assess/reimbursementIsNoTicketService'
  154. import SelectUserTree from '@/views/modules/reimbursementSys/utils/treeReimbursementBuinessUserSelect.vue'
  155. import reimbursementForm from './reimbursementForm'
  156. import reimbursementGatheringTimeForm from './reimbursementGatheringTimeForm'
  157. import reimbursementRatioForm from './reimbursementRatioForm'
  158. import reimbursementInvoiceForm from './reimbursementInvoiceForm'
  159. import reimbursementBusinessForm from './reimbursementIsNoTicketForm'
  160. import reimbursementSelect from './reimbursementSelectDialog'
  161. export default {
  162. data () {
  163. return {
  164. dataList: [],
  165. searchForm: {
  166. year: '',
  167. userId: ''
  168. },
  169. tablePage: {
  170. total: 0,
  171. currentPage: 1,
  172. pageSize: 10,
  173. orders: [{column: 'a.create_date', asc: false}]
  174. },
  175. loading: false,
  176. dialogVisible: false,
  177. bindObj: [],
  178. selectCode: [],
  179. selectedCode: '',
  180. selectYear: [],
  181. selectedYear: '',
  182. reimbursementAmount: 0,
  183. canReimbursementAmount: 0
  184. }
  185. },
  186. components: {
  187. reimbursementForm,
  188. reimbursementGatheringTimeForm,
  189. reimbursementRatioForm,
  190. reimbursementInvoiceForm,
  191. reimbursementBusinessForm,
  192. reimbursementSelect,
  193. SelectUserTree
  194. },
  195. ReimbursementSys: null,
  196. created () {
  197. this.reimbursementSys = new ReimbursementSys()
  198. },
  199. activated () {
  200. this.refreshList()
  201. },
  202. methods: {
  203. // 获取数据列表
  204. refreshList () {
  205. this.loading = true
  206. this.reimbursementSys.findList({
  207. 'current': this.tablePage.currentPage,
  208. 'size': this.tablePage.pageSize,
  209. 'orders': this.tablePage.orders,
  210. ...this.searchForm
  211. }).then(({data}) => {
  212. this.dataList = data.records
  213. this.tablePage.total = data.total
  214. this.loading = false
  215. })
  216. },
  217. // 当前页
  218. currentChangeHandle ({currentPage, pageSize}) {
  219. this.tablePage.currentPage = currentPage
  220. this.tablePage.pageSize = pageSize
  221. this.refreshList()
  222. },
  223. resetSearch () {
  224. this.$refs.searchForm.resetFields()
  225. this.$nextTick(() => {
  226. this.refreshList()
  227. })
  228. },
  229. // 修改发票信息
  230. modifyInvoice (id) {
  231. this.$refs.reimbursementInvoiceModify.init('modifyInvoice', {id: id, parent: {id: '', name: ''}})
  232. },
  233. // 删除
  234. delInvoice (id) {
  235. let ids = id || this.$refs.reimbursementUserTable.getCheckboxRecords().map(item => {
  236. return item.id
  237. }).join(',')
  238. this.$confirm(`确定删除该记录吗?`, '提示', {
  239. confirmButtonText: '确定',
  240. cancelButtonText: '取消',
  241. type: 'warning'
  242. }).then(() => {
  243. this.loading = true
  244. this.reimbursementSys.deleteInvoice(ids).then(({data}) => {
  245. this.loading = false
  246. this.$message({
  247. message: data,
  248. type: 'success',
  249. duration: 1500
  250. })
  251. this.refreshList()
  252. })
  253. })
  254. },
  255. addBusinessInfo (id, businessCode) {
  256. this.$refs.reimbursementBusinessForm.init('addBusinessInfo', {
  257. id: '',
  258. businessCodeId: '',
  259. businessCode: '',
  260. parent: {id: '', name: ''}
  261. })
  262. },
  263. bindBusinessCode () {
  264. if (this.selectedCode === '') {
  265. this.$message.error('请选择业务编号')
  266. return
  267. }
  268. this.reimbursementSys.modifyBindCode({
  269. 'ids': this.bindObj,
  270. 'businessCode': this.selectedCode,
  271. 'money': this.reimbursementAmount
  272. }).then(({data}) => {
  273. if (!data) {
  274. this.$message.error('可报销额度不足')
  275. } else {
  276. this.closeDialog()
  277. }
  278. })
  279. },
  280. openDialog (obj) {
  281. // eslint-disable-next-line eqeqeq
  282. this.bindObj = obj.id || obj.map(item => {
  283. return item.id
  284. }).join(',')
  285. this.dialogVisible = true
  286. if (obj.length > 1) {
  287. obj.map(item => {
  288. this.reimbursementAmount += parseInt(item.reimbursementAmount)
  289. })
  290. } else {
  291. this.reimbursementAmount = obj.reimbursementAmount
  292. }
  293. this.reimbursementSys.findSelectYearList().then(({data}) => {
  294. this.selectYear = data
  295. this.selectedYear = this.selectYear[0]
  296. this.findSelectCodeListByYear()
  297. })
  298. },
  299. closeDialog () {
  300. this.dialogVisible = false
  301. this.selectedCode = ''
  302. this.refreshList()
  303. this.bindObj = []
  304. this.reimbursementAmount = 0
  305. },
  306. findSelectCodeListByYear () {
  307. this.selectedCode = ''
  308. this.reimbursementSys.findSelectCodeListByYear(this.selectedYear).then(({data}) => {
  309. this.selectCode = data
  310. this.selectedCode = ''
  311. })
  312. },
  313. determination (e) {
  314. for (let i = 0; i < this.selectCode.length; i++) {
  315. if (this.selectCode[i].id === e) {
  316. if (parseInt(this.selectCode[i].canReimbursementAmount) < parseInt(this.reimbursementAmount)) {
  317. this.$message.error('可报销额度不足,可报销额度为' + this.selectCode[i].canReimbursementAmount)
  318. }
  319. }
  320. }
  321. },
  322. // 自定义服务端导出
  323. exportMethod ({ options }) {
  324. // 传给服务端的参数
  325. const params = {
  326. 'current': this.tablePage.currentPage,
  327. 'size': this.tablePage.pageSize,
  328. 'orders': this.tablePage.orders,
  329. ...this.searchForm,
  330. filename: options.filename,
  331. sheetName: options.sheetName,
  332. isHeader: options.isHeader,
  333. original: options.original,
  334. mode: options.mode,
  335. selectIds: options.mode === 'selected' ? options.data.map(item => item.id) : [],
  336. exportFields: options.columns.map(column => column.property)
  337. }
  338. return this.reimbursementSys.exportExcel(params).then((res) => {
  339. // 将二进制流文件写入excel表,以下为重要步骤
  340. this.$utils.downloadExcel(res.data, options.filename)
  341. }).catch(function (err) {
  342. if (err.response) {
  343. console.log(err.response)
  344. }
  345. })
  346. }
  347. }
  348. }
  349. </script>