index.vue 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735
  1. <template>
  2. <section>
  3. <el-col :span="4" class="left" :style="'height:'+ (tableHeight + 113) + 'px'">
  4. <div class="department">
  5. <span><i class="iconfont firerock-iconzuzhijiegou" style="font-size:10px;" ></i>&nbsp;部门</span>
  6. <div v-on:click="createDepartment(-1)">
  7. <i class="fa fa-plus-circle"></i>
  8. 创建
  9. </div>
  10. </div>
  11. <el-divider style="margin: 0px 0px !important;height:0.5px;"></el-divider>
  12. <div class="tree" :style="'height:'+ (tableHeight + 83) + 'px'">
  13. <!-- <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick" accordion></el-tree> -->
  14. <el-tree :data="data" :props="defaultProps" node-key="id" :expand-on-click-node="false" accordion @node-click="handleNodeClick" :default-expanded-keys="jDarr" @node-expand="jieDian" @node-collapse="shutDown" @current-change="chufa">
  15. <span class="custom-tree-node" slot-scope="{ node }" @mouseleave= mouseleave(data,$event) @mouseover= mouseover(data,$event)>
  16. <span style="width: 100%;line-height: 36px; display: inline-block;">{{ node.label }}</span>
  17. <span v-if="node.label != '全部人员'" class="node none">
  18. <el-button type="text" size="mini" @click="createDepartment(-2)" >
  19. <i class="el-icon-circle-plus-outline"></i> <!-- 新增 -->
  20. </el-button>
  21. <el-button type="text" size="mini" @click="deleteDep(null)">
  22. <i class="el-icon-delete"></i> <!-- 删除 -->
  23. </el-button>
  24. </span>
  25. </span>
  26. </el-tree>
  27. </div>
  28. </el-col>
  29. <el-col :span="20" class="right">
  30. <!--工具条-->
  31. <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  32. <el-form :inline="true">
  33. <!-- <div style="width: 300px;display: inline-block;">
  34. <el-input v-model="keyword" class="input-with-select" placeholder="请输入人员名字搜索" clearable="true">
  35. <el-button slot="append" @click="searchList" icon="el-icon-search"></el-button>
  36. </el-input>
  37. </div> -->
  38. <el-form-item>
  39. <div v-if="depData == null || depData.id == -1" class="nowTime" style="cursor:unset">
  40. <i class="fa fa-home"></i>全部人员
  41. </div>
  42. <div v-else-if="depData.id == 0" class="nowTime" style="cursor:unset">
  43. <i class="fa fa-home"></i>未分配
  44. </div>
  45. <div v-else-if="depData != null && depData.id != -1 && depData.id != 0" class="nowTime" @click="createDepartment(0)">
  46. <i class="fa fa-pencil-square-o"></i>
  47. {{depData!=null?depData.label:''}}
  48. </div>
  49. </el-form-item>
  50. <el-form-item>
  51. <div style="color:#999;font-size:13px;">共{{total}}人</div>
  52. </el-form-item>
  53. <el-form-item style="float:right;" v-if="permissions.structureExport">
  54. <el-link type="primary" :underline="false" @click="showExportDialog">导出人员</el-link>
  55. </el-form-item>
  56. <el-form-item style="float:right;" v-if="!isDingShow && permissions.structureAdd">
  57. <el-link type="primary" :underline="false" @click="openInsertDialog(null)">添加人员</el-link>
  58. </el-form-item>
  59. <!-- 原来的 -->
  60. <!-- <el-form-item style="float:right;" v-if="depData != null && depData.id != -1 && depData.id != 0">
  61. <el-upload ref="upload" action="#" :limit="1" :http-request="importUser" :show-file-list="false">
  62. <el-link type="primary" :underline="false">批量导入</el-link>
  63. </el-upload>
  64. </el-form-item> -->
  65. <el-form-item style="float:right;" v-if="!isDingShow && permissions.structureImport">
  66. <el-upload ref="upload" action="#" :limit="1" :http-request="importUser" :show-file-list="false">
  67. <el-link type="primary" :underline="false">批量导入</el-link>
  68. </el-upload>
  69. </el-form-item>
  70. <el-form-item style="float:right;" v-if="!isDingShow && permissions.structureImport">
  71. <el-link type="primary" :underline="false" href="./upload/人员导入模板.xlsx" download="人员导入模板.xlsx">模板下载</el-link>
  72. </el-form-item>
  73. <!-- <el-form-item v-if="depData != null && depData.id != -1 && depData.id != 0" style="float:right;border: 0.5px solid #20a0ff;height: 27px;margin-top: 6px;">
  74. </el-form-item> -->
  75. <!-- <el-form-item style="float:right;">
  76. <el-link type="danger" v-if="depData != null && depData.id != -1 && depData.id != 0" :underline="false" @click="deleteDep(null)">删除部门</el-link>
  77. </el-form-item>
  78. <el-form-item style="float:right;">
  79. <el-link type="primary" v-if="depData != null && depData.id != -1 && depData.id != 0" :underline="false" @click="createDepartment(-2)">新增子部门</el-link>
  80. </el-form-item> -->
  81. <el-form-item style="float:right;">
  82. <span style="color: #666666">角色</span>
  83. <el-select v-model="roleId" placeholder="请选择" @change="getUser()" style="width: 120px" clearable>
  84. <!-- <el-option
  85. v-for="item in rolesa"
  86. :key="item.value"
  87. :label="item.label"
  88. :value="item.value">
  89. </el-option> -->
  90. <el-option v-for="item in acquireRoleList" :key="item.id" :label="item.rolename" :value="item.id"></el-option>
  91. </el-select>
  92. </el-form-item>
  93. <el-form-item style="float:right;">
  94. <span style="color: #666666">状态</span>
  95. <el-select v-model="status" placeholder="请选择" @change="getUser()" style="width: 120px">
  96. <el-option
  97. v-for="item in states"
  98. :key="item.value"
  99. :label="item.label"
  100. :value="item.value">
  101. </el-option>
  102. </el-select>
  103. </el-form-item>
  104. <el-form-item style="float:right;">
  105. <div style="width: 250px;display: inline-block;">
  106. <el-input v-model="keyword" class="input-with-select" placeholder="请输入人员名字搜索" clearable="true">
  107. <el-button slot="append" @click="searchList" icon="el-icon-search"></el-button>
  108. </el-input>
  109. </div>
  110. </el-form-item>
  111. </el-form>
  112. </el-col>
  113. <!--列表-->
  114. <el-table ref="handleSelectTable" :data="list" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;" @selection-change="handleSelectionZzjg">
  115. <el-table-column type="selection" width="50"></el-table-column>
  116. <el-table-column type="index" width="50">
  117. <template slot-scope="scope" >
  118. {{scope.$index+1+(page-1)*size}}
  119. </template>
  120. </el-table-column>
  121. <el-table-column prop="name" label="姓名" sortable></el-table-column>
  122. <el-table-column prop="phone" label="手机" width="120"></el-table-column>
  123. <el-table-column prop="departmentName" label="部门" sortable></el-table-column>
  124. <el-table-column label="角色" width="100">
  125. <template slot-scope="scope">{{scope.row.roleName}}</template>
  126. </el-table-column>
  127. <el-table-column prop="monthCost" label="月成本" sortable v-if="permissions.structurePersonnel">
  128. <template slot-scope="scope">{{scope.row.monthCost==null?0:scope.row.monthCost}} 元</template>
  129. </el-table-column>
  130. <el-table-column prop="cost" label="时薪" sortable v-if="permissions.structurePersonnel">
  131. <template slot-scope="scope">{{scope.row.cost==null?0:scope.row.cost}} 元
  132. <el-link @click.native="showSalaryList(scope.row)"><i class="iconfont firerock-iconrecord"></i></el-link>
  133. </template>
  134. </el-table-column>
  135. <el-table-column label="操作" width="330">
  136. <template slot-scope="scope">
  137. <el-button size="mini" type="default" v-if="scope.row.roleName == '超级管理员'" @click="transferRole(scope.row)">转让</el-button>
  138. <el-button size="mini" type="default" v-if="scope.row.roleName != '超级管理员'" @click="resetPwd(scope.row)">重置</el-button>
  139. <el-button size="mini" type="primary" v-if="scope.row.roleName != '超级管理员'" @click="openInsertDialog(scope.$index)">编辑</el-button>
  140. <el-button size="mini" type="primary" v-if="scope.row.roleName == '超级管理员'" @click="openInsertDialog1(scope.$index)">编辑</el-button>
  141. <el-button size="mini" type="danger" v-if="scope.row.roleName != '超级管理员'" @click="deleteUser(scope.row)">删除</el-button>
  142. <el-button size="mini" type="default" v-if="scope.row.roleName != '超级管理员' && scope.row.isActive==1" @click="showDeactiveDialog(scope.row)">停用</el-button>
  143. <el-button size="mini" type="success" v-if="scope.row.roleName != '超级管理员' && scope.row.isActive==0" @click="setActive(scope.row, 1)">启用</el-button>
  144. </template>
  145. </el-table-column>
  146. </el-table>
  147. <!--工具条-->
  148. <el-col :span="24" class="toolbar">
  149. <!-- 123 -->
  150. <el-button size="small" @click="handleSelectionZzjgbtn1">取消</el-button>
  151. <!-- <el-cascader v-model="handleSelectionZzjgwillchange" size="small" placeholder="请选择部门" style="width: 13%;margin-left: 1%;margin-right: 1%;font-size:12px"
  152. :options="option" :props="{ checkStrictly: false,expandTrigger: 'hover' }" :show-all-levels="false" clearable></el-cascader>
  153. <el-button size="small" type="primary" @click="handleSelectionZzjgbtn2">修改</el-button> -->
  154. <el-button size="small" type="primary" @click="handleSelectionZzjgbtn3">批量修改部门</el-button>
  155. <el-button size="small" type="primary" @click="handJue">批量修改角色</el-button>
  156. <el-pagination
  157. @size-change="handleSizeChange"
  158. @current-change="handleCurrentChange"
  159. :page-sizes="[20 , 50 , 80 , 100]"
  160. :page-size="size"
  161. layout="total, sizes, prev, pager, next"
  162. :total="total"
  163. style="float:right;"
  164. ></el-pagination>
  165. </el-col>
  166. </el-col>
  167. <!-- 批量修改弹出框 -->
  168. <el-dialog title="批量修改" :visible.sync="handleSelectionZzjgshow" v-if="handleSelectionZzjgshow" width="30%">
  169. <el-form model="" label-width="20%">
  170. <el-form-item label="修改部门">
  171. <!-- <el-cascader v-model="handleSelectionZzjgwillchange" placeholder="请选择部门" style="width: 60%;"
  172. :options="option" :props="{ checkStrictly: false,expandTrigger: 'hover' }" :show-all-levels="false" clearable></el-cascader> -->
  173. <el-cascader v-model="handleSelectionZzjgwillchange" placeholder="请选择部门" style="width: 60%;"
  174. :options="option" :props="{ checkStrictly: true,expandTrigger: 'hover' }" :show-all-levels="false" clearable></el-cascader>
  175. </el-form-item>
  176. </el-form>
  177. <div slot="footer" class="dialog-footer">
  178. <el-button @click="handleSelectionZzjgshow = false">取消</el-button>
  179. <el-button type="primary" @click="handleSelectionZzjgbtn2">确定</el-button>
  180. </div>
  181. </el-dialog>
  182. <!-- 批量修改角色弹出框 -->
  183. <el-dialog title="批量修改" :visible.sync="handljues" v-if="handljues" width="30%">
  184. <el-form model="" label-width="20%">
  185. <el-form-item label="修改角色">
  186. <el-select v-model="xiuRoleId" placeholder="请选择" style="width: 100%">
  187. <el-option v-for="(item, index) in acquireRoleLists" :key="index" :label="item.rolename" :value="item.id"></el-option>
  188. </el-select>
  189. </el-form-item>
  190. </el-form>
  191. <div slot="footer" class="dialog-footer">
  192. <el-button @click="handljues = false">取消</el-button>
  193. <el-button type="primary" @click="handTrue">确定</el-button>
  194. </div>
  195. </el-dialog>
  196. <!-- 新增部门 -->
  197. <el-dialog :title="depTitle" :visible.sync="departmentVisible" width="400px" >
  198. <el-form ref="depForm" :model="depForm" :rules="depRules" label-width="80px">
  199. <el-form-item label="部门名称" prop="name">
  200. <el-input v-model="depForm.name" placeholder="请输入部门名称" clearable></el-input>
  201. </el-form-item>
  202. <el-form-item label="负责人" prop="managerId">
  203. <el-select v-model="depForm.managerId" filterable clearable placeholder="请选择部门负责人" >
  204. <el-option v-for="item in users" :key="item.id" :label="item.name" :value="item.id"></el-option>
  205. </el-select>
  206. </el-form-item>
  207. <!-- 直属领导 -->
  208. <el-form-item label="直属领导" prop="reportAuditUserid">
  209. <el-select v-model="depForm.reportAuditUserid" filterable clearable placeholder="请选择直属领导" >
  210. <el-option v-for="item in users" :key="item.id" :label="item.name" :value="item.id"></el-option>
  211. </el-select>
  212. </el-form-item>
  213. </el-form>
  214. <span slot="footer" class="dialog-footer">
  215. <el-button @click="departmentVisible = false">取消</el-button>
  216. <el-button type="primary" @click="submitDepartment" >提交</el-button>
  217. </span>
  218. </el-dialog>
  219. <!-- 新增单个人员的Dialog -->
  220. <el-dialog :title="title" :visible.sync="dialogVisible" width="550px" >
  221. <el-form ref="form1" :model="insertForm" :rules="rules" label-width="80px">
  222. <el-form-item label="名字" prop="name">
  223. <el-input v-model="insertForm.name" placeholder="请输入姓名" clearable></el-input>
  224. </el-form-item>
  225. <el-form-item label="电话" prop="phone">
  226. <el-input v-model="insertForm.phone" placeholder="请输入电话号码" clearable></el-input>
  227. </el-form-item>
  228. <el-form-item label="薪酬方式" prop="salaryType" v-if="permissions.structurePersonnel">
  229. <el-radio-group v-model="insertForm.salaryType" @change="onSalaryTypeChange">
  230. <el-radio :label="0" >固定月成本</el-radio>
  231. <el-radio :label="1">计时工资</el-radio>
  232. </el-radio-group>
  233. </el-form-item>
  234. <el-form-item label="月成本" prop="monthCost" v-if="insertForm.salaryType == 0 && permissions.structurePersonnel">
  235. <el-input v-model="insertForm.monthCost" id="mc" @input="oninput" placeholder="请输入月成本,单位:元" clearable @keyup.native="restrictNumber('mc')"></el-input>
  236. <span style="color:orange;font-size:12px;">按照每个月工作{{timeType.monthDays}}天,每天{{timeType.allday}}小时预估时薪</span>
  237. <el-link :underline="false" style="color:blue;font-size:12px;margin-left:7px;" href="#/timetype">修改工作时长</el-link>
  238. </el-form-item>
  239. <el-form-item label="时薪" prop="cost" v-if="permissions.structurePersonnel">
  240. <el-input v-model="insertForm.cost" :disabled="insertForm.salaryType == 0" id="cc" style="width:120px;" @keyup.native="restrictNumber('cc')"
  241. placeholder="请输入成本 单位:元/小时" clearable></el-input>
  242. <span style="margin-left:25px;">生效日期</span>
  243. <el-date-picker v-model="insertForm.costApplyDate" value-format="yyyy-MM-dd"></el-date-picker>
  244. </el-form-item>
  245. <el-form-item label="部门" prop="departmentId">
  246. <!-- <el-cascader v-model="insertForm.departmentId" placeholder="请选择部门" style="width: 100%"
  247. :options="option" :props="{ checkStrictly: false,expandTrigger: 'hover' }" :show-all-levels="false" clearable></el-cascader> -->
  248. <el-cascader v-model="insertForm.departmentId" placeholder="请选择部门" style="width: 100%"
  249. :options="option" :props="{ checkStrictly: true,expandTrigger: 'hover' }" :show-all-levels="false" clearable></el-cascader>
  250. </el-form-item>
  251. <el-form-item label="角色" prop="roleId">
  252. <el-select v-model="insertForm.roleId" placeholder="请选择角色" style="width: 100%">
  253. <el-option v-for="item in acquireRoleList" :label="item.rolename" :value="item.id" :key="item.name">
  254. <span style="float: left">{{item.rolename}}</span>
  255. <span style="float: right; color: #8492a6; font-size: 13px">{{item.roleDescribe}}</span>
  256. </el-option>
  257. </el-select>
  258. </el-form-item>
  259. </el-form>
  260. <span slot="footer" class="dialog-footer">
  261. <el-button @click="dialogVisible=false">取消</el-button>
  262. <el-button type="primary" @click="submitInsert" :loading="submitLoading">提交</el-button>
  263. </span>
  264. </el-dialog>
  265. <el-dialog title="修改成本" :visible.sync="dialogVisible1" width="550px" >
  266. <el-form ref="form1" :model="insertForm" :rules="rules" label-width="80px">
  267. <el-form-item label="名字" prop="name">
  268. <el-input v-model="insertForm.name" placeholder="请输入姓名" clearable></el-input>
  269. </el-form-item>
  270. <el-form-item label="薪酬方式" prop="salaryType">
  271. <el-radio-group v-model="insertForm.salaryType" @change="onSalaryTypeChange">
  272. <el-radio :label="0" >固定月成本</el-radio>
  273. <el-radio :label="1">计时工资</el-radio>
  274. </el-radio-group>
  275. </el-form-item>
  276. <el-form-item label="月成本" prop="monthCost" v-if="insertForm.salaryType == 0">
  277. <el-input v-model="insertForm.monthCost" id="monthCost" @input="oninput" @keyup.native="restrictNumber('monthCost')" placeholder="请输入月成本,单位:元" clearable></el-input>
  278. <span style="color:orange;font-size:12px;">按照每个月工作{{timeType.monthDays}}天,每天{{timeType.allday}}小时预估时薪</span>
  279. <el-link :underline="false" style="color:blue;font-size:12px;margin-left:7px;" href="#/timetype">修改工作时长</el-link>
  280. </el-form-item>
  281. <el-form-item label="时薪" prop="cost">
  282. <el-input v-model="insertForm.cost" id="cost" :disabled="insertForm.salaryType == 0" @keyup.native="restrictNumber('cost')" style="width:120px;"
  283. placeholder="请输入成本 单位:元/小时" clearable></el-input>
  284. <span style="margin-left:25px;">生效日期</span>
  285. <el-date-picker v-model="insertForm.costApplyDate" value-format="yyyy-MM-dd"></el-date-picker>
  286. </el-form-item>
  287. <el-form-item label="部门" prop="departmentId">
  288. <el-cascader v-model="insertForm.departmentId"
  289. placeholder="请选择部门"
  290. style="width: 100%"
  291. :options="option"
  292. :props="{ checkStrictly: false,expandTrigger: 'hover' }" :show-all-levels="false"
  293. clearable></el-cascader>
  294. </el-form-item>
  295. </el-form>
  296. <span slot="footer" class="dialog-footer">
  297. <el-button @click="dialogVisible1=false">取消</el-button>
  298. <el-button type="primary" @click="submitInsert1" :loading="submitLoading">提交</el-button>
  299. </span>
  300. </el-dialog>
  301. <el-dialog title="人员历史成本" :visible.sync="userSalaryListDialog" width="550px" >
  302. <el-table :data="userSalaryList" highlight-current-row v-loading="listLoading" height="300px" style="width: 100%;">
  303. <el-table-column prop="userName" label="姓名" ></el-table-column>
  304. <el-table-column prop="indate" label="更新时间" width="150px">
  305. </el-table-column>
  306. <el-table-column prop="salaryType" label="薪酬方式" >
  307. <template slot-scope="scope" >
  308. {{scope.row.salaryType==0?"固定月薪":"计时工资"}}
  309. </template>
  310. </el-table-column>
  311. <el-table-column prop="monthCost" label="月薪" >
  312. <template slot-scope="scope" >
  313. {{scope.row.monthCost}}元
  314. </template>
  315. </el-table-column>
  316. <el-table-column prop="cost" label="时薪" >
  317. <template slot-scope="scope" >
  318. {{scope.row.cost}}元
  319. </template>
  320. </el-table-column>
  321. </el-table>
  322. </el-dialog>
  323. <!--导出人员 -->
  324. <el-dialog title="导出人员列表" :visible.sync="exportDialogVisible" width="550px" >
  325. <el-form label-width="100px">
  326. <el-form-item label="导出" >
  327. <el-radio-group v-model="containInvalid" >
  328. <el-radio :label="1" >全部人员</el-radio>
  329. <el-radio :label="0" >仅活跃人员</el-radio>
  330. </el-radio-group>
  331. </el-form-item>
  332. </el-form>
  333. <span slot="footer" class="dialog-footer">
  334. <el-button type="primary" @click="exportUsers">导出</el-button>
  335. </span>
  336. </el-dialog>
  337. <!-- 转让超级管理员权限 -->
  338. <el-dialog title="权限转让" :visible.sync="transferDialog" width="550px" >
  339. <el-form label-width="200px">
  340. <el-form-item label="转让超级管理员角色至" >
  341. <el-select v-model="toUserId" style="width:300px" filterable clearable>
  342. <el-option v-for="item in allActiveUsers" :key="item.id" :value="item.id" :label="item.name">
  343. </el-option>
  344. </el-select>
  345. </el-form-item>
  346. <el-form-item label="转让后自己的角色" >
  347. <el-select v-model="myRoleId" style="width:300px">
  348. <el-option v-for="item in roleDescArray" :label="item.label" :value="item.value" :key="item.name">
  349. <span style="float: left">{{item.label}}</span>
  350. <span style="float: right; color: #8492a6; font-size: 13px">{{item.desc}}</span>
  351. </el-option>
  352. </el-select>
  353. </el-form-item>
  354. </el-form>
  355. <span slot="footer" class="dialog-footer">
  356. <el-button type="default" @click="transferDialog = false">取消</el-button>
  357. <el-button type="primary" @click="showConfirmDialog">确定</el-button>
  358. </span>
  359. </el-dialog>
  360. <!--停用时选择日期 -->
  361. <el-dialog title="离职停用员工" :visible.sync="deactiveDialog" width="550px" >
  362. <el-form label-width="200px">
  363. <el-form-item label="员工离职日期" >
  364. <el-date-picker type="date" v-model="deactiveDate" value-format="yyyy-MM-dd" format="yyyy-MM-dd" placeholder="请选择" />
  365. </el-form-item>
  366. </el-form>
  367. <span slot="footer" class="dialog-footer">
  368. <el-button type="default" @click="deactiveDialog = false">取消</el-button>
  369. <el-button type="primary" @click="confirmDeactive">确定</el-button>
  370. </span>
  371. </el-dialog>
  372. </section>
  373. </template>
  374. <script>
  375. import util from "../../common/js/util";
  376. let that
  377. export default {
  378. data() {
  379. return {
  380. permissions: JSON.parse(sessionStorage.getItem("permissions")),
  381. isDingShow : false,
  382. handleSelectionZzjgshow: false,
  383. handljues: false,
  384. submitLoading:false,
  385. deactiveUser:null,
  386. deactiveDate:null,
  387. deactiveDialog:false,
  388. toUserId:null,
  389. myRoleId: 2,
  390. allActiveUsers:[],
  391. transferDialog: false,
  392. containInvalid:1,
  393. exportDialogVisible: false,
  394. roleArray:["普通员工","超级管理员", "系统管理员", "公司高层","财务管理员", "项目管理员","公司领导"],
  395. roleDescArray:[{label:"普通员工",value:0, desc:"填报日报,参与项目协作"},
  396. {label:"系统管理员",value:2, desc:"具有除了创建系统管理员之外的全部功能"},
  397. // {label:"公司高层",value:3, desc:"查阅项目信息,人员工时情况"},
  398. {label:"财务管理员",value:4, desc:"财务核算成本,费用报销审核,负责组织架构管理"},
  399. {label:"项目管理员",value:5, desc:"创建和管理项目"},
  400. {label:"公司领导",value:6, desc:"查看日报、工时成本统计、财务核算、项目和报表"},
  401. ],
  402. userSalaryList:[],
  403. userSalaryListDialog: false,
  404. value:{},
  405. user: JSON.parse(sessionStorage.getItem("user")),
  406. users:[],
  407. tableHeight: 0,
  408. listLoading: false,
  409. total: 0,
  410. page: 1,
  411. size: 20,
  412. list: [],
  413. data: [
  414. {
  415. id: -1,
  416. label: '全部人员',
  417. },
  418. {
  419. id: 0,
  420. label: '未分配',
  421. }
  422. ],
  423. option: [],
  424. depData: {
  425. id: -1,
  426. label: '全部人员',
  427. },
  428. defaultProps: {
  429. children: 'children',
  430. label: 'label'
  431. },
  432. dialogVisible: false,
  433. title: "",
  434. insertForm: {
  435. id: null,
  436. name: null,
  437. phone: null,
  438. // role: null,
  439. roleId: null,
  440. monthCost:null,
  441. cost: null,
  442. departmentId: null,
  443. salaryType:0,
  444. costApplyDate: '2021-04-09'
  445. },
  446. rules: {
  447. name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
  448. // phone: [{ required: true, message: "请输入电话", trigger: "blur" }],
  449. // role: [{ required: true, message: "请选择角色", trigger: "blur" }],
  450. roleId: [{ required: true, message: "请选择角色", trigger: "blur" }],
  451. cost: [{ required: true, message: "请输入成本", trigger: "blur" }],
  452. monthCost:[{ required: true, message: "请输入月成本", trigger: "blur" }]
  453. },
  454. dialogVisible1: false,
  455. departmentVisible: false,
  456. depTitle: '',
  457. depForm: {
  458. id: null,
  459. name: null,
  460. parentId: null,
  461. managerId: null,
  462. },
  463. depRules: {
  464. name: [{ required: true, message: "请输入部门名称", trigger: "blur" }],
  465. },
  466. timeType:{},
  467. keyword: '',
  468. rolesa: [{
  469. value: '',
  470. label: '全部'
  471. }, {
  472. value: '6',
  473. label: '公司领导'
  474. }, {
  475. value: '2',
  476. label: '系统管理员'
  477. }, {
  478. value: '4',
  479. label: '财务管理员'
  480. }, {
  481. value: '5',
  482. label: '项目管理员'
  483. }, {
  484. value: '0',
  485. label: '普通员工'
  486. }],
  487. states: [{
  488. value: '',
  489. label: '全部'
  490. }, {
  491. value: '1',
  492. label: '活跃'
  493. }, {
  494. value: '0',
  495. label: '停用'
  496. }],
  497. status: '',
  498. role: '',
  499. jDarr: [],
  500. handleSelectionZzjgDate:[],
  501. handleSelectionZzjgwillchange : null,
  502. acquireRoleList: [], // 角色列表
  503. acquireRoleLists: [], // 没有超级管理员
  504. roleId: '',
  505. xiuRoleId: ''
  506. };
  507. },
  508. filters: {
  509. acquireRoleName(value) {
  510. for(var i in that.acquireRoleList) {
  511. if(that.acquireRoleList[i].id == value) {
  512. return that.acquireRoleList[i].rolename
  513. }
  514. }
  515. }
  516. },
  517. beforeCreate: function () {
  518. that = this;
  519. },
  520. methods: {
  521. // 批量修改部门
  522. handleSelectionZzjg(e){
  523. // if (e.length == 0) {
  524. // this.handleSelectionZzjgshow = false
  525. // }else{
  526. // this.handleSelectionZzjgshow = true
  527. // }
  528. this.handleSelectionZzjgDate = e
  529. },
  530. handleSelectionZzjgbtn1(){
  531. this.handleSelectionZzjgshow = false
  532. this.$refs.handleSelectTable.clearSelection()
  533. this.handleSelectionZzjgwillchange = null
  534. },
  535. handleSelectionZzjgbtn2(){
  536. if (this.handleSelectionZzjgwillchange == null) {
  537. this.$message('请选择部门');
  538. return
  539. }
  540. //接口调用样例代码如下
  541. var ids = [];
  542. for (let index = 0; index < this.handleSelectionZzjgDate.length; index++) {
  543. ids.push(this.handleSelectionZzjgDate[index].id)
  544. }
  545. var changeId = this.handleSelectionZzjgwillchange[this.handleSelectionZzjgwillchange.length - 1]
  546. this.http.post('/user/batchUpdateDept', {
  547. userIds: JSON.stringify(ids),
  548. deptId: changeId
  549. },
  550. res => {
  551. if (res.code == "ok") {
  552. this.$message({
  553. message: '修改成功',
  554. type: "success"
  555. });
  556. this.getUser()
  557. } else {
  558. this.$message({
  559. message: res.msg,
  560. type: "error"
  561. });
  562. }
  563. },
  564. error => {
  565. this.$message({
  566. message: error,
  567. type: "error"
  568. });
  569. });
  570. // for (let index = 0; index < this.handleSelectionZzjgDate.length; index++) {
  571. // this.handleSelectionZzjgDate[index].departmentId = this.handleSelectionZzjgwillchange[this.handleSelectionZzjgwillchange.length - 1]
  572. // if (this.handleSelectionZzjgDate[index].role == 1) {
  573. // this.submitInsert1(this.handleSelectionZzjgDate[index],1)
  574. // }else{
  575. // this.submitInsert(this.handleSelectionZzjgDate[index],1)
  576. // }
  577. // }
  578. // this.handleSelectionZzjgwillchange = null
  579. this.handleSelectionZzjgshow = false
  580. },
  581. handleSelectionZzjgbtn3(){
  582. if(this.handleSelectionZzjgDate.length == 0){
  583. this.$message('请选择');
  584. return
  585. }
  586. this.handleSelectionZzjgshow = true
  587. },
  588. handJue() {
  589. if(this.handleSelectionZzjgDate.length == 0){
  590. this.$message('请选择');
  591. return
  592. }
  593. for(var i in this.acquireRoleList) {
  594. if(this.acquireRoleList[i].isDefault == 1) {
  595. this.xiuRoleId = this.acquireRoleList[i].id
  596. }
  597. }
  598. this.handljues = true
  599. console.log('触发了')
  600. },
  601. handTrue() {
  602. var arr = []
  603. for(var i in this.handleSelectionZzjgDate) {
  604. arr.push(this.handleSelectionZzjgDate[i].id)
  605. }
  606. this.http.post('/user/batchUpdateRole', {
  607. userIds: JSON.stringify(arr),
  608. roleId: this.xiuRoleId
  609. },
  610. res => {
  611. if (res.code == "ok") {
  612. this.$message({
  613. message: '操作成功',
  614. type: "success"
  615. });
  616. this.handljues = false
  617. this.getUser()
  618. } else {
  619. this.$message({
  620. message: res.msg,
  621. type: "error"
  622. });
  623. }
  624. },
  625. error => {
  626. this.$message({
  627. message: error,
  628. type: "error"
  629. });
  630. });
  631. },
  632. deleteUser(targetUser) {
  633. this.$confirm("确定要删除该员工吗?", "提示", {
  634. //type: 'warning'
  635. }).then(() => {
  636. this.http.post('/user/deleteUser', {
  637. userId: targetUser.id,
  638. },
  639. res => {
  640. if (res.code == "ok") {
  641. this.$message({
  642. message: '删除成功',
  643. type: "success"
  644. });
  645. this.getUser()
  646. } else {
  647. this.$message({
  648. message: res.msg,
  649. type: "error"
  650. });
  651. }
  652. },
  653. error => {
  654. this.$message({
  655. message: error,
  656. type: "error"
  657. });
  658. });
  659. })
  660. },
  661. chufa(data, b, c, e) {
  662. if(this.depData == null || data.id != this.depData.id) {
  663. // this.depData = data.id
  664. this.depData = data;
  665. this.page = 1;
  666. this.getUser();
  667. }
  668. },
  669. jieDian(a, b, c) {
  670. var ids = a.id
  671. var arrs = this.jDarr
  672. arrs.push(ids)
  673. this.jDarr = arrs
  674. },
  675. shutDown(a, b, c) {
  676. var ids = a.id
  677. var arrs = []
  678. for (var i in this.jDarr) {
  679. if(this.jDarr[i] != ids) {
  680. arrs.push(this.jDarr[i])
  681. }
  682. }
  683. this.jDarr = arrs
  684. },
  685. mouseleave(data,$event){
  686. $event.currentTarget.firstElementChild.nextElementSibling.setAttribute('class','node none')
  687. },
  688. mouseover(data,$event){
  689. $event.currentTarget.lastChild.setAttribute('class','node block');
  690. },
  691. confirmDeactive() {
  692. this.http.post('/user/deactiveUser', {
  693. id: this.deactiveUser.id,
  694. inactiveDate: this.deactiveDate
  695. },
  696. res => {
  697. if (res.code == "ok") {
  698. this.deactiveDialog = false;
  699. this.$message({
  700. message: '停用成功',
  701. type: "success"
  702. });
  703. // this.getUsers();
  704. this.getUser()
  705. } else {
  706. this.$message({
  707. message: res.msg,
  708. type: "error"
  709. });
  710. }
  711. },
  712. error => {
  713. this.$message({
  714. message: error,
  715. type: "error"
  716. });
  717. });
  718. },
  719. showDeactiveDialog(item) {
  720. this.deactiveDialog = true;
  721. this.deactiveUser = item;
  722. },
  723. restrictNumber(targetId) {
  724. let inpu = document.getElementById(targetId);
  725. inpu.value = inpu.value.replace(/[^\d.]/g, ""); //仅保留数字和"."
  726. inpu.value = inpu.value.replace(/\.{2,}/g, "."); //两个连续的"."仅保留第一个"."
  727. inpu.value = inpu.value.replace(".", "$#*").replace(/\./g,'').replace('$#*','.');//去除其他"."
  728. inpu.value = inpu.value.replace(/^(\d+)\.(\d\d).*$/, '$1.$2');;//限制只能输入两个小数
  729. if (inpu.value.indexOf(".") < 0 && inpu.value != "") { //首位是0的话去掉
  730. inpu.value = parseFloat(inpu.value);
  731. }
  732. },
  733. showConfirmDialog() {
  734. if (this.toUserId == null || this.toUserId == '') {
  735. this.$message({
  736. message: '请选择要转让的人员',
  737. type: "error"
  738. });
  739. return;
  740. }
  741. this.$confirm("您将失去超级管理员角色,需要重新登录。确定要转让吗?", "提示", {
  742. //type: 'warning'
  743. }).then(() => {
  744. this.http.post('/user/changeSysManager', {
  745. toUserId: this.toUserId,
  746. myRoleId: this.myRoleId
  747. },
  748. res => {
  749. if (res.code == "ok") {
  750. sessionStorage.removeItem("user");
  751. this.$router.push("/login");
  752. } else {
  753. this.$message({
  754. message: res.msg,
  755. type: "error"
  756. });
  757. }
  758. },
  759. error => {
  760. this.$message({
  761. message: error,
  762. type: "error"
  763. });
  764. });
  765. });
  766. },
  767. transferRole() {
  768. this.transferDialog = true;
  769. this.http.post(this.port.manage.list, {
  770. departmentId: -1,
  771. pageIndex: 1,
  772. pageSize: 99999,
  773. keyword: this.keyword
  774. },
  775. res => {
  776. if (res.code == "ok") {
  777. this.allActiveUsers = res.data.records.filter(u=>u.isActive == 1 && u.id != this.user.id);
  778. } else {
  779. this.$message({
  780. message: res.msg,
  781. type: "error"
  782. });
  783. }
  784. },
  785. error => {
  786. this.$message({
  787. message: error,
  788. type: "error"
  789. });
  790. });
  791. },
  792. showExportDialog() {
  793. this.exportDialogVisible = true;
  794. },
  795. exportUsers() {
  796. this.http.post('/user/exportUsers', {
  797. containInvalid: this.containInvalid
  798. },
  799. res => {
  800. if (res.code == "ok") {
  801. this.exportDialogVisible = false;
  802. var aTag = document.createElement('a');
  803. aTag.download = "全部员工列表.xls";
  804. aTag.href = res.data;
  805. aTag.click();
  806. } else {
  807. this.$message({
  808. message: res.msg,
  809. type: "error"
  810. });
  811. }
  812. },
  813. error => {
  814. this.$message({
  815. message: error,
  816. type: "error"
  817. });
  818. });
  819. },
  820. showSalaryList(item) {
  821. this.userSalaryListDialog = true;
  822. this.userSalaryList = [];
  823. this.http.post('/user/getUserSalaryList', {
  824. id: item.id
  825. },
  826. res => {
  827. if (res.code == "ok") {
  828. this.userSalaryList = res.data;
  829. } else {
  830. this.$message({
  831. message: res.msg,
  832. type: "error"
  833. });
  834. }
  835. },
  836. error => {
  837. this.$message({
  838. message: error,
  839. type: "error"
  840. });
  841. });
  842. },
  843. getUsers() {
  844. this.http.post(this.port.manage.list, {
  845. departmentId: -1,
  846. pageIndex: 1,
  847. pageSize: 99999,
  848. keyword: this.keyword
  849. },
  850. res => {
  851. if (res.code == "ok") {
  852. this.users = res.data.records;
  853. } else {
  854. this.$message({
  855. message: res.msg,
  856. type: "error"
  857. });
  858. }
  859. },
  860. error => {
  861. this.$message({
  862. message: error,
  863. type: "error"
  864. });
  865. });
  866. },
  867. onSalaryTypeChange(value) {
  868. if (value == 1) {
  869. this.insertForm.monthCost = null;
  870. }
  871. },
  872. //选中部门
  873. choseDept(value) {
  874. console.log(value);
  875. },
  876. //月成本输入变化
  877. oninput(e) {
  878. this.insertForm.cost = (this.insertForm.monthCost/this.timeType.monthDays/this.timeType.allday).toFixed(2);
  879. },
  880. // 获取本公司的工作时间设置
  881. getCompanyTimeSetting() {
  882. this.http.post('/time-type/getCompanyTimeSetting',{
  883. companyId: this.user.companyId
  884. },
  885. res => {
  886. if (res.code == "ok") {
  887. this.timeType = res.data;
  888. } else {
  889. this.$message({
  890. message: res.msg,
  891. type: "error"
  892. });
  893. }
  894. },
  895. error => {
  896. this.listLoading = false;
  897. this.$message({
  898. message: error,
  899. type: "error"
  900. });
  901. }
  902. );
  903. },
  904. // 批量导入人员
  905. importUser(item) {
  906. //首先判断文件类型
  907. let str = item.file.name.split(".");
  908. let format = str[str.length - 1];
  909. if (format != "xls" && format != "xlsx") {
  910. this.$message({
  911. message: "请选择.xls或.xlsx文件",
  912. type: "error"
  913. });
  914. } else {
  915. this.listLoading = true;
  916. let formData = new FormData();
  917. formData.append("file", item.file);
  918. this.http.uploadFile( this.port.manage.import, formData,
  919. res => {
  920. this.$refs.upload.clearFiles();
  921. this.listLoading = false;
  922. if (res.code == "ok") {
  923. this.$message({
  924. message: "导入成功",
  925. type: "success"
  926. });
  927. //重新读取列表
  928. this.getUser();
  929. } else {
  930. this.$message({
  931. message: res.msg,
  932. type: "error"
  933. });
  934. }
  935. },
  936. error => {
  937. this.$refs.upload.clearFiles();
  938. this.listLoading = false;
  939. this.$message({
  940. message: error,
  941. type: "error"
  942. });
  943. });
  944. }
  945. },
  946. //分页
  947. handleCurrentChange(val) {
  948. this.page = val;
  949. this.getUser();
  950. },
  951. handleSizeChange(val) {
  952. this.size = val;
  953. this.getUser();
  954. },
  955. //获取所有员工的列表
  956. getUser() {
  957. console.log(12345)
  958. this.listLoading = true;
  959. this.http.post( this.port.manage.list, {
  960. departmentId: this.depData.id,
  961. pageIndex: this.page,
  962. pageSize: this.size,
  963. keyword: this.keyword,
  964. status: this.status,
  965. // role: this.role
  966. roleId: this.roleId
  967. },
  968. res => {
  969. this.listLoading = false;
  970. if (res.code == "ok") {
  971. this.list = res.data.records;
  972. this.total = res.data.total;
  973. } else {
  974. this.$message({
  975. message: res.msg,
  976. type: "error"
  977. });
  978. }
  979. },
  980. error => {
  981. this.listLoading = false;
  982. this.$message({
  983. message: error,
  984. type: "error"
  985. });
  986. });
  987. },
  988. resetPwd(user) {
  989. this.$confirm( "确定要为" + user.name + "重置密码吗?", "重置密码", {
  990. confirmButtonText: "确定",
  991. cancelButtonText: "取消",
  992. type: "warning"
  993. })
  994. .then(() => {
  995. this.http.post('/user/resetPwd', { userId: user.id },
  996. res => {
  997. if (res.code == "ok") {
  998. this.$message({
  999. message: "密码已重置为000000,请通知员工及时修改",
  1000. type: "success"
  1001. });
  1002. } else {
  1003. this.$message({
  1004. message: res.msg,
  1005. type: "error"
  1006. });
  1007. }
  1008. },
  1009. error => {
  1010. this.listLoading = false;
  1011. this.$message({
  1012. message: error,
  1013. type: "error"
  1014. });
  1015. });
  1016. })
  1017. .catch(() => {});
  1018. },
  1019. // 新增、编辑人员
  1020. openInsertDialog(i) {
  1021. if (i != null) {
  1022. var list = JSON.parse(JSON.stringify(this.list[i])) , arr = [] , array = [];
  1023. if(list.departmentCascade!='0' && list.departmentCascade!=null) {
  1024. if(list.departmentCascade.indexOf(",")>-1) {
  1025. arr = list.departmentCascade.split(",");
  1026. } else {
  1027. arr = [].concat(list.departmentCascade)
  1028. }
  1029. }
  1030. for(var i in arr) {
  1031. array.push(parseInt(arr[i]))
  1032. }
  1033. this.insertForm = {
  1034. id: list.id,
  1035. name: list.name,
  1036. phone: list.phone,
  1037. // role: list.role,
  1038. roleId: list.roleId,
  1039. monthCost:list.monthCost,
  1040. cost: list.cost,
  1041. departmentId: array.reverse(),
  1042. salaryType: list.salaryType,
  1043. costApplyDate: list.costApplyDate,
  1044. };
  1045. this.title = "编辑人员"
  1046. } else {
  1047. this.insertForm = {
  1048. id: null,
  1049. name: null,
  1050. phone: null,
  1051. // role: null,
  1052. roleId: null,
  1053. monthCost:null,
  1054. cost: null,
  1055. departmentId: null,
  1056. salaryType:0,
  1057. costApplyDate: util.formatDate.format(new Date(), 'yyyy-MM-dd'),
  1058. };
  1059. this.title = "新增人员"
  1060. }
  1061. this.dialogVisible = true;
  1062. },
  1063. submitInsert() {
  1064. var form = {}
  1065. this.$refs.form1.validate(valid => {
  1066. if (valid) {
  1067. this.submitLoading = true;
  1068. form = {
  1069. name: this.insertForm.name,
  1070. phone: this.insertForm.phone,
  1071. // role: this.insertForm.role,
  1072. roleId: this.insertForm.roleId,
  1073. monthCost: this.insertForm.monthCost,
  1074. cost: this.insertForm.cost,
  1075. salaryType: this.insertForm.salaryType,
  1076. };
  1077. if (this.insertForm.id != null) {
  1078. form.id = this.insertForm.id;
  1079. }
  1080. if (this.insertForm.costApplyDate != null) {
  1081. form.costApplyDate = this.insertForm.costApplyDate;
  1082. }
  1083. if (this.insertForm.departmentId != null) {
  1084. form.departmentId = this.insertForm.departmentId[this.insertForm.departmentId.length-1];
  1085. }
  1086. }
  1087. });
  1088. console.log(form, '提交的数据')
  1089. if(this.permissions.structurePersonnel && this.title == '编辑人员') {
  1090. this.from.cost = 0
  1091. this.from.monthCost = 0
  1092. }
  1093. // return
  1094. this.http.post( this.port.manage.insert, form,
  1095. res => {
  1096. this.submitLoading = false;
  1097. if (res.code == "ok") {
  1098. this.$message({
  1099. message: this.insertForm.id != null ? "修改" : "创建" + "成功",
  1100. type: "success"
  1101. });
  1102. this.dialogVisible = false;
  1103. this.getUser();
  1104. this.getUsers()
  1105. } else {
  1106. this.$message({
  1107. message: res.msg,
  1108. type: "error"
  1109. });
  1110. }
  1111. },
  1112. error => {
  1113. this.listLoading = false;
  1114. this.$message({
  1115. message: error,
  1116. type: "error"
  1117. });
  1118. });
  1119. },
  1120. // 切换角色
  1121. switchRole(index) {
  1122. this.listLoading = true;
  1123. this.http.post( this.port.manage.permission, { id: this.list[index].id },
  1124. res => {
  1125. this.listLoading = false;
  1126. if (res.code == "ok") {
  1127. this.$message({
  1128. message: "切换角色成功",
  1129. type: "success"
  1130. });
  1131. //重新读取列表
  1132. this.getUser();
  1133. } else {
  1134. this.$message({
  1135. message: res.msg,
  1136. type: "error"
  1137. });
  1138. }
  1139. },
  1140. error => {
  1141. this.listLoading = false;
  1142. this.$message({
  1143. message: error,
  1144. type: "error"
  1145. });
  1146. });
  1147. },
  1148. // 删除用户
  1149. setActive(item, isActive) {
  1150. var txt = isActive==1?"启用":"停用";
  1151. this.$confirm( "确定要"+txt +" " + item.name + " 吗?", "账号"+txt, {
  1152. confirmButtonText: "确定",
  1153. cancelButtonText: "取消",
  1154. type: "warning"
  1155. })
  1156. .then(() => {
  1157. this.listLoading = true;
  1158. this.http.post('/user/setActive', { id: item.id, isActive: isActive},
  1159. res => {
  1160. this.listLoading = false;
  1161. if (res.code == "ok") {
  1162. this.$message({
  1163. message: txt+"成功",
  1164. type: "success"
  1165. });
  1166. //重新读取列表
  1167. this.getUser();
  1168. } else {
  1169. this.$message({
  1170. message: res.msg,
  1171. type: "error"
  1172. });
  1173. }
  1174. },
  1175. error => {
  1176. this.listLoading = false;
  1177. this.$message({
  1178. message: error,
  1179. type: "error"
  1180. });
  1181. });
  1182. })
  1183. .catch(() => {});
  1184. },
  1185. // 修改老板的成本
  1186. openInsertDialog1(i) {
  1187. var list1 = JSON.parse(JSON.stringify(this.list[i])) , arr1 = [] , array1 = [];
  1188. if(list1.departmentCascade!='0' && list1.departmentCascade!=null) {
  1189. if(list1.departmentCascade.indexOf(",")>-1) {
  1190. arr1 = list1.departmentCascade.split(",");
  1191. } else {
  1192. arr1 = [].concat(list1.departmentCascade)
  1193. }
  1194. }
  1195. for(var i in arr1) {
  1196. array1.push(parseInt(arr1[i]))
  1197. }
  1198. console.log(list1)
  1199. this.insertForm = {
  1200. id: list1.id,
  1201. name: list1.name,
  1202. phone: list1.phone,
  1203. role: list1.role,
  1204. monthCost:list1.monthCost,
  1205. cost: list1.cost,
  1206. departmentId: array1.reverse(),
  1207. salaryType: list1.salaryType,
  1208. name: list1.name
  1209. };
  1210. this.dialogVisible1 = true;
  1211. },
  1212. submitInsert1() {
  1213. var form = {}
  1214. this.$refs.form1.validate(valid => {
  1215. if (valid) {
  1216. this.submitLoading = true;
  1217. form = {
  1218. id: this.insertForm.id,
  1219. name: this.insertForm.name,
  1220. phone: this.insertForm.phone,
  1221. // role: this.insertForm.role,
  1222. roleId: this.insertForm.roleId,
  1223. monthCost: this.insertForm.monthCost,
  1224. cost: this.insertForm.cost
  1225. };
  1226. if (this.insertForm.departmentId != null) {
  1227. form.departmentId = this.insertForm.departmentId[this.insertForm.departmentId.length-1];
  1228. }
  1229. if (this.insertForm.costApplyDate != null) {
  1230. form.costApplyDate = this.insertForm.costApplyDate;
  1231. }
  1232. }
  1233. });
  1234. this.http.post( this.port.manage.insert, form,
  1235. res => {
  1236. this.submitLoading = false;
  1237. if (res.code == "ok") {
  1238. this.$message({
  1239. message: "修改成功",
  1240. type: "success"
  1241. });
  1242. this.dialogVisible1 = false;
  1243. //重新读取列表
  1244. this.getUser();
  1245. this.getUsers()
  1246. } else {
  1247. this.$message({
  1248. message: res.msg,
  1249. type: "error"
  1250. });
  1251. }
  1252. },
  1253. error => {
  1254. this.listLoading = false;
  1255. this.$message({
  1256. message: error,
  1257. type: "error"
  1258. });
  1259. });
  1260. },
  1261. // 获取部门列表
  1262. getDepartment() {
  1263. this.http.post( this.port.manage.depList, {},
  1264. res => {
  1265. if (res.code == "ok") {
  1266. var list = res.data , list1 = JSON.parse(JSON.stringify(res.data));
  1267. list.splice(0,0,{
  1268. id: -1,
  1269. label: '全部人员',
  1270. })
  1271. list.push({
  1272. id: 0,
  1273. label: '未分配',
  1274. })
  1275. this.data = list;
  1276. console.log(list, "部门数据")
  1277. this.option = this.changeArr(list1);
  1278. } else {
  1279. this.$message({
  1280. message: res.msg,
  1281. type: "error"
  1282. });
  1283. }
  1284. },
  1285. error => {
  1286. this.$message({
  1287. message: error,
  1288. type: "error"
  1289. });
  1290. });
  1291. },
  1292. // 修改数组
  1293. changeArr(arr) {
  1294. for (var i = 0; i < arr.length; i++) {
  1295. if(arr[i].id != -1 && arr[i].id != 0) {
  1296. if (arr[i].children != null && arr[i].children.length>0) {
  1297. arr[i].children = this.changeArr(arr[i].children);
  1298. }
  1299. arr[i].id && (arr[i].value = arr[i].id);
  1300. delete arr[i].id;
  1301. }
  1302. }
  1303. for(var i in arr) {
  1304. if(arr[i].id == -1 || arr[i].id == 0) {
  1305. arr.splice(i,1)
  1306. }
  1307. }
  1308. return arr;
  1309. },
  1310. // 部门列表点击
  1311. handleNodeClick(data) {
  1312. console.log(data, 999)
  1313. if(this.depData == null || data.id != this.depData.id) {
  1314. this.depData = data;
  1315. this.page = 1;
  1316. this.getUser();
  1317. }
  1318. },
  1319. // 新增、修改部门
  1320. createDepartment(i) {
  1321. setTimeout(() => {
  1322. var that = this
  1323. if(i == -2) {//创建子部门
  1324. that.depForm = {
  1325. id: null,
  1326. name: null,
  1327. parentId: null,
  1328. managerId: null,
  1329. }
  1330. if(that.depData.id != -1 && that.depData.id != 0) {
  1331. that.depForm.parentId = that.depData.id;
  1332. }
  1333. that.depTitle = "新增子部门";
  1334. } else if(i == -1) {//创建一级部门
  1335. that.depForm = {
  1336. id: null,
  1337. name: null,
  1338. parentId: null,
  1339. managerId: null,
  1340. }
  1341. that.depTitle = "新增部门";
  1342. } else {
  1343. if(that.depData.managerId == "null") {
  1344. that.depData.managerId = ''
  1345. }
  1346. if(that.depData.reportAuditUserid == "null") {
  1347. that.depData.reportAuditUserid = ''
  1348. }
  1349. that.depForm = {
  1350. id: that.depData.id,
  1351. name: that.depData.label,
  1352. parentId: that.depData.parentId,
  1353. managerId: that.depData.managerId,
  1354. reportAuditUserid: that.depData.reportAuditUserid
  1355. }
  1356. // if(that.depData.reportAuditUserid != null && that.depData.reportAuditUserid != "null" && that.depData.reportAuditUserid.length > 0) {
  1357. // that.depForm.reportAuditUserid = that.depData.reportAuditUserid
  1358. // }
  1359. that.depTitle = "编辑部门";
  1360. }
  1361. that.departmentVisible = true;
  1362. })
  1363. // if(i == -2) {//创建子部门
  1364. // this.depForm = {
  1365. // id: null,
  1366. // name: null,
  1367. // parentId: null,
  1368. // managerId: null,
  1369. // }
  1370. // if(this.depData.id != -1 && this.depData.id != 0) {
  1371. // this.depForm.parentId = this.depData.id;
  1372. // }
  1373. // this.depTitle = "新增子部门";
  1374. // } else if(i == -1) {//创建一级部门
  1375. // this.depForm = {
  1376. // id: null,
  1377. // name: null,
  1378. // parentId: null,
  1379. // managerId: null,
  1380. // }
  1381. // this.depTitle = "新增部门";
  1382. // } else {
  1383. // if(this.depData.managerId == "null") {
  1384. // this.depData.managerId = ''
  1385. // }
  1386. // if(this.depData.reportAuditUserid == "null") {
  1387. // this.depData.reportAuditUserid = ''
  1388. // }
  1389. // this.depForm = {
  1390. // id: this.depData.id,
  1391. // name: this.depData.label,
  1392. // parentId: this.depData.parentId,
  1393. // managerId: this.depData.managerId,
  1394. // reportAuditUserid: this.depData.reportAuditUserid
  1395. // }
  1396. // // if(this.depData.reportAuditUserid != null && this.depData.reportAuditUserid != "null" && this.depData.reportAuditUserid.length > 0) {
  1397. // // this.depForm.reportAuditUserid = this.depData.reportAuditUserid
  1398. // // }
  1399. // this.depTitle = "编辑部门";
  1400. // }
  1401. // this.departmentVisible = true;
  1402. },
  1403. submitDepartment() {
  1404. this.$refs.depForm.validate(valid => {
  1405. if (valid) {
  1406. var form = {
  1407. name: this.depForm.name,
  1408. };
  1409. if(this.depForm.id != null) {
  1410. form.id = this.depForm.id
  1411. }
  1412. if(this.depForm.parentId != null) {
  1413. form.parentId = this.depForm.parentId
  1414. }
  1415. if (this.depForm.managerId) {
  1416. form.managerId = this.depForm.managerId
  1417. }
  1418. console.log(this.depForm)
  1419. if (this.depForm.reportAuditUserid) {
  1420. form.reportAuditUserid = this.depForm.reportAuditUserid
  1421. }
  1422. this.http.post( this.depForm.id==null?this.port.manage.add:this.port.manage.edit, form,
  1423. res => {
  1424. if (res.code == "ok") {
  1425. this.$message({
  1426. message: this.depForm.id==null?"新增成功":"修改成功",
  1427. type: "success"
  1428. });
  1429. this.departmentVisible = false;
  1430. if (this.depForm.id !=null) {
  1431. this.depData.label = form.name;
  1432. this.depData.managerId = form.managerId;
  1433. }
  1434. this.getDepartment();
  1435. } else {
  1436. this.$message({
  1437. message: res.msg,
  1438. type: "error"
  1439. });
  1440. }
  1441. },
  1442. error => {
  1443. this.listLoading = false;
  1444. this.$message({
  1445. message: error,
  1446. type: "error"
  1447. });
  1448. });
  1449. }
  1450. });
  1451. },
  1452. // 删除部门
  1453. deleteDep() {
  1454. var that = this
  1455. setTimeout(() =>{
  1456. that.$confirm( "确定要删除部门" + that.depData.label + "吗?", "删除部门", {
  1457. confirmButtonText: "确定",
  1458. cancelButtonText: "取消",
  1459. type: "warning"
  1460. })
  1461. .then(() => {
  1462. that.listLoading = true;
  1463. that.http.post( that.port.manage.del, { id: that.depData.id },
  1464. res => {
  1465. that.listLoading = false;
  1466. if (res.code == "ok") {
  1467. that.$message({
  1468. message: "删除成功",
  1469. type: "success"
  1470. });
  1471. that.depData = {
  1472. id: -1,
  1473. label: '全部人员',
  1474. }
  1475. that.getDepartment();
  1476. that.getUser();
  1477. } else {
  1478. that.$message({
  1479. message: res.msg,
  1480. type: "error"
  1481. });
  1482. }
  1483. },
  1484. error => {
  1485. that.listLoading = false;
  1486. that.$message({
  1487. message: error,
  1488. type: "error"
  1489. });
  1490. });
  1491. })
  1492. .catch(() => {});
  1493. },100);
  1494. // this.$confirm( "确定要删除部门" + this.depData.label + "吗?", "删除部门", {
  1495. // confirmButtonText: "确定",
  1496. // cancelButtonText: "取消",
  1497. // type: "warning"
  1498. // })
  1499. // .then(() => {
  1500. // this.listLoading = true;
  1501. // this.http.post( this.port.manage.del, { id: this.depData.id },
  1502. // res => {
  1503. // this.listLoading = false;
  1504. // if (res.code == "ok") {
  1505. // this.$message({
  1506. // message: "删除成功",
  1507. // type: "success"
  1508. // });
  1509. // this.depData = {
  1510. // id: -1,
  1511. // label: '全部人员',
  1512. // }
  1513. // this.getDepartment();
  1514. // this.getUser();
  1515. // } else {
  1516. // this.$message({
  1517. // message: res.msg,
  1518. // type: "error"
  1519. // });
  1520. // }
  1521. // },
  1522. // error => {
  1523. // this.listLoading = false;
  1524. // this.$message({
  1525. // message: error,
  1526. // type: "error"
  1527. // });
  1528. // });
  1529. // })
  1530. // .catch(() => {});
  1531. },
  1532. // 关键搜索
  1533. searchList() {
  1534. console.log(this.keyword)
  1535. this.listLoading = true;
  1536. this.http.post( this.port.manage.list, {
  1537. departmentId: this.depData.id,
  1538. pageIndex: this.page,
  1539. pageSize: this.size,
  1540. keyword: this.keyword
  1541. },
  1542. res => {
  1543. this.listLoading = false;
  1544. if (res.code == "ok") {
  1545. this.list = res.data.records;
  1546. this.total = res.data.total;
  1547. } else {
  1548. this.$message({
  1549. message: res.msg,
  1550. type: "error"
  1551. });
  1552. }
  1553. },
  1554. error => {
  1555. this.listLoading = false;
  1556. this.$message({
  1557. message: error,
  1558. type: "error"
  1559. });
  1560. });
  1561. },
  1562. // 获取角色
  1563. acquireRole() {
  1564. // this.http.post('/permission/getFrontRoleList', {
  1565. this.http.post('/permission/getFrontRoleList', {
  1566. companyId: this.user.companyId
  1567. },
  1568. res => {
  1569. if (res.code == "ok") {
  1570. console.log(res.data, '获取角色')
  1571. this.acquireRoleList = res.data
  1572. var arr = []
  1573. for(var i in res.data) {
  1574. if(res.data[i].rolename != '系统管理员') {
  1575. arr.push(res.data[i])
  1576. }
  1577. }
  1578. this.acquireRoleLists = arr
  1579. } else {
  1580. this.$message({
  1581. message: res.msg,
  1582. type: "error"
  1583. });
  1584. }
  1585. },
  1586. error => {
  1587. this.$message({
  1588. message: error,
  1589. type: "error"
  1590. });
  1591. });
  1592. }
  1593. },
  1594. created() {
  1595. let height = window.innerHeight;
  1596. this.tableHeight = height - 195;
  1597. const that = this;
  1598. window.onresize = function temp() {
  1599. that.tableHeight = window.innerHeight - 195;
  1600. };
  1601. },
  1602. mounted() {
  1603. this.deactiveDate = util.formatDate.format(new Date(), 'yyyy-MM-dd');
  1604. this.getDepartment();
  1605. this.getUser();
  1606. this.getCompanyTimeSetting();
  1607. this.getUsers();
  1608. this.acquireRole();
  1609. this.isDingShow = this.$store.state.isDing;
  1610. }
  1611. };
  1612. </script>
  1613. <style lang="scss" scoped>
  1614. .custom-tree-node {
  1615. flex: 1;
  1616. display: flex;
  1617. align-items: center;
  1618. justify-content: space-between;
  1619. font-size: 14px;
  1620. padding-right: 8px;
  1621. }
  1622. .left {
  1623. border-right: 1px solid #f2f2f2;
  1624. overflow: hidden;
  1625. .department {
  1626. background:#f2f2f2;
  1627. line-height: 60px;
  1628. color:#666;
  1629. padding:0 10px;
  1630. height:60px;
  1631. font-size: 15px;
  1632. div {
  1633. float: right;
  1634. color: #20a0ff;
  1635. font-size: 14px;
  1636. cursor: pointer;
  1637. }
  1638. }
  1639. .tree {
  1640. overflow: auto;
  1641. }
  1642. }
  1643. .nowTime {
  1644. height: 40px;
  1645. line-height: 40px;
  1646. font-size: 16px;
  1647. color: #20a0ff;
  1648. margin-left: 10px;
  1649. cursor: pointer;
  1650. i {
  1651. margin-right: 10px;
  1652. }
  1653. }
  1654. .none {
  1655. display: none;
  1656. }
  1657. .block {
  1658. display: block;
  1659. }
  1660. </style>
  1661. <style lang="scss">
  1662. .tree {
  1663. .el-tree-node__label {
  1664. overflow-x: hidden;
  1665. white-space: nowrap;
  1666. text-overflow: ellipsis;
  1667. }
  1668. }
  1669. .el-divider--horizontal {
  1670. margin: 0px;
  1671. background:#f3f3f3;
  1672. }
  1673. //全局的作用范围
  1674. .el-tree-node__content {
  1675. height:36px;
  1676. }
  1677. </style>