list.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <div class="app-container">
  3. <div class="title-container">
  4. <breadcrumb id="breadcrumb-container" class="breadcrumb-container"/>
  5. </div>
  6. <y-page-list-layout :page-list="pageData" :page-para="listQuery" :get-page-list="getList">
  7. <template slot="left">
  8. <PermissionButton
  9. menu-code="_views_user_add"
  10. class-name="filter-item"
  11. type="primary"
  12. name
  13. size="mini"
  14. :page-jump="true"
  15. round
  16. style="float: left"
  17. />
  18. <el-select
  19. v-model="listQuery.sex"
  20. placeholder="性别"
  21. clearable
  22. filterable
  23. style="margin-left: 20px;width: 100px;float: left;"
  24. class="filter-item"
  25. >
  26. <el-option label="男" value="男"/>
  27. <el-option label="女" value="女"/>
  28. </el-select>
  29. <el-input
  30. v-model="listQuery.description"
  31. placeholder="请输入内容"
  32. clearable
  33. style="margin-left: 20px;width: 320px;float: left;"
  34. >
  35. <el-select slot="prepend" v-model="listQueryKey" style="width: 90px;" placeholder="请选择">
  36. <el-option label="全部" value="keyword"/>
  37. <el-option label="工号" value="staffNo"/>
  38. <el-option label="姓名" value="name"/>
  39. </el-select>
  40. </el-input>
  41. <el-select clearable style="margin-left: 10px;width: 200px;float: left;" v-model="listQuery.resignState" placeholder="在职状态">
  42. <el-option label="在职" value="false"></el-option>
  43. <el-option label="离职" value="true"></el-option>
  44. </el-select>
  45. <el-button
  46. class="filter-item"
  47. style="margin-left: 10px;float: left;"
  48. type="primary"
  49. @click="searchList"
  50. round
  51. >搜索
  52. </el-button>
  53. <el-button
  54. class="filter-item"
  55. style="float: left;"
  56. round
  57. type="warning"
  58. @click="resetSearch()"
  59. >重置
  60. </el-button>
  61. </template>
  62. <template slot="right">
  63. <PermissionButton
  64. menu-code="_views_user_template"
  65. class-name="filter-item"
  66. round
  67. icon="el-icon-download"
  68. name="下载模板"
  69. @click="handleDownload"
  70. />
  71. <PermissionButton
  72. menu-code="_views_user_import"
  73. class-name="filter-item"
  74. round
  75. type="text"
  76. name=""
  77. style="padding: 0; margin-bottom: 10px"
  78. >
  79. <excelImport
  80. ref="uploadControl"
  81. flag="user/importExcel"
  82. :style-type="1"
  83. title="导入"
  84. @fath="getList"
  85. />
  86. </PermissionButton>
  87. </template>
  88. <parentTable
  89. v-loading="listLoading"
  90. :data="pageData.records"
  91. slot="table"
  92. style="width: 100%;"
  93. >
  94. <el-table-column label="工号" align="center">
  95. <template slot-scope="{row}">
  96. <span>{{ row.staffNo }}</span>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="姓名" align="center">
  100. <template slot-scope="{row}">
  101. <span>{{ row.name }}</span>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="性别" align="center" width="120">
  105. <template slot-scope="{row}">
  106. <span>{{ row.sex }}</span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="所属部门-岗位" align="center" width="360">
  110. <template slot-scope="{row}">
  111. <span v-for="(item, index) in row.departmentPostVOList" :key="index">
  112. <span v-if="index > 0">、</span>
  113. {{ item.departmentName }}-{{ item.postName }}
  114. </span>
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="在职状态" align="center" width="120">
  118. <template slot-scope="{row}">
  119. <span>{{ row.resignState?'离职':'在职' }}</span>
  120. </template>
  121. </el-table-column>
  122. <el-table-column label="系统状态" align="center" width="120">
  123. <template slot-scope="{row}">
  124. <span>{{ row.enable===true?'启用':'禁用' }}</span>
  125. </template>
  126. </el-table-column>
  127. <el-table-column label="操作" align="center">
  128. <template slot-scope="{row}">
  129. <PermissionButton
  130. menu-code="_views_user_detail"
  131. class-name="filter-item"
  132. name=""
  133. type="primary"
  134. :page-jump="true"
  135. :page-query="{id: row.id}"
  136. round
  137. size="mini"
  138. />
  139. <PermissionButton
  140. menu-code="_views_user_remove"
  141. class-name="filter-item"
  142. name=""
  143. type="danger"
  144. round
  145. size="mini"
  146. @click="deleteInfo(row.id)"
  147. />
  148. </template>
  149. </el-table-column>
  150. </parentTable>
  151. </y-page-list-layout>
  152. </div>
  153. </template>
  154. <script>
  155. import YPageListLayout from '@/components/YPageListLayout'
  156. import Breadcrumb from '@/components/Breadcrumb'
  157. import PermissionButton from '@/components/PermissionButton/PermissionButton'
  158. import { fileDown } from '../../utils/file'
  159. export default {
  160. name: 'ViewsStaffList',
  161. components: {
  162. Breadcrumb,
  163. YPageListLayout,
  164. PermissionButton,
  165. },
  166. filters: {
  167. statusFilter(status) {
  168. const statusMap = {
  169. published: 'success',
  170. draft: 'info',
  171. deleted: 'danger',
  172. }
  173. return statusMap[status]
  174. },
  175. },
  176. data() {
  177. return {
  178. isDisable:false,
  179. tableKey: 0,
  180. pageData: { records: [] },
  181. total: 20,
  182. listLoading: true,
  183. listQuery: {
  184. page: 1,
  185. size: 10,
  186. // name: '',
  187. // staffNo: '',
  188. descs: 'id',
  189. },
  190. listQueryKey: 'keyword',
  191. importLoading: false,
  192. }
  193. },
  194. created() {
  195. const that = this
  196. that.getList()
  197. },
  198. methods: {
  199. handleDownload(url) {
  200. this.$utils.exportUtil('/user/download/importTemplate', {}, '模板下载')
  201. },
  202. resetSearch() {
  203. this.listQuery = {
  204. current: 1,
  205. size: 10,
  206. descs: 'id',
  207. }
  208. this.getList()
  209. },
  210. removeHandle(row) {
  211. // console.log(data)
  212. const that = this
  213. that
  214. .$confirm('确认删除当前记录吗?', '警告', {
  215. confirmButtonText: '确认',
  216. cancelButtonText: '取消',
  217. type: 'warning',
  218. })
  219. .then(async () => {
  220. this.$api.term.delete(row.id).then((res) => {
  221. if (res.code === 200) {
  222. this.$message({
  223. type: 'success',
  224. message: '删除成功',
  225. })
  226. this.getList()
  227. }
  228. })
  229. })
  230. .catch((err) => {
  231. console.error(err)
  232. })
  233. },
  234. searchList() {
  235. // 重置分页
  236. this.listQuery.page = 1
  237. this.listQuery.size = 20
  238. this.getList()
  239. },
  240. getList() {
  241. const that = this
  242. this.listLoading = true
  243. // console.log(that.listQuery)
  244. const key = {}
  245. key[this.listQueryKey] = this.listQuery.description
  246. this.$api.user
  247. .list(Object.assign({}, that.listQuery, key))
  248. .then((res) => {
  249. that.pageData = res.data
  250. setTimeout(() => {
  251. that.listLoading = false
  252. }, 200)
  253. })
  254. .catch(() => {
  255. that.listLoading = false
  256. })
  257. },
  258. deleteInfo(id) {
  259. const that = this
  260. that.$confirm('请确认是否删除该数据?', '提示', {
  261. confirmButtonText: '确定',
  262. cancelButtonText: '取消',
  263. type: 'warning',
  264. center: true
  265. }).then(() => {
  266. that.$api.user.delete(id).then(data => {
  267. that.loading = false
  268. if (data.code === 200) {
  269. that.getList()
  270. } else {
  271. this.$message({
  272. type: 'error',
  273. message: data.msg
  274. })
  275. }
  276. })
  277. }).catch(() => {
  278. })
  279. }
  280. },
  281. }
  282. </script>
  283. <style lang="scss" scoped>
  284. .right {
  285. flex: 1;
  286. .title {
  287. font-size: 16px;
  288. font-weight: 500;
  289. color: rgba(51, 51, 51, 1);
  290. line-height: 35px;
  291. margin-bottom: 8px;
  292. }
  293. .menu-2-box {
  294. display: flex;
  295. flex-wrap: wrap;
  296. width: 100%;
  297. }
  298. .menu-2-item {
  299. display: flex;
  300. align-items: center;
  301. color: #656565;
  302. font-size: 12px;
  303. width: 230px;
  304. height: 101px;
  305. background: rgb(255, 185, 129);
  306. border-radius: 3px;
  307. padding-left: 20px;
  308. margin-right: 10px;
  309. margin-bottom: 10px;
  310. cursor: pointer;
  311. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
  312. .text {
  313. margin-left: 16px;
  314. }
  315. }
  316. }
  317. </style>