index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <HcCard>
  3. <template #header>
  4. <div class="w-36 ml-2">
  5. <el-select v-model="searchForm.userId" block clearable filterable placeholder="员工姓名" size="large">
  6. <el-option v-for="item in userList" :label="item.name" :value="item.id" />
  7. </el-select>
  8. </div>
  9. <div class="ml-4">
  10. <el-button type="primary" @click="searchClick" size="large">
  11. <HcIcon name="search-2"/>
  12. <span>搜索</span>
  13. </el-button>
  14. </div>
  15. <div class="ml-2">
  16. <el-button size="large" @click="resetClick">
  17. <HcIcon name="close-circle"/>
  18. <span>重置</span>
  19. </el-button>
  20. </div>
  21. </template>
  22. <HcTable :loading="tableLoading" :column="tableColumn" :datas="tableData">
  23. <template #conFileUrl="{row}">
  24. <span class="text-blue text-hover" @click="rowViewPdf(row.conFileUrl)">
  25. {{getFileName(row.conFileUrl)}}
  26. </span>
  27. </template>
  28. <template #carAimgUrl="{row}">
  29. <span class="text-blue text-hover" @click="rowViewImg(row.carAimgUrl)">
  30. {{getFileName(row.carAimgUrl)}}
  31. </span>
  32. </template>
  33. <template #carBimgUrl="{row}">
  34. <span class="text-blue text-hover" @click="rowViewImg(row.carBimgUrl)">
  35. {{getFileName(row.carBimgUrl)}}
  36. </span>
  37. </template>
  38. <template #userImgUrl="{row}">
  39. <span class="text-blue text-hover" @click="rowViewImg(row.userImgUrl)">
  40. {{getFileName(row.userImgUrl)}}
  41. </span>
  42. </template>
  43. <template #action="{row, index}">
  44. <el-button type="primary" size="small" @click="editRowClick(row)">编辑</el-button>
  45. <el-button type="danger" size="small" @click="delRowClick(row)">删除</el-button>
  46. </template>
  47. </HcTable>
  48. <template #action>
  49. <HcPages :pages="searchForm" @change="pageChange"/>
  50. </template>
  51. <!--预览图片-->
  52. <el-image-viewer v-if="showViewer" :initial-index="initialIndex" :url-list="previewFileList" @close="showViewerClose"/>
  53. </HcCard>
  54. </template>
  55. <script setup>
  56. import {onActivated, ref} from 'vue'
  57. import mainApi from "~api/people/archive";
  58. import {useRouter} from 'vue-router'
  59. import {getuserList} from "~api/other";
  60. import {getArrValue} from "js-fast-way";
  61. import {delMessage, getFileName} from "~uti/tools";
  62. const router = useRouter()
  63. onActivated(() => {
  64. getuserListApi()
  65. getTableData()
  66. })
  67. //获取用户下拉数据
  68. const userList = ref([])
  69. const getuserListApi = async () => {
  70. const {data} = await getuserList()
  71. userList.value = getArrValue(data)
  72. }
  73. const searchForm = ref({
  74. type: 1, userId: null,
  75. current: 1, size: 20, total: 0
  76. })
  77. //搜索
  78. const searchClick = () => {
  79. searchForm.value.current = 1;
  80. getTableData()
  81. }
  82. //重置搜索表单
  83. const resetClick = () => {
  84. searchForm.value = {current: 1, size: 20, total: 0}
  85. }
  86. //分页被点击
  87. const pageChange = ({current, size}) => {
  88. searchForm.value.current = current
  89. searchForm.value.size = size
  90. getTableData()
  91. }
  92. //表格参数
  93. const tableLoading = ref(false)
  94. const tableColumn = [
  95. {key: 'name', name: '姓名', width: 100},
  96. {key: 'email', name: '邮箱', width: 160},
  97. {key: 'deptName', name: '部门', width: 120},
  98. {key: 'leaderName', name: '直属主管', width: 100},
  99. {key: 'postName', name: '职位', width: 120},
  100. {key: 'phone', name: '手机号', width: 120},
  101. {key: 'entryTime', name: '入职时间', width: 120},
  102. {key: 'cyear', name: '司龄', width: 100},
  103. {key: 'userTypeName', name: '员工类型', width: 120},
  104. {key: 'userStatusName', name: '员工状态', width: 100},
  105. {key: 'periodMoth', name: '试用期(月)', width: 100},
  106. {key: 'idNumber', name: '身份证号码', width: 220},
  107. {key: 'carName', name: '身份证姓名', width: 120},
  108. {key: 'birthday', name: '出生日期', width: 120},
  109. {key: 'userAge', name: '年龄', width: 90},
  110. {key: 'sex', name: '性别', width: 90},
  111. {key: 'nation', name: '民族', width: 90},
  112. {key: 'carAddr', name: '身份证地址', width: 220},
  113. {key: 'marriageStatusName', name: '婚姻状况', width: 100},
  114. {key: 'domicileAddr', name: '户籍', width: 160},
  115. {key: 'politicalName', name: '政治面貌', width: 100},
  116. {key: 'educationName', name: '学历', width: 100},
  117. {key: 'speciality', name: '专业', width: 120},
  118. {key: 'bankNum', name: '银行卡号', width: 200},
  119. {key: 'bankName', name: '开户行', width: 200},
  120. {key: 'conTypeName', name: '合同类型', width: 120},
  121. {key: 'conStartDate', name: '合同开始日期', width: 120},
  122. {key: 'conEndDate', name: '合同结束日期', width: 120},
  123. {key: 'renewalCount', name: '续签次数', width: 100},
  124. {key: 'key13', name: '合同期限', width: 100},
  125. {key: 'conFileUrl', name: '合同附件', width: 120},
  126. {key: 'emergencyName', name: '紧急联系人姓名', width: 130},
  127. {key: 'emergencyPhone', name: '联系人电话', width: 120},
  128. {key: 'emergencyRelation', name: '联系人关系', width: 100},
  129. {key: 'carAimgUrl', name: '身份证(人面像)', width: 120},
  130. {key: 'carBimgUrl', name: '身份证(国徽)', width: 120},
  131. {key: 'userImgUrl', name: '员工照片', width: 120},
  132. {key: 'action', name: '操作', width: 145, align: 'center', fixed: 'right'},
  133. ]
  134. //获取表格数据
  135. const tableData = ref([
  136. {id:1}
  137. ])
  138. const getTableData = async () => {
  139. tableLoading.value = true
  140. const {data} = await mainApi.page(searchForm.value)
  141. tableLoading.value = false
  142. tableData.value = getArrValue(data['records'])
  143. searchForm.value.total = data['total'] || 0
  144. }
  145. //编辑
  146. const editRowClick = (row) => {
  147. router.push({
  148. name: 'people-archive-info',
  149. query: {id: row.id}
  150. })
  151. }
  152. //删除
  153. const delRowClick = (row) => {
  154. delMessage(async () => {
  155. const {error, code, msg} = await mainApi.remove({ids: row.id})
  156. if (!error && code === 200) {
  157. window.$message?.success(msg)
  158. getTableData().then()
  159. } else {
  160. window.$message?.error(msg)
  161. }
  162. })
  163. }
  164. //预览Pdf
  165. const rowViewPdf = (url) => {
  166. if (url) {
  167. window.open(url, '_blank')
  168. } else {
  169. window.$message?.error('文件不存在')
  170. }
  171. }
  172. //预览图片
  173. const showViewer = ref(false)
  174. const initialIndex = ref(0)
  175. const previewFileList = ref([])
  176. const rowViewImg = (url) => {
  177. if (url) {
  178. previewFileList.value = [url]
  179. showViewer.value = true
  180. } else {
  181. window.$message?.error('文件不存在')
  182. }
  183. }
  184. //关闭预览
  185. const showViewerClose = () => {
  186. showViewer.value = false
  187. }
  188. </script>