list.vue 11 KB

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