list.vue 11 KB

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