bearerList.vue 11 KB

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