custom_rank code.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. <template>
  2. <div class="all-box">
  3. <div class="all">
  4. <div class="flex-box" v-loading="groups_loading">
  5. <div class="terr-left">
  6. <el-button v-if="employeeOrdept" size="medium" @click="addGroup" type="primary">新建分组</el-button>
  7. <el-menu default-active="0" class="el-menu-vertical-demo" style="border: none" v-if="groups_list.length>0">
  8. <el-menu-item
  9. style="height: 47px;line-height: 47px;"
  10. :index="index.toString()"
  11. class="font-flex-word"
  12. v-for="(item, index) in groups_list"
  13. :key="index"
  14. @click="open_right(item)"
  15. v-show="item.code !== 'employee'"
  16. >
  17. <i class="el-icon-document-copy"></i>
  18. <span slot="title">{{ item.name }}</span>
  19. </el-menu-item>
  20. </el-menu>
  21. <div v-else style="text-align: center;margin-top: 10%;" class="fontColorF">
  22. <img src="@/assets/image/nodata.png" style="width: 180px;height: 120px;margin: 30px auto;">
  23. 还没有自定义分组
  24. </div>
  25. </div>
  26. <div class="terr-right border-right flex-1" v-loading="table_loading">
  27. <div class="listData" v-if="table_list.length > 0">
  28. <div class="flex-box">
  29. <div class="flex-box flex-v-ce margin-bottom">
  30. <div class="groupsName">{{groups_info.name}}<span class="blue">({{total}}人)</span></div>
  31. <el-button v-if="employeeOrdept" @click="editGroup" size="medium">编辑</el-button>
  32. </div>
  33. </div>
  34. <!-- form -->
  35. <el-form :model="params" :inline="true" ref="params">
  36. <!-- <el-form-item label="时间" label-width="40px">
  37. <el-date-picker v-model="params.month" size="medium" type="month" placeholder="请选择月份" value-format="yyyy-MM"></el-date-picker>
  38. </el-form-item> -->
  39. <el-form-item label="月份" label-width="40px" v-if="newGroupForm.date_interval == 1">
  40. <el-date-picker v-model="time.month" type="month" :clearable="false" placeholder="请选择月份" value-format="yyyy-MM"></el-date-picker>
  41. </el-form-item>
  42. <el-form-item label="年份" label-width="40px" v-if="newGroupForm.date_interval == 3">
  43. <el-date-picker v-model="time.year" type="year" :clearable="false" placeholder="请选择年份" value-format="yyyy"></el-date-picker>
  44. </el-form-item>
  45. <el-form-item label="季度" label-width="40px" v-if="newGroupForm.date_interval == 2">
  46. <!-- <el-date-picker
  47. v-model="time.quarter"
  48. type="month"
  49. placeholder="请选择季度"
  50. value-format="Q"
  51. ></el-date-picker> -->
  52. <Season :defaultHint="true" :isActive="true" class="date-picker-width" @confirm="export_quarter_confirm"></Season>
  53. </el-form-item>
  54. <el-form-item>
  55. <el-checkbox v-model="sort" size="medium" label="由低到高" border></el-checkbox>
  56. </el-form-item>
  57. </el-form>
  58. <!-- 表格 -->
  59. <el-table :data="table_list" style="width: 100%" >
  60. <el-table-column label="名次" width="80" align="center">
  61. <template slot-scope="scope">
  62. <img v-if="scope.row.rank === 1" src="@/assets/image/statistics_NO1.png" alt="" />
  63. <img v-if="scope.row.rank === 2" src="@/assets/image/statistics_NO2.png" alt="" />
  64. <img v-if="scope.row.rank === 3" src="@/assets/image/statistics_NO3.png" alt="" />
  65. <span v-if="scope.row.rank > 3">{{ scope.row.rank }}</span>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="姓名" align="left">
  69. <template slot-scope="scope">
  70. <div class="flex-box">
  71. <userImage class="fl" :user_name="scope.row.name" :img_url="scope.row.img_url" width="50px" height="50px"></userImage>
  72. <span style="line-height: 50px; padding-left: 10px;">{{ scope.row.name }}</span>
  73. </div>
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="B分" align="left" prop="point"></el-table-column>
  77. <template slot="empty">
  78. <noData></noData>
  79. </template>
  80. </el-table>
  81. <center style="padding: 20px 0;">
  82. <el-pagination
  83. background
  84. @size-change="handleSizeChange"
  85. @current-change="handleCurrentChange"
  86. :page-sizes="[10, 20, 50, 100]"
  87. layout="total, sizes, prev, pager, next"
  88. :page-size="params.page_size"
  89. :current-page="params.page"
  90. :total="total">
  91. </el-pagination>
  92. </center>
  93. </div>
  94. <div v-else style="margin-top: 10%;">
  95. <noData :isSolt="true">
  96. <template v-slot:default>
  97. <div style="text-align: center;">还没有分组<span v-if="employeeOrdept">,</span><span v-if="employeeOrdept" style="color:#26A2FF;cursor:pointer" @click="addGroup">去添加 >></span></div>
  98. </template>
  99. </noData>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. <!-- 新增编辑分组 -->
  105. <el-dialog :title="popupType? '新增分组':'编辑分组'" width="660px" top="5%" :visible.sync="groupShow" @close="resetForm('newGroupForm')" :close-on-click-modal="false">
  106. <el-form ref="newGroupForm" :model="newGroupForm" :rules="rules" label-width="85px" @submit.native.prevent>
  107. <el-form-item label="分组名称" prop="group_name">
  108. <el-input v-model="newGroupForm.group_name" placeholder="请输入分组名称" :clearable="true"></el-input>
  109. </el-form-item>
  110. <el-form-item label="分组成员">
  111. <el-input v-model="employeeNames" placeholder="全部成员"></el-input>
  112. <div @click="isEmployeeShow=true" style="height:36px; position: absolute; top: 0; right: 0; left: 0; bottom: 0; z-index: 9;cursor:pointer"></div>
  113. <el-dialog title="选择人员" width="700px" :visible.sync="isEmployeeShow" append-to-body :before-close="handleClose">
  114. <EmployeeSelector
  115. v-if="isEmployeeShow"
  116. ref="Employee"
  117. :user_no_select="false"
  118. :can_select_dept="true"
  119. :selected="employees_selected"
  120. :close_clear_data="true"
  121. @confirm="move_employee_confirm"/>
  122. <span slot="footer" class="dialog-footer">
  123. <el-button @click="isEmployeeShow = false">取 消</el-button>
  124. <el-button type="primary" @click="submitEmployee()">确 定</el-button>
  125. </span>
  126. </el-dialog>
  127. </el-form-item>
  128. <el-form-item label="积分规则">
  129. <el-input v-model="newGroupFormRules" placeholder="全部规则分类"></el-input>
  130. <div @click="ruleDialogTableVisibles" style="height:36px; position: absolute; top: 0; right: 0; left: 0; bottom: 0; z-index: 9;cursor:pointer"></div>
  131. <div style="margin-bottom:12px;">
  132. <span style="font-size:13px;color:rgb(138 138 138);position: absolute; top: 30px; left: 0;">{{ruleHint}}</span>
  133. </div>
  134. <el-dialog title="选择规则" width="800px" :visible.sync="ruleDialogTableVisible" append-to-body :before-close="handleClose">
  135. <div style="display:flex;position: relative;width:100%;height:40px">
  136. <span style="position: absolute;line-height:40px;left:20px">已选:{{ valuesOrLength.length }}条</span>
  137. <el-input type="text" class="search" style="position: absolute;right:20px;width:20%" placeholder="输入关键字搜索" v-model.trim="keyword" />
  138. </div>
  139. <el-row class="architecture">
  140. <el-col :span="8" class="RuleLeft" style="height:500px">
  141. <div class="rule_class_box">
  142. <el-tree
  143. ref="menum"
  144. class="cate-tree"
  145. node-key="id"
  146. :accordion="true"
  147. :highlight-current="true"
  148. :data="rule_trees"
  149. :default-expand-all="false"
  150. :props="defaultProps"
  151. :expand-on-click-node="false"
  152. @node-click="handleNodeClick"
  153. >
  154. <div content="tree" v-if="!data.dis" v-show="rule_trees.length != 0" slot-scope="{ node, data }">
  155. <span class="name">{{ data.name }}</span>
  156. </div>
  157. </el-tree>
  158. </div>
  159. </el-col>
  160. <el-col :span="16" class="RuleRight" v-loading="tableLoadingRule" style="height:500px;overflow-y:auto">
  161. <el-table
  162. ref="multipleTable"
  163. :data="tableData_rule"
  164. tooltip-effect="dark"
  165. style="width: 100%;cursor:pointer"
  166. @select="onTableSelect"
  167. @select-all="selectAll"
  168. @cell-click="clicktable"
  169. >
  170. <el-table-column type="selection" width="55"></el-table-column>
  171. <el-table-column prop="remark" :label="'全选'" show-overflow-tooltip></el-table-column>
  172. </el-table>
  173. </el-col>
  174. </el-row>
  175. <span slot="footer" class="dialog-footer">
  176. <el-button @click="ruleDialogTableVisible = false">取 消</el-button>
  177. <el-button type="primary" @click="ruleDialogTableVisibleQD">确 定</el-button>
  178. </span>
  179. </el-dialog>
  180. </el-form-item>
  181. <el-form-item label="统计周期" label-width="85px" prop="date_interval" :show-message="false">
  182. <el-select v-model="newGroupForm.date_interval" placeholder="请选择周期">
  183. <el-option v-for="item in options_time" :key="item.value" :label="item.label" :value="item.value"></el-option>
  184. </el-select>
  185. </el-form-item>
  186. </el-form>
  187. <div class="flex-box flex-v-ce">
  188. <el-button type="danger" v-if="!popupType" :disabled="delLoad" :loading="delLoad" @click="delItem">删除</el-button>
  189. <div class="flex-1"></div>
  190. <el-button @click="resetForm('newGroupForm')">取 消</el-button>
  191. <el-button type="primary" :loading="saveLoad" :disabled="saveLoad" @click="subGroupForm('newGroupForm')">确 定</el-button>
  192. </div>
  193. </el-dialog>
  194. </div>
  195. </template>
  196. <script>
  197. import EmployeeSelector from '@/components/EmployeeSelector.vue';
  198. import noData from '@/components/noData';
  199. import moment from 'moment'
  200. var selecteds = [];
  201. let selectionID = [];
  202. export default {
  203. components: { EmployeeSelector, noData },
  204. data() {
  205. return {
  206. page: 1,
  207. page_size: 10,
  208. total: null,
  209. tips_show:false,
  210. groups_list:[],
  211. groups_loading:false,
  212. table_loading:false,
  213. table_list:[],
  214. time: {
  215. year: moment().format('YYYY'), //年
  216. quarter: moment().format('YYYYQ'), //季度
  217. month: moment().format('YYYY-MM') //月
  218. },
  219. groups_info: {
  220. name:'',
  221. employees: []
  222. },
  223. //
  224. params:{
  225. page: 1,
  226. page_size: 10,
  227. group_id: '',
  228. // month: moment().format('YYYY-MM'),
  229. sort: 'asc',
  230. // rule_id: '',
  231. },
  232. rule_trees: [],
  233. clickItem: null,
  234. groupShow: false,
  235. rules: {
  236. group_name: [{ required: true, message: '请输入分组名称', trigger: 'blur' },{ min: 2, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur' }],
  237. date_interval: [{ required: true, message: '请选择周期', trigger: 'change' }],
  238. },
  239. newGroupForm:{
  240. group_name: "",
  241. employees: [],
  242. items:[],
  243. date_interval:"1",
  244. },
  245. saveLoad: false,
  246. delLoad: false,
  247. show_employee_selector: false,
  248. employee_not_select: [],
  249. employees_selected: {employee:[], dept: []},
  250. props:{checkStrictly: true,value: 'id', label: 'name',children:'child'},
  251. sort: false,
  252. popupType: false,
  253. // 添加分组(第二期内容添加)
  254. ruleDialogTableVisible:false,
  255. defaultProps: {
  256. children: 'child',
  257. label: 'name'
  258. },
  259. tableLoadingRule:false,
  260. tableData_rule: [],
  261. options_time_value: '',
  262. options_time: [
  263. {
  264. value: '1',
  265. label: '月度'
  266. },
  267. {
  268. value: '2',
  269. label: '季度'
  270. },
  271. {
  272. value: '3',
  273. label: '年度'
  274. }
  275. ],
  276. newGroupFormRules:'',
  277. ruleHint:'统计所有积分(基础分和工龄分除外)',
  278. valuesOrLength: [],
  279. keyword:'',
  280. treedata: [],
  281. isEmployeeShow:false,
  282. employeeNames:'',
  283. employeeOrdept:!this.$authoritys('employee') && !this.$authoritys('dept_manager'),
  284. };
  285. },
  286. created() {
  287. this.getRuleList();
  288. this.get_groups_list(true);
  289. },
  290. watch:{
  291. 'params.rule_id'(){
  292. this.$refs.rule.dropDownVisible = false;
  293. },
  294. 'time.month'(val, old_val) {
  295. this.time.month = val;
  296. this.params.page = 1;
  297. this.open_right(this.clickItem);
  298. },
  299. 'time.year'(val, old_val) {
  300. this.time.year = val;
  301. this.params.page = 1;
  302. this.open_right(this.clickItem);
  303. },
  304. // 'params.month'(val,old_val){
  305. // this.page = 1
  306. // this.open_right()
  307. // },
  308. 'sort'(val){
  309. this.params.page = 1;
  310. val ? (this.params.sort = 'desc') : (this.params.sort = 'asc');
  311. this.open_right(this.clickItem);
  312. },
  313. keyword() {
  314. //函数节流
  315. if (this.timer) {
  316. clearTimeout(this.timer);
  317. }
  318. //清空 全部
  319. if (!this.keyword) {
  320. this.tableData_rule = this.tableData_rule2;
  321. this.ifPitchOnChild(this.tableData_rule, selecteds);
  322. return;
  323. }
  324. this.timer = setTimeout(() => {
  325. const result = [];
  326. this.tableData_rule2.forEach(val => {
  327. if (val.remark.indexOf(this.keyword) > -1) {
  328. result.push(val);
  329. }
  330. });
  331. this.tableData_rule = result;
  332. this.ifPitchOnChild(this.tableData_rule, selecteds);
  333. }, 100);
  334. }
  335. },
  336. mounted() {
  337. },
  338. methods: {
  339. // 第二期内容
  340. //
  341. submitEmployee(){
  342. this.$refs.Employee.confirm();//调用组件的confirm();
  343. },
  344. //点击规则弹出窗口
  345. ruleDialogTableVisibles() {
  346. this.tableLoadingRule = true;
  347. selecteds = this.valuesOrLength;
  348. //点击弹出窗口并展示所有数据
  349. let tableData_r = [];
  350. for (let i in this.itemList) {
  351. for (let a in this.itemList[i]) {
  352. tableData_r.push(this.itemList[i][a]);
  353. }
  354. }
  355. this.tableData_rule2 = tableData_r; //赋予筛选数据
  356. this.tableData_rule = tableData_r;
  357. this.ruleDialogTableVisible = true;
  358. this.ifPitchOnChild(this.tableData_rule, selecteds);
  359. },
  360. //规则弹窗确定
  361. ruleDialogTableVisibleQD() {
  362. let valuesLengths = [];
  363. for (let i in selecteds) {
  364. valuesLengths.push(selecteds[i]);
  365. }
  366. this.valuesOrLength = valuesLengths;
  367. this.newGroupForm.items = this.valuesOrLength;
  368. if (this.valuesOrLength.length >= 1) {
  369. this.newGroupFormRules = this.valuesOrLength.length + '条规则';
  370. this.ruleHint = '统计已选规则的积分(只选分类不指定规则的积分除外)'
  371. } else {
  372. this.newGroupFormRules = '';
  373. this.ruleHint = '统计所有积分(基础分和工龄分除外)'
  374. }
  375. this.ruleDialogTableVisible = false;
  376. },
  377. //点击某行
  378. clicktable(row, column, cell, event) {
  379. let selectedsif = false;
  380. for (let i in selecteds) {
  381. if (row.id == selecteds[i]) {
  382. selectedsif = true;
  383. selecteds.splice(i, 1);
  384. this.toggleSelection([row], false);
  385. }
  386. }
  387. if (selectedsif == false) {
  388. selecteds.push(row.id);
  389. this.ifPitchOnChild(this.tableData_rule, selecteds);
  390. }
  391. },
  392. //全选
  393. selectAll(selection) {
  394. for (let i in selection) {
  395. selectionID.push(selection[i].id);
  396. }
  397. let tableData_rules = []; //当前分页id
  398. for (let i in this.tableData_rule) {
  399. tableData_rules.push(this.tableData_rule[i].id);
  400. }
  401. selectionID = [...new Set(selectionID)];
  402. if (selection.length == 0) {
  403. //全不选
  404. var diff = [];
  405. var tmp = tableData_rules;
  406. selectionID.forEach(function(val1, i) {
  407. if (tableData_rules.indexOf(val1) < 0) {
  408. diff.push(val1);
  409. } else {
  410. tmp.splice(tmp.indexOf(val1), 1);
  411. }
  412. });
  413. selectionID = diff.concat(tmp);
  414. }
  415. selecteds = [...new Set(selectionID)];
  416. this.valuesOrLength = selecteds;
  417. },
  418. onTableSelect(rows, row) {
  419. let selected = rows.length && rows.indexOf(row) !== -1;
  420. if (selected) {
  421. selecteds.push(row.id);
  422. } else {
  423. for (let i in selecteds) {
  424. if (row.id == selecteds[i]) {
  425. selecteds.splice(i, 1);
  426. }
  427. }
  428. }
  429. },
  430. //关闭
  431. handleClose(done) {
  432. done();
  433. },
  434. // 选择时间-季度
  435. export_quarter_confirm(val) {
  436. this.time.quarter = val;
  437. this.params.page = 1;
  438. console.log("1")
  439. this.open_right(this.clickItem);
  440. },
  441. //此方法:拿到当前点击规则分类的所有子节点ID,(为了包含子分类 规则)
  442. menuIdInit(menus) {
  443. var _this = this;
  444. var _menu = menus;
  445. var menuId = [];
  446. var len = _menu.length;
  447. for (var i = 0; i < len; i++) {
  448. var item = _menu[i];
  449. if (item.child && item.child.length != 0) {
  450. var child = item.child;
  451. for (var j = 0; j < child.length; j++) {
  452. _menu[len + j] = child[j];
  453. }
  454. len = _menu.length;
  455. }
  456. menuId.push(item.id);
  457. }
  458. return menuId;
  459. },
  460. //点击规则分类
  461. handleNodeClick(data) {
  462. let dataArr = this.menuIdInit([data]); //调用方法
  463. this.tableLoadingRule = true;
  464. this.keyword = ''; //切换规则重置搜索框
  465. let tableData_r = [];
  466. for (let i in this.itemList) {
  467. for (let a in this.itemList[i]) {
  468. for (let x in dataArr) {
  469. if (dataArr[x] == this.itemList[i][a].rule_id) {
  470. tableData_r.push(this.itemList[i][a]);
  471. }
  472. }
  473. }
  474. }
  475. this.tableData_rule2 = tableData_r; //赋予筛选数据
  476. this.tableData_rule = tableData_r;
  477. this.ifPitchOnChild(this.tableData_rule, selecteds);
  478. },
  479. ifPitchOnChild(item, indexID) {
  480. let pitchOnChild = [];
  481. for (let i in item) {
  482. for (let a in indexID) {
  483. //判断外层的值相不相等
  484. if (indexID[a] == item[i].id) {
  485. pitchOnChild.push(item[i]);
  486. }
  487. }
  488. }
  489. this.toggleSelection(pitchOnChild, true);
  490. },
  491. //默认选中
  492. toggleSelection(rows, selected) {
  493. if (rows) {
  494. this.$nextTick(() => {
  495. rows.forEach(row => {
  496. this.$refs.multipleTable.toggleRowSelection(row, selected);
  497. });
  498. });
  499. } else {
  500. this.$refs.multipleTable.clearSelection();
  501. }
  502. setTimeout(() => {
  503. //给遮到层,让默认选中的有缓冲时间
  504. this.tableLoadingRule = false;
  505. }, 300);
  506. },
  507. // 提交表单
  508. subGroupForm(formName){
  509. this.$refs[formName].validate((valid) => {
  510. if (valid) {
  511. this.saveFun()
  512. }
  513. });
  514. },
  515. //获取分组详情
  516. getGroupDetail(func){
  517. this.$axios('get','/api/integral/statistics/groups/info', {group_id: this.groups_info.id}).then(res => {
  518. func(res.data.data);
  519. })
  520. },
  521. //编辑
  522. editGroup(){
  523. var that=this;
  524. this.getGroupDetail(function(res){
  525. that.groups_info = res;
  526. // 分组名称
  527. that.newGroupForm.group_name = res.name;
  528. // 规则
  529. that.newGroupForm.items = [];
  530. for (let i in res.items) {
  531. that.newGroupForm.items.push(res.items[i].id);
  532. }
  533. that.valuesOrLength = that.newGroupForm.items;
  534. if (that.valuesOrLength.length >= 1) {
  535. that.newGroupFormRules = that.valuesOrLength.length + '条规则';
  536. that.ruleHint = '统计已选规则的积分(只选分类不指定规则的积分除外)'
  537. } else {
  538. that.newGroupFormRules = '';
  539. that.ruleHint = '统计所有积分(基础分和工龄分除外)'
  540. }
  541. // 统计周期
  542. that.newGroupForm.date_interval = String(res.date_interval);
  543. that.options_time_value = res.date_interval == 1 ? '月度' : res.date_interval == 2 ? '季度' : res.date_interval == 3 ? '年度' : '';
  544. // 分组人员
  545. that.newGroupForm.employees = [];
  546. that.employeeNames ="";
  547. res.employees.forEach(element => {
  548. that.newGroupForm.employees.push(element.id);
  549. that.employeeNames += element.name + ',';
  550. });
  551. that.employees_selected.employee=res.employees;
  552. that.popupType = false;
  553. that.groupShow = true;
  554. })
  555. },
  556. //添加编辑组
  557. saveFun(){
  558. this.saveLoad = true;
  559. var url=this.popupType? '/api/integral/statistics/groups/create':'/api/integral/statistics/groups'
  560. this.newGroupForm.group_id=this.groups_info.id;
  561. // return;
  562. var obj={//为编辑时
  563. name:this.newGroupForm.group_name,
  564. id:this.popupType?'':this.groups_info.id,
  565. employees:this.newGroupForm.employees,
  566. }
  567. this.$axios('post',url,this.newGroupForm).then((res) => {
  568. if (res.data.code == 1) {
  569. this.$message.success(res.data.msg);
  570. if(!this.popupType){//为编辑时
  571. this.groups_info=obj;
  572. }
  573. if(this.groups_list.length==0){
  574. this.get_groups_list(true)
  575. }else{
  576. this.get_groups_list()
  577. }
  578. this.resetForm('newGroupForm');
  579. }else{
  580. this.saveLoad = false
  581. this.$message.error(res.data.msg)
  582. }
  583. }).finally(()=>{
  584. this.saveLoad = false
  585. })
  586. },
  587. // 重置表单
  588. resetForm(formName){
  589. this.$refs[formName].resetFields()
  590. this.newGroupForm.employees = []
  591. this.employee_not_select = []
  592. this.employeeNames='';
  593. this.employees_selected = {employee:[], dept: []}
  594. this.groupShow = false
  595. },
  596. // 新增分组
  597. addGroup(){
  598. this.employee_not_select = []
  599. this.newGroupFormRules='';
  600. this.employees_selected = {employee:[], dept: []}
  601. this.newGroupForm = {
  602. group_name: "",
  603. employees: [],
  604. items:[],
  605. date_interval:"1",
  606. }
  607. this.groupShow = true
  608. this.popupType = true
  609. },
  610. // 删除分组
  611. delItem(){
  612. this.$confirm('确定要删除当前分组吗?, 是否继续?', '删除分组', {
  613. confirmButtonText: '确定',
  614. cancelButtonText: '取消',
  615. type: 'warning'
  616. }).then(() => {
  617. let data = {group_id:this.groups_info.id};
  618. this.delLoad = true
  619. this.$axios('post','/api/integral/statistics/groups/drop',data).then((res) => {
  620. if (res.data.code == 1) {
  621. this.$message.success(res.data.msg)
  622. this.groupShow = false
  623. this.get_groups_list(true);
  624. }else{
  625. this.$message.error(res.data.msg)
  626. }
  627. }).finally(()=>{
  628. this.delLoad = false
  629. })
  630. })
  631. },
  632. // 选人组件提交
  633. move_employee_confirm(data){
  634. this.employeeNames='';
  635. this.newGroupForm.employees=[];
  636. var employee=data.employee;
  637. if(employee.length>0){
  638. employee.forEach(item=>{
  639. this.employeeNames+=item.name+','
  640. this.newGroupForm.employees.push(item.id);
  641. })
  642. }else{
  643. this.newGroupForm.employees=[];
  644. }
  645. this.employees_selected.employee=employee;
  646. this.isEmployeeShow=false;
  647. },
  648. // 递归判断列表,把最后的children设为undefined
  649. getTreeData(data) {
  650. for (var i = 0; i < data.length; i++) {
  651. if (data[i].child.length < 1) {
  652. // children若为空数组,则将children设为undefined
  653. data[i].child = undefined;
  654. } else {
  655. // children若不为空数组,则继续 递归调用 本方法
  656. this.getTreeData(data[i].child);
  657. }
  658. }
  659. return data;
  660. },
  661. //获取规则
  662. getRuleList() {
  663. this.$axios('get','/api/integral/rule/trees', {cycle_type: 1}).then(res => {
  664. this.rule_trees = this.getTreeData(res.data.data.rule_tree || []);
  665. this.itemList = res.data.data.item_list; //规则
  666. })
  667. },
  668. // 规则分类改变之后请求数据
  669. rule_null(val){
  670. this.params.rule_id=val.length == 0? '': val[val.length -1]
  671. this.$nextTick(()=>{
  672. this.page = 1
  673. this.open_right()
  674. })
  675. },
  676. //获取初始化数据
  677. get_groups_list(isAdd) {
  678. this.groups_loading = true;
  679. this.$axios('get','/api/integral/statistics/groups').then(res => {
  680. if (res.data.code == 1) {
  681. let lists = res.data.data.list;
  682. if(this.$authoritys('employee')){//员工权限只能查看包含自己的
  683. let user = this.$getUserData().id
  684. let data = []
  685. lists.forEach(item=>{
  686. if(item.employees.length == 0){
  687. data.push(item)
  688. }else{
  689. if(item.employees.indexOf(user.toString())!=-1){
  690. data.push(item)
  691. }
  692. }
  693. })
  694. this.groups_list = data;
  695. }else{
  696. this.groups_list = lists;
  697. }
  698. if(this.groups_list[0]){
  699. isAdd? this.open_right(this.groups_list[0]):this.open_right();
  700. }else{
  701. this.table_list=[];
  702. }
  703. }
  704. }).finally(() => {
  705. this.groups_loading = false;
  706. });
  707. },
  708. // 打开右边列表
  709. open_right(item){
  710. console.log(item)
  711. this.table_loading = true;
  712. this.clickItem = item;
  713. if (!item) {
  714. this.table_loading = false;
  715. return false;
  716. }
  717. let data = JSON.parse(JSON.stringify(this.params));
  718. data.rule ? '' : delete data.rule;
  719. data.group_id = item.id;
  720. let months;
  721. if (this.newGroupForm.date_interval == '1') {
  722. months = this.time.month.replace('-', '');
  723. }
  724. data.date =
  725. this.newGroupForm.date_interval == '1' ? months : this.newGroupForm.date_interval == '2' ? this.time.quarter : this.newGroupForm.date_interval == '3' ? this.time.year : '';
  726. // var data={};
  727. // if(item){
  728. // this.groups_info=item;
  729. // data={
  730. // group_id: item.id,
  731. // month: this.params.month,
  732. // sort: this.params.sort,
  733. // rule_id: this.params.rule_id,
  734. // pt_id: 3,
  735. // }
  736. // }else{
  737. // data={
  738. // group_id: this.groups_info.id,
  739. // month: this.params.month,
  740. // sort: this.params.sort,
  741. // rule_id: this.params.rule_id,
  742. // pt_id: 3,
  743. // }
  744. // }
  745. // this.$axios('get','/api/integral/statistics/groups/rank',data).then((res) => {
  746. // if (res.data.code == 1) {
  747. // this.table_list = res.data.data.list
  748. // this.total = res.data.data.total
  749. // }else{
  750. // this.$message.error(res.data.data.msg)
  751. // }
  752. // }).finally(() => {
  753. // this.table_loading = false
  754. // })
  755. this.$axios('get','/api/integral/statistics/groups/rank',data).then(res => {
  756. if (res.data.code == 1) {
  757. this.table_list = res.data.data.list;
  758. this.total = res.data.data.total;
  759. // this.lastUpdateTime = res.data.data.update_time;
  760. } else {
  761. this.$message.error(res.data.data.msg)
  762. }
  763. }).finally(() => {
  764. this.table_loading = false;
  765. });
  766. // this.$axios('get','/api/integral/statistics/ranking',data,'v2').then((res) => {
  767. // if (res.data.code == 1) {
  768. // this.table_list = res.data.data.list
  769. // this.total = res.data.data.total
  770. // }else{
  771. // this.$message.error(res.data.data.msg)
  772. // }
  773. // }).finally(() => {
  774. // this.table_loading = false
  775. // })
  776. },
  777. // 页码变更
  778. handleCurrentChange(val) {
  779. this.params.page = val
  780. this.open_right(this.groups_info)
  781. },
  782. handleSizeChange(val){
  783. this.params.page_size = val
  784. this.open_right(this.groups_info)
  785. },
  786. }
  787. };
  788. </script>
  789. <style scoped lang="scss">
  790. .architecture {
  791. display: flex;
  792. text-align: center;
  793. padding-left: 0px;
  794. background-color: #fff;
  795. width: 100%;
  796. overflow: hidden;
  797. cursor: default;
  798. min-height: calc(60vh - 160px);
  799. }
  800. .architecture .RuleLine {
  801. display: table-cell;
  802. width: 1px;
  803. min-height: 600px;
  804. background: hsl(0, 2%, 76%);
  805. }
  806. .architecture .RuleLeft {
  807. display: block;
  808. text-align: center;
  809. padding: 20px 10px;
  810. border-right: none;
  811. overflow-y: auto;
  812. overflow-x: none;
  813. }
  814. /*滚动条的宽度*/
  815. .architecture .RuleLeft::-webkit-scrollbar {
  816. width: 9px;
  817. height: 9px;
  818. }
  819. .architecture .RuleRight::-webkit-scrollbar {
  820. width: 9px;
  821. height: 9px;
  822. }
  823. /*外层轨道。可以用display:none让其不显示,也可以添加背景图片,颜色改变显示效果*/
  824. .architecture .RuleLeft::-webkit-scrollbar-track {
  825. width: 6px;
  826. background-color: #fff0;
  827. -webkit-border-radius: 2em;
  828. -moz-border-radius: 2em;
  829. border-radius: 2em;
  830. }
  831. .architecture .RuleRight::-webkit-scrollbar-track {
  832. width: 6px;
  833. background-color: #fff0;
  834. -webkit-border-radius: 2em;
  835. -moz-border-radius: 2em;
  836. border-radius: 2em;
  837. }
  838. /*滚动条的设置*/
  839. .architecture .RuleLeft::-webkit-scrollbar-thumb {
  840. background-color: #fff0;
  841. background-clip: padding-box;
  842. min-height: 28px;
  843. -webkit-border-radius: 2em;
  844. -moz-border-radius: 2em;
  845. border-radius: 2em;
  846. }
  847. .architecture .RuleRight::-webkit-scrollbar-thumb {
  848. background-color: #fff0;
  849. background-clip: padding-box;
  850. min-height: 28px;
  851. -webkit-border-radius: 2em;
  852. -moz-border-radius: 2em;
  853. border-radius: 2em;
  854. }
  855. /*滚动条移上去的背景*/
  856. .architecture .RuleLeft:hover::-webkit-scrollbar-thumb {
  857. overflow-x: none;
  858. background-color: rgba(144, 147, 153, 0.3);
  859. }
  860. .architecture .RuleRight:hover::-webkit-scrollbar-thumb {
  861. background-color: rgba(115, 118, 124, 0.3);
  862. }
  863. .architecture .RuleLeft .company_name {
  864. position: relative;
  865. display: block;
  866. font-family: 'Microsoft YaHei';
  867. text-align: left;
  868. padding: 15px 28px 17px;
  869. cursor: pointer;
  870. overflow: hidden;
  871. white-space: nowrap;
  872. text-overflow: ellipsis;
  873. border-bottom: 1px #f8f8f8 solid;
  874. }
  875. .architecture .RuleLeft .company_name img {
  876. position: relative;
  877. display: inline-block;
  878. top: 2px;
  879. width: 18px;
  880. height: 18px;
  881. margin-right: 4px;
  882. }
  883. .architecture .RuleLeft ::v-deep .el-button {
  884. margin-bottom: 16px !important;
  885. }
  886. .architecture .RuleRight {
  887. position: relative;
  888. display: table-cell;
  889. text-align: left;
  890. padding: 20px;
  891. }
  892. .architecture .RuleRight .title span .sapn {
  893. display: inline-block;
  894. vertical-align: middle;
  895. max-width: 600px;
  896. overflow: hidden;
  897. white-space: nowrap;
  898. text-overflow: ellipsis;
  899. }
  900. .architecture .RuleRight:after {
  901. content: ' ';
  902. position: absolute;
  903. top: 0;
  904. left: 0;
  905. bottom: 0;
  906. width: 1px;
  907. background: #ebeef5;
  908. }
  909. .architecture .RuleRight .list_box {
  910. width: 100%;
  911. background: #fff;
  912. }
  913. .architecture .RuleRight .list_box ::v-deep table {
  914. font-family: 'Microsoft YaHei';
  915. width: 100% !important;
  916. }
  917. ::v-deep .el-radio .el-radio__label {
  918. display: none;
  919. }
  920. .tips {
  921. background: #dcdfe6;
  922. border-radius: 50%;
  923. width: 14px;
  924. height: 14px;
  925. color: #fff;
  926. display: inline-block;
  927. font-size: 12px;
  928. line-height: 14px;
  929. text-align: center;
  930. }
  931. .groupsName {
  932. font-size: 18px;
  933. margin-right:20px
  934. }
  935. .groupsName span{
  936. margin-left:5px
  937. }
  938. .user_text {
  939. font-size: 12px;
  940. }
  941. .cursor_pointer {
  942. cursor: pointer;
  943. }
  944. .terr-left button{
  945. margin: 0 auto;
  946. display: block;
  947. margin-bottom: 20px;
  948. }
  949. ::v-deep .el-menu-item{
  950. padding:0 10px !important;
  951. }
  952. .rule_class_box {
  953. ::v-deep .el-tree-node {
  954. border-bottom: 1px #f8f8f8 solid;
  955. }
  956. ::v-deep .el-tree-node__content {
  957. padding: 10px 0;
  958. // border-bottom: 1px #f8f8f8 solid;
  959. }
  960. ::v-deep .el-tree-node__content:hover {
  961. background: #ecf5ff;
  962. border-radius: 4px;
  963. }
  964. ::v-deep .is-current .el-tree-node__content .el-icon-caret-right {
  965. color: #409eff !important;
  966. }
  967. ::v-deep .is-current .el-tree-node__content .el-tree-node__label {
  968. color: #409eff !important;
  969. }
  970. ::v-deep .is-current .el-tree-node__children .el-icon-caret-right {
  971. color: #c0c4cc !important;
  972. }
  973. ::v-deep .is-current .el-tree-node__children .el-tree-node__label {
  974. color: #606266 !important;
  975. }
  976. ::v-deep .el-tree-node__label {
  977. overflow: hidden;
  978. text-overflow: ellipsis;
  979. white-space: nowrap;
  980. }
  981. }
  982. </style>