list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <a-card size="small" :bordered="false" class="chainSalesDetailsCountReportList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form-model
  7. id="chainSalesDetailsCountReportList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="queryParam"
  12. :rules="rules"
  13. :labelCol="labelCol"
  14. :wrapperCol="wrapperCol"
  15. @keyup.enter.native="handleSearch" >
  16. <a-row :gutter="15">
  17. <a-col :md="6" :sm="24">
  18. <a-form-model-item label="审核日期" prop="time">
  19. <rangeDate ref="rangeDate" @change="dateChange" />
  20. </a-form-model-item>
  21. </a-col>
  22. <a-col :md="6" :sm="24">
  23. <a-form-model-item label="连锁店" prop="tenantId">
  24. <a-select
  25. placeholder="请选择连锁店"
  26. id="chainSalesDetailsCountReportList-tenantId"
  27. allowClear
  28. v-model="queryParam.tenantId"
  29. :showSearch="true"
  30. option-filter-prop="children"
  31. :filter-option="filterOption">
  32. <a-select-option v-for="item in linkageGroupData" :key="item.dealerSn" :value="item.dealerSn">{{ item.dealerName }}</a-select-option>
  33. </a-select>
  34. </a-form-model-item>
  35. </a-col>
  36. <a-col :md="2" :sm="8" style="margin-top: 6px;">
  37. <a-checkbox @change="onChange" :default-checked="queryParam.oosFlag">
  38. 包含急件
  39. </a-checkbox>
  40. </a-col>
  41. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  42. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="chainSalesDetailsCountReportList-refresh">查询</a-button>
  43. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chainSalesDetailsCountReportList-reset">重置</a-button>
  44. <a-button
  45. style="margin-left: 5px"
  46. type="primary"
  47. class="button-warning"
  48. @click="handleExport"
  49. :disabled="disabled"
  50. :loading="exportLoading"
  51. v-if="$hasPermissions('B_chainSalesDetailsCountReport_export')"
  52. id="chainSalesDetailsCountReportList-export">导出</a-button>
  53. </a-col>
  54. </a-row>
  55. </a-form-model>
  56. </div>
  57. <!-- 列表 -->
  58. <s-table
  59. class="sTable"
  60. ref="table"
  61. size="small"
  62. :rowKey="(record) => record.targetSn"
  63. rowKeyName="targetSn"
  64. :columns="columns"
  65. :data="loadData"
  66. :defaultLoadData="false"
  67. :showPagination="false"
  68. bordered>
  69. </s-table>
  70. </a-spin>
  71. </a-card>
  72. </template>
  73. <script>
  74. import { commonMixin } from '@/utils/mixin'
  75. import { STable, VSelect } from '@/components'
  76. import rangeDate from '@/views/common/rangeDate.vue'
  77. import { downloadExcel } from '@/libs/JGPrint.js'
  78. import { reportSalesBillDetailTotalList, reportSalesBillDetailTotalExport, linkageGroupList } from '@/api/reportData'
  79. export default {
  80. mixins: [commonMixin],
  81. components: { STable, VSelect, rangeDate },
  82. data () {
  83. const _this = this
  84. return {
  85. spinning: false,
  86. labelCol: { span: 8 },
  87. wrapperCol: { span: 16 },
  88. tableHeight: 0,
  89. queryParam: { // 查询条件
  90. tenantId: undefined,
  91. time: [],
  92. beginDate: '',
  93. endDate: '',
  94. oosFlag: true
  95. },
  96. rules: {
  97. 'time': [{ required: true, message: '请选择审核日期', trigger: 'change' }]
  98. },
  99. disabled: false, // 查询、重置按钮是否可操作
  100. exportLoading: false,
  101. columns: [
  102. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  103. { title: '门店', dataIndex: 'salesTargetName', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  104. {
  105. title: '所有品牌',
  106. children: [
  107. { title: '滤清器', dataIndex: 'lqqAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  108. { title: '雨刮片', dataIndex: 'ygpAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  109. { title: '刹车制动系统', dataIndex: 'scpAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  110. { title: '蓄电池', dataIndex: 'xdcAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  111. { title: 'LED灯', dataIndex: 'ledAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  112. ]
  113. },
  114. {
  115. title: '稳升',
  116. children: [
  117. { title: '点火线圈', dataIndex: 'dhxqAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  118. ]
  119. },
  120. {
  121. title: '德路斯、TBU',
  122. children: [
  123. { title: '润滑油', dataIndex: 'rhyAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  124. { title: '变速箱油', dataIndex: 'bsxyAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  125. { title: '刹车油', dataIndex: 'scyAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  126. ]
  127. },
  128. {
  129. title: '火花塞',
  130. children: [
  131. { title: 'NGK', dataIndex: 'hhsNgkAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  132. { title: '中冠', dataIndex: 'hhsZgAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  133. ]
  134. },
  135. {
  136. title: '轮胎',
  137. children: [
  138. { title: '箭冠', dataIndex: 'ltAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  139. ]
  140. },
  141. {
  142. title: '防冻液',
  143. children: [
  144. { title: '酷兰德', dataIndex: 'fdyAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  145. ]
  146. },
  147. { title: '皮带', dataIndex: 'pdAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  148. { title: '轮子', dataIndex: 'lzAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  149. { title: '其他', dataIndex: 'otherAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  150. { title: '合计', dataIndex: 'totalAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  151. ],
  152. // 加载数据方法 必须为 Promise 对象
  153. loadData: parameter => {
  154. this.disabled = true
  155. const params = Object.assign(parameter, this.queryParam)
  156. this.spinning = true
  157. delete params.time
  158. return reportSalesBillDetailTotalList(params).then(res => {
  159. let data
  160. if (res.status == 200) {
  161. data = res.data
  162. const no = 0
  163. for (var i = 0; i < data.length; i++) {
  164. data[i].no = no + i + 1
  165. }
  166. this.disabled = false
  167. }
  168. this.spinning = false
  169. return data
  170. })
  171. },
  172. linkageGroupData: [],
  173. totalData: null
  174. }
  175. },
  176. methods: {
  177. onChange (e) {
  178. this.queryParam.oosFlag = e.target.checked
  179. },
  180. // 创建时间 change
  181. dateChange (date) {
  182. this.queryParam.time = date
  183. this.queryParam.beginDate = date[0] || ''
  184. this.queryParam.endDate = date[1] || ''
  185. },
  186. // 查询
  187. handleSearch () {
  188. this.$refs.ruleForm.validate(valid => {
  189. if (valid) {
  190. this.$refs.table.refresh(true)
  191. } else {
  192. console.log('error submit!!')
  193. return false
  194. }
  195. })
  196. },
  197. // 重置
  198. resetSearchForm () {
  199. this.queryParam.tenantId = undefined
  200. this.$refs.rangeDate.resetDate()
  201. this.queryParam.time = []
  202. this.queryParam.beginDate = ''
  203. this.queryParam.endDate = ''
  204. this.totalData = null
  205. this.$refs.ruleForm.resetFields()
  206. this.$refs.table.clearTable()
  207. },
  208. // 导出
  209. handleExport () {
  210. const _this = this
  211. this.$refs.ruleForm.validate(valid => {
  212. if (valid) {
  213. const params = _this.queryParam
  214. _this.exportLoading = true
  215. _this.spinning = true
  216. reportSalesBillDetailTotalExport(params).then(res => {
  217. downloadExcel(res, '连锁门店销售明细合计报表')
  218. _this.exportLoading = false
  219. _this.spinning = false
  220. })
  221. } else {
  222. return false
  223. }
  224. })
  225. },
  226. // 连锁店
  227. getLinkageGroup () {
  228. linkageGroupList({}).then(res => {
  229. if (res.status == 200) {
  230. const data = res.data || []
  231. if (data.length > 0) {
  232. this.linkageGroupData = data
  233. } else {
  234. this.linkageGroupData = []
  235. }
  236. } else {
  237. this.linkageGroupData = []
  238. }
  239. })
  240. },
  241. filterOption (input, option) {
  242. return (
  243. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  244. )
  245. },
  246. pageInit () {
  247. this.getLinkageGroup()
  248. }
  249. },
  250. mounted () {
  251. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  252. this.pageInit()
  253. this.resetSearchForm()
  254. }
  255. },
  256. activated () {
  257. // 如果是新页签打开,则重置当前页面
  258. if (this.$store.state.app.isNewTab) {
  259. this.pageInit()
  260. this.resetSearchForm()
  261. }
  262. },
  263. beforeRouteEnter (to, from, next) {
  264. next(vm => {})
  265. }
  266. }
  267. </script>