total_rank.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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" style="padding: 20px;">
  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. window.open(process.env.VUE_APP_BASE_API + 'api/download/ranking/v2?pt_id=3&type=all&employee_id='+this.$getUserData().id+ data, '_blank');
  190. this.dialogVisible = false;
  191. },
  192. // 提示信息
  193. tips_close() {
  194. localStorage.setItem('total_rank_tips', 'true');
  195. this.tips_show = false;
  196. },
  197. // 页面变更
  198. handleCurrentChange(val) {
  199. this.formData.page = val;
  200. this.get_list();
  201. },
  202. handleSizeChange(val) {
  203. this.pageLimit = val;
  204. this.formData.page_size = this.pageLimit;
  205. this.get_list();
  206. },
  207. //获取部门
  208. getDepartment() {
  209. this.$axios('get','/api/department/tree').then(res => {
  210. this.dept_tree =this.getTreeData(res.data.data.list);
  211. });
  212. },
  213. get_list() {
  214. this.loading = true;
  215. this.$axios('get','/api/integral/statistics/ranking', this.formData,'v2').then(res => {
  216. if (res.data.code == 1) {
  217. this.list = res.data.data.list;
  218. this.total = res.data.data.total;
  219. } else {
  220. this.$message.error(res.data.data.msg);
  221. }
  222. })
  223. .finally(() => {
  224. this.loading = false;
  225. });
  226. },
  227. // 递归判断列表,把最后的children设为undefined
  228. getTreeData(data) {
  229. for (var i = 0; i < data.length; i++) {
  230. if (data[i]._child.length < 1) {
  231. // children若为空数组,则将children设为undefined
  232. data[i]._child = undefined;
  233. } else {
  234. // children若不为空数组,则继续 递归调用 本方法
  235. this.getTreeData(data[i]._child);
  236. }
  237. }
  238. return data;
  239. }
  240. },
  241. created() {
  242. this.getDepartment();
  243. },
  244. mounted() {
  245. this.tips_show = JSON.parse(localStorage.getItem('total_rank_tips')) ? false : true;
  246. this.get_list();
  247. }
  248. };
  249. </script>
  250. <style scoped lang="scss">
  251. .search_box {
  252. ::v-deep button:active {
  253. background: #26a2ff;
  254. }
  255. ::v-deep button:active .el-icon-search {
  256. color: #fff;
  257. }
  258. }
  259. .date-picker-width {
  260. width: 100% !important;
  261. }
  262. .color_green {
  263. color: #67c23a;
  264. }
  265. .nopoint_box {
  266. display: inline-block;
  267. text-align: center;
  268. width: 100%;
  269. margin-bottom: 10px;
  270. }
  271. .noimg {
  272. display: inline-block;
  273. width: 110px;
  274. height: 110px;
  275. margin: 22px auto 16px;
  276. background-size: 99%;
  277. }
  278. .noperson {
  279. display: inline-block;
  280. width: 110px;
  281. height: 110px;
  282. line-height: none;
  283. margin: 22px auto 16px;
  284. // background: url("@/assets/image/rules_mould.png") no-repeat center;
  285. background-size: 99%;
  286. }
  287. .title {
  288. display: block;
  289. text-align: center;
  290. font-size: 12px !important;
  291. line-height: 30px;
  292. color: #909399 !important;
  293. padding: 0;
  294. }
  295. .nopoint_box a {
  296. color: #26a2ff;
  297. }
  298. .chart_content {
  299. .chart-legend__wrap {
  300. text-align: right;
  301. padding: 20px;
  302. padding-right: 50px;
  303. & .chart-legend__pink {
  304. position: relative;
  305. padding-left: 12px;
  306. padding-right: 5px;
  307. &:after {
  308. content: '';
  309. position: absolute;
  310. margin-top: -2px;
  311. top: 35%;
  312. left: 0;
  313. width: 8px;
  314. height: 8px;
  315. background: #f56c6c;
  316. border-radius: 100%;
  317. }
  318. }
  319. & .chart-legend__green {
  320. position: relative;
  321. padding-left: 12px;
  322. &:after {
  323. content: '';
  324. position: absolute;
  325. margin-top: -2px;
  326. top: 35%;
  327. left: 0;
  328. width: 8px;
  329. height: 8px;
  330. background: #53b87f;
  331. border-radius: 100%;
  332. }
  333. }
  334. }
  335. }
  336. .drawer_title {
  337. font-size: 18px;
  338. padding: 20px;
  339. }
  340. .manager_statistics_box {
  341. background-color: #ffffff;
  342. padding: 20px;
  343. min-height: calc(100vh - 160px);
  344. ::v-deep .el-row .el-checkbox .el-checkbox__label {
  345. line-height: 20px;
  346. }
  347. }
  348. .diy_tip_bg {
  349. background: #f5f6f9;
  350. overflow: hidden;
  351. .diy-tip {
  352. margin-bottom: 15px;
  353. border: 1px solid #67c23a;
  354. padding: 20px 16px;
  355. p {
  356. color: #67c23a !important;
  357. font-size: 14px;
  358. margin: 0 !important;
  359. padding: 4px 0;
  360. }
  361. }
  362. }
  363. </style>