dept_rank.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  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-select size="medium" v-model="time_type" placeholder="请选择分类" style="width: 100px;">
  10. <el-option v-for="item in time_types" :key="item.label" :label="item.label" :value="item.value"></el-option>
  11. </el-select>
  12. </el-form-item>
  13. <el-form-item>
  14. <el-date-picker
  15. size="medium"
  16. v-show="time_type == '2'"
  17. v-model="export_from.year"
  18. class="date-picker-width"
  19. type="year"
  20. value-format="yyyy"
  21. placeholder="选择年份排名"
  22. ></el-date-picker>
  23. <el-date-picker
  24. size="medium"
  25. v-show="time_type == '1' || time_type == '月份'"
  26. v-model="export_from.month"
  27. class="date-picker-width"
  28. type="month"
  29. value-format="yyyy-MM"
  30. placeholder="选择月份排名"
  31. ></el-date-picker>
  32. <season v-if="time_type == '3'" :isActive="true" class="date-picker-width" @confirm="export_quarter_confirm"></season>
  33. <el-date-picker
  34. size="medium"
  35. v-show="time_type == '4'"
  36. class="date-picker-width"
  37. v-model="export_from.time_range"
  38. type="daterange"
  39. value-format="timestamp"
  40. range-separator="至"
  41. start-placeholder="开始日期"
  42. end-placeholder="结束日期"
  43. :picker-options="instantPickerOptions"
  44. ></el-date-picker>
  45. </el-form-item>
  46. <el-form-item label="部门">
  47. <el-cascader
  48. size="medium"
  49. class="date-picker-width"
  50. v-model="dept_name"
  51. :options="dept_tree"
  52. :props="{ checkStrictly: true, value: 'id', label: 'name', children: '_child' }"
  53. ref="dept"
  54. clearable
  55. filterable
  56. placeholder="全公司"
  57. ></el-cascader>
  58. <!-- 这是选部门多选。如果更改需求用这个: -->
  59. <!-- <el-cascader
  60. v-model="dept_name"
  61. :options="dept_tree"
  62. :props="{ multiple: true, checkStrictly: true }"
  63. class="date-picker-width"
  64. ref="dept"
  65. clearable
  66. collapse-tags
  67. placeholder="全公司"
  68. ></el-cascader>-->
  69. </el-form-item>
  70. <el-form-item label="谁不参与排名">
  71. <el-select v-model="formData.exclusion" size="medium" multiple filterable collapse-tags placeholder="请选择员工">
  72. <el-option v-for="item in employee_map" :key="item.id" :label="item.name" :value="item.id"></el-option>
  73. </el-select>
  74. </el-form-item>
  75. <el-form-item label="规则分类">
  76. <el-cascader
  77. size="medium"
  78. class="date-picker-width"
  79. v-model="rule_id"
  80. :options="rule_trees"
  81. :props="props2"
  82. ref="rule_id"
  83. clearable
  84. placeholder="请选择规则分类"
  85. ></el-cascader>
  86. </el-form-item>
  87. <el-form-item label="积分分类">
  88. <el-select class="date-picker-width" size="medium" v-model="formData.pt_id" placeholder="请选择积分分类">
  89. <el-option v-for="item in point_types" :key="item.name" :label="item.name" :value="item.id"></el-option>
  90. </el-select>
  91. </el-form-item>
  92. <el-form-item label="人员">
  93. <el-select size="medium" v-model="formData.position" style="width:150px" placeholder="请选择">
  94. <el-option v-for="item in positions" :key="item.id" :label="item.name" :value="item.age"></el-option>
  95. </el-select>
  96. </el-form-item>
  97. <el-form-item>
  98. <el-checkbox v-model="sort" size="medium" label="排名由低到高" border></el-checkbox>
  99. <el-button type="primary" size="medium" @click="selectBtn" style="margin-left:20px">查询</el-button>
  100. </el-form-item>
  101. <el-form-item>
  102. <el-button type="primary" size="medium" plain @click="dialogVisible = true">导出排名</el-button>
  103. <!-- <el-button type="primary" size="medium" plain @click="byRanking('byRankingData')">轮播排名</el-button> -->
  104. </el-form-item>
  105. </el-form>
  106. <el-table :data="list" style="width: 100%" v-loading="loading">
  107. <el-table-column label="名次" width="80" align="center">
  108. <template slot-scope="scope">
  109. <img v-if="scope.row.rank === 1" src="@/assets/image/statistics_NO1.png" alt="" />
  110. <img v-if="scope.row.rank === 2" src="@/assets/image/statistics_NO2.png" alt="" />
  111. <img v-if="scope.row.rank === 3" src="@/assets/image/statistics_NO3.png" alt="" />
  112. <span v-if="scope.row.rank > 3">{{ scope.row.rank }}</span>
  113. </template>
  114. </el-table-column>
  115. <el-table-column label="姓名" align="left">
  116. <template slot-scope="scope">
  117. <div class="flex-box">
  118. <userImage :user_name="scope.row.employee_name" :img_url="scope.row.employee_img_url" width="50px" height="50px"></userImage>
  119. <span style="line-height: 50px; padding-left: 10px;">{{ scope.row.employee_name }}</span>
  120. </div>
  121. </template>
  122. </el-table-column>
  123. <el-table-column :label="labelName" align="left" prop="point"></el-table-column>
  124. <template slot="empty">
  125. <div class="nopoint_box">
  126. <div class="noimg noperson"></div>
  127. <span class="title">没有对应的数据</span>
  128. </div>
  129. </template>
  130. </el-table>
  131. <center style="padding: 20px 0;">
  132. <el-pagination
  133. background
  134. @size-change="handleSizeChange"
  135. @current-change="handleCurrentChange"
  136. :page-sizes="[10, 20, 50, 100]"
  137. layout="total, sizes, prev, pager, next"
  138. :page-size="formData.page_size"
  139. :total="total"
  140. ></el-pagination>
  141. </center>
  142. </div>
  143. <!-- 导出弹窗 -->
  144. <el-dialog title="导出排名" :visible.sync="dialogVisible" width="730px" top="10%">
  145. <span style="font-size:15px">系统将按以下已选条件导出对应的排名报表</span>
  146. <el-form :inline="true">
  147. <div class="picker_er">
  148. <el-form-item label="时间">
  149. <el-date-picker
  150. v-model="Dc_Data.value1"
  151. type="daterange"
  152. size="medium"
  153. value-format="timestamp"
  154. range-separator="至"
  155. start-placeholder="开始日期"
  156. end-placeholder="结束日期"
  157. :picker-options="instantPickerOptions"
  158. ></el-date-picker>
  159. </el-form-item>
  160. <el-form-item label="人员" style="margin-left:30px">
  161. <el-select size="medium" v-model="Dc_Data.DC_position" style="width:150px" placeholder="请选择">
  162. <el-option v-for="item in positions" :key="item.id" :label="item.name" :value="item.age"></el-option>
  163. </el-select>
  164. </el-form-item>
  165. </div>
  166. <el-form-item label="部门">
  167. <el-cascader
  168. class="date-picker-width cascader_bm"
  169. v-model="Dc_Data.dept_name"
  170. :options="dept_tree"
  171. :props="{ checkStrictly: true, value: 'id', label: 'name', children: '_child' }"
  172. ref="dept2"
  173. size="medium"
  174. clearable
  175. filterable
  176. placeholder="全公司"
  177. ></el-cascader>
  178. </el-form-item>
  179. <el-form-item label="积分分类">
  180. <el-select style="width: 80px;" size="medium" v-model="Dc_Data.pt_id" placeholder="请选择积分分类">
  181. <el-option v-for="item in point_types" :key="item.name" :label="item.name" :value="item.id"></el-option>
  182. </el-select>
  183. </el-form-item>
  184. <el-form-item label="规则分类" style="margin-left:20px">
  185. <el-cascader
  186. class="date-picker-width"
  187. @change="ruleInquiredialog"
  188. v-model="rule_ids"
  189. :options="rule_trees"
  190. :props="props"
  191. size="medium"
  192. ref="derive"
  193. clearable
  194. collapse-tags
  195. placeholder="请选择规则分类"
  196. ></el-cascader>
  197. </el-form-item>
  198. </el-form>
  199. <span slot="footer" class="dialog-footer">
  200. <el-button @click="dialogVisible = false" size="medium">取 消</el-button>
  201. <el-button type="primary" @click="exportExcel" size="medium">导 出</el-button>
  202. </span>
  203. </el-dialog>
  204. <!-- 轮播弹窗 -->
  205. <el-dialog title="轮播排名" :visible.sync="byRankingShow" width="500px" top="10%">
  206. <div>
  207. <el-form :inline="true" ref="byRankingData" :model="byRankingData" :rules="byRankingDataRules" label-width="90px">
  208. <el-form-item label="月份" prop="month">
  209. <el-date-picker
  210. v-model="byRankingData.month"
  211. size="medium"
  212. class="date-picker-width"
  213. type="month"
  214. value-format="yyyy-MM"
  215. placeholder="选择月份排名"
  216. ></el-date-picker>
  217. </el-form-item>
  218. <el-form-item label="选择部门" prop="dept_id">
  219. <el-cascader
  220. size="medium"
  221. class="date-picker-width"
  222. v-model="byRankingData.dept_id"
  223. :options="dept_tree"
  224. :props="{ checkStrictly: true, value: 'obj', label: 'name', children: '_child' }"
  225. ref="dept1"
  226. clearable
  227. filterable
  228. placeholder="全公司"
  229. ></el-cascader>
  230. </el-form-item>
  231. <el-form-item label="人员范围" prop="position">
  232. <el-radio-group size="medium" v-model="byRankingData.position">
  233. <el-radio label="all">管理者和员工</el-radio>
  234. <el-radio label="manager">只看管理者</el-radio>
  235. <el-radio label="employee">只看员工</el-radio>
  236. </el-radio-group>
  237. </el-form-item>
  238. </el-form>
  239. </div>
  240. <span slot="footer">
  241. <el-button @click="byRankingShow = false" size="medium">取 消</el-button>
  242. <el-button type="primary" @click="swiperPage('byRankingData')" size="medium">开始轮播</el-button>
  243. </span>
  244. </el-dialog>
  245. </div>
  246. </template>
  247. <script>
  248. import moment from 'moment';
  249. import season from '@/components/season';
  250. export default {
  251. data() {
  252. return {
  253. rule_ids: null,
  254. Dc_Data: {
  255. //导出数据
  256. value1: '', //时间
  257. DC_position: '全部', //人员
  258. dept_name: [], //部门
  259. rule_id: [] ,//规则
  260. pt_id: 3,
  261. },
  262. dialogVisible: false,
  263. dept_name: [],
  264. dept_tree: [],
  265. loading: false,
  266. formData: {
  267. dept_id: '0',
  268. sort: 'DESC',
  269. pt_id: 3,
  270. time_type: 1,
  271. exclusion: [],
  272. page: 1,
  273. rule_id: '',
  274. page_size: 10,
  275. position: 0 //部门多选删除这个
  276. },
  277. total: null,
  278. rule_trees: null,
  279. rule_id: null,
  280. list: null,
  281. point_types: [],
  282. point_type: [],
  283. sort: false,
  284. time_types: [{ label: '月份', value: '1' }, { label: '年份', value: '2' }, { label: '季度', value: '3' }, { label: '自定义', value: '4' }],
  285. props: { value: 'id', label: 'name', children: 'child', multiple: true },
  286. props2: { value: 'id', label: 'name', children: 'child', checkStrictly: true},
  287. time_type: '月份',
  288. export_from: {
  289. year: '',
  290. month: moment().format('YYYY-MM'),
  291. quarter: '',
  292. // time_range: [new Date(new Date().toLocaleDateString()).getTime(), new Date(new Date().toLocaleDateString()).getTime()]
  293. time_range: []
  294. },
  295. employee_map: JSON.parse(localStorage.getItem('SET_EMPLOYEE_MAP')),
  296. positions: [{ id: 0, age: 'all', name: '全部' }, { id: 1, age: 'manager', name: '管理者' }, { id: 2, age: 'employee', name: '员工' }],
  297. tips_show: false,
  298. byRankingShow: false,
  299. byRankingData: {
  300. month: '',
  301. dept_id: '',
  302. position: 'all'
  303. },
  304. byRankingDeptId: '',
  305. byRankingDataRules: {
  306. month: [{ required: true, message: '请选择月份', trigger: 'blur' }],
  307. dept_id: [{ required: true, message: '请选择部门', trigger: 'change' }],
  308. position: [{ required: true, message: '请选择人员范围', trigger: 'change' }]
  309. },
  310. labelName: 'B分',
  311. instantPickerOptions: {
  312. shortcuts: [
  313. {
  314. text: '今天',
  315. onClick(picker) {
  316. const now = new Date(new Date().toLocaleDateString());
  317. const start = now.getTime();
  318. picker.$emit('pick', [start, start]);
  319. }
  320. },
  321. {
  322. text: '昨天',
  323. onClick(picker) {
  324. const now = new Date(new Date().toLocaleDateString());
  325. const start = now.getTime() - 60 * 60 * 24 * 1000;
  326. picker.$emit('pick', [start, start]);
  327. }
  328. },
  329. {
  330. text: '本周',
  331. onClick(picker) {
  332. const now = new Date(new Date().toLocaleDateString());
  333. const start = now.getTime() - (now.getDay() - 1) * 24 * 60 * 60 * 1000;
  334. const end = start + 7 * 24 * 60 * 60 * 1000 - 1000;
  335. picker.$emit('pick', [start, end]);
  336. }
  337. },
  338. {
  339. text: '上周',
  340. onClick(picker) {
  341. const now = new Date(new Date().toLocaleDateString());
  342. const start = now.getTime() - (now.getDay() + 6) * 24 * 60 * 60 * 1000;
  343. const end = start + 7 * 24 * 60 * 60 * 1000 - 1000;
  344. picker.$emit('pick', [start, end]);
  345. }
  346. },
  347. {
  348. text: '本月',
  349. onClick(picker) {
  350. const now = new Date();
  351. const startDate = new Date(now.getFullYear(), now.getMonth(), 1);
  352. const endDate = new Date(now.getFullYear(), now.getMonth() + 1, 0);
  353. picker.$emit('pick', [startDate.getTime(), endDate.getTime()]);
  354. }
  355. },
  356. {
  357. text: '上月',
  358. onClick(picker) {
  359. const now = new Date();
  360. const startDate = new Date(now.getFullYear() - (now.getMonth() > 0 ? 0 : 1), (now.getMonth() + 11) % 12, 1);
  361. const endDate = new Date(now.getFullYear(), now.getMonth(), 0);
  362. picker.$emit('pick', [startDate.getTime(), endDate.getTime()]);
  363. }
  364. }
  365. ],
  366. onPick: (obj) => {
  367. if(!this.dialogVisible){
  368. this.pickerMinDate = new Date(obj.minDate).getTime();
  369. }
  370. },
  371. disabledDate : time => {
  372. if (this.pickerMinDate && !this.dialogVisible) {
  373. const day1 = 30 * 24 * 3600 * 1000//限制只能选一个月的范围区间
  374. let maxTime = this.pickerMinDate + day1
  375. let minTime = this.pickerMinDate - day1
  376. return time.getTime() > maxTime || time.getTime()<minTime
  377. }
  378. }
  379. },
  380. pickerDisabledDate: {
  381. },
  382. };
  383. },
  384. watch: {
  385. sort(val) {
  386. if (val) {
  387. this.formData.sort = 'ASC';
  388. } else {
  389. this.formData.sort = 'DESC';
  390. }
  391. },
  392. dept_name(val) {
  393. if (val.length !== 0) {
  394. // 这是选部门多选。如果更改需求用这个:
  395. // let dept_id = [];
  396. // for (var i in val) {
  397. // dept_id.push(val[i][0]);
  398. // }
  399. // this.formData.dept_id = dept_id;//传入选中的部门ID,是数组
  400. this.formData.dept_id = val[val.length - 1];
  401. } else {
  402. this.formData.dept_id = 0;
  403. }
  404. this.$nextTick(() => {
  405. this.$refs.dept.dropDownVisible = false;
  406. this.getEmployeeList();
  407. });
  408. },
  409. 'byRankingData.dept_id'(val) {
  410. this.$refs.dept1.dropDownVisible = false;
  411. },
  412. 'Dc_Data.dept_name': function(val) {
  413. this.$refs.dept2.dropDownVisible = false;
  414. },
  415. rule_id(val) {
  416. if(val.length==0){
  417. this.formData.rule_id='';
  418. return false
  419. }
  420. if(val.length==1){
  421. this.formData.rule_id=(val).toString()
  422. }else{
  423. this.formData.rule_id=(val[val.length-1]).toString()
  424. }
  425. this.$refs.rule_id.dropDownVisible = false;
  426. }
  427. },
  428. components: { season },
  429. methods: {
  430. ruleInquiredialog() {
  431. this.ruleUtif('derive');
  432. },
  433. ruleUtif(rule) {
  434. let ruleList = this.$refs[rule].getCheckedNodes();
  435. let ruleId = [];
  436. ruleList.forEach(item => {
  437. ruleId.push(item.value);
  438. });
  439. if (rule == 'ruleinquire') {
  440. this.formData.rule_id = ruleId;
  441. } else {
  442. this.Dc_Data.rule_id = ruleId;
  443. }
  444. this.$nextTick(() => {
  445. if (this.$refs[rule].presentTags[1]) {
  446. this.$refs[rule].presentTags[1].text = '+ ' + (ruleId.length - 1).toString();
  447. } else {
  448. if (ruleId.length > 1) {
  449. let list = {
  450. closable: false,
  451. key: -1,
  452. text: '+ ' + (ruleId.length - 1).toString()
  453. };
  454. this.$refs[rule].presentTags[1] = list;
  455. }
  456. }
  457. });
  458. },
  459. // 轮播页面跳转
  460. swiperPage(formName) {
  461. this.$refs[formName].validate(valid => {
  462. if (valid) {
  463. var { href } = this.$router.resolve({
  464. path: '/deptRankSwiper',
  465. query: {
  466. month: this.byRankingData.month || 0,
  467. type: '2',
  468. position: this.byRankingData.position,
  469. dept_id: this.byRankingData.dept_id[0].id,
  470. dept_name: this.byRankingData.dept_id[0].name,
  471. pt_id: 3
  472. }
  473. });
  474. window.open(href);
  475. }
  476. });
  477. },
  478. // 轮播排名弹窗
  479. byRanking() {
  480. (this.byRankingData = {
  481. month: '',
  482. dept_id: '',
  483. position: 'all'
  484. }),
  485. (this.byRankingShow = true);
  486. },
  487. // 提示信息
  488. tips_close() {
  489. localStorage.setItem('dept_rank_tips', 'true');
  490. this.tips_show = false;
  491. },
  492. // 查询
  493. selectBtn() {
  494. switch (this.time_type) {
  495. case '1':
  496. this.$set(this.formData, 'month', this.export_from.month);
  497. this.formData.month ? '' : delete this.formData.month;
  498. break;
  499. case '2':
  500. this.$set(this.formData, 'year', this.export_from.year);
  501. this.formData.year ? '' : delete this.formData.year;
  502. break;
  503. case '月份':
  504. this.$set(this.formData, 'month', this.export_from.month);
  505. this.formData.month ? '' : delete this.formData.month;
  506. break;
  507. case '3':
  508. this.$set(this.formData, 'quarter', this.export_from.quarter);
  509. this.formData.quarter ? '' : delete this.formData.quarter;
  510. break;
  511. case '4':
  512. this.$set(this.formData, 'time_range', this.export_from.time_range);
  513. this.formData.time_range ? '' : delete this.formData.time_range;
  514. break;
  515. default:
  516. break;
  517. }
  518. let data = JSON.parse(JSON.stringify(this.formData));
  519. var employee_ids = data.exclusion.join(',');
  520. data.exclusion = employee_ids;
  521. data.page = 1;
  522. data.page_size = 10;
  523. this.$nextTick(() => {
  524. this.get_list(data);
  525. });
  526. },
  527. // 页面变更
  528. handleCurrentChange(val) {
  529. this.formData.page = val;
  530. this.get_list(this.formData);
  531. },
  532. handleSizeChange(val) {
  533. this.formData.page = 1;
  534. this.formData.page_size = val;
  535. this.get_list(this.formData);
  536. },
  537. // 选择时间
  538. export_quarter_confirm(val) {
  539. this.export_from.quarter = val;
  540. },
  541. //请求数据
  542. get_list(data, bool) {
  543. if (this.time_type == 1) {
  544. delete data.year;
  545. delete data.quarter;
  546. delete data.time_range;
  547. } else if (this.time_type == 2) {
  548. delete data.month;
  549. delete data.quarter;
  550. delete data.time_range;
  551. } else if (this.time_type == '月份') {
  552. delete data.year;
  553. delete data.quarter;
  554. delete data.time_range;
  555. } else if (this.time_type == 3) {
  556. delete data.month;
  557. delete data.year;
  558. delete data.time_range;
  559. } else if (this.time_type == 4) {
  560. delete data.month;
  561. delete data.year;
  562. delete data.quarter;
  563. if(data.time_range && data.time_range.length > 0){
  564. data.start_date = moment(data.time_range[0]).format('YYYY-MM-DD')
  565. data.end_date = moment(data.time_range[1]).format('YYYY-MM-DD')
  566. }
  567. delete data.time_range
  568. }
  569. if (bool) {
  570. data.month = moment().format('YYYY-MM');
  571. }
  572. let self = this;
  573. self.loading = true;
  574. data ? '' : (data = this.formData);
  575. data.position = data.position == 'manager' ? 'manager' : data.position == 'employee' ? 'employee' : 'all';
  576. self.$axios('get', '/api/integral/statistics/ranking', data, 'v2')
  577. .then(res => {
  578. this.labelName = this.formData.pt_id == 2 ? 'A分' : 'B分';
  579. if (res.data.code == 1) {
  580. self.list = res.data.data.list;
  581. self.total = res.data.data.total;
  582. } else {
  583. self.$message.error(res.data.data.msg);
  584. }
  585. })
  586. .finally(() => {
  587. self.loading = false;
  588. });
  589. },
  590. // 获取积分规则
  591. get_rule_tree() {
  592. this.$axios('get', '/api/integral/rule/trees', { cycle_type: '1' }).then(res => {
  593. this.rule_trees = this.getRuleTreeData(res.data.data.rule_tree);
  594. });
  595. },
  596. // 规则递归 children
  597. getRuleTreeData(data) {
  598. for (var i = 0; i < data.length; i++) {
  599. if (data[i].child.length < 1) {
  600. // children若为空数组,则将children设为undefined
  601. data[i].child = undefined;
  602. } else {
  603. // children若不为空数组,则继续 递归调用 本方法
  604. this.getRuleTreeData(data[i].child);
  605. }
  606. }
  607. return data;
  608. },
  609. // 递归判断列表,把最后的children设为undefined
  610. getTreeData(data) {
  611. for (var i = 0; i < data.length; i++) {
  612. data[i].obj = { id: data[i].id, name: data[i].name };
  613. if (data[i]._child.length < 1) {
  614. // children若为空数组,则将children设为undefined
  615. data[i]._child = undefined;
  616. } else {
  617. // children若不为空数组,则继续 递归调用 本方法
  618. this.getTreeData(data[i]._child);
  619. }
  620. }
  621. return data;
  622. },
  623. getEmployeeList() {
  624. let self = this;
  625. self.$axios('get', '/api/employee/list', { dept_id: self.formData.dept_id }).then(res => {
  626. if (res.data.code == 1) {
  627. this.employee_map = res.data.data.list;
  628. } else {
  629. self.$message.error(res.data.data.msg);
  630. }
  631. });
  632. },
  633. exportExcel() {
  634. //人员
  635. this.Dc_Data.DC_position =
  636. this.Dc_Data.DC_position == 'manager' ? 'manager' : this.Dc_Data.DC_position == 'employee' ? 'employee' : this.Dc_Data.DC_position == '全部' ? 'all' : 'all';
  637. //部门
  638. let dept_name;
  639. for (let i in this.Dc_Data.dept_name) {
  640. dept_name = this.Dc_Data.dept_name[i];
  641. }
  642. this.Dc_Data.dept_name = dept_name;
  643. //规则
  644. // let rule_id = [];
  645. // for (let i in this.Dc_Data.rule_id) {
  646. // for (let a in this.Dc_Data.rule_id[i]) {
  647. // rule_id.push(this.Dc_Data.rule_id[i][a]);
  648. // }
  649. // }
  650. // this.Dc_Data.rule_id = rule_id;
  651. let data = '';
  652. if (this.Dc_Data.value1) {
  653. data += '&start_date=' + moment(this.Dc_Data.value1[0]).format('YYYY-MM-DD');
  654. data += '&end_date=' + moment(this.Dc_Data.value1[1]).format('YYYY-MM-DD');
  655. }
  656. data += '&position=' + this.Dc_Data.DC_position;
  657. this.Dc_Data.dept_name > 0 ? (data += '&dept_id=' + this.Dc_Data.dept_name) : (data += '&dept_id=0');
  658. if (this.Dc_Data.rule_id.length > 0) {
  659. data += '&rule_id=' + this.Dc_Data.rule_id;
  660. }
  661. window.open(process.env.VUE_APP_BASE_API + 'api/download/ranking/v2?pt_id=' + this.Dc_Data.pt_id + '&employee_id=' + this.$getUserData().id + data, '_blank');
  662. this.dialogVisible = false;
  663. },
  664. //获取部门
  665. getDepartment() {
  666. this.$axios('get', '/api/department/tree').then(res => {
  667. this.dept_tree = this.getTreeData(res.data.data.list);
  668. });
  669. }
  670. },
  671. mounted() {
  672. this.point_types = this.$getTyps();
  673. this.tips_show = JSON.parse(localStorage.getItem('dept_rank_tips')) ? false : true;
  674. this.getDepartment();
  675. this.getEmployeeList();
  676. this.get_list(this.formData, true);
  677. this.get_rule_tree();
  678. }
  679. };
  680. </script>
  681. <style scoped lang="scss">
  682. .search_box {
  683. ::v-deep button:active {
  684. background: #26a2ff;
  685. }
  686. ::v-deep button:active .el-icon-search {
  687. color: #fff;
  688. }
  689. }
  690. .date-picker-width {
  691. width: 100% !important;
  692. }
  693. .nopoint_box {
  694. display: inline-block;
  695. text-align: center;
  696. width: 100%;
  697. margin-bottom: 10px;
  698. }
  699. .noimg {
  700. display: inline-block;
  701. width: 110px;
  702. height: 110px;
  703. margin: 22px auto 16px;
  704. /* background:url("/static/images/nodata_default.png") no-repeat center; */
  705. background-size: 99%;
  706. }
  707. .noperson {
  708. display: inline-block;
  709. width: 110px;
  710. height: 110px;
  711. line-height: none;
  712. margin: 22px auto 16px;
  713. background: url('/static/images/noperson_default.png') no-repeat center;
  714. background-size: 99%;
  715. }
  716. .title {
  717. display: block;
  718. text-align: center;
  719. font-size: 12px !important;
  720. line-height: 30px;
  721. color: #909399 !important;
  722. padding: 0;
  723. }
  724. .nopoint_box a {
  725. color: #26a2ff;
  726. }
  727. .chart_content {
  728. .chart-legend__wrap {
  729. text-align: right;
  730. padding: 20px;
  731. padding-right: 50px;
  732. & .chart-legend__pink {
  733. position: relative;
  734. padding-left: 12px;
  735. padding-right: 5px;
  736. &:after {
  737. content: '';
  738. position: absolute;
  739. margin-top: -2px;
  740. top: 35%;
  741. left: 0;
  742. width: 8px;
  743. height: 8px;
  744. background: #f56c6c;
  745. border-radius: 100%;
  746. }
  747. }
  748. & .chart-legend__green {
  749. position: relative;
  750. padding-left: 12px;
  751. &:after {
  752. content: '';
  753. position: absolute;
  754. margin-top: -2px;
  755. top: 35%;
  756. left: 0;
  757. width: 8px;
  758. height: 8px;
  759. background: #53b87f;
  760. border-radius: 100%;
  761. }
  762. }
  763. }
  764. }
  765. .drawer_title {
  766. font-size: 18px;
  767. padding: 20px;
  768. }
  769. .manager_statistics_box {
  770. background-color: #ffffff;
  771. padding: 20px;
  772. min-height: calc(100vh - 160px);
  773. ::v-deep .el-row .el-checkbox .el-checkbox__label {
  774. line-height: 20px;
  775. }
  776. }
  777. .diy_tip_bg {
  778. background: #f5f6f9;
  779. overflow: hidden;
  780. .diy-tip {
  781. margin-bottom: 15px;
  782. border: 1px solid #67c23a;
  783. padding: 20px 16px;
  784. p {
  785. color: #67c23a !important;
  786. font-size: 14px;
  787. margin: 0 !important;
  788. padding: 4px 0;
  789. }
  790. }
  791. }
  792. ::v-deep .el-dialog {
  793. top: 21%;
  794. }
  795. .picker_er {
  796. margin-top: 20px;
  797. }
  798. .el-range-editor--medium.el-input__inner {
  799. width: 280px;
  800. }
  801. ::v-deep .el-cascader .el-input .el-input__inner {
  802. width: 150px;
  803. }
  804. .el-checkbox.is-bordered.el-checkbox--medium {
  805. padding: 9px 20px 7px 10px;
  806. }
  807. </style>