企微助手 ,仓库名 短剧

promotePlaylet.vue 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <div class="promotePlaylet-wrap" v-loading="pageLoading">
  3. <div class="screenBox flex">
  4. <!-- <div />
  5. <el-button type="primary" size="mini" @click="onClickExport">导出Excel</el-button> -->
  6. </div>
  7. <!-- S 筛选区 -->
  8. <div class="screenBox filter-wrap">
  9. <!-- 日期 -->
  10. <datePicker style="margin-right: 30px;" :reset="reset" title="自定义" :quickFlag="true" :afferent_time="default_time" :clearFlag="false" @changeTime="onChangeTime" />
  11. <!-- 剧集 -->
  12. <selectPlaylet v-model="filter.playlet" style="margin-right: 30px;margin-left: -60px;" @change="onChangePlaylet" />
  13. <!-- <div class="flex">
  14. <el-button size="mini" type="primary" plain @click="onClickSearch">确定</el-button>
  15. <el-button size="mini" plain @click="onClickReset">重置</el-button>
  16. </div> -->
  17. </div>
  18. <!-- E 筛选区 -->
  19. <!-- S 表 -->
  20. <!-- S 明细表 detailsTable -->
  21. <div v-loading="detailLoading">
  22. <ux-grid class="detailsTable" ref="detailsTable" :border="false" @row-click="() => { return }" :header-cell-style="getHeaderCellStyle" show-footer-overflow="tooltip" show-overflow="tooltip" size="mini" :height="height">
  23. <ux-table-column v-for="(item, idx) in detailsTableCol" :key="item.column + idx" :resizable="true" :field="item.column" :title="item.name" :min-width="item.min_width ? item.min_width : 140" :fixed="item.fixed ? item.fixed : ''" align="center">
  24. <template #header>
  25. <div class="flex-align-jus-center">
  26. {{ item.name }}
  27. <el-tooltip v-if="item.notes" :content="item.notes" placement="top">
  28. <div><i class="el-icon-question"></i></div>
  29. </el-tooltip>
  30. <div v-if="item.enable_to_sort" class="sort-wrap">
  31. <i class="el-icon-caret-top" :class="{ 'active': filter.sort_field === item.column && filter.sort_type === 'asc' }" @click="onClickSort(item.column, 'asc')" />
  32. <i class="el-icon-caret-bottom" :class="{ 'active': filter.sort_field === item.column && filter.sort_type === 'desc' }" @click="onClickSort(item.column, 'desc')" />
  33. </div>
  34. </div>
  35. </template>
  36. <template v-slot="{ row }">
  37. <!-- 时间 -->
  38. <div v-if="item.column === 'ref_date'">
  39. <span>{{ row['expense_date'] }}</span><span v-if="row['expense_date_end']"> ~ {{ row['expense_date_end'] }}</span>
  40. </div>
  41. <!-- 其他 -->
  42. <span v-else>{{ row[item.column] ? $formatNum(row[item.column]) : '-' }}</span>
  43. </template>
  44. </ux-table-column>
  45. </ux-grid>
  46. <div class="pagination" v-show="pagination.total > 0">
  47. <el-pagination background :current-page="pagination.page" @current-change="handleCurrentChange" layout="prev, pager, next" :page-count='Number(pagination.pages)' />
  48. </div>
  49. </div>
  50. <!-- E 明细表 detailsTable -->
  51. <!-- E 表 -->
  52. </div>
  53. </template>
  54. <script>
  55. import datePicker from '@/components/assembly/screen/datePicker.vue'
  56. import selfChannel from '@/components/assembly/screen/channel.vue'
  57. import selectPlaylet from './selectPlaylet.vue'
  58. import _lodash from 'lodash'
  59. export default {
  60. components: {
  61. datePicker,
  62. selfChannel,
  63. selectPlaylet,
  64. },
  65. data () {
  66. const DEFAULT_TIME = [this.$getDay(-30, false), this.$getDay(0, false)]
  67. return {
  68. default_time: DEFAULT_TIME,
  69. reset: false,
  70. height: '',
  71. pageLoading: false,
  72. detailLoading: false,
  73. detailsTableCol: [],
  74. pagination: {
  75. page: 1,
  76. page_size: 20,
  77. pages: 0,
  78. total: 0,
  79. },
  80. filter: {
  81. time: DEFAULT_TIME, // 自定义日期
  82. playlet: '', // 剧集
  83. sort_field: 'paid', // 排序字段 - 默认值
  84. sort_type: 'desc', // 升序/降序
  85. },
  86. }
  87. },
  88. created () {
  89. this.initTableHeight()
  90. // this.handleGetList()
  91. },
  92. methods: {
  93. initTableHeight() {
  94. this.height = document.documentElement.clientHeight - 200 > 400 ? document.documentElement.clientHeight - 200 : 400
  95. },
  96. // 获取列表数据
  97. async handleGetList() {
  98. try {
  99. this.detailLoading = true
  100. const params = {
  101. page: this.pagination.page,
  102. page_size: this.pagination.page_size,
  103. start_date: this.filter.time[0],
  104. end_date: this.filter.time[1],
  105. playlet: this.filter.playlet,
  106. sort_field: this.filter.sort_field,
  107. sort_type: this.filter.sort_type,
  108. }
  109. const url = `${this.URL.BASEURL}${this.URL.dataBoard_loseUser_account}`
  110. const { data: res = {} } = await this.$axios.get(url, { params })
  111. if (res && res.errno == 0) {
  112. res.rst.extra[0].fixed = 'left' // 前2列固定左侧
  113. res.rst.extra[1].fixed = 'left' // 前2列固定左侧
  114. const detailsTableCol = []
  115. res.rst.extra.forEach(item => {
  116. if (item.name && item.name.length > 6) { // 长字符宽度
  117. item['min_width'] = item.name.length * 20
  118. }
  119. detailsTableCol.push(item) // 收集普通表头
  120. })
  121. this.detailsTableCol = Object.freeze(detailsTableCol)
  122. await this.$nextTick()
  123. const detailsTableList = Array.isArray(res.rst.data) ? res.rst.data : []
  124. this.$refs.detailsTable.reloadData(detailsTableList)
  125. this.pagination.total = res.rst.pageInfo.total
  126. this.pagination.pages = res.rst.pageInfo.pages
  127. } else if (res.errno != 4002) {
  128. this.$message.warning(res.err)
  129. this.$refs.detailsTable.reloadData([])
  130. this.pagination.total = 0
  131. this.pagination.pages = 0
  132. }
  133. } catch (error) {
  134. console.log(error)
  135. this.$refs.detailsTable.reloadData([])
  136. this.pagination.total = 0
  137. this.pagination.pages = 0
  138. } finally {
  139. this.detailLoading = false
  140. }
  141. },
  142. // 监听时间筛选变化
  143. onChangeTime(time) {
  144. this.filter.time = Array.isArray(time) ? time : []
  145. this.pagination.page = 1
  146. // this.handleGetList()
  147. },
  148. // 监听剧集筛选变化
  149. onChangePlaylet(val) {
  150. this.filter.playlet = val
  151. this.pagination.page = 1
  152. // this.handleGetList()
  153. },
  154. // 监听当前页变化
  155. handleCurrentChange(currentPage) {
  156. this.pagination.page = currentPage
  157. // this.handleGetList()
  158. },
  159. // 监听点击"确定(搜索)"按钮
  160. onClickSearch() {
  161. this.pagination.page = 1
  162. // this.handleGetList()
  163. },
  164. // 监听排序变化
  165. onClickSort(sort_field, sort_type) {
  166. // sort_type:升序asc、降序desc
  167. if (this.filter.sort_field === sort_field) {
  168. if (this.filter.sort_type === sort_type) {
  169. // 点击的是当前排序字段 && 是当前排序类型 => 重置 取消排序
  170. this.filter.sort_field = 'paid'
  171. this.filter.sort_type = 'desc'
  172. } else {
  173. // 点击的是当前排序字段 && 非当前排序类型 => 设置排序类型
  174. this.filter.sort_type = sort_type
  175. }
  176. } else {
  177. // 点击的不是当前排序字段 => 设置排序字段和类型
  178. this.filter.sort_field = sort_field
  179. this.filter.sort_type = sort_type
  180. }
  181. // 后端排序 => 获取最新数据
  182. this.pagination.page = 1
  183. // this.handleGetList()
  184. },
  185. // 监听点击"重置"按钮
  186. onClickReset() {
  187. this.reset = !this.reset
  188. this.filter.time = this.default_time
  189. this.filter.playlet = ''
  190. this.filter.sort_field = 'paid'
  191. this.filter.sort_type = 'desc'
  192. this.pagination.page = 1
  193. // this.handleGetList()
  194. },
  195. getHeaderCellStyle() {
  196. return { backgroundColor: '#FFFFFF !important', border: 'none!important' }
  197. },
  198. }
  199. }
  200. </script>
  201. <style lang="scss" scoped>
  202. .promotePlaylet-wrap {
  203. min-width: 1125px;
  204. }
  205. .screenBox {
  206. position: relative;
  207. background: #fff;
  208. padding: 5px 20px;
  209. }
  210. .mt-10 {
  211. margin-top: 10px;
  212. }
  213. .ml-10 {
  214. margin-left: 10px;
  215. }
  216. .filter-wrap {
  217. display: flex;
  218. align-items: center;
  219. flex-wrap: wrap;
  220. padding-bottom: 10px;
  221. & > div {
  222. margin: 0 10px 10px 0;
  223. }
  224. & > button {
  225. margin: -10px 0 0 10px;
  226. }
  227. .el-button+.el-button {
  228. margin-left: 10px;
  229. }
  230. }
  231. .sort-wrap {
  232. display: flex;
  233. flex-direction: column;
  234. i {
  235. cursor: pointer;
  236. &.active {
  237. color: #32B38A;
  238. }
  239. }
  240. i:first-child {
  241. margin-bottom: -3px;
  242. }
  243. i:last-child {
  244. margin-top: -3px;
  245. }
  246. }
  247. </style>