adReadData.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <div class="content">
  3. <header>浏览数据</header>
  4. <div class="main">
  5. <div class="chart-box">
  6. <div :id="type + 'pie1'" style="width:100%"></div>
  7. </div>
  8. <div style="flex:1;">
  9. <div class="title-box">
  10. <div class="title">未浏览{{ type == 'agency' ? '经销商' : '业务员' }}</div>
  11. <exportExcel :tablecols="unReadData.tablecols" :param="unReadData.params"
  12. :excelTitle="type == 'agency' ? '推广素材经销商未浏览表' : '推广素材团队未浏览表'" />
  13. </div>
  14. <!-- 未读表格 -->
  15. <tableLayout style="margin-top:16px" :layout="unReadData.tablecols" :data="unReadData.list"
  16. :custom="true">
  17. <template v-slot:customcol="scope">
  18. <div v-if="scope.column.columnname == 'region'">
  19. {{ scope.column.data.province }}{{ scope.column.data.city }}{{ scope.column.data.county }}
  20. </div>
  21. <p v-else>{{ scope.column.data[scope.column.columnname] }}</p>
  22. </template>
  23. </tableLayout>
  24. <div style="margin-top:16px;text-align:right">
  25. <el-pagination background small @current-change="handlUnReadCurrentChange"
  26. :current-page="unReadData.pageNumber" :page-size="unReadData.pageSize"
  27. layout="total, prev, pager, next, jumper" :total="unReadData.total">
  28. </el-pagination>
  29. </div>
  30. <div class="title-box" style="margin-top:30px">
  31. <div class="title">已浏览{{ type == 'agency' ? '经销商' : '业务员' }}</div>
  32. <exportExcel :tablecols="readData.tablecols" :param="readData.params"
  33. :excelTitle="type == 'agency' ? '推广素材经销商已浏览表' : '推广素材团队已浏览表'" />
  34. </div>
  35. <!-- 已读表格 -->
  36. <tableLayout style="margin-top:16px" :layout="readData.tablecols" :data="readData.list" :custom="true">
  37. <template v-slot:customcol="scope">
  38. <div v-if="scope.column.columnname == 'region'">
  39. {{ scope.column.data.province }}{{ scope.column.data.city }}{{ scope.column.data.county }}
  40. </div>
  41. <div v-else-if="scope.column.columnname == 'isdownloadfile'">
  42. {{ scope.column.data.isdownloadfile == 1 ? '是' : '否' }}
  43. </div>
  44. <p v-else>{{ scope.column.data[scope.column.columnname] }}</p>
  45. </template>
  46. </tableLayout>
  47. <div style="margin-top:16px;text-align:right">
  48. <el-pagination background small @current-change="handlReadCurrentChange"
  49. :current-page="readData.pageNumber" :page-size="readData.pageSize"
  50. layout="total, prev, pager, next, jumper" :total="readData.total">
  51. </el-pagination>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. </template>
  57. <script>
  58. import exportExcel from "@/components/export_excel";
  59. import { Pie } from '@antv/g2plot';
  60. export default {
  61. props: ["type"],
  62. components: { exportExcel },
  63. data() {
  64. return {
  65. //已读对象
  66. readData: {
  67. tablecols: [],
  68. list: [],
  69. pageNumber: 1,
  70. pageSize: 10,
  71. total: 0
  72. },
  73. //未读对象
  74. unReadData: {
  75. tablecols: [],
  76. list: [],
  77. pageNumber: 1,
  78. pageSize: 10,
  79. total: 0
  80. }
  81. }
  82. },
  83. methods: {
  84. /* 获取已读表格 */
  85. getReadList() {
  86. let params = {
  87. classname: this.classname,
  88. "method": "getReadList",
  89. "content": {
  90. "sat_sharematerialid": this.$route.query.id,
  91. pageNumber: this.readData.pageNumber,
  92. pageSize: this.readData.pageSize,
  93. "isAll": false
  94. }
  95. };
  96. this.$api.requested(params).then(res => {
  97. console.log(this.type, "read", res)
  98. if (res.msg != '成功') return this.$message.error(res.data);
  99. this.readData.params = params;
  100. this.readData.list = res.data;
  101. this.readData.pageNumber = res.pageNumber;
  102. this.readData.total = res.total;
  103. });
  104. },
  105. /* 获取未读表格 */
  106. getUnReadList() {
  107. let params = {
  108. classname: this.classname,
  109. "method": "getUnReadList",
  110. "content": {
  111. "sat_sharematerialid": this.$route.query.id,
  112. pageNumber: this.unReadData.pageNumber,
  113. pageSize: this.unReadData.pageSize,
  114. "isAll": false
  115. }
  116. };
  117. this.$api.requested(params).then(res => {
  118. console.log(this.type, "unread", res)
  119. if (res.msg != '成功') return this.$message.error(res.data);
  120. this.unReadData.params = params;
  121. this.unReadData.list = res.data;
  122. this.unReadData.pageNumber = res.pageNumber;
  123. this.unReadData.total = res.total;
  124. });
  125. },
  126. /* 已读切换分页 */
  127. handlReadCurrentChange(index) {
  128. this.readData.pageNumber = index;
  129. this.getReadList();
  130. },
  131. /* 未读切换分页 */
  132. handlUnReadCurrentChange(index) {
  133. this.unReadData.pageNumber = index;
  134. this.getUnReadList();
  135. },
  136. /* 渲染表格 */
  137. renderer(data) {
  138. const piePlot = new Pie(this.type + 'pie1', {
  139. appendPadding: 10,
  140. data,
  141. angleField: 'value',
  142. colorField: 'type',
  143. radius: 0.75,
  144. color: ['#FBB33B','#F77655'],
  145. legend: {
  146. position: 'leftTop'
  147. },
  148. label: {
  149. type: 'spider',
  150. labelHeight: 28,
  151. content: '{name}\n{percentage}',
  152. },
  153. interactions: [{ type: 'element-selected' }, { type: 'element-active' }],
  154. });
  155. piePlot.render();
  156. },
  157. },
  158. created() {
  159. //判断经销商数据还是内部数据
  160. this.readData.tablecols = this.tool.tabelCol('archives_adlist')[`${this.type}ReadTable`].tablecols;
  161. this.unReadData.tablecols = this.tool.tabelCol('archives_adlist')[`${this.type}UnreadTable`].tablecols;
  162. this.classname = this.type == 'agency' ? "webmanage.saletool.sharematerial.statistics.agent" : "webmanage.saletool.sharematerial.statistics.team";
  163. this.getUnReadList();
  164. this.getReadList();
  165. },
  166. mounted() {
  167. this.$api.requested({
  168. "classname": this.type == 'agency' ? "webmanage.saletool.sharematerial.statistics.agent" : "webmanage.saletool.sharematerial.statistics.team",
  169. "method": "getData",
  170. "content": {
  171. "sat_sharematerialid": this.$route.query.id
  172. }
  173. }).then(res => {
  174. if (res.msg != '成功') return this.$message.error(res.data);
  175. const data = [
  176. { type: '未浏览', value: res.data.unreadNum },
  177. { type: '已浏览', value: res.data.readNum },
  178. ];
  179. this.renderer(data);
  180. })
  181. }
  182. }
  183. </script>
  184. <style scoped>
  185. @import url('./public.css');
  186. </style>