creativeStatistics.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <div class="app-container">
  3. <div class="app-content">
  4. <div class="title" style="display: flex; justify-content: center; align-items: center;">定向统计</div>
  5. <el-form class="search-form" :inline="true" label-width="90px">
  6. <el-form-item label="时间" prop="time">
  7. <el-date-picker
  8. v-model="queryParams.time"
  9. type="daterange"
  10. range-separator="至"
  11. value-format="yyyy-MM-dd"
  12. start-placeholder="开始日期"
  13. end-placeholder="结束日期">
  14. </el-date-picker>
  15. </el-form-item>
  16. <el-form-item label="定向维度">
  17. <el-select v-model="queryParams.reportType" placeholder="请选择维度">
  18. <el-option
  19. v-for="item in options2"
  20. :key="item.value"
  21. :label="item.label"
  22. :value="item.value">
  23. </el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item label="选择部门" prop="userId">
  27. <treeselect style="width: 217px" :clearable="false" clearable v-model="deptId" :options="deptOptions" :show-count="true"
  28. placeholder="请选择归属部门"/>
  29. </el-form-item>
  30. <el-form-item label="选择员工" prop="userId">
  31. <el-select v-model="queryParams.userId" filterable clearable @change="accountListFun" placeholder="请选择员工">
  32. <el-option
  33. v-for="item in users"
  34. :key="item.userId"
  35. :label="item.nickName"
  36. :value="item.userId">
  37. </el-option>
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item label="推广账户" prop="accountId">
  41. <el-select v-model="queryParams.id" @change="planLoad" filterable clearable placeholder="请选择推广账户">
  42. <el-option
  43. v-for="item in accountList"
  44. :key="item.id"
  45. :label="item.accountName"
  46. :value="item.id">
  47. </el-option>
  48. </el-select>
  49. </el-form-item>
  50. <el-form-item>
  51. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  52. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  53. </el-form-item>
  54. </el-form>
  55. </div>
  56. <!-- <div ref="chartContainer" style="width: 100%; height: 400px;"></div>-->
  57. <!-- <el-button class="export" size="small" @click="handleExport"-->
  58. <!-- style="float: right; margin-bottom: 15px; margin-right: 40px;">导出-->
  59. <!-- </el-button>-->
  60. <div class="table-box" style="margin: 0 auto">
  61. <el-table :data="dataList" border v-loading="loading" style="width: 100%" height="500">
  62. <el-table-column label="地区" v-if="queryParams.reportType == 2324048">
  63. <template slot-scope="scope">
  64. {{scope.row.prov.provinceName}}
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="性别" v-if="queryParams.reportType == 2503330">
  68. <template slot-scope="scope">
  69. {{scope.row.genderName}}
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="年龄" v-if="queryParams.reportType == 2510393">
  73. <template slot-scope="scope">
  74. {{scope.row.ageName}}
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="意向词" v-if="queryParams.reportType == 2532512">
  78. <template slot-scope="scope">
  79. {{scope.row.showWord}} - {{scope.row.feedWord}}
  80. </template>
  81. </el-table-column>
  82. <el-table-column prop="date" label="日期" />
  83. <el-table-column prop="impression" label="展现" />
  84. <el-table-column prop="click" label="点击" />
  85. <el-table-column prop="cost" label="消费" />
  86. <el-table-column prop="ctr" label="点击率">
  87. <template slot-scope="scope">
  88. {{scope.row.ctr}}%
  89. </template>
  90. </el-table-column>
  91. <el-table-column prop="cpc" label="平均点击价格" />
  92. <el-table-column prop="cpm" label="千次展现消费" />
  93. <el-table-column prop="weixinFollowSuccessConversions" label="微信加粉成功" />
  94. <el-table-column prop="weixinFollowSuccessConversionsCost" label="微信加粉成本" />
  95. <el-table-column prop="feedOCPCConversionsDetail133" label="直播间微信加粉成功" />
  96. <el-table-column prop="feedOCPCConversionsDetail133Cost" label="直播间微信加粉成本" />
  97. </el-table>
  98. <pagination
  99. v-show="total>0"
  100. :total="total"
  101. :page.sync="queryParams.page"
  102. :limit.sync="queryParams.rowCount"
  103. @pagination="getReportData"
  104. />
  105. </div>
  106. </div>
  107. </template>
  108. <script>
  109. import {listStore} from "@/api/his/storeProduct";
  110. import echarts from 'echarts'
  111. import {orderChartData, storeOrderChart, storeOrderChartStore, storeExport} from "@/api/his/index";
  112. import {getReportData} from "@/api/baidu/statistics";
  113. import {getUserListByDeptId} from "@/api/company/companyUser";
  114. import {listAll} from "@/api/baidu/BdAccount";
  115. import Treeselect from "@riophae/vue-treeselect";
  116. import {treeselect} from "@/api/company/companyDept";
  117. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  118. export default {
  119. components: {Treeselect},
  120. data() {
  121. return {
  122. deptOptions: [],
  123. loading: false,
  124. total: 0,
  125. exportLoading: false,
  126. deptId: null,
  127. queryParams: {
  128. id: null,
  129. reportType: 2324048,
  130. startDate: null,
  131. endDate: null,
  132. time: '',
  133. page: 0,
  134. rowCount: 10,
  135. },
  136. accountList: [],
  137. users: [],
  138. dateList: [],
  139. tableList: [],
  140. planList: [],
  141. unitList: [],
  142. creativeList: [],
  143. chart: null,
  144. pload: false,
  145. uload: false,
  146. aload: false,
  147. dataList: [],
  148. options: [{
  149. value: '1',
  150. label: '今天'
  151. }, {
  152. value: '2',
  153. label: '昨天'
  154. }, {
  155. value: '3',
  156. label: '本周'
  157. }, {
  158. value: '4',
  159. label: '上周'
  160. }, {
  161. value: '5',
  162. label: '本月'
  163. }
  164. , {
  165. value: '6',
  166. label: '上月'
  167. },
  168. {
  169. value: '7',
  170. label: '本季度'
  171. },
  172. {
  173. value: '8',
  174. label: '上季度'
  175. }
  176. , {
  177. value: '9',
  178. label: '本年'
  179. }
  180. , {
  181. value: '10',
  182. label: '去年'
  183. }],
  184. options2: [{
  185. value: 2324048,
  186. label: '地域'
  187. }, {
  188. value: 2503330,
  189. label: '性别'
  190. }, {
  191. value: 2510393,
  192. label: '年龄'
  193. }, {
  194. value: 2532512,
  195. label: '意图词'
  196. }],
  197. };
  198. },
  199. created() {
  200. },
  201. mounted() {
  202. // this.chart = echarts.init(this.$refs.chartContainer, 'macarons');
  203. // this.chart.on('mouseout', this.hideTooltip);
  204. // this.updateChart();
  205. this.getReportData();
  206. this.getTreeselect();
  207. this.accountListFun();
  208. },
  209. watch: {
  210. // dataList() {
  211. // this.updateChart();
  212. // },
  213. 'deptId': 'currDeptChange'
  214. },
  215. methods: {
  216. planLoad(){
  217. },
  218. /** 导出按钮操作 */
  219. handleExport() {
  220. const queryParams = this.queryParams;
  221. this.$confirm('是否确认导出所有数据?', "警告", {
  222. confirmButtonText: "确定",
  223. cancelButtonText: "取消",
  224. type: "warning"
  225. }).then(() => {
  226. this.exportLoading = true;
  227. return storeExport(queryParams);
  228. }).then(response => {
  229. this.download(response.msg);
  230. this.exportLoading = false;
  231. }).catch(() => {
  232. });
  233. },
  234. /** 查询部门下拉树结构 */
  235. getTreeselect() {
  236. treeselect().then((response) => {
  237. this.deptOptions = response.data;
  238. if (response.data != null && response.data.length > 0) {
  239. this.dept.deptId = response.data[0].id;
  240. }
  241. });
  242. },
  243. currDeptChange(val) {
  244. this.deptId = val;
  245. this.getUserListByDeptId();
  246. },
  247. getUserListByDeptId() {
  248. this.queryParams.userId = undefined;
  249. var data = {deptId: this.deptId};
  250. getUserListByDeptId(data).then(response => {
  251. this.users = response.data;
  252. });
  253. },
  254. accountListFun() {
  255. listAll({userId: this.queryParams.userId}).then(e => {
  256. this.accountList = e.data;
  257. })
  258. },
  259. handleQuery() {
  260. this.getReportData();
  261. },
  262. /** 重置按钮操作 */
  263. resetQuery() {
  264. this.queryParams = {
  265. type: null,
  266. storeId: null,
  267. }
  268. this.getReportData()
  269. },
  270. getReportData() {
  271. if(!this.queryParams.id){
  272. return;
  273. }
  274. if(!this.queryParams.time || this.queryParams.time.length < 2){
  275. return;
  276. }
  277. this.queryParams.startDate = this.queryParams.time[0];
  278. this.queryParams.endDate = this.queryParams.time[1];
  279. this.loading = true;
  280. getReportData(this.queryParams).then(e => {
  281. this.dataList = e.data;
  282. this.loading = false;
  283. this.total = e.total;
  284. });
  285. },
  286. formatter(params) {
  287. const item1 = params[0].value;
  288. const item2 = params[1].value;
  289. const item3 = params[2].value;
  290. const item4 = params[3].value;
  291. return `
  292. <div>
  293. <div>日期:${params[0].axisValue}</div>
  294. <div>加微量:${item1}</div>
  295. <div>注册量:${item2}(${item2 == 0 || item1 == 0 ? "0" :((item2 / item1) * 100).toFixed(2)}%)</div>
  296. <div>完课量:${item3}(${item3 == 0 || item2 == 0 ? "0" :((item3 / item2) * 100).toFixed(2)}%)</div>
  297. <div>订单转化数:${item4}(${item4 == 0 || item2 == 0 ? "0" :((item4 / item2) * 100).toFixed(2)}%)</div>
  298. </div>
  299. `;
  300. },
  301. updateChart() {
  302. const option = {
  303. xAxis: {
  304. type: 'category',
  305. data: this.dateList,
  306. },
  307. yAxis: {
  308. type: 'value',
  309. },
  310. tooltip: {
  311. trigger: 'axis',
  312. formatter: this.formatter,
  313. axisPointer: {
  314. type: "line",
  315. lineStyle: {
  316. color: "rgba(227, 242, 252, 0.39)",
  317. width: 40,
  318. type: "solid",
  319. },
  320. z: 0, //注意要设置层级,不然会在覆盖在柱子前面,设置为0就在柱子后面显示了。
  321. },
  322. },
  323. series: [
  324. {
  325. name: '加微量',
  326. type: 'line',
  327. barWidth: '40%',
  328. label: {
  329. show: true,
  330. position: 'top',
  331. },
  332. data: this.dataList[0],
  333. },
  334. {
  335. name: '注册量',
  336. type: 'line',
  337. barWidth: '40%',
  338. label: {
  339. show: true,
  340. position: 'top',
  341. },
  342. data: this.dataList[1],
  343. },
  344. {
  345. name: '完课量',
  346. type: 'line',
  347. barWidth: '40%',
  348. label: {
  349. show: true,
  350. position: 'top',
  351. },
  352. data: this.dataList[2],
  353. },
  354. {
  355. name: '下单量',
  356. type: 'line',
  357. barWidth: '40%',
  358. label: {
  359. show: true,
  360. position: 'top',
  361. },
  362. data: this.dataList[3],
  363. },
  364. ],
  365. };
  366. this.chart.setOption(option);
  367. },
  368. hideTooltip() {
  369. this.chart.dispatchAction({
  370. type: 'hideTip',
  371. });
  372. },
  373. },
  374. };
  375. </script>
  376. <style>
  377. .title {
  378. padding: 20px 30px 0px 30px;
  379. font-size: 18px;
  380. font-weight: bold;
  381. color: black;
  382. }
  383. .search-form {
  384. margin: 20px 30px 0px 30px;
  385. }
  386. .echart-box {
  387. margin: 0 auto;
  388. text-align: center;
  389. }
  390. .el-select {
  391. margin: 5px 10px;
  392. }
  393. .table-box {
  394. margin-top: 15px;
  395. .export {
  396. float: right;
  397. margin: 10px 0px;
  398. }
  399. }
  400. .app-container {
  401. border: 1px solid #e6e6e6;
  402. padding: 12px;
  403. }
  404. .app-content {
  405. background-color: white;
  406. }
  407. .data-box {
  408. padding: 30px;
  409. background-color: rgb(255, 255, 255);
  410. height: 100%;
  411. }
  412. </style>