CrowdTaskView.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <div class="crowd-task-view">
  3. <el-card v-if="current">
  4. <div slot="header" class="header">
  5. <span class="title">客群规则任务详情</span>
  6. </div>
  7. <!-- 基本信息 -->
  8. <div class="section-title">基本信息</div>
  9. <el-descriptions :column="2" border>
  10. <el-descriptions-item label="客群名称">{{ current.name }}</el-descriptions-item>
  11. <el-descriptions-item label="客群编号">{{ current.id }}</el-descriptions-item>
  12. <el-descriptions-item label="状态">
  13. <el-tag :type="statusTagType(current.status)" size="small">{{ statusLabel(current.status) }}</el-tag>
  14. </el-descriptions-item>
  15. <el-descriptions-item label="客群类型">{{ typeLabel(current.type) }}</el-descriptions-item>
  16. <el-descriptions-item label="客群描述" :span="2">{{ current.description || '-' }}</el-descriptions-item>
  17. <el-descriptions-item label="圈客周期">{{ cycleLabel(current) }}</el-descriptions-item>
  18. <el-descriptions-item label="任务开始/结束日期">
  19. {{ current.startDate }} ~ {{ current.endDate }}
  20. </el-descriptions-item>
  21. <el-descriptions-item label="任务创建时间">{{ current.createdAt }}</el-descriptions-item>
  22. <el-descriptions-item label="任务创建用户">{{ current.creator }}</el-descriptions-item>
  23. <el-descriptions-item label="审核人">{{ current.reviewer || '-' }}</el-descriptions-item>
  24. <el-descriptions-item label="最近更新时间">{{ current.updatedAt }}</el-descriptions-item>
  25. </el-descriptions>
  26. <!-- 规则组信息 -->
  27. <div class="section-title" style="margin-top: 24px">规则组信息</div>
  28. <div class="rule-group-meta">
  29. <span class="meta-label">规则组间逻辑:</span>
  30. <span>{{ current.ruleGroupLogic === 'AND' ? 'and/且' : 'or/或' }}</span>
  31. </div>
  32. <div class="rule-group-meta">
  33. <span class="meta-label">规则组详情:</span>
  34. </div>
  35. <el-table :data="current.ruleGroups || []" border style="width: 100%" empty-text="无规则组">
  36. <el-table-column prop="id" label="规则组编号" width="170" align="center" />
  37. <el-table-column prop="name" label="规则组名称" min-width="160" show-overflow-tooltip />
  38. <el-table-column prop="description" label="规则组描述" min-width="200" show-overflow-tooltip />
  39. <el-table-column label="规则组内逻辑" width="120" align="center">
  40. <template slot-scope="scope">{{ scope.row.logic === 'AND' ? 'and/且' : 'or/或' }}</template>
  41. </el-table-column>
  42. <el-table-column prop="ruleCount" label="规则个数" width="90" align="center" />
  43. </el-table>
  44. <!-- 运行信息 -->
  45. <div class="section-title" style="margin-top: 24px">运行信息</div>
  46. <div class="run-info">
  47. <div class="run-row">
  48. <span class="run-label">总数(count):</span>
  49. <span class="run-value">{{ countDisplay }}</span>
  50. </div>
  51. <div class="run-row">
  52. <span class="run-label">校验(sample):</span>
  53. <span class="run-value">
  54. <el-link
  55. v-if="sampleAvailable"
  56. type="primary"
  57. :underline="false"
  58. @click="showSample = true"
  59. >详情</el-link>
  60. <span v-else-if="current.run.sample === 'running'" class="muted">详情</span>
  61. <span v-else class="muted">未运行</span>
  62. </span>
  63. <el-button
  64. size="small"
  65. type="primary"
  66. :disabled="!canRerun"
  67. style="margin-left: 16px"
  68. @click="handleRerun"
  69. >重新校验</el-button>
  70. </div>
  71. <div class="run-row">
  72. <span class="run-label">全量圈客(fulllist):</span>
  73. <span :class="['run-value', fulllistClass]">{{ fulllistDisplay }}</span>
  74. </div>
  75. </div>
  76. <div class="footer">
  77. <el-button type="primary" @click="$router.push('/customization/hsbc/crowd-tasks')">返回</el-button>
  78. </div>
  79. </el-card>
  80. <sample-detail-dialog
  81. :visible.sync="showSample"
  82. :rows="sampleRows"
  83. />
  84. </div>
  85. </template>
  86. <script>
  87. import crowdTaskStore from '@/store/crowdTaskStore'
  88. import SampleDetailDialog from '@/components/crowdTask/SampleDetailDialog.vue'
  89. export default {
  90. name: 'CrowdTaskView',
  91. components: { SampleDetailDialog },
  92. data() {
  93. return { current: null, showSample: false }
  94. },
  95. computed: {
  96. sampleAvailable() {
  97. return this.current && Array.isArray(this.current.run.sample) && this.current.run.sample.length > 0
  98. },
  99. sampleRows() {
  100. return this.sampleAvailable ? this.current.run.sample : []
  101. },
  102. countDisplay() {
  103. const c = this.current && this.current.run.count
  104. if (c === null || c === undefined) return '未运行'
  105. if (c === 'running') return '正在运行'
  106. return c
  107. },
  108. fulllistDisplay() {
  109. const f = this.current && this.current.run.fulllist
  110. if (f === null || f === undefined) return '未运行'
  111. if (f === 'running') return '正在运行'
  112. if (f === 'completed') return '已完成'
  113. return f
  114. },
  115. fulllistClass() {
  116. const f = this.current && this.current.run.fulllist
  117. if (!f) return 'red'
  118. if (f === 'running') return 'muted'
  119. return 'green'
  120. },
  121. canRerun() {
  122. if (!this.current) return false
  123. if (this.current.run.count === 'running' || this.current.run.sample === 'running') return false
  124. if (this.current.status === 'stopped') return false
  125. // 任意非"正在运行"且非"已停止"状态都支持运维人员重跑
  126. return this.current.run.count !== null
  127. }
  128. },
  129. created() {
  130. const target = crowdTaskStore.getById(this.$route.params.id)
  131. if (!target) {
  132. this.$message.error('任务不存在')
  133. this.$router.replace('/customization/hsbc/crowd-tasks')
  134. return
  135. }
  136. this.current = target
  137. },
  138. methods: {
  139. statusLabel(s) {
  140. return { draft: '新建', verifying: '校验', online: '上线', stopped: '已停止' }[s] || s
  141. },
  142. statusTagType(s) {
  143. return { draft: 'info', verifying: 'warning', online: 'success', stopped: 'danger' }[s] || ''
  144. },
  145. typeLabel(t) {
  146. return { display: '展示规则', reward: '奖励规则' }[t] || t
  147. },
  148. cycleLabel(row) {
  149. if (!row) return ''
  150. if (row.cycle === 'once') return '永久一次'
  151. if (row.cycle === 'daily') return '每日一次'
  152. if (row.cycle === 'monthly') return `每月${row.cycleConfig && row.cycleConfig.day}号`
  153. if (row.cycle === 'weekly') {
  154. const w = ['一', '二', '三', '四', '五', '六', '日']
  155. const idx = row.cycleConfig && row.cycleConfig.weekday
  156. return idx ? `每周${w[idx - 1]}` : '每周'
  157. }
  158. return row.cycle
  159. },
  160. handleRerun() {
  161. this.$confirm('重新校验将重新运行 count 和 sample,不影响 fullist。', '重新校验', {
  162. confirmButtonText: '运行', cancelButtonText: '取消', type: 'info'
  163. }).then(() => {
  164. crowdTaskStore.rerunCountSample(this.current.id)
  165. this.$message.success('已触发重新校验,请稍候查看结果')
  166. }).catch(() => {})
  167. }
  168. }
  169. }
  170. </script>
  171. <style scoped>
  172. .crowd-task-view { padding: 0; }
  173. .header { display: flex; align-items: center; justify-content: center; }
  174. .title { font-size: 16px; font-weight: 600; color: #409EFF; }
  175. .section-title {
  176. font-size: 14px; font-weight: 600; color: #303133;
  177. background: #f5f7fa; padding: 10px 14px; border-radius: 4px;
  178. margin-bottom: 16px;
  179. }
  180. .rule-group-meta { margin: 8px 0; font-size: 13px; color: #606266; }
  181. .rule-group-meta .meta-label { font-weight: 600; color: #303133; }
  182. .run-info {
  183. border: 1px solid #fbbfbf; border-radius: 4px;
  184. background: #fffaf0; padding: 16px 24px;
  185. }
  186. .run-row { display: flex; align-items: center; padding: 6px 0; font-size: 14px; }
  187. .run-label { width: 160px; color: #303133; font-weight: 600; }
  188. .run-value { color: #606266; }
  189. .run-value.red { color: #F56C6C; }
  190. .run-value.green { color: #67C23A; }
  191. .muted { color: #c0c4cc; }
  192. .footer { text-align: center; margin-top: 24px; padding-top: 16px; border-top: 1px solid #ebeef5; }
  193. </style>