adOld.vue 13 KB

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