total_rank.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  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>
  5. <p><b>累计排名常用于长期激励</b></p>
  6. <li class="headLi">累计排名包含从入职开始至今所有的积分(包含基础分和工龄分)</li>
  7. <li class="headLi">导出时,额外支持自定义时间段排名、工龄分排名、管理者/员工排名的导出</li>
  8. </el-alert>
  9. </div>
  10. <div class="manager_statistics_box">
  11. <el-form :inline="true">
  12. <el-form-item label="部门">
  13. <deptData deptStyle="height:24px;line-height:24px;margin-top:7px;" v-if="toPdept && toPdept!=0" :refsName="$refs.dept" :toPdept="toPdept"></deptData>
  14. <el-cascader class="date-picker-width" v-model="dept_name" :props="{ label: 'name', value: 'id'}" :options="dept_tree" ref="dept" clearable filterable change-on-select placeholder="全公司">
  15. <template slot-scope="{ node, data }">
  16. <span>
  17. <WWOpenData type="departmentName" :openid="data.name"></WWOpenData>
  18. </span>
  19. <!-- <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span> -->
  20. </template>
  21. </el-cascader>
  22. </el-form-item>
  23. <el-form-item><el-checkbox v-model="agePolyethism" size="medium" label="只看工龄分" border></el-checkbox></el-form-item>
  24. <el-form-item><el-checkbox v-model="sort" size="medium" label="排名由低到高" border></el-checkbox></el-form-item>
  25. <el-form-item>
  26. <!-- <el-button type="primary" plain @click="dialogVisible = true">导出排名</el-button> -->
  27. <!-- <el-button type="primary" plain @click="byRanking">轮播排名</el-button> -->
  28. </el-form-item>
  29. </el-form>
  30. <el-table :data="list" style="width: 100%" v-loading="loading">
  31. <el-table-column label="名次" width="80" align="center">
  32. <template slot-scope="scope">
  33. <img v-if="scope.row.rank === 1" src="/static/images/statistics_NO1.png" alt="" />
  34. <img v-if="scope.row.rank === 2" src="/static/images/statistics_NO2.png" alt="" />
  35. <img v-if="scope.row.rank === 3" src="/static/images/statistics_NO3.png" alt="" />
  36. <span v-if="scope.row.rank > 3">{{ scope.row.rank }}</span>
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="姓名" align="left">
  40. <template slot-scope="scope">
  41. <userImage class="fl" :id="scope.row.employee_id" :user_name="scope.row.employee_name" :img_url="scope.row.employee_img_url" width="50px" height="50px"></userImage>
  42. <span style="line-height: 50px; padding-left: 10px;"><WWOpenData type="userName" :openid="scope.row.employee_name"></WWOpenData></span>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="B分" align="left" prop="point"></el-table-column>
  46. <template slot="empty">
  47. <div class="nopoint_box">
  48. <div class="noimg noperson"></div>
  49. <span class="title">没有对应的数据</span>
  50. </div>
  51. </template>
  52. </el-table>
  53. <center style="padding: 20px 0;">
  54. <el-pagination
  55. background
  56. @size-change="handleSizeChange"
  57. @current-change="handleCurrentChange"
  58. :current-page="formData.page"
  59. :page-sizes="[10, 20, 50, 100]"
  60. layout="total, sizes, prev, pager, next"
  61. :page-size="pageLimit"
  62. :total="total"
  63. ></el-pagination>
  64. </center>
  65. </div>
  66. <!-- 导出弹窗 -->
  67. <el-dialog title="导出排名" :visible.sync="dialogVisible" width="730px">
  68. <div style="font-size:15px;margin-top:20px;"><span>系统将按以下已选条件导出对应的排名报表 </span>
  69. <el-checkbox v-model="deriveAgePolyethism" style="margin-left:20px;"><b>只看工龄分</b></el-checkbox></div>
  70. <el-form :inline="true">
  71. <div class="picker_er" style="margin-top:20px">
  72. <el-form-item label="时间">
  73. <el-date-picker
  74. v-model="Dc_Data.value1"
  75. type="daterange"
  76. value-format="yyyy-MM-dd"
  77. format="yyyy-MM-dd"
  78. range-separator="至"
  79. start-placeholder="开始日期"
  80. end-placeholder="结束日期"
  81. :disabled="deriveAgePolyethism"
  82. ></el-date-picker>
  83. </el-form-item>
  84. <el-form-item label="人员" style="margin-left:30px">
  85. <el-select v-model="Dc_Data.DC_position" style="width:150px" placeholder="请选择">
  86. <el-option v-for="item in positions" :key="item.id" :label="item.name" :value="item.age"></el-option>
  87. </el-select>
  88. </el-form-item>
  89. </div>
  90. <el-form-item label="部门">
  91. <deptData deptStyle="height:24px;line-height:24px;margin-top:7px;" v-if="toPdept2 && toPdept2!=0" :refsName="$refs.dept2" :toPdept="toPdept2"></deptData>
  92. <el-cascader
  93. class="date-picker-width cascader_bm"
  94. v-model="Dc_Data.dept_name"
  95. :options="dept_tree"
  96. :props="{ label: 'name', value: 'id'}"
  97. ref="dept2"
  98. clearable
  99. filterable
  100. change-on-select
  101. placeholder="全公司"
  102. >
  103. <template slot-scope="{ node, data }">
  104. <span>
  105. <WWOpenData type="departmentName" :openid="data.name"></WWOpenData>
  106. </span>
  107. <!-- <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span> -->
  108. </template>
  109. </el-cascader>
  110. </el-form-item>
  111. <!-- <el-form-item label="规则分类" style="margin-left:20px">
  112. <el-cascader
  113. class="date-picker-width"
  114. v-model="Dc_Data.rule_id"
  115. :options="rule_trees"
  116. :props="props"
  117. ref="rule"
  118. clearable
  119. collapse-tags
  120. placeholder="请选择规则分类"
  121. ></el-cascader>
  122. </el-form-item> -->
  123. </el-form>
  124. <span slot="footer" class="dialog-footer">
  125. <el-button @click="dialogVisible = false">取 消</el-button>
  126. <el-button type="primary" @click="exportExcel">导 出</el-button>
  127. </span>
  128. </el-dialog>
  129. <el-dialog title="轮播排名" :visible.sync="byRankingShow" width="500px">
  130. <div>
  131. <el-form :inline="true" ref="byRankingData" :model="byRankingData" :rules="byRankingDataRules" label-width="90px">
  132. <div style="color:rgb(122 202 126);font-size: 13px;padding:5px 0 20px 0">设置后,相关排名信息可在各类智能终端屏幕上的网页浏览器滚屏展示</div>
  133. <el-form-item label="展示标题">
  134. <el-input
  135. type="textarea"
  136. :autosize="{ minRows: 2, maxRows: 6 }"
  137. v-model="titleVals"
  138. placeholder="请输入标题"
  139. maxlength="20"
  140. show-word-limit
  141. style="width: 341px"
  142. ></el-input>
  143. </el-form-item>
  144. <el-form-item label="选择部门">
  145. <deptData deptStyle="height:24px;line-height:24px;margin-top:7px;" v-if="toPdept1 && toPdept1!=0" :refsName="$refs.dept1" :toPdept="toPdept1"></deptData>
  146. <el-cascader
  147. class="date-picker-width"
  148. v-model="byRankingDeptId"
  149. :options="dept_tree"
  150. :props="{ label: 'name', value: 'id'}"
  151. ref="dept1"
  152. clearable
  153. filterable
  154. change-on-select
  155. placeholder="全公司"
  156. >
  157. <template slot-scope="{ node, data }">
  158. <span>
  159. <WWOpenData type="departmentName" :openid="data.name"></WWOpenData>
  160. </span>
  161. <!-- <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span> -->
  162. </template>
  163. </el-cascader>
  164. </el-form-item>
  165. <el-form-item label="人员范围" prop="position" :required="true">
  166. <el-radio-group v-model="byRankingData.position">
  167. <el-radio label="all">管理者和员工</el-radio>
  168. <el-radio label="manager">只看管理者</el-radio>
  169. <el-radio label="employee">只看员工</el-radio>
  170. </el-radio-group>
  171. </el-form-item>
  172. </el-form>
  173. </div>
  174. <span slot="footer">
  175. <el-button @click="byRankingShow = false">取 消</el-button>
  176. <el-button type="primary" @click="swiperPage('byRankingData')">开始轮播</el-button>
  177. </span>
  178. </el-dialog>
  179. </div>
  180. </template>
  181. <script>
  182. import { getToken } from '@/utils/auth';
  183. export default {
  184. data() {
  185. return {
  186. dialogVisible: false,
  187. Dc_Data: {
  188. //导出数据
  189. value1: '', //时间
  190. DC_position: '全部', //人员
  191. dept_name: [], //部门
  192. work_age:0
  193. // rule_id: [], //规则
  194. },
  195. // positions: [
  196. // { id: 0, age: "all", name: "全部" },
  197. // { id: 1, age: "manager", name: "管理者" },
  198. // { id: 2, age: "employee", name: "员工" },
  199. // ],
  200. titleVals: '',
  201. titleVal: {
  202. titleVal1: '',
  203. titleVal2: '',
  204. titleVal3: ''
  205. },
  206. DC_position: 0,
  207. positions: [{ id: 0, age: 'all', name: '全部' }, { id: 1, age: 'manager', name: '管理者' }, { id: 2, age: 'employee', name: '员工' }],
  208. byRankingDeptId: '', //部门
  209. byRankingData: {
  210. //部门ID
  211. dept_id: 0,
  212. position: 'all'
  213. },
  214. byRankingShow: false, //轮播排名弹窗
  215. byRankingDataRules: {
  216. //提示
  217. // dept_id: [
  218. // { required: true, message: '请选择部门', trigger: 'blur' }
  219. // ],
  220. },
  221. // 20200806
  222. dept_name: [],
  223. dept_tree: [],
  224. loading: false,
  225. formData: {
  226. dept_id: '0',
  227. sort: 'DESC',
  228. page: 1,
  229. page_size: 10,
  230. pt_id: 3,
  231. type: 'all',
  232. work_age:0,
  233. },
  234. agePolyethism:false,
  235. deriveAgePolyethism:false,
  236. sort: false,
  237. list: null,
  238. pageLimit: 10,
  239. total: null,
  240. tips_show: false,
  241. toPdept:0,
  242. toPdept1:0,
  243. toPdept2:0,
  244. };
  245. },
  246. watch: {
  247. deriveAgePolyethism(val){
  248. if(val){
  249. this.Dc_Data.work_age = 1
  250. this.Dc_Data.value1 = null
  251. }else{
  252. this.Dc_Data.work_age = 0
  253. }
  254. },
  255. agePolyethism(val){
  256. if(val){
  257. this.formData.work_age = 1
  258. }else{
  259. this.formData.work_age = 0
  260. }
  261. this.formData.page = 1;
  262. this.get_list();
  263. },
  264. sort(val) {
  265. if (val) {
  266. this.formData.sort = 'ASC';
  267. } else {
  268. this.formData.sort = 'DESC';
  269. }
  270. this.formData.page = 1;
  271. this.get_list();
  272. },
  273. dept_name(val) {
  274. this.toPdept = val[val.length-1]
  275. if (val.length !== 0) {
  276. this.formData.dept_id = val[val.length - 1];
  277. } else {
  278. this.formData.dept_id = '0';
  279. }
  280. this.formData.page = 1;
  281. this.$nextTick(() => {
  282. this.$refs.dept.dropDownVisible = false;
  283. this.get_list();
  284. });
  285. },
  286. byRankingDeptId(val) {
  287. this.toPdept1 = val[val.length-1]
  288. this.byRankingDeptId = val;
  289. this.$refs.dept1.dropDownVisible = false;
  290. },
  291. 'Dc_Data.dept_name': function(val) {
  292. this.toPdept2 = val[val.length-1]
  293. this.$refs.dept2.dropDownVisible = false;
  294. }
  295. },
  296. methods: {
  297. exportExcel() {
  298. //人员
  299. this.Dc_Data.DC_position =
  300. this.Dc_Data.DC_position == 'manager' ? 'manager' : this.Dc_Data.DC_position == 'employee' ? 'employee' : this.Dc_Data.DC_position == '全部' ? 'all' : 'all';
  301. //部门
  302. let dept_name;
  303. for (let i in this.Dc_Data.dept_name) {
  304. dept_name = this.Dc_Data.dept_name[i];
  305. }
  306. this.Dc_Data.dept_name = dept_name;
  307. let data = '';
  308. if (this.Dc_Data.value1) {
  309. data += '&start_date=' + this.Dc_Data.value1[0];
  310. data += '&end_date=' + this.Dc_Data.value1[1];
  311. }
  312. data += '&position=' + this.Dc_Data.DC_position;
  313. data += '&work_age=' + this.Dc_Data.work_age
  314. this.Dc_Data.dept_name > 0 ? (data += '&dept_id=' + this.Dc_Data.dept_name) : (data += '&dept_id=0');
  315. // var id = window.open(
  316. // process.env.BASE_API +
  317. // "/api/download/ranking/v2?pt_id=3&type=all&employee_id=" +
  318. // this.$store.getters.user_info.id +
  319. // data,
  320. // "_blank"
  321. // );
  322. var tempwindow = window.open('_blank'); // 先打开页面
  323. tempwindow.document.write(
  324. "<p style='text-align:center;padding-top:50px;font-size:24px'>数据报表正在生成,生成后将自动下载,请不要关闭此标签页<br/><span style='font-size:17px'>(如网络错误请刷新后重试)<span/></p>"
  325. );
  326. tempwindow.document.title = '导出';
  327. let token = this.$getToken?this.$getToken:getToken()
  328. tempwindow.location = process.env.BASE_API + '/api/download/ranking/v2?pt_id=3&type=all&employee_id=' + this.$store.getters.user_info.id + data+'&token='+token; // 后更改页面地址
  329. this.dialogVisible = false;
  330. // var img = new Image(); //创建img标签
  331. // img.src = 'http://5b0988e595225.cdn.sohucs.com/images/20170930/89fe9e8a782645048fb826e074208862.jpeg';
  332. // let imgSty = 'width: 100%; height: 100%;';
  333. // img.style = imgSty;
  334. // img.style.width = '50%';
  335. // img.style.height = '50%';
  336. // img.style.position='absolute'
  337. // img.style.top='50%'
  338. // img.style.left='50%'
  339. // img.style.margin ='-12.5% 0 0 -25%'
  340. // tempwindow.document.write(img.outerHTML);
  341. },
  342. //轮播排名弹窗
  343. byRanking() {
  344. if (localStorage.getItem('titleVal')) {
  345. this.titleVal = JSON.parse(localStorage.getItem('titleVal'));
  346. this.titleVals = this.titleVal.titleVal3;
  347. } else {
  348. this.titleVals = '';
  349. }
  350. this.byRankingShow = true;
  351. },
  352. // 轮播页面跳转
  353. swiperPage(formName) {
  354. if (this.titleVals != '') {
  355. this.titleVal.titleVal3 = this.titleVals;
  356. localStorage.setItem('titleVal', JSON.stringify(this.titleVal));
  357. } else {
  358. this.titleVal.titleVal3 = '';
  359. localStorage.setItem('titleVal', JSON.stringify(this.titleVal));
  360. }
  361. //拿到当前点击的部门id
  362. let byRankingDeptId_bl = '';
  363. for (let i in this.byRankingDeptId) {
  364. byRankingDeptId_bl = this.byRankingDeptId[i];
  365. }
  366. if (byRankingDeptId_bl == '' || byRankingDeptId_bl == 0) {
  367. byRankingDeptId_bl = 0;
  368. }
  369. this.byRankingData.dept_id = byRankingDeptId_bl;
  370. this.$refs[formName].validate(valid => {
  371. if (valid) {
  372. var { href } = this.$router.resolve({
  373. path: '/deptRankSwiper',
  374. query: {
  375. types: '3',
  376. dept_id: this.byRankingData.dept_id,
  377. pt_id: 3,
  378. type: 'all',
  379. position: this.byRankingData.position
  380. }
  381. });
  382. window.open(href);
  383. }
  384. });
  385. },
  386. // 提示信息
  387. tips_close() {
  388. localStorage.setItem('total_rank_tips', 'true');
  389. this.tips_show = false;
  390. },
  391. // 页面变更
  392. handleCurrentChange(val) {
  393. this.formData.page = val;
  394. this.get_list();
  395. },
  396. handleSizeChange(val) {
  397. this.pageLimit = val;
  398. this.formData.page_size = this.pageLimit;
  399. this.get_list();
  400. },
  401. get_list() {
  402. let self = this;
  403. self.loading = true;
  404. self.$http('get','/api/integral/statistics/ranking',self.formData,'v2')
  405. .then(res => {
  406. if (res.data.code == 1) {
  407. self.list = res.data.data.list;
  408. self.total = res.data.data.total;
  409. } else {
  410. self.$message.error(res.data.data.msg);
  411. }
  412. })
  413. .finally(() => {
  414. self.loading = false;
  415. });
  416. },
  417. // 递归判断列表,把最后的children设为undefined
  418. getTreeData(data) {
  419. for (var i = 0; i < data.length; i++) {
  420. if (data[i].children.length < 1) {
  421. // children若为空数组,则将children设为undefined
  422. data[i].children = undefined;
  423. } else {
  424. // children若不为空数组,则继续 递归调用 本方法
  425. this.getTreeData(data[i].children);
  426. }
  427. }
  428. return data;
  429. }
  430. },
  431. mounted() {
  432. this.tips_show = JSON.parse(localStorage.getItem('total_rank_tips')) ? false : true;
  433. if (localStorage.getItem('dept_tree')) {
  434. this.dept_tree = this.getTreeData(JSON.parse(localStorage.getItem('dept_tree')));
  435. }
  436. this.get_list();
  437. }
  438. };
  439. </script>
  440. <style scoped lang="scss">
  441. .search_box {
  442. /deep/ button:active {
  443. background: #26a2ff;
  444. }
  445. /deep/ button:active .el-icon-search {
  446. color: #fff;
  447. }
  448. }
  449. .date-picker-width {
  450. width: 100% !important;
  451. }
  452. .color_green {
  453. color: #67c23a;
  454. }
  455. .nopoint_box {
  456. display: inline-block;
  457. text-align: center;
  458. width: 100%;
  459. margin-bottom: 10px;
  460. }
  461. .noimg {
  462. display: inline-block;
  463. width: 110px;
  464. height: 110px;
  465. margin: 22px auto 16px;
  466. /* background:url("/static/images/nodata_default.png") no-repeat center; */
  467. background-size: 99%;
  468. }
  469. .noperson {
  470. display: inline-block;
  471. width: 110px;
  472. height: 110px;
  473. line-height: none;
  474. margin: 22px auto 16px;
  475. background: url('/static/images/noperson_default.png') no-repeat center;
  476. background-size: 99%;
  477. }
  478. .title {
  479. display: block;
  480. text-align: center;
  481. font-size: 12px !important;
  482. line-height: 30px;
  483. color: #909399 !important;
  484. padding: 0;
  485. }
  486. .nopoint_box a {
  487. color: #26a2ff;
  488. }
  489. .chart_content {
  490. .chart-legend__wrap {
  491. text-align: right;
  492. padding: 20px;
  493. padding-right: 50px;
  494. & .chart-legend__pink {
  495. position: relative;
  496. padding-left: 12px;
  497. padding-right: 5px;
  498. &:after {
  499. content: '';
  500. position: absolute;
  501. margin-top: -2px;
  502. top: 35%;
  503. left: 0;
  504. width: 8px;
  505. height: 8px;
  506. background: #f56c6c;
  507. border-radius: 100%;
  508. }
  509. }
  510. & .chart-legend__green {
  511. position: relative;
  512. padding-left: 12px;
  513. &:after {
  514. content: '';
  515. position: absolute;
  516. margin-top: -2px;
  517. top: 35%;
  518. left: 0;
  519. width: 8px;
  520. height: 8px;
  521. background: #53b87f;
  522. border-radius: 100%;
  523. }
  524. }
  525. }
  526. }
  527. .drawer_title {
  528. font-size: 18px;
  529. padding: 20px;
  530. }
  531. .manager_statistics_box {
  532. background-color: #ffffff;
  533. padding: 20px;
  534. min-height: calc(100vh - 160px);
  535. /deep/ .el-row .el-checkbox .el-checkbox__label {
  536. line-height: 20px;
  537. }
  538. }
  539. .diy_tip_bg {
  540. background: #f5f6f9;
  541. overflow: hidden;
  542. .diy-tip {
  543. margin-bottom: 15px;
  544. border: 1px solid #67c23a;
  545. padding: 20px 16px;
  546. p {
  547. color: #67c23a !important;
  548. font-size: 15px;
  549. margin: 0 !important;
  550. padding-bottom: 4px;
  551. }
  552. }
  553. }
  554. /deep/ .el-dialog__body{
  555. padding:0px 20px 30px;
  556. }
  557. .headLi{
  558. padding: 4px;
  559. list-style:disc;
  560. font-size:14px;
  561. }
  562. </style>