index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <wrapper
  3. fill
  4. margin
  5. padding
  6. background
  7. >
  8. <schema-table
  9. ref="table"
  10. :schema="schema"
  11. />
  12. <confirm-dialog
  13. ref="rejectDialog"
  14. title="拒绝原因"
  15. @confirm="onConfirmReject"
  16. >
  17. <div class="c-grid-form u-align-self--center">
  18. <span class="c-grid-form__label">拒绝原因</span>
  19. <el-select
  20. v-model="review.type"
  21. placeholder="请选择"
  22. >
  23. <el-option
  24. v-for="option in reviewOptions"
  25. :key="option.label"
  26. :label="option.label"
  27. :value="option.value"
  28. />
  29. </el-select>
  30. <template v-if="review.type === 'reject'">
  31. <span class="c-grid-form__label required">描述</span>
  32. <el-input
  33. v-model.trim="review.reason"
  34. type="textarea"
  35. placeholder="请填写拒绝原因"
  36. maxlength="50"
  37. :rows="3"
  38. resize="none"
  39. show-word-limit
  40. />
  41. </template>
  42. </div>
  43. </confirm-dialog>
  44. <table-dialog
  45. ref="adDialog"
  46. title="上播内容"
  47. :schema="adSchema"
  48. />
  49. <preview-dialog ref="previewDialog" />
  50. </wrapper>
  51. </template>
  52. <script>
  53. import {
  54. State,
  55. AssetType,
  56. AssetTypeInfo
  57. } from '@/constant'
  58. import { parseDuration } from '@/utils'
  59. import {
  60. getOrders,
  61. resolveOrder,
  62. rejectOrder
  63. } from '../api'
  64. export default {
  65. name: 'AdOrderReview',
  66. data () {
  67. return {
  68. schema: {
  69. condition: { status: State.SUBMITTED },
  70. list: getOrders,
  71. transform: this.transform,
  72. cols: [
  73. { type: 'refresh' },
  74. { prop: 'deviceName', label: '设备', 'min-width': 100 },
  75. { prop: 'startDate', label: '起始日期', align: 'right', 'min-width': 100 },
  76. { prop: 'range', label: '时段', align: 'right', 'min-width': 100 },
  77. { prop: 'freq', label: '频率', align: 'right', 'min-width': 140 },
  78. { prop: 'price', label: '总价(元)', 'min-width': 100, align: 'right' },
  79. { prop: 'createTime', label: '提交时间', 'min-width': 140, align: 'right' },
  80. { type: 'invoke', width: 180, render: [
  81. { label: '上播内容', on: this.onView },
  82. { label: '通过', on: this.onResolve },
  83. { label: '拒绝', on: this.onReject }
  84. ] }
  85. ]
  86. },
  87. reviewOptions: [
  88. { value: 'reject', label: '自定义' },
  89. { value: '播放时段已被占用' },
  90. { value: '内容不合规' }
  91. ],
  92. review: {
  93. type: '',
  94. reason: ''
  95. },
  96. adSchema: {
  97. list: this.getOrderAssets,
  98. cols: [
  99. { prop: 'fileType', label: '文件', width: 100, align: 'center' },
  100. { prop: 'file', label: '', type: 'asset', on: this.onViewAsset },
  101. { prop: 'adDuration', label: '上播时长', align: 'center' },
  102. { prop: 'ratio', label: '分辨率', align: 'right' },
  103. { prop: 'statusTag', type: 'tag' },
  104. { type: 'invoke', render: [
  105. { label: '查看', allow: ({ file }) => !!file, on: this.onViewAsset }
  106. ] }
  107. ]
  108. }
  109. }
  110. },
  111. methods: {
  112. transform ({ id, price, status, createTime, expand, orders, assets }) {
  113. const { startDate, startTime, endTime, day, duration, count } = orders[0]
  114. return {
  115. id,
  116. deviceName: orders[0].name,
  117. startDate,
  118. range: `${startTime}-${endTime}`,
  119. price: (price / 100).toFixed(2),
  120. freq: `${day}天 x ${duration}秒 x ${count}次`,
  121. remark: status === State.REJECTED ? expand : '-',
  122. createTime,
  123. assets
  124. }
  125. },
  126. onView (order) {
  127. this.$order = order
  128. this.$refs.adDialog.show()
  129. },
  130. onResolve (order) {
  131. resolveOrder(order).then(() => {
  132. this.$refs.table.decrease(1)
  133. })
  134. },
  135. onReject (order) {
  136. this.$order = order
  137. this.review = {
  138. type: 'reject',
  139. reason: ''
  140. }
  141. this.$refs.rejectDialog.show()
  142. },
  143. onConfirmReject (done) {
  144. const reason = this.review.type === 'reject' ? this.review.reason : this.review.type
  145. if (!reason) {
  146. this.$message({
  147. type: 'warning',
  148. message: '请选择或填写驳回原因'
  149. })
  150. return
  151. }
  152. rejectOrder(this.$order, reason).then(() => {
  153. done()
  154. this.$refs.table.decrease(1)
  155. })
  156. },
  157. getOrderAssets () {
  158. const assets = this.$order.assets
  159. return Promise.resolve({
  160. data: assets.map(this.transformOrderAsset),
  161. totalCount: assets.length
  162. })
  163. },
  164. transformOrderAsset ({ keyName, type, adDuration, width, height, thumb, status, reason }) {
  165. const isImage = type === AssetType.IMAGE
  166. return type
  167. ? {
  168. fileType: AssetTypeInfo[type],
  169. file: {
  170. type,
  171. url: keyName,
  172. thumb: isImage ? keyName : thumb,
  173. origin: !isImage
  174. },
  175. adDuration: parseDuration(adDuration),
  176. ratio: width && height ? `${width}x${height}` : '-',
  177. status,
  178. statusTag: {
  179. type: ['', 'primay', 'success', 'danger'][status],
  180. label: ['-', '待审核', '已审核', '驳回'][status],
  181. msg: status === State.REJECTED ? reason : ''
  182. }
  183. }
  184. : {
  185. fileType: '素材已删除',
  186. adDuration: parseDuration(adDuration)
  187. }
  188. },
  189. onViewAsset ({ file }) {
  190. this.$refs.previewDialog.show(file)
  191. }
  192. }
  193. }
  194. </script>