total_rank.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <div>
  3. <div class="diy_tip_bg" v-show="tips_show">
  4. <el-alert class="diy-tip" @close="tips_close" type="success" description><p>排名包含初始分和工龄分</p></el-alert>
  5. </div>
  6. <div class="manager_statistics_box">
  7. <el-form :inline="true">
  8. <el-form-item label="部门">
  9. <el-cascader
  10. size="medium"
  11. class="date-picker-width"
  12. v-model="dept_name"
  13. :options="dept_tree"
  14. :props="{ checkStrictly: true,value:'id',label:'name',children:'_child'}"
  15. ref="dept"
  16. clearable
  17. filterable
  18. placeholder="全公司"
  19. ></el-cascader>
  20. </el-form-item>
  21. <el-form-item>
  22. <el-checkbox v-model="sort" size="medium" label="排名由低到高" border></el-checkbox>
  23. <el-button type="primary" size="medium" @click="dialogVisible = true" style="margin-left: 10px;" plain>导出排名</el-button>
  24. </el-form-item>
  25. </el-form>
  26. <el-table :data="list" style="width: 100%" v-loading="loading">
  27. <el-table-column label="名次" width="80" align="center">
  28. <template slot-scope="scope">
  29. <img v-if="scope.row.rank === 1" src="@/assets/image/statistics_NO1.png" alt="" />
  30. <img v-if="scope.row.rank === 2" src="@/assets/image/statistics_NO2.png" alt="" />
  31. <img v-if="scope.row.rank === 3" src="@/assets/image/statistics_NO3.png" alt="" />
  32. <span v-if="scope.row.rank > 3">{{ scope.row.rank }}</span>
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="姓名" align="left">
  36. <template slot-scope="scope">
  37. <div class="flex-box">
  38. <userImage class="fl" :user_name="scope.row.employee_name" :img_url="scope.row.employee_img_url" width="50px" height="50px"></userImage>
  39. <span style="line-height: 50px; padding-left: 10px;">{{ scope.row.employee_name }}</span>
  40. </div>
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="B分" align="left" prop="point"></el-table-column>
  44. <template slot="empty">
  45. <div class="nopoint_box">
  46. <div class="noimg noperson"></div>
  47. <span class="title">没有对应的数据</span>
  48. </div>
  49. </template>
  50. </el-table>
  51. <center style="padding: 20px 0;">
  52. <el-pagination
  53. background
  54. @size-change="handleSizeChange"
  55. @current-change="handleCurrentChange"
  56. :current-page="formData.page"
  57. :page-sizes="[10, 20, 30, 40, 50, 100]"
  58. layout="total, sizes, prev, pager, next"
  59. :page-size="pageLimit"
  60. :total="total"
  61. ></el-pagination>
  62. </center>
  63. </div>
  64. <!-- 导出弹窗 -->
  65. <el-dialog title="导出排名" :visible.sync="dialogVisible" width="730px" top="10%">
  66. <span style="font-size:15px">系统将按以下已选条件导出对应的排名报表</span>
  67. <el-form :inline="true">
  68. <div class="picker_er">
  69. <el-form-item label="时间">
  70. <el-date-picker
  71. v-model="Dc_Data.value1"
  72. type="daterange"
  73. size="medium"
  74. value-format="yyyy-MM-dd"
  75. format="yyyy-MM-dd"
  76. range-separator="至"
  77. start-placeholder="开始日期"
  78. end-placeholder="结束日期"
  79. ></el-date-picker>
  80. </el-form-item>
  81. <el-form-item label="人员" style="margin-left:30px">
  82. <el-select size="medium" v-model="Dc_Data.DC_position" style="width:150px" placeholder="请选择">
  83. <el-option v-for="item in positions" :key="item.id" :label="item.name" :value="item.age"></el-option>
  84. </el-select>
  85. </el-form-item>
  86. </div>
  87. <el-form-item label="部门">
  88. <el-cascader
  89. class="date-picker-width cascader_bm"
  90. v-model="Dc_Data.dept_name"
  91. :options="dept_tree"
  92. :props="{ checkStrictly: true,value:'id',label:'name',children:'_child'}"
  93. ref="dept2"
  94. size="medium"
  95. clearable
  96. filterable
  97. placeholder="全公司"
  98. ></el-cascader>
  99. </el-form-item>
  100. </el-form>
  101. <span slot="footer" class="dialog-footer">
  102. <el-button @click="dialogVisible = false" size="medium">取 消</el-button>
  103. <el-button type="primary" @click="exportExcel" size="medium">导 出</el-button>
  104. </span>
  105. </el-dialog>
  106. </div>
  107. </template>
  108. <script>
  109. export default {
  110. data() {
  111. return {
  112. dept_name: [],
  113. dept_tree: [],
  114. loading: false,
  115. formData: {
  116. dept_id: '0',
  117. sort: 'DESC',
  118. page: 1,
  119. page_size: 10,
  120. pt_id: 3,
  121. type: 'all'
  122. },
  123. sort: false,
  124. list: null,
  125. pageLimit: 10,
  126. total: null,
  127. tips_show: false,
  128. dialogVisible:false,
  129. positions: [{ id: 0, age: 'all', name: '全部' }, { id: 1, age: 'manager', name: '管理者' }, { id: 2, age: 'employee', name: '员工' }],
  130. Dc_Data: {
  131. //导出数据
  132. value1: '', //时间
  133. DC_position: '全部', //人员
  134. dept_name: [], //部门
  135. },
  136. };
  137. },
  138. watch: {
  139. sort(val) {
  140. if (val) {
  141. this.formData.sort = 'ASC';
  142. } else {
  143. this.formData.sort = 'DESC';
  144. }
  145. this.formData.page = 1;
  146. this.get_list();
  147. },
  148. dept_name(val) {
  149. if (val.length !== 0) {
  150. this.formData.dept_id = val[val.length - 1];
  151. } else {
  152. this.formData.dept_id = '0';
  153. }
  154. this.formData.page = 1;
  155. this.$nextTick(() => {
  156. this.$refs.dept.dropDownVisible = false;
  157. this.get_list();
  158. });
  159. }
  160. },
  161. methods: {
  162. exportExcel() {
  163. //人员
  164. this.Dc_Data.DC_position =this.Dc_Data.DC_position == 'manager' ? 'manager' : this.Dc_Data.DC_position == 'employee' ? 'employee' : this.Dc_Data.DC_position == '全部' ? 'all' : 'all';
  165. //部门
  166. let dept_name;
  167. for (let i in this.Dc_Data.dept_name) {
  168. dept_name = this.Dc_Data.dept_name[i];
  169. }
  170. this.Dc_Data.dept_name = dept_name;
  171. //规则
  172. let rule_id = [];
  173. for (let i in this.Dc_Data.rule_id) {
  174. for (let a in this.Dc_Data.rule_id[i]) {
  175. rule_id.push(this.Dc_Data.rule_id[i][a]);
  176. }
  177. }
  178. this.Dc_Data.rule_id = rule_id;
  179. let data = '';
  180. if (this.Dc_Data.value1) {
  181. data += '&start_date=' + this.Dc_Data.value1[0];
  182. data += '&end_date=' + this.Dc_Data.value1[1];
  183. }
  184. data += '&position=' + this.Dc_Data.DC_position;
  185. this.Dc_Data.dept_name > 0 ? (data += '&dept_id=' + this.Dc_Data.dept_name) : (data += '&dept_id=0');
  186. if (this.Dc_Data.rule_id.length > 0) {
  187. data += '&rule_id=' + this.Dc_Data.rule_id;
  188. }
  189. var tempwindow = window.open('_blank'); // 先打开页面
  190. tempwindow.document.write(
  191. "<p style='text-align:center;padding-top:50px;font-size:24px'>数据报表正在生成,生成后将自动下载,请不要关闭此标签页<br/><span style='font-size:17px'>(如网络错误请刷新后重试)<span/></p>"
  192. );
  193. tempwindow.document.title = '导出';
  194. tempwindow.location = process.env.VUE_APP_BASE_API + '/api/download/ranking/v2?pt_id=3&type=all&employee_id='+this.$getUserData().id+ data; // 后更改页面地址
  195. this.dialogVisible = false;
  196. },
  197. // 提示信息
  198. tips_close() {
  199. localStorage.setItem('total_rank_tips', 'true');
  200. this.tips_show = false;
  201. },
  202. // 页面变更
  203. handleCurrentChange(val) {
  204. this.formData.page = val;
  205. this.get_list();
  206. },
  207. handleSizeChange(val) {
  208. this.pageLimit = val;
  209. this.formData.page_size = this.pageLimit;
  210. this.get_list();
  211. },
  212. //获取部门
  213. getDepartment() {
  214. this.$axios('get','/api/department/tree').then(res => {
  215. this.dept_tree =this.getTreeData(res.data.data.list);
  216. });
  217. },
  218. get_list() {
  219. this.loading = true;
  220. this.$axios('get','/api/integral/statistics/ranking', this.formData,'v2').then(res => {
  221. if (res.data.code == 1) {
  222. this.list = res.data.data.list;
  223. this.total = res.data.data.total;
  224. } else {
  225. this.$message.error(res.data.data.msg);
  226. }
  227. })
  228. .finally(() => {
  229. this.loading = false;
  230. });
  231. },
  232. // 递归判断列表,把最后的children设为undefined
  233. getTreeData(data) {
  234. for (var i = 0; i < data.length; i++) {
  235. if (data[i]._child.length < 1) {
  236. // children若为空数组,则将children设为undefined
  237. data[i]._child = undefined;
  238. } else {
  239. // children若不为空数组,则继续 递归调用 本方法
  240. this.getTreeData(data[i]._child);
  241. }
  242. }
  243. return data;
  244. }
  245. },
  246. created() {
  247. this.getDepartment();
  248. },
  249. mounted() {
  250. this.tips_show = JSON.parse(localStorage.getItem('total_rank_tips')) ? false : true;
  251. this.get_list();
  252. }
  253. };
  254. </script>
  255. <style scoped lang="scss">
  256. .search_box {
  257. ::v-deep button:active {
  258. background: #26a2ff;
  259. }
  260. ::v-deep button:active .el-icon-search {
  261. color: #fff;
  262. }
  263. }
  264. .date-picker-width {
  265. width: 100% !important;
  266. }
  267. .color_green {
  268. color: #67c23a;
  269. }
  270. .nopoint_box {
  271. display: inline-block;
  272. text-align: center;
  273. width: 100%;
  274. margin-bottom: 10px;
  275. }
  276. .noimg {
  277. display: inline-block;
  278. width: 110px;
  279. height: 110px;
  280. margin: 22px auto 16px;
  281. background-size: 99%;
  282. }
  283. .noperson {
  284. display: inline-block;
  285. width: 110px;
  286. height: 110px;
  287. line-height: none;
  288. margin: 22px auto 16px;
  289. // background: url("@/assets/image/rules_mould.png") no-repeat center;
  290. background-size: 99%;
  291. }
  292. .title {
  293. display: block;
  294. text-align: center;
  295. font-size: 12px !important;
  296. line-height: 30px;
  297. color: #909399 !important;
  298. padding: 0;
  299. }
  300. .nopoint_box a {
  301. color: #26a2ff;
  302. }
  303. .chart_content {
  304. .chart-legend__wrap {
  305. text-align: right;
  306. padding: 20px;
  307. padding-right: 50px;
  308. & .chart-legend__pink {
  309. position: relative;
  310. padding-left: 12px;
  311. padding-right: 5px;
  312. &:after {
  313. content: '';
  314. position: absolute;
  315. margin-top: -2px;
  316. top: 35%;
  317. left: 0;
  318. width: 8px;
  319. height: 8px;
  320. background: #f56c6c;
  321. border-radius: 100%;
  322. }
  323. }
  324. & .chart-legend__green {
  325. position: relative;
  326. padding-left: 12px;
  327. &:after {
  328. content: '';
  329. position: absolute;
  330. margin-top: -2px;
  331. top: 35%;
  332. left: 0;
  333. width: 8px;
  334. height: 8px;
  335. background: #53b87f;
  336. border-radius: 100%;
  337. }
  338. }
  339. }
  340. }
  341. .drawer_title {
  342. font-size: 18px;
  343. padding: 20px;
  344. }
  345. .manager_statistics_box {
  346. background-color: #ffffff;
  347. padding: 20px;
  348. min-height: calc(100vh - 160px);
  349. ::v-deep .el-row .el-checkbox .el-checkbox__label {
  350. line-height: 20px;
  351. }
  352. }
  353. .diy_tip_bg {
  354. background: #f5f6f9;
  355. overflow: hidden;
  356. .diy-tip {
  357. margin-bottom: 15px;
  358. border: 1px solid #67c23a;
  359. padding: 20px 16px;
  360. p {
  361. color: #67c23a !important;
  362. font-size: 14px;
  363. margin: 0 !important;
  364. padding: 4px 0;
  365. }
  366. }
  367. }
  368. </style>