framework.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <div class="all-box">
  3. <!-- 头部提示 -->
  4. <div class="diy-tip" style="margin-bottom: 10px;">
  5. <div>
  6. 当前组织架构成员通过钉钉通讯录同步,员工开启积分管理后才能正式启用并进入“功道云积分制”,如果您的钉钉通讯录有变动,点击
  7. <span class="blue" style="margin-left: 10px;cursor: pointer;" @click="tb()" v-loading="tbLoading">
  8. <i class="el-icon-refresh"></i>
  9. 立即同步
  10. </span>
  11. </div>
  12. </div>
  13. <div class="all">
  14. <div class="flex-box">
  15. <div class="terr-left">
  16. <div class="rule_class_box">
  17. <div class="company_name">
  18. <img src="@/assets/image/two.png" />
  19. <span>组织架构</span>
  20. <!-- <span :class="[dept_id==0? 'blue':'']">{{ info.name }}</span> -->
  21. </div>
  22. <!-- <div @click="handleNodeClick({ id: 0 })" class="company_name">
  23. <img src="../assets/image/two.png" />
  24. <span :class="[dept_id==0? 'blue':'']">{{ info.name }}</span>
  25. </div> -->
  26. <el-tree
  27. :data="bmList"
  28. class="cate-tree"
  29. :highlight-current="true"
  30. :props="{ children: '_child', label: 'name' }"
  31. @node-click="handleNodeClick"
  32. :accordion="true"
  33. empty-text="您暂无部门数据,请同步钉钉通讯录"
  34. >
  35. <div
  36. content="tree"
  37. v-show="treedata.length != 0"
  38. class="flex-box flex-v-ce"
  39. slot-scope="{ node, data }"
  40. style="font-size: 14px;color: #606266; width:100%; text-align: left;"
  41. >
  42. <img src="@/assets/image/one.png" style="width: 20px;margin-right: 5px;" />
  43. <span class="name">{{ data.name }}</span>
  44. </div>
  45. </el-tree>
  46. </div>
  47. </div>
  48. <div class="terr-right border-right flex-1">
  49. <div class="margin-bottom">
  50. <el-button @click="participation()" :loading="enable_loading" size="medium" type="primary" style="margin-right: 10px;">批量启动积分管理</el-button>
  51. <el-input placeholder="输入同事姓名" size="medium" style="width: 230px;" v-model="keywords" clearable @input="searchUser()">
  52. <!-- <el-button slot="append" icon="el-icon-search" @click="getEmployee()"></el-button> -->
  53. </el-input>
  54. </div>
  55. <el-table :data="userList" @selection-change="handleSelectionChange" v-loading="tableToading">
  56. <el-table-column type="selection" width="50"></el-table-column>
  57. <el-table-column label="姓名">
  58. <template slot-scope="scope">
  59. <div class="flex-box flex-v-ce">
  60. <userImage :user_name="scope.row.name" :img_url="scope.row.img_url" width="44px" height="44px"></userImage>
  61. <div style="margin-left: 10px;">{{ scope.row.name }}</div>
  62. </div>
  63. </template>
  64. </el-table-column>
  65. <el-table-column label="部门">
  66. <template slot-scope="scope">
  67. <div class="flex-box flex-v-ce bms">
  68. <div v-for="(item, index) in scope.row.employee_detail.dept_list" :key="index">{{ item.dept_name }}</div>
  69. </div>
  70. </template>
  71. </el-table-column>
  72. <el-table-column prop="accedence_time" label="入职时间"></el-table-column>
  73. <el-table-column label="启用积分管理">
  74. <template slot="header" slot-scope="scope">
  75. <el-popover
  76. placement="top-start"
  77. width="300"
  78. trigger="manual"
  79. v-model="visible">
  80. <div class="el-popover2">
  81. <div class="title">提示 <i class="el-icon-info" style="margin-left: 5px;"></i></div>
  82. <div style="margin-bottom: 10px;">在这里启用积分管理,即可进入系统</div>
  83. <div class="flex-box">
  84. <div class="flex-1"></div>
  85. <el-button size="small" @click="visible_close()">我知道了</el-button>
  86. </div>
  87. </div>
  88. <div slot="reference" class="popover" @click="visible=!visible">启用积分管理</div>
  89. </el-popover>
  90. </template>
  91. <template slot-scope="scope">
  92. <div :class="[scope.row.is_official==1? 'switch-box':'']" @click="changeIs(scope.row.is_official, scope.row.id)">
  93. <div class="switch"></div>
  94. </div>
  95. <!-- <el-switch @change="changeIs($event, scope.row.id)" v-model="scope.row.is_official" :active-value="is" :inactive-value="no"></el-switch> -->
  96. </template>
  97. </el-table-column>
  98. <template slot="empty">
  99. <noData></noData>
  100. </template>
  101. </el-table>
  102. <div class="pagination">
  103. <el-pagination
  104. @size-change="handleSizeChange"
  105. @current-change="handleCurrentChange"
  106. :current-page="page"
  107. :page-sizes="[10, 20, 30, 40, 50, 100]"
  108. :page-size="perPage"
  109. layout="total,sizes, prev, pager, next"
  110. :total="total"
  111. ></el-pagination>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. </template>
  118. <script>
  119. import noData from '@/components/noData';
  120. export default {
  121. data() {
  122. return {
  123. is: 1,
  124. no: 0,
  125. page: 1,
  126. perPage: 10,
  127. total: 0,
  128. info: {}, //公司信息
  129. tips_show: true,
  130. bmList: [],
  131. userList: [],
  132. class_type: '',
  133. treedata: [1],
  134. tableData: [],
  135. keywords: '',
  136. dept_id: 0,
  137. tableToading: false,
  138. tbLoading: false,
  139. selectIds: [],
  140. enable_loading:false,
  141. visible:false
  142. };
  143. },
  144. components: {
  145. noData
  146. },
  147. watch: {
  148. dept_id(val) {
  149. this.getEmployee();
  150. }
  151. },
  152. created() {
  153. this.getInfo();
  154. // this.getDepartment();
  155. this.getEmployee();
  156. },
  157. mounted() {
  158. this.$nextTick(function() {
  159. if (localStorage.getItem('rule')) {
  160. this.tips_show = false;
  161. } else {
  162. this.tips_show = true;
  163. }
  164. });
  165. },
  166. methods: {
  167. //同步信息
  168. tb() {
  169. this.$confirm('下次同步时间需在10分钟之后,是否同步?', '提示', {
  170. confirmButtonText: '确定',
  171. cancelButtonText: '取消',
  172. type: 'warning'
  173. }).then(() => {
  174. this.tbLoading = true;
  175. this.$axios('post','/api/ding/department_sync').then(res => {
  176. this.$message.success({ message: '同步成功' });
  177. this.dept_id=0;
  178. this.getInfo();
  179. this.getEmployee();
  180. }).finally(()=>{
  181. this.tbLoading = false;
  182. });
  183. });
  184. },
  185. //搜索
  186. searchUser(){
  187. this.page = 1;
  188. this.getEmployee();
  189. },
  190. //是否开通
  191. changeIs(e, id) {
  192. var url = e == 1 ? '/api/employee/disable' : '/api/employee/enable';
  193. this.$axios('post',url, { employee_id: [id] }).then(res => {
  194. if (res) {
  195. if(e==0){
  196. this.$message.success({ message: '开启成功,可在"角色权限设置对应管理范围"' });
  197. }else{
  198. this.$message.success({ message: res.data.msg });
  199. }
  200. this.getEmployee();
  201. }
  202. });
  203. },
  204. //批量开通权限
  205. participation() {
  206. if(this.selectIds.length==0){
  207. this.$message.error({ message: '请选择参与的人员!' });
  208. return
  209. }
  210. this.enable_loading=true;
  211. this.$axios('post','/api/employee/enable', { employee_id: this.selectIds }).then(res => {
  212. if (res) {
  213. this.$message.success({ message: '开启成功,可在"角色权限设置对应管理范围"' });
  214. this.getEmployee();
  215. }
  216. }).finally(err=>{
  217. this.enable_loading=false;
  218. });
  219. },
  220. //获取公司信息
  221. getInfo(is) {
  222. // api/test?employee_id=155
  223. this.$axios('get','/api/site/info').then(res => {
  224. this.info = res.data.data;
  225. this.getDepartment(is);
  226. });
  227. },
  228. //选择员工
  229. handleSelectionChange(e) {
  230. var arr = [];
  231. for (var item in e) {
  232. arr.push(e[item].id);
  233. }
  234. this.selectIds = arr;
  235. },
  236. //点击部门
  237. handleNodeClick(e) {
  238. this.page = 1;
  239. this.dept_id = e.id;
  240. },
  241. //获取部门
  242. getDepartment() {
  243. this.$axios('get','/api/department/tree').then(res => {
  244. var list=[{
  245. id:0,
  246. name:this.info.name,
  247. _child:res.data.data.list
  248. }]
  249. this.bmList = list;
  250. });
  251. },
  252. //获取员工
  253. getEmployee() {
  254. this.tableToading = true;
  255. this.$axios('get','/api/employee/index', {dept_id: this.dept_id, keywords: this.keywords, page: this.page, page_size: this.perPage }).then(res => {
  256. this.total = res.data.data.pageInfo.count;
  257. this.userList = res.data.data.list;
  258. var visible=localStorage.getItem('visible');
  259. if(!visible){
  260. this.visible=true;
  261. }
  262. }).finally(err=>{
  263. this.tableToading=false;
  264. });
  265. },
  266. visible_close(){
  267. localStorage.setItem('visible', 'true');
  268. this.visible = false;
  269. },
  270. //关闭提示
  271. tips_close() {
  272. localStorage.setItem('rule', 'true');
  273. this.tips_show = false;
  274. },
  275. handleSizeChange: function(val) {
  276. this.perPage = val;
  277. this.page = 1;
  278. this.getEmployee();
  279. },
  280. //页码变更
  281. handleCurrentChange: function(val) {
  282. this.page = val;
  283. this.getEmployee();
  284. }
  285. }
  286. };
  287. </script>
  288. <style lang="scss" scoped="scoped">
  289. .title{
  290. font-size: 16px;
  291. color: #909399;
  292. margin-bottom: 10px;
  293. }
  294. .popover{
  295. border: none;
  296. // color: #909399;
  297. font-weight: 600;
  298. cursor: pointer;
  299. }
  300. .popover:hover{
  301. background-color: #fff;
  302. border-color: #fff;
  303. }
  304. .switch{
  305. margin: 0;
  306. display: inline-block;
  307. position: relative;
  308. width: 40px;
  309. height: 20px;
  310. border: 1px solid #dcdfe6;
  311. outline: none;
  312. border-radius: 10px;
  313. box-sizing: border-box;
  314. background: #dcdfe6;
  315. cursor: pointer;
  316. transition: border-color .3s,background-color .3s;
  317. vertical-align: middle;
  318. }
  319. .switch:after {
  320. content: "";
  321. position: absolute;
  322. top: 1px;
  323. left: 1px;
  324. border-radius: 100%;
  325. transition: all .3s;
  326. width: 16px;
  327. height: 16px;
  328. background-color: #fff;
  329. }
  330. .switch-box .switch {
  331. border-color: #409eff;
  332. background-color: #409eff;
  333. }
  334. .switch-box .switch:after {
  335. left: 100%;
  336. margin-left: -17px;
  337. }
  338. .name {
  339. overflow: hidden;
  340. text-overflow: ellipsis;
  341. white-space: nowrap;
  342. width: 80%;
  343. }
  344. .bms div {
  345. margin-right: 10px;
  346. }
  347. .top-msg div:nth-child(1) {
  348. margin-bottom: 10px;
  349. }
  350. .company_name {
  351. position: relative;
  352. display: block;
  353. font-family: 'Microsoft YaHei';
  354. text-align: left;
  355. padding: 15px 25px;
  356. cursor: pointer;
  357. overflow: hidden;
  358. white-space: nowrap;
  359. text-overflow: ellipsis;
  360. border-bottom: 1px #f8f8f8 solid;
  361. }
  362. .company_name img {
  363. position: relative;
  364. display: inline-block;
  365. top: 2px;
  366. width: 18px;
  367. height: 18px;
  368. margin-right: 4px;
  369. }
  370. .terr-right {
  371. .custom-tree-node {
  372. margin-left: -4px;
  373. }
  374. .custom-tree-node * {
  375. vertical-align: middle;
  376. }
  377. .custom-tree-node:hover {
  378. .treeIcon {
  379. display: inline-block;
  380. width: 55%;
  381. }
  382. }
  383. }
  384. .el-popover2{
  385. // background-color: #409eff !important;
  386. color: #409eff;
  387. }
  388. .rule_class_box {
  389. ::v-deep .el-tree-node {
  390. border-bottom: 1px #f8f8f8 solid;
  391. }
  392. ::v-deep .el-tree-node__content {
  393. padding: 10px 0;
  394. // border-bottom: 1px #f8f8f8 solid;
  395. }
  396. ::v-deep .el-tree-node__content:hover {
  397. background: #ecf5ff;
  398. border-radius: 4px;
  399. }
  400. ::v-deep .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content .name{
  401. color: #409eff !important;
  402. font-weight: normal;
  403. transition: 0.35s ease-in-out;
  404. }
  405. // ::v-deep .is-current .el-tree-node__content .el-icon-caret-right {
  406. // color: #409eff !important;
  407. // }
  408. // ::v-deep .is-current .el-tree-node__content .el-tree-node__label {
  409. // color: #409eff !important;
  410. // }
  411. // ::v-deep .is-current .el-tree-node__children .el-icon-caret-right {
  412. // color: #c0c4cc !important;
  413. // }
  414. // ::v-deep .is-current .el-tree-node__children .el-tree-node__label {
  415. // color: #606266 !important;
  416. // }
  417. // ::v-deep .is-current .name {
  418. // color: #409eff !important;
  419. // font-weight: normal;
  420. // transition: 0.35s ease-in-out;
  421. // }
  422. }
  423. </style>