Просмотр исходного кода

feat(applet): user

adjust some list operations and displays
Casper Dai 3 лет назад
Родитель
Сommit
be83409c6b

+ 5 - 1
src/components/table/Table/Column.vue

@@ -83,7 +83,11 @@ export default {
         return this.$createElement('auto-image', {
           staticClass: `o-thumbnail u-font-size--lg u-color--blue ${on ? 'u-pointer' : ''}`,
           props: {
-            src: value.origin ? getAssetUrl(thumb) : getThumbnailUrl(thumb, '80,fit'),
+            src: value.net
+              ? thumb
+              : value.origin
+                ? getAssetUrl(thumb)
+                : getThumbnailUrl(thumb, '80,fit'),
             broken: 'image-broken'
           },
           nativeOn: on && { click: $event => {

+ 6 - 1
src/router/index.js

@@ -471,7 +471,12 @@ export const asyncRoutes = [
       {
         path: 'order/history',
         component: () => import('@/views/ad/applet/history/index'),
-        meta: { title: '订单历史' }
+        meta: { title: '订单记录' }
+      },
+      {
+        path: 'user',
+        component: () => import('@/views/ad/applet/user/index'),
+        meta: { title: '注册用户' }
       }
     ]
   },

+ 28 - 6
src/views/ad/applet/api.js

@@ -36,7 +36,7 @@ export function rejectAsset ({ keyName }, reason) {
   })
 }
 
-export function getOrders (query, options) {
+export function getOrders (query) {
   const { pageNum: pageIndex, pageSize, ...params } = query
   return request({
     url: '/ad/tenant/order/list',
@@ -44,8 +44,19 @@ export function getOrders (query, options) {
     params: {
       pageIndex, pageSize,
       ...params
-    },
-    ...options
+    }
+  })
+}
+
+export function getOrdersByUser (query) {
+  const { pageNum: pageIndex, pageSize, ...params } = query
+  return request({
+    url: '/ad/user/order/list',
+    method: 'GET',
+    params: {
+      pageIndex, pageSize,
+      ...params
+    }
   })
 }
 
@@ -68,15 +79,26 @@ export function rejectOrder ({ id }, reason) {
   })
 }
 
-export function getOrdersByDevice (query, options) {
+export function getOrdersByDevice (query) {
   const { pageNum: pageIndex, pageSize, ...params } = query
   return request({
     url: '/ad/tenant/order/device/range',
     method: 'GET',
     params: {
       pageIndex, pageSize,
-      ...params,
-      ...options
+      ...params
+    }
+  })
+}
+
+export function getUsers (query) {
+  const { pageNum: pageIndex, pageSize, ...params } = query
+  return request({
+    url: '/wechatAppletUser/page',
+    method: 'GET',
+    params: {
+      pageIndex, pageSize,
+      ...params
     }
   })
 }

+ 65 - 14
src/views/ad/applet/history/index.vue

@@ -32,23 +32,31 @@ export default {
   data () {
     return {
       schema: {
-        condition: { status: State.RESOLVED },
         list: getOrders,
         transform: this.transform,
+        listeners: { 'row-click': this.onToggle },
         filters: [
-          { key: 'status', type: 'select', options: [
-            { value: State.RESOLVED, label: '通过' },
-            { value: State.REJECTED, label: '驳回' }
+          { key: 'status', type: 'select', placeholder: '订单状态', options: [
+            { value: 1, label: '待审核' },
+            { value: 2, label: '通过' },
+            { value: 3, label: '驳回' },
+            { value: 4, label: '待支付' },
+            { value: 5, label: '已过期' }
           ] }
         ],
         cols: [
-          { type: 'refresh' },
+          { type: 'expand', refresh: true, render: (data, h) => h('div', {
+            staticClass: 'o-info'
+          }, [
+            h('div', null, `时段:${data.range}`),
+            h('div', null, `频率:${data.freq}`)
+          ]) },
           { prop: 'deviceName', label: '设备', 'min-width': 100 },
-          { prop: 'startDate', label: '起始日期', align: 'right', 'min-width': 100 },
-          { prop: 'range', label: '时段', align: 'right', 'min-width': 100 },
-          { prop: 'freq', label: '频率', align: 'right', 'min-width': 140 },
+          { prop: 'startDate', label: '上刊日期', align: 'right', 'min-width': 100 },
           { prop: 'price', label: '总价(元)', 'min-width': 100, align: 'right' },
-          { prop: 'remark', label: '备注', 'min-width': 140, align: 'right' },
+          { prop: 'statusTag', type: 'tag' },
+          { prop: 'createTime', label: '提交时间', align: 'right', 'min-width': 120 },
+          { prop: 'auditTime', label: '审核时间', align: 'right', 'min-width': 120 },
           { type: 'invoke', render: [
             { label: '上播内容', on: this.onView }
           ] }
@@ -60,6 +68,7 @@ export default {
           { prop: 'fileType', label: '文件', width: 100, align: 'center' },
           { prop: 'file', label: '', type: 'asset', on: this.onViewAsset },
           { prop: 'adDuration', label: '上播时长', align: 'center' },
+          { prop: 'statusTag', type: 'tag' },
           { type: 'invoke', render: [
             { label: '查看', allow: ({ file }) => !!file, on: this.onViewAsset }
           ] }
@@ -68,7 +77,7 @@ export default {
     }
   },
   methods: {
-    transform ({ id, price, status, expand, orders, assets }) {
+    transform ({ id, price, status, expand, orders, assets, createTime, auditTime }) {
       const { startDate, startTime, endTime, day, duration, count } = orders[0]
       return {
         id,
@@ -77,10 +86,47 @@ export default {
         range: `${startTime}-${endTime}`,
         price: (price / 100).toFixed(2),
         freq: `${day}天 x ${duration}秒 x ${count}次`,
-        remark: status === State.REJECTED ? expand : '-',
-        assets
+        statusTag: this.getOrderTag(status, expand),
+        assets,
+        createTime,
+        auditTime
       }
     },
+    getOrderTag (status, expand) {
+      switch (status) {
+        case 1:
+          return {
+            type: 'primay',
+            label: '待审核'
+          }
+        case 2:
+          return {
+            type: 'success',
+            label: '通过'
+          }
+        case 3:
+          return {
+            type: 'danger',
+            label: '驳回',
+            msg: expand
+          }
+        case 4:
+          return {
+            type: 'warning',
+            label: '待支付'
+          }
+        case 5:
+          return {
+            type: 'danger',
+            label: '已过期'
+          }
+        default:
+          return null
+      }
+    },
+    onToggle (row) {
+      this.$refs.orderDialog.getTable().getInst().toggleRowExpansion(row)
+    },
     onView (order) {
       this.$order = order
       this.$refs.adDialog.show()
@@ -92,7 +138,7 @@ export default {
         totalCount: sources.length
       })
     },
-    transformSource ({ keyName, type, adDuration, thumb }) {
+    transformSource ({ keyName, type, adDuration, thumb, status, reason }) {
       const isImage = type === AssetType.IMAGE
       return type
         ? {
@@ -103,7 +149,12 @@ export default {
             thumb: isImage ? keyName : thumb,
             origin: !isImage
           },
-          adDuration: parseDuration(adDuration)
+          adDuration: parseDuration(adDuration),
+          statusTag: {
+            type: ['', 'primay', 'success', 'danger'][status],
+            label: ['-', '待审核', '通过', '驳回'][status],
+            msg: status === State.REJECTED ? reason : ''
+          }
         }
         : {
           fileType: '素材已删除',

+ 2 - 2
src/views/ad/applet/review-order/index.vue

@@ -74,7 +74,7 @@ export default {
         cols: [
           { type: 'refresh' },
           { prop: 'deviceName', label: '设备', 'min-width': 100 },
-          { prop: 'startDate', label: '起始日期', align: 'right', 'min-width': 100 },
+          { prop: 'startDate', label: '上刊日期', align: 'right', 'min-width': 100 },
           { prop: 'range', label: '时段', align: 'right', 'min-width': 100 },
           { prop: 'freq', label: '频率', align: 'right', 'min-width': 140 },
           { prop: 'price', label: '总价(元)', 'min-width': 100, align: 'right' },
@@ -179,7 +179,7 @@ export default {
           status,
           statusTag: {
             type: ['', 'primay', 'success', 'danger'][status],
-            label: ['-', '待审核', '已审核', '驳回'][status],
+            label: ['-', '待审核', '通过', '驳回'][status],
             msg: status === State.REJECTED ? reason : ''
           }
         }

+ 282 - 0
src/views/ad/applet/user/index.vue

@@ -0,0 +1,282 @@
+<template>
+  <wrapper
+    fill
+    margin
+    padding
+    background
+  >
+    <schema-table
+      ref="table"
+      :schema="schema"
+    />
+    <table-dialog
+      ref="assetDialog"
+      title="个人媒资"
+      size="lg"
+      :schema="assetSchema"
+    />
+    <table-dialog
+      ref="orderDialog"
+      title="个人订单"
+      size="lg"
+      :schema="orderSchema"
+    />
+    <table-dialog
+      ref="adDialog"
+      title="上播内容"
+      :schema="adSchema"
+    />
+    <preview-dialog ref="previewDialog" />
+  </wrapper>
+</template>
+
+<script>
+import {
+  State,
+  AssetType,
+  AssetTypeInfo
+} from '@/constant'
+import {
+  parseByte,
+  parseDuration
+} from '@/utils'
+import {
+  getUsers,
+  getAssets,
+  getOrders
+} from '../api'
+
+export default {
+  name: 'AdAssetReview',
+  data () {
+    return {
+      schema: {
+        list: getUsers,
+        transform: this.transform,
+        filters: [
+          { key: 'phoneNumber', type: 'search', placeholder: '手机号' }
+        ],
+        cols: [
+          { prop: 'file', type: 'asset', refresh: true },
+          { prop: 'nickName', label: '昵称' },
+          { prop: 'phoneNumber', label: '手机号', align: 'center', 'min-width': 120 },
+          { type: 'invoke', render: [
+            { label: '媒资', on: this.onAsset },
+            { label: '订单', on: this.onOrder }
+          ] }
+        ]
+      },
+      assetSchema: {
+        list: this.getAssets,
+        transform: this.transformAsset,
+        filters: [
+          { key: 'status', type: 'select', placeholder: '状态', options: [
+            { value: State.SUBMITTED, label: '待审核' },
+            { value: State.RESOLVED, label: '通过' },
+            { value: State.REJECTED, label: '驳回' }
+          ] }
+        ],
+        cols: [
+          { prop: 'fileType', type: 'refresh', width: 80 },
+          { prop: 'file', label: '', type: 'asset', on: this.onViewAsset },
+          { prop: 'size', label: '文件大小', align: 'right' },
+          { prop: 'ratio', label: '分辨率', align: 'right' },
+          { prop: 'diff', label: '其他', align: 'right' },
+          { prop: 'statusTag', type: 'tag' },
+          { prop: 'createTime', label: '上传时间', align: 'right', 'min-width': 120 },
+          { type: 'invoke', render: [
+            { label: '查看', allow: ({ file }) => !!file, on: this.onViewAsset }
+          ] }
+        ]
+      },
+      orderSchema: {
+        list: this.getOrders,
+        transform: this.transformOrder,
+        listeners: { 'row-click': this.onToggle },
+        filters: [
+          { key: 'status', type: 'select', placeholder: '订单状态', options: [
+            { value: 1, label: '待审核' },
+            { value: 2, label: '通过' },
+            { value: 3, label: '驳回' },
+            { value: 4, label: '待支付' },
+            { value: 5, label: '已过期' }
+          ] }
+        ],
+        cols: [
+          { type: 'expand', refresh: true, render: (data, h) => h('div', {
+            staticClass: 'o-info'
+          }, [
+            h('div', null, `时段:${data.range}`),
+            h('div', null, `频率:${data.freq}`)
+          ]) },
+          { prop: 'deviceName', label: '设备', 'min-width': 100 },
+          { prop: 'startDate', label: '上刊日期', align: 'right', 'min-width': 100 },
+          { prop: 'price', label: '总价(元)', 'min-width': 100, align: 'right' },
+          { prop: 'statusTag', type: 'tag' },
+          { prop: 'createTime', label: '提交时间', align: 'right', 'min-width': 120 },
+          { prop: 'auditTime', label: '审核时间', align: 'right', 'min-width': 120 },
+          { type: 'invoke', render: [
+            { label: '上播内容', on: this.onViewOrderAssets }
+          ] }
+        ]
+      },
+      adSchema: {
+        list: this.getSources,
+        cols: [
+          { prop: 'fileType', label: '文件', width: 100, align: 'center' },
+          { prop: 'file', label: '', type: 'asset', on: this.onViewAsset },
+          { prop: 'adDuration', label: '上播时长', align: 'center' },
+          { prop: 'statusTag', type: 'tag' },
+          { type: 'invoke', render: [
+            { label: '查看', allow: ({ file }) => !!file, on: this.onViewAsset }
+          ] }
+        ]
+      }
+    }
+  },
+  methods: {
+    transform ({ openid, avatarUrl, nickName, phoneNumber }) {
+      return {
+        openid,
+        file: avatarUrl && /^http/.test(avatarUrl)
+          ? {
+            net: true,
+            thumb: avatarUrl
+          }
+          : null,
+        nickName,
+        phoneNumber
+      }
+    },
+    getAssets (params) {
+      return getAssets({
+        openid: this.$openid,
+        ...params
+      })
+    },
+    transformAsset ({ keyName, type, size, duration, width, height, thumb, status, reason, createTime }) {
+      const isImage = type === AssetType.IMAGE
+      return {
+        keyName,
+        fileType: AssetTypeInfo[type],
+        file: {
+          type,
+          url: keyName,
+          thumb: isImage ? keyName : thumb,
+          origin: !isImage
+        },
+        ratio: width && height ? `${width}x${height}` : '-',
+        size: parseByte(size),
+        diff: parseDuration(duration),
+        statusTag: {
+          type: ['', 'primay', 'success', 'danger'][status],
+          label: ['-', '待审核', '通过', '驳回'][status],
+          msg: status === State.REJECTED ? reason : ''
+        },
+        createTime
+      }
+    },
+    onAsset ({ openid }) {
+      this.$openid = openid
+      this.$refs.assetDialog.show()
+    },
+    getOrders (params) {
+      return getOrders({
+        openid: this.$openid,
+        ...params
+      })
+    },
+    onOrder ({ openid }) {
+      this.$openid = openid
+      this.$refs.orderDialog.show()
+    },
+    transformOrder ({ id, price, status, expand, orders, assets, createTime, auditTime }) {
+      const { startDate, startTime, endTime, day, duration, count } = orders[0]
+      return {
+        id,
+        deviceName: orders[0].name,
+        startDate,
+        range: `${startTime}-${endTime}`,
+        price: (price / 100).toFixed(2),
+        freq: `${day}天 x ${duration}秒 x ${count}次`,
+        statusTag: this.getOrderTag(status, expand),
+        assets,
+        createTime,
+        auditTime
+      }
+    },
+    getOrderTag (status, expand) {
+      switch (status) {
+        case 1:
+          return {
+            type: 'primay',
+            label: '待审核'
+          }
+        case 2:
+          return {
+            type: 'success',
+            label: '通过'
+          }
+        case 3:
+          return {
+            type: 'danger',
+            label: '驳回',
+            msg: expand
+          }
+        case 4:
+          return {
+            type: 'warning',
+            label: '待支付'
+          }
+        case 5:
+          return {
+            type: 'danger',
+            label: '已过期'
+          }
+        default:
+          return null
+      }
+    },
+    onToggle (row) {
+      this.$refs.orderDialog.getTable().getInst().toggleRowExpansion(row)
+    },
+    onViewOrderAssets (order) {
+      this.$order = order
+      this.$refs.adDialog.show()
+    },
+    getSources () {
+      const sources = this.$order.assets
+      return Promise.resolve({
+        data: sources.map(this.transformSource),
+        totalCount: sources.length
+      })
+    },
+    transformSource ({ keyName, type, adDuration, thumb, status, reason }) {
+      const isImage = type === AssetType.IMAGE
+      return type
+        ? {
+          fileType: AssetTypeInfo[type],
+          file: {
+            type,
+            url: keyName,
+            thumb: isImage ? keyName : thumb,
+            origin: !isImage
+          },
+          adDuration: parseDuration(adDuration),
+          statusTag: {
+            type: ['', 'primay', 'success', 'danger'][status],
+            label: ['-', '待审核', '通过', '驳回'][status],
+            msg: status === State.REJECTED ? reason : ''
+          }
+        }
+        : {
+          fileType: '素材已删除',
+          adDuration: parseDuration(adDuration)
+        }
+    },
+    onViewAsset ({ file }) {
+      this.$refs.previewDialog.show(file)
+    }
+  }
+}
+</script>

+ 1 - 1
src/views/screen/review/workflow/detail/components/ReviewPublish.vue

@@ -28,7 +28,7 @@ export default {
         condition: { pageSize: this.list.length },
         list: this.getList,
         cols: [
-          { prop: 'expand', type: 'expand', render (data, h) {
+          { type: 'expand', render (data, h) {
             return h('div', {
               staticClass: 'o-info'
             }, [