renyuanjibenziliao.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <template>
  2. <div>
  3. <el-container>
  4. <!-- 左侧树形结构 -->
  5. <el-aside width="270px">
  6. <div class="JKWTree-tree" style="height: 500px">
  7. <h3>组织架构</h3>
  8. <el-tree :data="treeData" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
  9. </div>
  10. </el-aside>
  11. <!-- 右侧内容区域 -->
  12. <el-container>
  13. <el-main>
  14. <!-- 搜索框 -->
  15. <div class="gva-search-box">
  16. <el-form ref="elSearchFormRef" :inline="true" :model="searchInfo" class="demo-form-inline" :rules="searchRule" @keyup.enter="onSubmit">
  17. <!-- 左侧查询输入框 -->
  18. <el-form-item>
  19. <el-input v-model="searchInfo.ke" placeholder="请输入员工编号或员工姓名" clearable style="width: 200px;"></el-input>
  20. </el-form-item>
  21. <!-- 右侧查询和重置按钮 -->
  22. <el-form-item>
  23. <el-button type="primary" icon="search" @click="onSubmit">查询</el-button>
  24. <!-- <el-button icon="refresh" @click="onReset">重置</el-button>-->
  25. <el-button type="primary" icon="plus" @click="openDialog">新增</el-button>
  26. <el-button type="primary" icon="el-icon-download" @click="showExportDialog">导出到Excel</el-button>
  27. </el-form-item>
  28. </el-form>
  29. </div>
  30. <!-- 表格及操作按钮 -->
  31. <div class="gva-table-box">
  32. <!-- 导出字段选择对话框 -->
  33. <el-dialog title="选择导出字段" :visible.sync="exportDialogVisible" width="30%">
  34. <el-checkbox-group v-model="selectedExportFields">
  35. <el-checkbox label="employeenumber">员工编号</el-checkbox>
  36. <el-checkbox label="employeename">员工姓名</el-checkbox>
  37. <el-checkbox label="gender">性别</el-checkbox>
  38. <!-- 添加更多字段选项 -->
  39. </el-checkbox-group>
  40. <div slot="footer" class="dialog-footer">
  41. <el-button @click="exportDialogVisible = false">取 消</el-button>
  42. <el-button type="primary" @click="exportSelectedFields">确 定</el-button>
  43. </div>
  44. </el-dialog>
  45. <!-- 表格 -->
  46. <el-table ref="multipleTable"
  47. style="width: 100%;height: 500px"
  48. tooltip-effect="dark" :data="tableData" border
  49. row-key="ID"
  50. :row-class-name="tableRowClassName"
  51. @row-dblclick="updateCompanyFunc"
  52. @row-click="tableRowClick"
  53. @selection-change="handleSelectionChange">
  54. <el-table-column type="selection" width="55" />
  55. <el-table-column align="left" label="员工编号" prop="员工编号" width="100" />
  56. <el-table-column align="left" label="员工姓名" prop="员工姓名" width="100"/>
  57. <el-table-column align="left" label="性别" prop="性别" />
  58. <el-table-column align="left" label="聘用日期" prop="聘用日期" width="160" />
  59. <el-table-column align="left" label="转正日期" prop="转正日期" width="160" />
  60. <el-table-column align="left" label="所在部门" prop="所在部门" width="140" />
  61. <el-table-column align="left" label="职称职务" prop="职称职务" width="300" />
  62. <el-table-column align="left" label="身份证号" prop="身份证号" width="170" />
  63. <el-table-column align="left" label="出生日期" prop="出生日期" width="160" />
  64. <el-table-column align="left" label="人员性质" prop="人员性质" width="120" />
  65. <el-table-column align="left" label="人员类别" prop="人员类别" width="100" />
  66. <el-table-column align="left" label="班次类型" prop="班次类型" width="120" />
  67. <el-table-column align="left" label="工资表类别" prop="工资表类别" width="160" />
  68. <el-table-column align="left" label="薪酬核算分组" prop="薪酬核算分组" width="120" />
  69. <el-table-column align="left" label="MES在职" prop="在职状态" width="100" />
  70. <el-table-column align="left" label="U8在职" prop="U8在职" width="100" />
  71. <el-table-column align="left" label="U8离职日期" prop="U8离职日期" width="160" />
  72. <el-table-column align="left" label="创建用户" prop="sys_id" width="160" />
  73. <el-table-column align="left" label="创建时间" prop="sys_rq" width="160" />
  74. <el-table-column align="left" label="修改时间" prop="mod_rq" width="160" />
  75. <!-- <el-table-column align="left" label="操作" min-width="120" fixed='right'>-->
  76. <!-- <template #default="scope">-->
  77. <!-- <el-button type="primary" link icon="edit" class="table-button"-->
  78. <!-- @click="updateCompanyFunc(scope.row)">编辑</el-button>-->
  79. <!-- </template>-->
  80. <!-- </el-table-column>-->
  81. </el-table>
  82. <!-- 分页 -->
  83. <!-- <div class="gva-pagination">-->
  84. <!-- <el-pagination layout="total, sizes, prev, pager, next, jumper" :current-page="page"-->
  85. <!-- :page-size="pageSize" :page-sizes="[5,10, 30, 50, 100]" :total="total"-->
  86. <!-- @current-change="handleCurrentChange" @size-change="handleSizeChange" />-->
  87. <!-- </div>-->
  88. </div>
  89. <!-- 弹窗 -->
  90. <el-dialog v-model="dialogFormVisible" :before-close="closeDialog"
  91. :title="type==='create'?'添加员工基本资料':'修改员工基本资料'" destroy-on-close>
  92. <el-row>
  93. <!-- 左侧表单 -->
  94. <el-col :span="8">
  95. <el-scrollbar height="500px">
  96. <el-form :model="formData" label-position="right" ref="elFormRef" :rules="rule"
  97. label-width="100px">
  98. <el-form-item label="员工编号:" prop="address">
  99. <el-input v-model="formData.address" :clearable="true" placeholder="请输入员工编号"
  100. style="width: 180px;" />
  101. </el-form-item>
  102. <el-form-item label="性别:" prop="gender">
  103. <el-input v-model="formData.gender" :clearable="true" placeholder="请输入性别"
  104. style="width: 180px;" />
  105. </el-form-item>
  106. <el-form-item label="身份证:" prop="idCard">
  107. <el-input v-model="formData.idCard" :clearable="true" placeholder="请输入身份证"
  108. style="width: 180px;" />
  109. </el-form-item>
  110. <el-form-item label="部门名称:" prop="department">
  111. <el-input v-model="formData.department" :clearable="true"
  112. placeholder="请输入部门名称" style="width: 180px;" />
  113. </el-form-item>
  114. <el-form-item label="入职日期:" prop="joinDate">
  115. <el-input v-model="formData.joinDate" :clearable="true"
  116. placeholder="请输入入职日期" style="width: 180px;" />
  117. </el-form-item>
  118. <el-form-item label="人员类别:" prop="joinDate">
  119. <el-select v-model="formData.joinDate" placeholder="请选择人员类别"
  120. style="width: 180px;">
  121. <el-option label="生产" value="生产"></el-option>
  122. <el-option label="行政" value="行政"></el-option>
  123. </el-select>
  124. </el-form-item>
  125. <el-form-item label="班次类型:" prop="joinDate">
  126. <el-input v-model="formData.joinDate" :clearable="true"
  127. placeholder="请输入班次类型" style="width: 180px;" />
  128. </el-form-item>
  129. <el-form-item label="工资表类别:" prop="joinDate">
  130. <el-select v-model="formData.joinDate" placeholder="请选择工资表类别"
  131. style="width: 180px;">
  132. <el-option label="职员级计时工资表" value="职员级计时工资表"></el-option>
  133. <el-option label="另发工资" value="另发工资"></el-option>
  134. <el-option label="操作级计件工资表" value="操作级计件工资表"></el-option>
  135. <el-option label="操作级计时工资表" value="操作级计时工资表"></el-option>
  136. </el-select>
  137. </el-form-item>
  138. </el-form>
  139. </el-scrollbar>
  140. </el-col>
  141. <!-- 中间表单 -->
  142. <el-col :span="8">
  143. <el-scrollbar height="500px">
  144. <el-form :model="formData" label-position="right" ref="elFormRef" :rules="rule"
  145. label-width="100px">
  146. <el-form-item label="姓名:" prop="name"
  147. :rules="[{ required: true, message: '请输入姓名', trigger: 'blur' }]">
  148. <el-input v-model="formData.name" :clearable="true" placeholder="请输入姓名"
  149. style="width: 180px;" />
  150. </el-form-item>
  151. <el-form-item label="出生日期:" prop="birthDate">
  152. <el-input v-model="formData.birthDate" :clearable="true"
  153. placeholder="请输入出生日期" style="width: 180px;" />
  154. </el-form-item>
  155. <el-form-item label="职务:" prop="position">
  156. <el-input v-model="formData.position" :clearable="true" placeholder="请输入职务"
  157. style="width: 180px;" />
  158. </el-form-item>
  159. <el-form-item label="部门编号:" prop="departmentId">
  160. <el-input v-model="formData.departmentId" :clearable="true"
  161. placeholder="请输入部门编号" style="width: 180px;" />
  162. </el-form-item>
  163. <el-form-item label="转正日期:" prop="departmentId">
  164. <el-input v-model="formData.departmentId" :clearable="true"
  165. placeholder="请输入转正日期" style="width: 180px;" />
  166. </el-form-item>
  167. <el-form-item label="扣减司龄:" prop="departmentId">
  168. <el-input v-model="formData.departmentId" :clearable="true"
  169. placeholder="请输入扣减司龄" style="width: 180px;" />
  170. </el-form-item>
  171. <el-form-item label="人员性质:" prop="departmentId">
  172. <el-select v-model="formData.joinDate" placeholder="请选择人员性质"
  173. style="width: 180px;">
  174. <el-option label="退休返聘" value="退休返聘"></el-option>
  175. <el-option label="劳动合同工" value="劳动合同工"></el-option>
  176. <el-option label="借用" value="借用"></el-option>
  177. <el-option label="劳务派遣" value="劳务派遣"></el-option>
  178. <el-option label="实习生" value="实习生"></el-option>
  179. </el-select>
  180. </el-form-item>
  181. <el-form-item label="工资核算分组:" prop="departmentId">
  182. <el-input v-model="formData.departmentId" :clearable="true"
  183. placeholder="请输入工资核算分组" style="width: 180px;" />
  184. </el-form-item>
  185. </el-form>
  186. </el-scrollbar>
  187. </el-col>
  188. <!-- 右侧图片 -->
  189. </el-row>
  190. <!-- 添加 编辑页面 取消 确定 -->
  191. <template #footer>
  192. <div class="dialog-footer">
  193. <el-button @click="closeDialog">取 消</el-button>
  194. <el-button type="primary" @click="enterDialog">确 定</el-button>
  195. </div>
  196. </template>
  197. </el-dialog>
  198. </el-main>
  199. </el-container>
  200. </el-container>
  201. </div>
  202. </template>
  203. <script setup>
  204. // 全量引入格式化工具 请按需保留
  205. import {createCompany, deleteCompany, deleteCompanyByIds, updateCompany, findCompany, getCompanyList} from '@/api/company'
  206. import {getDictFunc, formatDate, formatBoolean, filterDict, ReturnArrImg, onDownloadFile} from '@/utils/format'
  207. import {ElMessage, ElMessageBox} from 'element-plus'
  208. import {ref, reactive} from 'vue'
  209. import {getDepartment, getProductData, getStaffList, ygjbzledit} from '@/api/yunyin/yunying'
  210. defineOptions({name: 'Company'})
  211. // =========== 左侧树侧形结构 ===========
  212. const treeData = ref({})
  213. const defaultProps = {
  214. children: 'children',
  215. label: '名称' // 将label设置为中文名称对应的字段名
  216. };
  217. const getDepartmentdata = async () => {
  218. try {
  219. const data = await getDepartment() //接口调用函数
  220. if(data.code === 0){
  221. treeData.value = data.data;
  222. }else {
  223. console.error(data.msg);
  224. }
  225. } catch (error) {
  226. console.error(error)
  227. }
  228. }
  229. getDepartmentdata();
  230. //点击左侧树形获取列表
  231. const tableData = reactive([])
  232. const handleNodeClick = async (node) => {
  233. //通过 department_code 编号 获取列表数据
  234. const department_code = node.编号;
  235. try {
  236. const WorkListdata = await getStaffList({ department_code:department_code,limit: '', page: ''});//接口调用函数
  237. tableData.splice(0,tableData.length,...WorkListdata.data.list);//表格数据
  238. total.value = tableData.length;//共多少条
  239. } catch (error) {
  240. console.error(error);
  241. }
  242. };
  243. // 分页相关的响应式变量
  244. const page = ref(1)
  245. const total = ref(0)
  246. const pageSize = ref(10)
  247. // 分页
  248. const handleCurrentChange = (val) => {
  249. page.value = val;
  250. getDepartmentdata();
  251. };
  252. // 修改页面容量 点击多少条/页
  253. const handleSizeChange = (val) => {
  254. page.value = 10;//默认显示十条
  255. pageSize.value = val;
  256. getDepartmentdata();
  257. };
  258. // 自动化生成的字典(可能为空)以及字段
  259. const formData = ref({
  260. address: '',
  261. image: '',
  262. name: '',
  263. })
  264. // 验证规则
  265. const rule = reactive({})
  266. const searchRule = reactive({
  267. createdAt: [{
  268. validator: (rule, value, callback) => {
  269. if (searchInfo.value.startCreatedAt && !searchInfo.value.endCreatedAt) {
  270. callback(new Error('请填写结束日期'))
  271. } else if (!searchInfo.value.startCreatedAt && searchInfo.value.endCreatedAt) {
  272. callback(new Error('请填写开始日期'))
  273. } else if (searchInfo.value.startCreatedAt && searchInfo.value.endCreatedAt && (
  274. searchInfo.value.startCreatedAt.getTime() === searchInfo.value.endCreatedAt
  275. .getTime() || searchInfo.value.startCreatedAt.getTime() > searchInfo.value
  276. .endCreatedAt.getTime())) {
  277. callback(new Error('开始日期应当早于结束日期'))
  278. } else {
  279. callback()
  280. }
  281. },
  282. trigger: 'change'
  283. }],
  284. })
  285. const elFormRef = ref()
  286. const elSearchFormRef = ref()
  287. const searchInfo = ref({})
  288. // 重置
  289. const onReset = () => {
  290. searchInfo.value = {}
  291. getTableData()
  292. }
  293. // 搜索
  294. const onSubmit = () => {
  295. elSearchFormRef.value?.validate(async (valid) => {
  296. console.log(valid)
  297. // if (!valid) return
  298. // page.value = 1
  299. // pageSize.value = 10
  300. // getTableData()
  301. })
  302. }
  303. // 查询
  304. const getTableData = async () => {
  305. const table = await getCompanyList({
  306. page: page.value,
  307. pageSize: pageSize.value,
  308. ...searchInfo.value
  309. })
  310. if (table.code === 0) {
  311. tableData.value = table.data.list
  312. total.value = table.data.total
  313. page.value = table.data.page
  314. pageSize.value = table.data.pageSize
  315. }
  316. }
  317. getTableData()
  318. // ============== 表格控制部分结束 ===============
  319. const tableRowClick = async (row) => {
  320. console.log(row);
  321. };
  322. // 获取需要的字典 可能为空 按需保留
  323. const setOptions = async () => {}
  324. // 获取需要的字典 可能为空 按需保留
  325. setOptions()
  326. // 多选数据
  327. const multipleSelection = ref([])
  328. // 多选
  329. const handleSelectionChange = (val) => {
  330. multipleSelection.value = val
  331. }
  332. // 行为控制标记(弹窗内部需要增还是改)
  333. const type = ref('')
  334. //修改
  335. const updateCompanyFunc = async (row) => {
  336. const product_code = row.员工编号;
  337. console.log(product_code);
  338. // const data = await ygjbzledit({ product_code: product_code });
  339. // console.log(data);
  340. dialogFormVisible.value = true;
  341. };
  342. // 弹窗控制标记
  343. const dialogFormVisible = ref(false)
  344. // 查看详情控制标记
  345. const detailShow = ref(false)
  346. // 打开详情弹窗
  347. const openDetailShow = () => {
  348. detailShow.value = true
  349. }
  350. // 打开详情
  351. const getDetails = async (row) => {
  352. detailShow.value = true
  353. }
  354. // 关闭详情弹窗
  355. const closeDetailShow = () => {
  356. detailShow.value = false
  357. formData.value = {
  358. address: '',
  359. image: '',
  360. name: '',
  361. }
  362. }
  363. // 打开弹窗
  364. const openDialog = () => {
  365. type.value = 'create'
  366. dialogFormVisible.value = true
  367. }
  368. // 关闭弹窗
  369. const closeDialog = () => {
  370. dialogFormVisible.value = false
  371. formData.value = {
  372. address: '',
  373. image: '',
  374. name: '',
  375. }
  376. }
  377. // 弹窗确定
  378. const enterDialog = async () => {
  379. elFormRef.value?.validate(async (valid) => {
  380. if (!valid) return
  381. let res
  382. switch (type.value) {
  383. case 'create':
  384. res = await createCompany(formData.value)
  385. break
  386. case 'update':
  387. res = await updateCompany(formData.value)
  388. break
  389. default:
  390. res = await createCompany(formData.value)
  391. break
  392. }
  393. if (res.code === 0) {
  394. ElMessage({
  395. type: 'success',
  396. message: '创建/更改成功'
  397. })
  398. closeDialog()
  399. getTableData()
  400. }
  401. })
  402. }
  403. </script>
  404. <style>
  405. .JKWTree-container {
  406. display: flex;
  407. }
  408. .JKWTree-tree {
  409. width: 300px;
  410. background-color: #fff;
  411. padding: 10px;
  412. margin-right: 20px;
  413. }
  414. .JKWTree-tree h3 {
  415. font-size: 15px;
  416. font-weight: 700;
  417. margin: 10px 0;
  418. }
  419. .JKWTree-content {
  420. flex: 1;
  421. }
  422. /* 图片上传 */
  423. .upload-box {
  424. width: 200px;
  425. height: 200px;
  426. border: 2px dashed #e2e2e2;
  427. display: flex;
  428. justify-content: center;
  429. align-items: center;
  430. position: relative;
  431. cursor: pointer;
  432. }
  433. .uploaded-image {
  434. width: 100%;
  435. height: 100%;
  436. object-fit: cover;
  437. }
  438. .upload-icon {
  439. font-size: 40px;
  440. color: #c0c4cc;
  441. }
  442. .file-input {
  443. display: none;
  444. }
  445. .el-table .warning-row {
  446. background: oldlace;
  447. }
  448. </style>