framework.vue 9.7 KB

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