index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <div>
  3. <div class="communal-list">
  4. <div class="communal-title">
  5. <div>员工列表</div>
  6. <div class="communal-box">
  7. <el-input @input="Inquireclick()" placeholder="请输入内容" v-model="input" clearable>
  8. </el-input>
  9. <el-button @click="Inquireclick()" type="primary"><i class="iconfont icon-sousuo"></i></el-button>
  10. </div>
  11. </div>
  12. <template>
  13. <el-table :data="tableDatas.slice((currentPage - 1) * pageSize, currentPage * pageSize)" border
  14. style="width: 100%" :row-class-name="rowClassName">
  15. <!-- <el-table-column type="expand">
  16. <template slot-scope="props">
  17. <el-form label-position="left" inline class="demo-table-expand">
  18. <el-form-item label="分机号">
  19. <span>{{ props.row.ext }}</span>
  20. </el-form-item>
  21. <el-form-item label="手机号">
  22. <span>{{ props.row.phone }}</span>
  23. </el-form-item>
  24. <el-form-item label="紧急联络电话">
  25. <span>{{ props.row.urgentPhone }}</span>
  26. </el-form-item>
  27. <el-form-item label="电子邮箱">
  28. <span>{{ props.row.email }}</span>
  29. </el-form-item>
  30. </el-form>
  31. </template>
  32. </el-table-column> -->
  33. <el-table-column prop="num" label="序 号" width="55">
  34. <template slot-scope="scope">
  35. {{ (currentPage - 1) * pageSize + scope.$index + 1 }}
  36. </template>
  37. </el-table-column>
  38. <el-table-column prop="number" width="100" label="员工号">
  39. </el-table-column>
  40. <el-table-column width="100" prop="cnName" label="姓 名">
  41. </el-table-column>
  42. <el-table-column prop="companyName" label="分属公司" width="220">
  43. </el-table-column>
  44. <el-table-column prop="jobName" label="职 位" width="200">
  45. </el-table-column>
  46. <el-table-column prop="ext" label="分机号" width="100">
  47. </el-table-column>
  48. <el-table-column prop="phone" label="手机号" width="120">
  49. </el-table-column>
  50. <el-table-column prop="urgentPhone" label="紧急联络电话" width="120">
  51. </el-table-column>
  52. <el-table-column prop="email" label="电子邮箱">
  53. </el-table-column>
  54. </el-table>
  55. </template>
  56. <div class="block">
  57. <el-pagination align='center' @size-change="handleSizeChange" @current-change="handleCurrentChange"
  58. :current-page="currentPage" :page-sizes="[10, 15, 20]" :page-size="pageSize"
  59. layout="total, sizes, prev, pager, next" :total="tableDatas.length">
  60. </el-pagination>
  61. </div>
  62. </div>
  63. </div>
  64. </template>
  65. <script>
  66. import { co, el } from '@fullcalendar/core/internal-common';
  67. export default {
  68. data() {
  69. return {
  70. tableDatas: [],
  71. tableData: [],
  72. currentPage: 1, // 当前页码
  73. pageSize: 15,// 每页的数据条数
  74. input: '',
  75. token: '',
  76. clientWidth:document.documentElement.clientWidth,
  77. }
  78. },
  79. methods: {
  80. //每页条数改变时触发 选择一页显示多少行
  81. handleSizeChange(val) {
  82. this.currentPage = 1;
  83. this.pageSize = val;
  84. },
  85. //当前页改变时触发 跳转其他页
  86. handleCurrentChange(val) {
  87. this.currentPage = val;
  88. },
  89. Inquireclick() {
  90. var newarr = [];
  91. if (this.input == "") {
  92. newarr = this.tableData;
  93. } else {
  94. for (var i = 0; i < this.tableData.length; i++) {
  95. if (this.tableData[i].number.indexOf(this.input) != -1) {
  96. newarr.push(this.tableData[i]);
  97. }
  98. else if (this.tableData[i].cnName.indexOf(this.input) != -1) {
  99. newarr.push(this.tableData[i]);
  100. }
  101. else if (this.tableData[i].jobName.indexOf(this.input) != -1) {
  102. newarr.push(this.tableData[i]);
  103. }
  104. else if (this.tableData[i].companyName.indexOf(this.input) != -1) {
  105. newarr.push(this.tableData[i]);
  106. }
  107. else if (this.tableData[i].ext.indexOf(this.input) != -1) {
  108. newarr.push(this.tableData[i]);
  109. }
  110. else if (this.tableData[i].phone.indexOf(this.input) != -1) {
  111. newarr.push(this.tableData[i]);
  112. }
  113. else if (this.tableData[i].urgentPhone.indexOf(this.input) != -1) {
  114. newarr.push(this.tableData[i]);
  115. }
  116. else if (this.tableData[i].email.indexOf(this.input) != -1) {
  117. newarr.push(this.tableData[i]);
  118. }
  119. }
  120. }
  121. this.tableDatas = newarr;
  122. this.currentPage = 1;
  123. },
  124. Getemployees() {
  125. var url = "/api/System/GetUserList"
  126. var that = this
  127. this.$axios({
  128. method: 'post',
  129. url: url,
  130. headers: {
  131. Authorization: 'Bearer ' + this.token
  132. },
  133. data: {
  134. portType: 1,
  135. }
  136. }).then(function (res) {
  137. if (res.data.code == 200) {
  138. that.tableData = res.data.data
  139. that.tableData.forEach(item => {
  140. if (item.cnName == null) {
  141. item.cnName = ''
  142. }
  143. if (item.companyId == null) {
  144. item.companyId = ''
  145. }
  146. if (item.companyName == null) {
  147. item.companyName = ''
  148. }
  149. if (item.depId == null) {
  150. item.depId = ''
  151. }
  152. if (item.depName == null) {
  153. item.depName = ''
  154. }
  155. if (item.email == null) {
  156. item.email = ''
  157. }
  158. if (item.ext == null) {
  159. item.ext = ''
  160. }
  161. if (item.id == null) {
  162. item.id = ''
  163. }
  164. if (item.jobName == null) {
  165. item.jobName = ''
  166. }
  167. if (item.jobPostId == null) {
  168. item.jobPostId = ''
  169. }
  170. if (item.number == null) {
  171. item.number = ''
  172. }
  173. if (item.phone == null) {
  174. item.phone = ''
  175. }
  176. if (item.urgentPhone == null) {
  177. item.urgentPhone = ''
  178. }
  179. })
  180. that.tableDatas = that.tableData;
  181. }
  182. })
  183. },
  184. rowClassName({ row, rowIndex }) {
  185. if (rowIndex % 2 === 0) {
  186. return 'warning-row';
  187. } else {
  188. return 'success-row';
  189. }
  190. },
  191. },
  192. // watch: {
  193. // clientWidth(news,olds) {
  194. // let that = this;
  195. // console.log("实时屏幕宽度:",news,olds, that.clientWidth );
  196. // }
  197. // },
  198. mounted() {
  199. this.token = JSON.parse(localStorage.getItem('userinif')).token;
  200. this.Getemployees();
  201. // this.clientWidth = document.body.clientWidth;
  202. // this.clientWidth = document.documentElement.clientWidth;
  203. // console.log(this.clientWidth);
  204. }
  205. }
  206. </script>
  207. <style>
  208. .el-table .warning-row {
  209. background: #f9f9f9;
  210. }
  211. .el-table .success-row {
  212. background: #efefef;
  213. }
  214. .communal-list {
  215. background-color: #fff;
  216. padding: 10px;
  217. box-shadow: 0 0 5px #0005;
  218. border-radius: 10px;
  219. }
  220. .communal-title {
  221. display: flex;
  222. font-size: 17px;
  223. font-weight: 600;
  224. color: #555;
  225. margin-top: 8px;
  226. margin-bottom: 2px;
  227. justify-content: space-between;
  228. align-items: center;
  229. }
  230. .communal-box {
  231. display: flex;
  232. }
  233. .communal-box>button {
  234. margin-left: 10px;
  235. padding: 8px 20px;
  236. }
  237. </style>