winingRecord.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <a-card :bordered="false" class="winRecord-table-page-search-wrapper">
  3. <div class="winRecord-searchForm">
  4. <a-form layout="inline" v-bind="formItemLayout" @keyup.enter.native="$refs.table.refresh(true)">
  5. <a-row :gutter="20">
  6. <a-col :span="6">
  7. <a-form-item label="中奖时间" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  8. <a-range-picker
  9. id="winRecord-time"
  10. v-model="time"
  11. :format="dateFormat"
  12. :placeholder="['开始时间','结束时间']"
  13. :disabledDate="disabledDate"
  14. @change="onChange" />
  15. </a-form-item>
  16. </a-col>
  17. <a-col :span="5">
  18. <a-form-item label="奖品" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  19. <a-input id="winRecord-prizeDesc" allowClear v-model="queryParam.prizeDesc" placeholder="请输入奖品名称" />
  20. </a-form-item>
  21. </a-col>
  22. <a-col :span="5">
  23. <a-form-item label="用户" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  24. <a-input id="winRecord-customerMobile" allowClear v-model="queryParam.customerMobile" placeholder="请输入用户账号" />
  25. </a-form-item>
  26. </a-col>
  27. <a-col :span="4">
  28. <a-form-item label="状态" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  29. <v-select
  30. v-model="queryParam.state"
  31. ref="orderState"
  32. id="winRecord-state"
  33. code="PRIZE_WIN_STATE"
  34. placeholder="请选择状态"
  35. allowClear></v-select>
  36. </a-form-item>
  37. </a-col>
  38. <a-col :span="4">
  39. <a-button class="handle-btn serach-btn" id="winRecord-btn-serach" type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  40. <a-button class="handle-btn" type="" id="winRecord-btn-reset" @click="handleReset">重置</a-button>
  41. </a-col>
  42. </a-row>
  43. </a-form>
  44. </div>
  45. <s-table
  46. ref="table"
  47. size="default"
  48. :rowKey="(record) => record.id"
  49. :columns="columns"
  50. :data="loadData"
  51. bordered>
  52. <!-- 操作 -->
  53. <template slot="action" slot-scope="text, record">
  54. <a-icon
  55. type="rocket"
  56. id="winRecord-sendGood"
  57. title="发货"
  58. v-if="record.prizeType=='GOODS'&&record.state=='WAIT_SEND_EXPRESS'&&$hasPermissions('B_winingRecord_sendGood')"
  59. class="actionBtn icon-blues"
  60. @click="sendGood(record)" />
  61. <a-icon
  62. type="eye"
  63. id="winRecord-handleView"
  64. title="详情"
  65. v-else-if="record.prizeType=='GOODS'&&record.state=='FINISH'&&$hasPermissions('B_winingRecord_view')"
  66. class="actionBtn icon-green"
  67. @click="handleView(record)" />
  68. <span v-else>--</span>
  69. </template>
  70. </s-table>
  71. <!-- 发货 -->
  72. <GoodsLogistics :openModal="openModal" :itemId="itemId" @submit="handleSubmit" @close="openModal=false" />
  73. <!-- 发货详情 -->
  74. <GoodsLogisticsDetail :openModal="openDetailModal" :itemId="itemId" @close="openDetailModal=false" />
  75. </a-card>
  76. </template>
  77. <script>
  78. import { STable, VSelect } from '@/components'
  79. import GoodsLogistics from './GoodsLogistics.vue'
  80. import GoodsLogisticsDetail from './GoodsLogisticsDetail.vue'
  81. import getDate from '@/libs/getDate.js'
  82. import moment from 'moment'
  83. import { getLuckyWinList, sendExpress } from '@/api/luckyDraw.js'
  84. export default {
  85. name: 'WinRecord',
  86. components: { STable, VSelect, GoodsLogistics, GoodsLogisticsDetail },
  87. data () {
  88. return {
  89. openModal: false, // 是否填写物流信息
  90. openDetailModal: false, // 是否查看物流信息
  91. formItemLayout: {
  92. labelCol: { span: 6 },
  93. wrapperCol: { span: 18 }
  94. },
  95. // 查询参数
  96. queryParam: {
  97. beginDate: null, // 开始时间
  98. endDate: null, // 结束时间
  99. prizeDesc: '', // 奖品
  100. customerMobile: '', // 用户
  101. state: '' // 状态
  102. },
  103. itemId: '', // 发货列id
  104. luckyDrawWinNo: '', // 中奖奖品编码
  105. loading: false, // 导出loading
  106. // 表头
  107. columns: [
  108. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  109. { title: '中奖时间', dataIndex: 'winTime', width: 200, align: 'center' },
  110. { title: '活动名称', dataIndex: 'activeName', width: 200, align: 'center' },
  111. { title: '奖品', dataIndex: 'prizeDesc', width: 200, align: 'center' },
  112. { title: '中奖用户', dataIndex: 'customerMobile', width: 200, align: 'center' },
  113. { title: '状态', dataIndex: 'stateDictValue', width: 200, align: 'center' },
  114. { title: '操作', scopedSlots: { customRender: 'action' }, width: 150, align: 'center' }
  115. ],
  116. // 加载数据方法 必须为 Promise 对象
  117. loadData: parameter => {
  118. const searchData = Object.assign(parameter, this.queryParam)
  119. if (this.time && this.time.length) {
  120. searchData.beginDate = moment(this.time[0]).format('YYYY-MM-DD 00:00:00')
  121. searchData.endDate = moment(this.time[1]).format('YYYY-MM-DD 23:59:59')
  122. } else {
  123. searchData.beginDate = ''
  124. searchData.endDate = ''
  125. }
  126. return getLuckyWinList(searchData).then(res => {
  127. if (res.status == 200) {
  128. const no = (res.data.pageNo - 1) * res.data.pageSize
  129. for (let i = 0; i < res.data.list.length; i++) {
  130. const _item = res.data.list[i]
  131. _item.no = no + i + 1
  132. _item.status = _item.status + '' === '1'
  133. }
  134. return res.data
  135. }
  136. })
  137. },
  138. // 将默认当天时间日期回显在时间选择框中
  139. time: [
  140. moment(getDate.getToday().starttime, this.dateFormat),
  141. moment(getDate.getToday().endtime, this.dateFormat)
  142. ],
  143. dateFormat: 'YYYY-MM-DD'
  144. }
  145. },
  146. methods: {
  147. moment,
  148. // 不可选日期
  149. disabledDate (date, dateStrings) {
  150. return date && date.valueOf() > Date.now()
  151. },
  152. // 创建时间change
  153. onChange (dates, dateStrings) {
  154. if ((dates, dateStrings)) {
  155. this.queryParam.beginDate = dateStrings[0]
  156. this.queryParam.endDate = dateStrings[1]
  157. }
  158. },
  159. // 重置
  160. handleReset () {
  161. this.queryParam.beginDate = getDate.getToday().starttime
  162. this.queryParam.endDate = getDate.getToday().endtime
  163. this.time = [
  164. moment(getDate.getToday().starttime, this.dateFormat),
  165. moment(getDate.getToday().endtime, this.dateFormat)
  166. ]
  167. this.queryParam.customerMobile = ''
  168. this.queryParam.prizeDesc = ''
  169. this.queryParam.state = ''
  170. this.$refs.table.refresh(true)
  171. },
  172. // 查看物流详情
  173. handleView (row) {
  174. this.itemId = row.id
  175. this.openDetailModal = true
  176. },
  177. // 发货
  178. sendGood (row) {
  179. this.itemId = row.id
  180. this.luckyDrawWinNo = row.luckyDrawWinNo
  181. this.openModal = true
  182. },
  183. // 提交发货
  184. handleSubmit (data) {
  185. console.log(data, 'ppppppp')
  186. const params = data
  187. params.luckyDrawWinNo = this.luckyDrawWinNo
  188. sendExpress(params).then(res => {
  189. if (res.status == 200) {
  190. this.openModal = false
  191. this.$message.success(res.message)
  192. this.$refs.table.refresh(true)
  193. }
  194. })
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="less" scoped>
  200. .winRecord-table-page-search-wrapper{
  201. .winRecord-searchForm{
  202. .ant-form-inline .ant-form-item{
  203. width: 100%;
  204. }
  205. // 搜索框的下间距
  206. .ant-form-item {
  207. margin-bottom: 10px;
  208. }
  209. .handle-btn{
  210. margin-top: 4px;
  211. margin-bottom: 20px;
  212. }
  213. .serach-btn{
  214. margin-right: 10px;
  215. }
  216. }
  217. }
  218. </style>