distributionB.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <br />
  3. <el-card style="margin: 0 1em;">
  4. <div class="title_card" v-text="title"></div>
  5. <br />
  6. <el-button-group style="margin-left: 1.5em">
  7. <el-button
  8. size="small"
  9. type="primary"
  10. v-for="(item, i) in soft_planting_list"
  11. :key="'soft_planting' + i"
  12. :plain="soft_planting_act !== i"
  13. @click="() => soft_planting_change(i)"
  14. >
  15. {{ item.text }}
  16. </el-button>
  17. </el-button-group>
  18. <br />
  19. <el-row>
  20. <el-col :span="12">
  21. <div class="customer_list">
  22. <div class="customer_list_head">
  23. 软广-节目类型占比
  24. </div>
  25. <div ref="softAd"></div>
  26. </div>
  27. </el-col>
  28. <el-col :span="12">
  29. <com-table
  30. :title="'栏目排名top10-' + titleName"
  31. :tableList="tableList"
  32. :child="true"
  33. >
  34. <template #cols>
  35. <el-table-column
  36. align="center"
  37. type="index"
  38. label="序号"
  39. width="50"
  40. />
  41. <el-table-column
  42. show-overflow-tooltip
  43. align="center"
  44. property="programName"
  45. label="栏目名称"
  46. >
  47. <template #default="scope">
  48. {{ scope.row.programName || '--' }}
  49. </template>
  50. </el-table-column>
  51. <el-table-column align="center" property="pinci">
  52. <template #header>
  53. <span
  54. :style="
  55. soft_planting_list[soft_planting_act].type === 1
  56. ? 'color: red'
  57. : ''
  58. "
  59. >
  60. 频次(次)
  61. </span>
  62. </template>
  63. <template #default="scope">
  64. {{ numFor(scope.row.pinci) }}
  65. </template>
  66. </el-table-column>
  67. <el-table-column align="center" property="timeSize">
  68. <template #header>
  69. <span
  70. :style="
  71. soft_planting_list[soft_planting_act].type === 2
  72. ? 'color: red'
  73. : ''
  74. "
  75. >
  76. 时长(秒)
  77. </span>
  78. </template>
  79. <template #default="scope">
  80. {{ numFor(scope.row.timeSize) }}
  81. </template>
  82. </el-table-column>
  83. <el-table-column align="center" property="customer" label="">
  84. <template #header>
  85. <span
  86. :style="
  87. soft_planting_list[soft_planting_act].type === 4
  88. ? 'color: red'
  89. : ''
  90. "
  91. >
  92. 客户数
  93. </span>
  94. </template>
  95. <template #default="scope">
  96. {{ numFor(scope.row.customer) }}
  97. </template>
  98. </el-table-column>
  99. </template>
  100. </com-table>
  101. </el-col>
  102. </el-row>
  103. </el-card>
  104. </template>
  105. <script>
  106. // @ is an alias to /src
  107. // import config from "@/config/index";
  108. import * as echarts from "echarts";
  109. import comTable from "./table.vue";
  110. import { ProgramTypeDistribution } from "@/api/index.js";
  111. export default {
  112. name: "AdvertisingEye_distribution",
  113. data() {
  114. return {
  115. titleName: "",
  116. tableList: [],
  117. soft_planting_act: 0,
  118. soft_planting_list: [
  119. {
  120. text: "时长",
  121. proportionType: "timeSize",
  122. type: 2,
  123. },
  124. {
  125. text: "频次",
  126. proportionType: "pinci",
  127. type: 1,
  128. },
  129. {
  130. text: "客户数",
  131. proportionType: "custom",
  132. type: 4,
  133. },
  134. ],
  135. softAd_chart: undefined,
  136. };
  137. },
  138. props: {
  139. title: String,
  140. industry: Number,
  141. industryRang: Number,
  142. },
  143. watch: {
  144. industryRang() {
  145. this.init();
  146. },
  147. industry() {
  148. this.init();
  149. },
  150. },
  151. mounted() {
  152. this.init();
  153. },
  154. computed: {},
  155. filter: {},
  156. methods: {
  157. init() {
  158. ProgramTypeDistribution({
  159. industryId: this.industry,
  160. dataType: this.industryRang + 1,
  161. type: this.soft_planting_list[this.soft_planting_act].type,
  162. }).then(all => {
  163. const li = (all || { data: [] }).data || [];
  164. this.tableList = li;
  165. li.length && (this.titleName = li[0].name || "");
  166. this.softAdChart(li || []);
  167. });
  168. },
  169. soft_planting_change(i) {
  170. this.soft_planting_act = i;
  171. this.init();
  172. },
  173. softAdChart(list) {
  174. if (!this.$refs.softAd) return;
  175. if (this.softAd_chart && this.softAd_chart.dispose) {
  176. this.softAd_chart.dispose();
  177. this.softAd_chart = undefined;
  178. }
  179. this.softAd_chart = echarts.init(this.$refs.softAd);
  180. this.softAd_chart.resize({
  181. height: 524,
  182. });
  183. let k = [],
  184. item = [],
  185. max =
  186. list[0][
  187. this.soft_planting_list[this.soft_planting_act].proportionType
  188. ] || 0;
  189. list.map(v => {
  190. k.push({ name: v.programType, max });
  191. let val = (
  192. v[this.soft_planting_list[this.soft_planting_act].proportionType] - 0
  193. ).toFixed(2);
  194. item.push(val);
  195. });
  196. var option = {
  197. radar: {
  198. // shape: 'circle',
  199. indicator: k,
  200. radius: 130,
  201. shape: "circle",
  202. splitNumber: 5,
  203. splitArea: {
  204. show: true,
  205. },
  206. axisName: {
  207. color: "#0000ee",
  208. },
  209. },
  210. tooltip: {
  211. trigger: "item",
  212. },
  213. series: [
  214. {
  215. type: "radar",
  216. lineStyle: {
  217. width: 1,
  218. opacity: 0.5,
  219. },
  220. areaStyle: {
  221. color: "rgba(157,200,241,.5)",
  222. },
  223. itemStyle: {
  224. color: "#7cb5ec",
  225. },
  226. data: [
  227. {
  228. value: item,
  229. },
  230. ],
  231. },
  232. ],
  233. };
  234. option && this.softAd_chart.setOption(option);
  235. },
  236. numFor(num) {
  237. if (isNaN(num)) return 0;
  238. if (num >= 100000000) return (num / 100000000).toFixed(2) + "亿";
  239. if (num >= 10000) return (num / 10000).toFixed(2) + "万";
  240. return Number(num).toFixed(2);
  241. },
  242. },
  243. beforeUnmount: function() {
  244. this.softAd_chart && this.softAd_chart.dispose();
  245. this.softAd_chart && (this.softAd_chart = undefined);
  246. },
  247. components: {
  248. comTable,
  249. },
  250. };
  251. </script>
  252. <style scoped>
  253. .customer_list {
  254. width: 500px;
  255. margin: 30px auto;
  256. border: 1px solid #d2e7fc;
  257. border-top: 3px solid #40a1f3;
  258. }
  259. .customer_list_head {
  260. line-height: 42px;
  261. height: 42px;
  262. color: #378ee8;
  263. border-bottom: none;
  264. font-family: "Microsoft YaHei";
  265. text-align: center;
  266. font-size: 18px;
  267. background-color: #d9efff;
  268. }
  269. .headStyle .cell {
  270. font-weight: 600;
  271. color: #000;
  272. }
  273. </style>