individual_statistics.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  1. <template>
  2. <div>
  3. <el-row style="min-width:1160px;">
  4. <FormBox :isShowHeader="false">
  5. <template #footer>
  6. <el-form ref="form" :inline="true" label-width="60px">
  7. <el-form-item label="人员">
  8. <el-select size="medium" v-model="select_employee_id" @change="selectEmployeeChange" filterable placeholder="请输入或选择人员">
  9. <el-option v-for="item in employee_map" :key="item.id" :label="item.name" :value="item.id"></el-option>
  10. </el-select>
  11. </el-form-item>
  12. <el-form-item label="时间">
  13. <div class="flex-box-ce">
  14. <div style="margin-right: 10px;">
  15. <el-select size="medium" v-model="time_type" placeholder="请选择分类" style="width: 100px;">
  16. <el-option v-for="item in time_types" :key="item.label" :label="item.label" :value="item.value"></el-option>
  17. </el-select>
  18. </div>
  19. <el-date-picker
  20. v-show="time_type == '2'"
  21. v-model="export_from.year"
  22. size="medium"
  23. type="year"
  24. value-format="yyyy"
  25. :clearable="false"
  26. :editable="false"
  27. placeholder="选择年份排名"
  28. ></el-date-picker>
  29. <el-date-picker
  30. v-show="time_type == '1' || time_type == '月份'"
  31. v-model="export_from.month"
  32. size="medium"
  33. type="month"
  34. value-format="yyyy-MM"
  35. :clearable="false"
  36. :editable="false"
  37. placeholder="选择月份排名"
  38. ></el-date-picker>
  39. </div>
  40. </el-form-item>
  41. </el-form>
  42. </template>
  43. </FormBox>
  44. <el-col :span="24" style="min-width:1160px;margin-top:10px;">
  45. <el-col :span="18" style="min-width:780px;">
  46. <el-row :span="24" class="top_user_info" style="margin:0 0 0 0;padding:0;">
  47. <el-col :span="7" class="userinfo_box">
  48. <el-row :gutter="40" style="margin:0;padding:0;">
  49. <el-col :span="24" class="user_info" style="display:flex;" v-loading="personnelMessage">
  50. <div class="flex-box-ce">
  51. <div class="headimg fl" style=" margin: 0 10px 0 30px;">
  52. <userImage :img_url="personnel.img_url" :user_name="personnel.name" fontSize="1" width="50px" height="50px"></userImage>
  53. </div>
  54. <div>
  55. <b style="font-size:16px;">{{ personnel.name }}</b>
  56. <el-popover trigger="hover" placement="top" popper-class="popperSPBOX">
  57. <div style="font-size:14px;color:#828282;">{{ dept_list }}</div>
  58. <div slot="reference" class="name-wrapper" style="width: 200px;">
  59. <span style="font-size:14px;color:#828282;">{{ dept_list }}</span>
  60. </div>
  61. </el-popover>
  62. </div>
  63. </div>
  64. </el-col>
  65. </el-row>
  66. </el-col>
  67. <el-col :span="17" style="margin-top:34px;padding:0 0 10px 0;height:58px;" v-loading="authorityManagerHeaderLoad">
  68. <el-col :gutter="50" style="margin:0;padding:0;" class="quick_button_box">
  69. <div style="display:flex;justify-content: space-around;">
  70. <p style="text-align:center;cursor:pointer;margin: 0;">
  71. <b style="color:#26A2FF;font-size:27px;">{{ authorityManagerHeaders.b_today ? authorityManagerHeaders.b_today : '0' }}</b>
  72. <br />
  73. <span style="color:#606266;font-size:14px;padding-top:8px;display: inline-block;">今日B分</span>
  74. </p>
  75. <p style="text-align:center;cursor:pointer;margin: 0;">
  76. <b style="color:#26A2FF;font-size:27px;">{{ authorityManagerHeaders.b ? authorityManagerHeaders.b : '0' }}</b>
  77. <br />
  78. <span style="color:#606266;font-size:14px;padding-top:8px;display: inline-block;">{{ yearhORmontStr }}度B分</span>
  79. </p>
  80. <p style="text-align:center;cursor:pointer;margin: 0;">
  81. <b style="color:#26A2FF;font-size:27px;">{{ authorityManagerHeaders.a ? authorityManagerHeaders.a : '0' }}</b>
  82. <br />
  83. <span style="color:#606266;font-size:14px;padding-top:8px;display: inline-block;">{{ yearhORmontStr }}度A分</span>
  84. </p>
  85. <p style="text-align:center;cursor:pointer;margin: 0;">
  86. <b style="color:#26A2FF;font-size:27px;">{{ authorityManagerHeaders.work_complete + '/' + authorityManagerHeaders.work_total}}</b>
  87. <br />
  88. <span style="color:#606266;font-size:14px;padding-top:8px;display: inline-block;">任务进度</span>
  89. </p>
  90. </div>
  91. </el-col>
  92. </el-col>
  93. </el-row>
  94. <el-col :span="24">
  95. <el-row class="left-all-style">
  96. <el-row style="position: relative;">
  97. <el-col :span="24" class="flex-box-ce" style="position: absolute;z-index: 999;">
  98. <b class="title" style="margin-bottom:15px;display:block">
  99. {{ yearhORmontStr }}积分构成
  100. <el-tooltip placement="top">
  101. <div slot="content">饼图仅统计B分占比较多的前8种规则分类</div>
  102. <i class="el-icon-question fontColorC"></i>
  103. </el-tooltip>
  104. </b>
  105. </el-col>
  106. <div v-loading="IntegralFormChartLoad">
  107. <div class="nopoint_box" style="height:307px;" v-show="IntegralFormnone">
  108. <div class="noimg" style="width: 150px;height: 150px;margin-top:80px;"></div>
  109. <span class="title1">暂无积分数据</span>
  110. </div>
  111. <div v-show="!IntegralFormnone"><div ref="IntegralFormChart" :style="{ width: '100%', height: '380px' }"></div></div>
  112. </div>
  113. </el-row>
  114. </el-row>
  115. </el-col>
  116. <el-col :span="24" style="">
  117. <el-row class="left-all-style">
  118. <el-row style="position: relative;">
  119. <el-col :span="24" style="display:flex">
  120. <b class="title" style="margin:0 20px 15px 0;display:block">{{ yearhORmontStr }}积分情况</b>
  121. <el-checkbox v-model="exclusiveMonthChecked">不包含自动积分加分项</el-checkbox>
  122. </el-col>
  123. <div v-loading="monthlyIntegralloading">
  124. <div class="nopoint_box" style="height:450px;" v-if="monthlyIntegralnone">
  125. <div class="noimg" style="width: 150px;height: 150px;margin-top:110px;"></div>
  126. <span class="title1">暂无积分数据</span>
  127. </div>
  128. <div v-show="!monthlyIntegralnone">
  129. <div ref="monthlyIntegralChart" :style="{ width: '100%', height: '400px' }"></div>
  130. <div style="width:90%;display:flex;justify-content: space-around;margin-top:30px;padding-left:40px">
  131. <p v-for="(item, index) in monthORyear == '2' ? monthlyIntegralList : yearlyIntegralList" :key="index" style="text-align:center">
  132. <b style="display:block;color:#303133;font-size:18px;" v-if="index < 3">
  133. {{ index == 0 ? item.total_point : index == 1 ? item.reward_point : index == 2 ? item.deduction_point : '' }}
  134. </b>
  135. <b style="display:block;color:#303133;font-size:18px;" v-else-if="index == 3">{{ item.ratio == -1 ? '—' : item.ratio + ':1' }}</b>
  136. <b style="display:block;color:#303133;font-size:18px;" v-else>
  137. {{ item.toRatio.ratio + '%' }}
  138. <svg-icon
  139. :icon-class="item.toRatio.type == 1 ? 'litrearrows' : item.toRatio.type == 2 ? 'droparrows' : ''"
  140. style="font-size:10px;margin-bottom:2px"
  141. />
  142. </b>
  143. <span style="color:rgb(48, 49, 51);font-size:14px;margin-top:5px;display:block;">{{ item.name }}</span>
  144. </p>
  145. </div>
  146. </div>
  147. </div>
  148. </el-row>
  149. </el-row>
  150. </el-col>
  151. </el-col>
  152. <el-col :span="6" style="min-width:280px;">
  153. <el-col>
  154. <el-row class="right-all-style" v-loading="awardDeductRanking">
  155. <el-row style="">
  156. <el-col :span="24" style="display:flex">
  157. <b class="title" style="margin:0 20px 15px 0;display:block">{{ yearhORmontStr }}奖分最多</b>
  158. </el-col>
  159. <el-col :span="24" style="margin-bottom:10px;">
  160. <el-col style="">
  161. <div class="nopoint_box" v-if="IntegralEventO.length == 0">
  162. <div class="noimg" style="margin: 48px auto 16px;"></div>
  163. <span class="title1" style="padding-bottom:20px;">暂无积分数据</span>
  164. </div>
  165. <el-table :data="IntegralEventO" fit :show-header="false" style="border:0px solid #fff;" v-else>
  166. <el-table-column prop="remark_data" label="规则">
  167. <template slot-scope="scope">
  168. <div
  169. style="padding-left:10px;display:flex;flex-wrap:wrap;overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 1;"
  170. >
  171. <el-popover trigger="hover" placement="top" popper-class="popperSPBOX">
  172. <div style="font-size:14px;color:#828282;">{{ scope.row.remark.customize || scope.row.remark.rule }}</div>
  173. <div slot="reference" class="name-wrapper">
  174. <span style="font-size:14px;color:#828282;">{{ scope.row.remark.customize || scope.row.remark.rule }}</span>
  175. </div>
  176. </el-popover>
  177. </div>
  178. <!-- <span>{{scope.row.remark.customize || scope.row.remark.rule}}</span> -->
  179. </template>
  180. </el-table-column>
  181. <!-- <el-table-column align="center" prop="create_time" label="创建时间" width="140"></el-table-column> -->
  182. <el-table-column align="center" prop="point" label="积分" width="110">
  183. <template slot-scope="scope">
  184. <span>
  185. {{ scope.row.point > 0 ? '+' : '' }}{{ scope.row.point }}
  186. <span class="blue">{{ getType(scope.row.pt_id) }}</span>
  187. </span>
  188. </template>
  189. </el-table-column>
  190. </el-table>
  191. </el-col>
  192. </el-col>
  193. </el-row>
  194. </el-row>
  195. </el-col>
  196. <el-col>
  197. <el-row class="right-all-style" v-loading="awardDeductRanking">
  198. <el-row style="">
  199. <el-col :span="24" style="display:flex">
  200. <b class="title" style="margin:0 20px 15px 0;display:block">{{ yearhORmontStr }}扣分最多</b>
  201. </el-col>
  202. <el-col :span="24" style="margin-bottom:10px;">
  203. <el-col style="">
  204. <div class="nopoint_box" v-if="IntegralEventT.length == 0">
  205. <div class="noimg" style="margin: 48px auto 16px;"></div>
  206. <span class="title1" style="padding-bottom:20px;">暂无积分数据</span>
  207. </div>
  208. <el-table :data="IntegralEventT" fit :show-header="false" v-else>
  209. <el-table-column prop="remark_data" label="规则">
  210. <template slot-scope="scope">
  211. <div
  212. style="padding-left:10px;display:flex;flex-wrap:wrap;overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 1;"
  213. >
  214. <el-popover trigger="hover" placement="top" popper-class="popperSPBOX">
  215. <div style="font-size:14px;color:#828282;max-width: 300px;">{{ scope.row.remark.customize || scope.row.remark.rule }}</div>
  216. <div slot="reference" class="name-wrapper">
  217. <span style="font-size:14px;color:#828282;">{{ scope.row.remark.customize || scope.row.remark.rule }}</span>
  218. </div>
  219. </el-popover>
  220. </div>
  221. <!-- <span>{{scope.row.remark.customize || scope.row.remark.rule}}</span> -->
  222. </template>
  223. </el-table-column>
  224. <!-- <el-table-column align="center" prop="create_time" label="创建时间" width="140"></el-table-column> -->
  225. <el-table-column align="center" prop="point_mark" label="积分" width="110">
  226. <template slot-scope="scope">
  227. <span>
  228. {{ scope.row.point > 0 ? '+' : '' }}{{ scope.row.point }}
  229. <span class="blue">{{ getType(scope.row.pt_id) }}</span>
  230. </span>
  231. </template>
  232. </el-table-column>
  233. <!-- <el-table-column align="center" prop="remark_data.rule" show-overflow-tooltip label="规则" width="180"></el-table-column> -->
  234. <!-- <el-table-column align="center" label="规则" prop="remark_data.rule" width="180">
  235. <template slot-scope="scope">
  236. <el-popover trigger="hover" placement="top" popper-class="popperSPBOX">
  237. <span>{{scope.row.remark_data.rule || scope.row.remark_data.customize}}</span>
  238. <div slot="reference" class="name-wrapper" style="width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><span>{{scope.row.remark_data.rule || scope.row.remark_data.customize}}</span></div>
  239. </el-popover>
  240. </template>
  241. </el-table-column> -->
  242. </el-table>
  243. </el-col>
  244. </el-col>
  245. </el-row>
  246. </el-row>
  247. </el-col>
  248. </el-col>
  249. </el-col>
  250. </el-row>
  251. </div>
  252. </template>
  253. <script>
  254. export default {
  255. data() {
  256. return {
  257. //筛选项
  258. formData: {
  259. employee_id: this.$getUserData().id
  260. },
  261. //时间
  262. time_type: '月份',
  263. time_types: [{ label: '月份', value: '1' }, { label: '年份', value: '2' }],
  264. export_from: {
  265. year: this.$moment().format('YYYY'),
  266. month: this.$moment().format('YYYY-MM')
  267. },
  268. yearhORmontStr: '月',
  269. monthORyear: '2',
  270. //选择人员
  271. select_employee_id: '',
  272. employee_map: '', //获取人员列表
  273. dept_list: '',
  274. //人员详情
  275. personnel: {},
  276. authorityManagerHeaderLoad: false, //人员loading
  277. authorityManagerHeaders: {work_complete:0,work_total:0}, //管理员头部 数据
  278. personnelMessage: false, //人员信息loading
  279. //饼图
  280. IntegralFormChartLoad: false, //积分构成loading
  281. IntegralFormnone: false, //积分构成为空或报错,展示的开关
  282. //本月积分情况
  283. exclusiveMonthChecked: true, //不包含自动积分加分项
  284. monthlyIntegralList: [
  285. //本月积分情况数据
  286. { total_point: '0', name: '月总积分' },
  287. { reward_point: '0', name: '月总奖分' },
  288. { deduction_point: '0', name: '月总扣分' },
  289. { ratio: '0', name: '奖扣分比例' },
  290. { toRatio: { ratio: '0', type: 0 }, name: '对比上月总分' },
  291. { toRatio: { ratio: '0', type: 0 }, name: '对比上月奖分' },
  292. { toRatio: { ratio: '0', type: 0 }, name: '对比上月扣分' }
  293. ],
  294. yearlyIntegralList: [
  295. //年积分情况数据
  296. { total_point: '0', name: '年总积分' },
  297. { reward_point: '0', name: '年总奖分' },
  298. { deduction_point: '0', name: '年总扣分' },
  299. { ratio: '0', name: '奖扣分比例' },
  300. { toRatio: { ratio: '0', type: 0 }, name: '对比去年总分' },
  301. { toRatio: { ratio: '0', type: 0 }, name: '对比去年奖分' },
  302. { toRatio: { ratio: '0', type: 0 }, name: '对比去年扣分' }
  303. ],
  304. monthlyIntegralloading: false, //本月积分情况loading
  305. monthlyIntegralnone: false, //本月积分情况为空或报错,展示的开关
  306. exclusiveMonthBranch: 0, //本月积分情况--部门
  307. IntegralEventO: [], //个人奖分数据
  308. IntegralEventT: [], //个人扣分数据
  309. awardDeductRanking: false //个人奖扣分loading
  310. };
  311. },
  312. watch: {
  313. time_type(val) {
  314. if (val == '1') {
  315. //月
  316. this.monthORyear = '2';
  317. this.formData.year = null;
  318. this.formData.month = this.$moment().format('YYYY-MM');
  319. this.export_from.month = this.$moment().format('YYYY-MM');
  320. this.yearhORmontStr = '月';
  321. } else if (val == '2') {
  322. //年
  323. this.monthORyear = '3';
  324. this.formData.month = null;
  325. this.formData.year = this.$moment().format('YYYY');
  326. this.export_from.year = this.$moment().format('YYYY');
  327. this.yearhORmontStr = '年';
  328. }
  329. this.executiveFunction();
  330. },
  331. 'export_from.month'(val, old_val) {
  332. this.formData.month = val;
  333. this.executiveFunction();
  334. },
  335. 'export_from.year'(val, old_val) {
  336. this.formData.year = val;
  337. this.executiveFunction();
  338. },
  339. //不包含自动积分加分项
  340. exclusiveMonthChecked() {
  341. this.monthlyIntegral();
  342. }
  343. },
  344. mounted() {
  345. window.addEventListener('resize', this.selfAdaption);
  346. this.getEmployee().then(res => {
  347. this.formData.month = this.$moment().format('YYYY-MM');
  348. this.executiveFunction();
  349. }).catch(err => {
  350. console.log(err);
  351. });
  352. },
  353. methods: {
  354. selectEmployeeChange(val) {
  355. this.formData.employee_id = val;
  356. this.executiveFunction(true);
  357. },
  358. getType(id) {
  359. return this.$getTyps(id).name;
  360. },
  361. //获取员工列表
  362. getEmployee() {
  363. return new Promise((resolve, reject) => {
  364. this.personnelMessage = true;
  365. this.$axios('get', '/api/employee/index', { dept_id:0, keywords: '', page: 1, page_size: 3000, is_official: 1 })
  366. .then(res => {
  367. let list = res.data.data.list;
  368. this.employee_map = list.filter(x => x.is_creator != 1);
  369. if (this.employee_map.length == 0) {
  370. reject('err');
  371. return;
  372. }
  373. if (this.$getUserData().is_creator == 1) {
  374. this.select_employee_id = this.employee_map[0].id;
  375. let employee = this.employee_map[0];
  376. this.formData.employee_id = employee.id;
  377. this.personnel = employee;
  378. let dept_li = this.personnel.employee_detail.dept_list;
  379. let dept_ = '';
  380. for (let i in dept_li) {
  381. dept_ += dept_li[i].dept_name + ' ';
  382. }
  383. this.dept_list = dept_;
  384. } else {
  385. if (this.$getUserData()) {
  386. let roat=this.$supremeAuthority();
  387. if(roat=='dept_manager'){
  388. let manage_scope=this.$getUserData().employee_detail.manage_scope;
  389. manage_scope.unshift({id: this.$getUserData().id, name: this.$getUserData().name})
  390. this.employee_map=manage_scope
  391. }
  392. if(roat=='employee'){
  393. let manage_scope=[];
  394. manage_scope.unshift({id: this.$getUserData().id, name: this.$getUserData().name})
  395. this.employee_map=manage_scope
  396. }
  397. this.$nextTick(()=>{
  398. this.select_employee_id = this.$getUserData().id;
  399. })
  400. this.personnel = this.$getUserData();
  401. let dept_li = this.personnel.employee_detail.dept_list;
  402. let dept_ = '';
  403. for (let i in dept_li) {
  404. dept_ += dept_li[i].dept_name + ' ';
  405. }
  406. this.dept_list = dept_;
  407. } else {
  408. this.personnelDetails(); //获取人员详情
  409. }
  410. }
  411. })
  412. .finally(err => {
  413. this.personnelMessage = false;
  414. resolve('res');
  415. });
  416. });
  417. },
  418. //echarts自适应
  419. selfAdaption() {
  420. var myChart1 = this.$echarts.init(this.$refs.monthlyIntegralChart);
  421. var myChart2 = this.$echarts.init(this.$refs.IntegralFormChart);
  422. myChart1.resize();
  423. myChart2.resize();
  424. },
  425. //需要执行的所有函数
  426. executiveFunction(item) {
  427. //切换角色才请求--人员详情--。
  428. if (item) {
  429. this.personnelDetails(); //获取人员详情
  430. this.authorityManagerHeader(); //本月 A B 绩效分 比例
  431. this.integralForm(); //饼图
  432. this.monthlyIntegral(); //本月积分情况
  433. this.integralEvents(); //积分事件列表
  434. } else {
  435. this.authorityManagerHeader(); //本月 A B 绩效分 比例
  436. this.integralForm(); //饼图
  437. this.monthlyIntegral(); //本月积分情况
  438. this.integralEvents(); //积分事件列表
  439. }
  440. },
  441. //获取人员详情
  442. personnelDetails() {
  443. this.personnelMessage = true;
  444. let params = {
  445. id: this.formData.employee_id
  446. };
  447. this.$axios('get', '/api/employee/info', params)
  448. .then(res => {
  449. this.personnel = res.data.data;
  450. let dept_li = this.personnel.employee_detail.dept_list;
  451. let dept_ = '';
  452. for (let i in dept_li) {
  453. dept_ += dept_li[i].dept_name + ' ';
  454. }
  455. this.dept_list = dept_;
  456. })
  457. .finally(() => {
  458. this.personnelMessage = false;
  459. });
  460. },
  461. //本月 A B 绩效分 比例
  462. authorityManagerHeader() {
  463. this.authorityManagerHeaderLoad = true;
  464. let params = {};
  465. params.employee_id = this.formData.employee_id;
  466. if (this.monthORyear == '2') {
  467. //月
  468. params.month = this.formData.month;
  469. } else if (this.monthORyear == '3') {
  470. //年
  471. params.year = this.formData.year;
  472. }
  473. let params1 = this.$axios('get', '/api/integral/statistics/', params, 'v3');
  474. Promise.all([params1])
  475. .then(res => {
  476. this.authorityManagerHeaders = res[0].data.data;
  477. })
  478. .finally(() => {
  479. this.authorityManagerHeaderLoad = false;
  480. });
  481. },
  482. //饼图
  483. //分为两列展示,多传legendDataTwo
  484. // drawLine(legendDataOne, legendDataTwo, dadalist) {
  485. drawLine(legendDataOne, dadalist) {
  486. const chart = this.$refs.IntegralFormChart;
  487. //此处可给固定颜色,不给就所有颜色随机
  488. let colors = ['rgb(38, 162, 255)', '#f36f2a', '#fecb09', '#00b6bd', '#e85d53', '#fecb09', '#725197', '#fcb814', '#41a08d', '#425a95', '#ea8b84', '#9d1d62', '#fcb814'];
  489. // let colors = [];
  490. // let legendDataLeng = legendDataOne.length + legendDataTwo.length;
  491. let legendDataLeng = legendDataOne.length;
  492. if (legendDataLeng > colors.length) {
  493. //当列表大于固定颜色时,给随机颜色
  494. let colorsLeng = colors.length;
  495. for (let i = 0; i <= legendDataLeng - colorsLeng; i++) {
  496. // colors.push('#' + Math.random().toString(16).substr(2, 6).toUpperCase());//也是随机色
  497. colors.push('rgb(' + Math.round(Math.random() * 255) + ',' + Math.round(Math.random() * 255) + ',' + Math.round(Math.random() * 255) + ')');
  498. }
  499. }
  500. //只显示 N 条标题,多余隐藏,但是饼图不会隐藏
  501. let DataLengths = [];
  502. // for (let i in legendDataTwo) {
  503. // if (i < 8) {
  504. // DataLengths.push(legendDataTwo[i]);
  505. // }
  506. // }
  507. let left1 = '45%';
  508. let leftBT = '25%';
  509. // if (legendDataTwo.length != 0) {
  510. // left1 = "36%";
  511. // leftBT = "18%";
  512. // }
  513. if (chart) {
  514. const myChart = this.$echarts.init(chart);
  515. var legendData1 = legendDataOne;
  516. // var legendData2 = DataLengths;
  517. const option = {
  518. tooltip: { trigger: 'item', formatter: '{b}' },
  519. legend: [
  520. {
  521. type: 'scroll',
  522. orient: 'vertical',
  523. // icon: 'square',
  524. left: left1,
  525. // align: 'left',
  526. top: '10%',
  527. itemGap: 14,
  528. textStyle: { fontSize: 14, color: 'rgb(48, 49, 51)' },
  529. data: legendData1
  530. }
  531. //分为两列展示
  532. // {
  533. // type: "scroll",
  534. // orient: "vertical",
  535. // icon: "square",
  536. // left: "70%",
  537. // align: "left",
  538. // top: "10%",
  539. // itemGap: 20,
  540. // textStyle: { fontSize: 14, color: "rgb(48, 49, 51)" },
  541. // data: legendData2,
  542. // },
  543. ],
  544. color: colors,
  545. grid: { x: 25, y: 45, x2: 5, y2: 20, borderWidth: 1 },
  546. toolbox: {
  547. show: true,
  548. feature: {
  549. mark: { show: true },
  550. magicType: { show: true, type: ['pie', 'funnel'] }
  551. }
  552. },
  553. series: [
  554. {
  555. name: '',
  556. type: 'pie',
  557. radius: [20, 110],
  558. center: [leftBT, '40%'],
  559. roseType: 'radius',
  560. label: { show: false },
  561. emphasis: { label: { show: false } },
  562. data: dadalist
  563. }
  564. ],
  565. };
  566. myChart.setOption(option);
  567. }
  568. },
  569. integralForm() {
  570. this.IntegralFormChartLoad = true;
  571. let listslength = [];
  572. let params = {};
  573. params.employee_id = this.formData.employee_id;
  574. if (this.monthORyear == '2') {
  575. //月
  576. params.month = this.formData.month;
  577. } else if (this.monthORyear == '3') {
  578. //年
  579. params.year = this.formData.year;
  580. }
  581. this.$axios('get', '/api/integral/statistics/pie/b', params, 'v2')
  582. .then(res => {
  583. let lists = res.data.data.list;
  584. listslength = lists;
  585. let legendData1 = [];
  586. let legendData2 = [];
  587. let dadalist = [];
  588. //分为两列展示
  589. // let listLeng = Math.ceil((lists.length)/2)
  590. for (let i in lists) {
  591. if (lists[i].name.length > 15) {
  592. lists[i].name = lists[i].name.slice(0, 15) + '...';
  593. }
  594. //分为两列展示
  595. // if(i<listLeng){
  596. // legendData1.push(lists[i].name+' '+'奖'+lists[i].reward+' '+'扣'+lists[i].deduction+' '+lists[i].ratio+'%')
  597. // }else{
  598. // legendData2.push(lists[i].name+' '+'奖'+lists[i].reward+' '+'扣'+lists[i].deduction+' '+lists[i].ratio+'%')
  599. // }
  600. if (i < 8) {
  601. legendData1.push(lists[i].name + ' ' + '奖' + lists[i].reward + ' ' + '扣' + lists[i].deduction + ' ' + lists[i].ratio + '%');
  602. } else {
  603. legendData2.push(lists[i].name + ' ' + '奖' + lists[i].reward + ' ' + '扣' + lists[i].deduction + ' ' + lists[i].ratio + '%');
  604. }
  605. let dataListDx = {};
  606. if (lists[i].ratio < 0) {
  607. dataListDx.value = 0;
  608. } else {
  609. dataListDx.value = lists[i].ratio;
  610. }
  611. dataListDx.name = lists[i].name + ' ' + '奖' + lists[i].reward + ' ' + '扣' + lists[i].deduction + ' ' + lists[i].ratio + '%';
  612. // dataListDx.name = lists[i].name
  613. dadalist.push(dataListDx);
  614. }
  615. //分为两列展示,多传legendData2
  616. this.drawLine(legendData1, dadalist); //图表
  617. })
  618. .finally(() => {
  619. if (listslength.length == 0) {
  620. this.IntegralFormnone = true;
  621. } else {
  622. this.IntegralFormnone = false;
  623. }
  624. this.IntegralFormChartLoad = false;
  625. });
  626. },
  627. //月度积分
  628. monthlyIntegralRanking(date, total, reward, deduction) {
  629. const chart = this.$refs.monthlyIntegralChart;
  630. if (chart) {
  631. const myChart = this.$echarts.init(chart);
  632. const option = {
  633. tooltip: {
  634. trigger: 'axis'
  635. },
  636. color: ['#F56C6C', '#26A2FF', '#FFC100'],
  637. legend: {
  638. right: '0%',
  639. data: ['总积分', '奖分', '扣分']
  640. },
  641. grid: {
  642. left: '3%',
  643. right: '4%',
  644. bottom: '3%',
  645. containLabel: true
  646. },
  647. toolbox: {
  648. feature: {}
  649. },
  650. xAxis: {
  651. type: 'category',
  652. boundaryGap: false,
  653. data: date
  654. },
  655. yAxis: {
  656. type: 'value',
  657. axisLine: {
  658. show: false
  659. },
  660. axisTick: {
  661. show: false
  662. }
  663. },
  664. series: [
  665. {
  666. name: '总积分',
  667. type: 'line',
  668. data: total
  669. },
  670. {
  671. name: '奖分',
  672. type: 'line',
  673. data: reward
  674. },
  675. {
  676. name: '扣分',
  677. type: 'line',
  678. data: deduction
  679. }
  680. ]
  681. };
  682. myChart.setOption(option);
  683. }
  684. },
  685. //月度积分
  686. // monthlyIntegralchange(val){
  687. // console.log(val)
  688. // if(val.length == 0){
  689. // this.exclusiveMonthBranch = 0
  690. // }else{
  691. // let valItem = 0
  692. // for(let i in val){
  693. // valItem = val[i]
  694. // }
  695. // this.exclusiveMonthBranch = valItem
  696. // }
  697. // this.monthlyIntegral()
  698. // this.$nextTick(()=>{
  699. // this.$refs.dept2.dropDownVisible = false;
  700. // })
  701. // },
  702. monthlyIntegral() {
  703. this.monthlyIntegralloading = true;
  704. let params = {};
  705. let listslength = [];
  706. params.employee_id = this.formData.employee_id;
  707. if (this.monthORyear == '2') {
  708. //月
  709. params.month = this.formData.month;
  710. } else if (this.monthORyear == '3') {
  711. //年
  712. params.year = this.formData.year;
  713. }
  714. if (this.exclusiveMonthChecked) {
  715. params.include_fixed = 1;
  716. } else {
  717. params.include_fixed = 0;
  718. }
  719. this.$axios('get', '/api/integral/statistics/curve', params)
  720. .then(res => {
  721. if (res.data.code == 1) {
  722. let lists = res.data.data;
  723. listslength = lists;
  724. if (this.monthORyear == '2') {
  725. this.monthlyIntegralList[0].total_point = lists.total_point;
  726. this.monthlyIntegralList[1].reward_point = lists.reward_point;
  727. this.monthlyIntegralList[2].deduction_point = lists.deduction_point;
  728. this.monthlyIntegralList[3].ratio = lists.ratio;
  729. this.monthlyIntegralList[4].toRatio = lists.contrast_total;
  730. this.monthlyIntegralList[5].toRatio = lists.contrast_reward;
  731. this.monthlyIntegralList[6].toRatio = lists.contrast_deduction;
  732. } else if (this.monthORyear == '3') {
  733. this.yearlyIntegralList[0].total_point = lists.total_point;
  734. this.yearlyIntegralList[1].reward_point = lists.reward_point;
  735. this.yearlyIntegralList[2].deduction_point = lists.deduction_point;
  736. this.yearlyIntegralList[3].ratio = lists.ratio;
  737. this.yearlyIntegralList[4].toRatio = lists.contrast_total;
  738. this.yearlyIntegralList[5].toRatio = lists.contrast_reward;
  739. this.yearlyIntegralList[6].toRatio = lists.contrast_deduction;
  740. }
  741. let dates = []; //日期
  742. let totals = []; //总积分
  743. let rewards = []; //奖分
  744. let deductions = []; //扣分
  745. for (let i in lists.total) {
  746. dates.push(lists.total[i].date);
  747. totals.push(lists.total[i].point);
  748. }
  749. for (let i in lists.reward) {
  750. rewards.push(lists.reward[i].point);
  751. }
  752. for (let i in lists.deduction) {
  753. deductions.push(lists.deduction[i].point);
  754. }
  755. this.monthlyIntegralRanking(dates, totals, rewards, deductions);
  756. }
  757. })
  758. .finally(() => {
  759. if (!listslength.total) {
  760. this.monthlyIntegralnone = true;
  761. } else {
  762. this.monthlyIntegralnone = false;
  763. }
  764. this.monthlyIntegralloading = false;
  765. });
  766. },
  767. //积分事件列表
  768. integralEvents() {
  769. this.awardDeductRanking = true;
  770. let params = {
  771. page: 1,
  772. page_size: 5,
  773. pt_id: '3',
  774. time_type: '2'
  775. };
  776. params.employee_id = this.formData.employee_id;
  777. if (this.monthORyear == '2') {
  778. //月
  779. params.month = this.formData.month;
  780. params.time_type = '2';
  781. } else if (this.monthORyear == '3') {
  782. //年
  783. params.year = this.formData.year;
  784. params.time_type = '3';
  785. }
  786. this.$axios('get', '/api/integral/statistics/prize/buckle/ranking', params)
  787. .then(res => {
  788. this.IntegralEventO = res.data.data.prize;
  789. this.IntegralEventT = res.data.data.buckle;
  790. })
  791. .finally(() => {
  792. this.awardDeductRanking = false;
  793. });
  794. }
  795. },
  796. beforeDestroy() {
  797. //取消echarts自适应
  798. window.removeEventListener('resize', this.selfAdaption);
  799. }
  800. };
  801. </script>
  802. <style scoped="scoped" lang="scss">
  803. .el-table::before {
  804. height: 0px;
  805. }
  806. .left-all-style {
  807. margin-top: 10px;
  808. padding: 20px;
  809. background: #fff;
  810. border-radius: 5px;
  811. .title {
  812. padding-left: 10px;
  813. font-size: 16px;
  814. font-weight: normal;
  815. border-left: 2px solid #409eff;
  816. }
  817. .titledes {
  818. display: block;
  819. padding-top: 10px;
  820. font-size: 14px;
  821. color: #909399;
  822. }
  823. .noremind {
  824. display: block;
  825. text-align: right;
  826. font-size: 12px;
  827. color: #909399;
  828. cursor: pointer;
  829. }
  830. .noremind:hover {
  831. color: #409eff;
  832. }
  833. .noremind:active {
  834. color: #409eff;
  835. }
  836. }
  837. .right-all-style {
  838. padding: 20px;
  839. background: #fff;
  840. border-radius: 5px;
  841. margin: 0 0 10px 10px;
  842. .title {
  843. padding-left: 10px;
  844. font-size: 16px;
  845. font-weight: normal;
  846. border-left: 2px solid #409eff;
  847. }
  848. }
  849. .rightexamineAndApproveList {
  850. text-align: left;
  851. width: 100%;
  852. border-bottom: 1px solid #efefef;
  853. }
  854. .nopoint_box {
  855. display: inline-block;
  856. text-align: center;
  857. width: 100%;
  858. margin-bottom: 10px;
  859. .noimg {
  860. display: inline-block;
  861. width: 110px;
  862. height: 110px;
  863. margin: 22px auto 16px;
  864. background: url('../../assets/image/nodata_default.png') no-repeat center;
  865. background-size: 99%;
  866. }
  867. .noperson {
  868. display: inline-block;
  869. width: 110px;
  870. height: 110px;
  871. margin: 22px auto 16px;
  872. background: url('../../assets/image/noperson_default.png') no-repeat center;
  873. background-size: 99%;
  874. }
  875. .title1 {
  876. display: block;
  877. text-align: center;
  878. font-size: 12px !important;
  879. color: #909399 !important;
  880. padding: 0;
  881. }
  882. a {
  883. color: #26a2ff;
  884. }
  885. }
  886. .top_user_info {
  887. position: relative;
  888. padding-top: 0;
  889. background: #fff;
  890. .userinfo_box {
  891. border-right: 1px #cecccc solid;
  892. margin: 34px 0;
  893. }
  894. .user_box {
  895. padding-left: 0 !important;
  896. border-right: 1px #333 solid;
  897. }
  898. .headimg_box {
  899. padding-left: 0 !important;
  900. }
  901. .headimg_box .headimg {
  902. width: 50px;
  903. height: 50px;
  904. background: #909399;
  905. border-radius: 50px;
  906. }
  907. .user_info {
  908. padding: 0 !important;
  909. line-height: 25px;
  910. .greetings {
  911. margin: 4px 0px 0 120px;
  912. font-size: 16px;
  913. font-weight: bold;
  914. }
  915. .greetings span {
  916. font-size: 14px;
  917. color: #666;
  918. display: inline-block;
  919. vertical-align: top;
  920. }
  921. span:nth-child(1) {
  922. display: block;
  923. font-size: 16px;
  924. overflow: hidden;
  925. white-space: nowrap;
  926. text-overflow: ellipsis;
  927. }
  928. }
  929. .person {
  930. display: block;
  931. font-size: 14px;
  932. padding: 32px 0 18px 0;
  933. color: #606266;
  934. }
  935. .time {
  936. font-size: 14px;
  937. padding-right: 10px;
  938. position: relative;
  939. }
  940. }
  941. /*
  942. padding: 18px 0 16px 0;
  943. color: #606266;
  944. height: 32px;
  945. box-sizing: content-box;
  946. */
  947. .pointsevent_box {
  948. display: block;
  949. text-align: center;
  950. margin: 20px 0 0 0px;
  951. padding-right: 0 !important;
  952. border: 1px #e1e4e7 solid;
  953. box-shadow: 0 2px 4px rgba(140, 140, 140, 0.1);
  954. .title {
  955. font-family: Microsoft Yahei;
  956. display: block;
  957. text-align: left;
  958. margin-bottom: 20px;
  959. padding: 0 0 0 10px;
  960. font-size: 16px;
  961. font-weight: normal;
  962. border-left: 2px solid #409eff;
  963. }
  964. }
  965. .popperSPBOX {
  966. max-width: calc(100vh - 400px);
  967. background-color: #fff;
  968. }
  969. </style>