total_rank.vue 10 KB

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