inquiryAnalysis.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <div>
  3. <a-row style="background: #fff; padding: 10px 15px; color: rgba(0, 0, 0, 0.85); margin-bottom: 10px">
  4. <!-- v-if="siteinfo.length != 1"-->
  5. <a-col :span="24">
  6. <span>请选择站点:</span>
  7. <a-select show-search option-filter-prop="children" :filter-option="filterOption" v-model="siteId" @change="changeUser" style="width: 300px">
  8. <a-select-option v-for="data in siteinfo" :key="data.id" :value="data.id">
  9. {{ data.name }}
  10. </a-select-option>
  11. </a-select>
  12. <a-button type="dashed" icon="reload" @click="reloadPage" style="margin-left: 20px">刷新</a-button>
  13. </a-col>
  14. </a-row>
  15. <a-row :gutter="10" class="middle-row">
  16. <a-col :xl="9" :lg="9" :md="9" :sm="24" :xs="24">
  17. <a-card :bordered="false" :body-style="{ padding: '0' }">
  18. <div class="salesCard">
  19. <a-tabs default-active-key="1" size="large">
  20. <a-tab-pane tab="询盘有效性饼图" key="1">
  21. <a-card :loading="mediumViewPieloading" :bordered="false" :body-style="{ padding: '0', width: '100%' }">
  22. <v-chart v-if="mediumViewPie.length > 1" :height="chartheight" :forceFit="true" :data="mediumPieData" :scale="mediumPieScale">
  23. <v-tooltip :showTitle="false" dataKey="item*percent" />
  24. <v-axis />
  25. <v-legend dataKey="item" />
  26. <v-pie position="percent" color="item" :v-style="pieStyle" :label="labelConfig" />
  27. <v-coord type="theta" />
  28. </v-chart>
  29. <a-empty v-else>
  30. <template #description>
  31. <span>暂无数据</span>
  32. </template>
  33. </a-empty>
  34. </a-card>
  35. </a-tab-pane>
  36. </a-tabs>
  37. </div>
  38. </a-card>
  39. </a-col>
  40. <a-col :xl="15" :lg="15" :md="15" :sm="24" :xs="24">
  41. <a-card :bordered="false" :body-style="{ padding: '0' }">
  42. <div class="salesCard">
  43. <a-tabs default-active-key="1" size="large">
  44. <a-tab-pane tab="询盘统计折线图" key="1">
  45. <a-card :loading="mediumViewLineloading" :bordered="false" :body-style="{ padding: '0', width: '100%' }">
  46. <line-chart-multid
  47. v-if="mediumViewLine.length > 1"
  48. :dataSource="mediumViewLine"
  49. :aliases="[{ field: 'num', alias: '询盘数' }]"
  50. :height="chartheight"
  51. />
  52. <a-empty v-else>
  53. <template #description>
  54. <span>暂无数据</span>
  55. </template>
  56. </a-empty>
  57. </a-card>
  58. </a-tab-pane>
  59. </a-tabs>
  60. </div>
  61. </a-card>
  62. </a-col>
  63. </a-row>
  64. <a-row style="margin-top: 10px">
  65. <a-col :span="24">
  66. <a-card :loading="enquiryChartloading" :bordered="false" title="询盘统计">
  67. <template #extra>
  68. <a :href="'/inquiry/list?siteId=' + siteId">询盘列表</a>
  69. </template>
  70. <a-row>
  71. <a-col :span="6">
  72. <head-info title="累计网站询盘" :content="enquiryInfo.total" />
  73. </a-col>
  74. <a-col :span="2">
  75. <a-spin class="circle-cust">
  76. <template #indicator>
  77. <a-icon type="rise" style="font-size: 24px" />
  78. </template>
  79. </a-spin>
  80. </a-col>
  81. <a-col :span="6">
  82. <head-info title="近7日累计询盘" :content="enquiryInfo.thisWeek" />
  83. </a-col>
  84. <a-col :span="2">
  85. <a-spin class="circle-cust">
  86. <template #indicator>
  87. <a-icon type="rise" style="font-size: 24px" />
  88. </template>
  89. </a-spin>
  90. </a-col>
  91. <a-col :span="6">
  92. <head-info title="近30日累计询盘" :content="enquiryInfo.thisMonth" />
  93. </a-col>
  94. <a-col :span="2">
  95. <a-spin class="circle-cust">
  96. <template #indicator>
  97. <a-icon type="rise" style="font-size: 24px" />
  98. </template>
  99. </a-spin>
  100. </a-col>
  101. </a-row>
  102. <bar-multid v-if="enquiryInfo.enquiryChart.length > 1" :dataSource="enquiryInfo.enquiryChart" :fields="enquiryInfo.enquiryFild" />
  103. <a-empty v-else>
  104. <template #description>
  105. <span>暂无数据</span>
  106. </template>
  107. </a-empty>
  108. </a-card>
  109. </a-col>
  110. </a-row>
  111. </div>
  112. </template>
  113. <script>
  114. import { DataSet } from '@antv/data-set';
  115. import { postAction, getAction } from '/@/api/manage/manage';
  116. import Qs from 'qs';
  117. import LineChartMultid from '/@/components/chart/LineMulti.vue';
  118. import Bar from '/@/components/chart/Bar.vue';
  119. import BarMultid from '/@/components/chart/BarMulti.vue';
  120. import MapAdweb from '/@/components/chart/mapAdweb.vue';
  121. import HeadInfo from '/@/components/tools/HeadInfo.vue';
  122. import ACol from 'ant-design-vue/es/grid/Col';
  123. export default {
  124. name: 'TrafficTrends',
  125. components: {
  126. BarMultid,
  127. LineChartMultid,
  128. Bar,
  129. HeadInfo,
  130. ACol,
  131. MapAdweb,
  132. },
  133. data() {
  134. return {
  135. mediumViewLineloading: true,
  136. mediumViewPieloading: true,
  137. mediumViewListloading: true,
  138. enquiryChartloading: true,
  139. siteinfo: [],
  140. defaultValue: '',
  141. siteId: '',
  142. siteCode: '',
  143. //图表高度
  144. chartheight: 400,
  145. mediumViewPie: [],
  146. mediumViewLine: [],
  147. mediumViewList: [],
  148. mediumPieScale: [
  149. {
  150. dataKey: 'percent',
  151. min: 0,
  152. formatter: '.0%',
  153. },
  154. ],
  155. pieStyle: {
  156. stroke: '#fff',
  157. lineWidth: 1,
  158. },
  159. labelConfig: [
  160. 'percent',
  161. {
  162. formatter: (val, item) => {
  163. return item.point.item + ': ' + val;
  164. },
  165. },
  166. ],
  167. //询盘数据
  168. enquiryInfo: {
  169. total: '0',
  170. thisWeek: '0',
  171. thisMonth: '0',
  172. enquiryFild: [],
  173. enquiryChart: [],
  174. },
  175. };
  176. },
  177. computed: {
  178. mediumPieData() {
  179. const dv = new DataSet.View().source(this.mediumViewPie);
  180. dv.transform({
  181. type: 'percent',
  182. field: 'count',
  183. dimension: 'item',
  184. as: 'percent',
  185. });
  186. return dv.rows;
  187. },
  188. },
  189. created() {
  190. this.getSiteInfo();
  191. },
  192. methods: {
  193. //进入获取站点code
  194. getSiteInfo() {
  195. let that = this;
  196. getAction('/sys/api/getSiteListByUid').then(function (res) {
  197. if (res.code == 0) {
  198. that.siteinfo = res.data;
  199. let isInSite = false;
  200. for (let i in res.data) {
  201. if (localStorage.getItem('siteCode') !== null && res.data[i].code === localStorage.getItem('siteCode')) {
  202. isInSite = true;
  203. that.siteId = res.data[i].id;
  204. }
  205. }
  206. if (localStorage.getItem('siteCode') !== null && isInSite) {
  207. } else {
  208. that.siteId = res.data[0].id;
  209. localStorage.setItem('siteCode', res.data[0].code);
  210. }
  211. that.getAllInfo();
  212. } else {
  213. that.$message.error('站点获取失败,请刷新重试');
  214. }
  215. });
  216. },
  217. //改变code的时候
  218. changeUser(value) {
  219. this.siteId = value;
  220. for (let i in this.siteinfo) {
  221. if (value == this.siteinfo[i].id) {
  222. localStorage.setItem('siteCode', this.siteinfo[i].code);
  223. }
  224. }
  225. this.getAllInfo();
  226. },
  227. //刷新获取全部数据
  228. getGoogleInfo() {
  229. let that = this;
  230. //获取图表数据
  231. let siteData = that.siteinfo;
  232. for (let i in siteData) {
  233. if (siteData[i].id == that.siteId) {
  234. that.siteCode = siteData[i].code;
  235. }
  236. }
  237. let chartd = {
  238. siteCode: that.siteCode,
  239. startTime: '',
  240. endTime: '',
  241. };
  242. //饼图
  243. postAction('/adweb/adwebEnquiry/effectivenessAnalysis/pie', Qs.stringify(chartd), 1000 * 60 * 2).then(function (res) {
  244. that.mediumViewPieloading = false;
  245. if (res.code == 200) {
  246. if (res.result[0].count == 0 && res.result[1].count == 0) {
  247. that.mediumViewPie = [];
  248. } else {
  249. that.mediumViewPie = res.result;
  250. }
  251. } else {
  252. that.mediumViewPie = [];
  253. }
  254. });
  255. //折线图
  256. postAction('/adweb/adwebEnquiry/effectivenessAnalysis/line', Qs.stringify(chartd), 1000 * 60 * 2).then(function (res) {
  257. that.mediumViewLineloading = false;
  258. if (res.code == 200) {
  259. that.mediumViewLine = res.result;
  260. } else {
  261. that.mediumViewLine = [];
  262. }
  263. });
  264. },
  265. getAllInfo() {
  266. let that = this;
  267. that.mediumViewPieloading = true;
  268. that.mediumViewLineloading = true;
  269. that.mediumViewListloading = true;
  270. //在请求完内部adweb接口后,请求google数据
  271. that.getGoogleInfo();
  272. //询盘数据
  273. let enquiryd = {
  274. siteId: that.siteId,
  275. day: 6,
  276. dayEnd: 1,
  277. };
  278. postAction('/adweb/adwebEnquiry/selectEnquiryCountV2', Qs.stringify(enquiryd), 1000 * 60 * 2).then(function (res) {
  279. that.enquiryChartloading = false;
  280. console.log(res.data.countDto.total);
  281. if (res.code == 0) {
  282. that.enquiryInfo.total = res.data.countDto.total.toString();
  283. that.enquiryInfo.thisWeek = res.data.countDto.thisWeek.toString();
  284. that.enquiryInfo.thisMonth = res.data.countDto.thisMonth.toString();
  285. let dateList = res.data.trendDto.dates;
  286. let dictsList = res.data.trendDto.dicts;
  287. let valuesList = res.data.trendDto.values;
  288. if (valuesList != null) {
  289. let arr = [];
  290. for (let i = 0; i < dictsList.length; i++) {
  291. let dict = dictsList[i];
  292. let value = dict.value;
  293. let label = dict.label;
  294. let values = valuesList[value];
  295. let obj = {};
  296. obj['label'] = label;
  297. for (let j = 0; j < dateList.length; j++) {
  298. obj[dateList[j]] = values[j];
  299. }
  300. arr.push(obj);
  301. }
  302. that.enquiryInfo.enquiryFild = dateList;
  303. that.enquiryInfo.enquiryChart = arr;
  304. } else {
  305. that.enquiryInfo.enquiryChart = [];
  306. }
  307. } else {
  308. that.enquiryInfo.total = 0;
  309. that.enquiryInfo.thisWeek = 0;
  310. that.enquiryInfo.thisMonth = 0;
  311. that.enquiryInfo.enquiryFild = [];
  312. that.enquiryInfo.enquiryChart = [];
  313. }
  314. });
  315. },
  316. //刷新页面
  317. reloadPage() {
  318. this.getAllInfo();
  319. },
  320. filterOption(input, option) {
  321. return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0;
  322. },
  323. },
  324. };
  325. </script>
  326. <style lang="less" scoped>
  327. .circle-cust {
  328. position: relative;
  329. top: 28px;
  330. left: -100%;
  331. }
  332. .middle-row .ant-tabs-tabpane .ant-card {
  333. height: 430px;
  334. align-items: center;
  335. justify-content: center;
  336. display: flex;
  337. }
  338. </style>