flStatistics.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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. <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 label="人员">
  22. <el-select v-model="select_employee_id" filterable placeholder="请输入或选择人员" clearable>
  23. <el-option v-for="item in employee_map" :key="item.id" :label="item.name" :value="item.id"></el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item>
  27. <el-button type="primary" size="medium" @click="dialogVisible = true" style="margin-left: 10px;" plain>导出排名</el-button>
  28. </el-form-item>
  29. </el-form>
  30. <el-table :data="list" style="width: 100%" v-loading="loading" @selection-change="deleteEvents">
  31. <el-table-column type="selection" width="55"></el-table-column>
  32. <el-table-column label="姓名" align="left">
  33. <template slot-scope="scope">
  34. <div class="flex-box">
  35. <userImage :user_name="scope.row.employee_name" :img_url="scope.row.employee_img_url" width="50px" height="50px"></userImage>
  36. <span style="line-height: 50px; padding-left: 10px;">{{ scope.row.employee_name }}</span>
  37. </div>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="部门" width="80" align="center"></el-table-column>
  41. <el-table-column label="累计B分" align="left" prop="point"></el-table-column>
  42. <template slot="empty">
  43. <div class="nopoint_box">
  44. <div class="noimg noperson"></div>
  45. <span class="title">没有对应的数据</span>
  46. </div>
  47. </template>
  48. </el-table>
  49. <center style="padding: 20px 0;">
  50. <el-pagination
  51. background
  52. @size-change="handleSizeChange"
  53. @current-change="handleCurrentChange"
  54. :current-page="formData.page"
  55. :page-sizes="[10, 20, 50, 100]"
  56. layout="total, sizes, prev, pager, next"
  57. :page-size="pageLimit"
  58. :total="total"
  59. ></el-pagination>
  60. </center>
  61. </div>
  62. <!-- 导出弹窗 -->
  63. <el-dialog title="导出排名" :visible.sync="dialogVisible" width="730px" top="10%">
  64. <span style="font-size:15px">系统将按以下已选条件导出对应的排名报表</span>
  65. <el-form :inline="true">
  66. <div class="picker_er">
  67. <el-form-item label="时间">
  68. <el-date-picker
  69. v-model="Dc_Data.value1"
  70. type="daterange"
  71. size="medium"
  72. value-format="yyyy-MM-dd"
  73. format="yyyy-MM-dd"
  74. range-separator="至"
  75. start-placeholder="开始日期"
  76. end-placeholder="结束日期"
  77. ></el-date-picker>
  78. </el-form-item>
  79. <el-form-item label="人员" style="margin-left:30px">
  80. <el-select size="medium" v-model="Dc_Data.DC_position" style="width:150px" placeholder="请选择">
  81. <el-option v-for="item in positions" :key="item.id" :label="item.name" :value="item.age"></el-option>
  82. </el-select>
  83. </el-form-item>
  84. </div>
  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>
  99. <span slot="footer" class="dialog-footer">
  100. <el-button @click="dialogVisible = false" size="medium">取 消</el-button>
  101. <el-button type="primary" @click="exportExcel" size="medium">导 出</el-button>
  102. </span>
  103. </el-dialog>
  104. </div>
  105. </template>
  106. <script>
  107. export default {
  108. name:'flStatistics',
  109. data() {
  110. return {
  111. select_employee_id:'',
  112. employee_map:[],
  113. dept_name: [],
  114. dept_tree: [],
  115. loading: false,
  116. formData: {
  117. dept_id: '0',
  118. sort: 'DESC',
  119. page: 1,
  120. page_size: 10,
  121. pt_id: 3,
  122. type: 'all'
  123. },
  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. dept_name(val) {
  140. if (val.length !== 0) {
  141. this.formData.dept_id = val[val.length - 1];
  142. } else {
  143. this.formData.dept_id = '0';
  144. }
  145. this.formData.page = 1;
  146. this.$nextTick(() => {
  147. this.$refs.dept.dropDownVisible = false;
  148. this.get_list();
  149. });
  150. }
  151. },
  152. methods: {
  153. deleteEvents(selection) {
  154. let listId = [];
  155. selection.forEach(item => {
  156. listId.push(item.id);
  157. });
  158. this.selectionID = listId;
  159. },
  160. exportExcel() {
  161. //人员
  162. this.Dc_Data.DC_position =
  163. this.Dc_Data.DC_position == 'manager' ? 'manager' : this.Dc_Data.DC_position == 'employee' ? 'employee' : this.Dc_Data.DC_position == '全部' ? 'all' : 'all';
  164. //部门
  165. let dept_name;
  166. for (let i in this.Dc_Data.dept_name) {
  167. dept_name = this.Dc_Data.dept_name[i];
  168. }
  169. this.Dc_Data.dept_name = dept_name;
  170. //规则
  171. let rule_id = [];
  172. for (let i in this.Dc_Data.rule_id) {
  173. for (let a in this.Dc_Data.rule_id[i]) {
  174. rule_id.push(this.Dc_Data.rule_id[i][a]);
  175. }
  176. }
  177. this.Dc_Data.rule_id = rule_id;
  178. let data = '';
  179. if (this.Dc_Data.value1) {
  180. data += '&start_date=' + this.Dc_Data.value1[0];
  181. data += '&end_date=' + this.Dc_Data.value1[1];
  182. }
  183. data += '&position=' + this.Dc_Data.DC_position;
  184. this.Dc_Data.dept_name > 0 ? (data += '&dept_id=' + this.Dc_Data.dept_name) : (data += '&dept_id=0');
  185. if (this.Dc_Data.rule_id.length > 0) {
  186. data += '&rule_id=' + this.Dc_Data.rule_id;
  187. }
  188. window.open(process.env.VUE_APP_BASE_API + 'api/download/ranking/v2?pt_id=3&type=all&employee_id=' + this.$getUserData().id + data, '_blank');
  189. this.dialogVisible = false;
  190. },
  191. // 提示信息
  192. tips_close() {
  193. localStorage.setItem('total_rank_tips', 'true');
  194. this.tips_show = false;
  195. },
  196. // 页面变更
  197. handleCurrentChange(val) {
  198. this.formData.page = val;
  199. this.get_list();
  200. },
  201. handleSizeChange(val) {
  202. this.pageLimit = val;
  203. this.formData.page_size = this.pageLimit;
  204. this.get_list();
  205. },
  206. //获取部门
  207. getDepartment() {
  208. this.$axios('get', '/api/department/tree').then(res => {
  209. this.dept_tree = this.getTreeData(res.data.data.list);
  210. });
  211. },
  212. get_list() {
  213. this.loading = true;
  214. this.$axios('get', '/api/integral/statistics/ranking', this.formData, 'v2')
  215. .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. this.employee_map=JSON.parse(localStorage.getItem('userList'))
  244. },
  245. mounted() {
  246. this.tips_show = JSON.parse(localStorage.getItem('total_rank_tips')) ? false : true;
  247. this.get_list();
  248. }
  249. };
  250. </script>
  251. <style scoped lang="scss">
  252. .search_box {
  253. ::v-deep button:active {
  254. background: #26a2ff;
  255. }
  256. ::v-deep button:active .el-icon-search {
  257. color: #fff;
  258. }
  259. }
  260. .date-picker-width {
  261. width: 100% !important;
  262. }
  263. .nopoint_box {
  264. display: inline-block;
  265. text-align: center;
  266. width: 100%;
  267. margin-bottom: 10px;
  268. }
  269. .noimg {
  270. display: inline-block;
  271. width: 110px;
  272. height: 110px;
  273. margin: 22px auto 16px;
  274. background-size: 99%;
  275. }
  276. .noperson {
  277. display: inline-block;
  278. width: 110px;
  279. height: 110px;
  280. line-height: none;
  281. margin: 22px auto 16px;
  282. // background: url("@/assets/image/rules_mould.png") no-repeat center;
  283. background-size: 99%;
  284. }
  285. .title {
  286. display: block;
  287. text-align: center;
  288. font-size: 12px !important;
  289. line-height: 30px;
  290. color: #909399 !important;
  291. padding: 0;
  292. }
  293. .nopoint_box a {
  294. color: #26a2ff;
  295. }
  296. .chart_content {
  297. .chart-legend__wrap {
  298. text-align: right;
  299. padding: 20px;
  300. padding-right: 50px;
  301. & .chart-legend__pink {
  302. position: relative;
  303. padding-left: 12px;
  304. padding-right: 5px;
  305. &:after {
  306. content: '';
  307. position: absolute;
  308. margin-top: -2px;
  309. top: 35%;
  310. left: 0;
  311. width: 8px;
  312. height: 8px;
  313. background: #f56c6c;
  314. border-radius: 100%;
  315. }
  316. }
  317. & .chart-legend__green {
  318. position: relative;
  319. padding-left: 12px;
  320. &:after {
  321. content: '';
  322. position: absolute;
  323. margin-top: -2px;
  324. top: 35%;
  325. left: 0;
  326. width: 8px;
  327. height: 8px;
  328. background: #53b87f;
  329. border-radius: 100%;
  330. }
  331. }
  332. }
  333. }
  334. .drawer_title {
  335. font-size: 18px;
  336. padding: 20px;
  337. }
  338. .manager_statistics_box {
  339. background-color: #ffffff;
  340. padding: 20px;
  341. min-height: calc(100vh - 160px);
  342. ::v-deep .el-row .el-checkbox .el-checkbox__label {
  343. line-height: 20px;
  344. }
  345. }
  346. .diy_tip_bg {
  347. background: #f5f6f9;
  348. overflow: hidden;
  349. .diy-tip {
  350. margin-bottom: 15px;
  351. border: 1px solid #67c23a;
  352. padding: 20px 16px;
  353. p {
  354. color: #67c23a !important;
  355. font-size: 14px;
  356. margin: 0 !important;
  357. padding: 4px 0;
  358. }
  359. }
  360. }
  361. </style>