list.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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)">
  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" :isValidateEnabled="true" id="couponDetails-customerSn" @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. v-model="queryParam.ticketState"
  22. ref="sourceType"
  23. id="couponDetails-ticketState"
  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'"
  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. import { ticketQueryPage } from '@/api/ticket'
  75. import { STable, VSelect } from '@/components'
  76. import selectCust from '@/views/common/selectCust.vue'
  77. import writeOffModal from './writeOffModal.vue'
  78. export default {
  79. name: 'UrgentOffsetList',
  80. components: { STable, VSelect, writeOffModal, selectCust },
  81. mixins: [commonMixin],
  82. data () {
  83. return {
  84. spinning: false,
  85. tableHeight: 0,
  86. openModal: false, // 核销弹窗
  87. openShowModal: false, // 促销展示弹窗
  88. time: [],
  89. queryParam: { // 查询条件
  90. queryWord: undefined,
  91. customerSn: undefined,
  92. ticketState: undefined
  93. },
  94. writeOffObj: null,
  95. descInfo: '', // 促销描述
  96. disabled: false, // 查询、重置按钮是否可操作
  97. columns: [
  98. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  99. { title: '销售单号', dataIndex: 'usedBizNo', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  100. { title: '客户名称', dataIndex: 'customerName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  101. { title: '券名称', dataIndex: 'ruleName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  102. { title: '券副标题', dataIndex: 'ruleTitle', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  103. { title: '券金额', dataIndex: 'ticketValue', width: '10%', align: 'right', customRender: text => { return text || text == 0 ? this.toThousands(text, 2) : '--' } },
  104. { title: '促销名称', dataIndex: 'promoActiveName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  105. { title: '有效期', scopedSlots: { customRender: 'dateBox' }, width: '20%', align: 'center' },
  106. { title: '券状态', dataIndex: 'ticketStateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  107. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  108. ],
  109. // 加载数据方法 必须为 Promise 对象
  110. loadData: parameter => {
  111. this.disabled = true
  112. this.spinning = true
  113. return ticketQueryPage(Object.assign(parameter, this.queryParam)).then(res => {
  114. let data
  115. if (res.status == 200) {
  116. data = res.data
  117. const no = (data.pageNo - 1) * data.pageSize
  118. for (var i = 0; i < data.list.length; i++) {
  119. data.list[i].no = no + i + 1
  120. }
  121. this.disabled = false
  122. }
  123. this.spinning = false
  124. return data
  125. })
  126. }
  127. }
  128. },
  129. methods: {
  130. // 核销
  131. handleWriteoff (row) {
  132. this.writeOffObj = {
  133. customerName: row.customerName,
  134. ticketSn: row.ticketSn
  135. }
  136. this.openModal = true
  137. },
  138. // 关闭核销弹窗
  139. closeModal () {
  140. this.writeOffObj = null
  141. this.openModal = false
  142. },
  143. // 客户名称
  144. custChange (obj) {
  145. const _this = this
  146. if (obj && obj.key) {
  147. const cust = obj.row
  148. _this.queryParam.customerSn = cust.customerSn
  149. } else {
  150. _this.$refs.custList.resetForm()
  151. }
  152. },
  153. // 重置
  154. resetSearchForm () {
  155. this.queryParam.queryWord = undefined
  156. this.queryParam.customerSn = undefined
  157. this.queryParam.ticketState = undefined
  158. this.$refs.custList.resetForm()
  159. this.$refs.table.refresh(true)
  160. },
  161. // 初始化
  162. pageInit () {
  163. const _this = this
  164. _this.resetSearchForm()
  165. this.$nextTick(() => { // 页面渲染完成后的回调
  166. _this.setTableH()
  167. })
  168. },
  169. // 计算表格高度
  170. setTableH () {
  171. const tableSearchH = this.$refs.tableSearch.offsetHeight
  172. this.tableHeight = window.innerHeight - tableSearchH - 203
  173. }
  174. },
  175. mounted () {
  176. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  177. this.pageInit()
  178. }
  179. },
  180. watch: {
  181. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  182. this.setTableH()
  183. }
  184. },
  185. activated () {
  186. // 如果是新页签打开,则重置当前页面
  187. if (this.$store.state.app.isNewTab) {
  188. this.pageInit()
  189. }
  190. // 只刷新列表
  191. if (this.$store.state.app.updateList) {
  192. this.pageInit()
  193. this.$refs.table.refresh()
  194. }
  195. },
  196. beforeRouteEnter (to, from, next) {
  197. next(vm => {})
  198. }
  199. }
  200. </script>
  201. <style lang="less">
  202. .couponDetails-wrap{
  203. .red{
  204. color: #ed1c24;
  205. }
  206. .green{
  207. color: #19be6b;
  208. }
  209. .font1{
  210. color:#39f;
  211. }
  212. .desc{
  213. width: 100%;
  214. overflow: hidden;
  215. text-overflow: ellipsis;
  216. display: -webkit-box;
  217. -webkit-line-clamp: 3;
  218. -webkit-box-orient: vertical;
  219. }
  220. }
  221. </style>