list.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <a-card size="small" :bordered="false" class="orderStatisticsList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="创建时间">
  9. <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="客户名称" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
  14. <custList ref="custList" id="orderStatisticsList-buyerSn" @change="custChange"></custList>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="销售单号">
  19. <a-input id="orderStatisticsList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  20. </a-form-item>
  21. </a-col>
  22. <template v-if="advanced">
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="促销名称">
  25. <promoList ref="promoList" id="orderStatisticsList-promoActiveSn" @change="promoChange"></promoList>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="业务状态">
  30. <v-select
  31. v-model="queryParam.billStatus"
  32. ref="billStatus"
  33. id="orderStatisticsList-billStatus"
  34. code="SALES_BILL_STATUS"
  35. placeholder="请选择业务状态"
  36. allowClear
  37. ></v-select>
  38. </a-form-item>
  39. </a-col>
  40. </template>
  41. <a-col :md="6" :sm="24">
  42. <span class="table-page-search-submitButtons">
  43. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="orderStatisticsList-refresh">查询</a-button>
  44. <a-button style="margin-left: 5px" @click="resetSearchForm()" :disabled="disabled" id="orderStatisticsList-reset">重置</a-button>
  45. <a @click="advanced=!advanced" style="margin-left: 5px">
  46. {{ advanced ? '收起' : '展开' }}
  47. <a-icon :type="advanced ? 'up' : 'down'"/>
  48. </a>
  49. </span>
  50. </a-col>
  51. </a-row>
  52. </a-form>
  53. </div>
  54. <!-- alert -->
  55. <a-alert type="info" style="margin-bottom:10px">
  56. <div slot="message">
  57. 促销品原价总额:<strong>{{ productTotal && (productTotal.totalOrigAmount || productTotal.totalOrigAmount==0) ? productTotal.totalOrigAmount : '--' }}</strong>,
  58. 促销品促销价总额:<strong>{{ productTotal && (productTotal.totalAmount || productTotal.totalAmount==0) ? productTotal.totalAmount : '--' }}</strong>,
  59. 节省总额:<strong>{{ productTotal && (productTotal.totalEconomizeAmount || productTotal.totalEconomizeAmount==0) ? productTotal.totalEconomizeAmount : '--' }}</strong>,
  60. 总单数:<strong>{{ productTotal && (productTotal.totalRecord || productTotal.totalRecord==0) ? productTotal.totalRecord : '--' }}</strong>,
  61. 总款数:<strong>{{ productTotal && (productTotal.totalCategory || productTotal.totalCategory==0) ? productTotal.totalCategory : '--' }}</strong>,
  62. 总数量:<strong>{{ productTotal && (productTotal.totalQty || productTotal.totalQty==0) ? productTotal.totalQty : '--' }}</strong>
  63. </div>
  64. </a-alert>
  65. <!-- 列表 -->
  66. <s-table
  67. class="sTable"
  68. ref="table"
  69. size="small"
  70. :rowKey="(record) => record.id"
  71. :columns="columns"
  72. :data="loadData"
  73. :scroll="{ x: 1690, y: tableHeight }"
  74. bordered>
  75. <!-- 操作 -->
  76. <template slot="action" slot-scope="text, record">
  77. <a-button
  78. size="small"
  79. type="link"
  80. v-if="$hasPermissions('B_orderStatistics_detail')"
  81. @click="handleDetail(record)"
  82. class="button-success"
  83. id="orderStatisticsList-edit-btn">详情</a-button>
  84. <span v-else>--</span>
  85. </template>
  86. </s-table>
  87. <!-- 详情 -->
  88. <orderStatisticsDetailModal :openModal="openModal" :itemSn="itemSn" :nowData="nowData" @close="closeModal" />
  89. </a-card>
  90. </template>
  91. <script>
  92. import moment from 'moment'
  93. import getDate from '@/libs/getDate.js'
  94. import { STable, VSelect } from '@/components'
  95. import rangeDate from '@/views/common/rangeDate.vue'
  96. import custList from '@/views/common/custList.vue'
  97. import promoList from '@/views/common/promoList.vue'
  98. import orderStatisticsDetailModal from './detailModal.vue'
  99. import { salesPromoList, salesPromoCount } from '@/api/sales'
  100. export default {
  101. components: { STable, VSelect, orderStatisticsDetailModal, custList, promoList, rangeDate },
  102. data () {
  103. return {
  104. advanced: true, // 高级搜索 展开/关闭
  105. disabled: false, // 查询、重置按钮是否可操作
  106. // 查询参数
  107. queryParam: {
  108. beginDate: getDate.getCurrMonthDays().starttime,
  109. endDate: getDate.getCurrMonthDays().endtime,
  110. buyerSn: undefined,
  111. promoActiveSn: undefined,
  112. salesBillNo: '',
  113. billStatus: undefined
  114. },
  115. time: [
  116. getDate.getCurrMonthDays().starttime,
  117. getDate.getCurrMonthDays().endtime
  118. ],
  119. // 表头
  120. columns: [
  121. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  122. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  123. { title: '单据来源', dataIndex: 'salesBillSourceDictValue', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  124. { title: '销售单号', dataIndex: 'salesBillNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  125. { title: '促销名称', dataIndex: 'promoName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  126. { title: '客户名称', dataIndex: 'buyerName', width: 100, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  127. { title: '促销品款数', dataIndex: 'totalPromoCategory', width: 110, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  128. { title: '促销品数量', dataIndex: 'totalPromoQty', width: 110, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  129. { title: '原价总额', dataIndex: 'promoTotal', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  130. { title: '促销品总额', dataIndex: 'totalPromoAmount', width: 110, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  131. { title: '节省总额', dataIndex: 'totalEconomizeAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  132. { title: '业务状态', dataIndex: 'billStatusDictValue', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  133. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  134. ],
  135. // 加载数据方法 必须为 Promise 对象
  136. loadData: parameter => {
  137. this.disabled = true
  138. return salesPromoList(Object.assign(parameter, this.queryParam)).then(res => {
  139. const data = res.data
  140. const no = (data.pageNo - 1) * data.pageSize
  141. for (var i = 0; i < data.list.length; i++) {
  142. data.list[i].no = no + i + 1
  143. const promotionActivityNameList = data.list[i].promotionActivityNameList || []
  144. data.list[i].promoName = promotionActivityNameList.join(',')
  145. const totalPromoAmount = data.list[i].totalPromoAmount || 0
  146. const totalEconomizeAmount = data.list[i].totalEconomizeAmount || 0
  147. data.list[i].promoTotal = Number(totalPromoAmount) + Number(totalEconomizeAmount)
  148. }
  149. this.disabled = false
  150. this.getTotal(Object.assign(parameter, this.queryParam))
  151. return data
  152. })
  153. },
  154. openModal: false, // 弹框是否显示
  155. itemSn: '', // 当前sn
  156. nowData: null,
  157. productTotal: null
  158. }
  159. },
  160. computed: {
  161. tableHeight () {
  162. return window.innerHeight - (this.advanced ? 430 : 375)
  163. }
  164. },
  165. methods: {
  166. // 创建时间 change
  167. dateChange (date) {
  168. this.queryParam.beginDate = date[0]
  169. this.queryParam.endDate = date[1]
  170. },
  171. custChange (obj) {
  172. this.queryParam.buyerSn = obj.key
  173. },
  174. promoChange (obj) {
  175. this.queryParam.promoActiveSn = obj.key
  176. },
  177. // 合计
  178. getTotal (param) {
  179. salesPromoCount(param).then(res => {
  180. if (res.status == 200 && res.data) {
  181. this.productTotal = res.data
  182. } else {
  183. this.productTotal = null
  184. }
  185. })
  186. },
  187. // 详情
  188. handleDetail (row) {
  189. this.itemSn = row.salesBillSn
  190. this.nowData = row
  191. this.openModal = true
  192. },
  193. // 重置
  194. resetSearchForm () {
  195. this.$refs.rangeDate.resetDate(this.time)
  196. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  197. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  198. this.queryParam.buyerSn = undefined
  199. this.queryParam.promoActiveSn = undefined
  200. this.queryParam.salesBillNo = ''
  201. this.queryParam.billStatus = undefined
  202. this.$refs.custList.resetForm()
  203. if (this.advanced) {
  204. this.$refs.promoList.resetForm()
  205. }
  206. this.$refs.table.refresh(true)
  207. },
  208. // 关闭弹框
  209. closeModal () {
  210. this.openModal = false
  211. this.itemSn = ''
  212. this.nowData = null
  213. }
  214. },
  215. beforeRouteEnter (to, from, next) {
  216. next(vm => {
  217. })
  218. }
  219. }
  220. </script>