list.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <a-card size="small" :bordered="false" class="jg-page-wrap couponDetails-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)" id="couponDetails-form">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="券名称/券副标题">
  10. <a-input id="couponDetails-queryWord" v-model.trim="queryParam.queryWord" allowClear placeholder="请输入券名称/券副标题"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="客户名称">
  15. <selectCust ref="custList" id="couponDetails-customerSn" :isValidateEnabled="true" @change="custChange" v-model="queryParam.customerSn"></selectCust>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="券状态">
  20. <v-select
  21. id="couponDetails-ticketState"
  22. v-model="queryParam.ticketState"
  23. ref="sourceType"
  24. code="TICKET_STATE"
  25. placeholder="请选择优惠券使用状态"
  26. allowClear></v-select>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="4" :sm="24">
  30. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="couponDetails-refresh">查询</a-button>
  31. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="couponDetails-reset">重置</a-button>
  32. </a-col>
  33. </a-row>
  34. </a-form>
  35. </div>
  36. <!-- 列表 -->
  37. <s-table
  38. class="sTable fixPagination"
  39. ref="table"
  40. :style="{ height: tableHeight+84.5+'px' }"
  41. size="small"
  42. :rowKey="(record) => record.id"
  43. :columns="columns"
  44. :data="loadData"
  45. :scroll="{ y: tableHeight }"
  46. :defaultLoadData="false"
  47. bordered>
  48. <!-- 有效期 -->
  49. <template slot="dateBox" slot-scope="text, record">
  50. <span v-if="record.validStartDate&&record.validEndDate">
  51. {{ record.validStartDate }}-{{ record.validEndDate }}
  52. </span>
  53. <span v-else>--</span>
  54. </template>
  55. <!-- 优惠券状态 ticketState 已使用USED 未使用 UNUSED 已过期 DATED -->
  56. <template slot="action" slot-scope="text, record">
  57. <a-button
  58. size="small"
  59. v-if="record.ticketState==='UNUSED'&&$hasPermissions('B_checkTicketBtn')"
  60. type="link"
  61. class="button-success"
  62. @click="handleWriteoff(record)"
  63. :id="'couponDetails-cancel-btn'+record.id">核销</a-button>
  64. <span v-else>--</span>
  65. </template>
  66. </s-table>
  67. </a-spin>
  68. <!-- 核销 -->
  69. <writeOffModal :itemObj="writeOffObj" :openModal="openModal" @ok="$refs.table.refresh()" @close="closeModal"/>
  70. </a-card>
  71. </template>
  72. <script>
  73. import { commonMixin } from '@/utils/mixin'
  74. // 组件
  75. import { STable, VSelect } from '@/components'
  76. import selectCust from '@/views/common/selectCust.vue'
  77. import writeOffModal from './writeOffModal.vue'
  78. // 接口
  79. import { ticketQueryPage } from '@/api/ticket'
  80. export default {
  81. name: 'CouponDetails',
  82. components: { STable, VSelect, writeOffModal, selectCust },
  83. mixins: [commonMixin],
  84. data () {
  85. return {
  86. spinning: false,
  87. tableHeight: 0, // 表格高度
  88. openModal: false, // 核销弹窗
  89. disabled: false, // 查询、重置按钮是否可操作
  90. // 查询条件
  91. queryParam: {
  92. queryWord: undefined, // 券名称/券副标题
  93. customerSn: undefined, // 客户名称sn
  94. ticketState: undefined// 券状态
  95. },
  96. writeOffObj: null, // 核销弹窗回显数据
  97. // 表头
  98. columns: [
  99. { title: '序号', dataIndex: 'no', width: '60px', align: 'center' },
  100. { title: '销售单号', dataIndex: 'usedBizNo', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  101. { title: '客户名称', dataIndex: 'customerName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  102. { title: '货架名称', dataIndex: 'shelfName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  103. { title: '券名称', dataIndex: 'ruleName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  104. { title: '券副标题', dataIndex: 'ruleTitle', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  105. { title: '券金额', dataIndex: 'ticketValue', width: '10%', align: 'right', customRender: text => { return text || text == 0 ? this.toThousands(text, 2) : '--' } },
  106. { title: '促销名称', dataIndex: 'promoActiveName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  107. { title: '有效期', scopedSlots: { customRender: 'dateBox' }, width: '20%', align: 'center' },
  108. { title: '券状态', dataIndex: 'ticketStateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  109. { title: '核销时间', dataIndex: 'usedBizDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  110. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  111. ],
  112. // 加载数据方法 必须为 Promise 对象
  113. loadData: parameter => {
  114. this.disabled = true
  115. this.spinning = true
  116. // 获取优惠券列表数据 有分页
  117. return ticketQueryPage(Object.assign(parameter, this.queryParam)).then(res => {
  118. let data
  119. if (res.status == 200) {
  120. data = res.data
  121. const no = (data.pageNo - 1) * data.pageSize
  122. for (var i = 0; i < data.list.length; i++) {
  123. data.list[i].no = no + i + 1
  124. }
  125. this.disabled = false
  126. }
  127. this.spinning = false
  128. return data
  129. })
  130. }
  131. }
  132. },
  133. methods: {
  134. // 核销
  135. handleWriteoff (row) {
  136. this.writeOffObj = {
  137. customerName: row.customerName,
  138. ticketSn: row.ticketSn
  139. }
  140. this.openModal = true
  141. },
  142. // 关闭核销弹窗
  143. closeModal () {
  144. this.writeOffObj = null
  145. this.openModal = false
  146. },
  147. // 客户名称
  148. custChange (obj) {
  149. const _this = this
  150. if (obj && obj.key) {
  151. const cust = obj.row
  152. _this.queryParam.customerSn = cust.customerSn
  153. } else {
  154. _this.$refs.custList.resetForm()
  155. }
  156. },
  157. // 重置
  158. resetSearchForm () {
  159. this.queryParam.queryWord = undefined
  160. this.queryParam.customerSn = undefined
  161. this.queryParam.ticketState = undefined
  162. this.$refs.custList.resetForm()
  163. this.$refs.table.refresh(true)
  164. },
  165. // 初始化
  166. pageInit () {
  167. const _this = this
  168. _this.resetSearchForm()
  169. this.$nextTick(() => { // 页面渲染完成后的回调
  170. _this.setTableH()
  171. })
  172. },
  173. // 计算表格高度
  174. setTableH () {
  175. const tableSearchH = this.$refs.tableSearch.offsetHeight
  176. this.tableHeight = window.innerHeight - tableSearchH - 203
  177. }
  178. },
  179. mounted () {
  180. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  181. this.pageInit()
  182. }
  183. },
  184. watch: {
  185. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  186. this.setTableH()
  187. }
  188. },
  189. activated () {
  190. // 如果是新页签打开,则重置当前页面
  191. if (this.$store.state.app.isNewTab) {
  192. this.pageInit()
  193. }
  194. // 只刷新列表
  195. if (this.$store.state.app.updateList) {
  196. this.pageInit()
  197. this.$refs.table.refresh()
  198. }
  199. },
  200. beforeRouteEnter (to, from, next) {
  201. next(vm => {})
  202. }
  203. }
  204. </script>
  205. <style lang="less">
  206. .couponDetails-wrap{
  207. .red{
  208. color: #ed1c24;
  209. }
  210. .green{
  211. color: #19be6b;
  212. }
  213. .font1{
  214. color:#39f;
  215. }
  216. .desc{
  217. width: 100%;
  218. overflow: hidden;
  219. text-overflow: ellipsis;
  220. display: -webkit-box;
  221. -webkit-line-clamp: 3;
  222. -webkit-box-orient: vertical;
  223. }
  224. }
  225. </style>