index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <wrapper
  3. fill
  4. margin
  5. padding
  6. background
  7. >
  8. <schema-table
  9. ref="table"
  10. :schema="schema"
  11. />
  12. <table-dialog
  13. ref="assetDialog"
  14. title="个人媒资"
  15. size="lg"
  16. :schema="assetSchema"
  17. />
  18. <table-dialog
  19. ref="orderDialog"
  20. title="个人订单"
  21. size="lg"
  22. :schema="orderSchema"
  23. @row-click="onToggle"
  24. />
  25. <table-dialog
  26. ref="adDialog"
  27. title="上播内容"
  28. :schema="adSchema"
  29. />
  30. <preview-dialog ref="previewDialog" />
  31. </wrapper>
  32. </template>
  33. <script>
  34. import {
  35. State,
  36. AssetType,
  37. AssetTypeInfo
  38. } from '@/constant'
  39. import {
  40. parseByte,
  41. parseDuration
  42. } from '@/utils'
  43. import {
  44. getUsers,
  45. getAssets,
  46. getOrders
  47. } from '../api'
  48. export default {
  49. name: 'AdAssetReview',
  50. data () {
  51. return {
  52. schema: {
  53. list: getUsers,
  54. transform: this.transform,
  55. filters: [
  56. { key: 'phoneNumber', type: 'search', placeholder: '手机号' }
  57. ],
  58. cols: [
  59. { prop: 'file', type: 'asset', refresh: true },
  60. { prop: 'nickName', label: '昵称' },
  61. { prop: 'phoneNumber', label: '手机号', align: 'center', 'min-width': 120 },
  62. { type: 'invoke', render: [
  63. { label: '媒资', on: this.onAsset },
  64. { label: '订单', on: this.onOrder }
  65. ] }
  66. ]
  67. },
  68. assetSchema: {
  69. list: this.getAssets,
  70. transform: this.transformAsset,
  71. filters: [
  72. { key: 'status', type: 'select', placeholder: '状态', options: [
  73. { value: State.SUBMITTED, label: '待审核' },
  74. { value: State.RESOLVED, label: '通过' },
  75. { value: State.REJECTED, label: '驳回' }
  76. ] }
  77. ],
  78. cols: [
  79. { prop: 'fileType', type: 'refresh', width: 80 },
  80. { prop: 'file', label: '', type: 'asset', on: this.onViewAsset },
  81. { prop: 'size', label: '文件大小', align: 'right' },
  82. { prop: 'ratio', label: '分辨率', align: 'right' },
  83. { prop: 'diff', label: '其他', align: 'right' },
  84. { prop: 'statusTag', type: 'tag' },
  85. { prop: 'createTime', label: '上传时间', align: 'right', 'min-width': 120 },
  86. { type: 'invoke', render: [
  87. { label: '查看', allow: ({ file }) => !!file, on: this.onViewAsset }
  88. ] }
  89. ]
  90. },
  91. orderSchema: {
  92. list: this.getOrders,
  93. transform: this.transformOrder,
  94. filters: [
  95. { key: 'status', type: 'select', placeholder: '订单状态', options: [
  96. { value: 1, label: '待审核' },
  97. { value: 2, label: '通过' },
  98. { value: 3, label: '驳回' },
  99. { value: 4, label: '待支付' },
  100. { value: 5, label: '已过期' }
  101. ] }
  102. ],
  103. cols: [
  104. { type: 'expand', refresh: true, render: (data, h) => h('div', {
  105. staticClass: 'o-info'
  106. }, [
  107. h('div', null, `时段:${data.range}`),
  108. h('div', null, `频率:${data.freq}`)
  109. ]) },
  110. { prop: 'deviceName', label: '设备', 'min-width': 100 },
  111. { prop: 'startDate', label: '上刊日期', align: 'right', 'min-width': 100 },
  112. { prop: 'price', label: '总价(元)', 'min-width': 100, align: 'right' },
  113. { prop: 'statusTag', type: 'tag' },
  114. { prop: 'createTime', label: '提交时间', align: 'right', 'min-width': 120 },
  115. { prop: 'auditTime', label: '审核时间', align: 'right', 'min-width': 120 },
  116. { type: 'invoke', render: [
  117. { label: '上播内容', on: this.onViewOrderAssets }
  118. ] }
  119. ]
  120. },
  121. adSchema: {
  122. list: this.getSources,
  123. cols: [
  124. { prop: 'fileType', label: '文件', width: 100, align: 'center' },
  125. { prop: 'file', label: '', type: 'asset', on: this.onViewAsset },
  126. { prop: 'adDuration', label: '上播时长', align: 'center' },
  127. { prop: 'statusTag', type: 'tag' },
  128. { type: 'invoke', render: [
  129. { label: '查看', allow: ({ file }) => !!file, on: this.onViewAsset }
  130. ] }
  131. ]
  132. }
  133. }
  134. },
  135. methods: {
  136. transform ({ openid, avatarUrl, nickName, phoneNumber }) {
  137. return {
  138. openid,
  139. file: avatarUrl && /^http/.test(avatarUrl)
  140. ? {
  141. net: true,
  142. thumb: avatarUrl
  143. }
  144. : null,
  145. nickName,
  146. phoneNumber
  147. }
  148. },
  149. getAssets (params) {
  150. return getAssets({
  151. openid: this.$openid,
  152. ...params
  153. })
  154. },
  155. transformAsset ({ keyName, type, size, duration, width, height, thumb, status, reason, createTime }) {
  156. const isImage = type === AssetType.IMAGE
  157. return {
  158. keyName,
  159. fileType: AssetTypeInfo[type],
  160. file: {
  161. type,
  162. url: keyName,
  163. thumb: isImage ? keyName : thumb,
  164. origin: !isImage
  165. },
  166. ratio: width && height ? `${width}x${height}` : '-',
  167. size: parseByte(size),
  168. diff: parseDuration(duration),
  169. statusTag: {
  170. type: ['', 'primay', 'success', 'danger'][status],
  171. label: ['-', '待审核', '通过', '驳回'][status],
  172. msg: status === State.REJECTED ? reason : ''
  173. },
  174. createTime
  175. }
  176. },
  177. onAsset ({ openid }) {
  178. this.$openid = openid
  179. this.$refs.assetDialog.show()
  180. },
  181. getOrders (params) {
  182. return getOrders({
  183. openid: this.$openid,
  184. ...params
  185. })
  186. },
  187. onOrder ({ openid }) {
  188. this.$openid = openid
  189. this.$refs.orderDialog.show()
  190. },
  191. transformOrder ({ id, price, status, expand, orders, assets, createTime, auditTime }) {
  192. const { startDate, startTime, endTime, day, duration, count } = orders[0]
  193. return {
  194. id,
  195. deviceName: orders[0].name,
  196. startDate,
  197. range: `${startTime}-${endTime}`,
  198. price: (price / 100).toFixed(2),
  199. freq: `${day}天 x ${duration}秒 x ${count}次`,
  200. statusTag: this.getOrderTag(status, expand),
  201. assets,
  202. createTime,
  203. auditTime
  204. }
  205. },
  206. getOrderTag (status, expand) {
  207. switch (status) {
  208. case 1:
  209. return {
  210. type: 'primay',
  211. label: '待审核'
  212. }
  213. case 2:
  214. return {
  215. type: 'success',
  216. label: '通过'
  217. }
  218. case 3:
  219. return {
  220. type: 'danger',
  221. label: '驳回',
  222. msg: expand
  223. }
  224. case 4:
  225. return {
  226. type: 'warning',
  227. label: '待支付'
  228. }
  229. case 5:
  230. return {
  231. type: 'danger',
  232. label: '已过期'
  233. }
  234. default:
  235. return null
  236. }
  237. },
  238. onToggle (row) {
  239. this.$refs.orderDialog.getTable().getInst().toggleRowExpansion(row)
  240. },
  241. onViewOrderAssets (order) {
  242. this.$order = order
  243. this.$refs.adDialog.show()
  244. },
  245. getSources () {
  246. const sources = this.$order.assets
  247. return Promise.resolve({
  248. data: sources.map(this.transformSource),
  249. totalCount: sources.length
  250. })
  251. },
  252. transformSource ({ keyName, type, adDuration, thumb, status, reason }) {
  253. const isImage = type === AssetType.IMAGE
  254. return type
  255. ? {
  256. fileType: AssetTypeInfo[type],
  257. file: {
  258. type,
  259. url: keyName,
  260. thumb: isImage ? keyName : thumb,
  261. origin: !isImage
  262. },
  263. adDuration: parseDuration(adDuration),
  264. statusTag: {
  265. type: ['', 'primay', 'success', 'danger'][status],
  266. label: ['-', '待审核', '通过', '驳回'][status],
  267. msg: status === State.REJECTED ? reason : ''
  268. }
  269. }
  270. : {
  271. fileType: '素材已删除',
  272. adDuration: parseDuration(adDuration)
  273. }
  274. },
  275. onViewAsset ({ file }) {
  276. this.$refs.previewDialog.show(file)
  277. }
  278. }
  279. }
  280. </script>