bearerList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="searchBoxNormal">
  4. <div class="table-page-search-wrapper" ref="tableSearch">
  5. <a-form-model
  6. id="expenseAccountBearerList-form"
  7. ref="ruleForm"
  8. class="form-model-con"
  9. layout="inline"
  10. :rules="rules"
  11. :model="queryParam"
  12. @keyup.enter.native="handleSearch">
  13. <a-row :gutter="15">
  14. <a-col :md="6" :sm="24">
  15. <a-form-model-item label="统计月份" prop="months">
  16. <a-input id="expenseAccountBearerList-months" :value="queryParam.months?queryParam.months.join(','):''" placeholder="请选择月份(多选)" style="width: 100%;">
  17. <span style="cursor: pointer;" slot="addonAfter" @click="openMonth">
  18. 点击选择
  19. </span>
  20. </a-input>
  21. </a-form-model-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-form-model-item label="费用承担方类型" prop="targetType">
  25. <v-select
  26. code="EXPENSE_ACCOUNT_DETAIL_SPLIT_OBJ_TYPE"
  27. allowClear
  28. style="width: 100%;"
  29. id="expenseAccountBearerList-targetType"
  30. v-model="queryParam.targetType"
  31. @change="targetChange"
  32. placeholder="请选择费用承担方类型"
  33. ></v-select>
  34. </a-form-model-item>
  35. </a-col>
  36. <a-col :md="6" :sm="24">
  37. <a-form-model-item label="费用承担方名称" prop="targetSn">
  38. <!-- 部门 -->
  39. <department id="expenseAccountBearerList-targetSn" v-show="queryParam.targetType=='DEPARTMENT'" style="width: 100%;" placeholder="请选择费用承担方名称" v-model="queryParam.targetSn"></department>
  40. <!-- 经销商 -->
  41. <custList
  42. v-show="queryParam.targetType=='CUSTOMER'"
  43. ref="custList"
  44. cooperateFlag="1"
  45. @change="custChange"
  46. id="expenseAccountBearerList-custList"
  47. placeholder="请选择经销商(输入名称搜索)"></custList>
  48. <a-select v-if="!queryParam.targetType" placeholder="请选择费用承担方名称"></a-select>
  49. </a-form-model-item>
  50. </a-col>
  51. <a-col :md="6" :sm="24">
  52. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="expenseAccountBearerList-refresh">查询</a-button>
  53. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="expenseAccountBearerList-reset">重置</a-button>
  54. <a-button
  55. style="margin-left: 5px"
  56. type="primary"
  57. class="button-warning"
  58. @click="handleExport"
  59. :disabled="disabled"
  60. v-if="$hasPermissions('B_expenseCollectExportByTarget')"
  61. :loading="exportLoading"
  62. id="expenseAccountBearerList-export">导出</a-button>
  63. </a-col>
  64. </a-row>
  65. </a-form-model>
  66. </div>
  67. </a-card>
  68. <a-card>
  69. <a-spin :spinning="spinning" tip="Loading...">
  70. <!-- 列表 -->
  71. <s-table
  72. class="sTable fixPagination"
  73. ref="table"
  74. size="small"
  75. :defaultLoadData="false"
  76. :rowKey="(record) => record.no"
  77. rowKeyName="no"
  78. :columns="columns"
  79. :showPagination="false"
  80. :data="loadData"
  81. :style="{ height: tableHeight+84.5+'px' }"
  82. :scroll="{ y: tableHeight-30}"
  83. bordered>
  84. <template slot="footer">
  85. <table v-if="totalData">
  86. <tr>
  87. <th colspan="5" width="42%" style="text-align: right;">汇总:</th>
  88. <th v-for="item in totalMData" width="6%" style="text-align: center;">{{ toThousands(item) }}</th>
  89. <th width="6%" style="text-align: center;">{{ toThousands(totalData['COUNT_PRICE']) }}</th>
  90. </tr>
  91. </table>
  92. </template>
  93. </s-table>
  94. </a-spin>
  95. <!-- 导出提示框 -->
  96. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  97. <selectMonth ref="months" @ok="getDateValue"></selectMonth>
  98. </a-card>
  99. </div>
  100. </template>
  101. <script>
  102. import { commonMixin } from '@/utils/mixin'
  103. import { hdExportExcel } from '@/libs/exportExcel'
  104. // 组件
  105. import { STable, VSelect } from '@/components'
  106. import selectMonth from './selectMonth.vue'
  107. import reportModal from '@/views/common/reportModal.vue'
  108. import department from '@/views/expenseManagement/expenseReimbursement/department.js'
  109. import custList from '@/views/common/custList.vue'
  110. // 接口
  111. import { expenseCollectReportQueryPageByTarget, expenseCollectReportQueryCountByTarget, expenseCollectReportExportByTarget } from '@/api/reportData'
  112. export default {
  113. name: 'ExpenseAccountBearerList',
  114. mixins: [commonMixin],
  115. components: { STable, VSelect, selectMonth, department, custList, reportModal },
  116. data () {
  117. return {
  118. spinning: false,
  119. showExport: false, // 导出弹窗初始值
  120. disabled: false, // 查询、重置按钮是否可操作
  121. exportLoading: false, // 导出按钮加载状态
  122. tableHeight: 0, // 表格高度
  123. queryParam: {
  124. months: undefined, // 月
  125. targetType: undefined, // 费用承担方类型
  126. targetSn: undefined// 费用承担方
  127. },
  128. rules: {
  129. 'months': [{ required: true, message: '请选择月份', trigger: 'change' }],
  130. 'targetType': [{ required: true, message: '请选择费用承担方类型', trigger: 'change' }],
  131. 'targetSn': [{ required: true, message: '请选择费用承担方名称', trigger: 'change' }]
  132. },
  133. columns: [], // 表头数据
  134. // 加载数据方法 必须为 Promise 对象
  135. loadData: parameter => {
  136. const _this = this
  137. _this.disabled = true
  138. _this.spinning = true
  139. const paramsPage = Object.assign(parameter, this.queryParam)
  140. // 获取列表数据 无分页
  141. return expenseCollectReportQueryPageByTarget(paramsPage).then(res => {
  142. let data
  143. if (res.status == 200) {
  144. data = res.data
  145. // 计算列表序号
  146. const no = (data.pageNo - 1) * data.pageSize
  147. for (var i = 0; i < data.list.length; i++) {
  148. data.list[i].no = no + i + 1
  149. }
  150. }
  151. _this.spinning = false
  152. _this.disabled = false
  153. // 统计
  154. this.getCount(paramsPage)
  155. return data
  156. })
  157. },
  158. totalData: null, // 统计数据
  159. totalMData: []// 汇总数据
  160. }
  161. },
  162. methods: {
  163. getColumns () {
  164. const _this = this
  165. const arr = [
  166. {
  167. title: '单据类型',
  168. dataIndex: 'BILL_TYPE',
  169. width: '8%',
  170. align: 'center',
  171. customRender: function (text) {
  172. return text || '--'
  173. }
  174. },
  175. {
  176. title: '费用类型',
  177. dataIndex: 'COST_TYPE_NAME',
  178. align: 'center',
  179. customRender: function (text) {
  180. return text || '--'
  181. },
  182. width: '8%',
  183. ellipsis: true
  184. },
  185. {
  186. title: '费用承担方类型',
  187. dataIndex: 'TARGET_TYPE',
  188. width: '10%',
  189. align: 'center',
  190. customRender: function (text) {
  191. return ((text || text == 0) ? text : '--')
  192. }
  193. },
  194. {
  195. title: '费用承担方名称',
  196. dataIndex: 'TARGET_NAME',
  197. width: '10%',
  198. align: 'center',
  199. customRender: function (text) {
  200. return ((text || text == 0) ? text : '--')
  201. }
  202. },
  203. {
  204. title: '区域',
  205. dataIndex: 'SUBAREA_NAME',
  206. width: '6%',
  207. align: 'center',
  208. customRender: function (text) {
  209. return ((text || text == 0) ? text : '--')
  210. }
  211. }
  212. ]
  213. if (this.queryParam.months) {
  214. // 月份排序
  215. this.queryParam.months.sort((a, b) => {
  216. return a.replace('-', '') - b.replace('-', '')
  217. })
  218. for (let i = 0; i < this.queryParam.months.length; i++) {
  219. const item = this.queryParam.months[i]
  220. arr.push({
  221. title: item.replace('-', '年') + '月',
  222. dataIndex: 'M_' + item.replace('-', '_'),
  223. width: '6%',
  224. align: 'center',
  225. customRender: function (text) {
  226. return ((text || text == 0) ? _this.toThousands(text) : '--')
  227. }
  228. })
  229. }
  230. }
  231. arr.push({
  232. title: '总计',
  233. dataIndex: 'COUNT_PRICE',
  234. width: '6%',
  235. align: 'center',
  236. customRender: function (text) {
  237. return ((text || text == 0) ? _this.toThousands(text) : '--')
  238. }
  239. })
  240. this.columns = arr
  241. },
  242. // 选择月份
  243. openMonth () {
  244. this.$refs.months.showModal(this.queryParam.months, 'm1')
  245. },
  246. // 选择月份完成
  247. getDateValue (data) {
  248. this.queryParam.months = data
  249. },
  250. // 费用承担方类型 change
  251. targetChange (v) {
  252. // 清空费用承担方名称
  253. this.queryParam.targetSn = undefined
  254. this.$refs.custList.resetForm()
  255. },
  256. // 经销商 change
  257. custChange (v, obj, id) {
  258. this.queryParam.targetSn = v.key
  259. this.$refs.ruleForm.validateField('targetSn')
  260. },
  261. // 查询
  262. handleSearch () {
  263. const _this = this
  264. this.$refs.ruleForm.validate(valid => {
  265. if (valid) {
  266. _this.getColumns()
  267. _this.$refs.table.refresh(true)
  268. } else {
  269. _this.$message.error('请选择查询条件')
  270. return false
  271. }
  272. })
  273. },
  274. // 获取统计数据
  275. getCount (params) {
  276. this.totalData = null
  277. this.totalMData = []
  278. expenseCollectReportQueryCountByTarget(params).then(res => {
  279. this.totalData = res.data
  280. for (var key in res.data) {
  281. if (key.indexOf('M_') >= 0) {
  282. this.totalMData.push(res.data[key])
  283. }
  284. }
  285. })
  286. },
  287. // 重置
  288. resetSearchForm () {
  289. this.queryParam = {
  290. months: undefined,
  291. targetType: undefined,
  292. targetSn: undefined
  293. }
  294. this.totalData = null
  295. this.totalMData = []
  296. this.$refs.ruleForm.resetFields()
  297. this.$refs.table.clearTable()
  298. this.getColumns()
  299. },
  300. // 导出
  301. handleExport () {
  302. const _this = this
  303. this.$refs.ruleForm.validate(valid => {
  304. if (valid) {
  305. _this.showExport = true
  306. const params = _this.queryParam
  307. _this.$store.state.app.curActionPermission = 'B_expenseCollectExportByTarget'
  308. _this.exportLoading = true
  309. _this.spinning = true
  310. hdExportExcel(expenseCollectReportExportByTarget, params, '费用汇总报表(按承担方)', function () {
  311. _this.exportLoading = false
  312. _this.spinning = false
  313. _this.$store.state.app.curActionPermission = ''
  314. })
  315. } else {
  316. return false
  317. }
  318. })
  319. },
  320. // 初始化
  321. pageInit () {
  322. this.getColumns()
  323. this.setTableH()
  324. },
  325. // 计算表格高度
  326. setTableH () {
  327. const tableSearchH = this.$refs.tableSearch.offsetHeight
  328. this.tableHeight = window.innerHeight - tableSearchH - 240
  329. }
  330. },
  331. mounted () {
  332. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  333. this.pageInit()
  334. }
  335. },
  336. activated () {
  337. // 如果是新页签打开,则重置当前页面
  338. if (this.$store.state.app.isNewTab) {
  339. this.pageInit()
  340. }
  341. },
  342. beforeRouteEnter (to, from, next) {
  343. next(vm => {})
  344. }
  345. }
  346. </script>
  347. <style style="less">
  348. </style>