list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. <span v-if="$hasPermissions('B_isShowPrice')">促销品原价总额:<strong>{{ productTotal && (productTotal.totalOrigAmount || productTotal.totalOrigAmount==0) ? productTotal.totalOrigAmount : '--' }}</strong>,</span>
  59. <span v-if="$hasPermissions('B_isShowPrice')">促销品促销价总额:<strong>{{ productTotal && (productTotal.totalAmount || productTotal.totalAmount==0) ? productTotal.totalAmount : '--' }}</strong>,</span>
  60. <span v-if="$hasPermissions('B_isShowPrice')">节省总额:<strong>{{ productTotal && (productTotal.totalEconomizeAmount || productTotal.totalEconomizeAmount==0) ? productTotal.totalEconomizeAmount : '--' }}</strong>,</span>
  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="{ y: tableHeight }"
  76. :defaultLoadData="false"
  77. bordered>
  78. <!-- 操作 -->
  79. <template slot="action" slot-scope="text, record">
  80. <a-button
  81. size="small"
  82. type="link"
  83. v-if="$hasPermissions('B_orderStatistics_detail')"
  84. @click="handleDetail(record)"
  85. class="button-success"
  86. id="orderStatisticsList-edit-btn">详情</a-button>
  87. <span v-else>--</span>
  88. </template>
  89. </s-table>
  90. </a-spin>
  91. <!-- 详情 -->
  92. <orderStatisticsDetailModal :openModal="openModal" :itemSn="itemSn" :nowData="nowData" @close="closeModal" />
  93. </a-card>
  94. </template>
  95. <script>
  96. import getDate from '@/libs/getDate.js'
  97. import { STable, VSelect } from '@/components'
  98. import rangeDate from '@/views/common/rangeDate.vue'
  99. import custList from '@/views/common/custList.vue'
  100. import promoList from '@/views/common/promoList.vue'
  101. import orderStatisticsDetailModal from './detailModal.vue'
  102. import { salesPromoList, salesPromoCount } from '@/api/sales'
  103. export default {
  104. components: { STable, VSelect, orderStatisticsDetailModal, custList, promoList, rangeDate },
  105. data () {
  106. return {
  107. spinning: false,
  108. tableHeight: 0,
  109. advanced: true, // 高级搜索 展开/关闭
  110. disabled: false, // 查询、重置按钮是否可操作
  111. // 查询参数
  112. queryParam: {
  113. beginDate: getDate.getCurrMonthDays().starttime,
  114. endDate: getDate.getCurrMonthDays().endtime,
  115. buyerSn: undefined,
  116. promoActiveSn: undefined,
  117. salesBillNo: '',
  118. billStatus: undefined
  119. },
  120. time: [
  121. getDate.getCurrMonthDays().starttime,
  122. getDate.getCurrMonthDays().endtime
  123. ],
  124. // 加载数据方法 必须为 Promise 对象
  125. loadData: parameter => {
  126. this.disabled = true
  127. this.spinning = true
  128. return salesPromoList(Object.assign(parameter, this.queryParam)).then(res => {
  129. let data
  130. if (res.status == 200) {
  131. data = res.data
  132. this.getTotal(Object.assign(parameter, this.queryParam))
  133. const no = (data.pageNo - 1) * data.pageSize
  134. for (var i = 0; i < data.list.length; i++) {
  135. data.list[i].no = no + i + 1
  136. const promotionActivityNameList = data.list[i].promotionActivityNameList || []
  137. data.list[i].promoName = promotionActivityNameList.join(',')
  138. const totalPromoAmount = data.list[i].totalPromoAmount || 0
  139. const totalEconomizeAmount = data.list[i].totalEconomizeAmount || 0
  140. data.list[i].promoTotal = Number(totalPromoAmount) + Number(totalEconomizeAmount)
  141. }
  142. this.disabled = false
  143. }
  144. this.spinning = false
  145. return data
  146. })
  147. },
  148. openModal: false, // 弹框是否显示
  149. itemSn: '', // 当前sn
  150. nowData: null,
  151. productTotal: null
  152. }
  153. },
  154. computed: {
  155. columns () {
  156. const arr = [
  157. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  158. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  159. { title: '单据来源', dataIndex: 'salesBillSourceDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  160. { title: '销售单号', dataIndex: 'salesBillNo', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  161. { title: '促销名称', dataIndex: 'promoName', align: 'center', width: '9%', customRender: function (text) { return text || '--' }, ellipsis: true },
  162. { title: '客户名称', dataIndex: 'buyerName', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  163. { title: '促销品款数', dataIndex: 'totalPromoCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  164. { title: '促销品数量', dataIndex: 'totalPromoQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  165. // { title: '原价总额', dataIndex: 'promoTotal', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  166. // { title: '促销品总额', dataIndex: 'totalPromoAmount', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  167. // { title: '节省总额', dataIndex: 'totalEconomizeAmount', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  168. { title: '业务状态', dataIndex: 'billStatusDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  169. { title: '操作', scopedSlots: { customRender: 'action' }, width: '4%', align: 'center' }
  170. ]
  171. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  172. arr.splice(8, 0, { title: '原价总额', dataIndex: 'promoTotal', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  173. arr.splice(9, 0, { title: '促销品总额', dataIndex: 'totalPromoAmount', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  174. arr.splice(10, 0, { title: '节省总额', dataIndex: 'totalEconomizeAmount', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  175. }
  176. return arr
  177. }
  178. },
  179. methods: {
  180. // 创建时间 change
  181. dateChange (date) {
  182. this.queryParam.beginDate = date[0]
  183. this.queryParam.endDate = date[1]
  184. },
  185. custChange (obj) {
  186. this.queryParam.buyerSn = obj.key
  187. },
  188. promoChange (obj) {
  189. this.queryParam.promoActiveSn = obj.key
  190. },
  191. // 合计
  192. getTotal (param) {
  193. salesPromoCount(param).then(res => {
  194. if (res.status == 200 && res.data) {
  195. this.productTotal = res.data
  196. } else {
  197. this.productTotal = null
  198. }
  199. })
  200. },
  201. // 详情
  202. handleDetail (row) {
  203. this.itemSn = row.salesBillSn
  204. this.nowData = row
  205. this.openModal = true
  206. },
  207. // 重置
  208. resetSearchForm () {
  209. this.$refs.rangeDate.resetDate(this.time)
  210. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  211. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  212. this.queryParam.buyerSn = undefined
  213. this.queryParam.promoActiveSn = undefined
  214. this.queryParam.salesBillNo = ''
  215. this.queryParam.billStatus = undefined
  216. this.$refs.custList.resetForm()
  217. if (this.advanced) {
  218. this.$refs.promoList.resetForm()
  219. }
  220. this.$refs.table.refresh(true)
  221. },
  222. // 关闭弹框
  223. closeModal () {
  224. this.openModal = false
  225. this.itemSn = ''
  226. this.nowData = null
  227. },
  228. pageInit () {
  229. const _this = this
  230. this.$nextTick(() => { // 页面渲染完成后的回调
  231. _this.setTableH()
  232. })
  233. },
  234. setTableH () {
  235. const tableSearchH = this.$refs.tableSearch.offsetHeight
  236. this.tableHeight = window.innerHeight - tableSearchH - 230
  237. }
  238. },
  239. watch: {
  240. advanced (newValue, oldValue) {
  241. const _this = this
  242. this.$nextTick(() => { // 页面渲染完成后的回调
  243. _this.setTableH()
  244. })
  245. },
  246. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  247. this.setTableH()
  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. if (this.$store.state.app.updateList) {
  264. this.pageInit()
  265. this.$refs.table.refresh()
  266. }
  267. },
  268. beforeRouteEnter (to, from, next) {
  269. next(vm => {})
  270. }
  271. }
  272. </script>