index.vue 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250
  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. </div>
  15. </el-col>
  16. <el-col :span="20" class="right">
  17. <!--工具条-->
  18. <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  19. <el-form :inline="true">
  20. <!-- <div style="width: 300px;display: inline-block;">
  21. <el-input v-model="keyword" class="input-with-select" placeholder="请输入人员名字搜索" clearable="true">
  22. <el-button slot="append" @click="searchList" icon="el-icon-search"></el-button>
  23. </el-input>
  24. </div> -->
  25. <el-form-item>
  26. <div v-if="depData == null || depData.id == -1" class="nowTime" style="cursor:unset">
  27. <i class="fa fa-home"></i>全部人员
  28. </div>
  29. <div v-else-if="depData.id == 0" class="nowTime" style="cursor:unset">
  30. <i class="fa fa-home"></i>未分配
  31. </div>
  32. <div v-else-if="depData != null && depData.id != -1 && depData.id != 0" class="nowTime" @click="createDepartment(0)">
  33. <i class="fa fa-pencil-square-o"></i>
  34. {{depData!=null?depData.label:''}}
  35. </div>
  36. </el-form-item>
  37. <el-form-item>
  38. <div style="color:#999;font-size:13px;">共{{total}}人</div>
  39. </el-form-item>
  40. <el-form-item style="float:right;">
  41. <el-link type="primary" :underline="false" @click="showExportDialog">导出人员</el-link>
  42. </el-form-item>
  43. <el-form-item style="float:right;">
  44. <el-link type="primary" :underline="false" @click="openInsertDialog(null)">添加人员</el-link>
  45. </el-form-item>
  46. <el-form-item style="float:right;" v-if="depData != null && depData.id != -1 && depData.id != 0">
  47. <el-upload ref="upload" action="#" :limit="1" :http-request="importUser" :show-file-list="false">
  48. <el-link type="primary" :underline="false">批量导入</el-link>
  49. </el-upload>
  50. </el-form-item>
  51. <el-form-item style="float:right;">
  52. <el-link type="primary" :underline="false" href="./upload/人员导入模板.xlsx" download="人员导入模板.xlsx">模板下载</el-link>
  53. </el-form-item>
  54. <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;">
  55. </el-form-item>
  56. <el-form-item style="float:right;">
  57. <el-link type="danger" v-if="depData != null && depData.id != -1 && depData.id != 0" :underline="false" @click="deleteDep(null)">删除部门</el-link>
  58. </el-form-item>
  59. <el-form-item style="float:right;">
  60. <el-link type="primary" v-if="depData != null && depData.id != -1 && depData.id != 0" :underline="false" @click="createDepartment(-2)">新增子部门</el-link>
  61. </el-form-item>
  62. <el-form-item style="float:right;">
  63. <div style="width: 300px;display: inline-block;">
  64. <el-input v-model="keyword" class="input-with-select" placeholder="请输入人员名字搜索" clearable="true">
  65. <el-button slot="append" @click="searchList" icon="el-icon-search"></el-button>
  66. </el-input>
  67. </div>
  68. </el-form-item>
  69. </el-form>
  70. </el-col>
  71. <!--列表-->
  72. <el-table :data="list" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;">
  73. <el-table-column type="index" width="50">
  74. <template slot-scope="scope" >
  75. {{scope.$index+1+(page-1)*size}}
  76. </template>
  77. </el-table-column>
  78. <el-table-column prop="name" label="姓名" sortable></el-table-column>
  79. <el-table-column prop="phone" label="手机" width="120"></el-table-column>
  80. <el-table-column prop="departmentName" label="部门" sortable></el-table-column>
  81. <el-table-column label="角色" width="100">
  82. <template slot-scope="scope">{{roleArray[scope.row.role]}}</template>
  83. </el-table-column>
  84. <el-table-column prop="monthCost" label="月成本" sortable>
  85. <template slot-scope="scope">{{scope.row.monthCost==null?0:scope.row.monthCost}} 元</template>
  86. </el-table-column>
  87. <el-table-column prop="cost" label="时薪" sortable>
  88. <template slot-scope="scope">{{scope.row.cost==null?0:scope.row.cost}} 元
  89. <el-link @click.native="showSalaryList(scope.row)"><i class="iconfont firerock-iconrecord"></i></el-link>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="操作" width="280">
  93. <template slot-scope="scope">
  94. <!-- <el-button size="small" v-if="scope.row.role == 0 && user.role == 1" @click="switchRole(scope.$index)">切换为管理员</el-button>
  95. <el-button size="small" v-if="scope.row.role == 2 && user.role == 1" @click="switchRole(scope.$index)">切换为员工</el-button> -->
  96. <el-button size="mini" type="default" v-if="scope.row.role == 1 && user.role == 1" @click="transferRole(scope.row)">转让</el-button>
  97. <el-button size="mini" type="default" v-if="scope.row.role != 1" @click="resetPwd(scope.row)">重置</el-button>
  98. <el-button size="mini" type="primary" v-if="scope.row.role != 1" @click="openInsertDialog(scope.$index)">编辑</el-button>
  99. <el-button size="mini" type="primary" v-if="scope.row.role == 1" @click="openInsertDialog1(scope.$index)">编辑</el-button>
  100. <el-button size="mini" type="default" v-if="scope.row.role != 1 && scope.row.isActive==1" @click="showDeactiveDialog(scope.row)">停用</el-button>
  101. <el-button size="mini" type="success" v-if="scope.row.role != 1 && scope.row.isActive==0" @click="setActive(scope.row, 1)">启用</el-button>
  102. </template>
  103. </el-table-column>
  104. </el-table>
  105. <!--工具条-->
  106. <el-col :span="24" class="toolbar">
  107. <el-pagination
  108. @size-change="handleSizeChange"
  109. @current-change="handleCurrentChange"
  110. :page-sizes="[20 , 50 , 80 , 100]"
  111. :page-size="size"
  112. layout="total, sizes, prev, pager, next"
  113. :total="total"
  114. style="float:right;"
  115. ></el-pagination>
  116. </el-col>
  117. </el-col>
  118. <!-- 新增部门 -->
  119. <el-dialog :title="depTitle" :visible.sync="departmentVisible" width="400px" >
  120. <el-form ref="depForm" :model="depForm" :rules="depRules" label-width="80px">
  121. <el-form-item label="部门名称" prop="name">
  122. <el-input v-model="depForm.name" placeholder="请输入部门名称" clearable></el-input>
  123. </el-form-item>
  124. <el-form-item label="负责人" prop="managerId">
  125. <el-select v-model="depForm.managerId" filterable clearable placeholder="请选择部门负责人" >
  126. <el-option v-for="item in users" :key="item.id" :label="item.name" :value="item.id"></el-option>
  127. </el-select>
  128. </el-form-item>
  129. </el-form>
  130. <span slot="footer" class="dialog-footer">
  131. <el-button @click="departmentVisible = false">取消</el-button>
  132. <el-button type="primary" @click="submitDepartment">提交</el-button>
  133. </span>
  134. </el-dialog>
  135. <!-- 新增单个人员的Dialog -->
  136. <el-dialog :title="title" :visible.sync="dialogVisible" width="550px" >
  137. <el-form ref="form1" :model="insertForm" :rules="rules" label-width="80px">
  138. <el-form-item label="名字" prop="name">
  139. <el-input v-model="insertForm.name" placeholder="请输入姓名" clearable></el-input>
  140. </el-form-item>
  141. <el-form-item label="电话" prop="phone">
  142. <el-input v-model="insertForm.phone" placeholder="请输入电话号码" clearable></el-input>
  143. </el-form-item>
  144. <el-form-item label="薪酬方式" prop="salaryType">
  145. <el-radio-group v-model="insertForm.salaryType" @change="onSalaryTypeChange">
  146. <el-radio :label="0" >固定月成本</el-radio>
  147. <el-radio :label="1">计时工资</el-radio>
  148. </el-radio-group>
  149. </el-form-item>
  150. <el-form-item label="月成本" prop="monthCost" v-if="insertForm.salaryType == 0">
  151. <el-input v-model="insertForm.monthCost" id="mc" @input="oninput" placeholder="请输入月成本,单位:元" clearable @keyup.native="restrictNumber('mc')"></el-input>
  152. <span style="color:orange;font-size:12px;">按照每个月工作{{timeType.monthDays}}天,每天{{timeType.allday}}小时预估时薪</span>
  153. <el-link :underline="false" style="color:blue;font-size:12px;margin-left:7px;" href="#/timetype">修改工作时长</el-link>
  154. </el-form-item>
  155. <el-form-item label="时薪" prop="cost">
  156. <el-input v-model="insertForm.cost" :disabled="insertForm.salaryType == 0" id="cc" style="width:120px;" @keyup.native="restrictNumber('cc')"
  157. placeholder="请输入成本 单位:元/小时" clearable></el-input>
  158. <span style="margin-left:25px;">生效日期</span>
  159. <el-date-picker v-model="insertForm.costApplyDate" value-format="yyyy-MM-dd"></el-date-picker>
  160. </el-form-item>
  161. <el-form-item label="部门" prop="departmentId">
  162. <el-cascader v-model="insertForm.departmentId" placeholder="请选择部门" style="width: 100%"
  163. :options="option" :props="{ checkStrictly: false,expandTrigger: 'hover' }" :show-all-levels="false" clearable></el-cascader>
  164. </el-form-item>
  165. <el-form-item label="角色" prop="role">
  166. <el-select v-model="insertForm.role" placeholder="请选择角色" style="width: 100%">
  167. <!-- <el-option label="普通员工" :value="0">
  168. <span style="float: left">普通员工</span>
  169. <span style="float: right; color: #8492a6; font-size: 13px">具有填报日报,参与项目协作基础功能</span>
  170. </el-option>
  171. <el-option label="系统管理员" :value="2" :disabled="user.role != 1">
  172. <span style="float: left">普通员工</span>
  173. <span style="float: right; color: #8492a6; font-size: 13px">具有填报日报,参与项目协作基础功能</span>
  174. </el-option>
  175. <el-option label="公司高层" :value="3"></el-option>
  176. <el-option label="人事管理员" :value="4"></el-option>
  177. <el-option label="项目管理员" :value="5"></el-option> -->
  178. <el-option v-for="item in roleDescArray" :label="item.label" :disabled="item.value==2&&user.role != 1" :value="item.value" :key="item.name">
  179. <span style="float: left">{{item.label}}</span>
  180. <span style="float: right; color: #8492a6; font-size: 13px">{{item.desc}}</span>
  181. </el-option>
  182. </el-select>
  183. </el-form-item>
  184. </el-form>
  185. <span slot="footer" class="dialog-footer">
  186. <el-button @click="dialogVisible=false">取消</el-button>
  187. <el-button type="primary" @click="submitInsert">提交</el-button>
  188. </span>
  189. </el-dialog>
  190. <el-dialog title="修改成本" :visible.sync="dialogVisible1" width="550px" >
  191. <el-form ref="form1" :model="insertForm" :rules="rules" label-width="80px">
  192. <el-form-item label="薪酬方式" prop="salaryType">
  193. <el-radio-group v-model="insertForm.salaryType" @change="onSalaryTypeChange">
  194. <el-radio :label="0" >固定月成本</el-radio>
  195. <el-radio :label="1">计时工资</el-radio>
  196. </el-radio-group>
  197. </el-form-item>
  198. <el-form-item label="月成本" prop="monthCost" v-if="insertForm.salaryType == 0">
  199. <el-input v-model="insertForm.monthCost" id="monthCost" @input="oninput" @keyup.native="restrictNumber('monthCost')" placeholder="请输入月成本,单位:元" clearable></el-input>
  200. <span style="color:orange;font-size:12px;">按照每个月工作{{timeType.monthDays}}天,每天{{timeType.allday}}小时预估时薪</span>
  201. <el-link :underline="false" style="color:blue;font-size:12px;margin-left:7px;" href="#/timetype">修改工作时长</el-link>
  202. </el-form-item>
  203. <el-form-item label="时薪" prop="cost">
  204. <el-input v-model="insertForm.cost" id="cost" :disabled="insertForm.salaryType == 0" @keyup.native="restrictNumber('cost')" style="width:120px;"
  205. placeholder="请输入成本 单位:元/小时" clearable></el-input>
  206. <span style="margin-left:25px;">生效日期</span>
  207. <el-date-picker v-model="insertForm.costApplyDate" value-format="yyyy-MM-dd"></el-date-picker>
  208. </el-form-item>
  209. <el-form-item label="部门" prop="departmentId">
  210. <el-cascader v-model="insertForm.departmentId"
  211. placeholder="请选择部门"
  212. style="width: 100%"
  213. :options="option"
  214. :props="{ checkStrictly: false,expandTrigger: 'hover' }" :show-all-levels="false"
  215. clearable></el-cascader>
  216. </el-form-item>
  217. </el-form>
  218. <span slot="footer" class="dialog-footer">
  219. <el-button @click="dialogVisible1=false">取消</el-button>
  220. <el-button type="primary" @click="submitInsert1">提交</el-button>
  221. </span>
  222. </el-dialog>
  223. <el-dialog title="人员历史成本" :visible.sync="userSalaryListDialog" width="550px" >
  224. <el-table :data="userSalaryList" highlight-current-row v-loading="listLoading" height="300px" style="width: 100%;">
  225. <el-table-column prop="userName" label="姓名" ></el-table-column>
  226. <el-table-column prop="indate" label="更新时间" width="150px">
  227. </el-table-column>
  228. <el-table-column prop="salaryType" label="薪酬方式" >
  229. <template slot-scope="scope" >
  230. {{scope.row.salaryType==0?"固定月薪":"计时工资"}}
  231. </template>
  232. </el-table-column>
  233. <el-table-column prop="monthCost" label="月薪" >
  234. <template slot-scope="scope" >
  235. {{scope.row.monthCost}}元
  236. </template>
  237. </el-table-column>
  238. <el-table-column prop="cost" label="时薪" >
  239. <template slot-scope="scope" >
  240. {{scope.row.cost}}元
  241. </template>
  242. </el-table-column>
  243. </el-table>
  244. </el-dialog>
  245. <!--导出人员 -->
  246. <el-dialog title="导出人员列表" :visible.sync="exportDialogVisible" width="550px" >
  247. <el-form label-width="100px">
  248. <el-form-item label="导出" >
  249. <el-radio-group v-model="containInvalid" >
  250. <el-radio :label="1" >全部人员</el-radio>
  251. <el-radio :label="0" >仅活跃人员</el-radio>
  252. </el-radio-group>
  253. </el-form-item>
  254. </el-form>
  255. <span slot="footer" class="dialog-footer">
  256. <el-button type="primary" @click="exportUsers">导出</el-button>
  257. </span>
  258. </el-dialog>
  259. <!-- 转让超级管理员权限 -->
  260. <el-dialog title="权限转让" :visible.sync="transferDialog" width="550px" >
  261. <el-form label-width="200px">
  262. <el-form-item label="转让超级管理员角色至" >
  263. <el-select v-model="toUserId" style="width:300px" filterable clearable>
  264. <el-option v-for="item in allActiveUsers" :key="item.id" :value="item.id" :label="item.name">
  265. </el-option>
  266. </el-select>
  267. </el-form-item>
  268. <el-form-item label="转让后自己的角色" >
  269. <el-select v-model="myRoleId" style="width:300px">
  270. <el-option v-for="item in roleDescArray" :label="item.label" :value="item.value" :key="item.name">
  271. <span style="float: left">{{item.label}}</span>
  272. <span style="float: right; color: #8492a6; font-size: 13px">{{item.desc}}</span>
  273. </el-option>
  274. </el-select>
  275. </el-form-item>
  276. </el-form>
  277. <span slot="footer" class="dialog-footer">
  278. <el-button type="default" @click="transferDialog = false">取消</el-button>
  279. <el-button type="primary" @click="showConfirmDialog">确定</el-button>
  280. </span>
  281. </el-dialog>
  282. <!--停用时选择日期 -->
  283. <el-dialog title="离职停用员工" :visible.sync="deactiveDialog" width="550px" >
  284. <el-form label-width="200px">
  285. <el-form-item label="员工离职日期" >
  286. <el-date-picker type="date" v-model="deactiveDate" value-format="yyyy-MM-dd" format="yyyy-MM-dd" placeholder="请选择" />
  287. </el-form-item>
  288. </el-form>
  289. <span slot="footer" class="dialog-footer">
  290. <el-button type="default" @click="deactiveDialog = false">取消</el-button>
  291. <el-button type="primary" @click="confirmDeactive">确定</el-button>
  292. </span>
  293. </el-dialog>
  294. </section>
  295. </template>
  296. <script>
  297. import util from "../../common/js/util";
  298. export default {
  299. data() {
  300. return {
  301. deactiveUser:null,
  302. deactiveDate:null,
  303. deactiveDialog:false,
  304. toUserId:null,
  305. myRoleId: 2,
  306. allActiveUsers:[],
  307. transferDialog: false,
  308. containInvalid:1,
  309. exportDialogVisible: false,
  310. roleArray:["普通员工","超级管理员", "系统管理员", "公司高层","人事管理员", "项目管理员","公司领导"],
  311. roleDescArray:[{label:"普通员工",value:0, desc:"填报日报,参与项目协作"},
  312. {label:"系统管理员",value:2, desc:"具有除了创建系统管理员之外的全部功能"},
  313. {label:"公司高层",value:3, desc:"查阅项目信息,人员工时情况"},
  314. {label:"人事管理员",value:4, desc:"财务核算成本,费用报销审核,负责组织架构管理"},
  315. {label:"项目管理员",value:5, desc:"创建和管理项目"},
  316. {label:"公司领导",value:6, desc:"财务核算成本,查阅项目、人员工时和成本情况"},
  317. ],
  318. userSalaryList:[],
  319. userSalaryListDialog: false,
  320. value:{},
  321. user: JSON.parse(sessionStorage.getItem("user")),
  322. users:[],
  323. tableHeight: 0,
  324. listLoading: false,
  325. total: 0,
  326. page: 1,
  327. size: 20,
  328. list: [],
  329. data: [
  330. {
  331. id: -1,
  332. label: '全部人员',
  333. },
  334. {
  335. id: 0,
  336. label: '未分配',
  337. }
  338. ],
  339. option: [],
  340. depData: {
  341. id: -1,
  342. label: '全部人员',
  343. },
  344. defaultProps: {
  345. children: 'children',
  346. label: 'label'
  347. },
  348. dialogVisible: false,
  349. title: "",
  350. insertForm: {
  351. id: null,
  352. name: null,
  353. phone: null,
  354. role: null,
  355. monthCost:null,
  356. cost: null,
  357. departmentId: null,
  358. salaryType:0,
  359. costApplyDate: '2021-04-09'
  360. },
  361. rules: {
  362. name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
  363. // phone: [{ required: true, message: "请输入电话", trigger: "blur" }],
  364. role: [{ required: true, message: "请选择角色", trigger: "blur" }],
  365. cost: [{ required: true, message: "请输入成本", trigger: "blur" }]
  366. },
  367. dialogVisible1: false,
  368. departmentVisible: false,
  369. depTitle: '',
  370. depForm: {
  371. id: null,
  372. name: null,
  373. parentId: null,
  374. managerId: null,
  375. },
  376. depRules: {
  377. name: [{ required: true, message: "请输入部门名称", trigger: "blur" }],
  378. },
  379. timeType:{},
  380. keyword: ''
  381. };
  382. },
  383. methods: {
  384. confirmDeactive() {
  385. this.http.post('/user/deactiveUser', {
  386. id: this.deactiveUser.id,
  387. inactiveDate: this.deactiveDate
  388. },
  389. res => {
  390. if (res.code == "ok") {
  391. this.deactiveDialog = false;
  392. this.$message({
  393. message: '停用成功',
  394. type: "success"
  395. });
  396. // this.getUsers();
  397. this.getUser()
  398. } else {
  399. this.$message({
  400. message: res.msg,
  401. type: "error"
  402. });
  403. }
  404. },
  405. error => {
  406. this.$message({
  407. message: error,
  408. type: "error"
  409. });
  410. });
  411. },
  412. showDeactiveDialog(item) {
  413. this.deactiveDialog = true;
  414. this.deactiveUser = item;
  415. },
  416. restrictNumber(targetId) {
  417. let inpu = document.getElementById(targetId);
  418. inpu.value = inpu.value.replace(/[^\d.]/g, ""); //仅保留数字和"."
  419. inpu.value = inpu.value.replace(/\.{2,}/g, "."); //两个连续的"."仅保留第一个"."
  420. inpu.value = inpu.value.replace(".", "$#*").replace(/\./g,'').replace('$#*','.');//去除其他"."
  421. inpu.value = inpu.value.replace(/^(\d+)\.(\d\d).*$/, '$1.$2');;//限制只能输入两个小数
  422. if (inpu.value.indexOf(".") < 0 && inpu.value != "") { //首位是0的话去掉
  423. inpu.value = parseFloat(inpu.value);
  424. }
  425. },
  426. showConfirmDialog() {
  427. if (this.toUserId == null || this.toUserId == '') {
  428. this.$message({
  429. message: '请选择要转让的人员',
  430. type: "error"
  431. });
  432. return;
  433. }
  434. this.$confirm("您将失去超级管理员角色,需要重新登录。确定要转让吗?", "提示", {
  435. //type: 'warning'
  436. }).then(() => {
  437. this.http.post('/user/changeSysManager', {
  438. toUserId: this.toUserId,
  439. myRoleId: this.myRoleId
  440. },
  441. res => {
  442. if (res.code == "ok") {
  443. sessionStorage.removeItem("user");
  444. this.$router.push("/login");
  445. } else {
  446. this.$message({
  447. message: res.msg,
  448. type: "error"
  449. });
  450. }
  451. },
  452. error => {
  453. this.$message({
  454. message: error,
  455. type: "error"
  456. });
  457. });
  458. });
  459. },
  460. transferRole() {
  461. this.transferDialog = true;
  462. this.http.post(this.port.manage.list, {
  463. departmentId: -1,
  464. pageIndex: 1,
  465. pageSize: 99999,
  466. keyword: this.keyword
  467. },
  468. res => {
  469. if (res.code == "ok") {
  470. this.allActiveUsers = res.data.records.filter(u=>u.isActive == 1 && u.id != this.user.id);
  471. } else {
  472. this.$message({
  473. message: res.msg,
  474. type: "error"
  475. });
  476. }
  477. },
  478. error => {
  479. this.$message({
  480. message: error,
  481. type: "error"
  482. });
  483. });
  484. },
  485. showExportDialog() {
  486. this.exportDialogVisible = true;
  487. },
  488. exportUsers() {
  489. this.http.post('/user/exportUsers', {
  490. containInvalid: this.containInvalid
  491. },
  492. res => {
  493. if (res.code == "ok") {
  494. this.exportDialogVisible = false;
  495. var aTag = document.createElement('a');
  496. aTag.download = "全部员工列表.xls";
  497. aTag.href = res.data;
  498. aTag.click();
  499. } else {
  500. this.$message({
  501. message: res.msg,
  502. type: "error"
  503. });
  504. }
  505. },
  506. error => {
  507. this.$message({
  508. message: error,
  509. type: "error"
  510. });
  511. });
  512. },
  513. showSalaryList(item) {
  514. this.userSalaryListDialog = true;
  515. this.userSalaryList = [];
  516. this.http.post('/user/getUserSalaryList', {
  517. id: item.id
  518. },
  519. res => {
  520. if (res.code == "ok") {
  521. this.userSalaryList = res.data;
  522. } else {
  523. this.$message({
  524. message: res.msg,
  525. type: "error"
  526. });
  527. }
  528. },
  529. error => {
  530. this.$message({
  531. message: error,
  532. type: "error"
  533. });
  534. });
  535. },
  536. getUsers() {
  537. this.http.post(this.port.manage.list, {
  538. departmentId: -1,
  539. pageIndex: 1,
  540. pageSize: 99999,
  541. keyword: this.keyword
  542. },
  543. res => {
  544. if (res.code == "ok") {
  545. this.users = res.data.records;
  546. } else {
  547. this.$message({
  548. message: res.msg,
  549. type: "error"
  550. });
  551. }
  552. },
  553. error => {
  554. this.$message({
  555. message: error,
  556. type: "error"
  557. });
  558. });
  559. },
  560. onSalaryTypeChange(value) {
  561. if (value == 1) {
  562. this.insertForm.monthCost = null;
  563. }
  564. },
  565. //选中部门
  566. choseDept(value) {
  567. console.log(value);
  568. },
  569. //月成本输入变化
  570. oninput(e) {
  571. this.insertForm.cost = (this.insertForm.monthCost/this.timeType.monthDays/this.timeType.allday).toFixed(2);
  572. },
  573. // 获取本公司的工作时间设置
  574. getCompanyTimeSetting() {
  575. this.http.post('/time-type/getCompanyTimeSetting',{
  576. companyId: this.user.companyId
  577. },
  578. res => {
  579. if (res.code == "ok") {
  580. this.timeType = res.data;
  581. } else {
  582. this.$message({
  583. message: res.msg,
  584. type: "error"
  585. });
  586. }
  587. },
  588. error => {
  589. this.listLoading = false;
  590. this.$message({
  591. message: error,
  592. type: "error"
  593. });
  594. }
  595. );
  596. },
  597. // 批量导入人员
  598. importUser(item) {
  599. //首先判断文件类型
  600. let str = item.file.name.split(".");
  601. let format = str[str.length - 1];
  602. if (format != "xls" && format != "xlsx") {
  603. this.$message({
  604. message: "请选择.xls或.xlsx文件",
  605. type: "error"
  606. });
  607. } else {
  608. this.listLoading = true;
  609. let formData = new FormData();
  610. formData.append("file", item.file);
  611. formData.append("departmentId", this.depData.id);
  612. this.http.uploadFile( this.port.manage.import, formData,
  613. res => {
  614. this.$refs.upload.clearFiles();
  615. this.listLoading = false;
  616. if (res.code == "ok") {
  617. this.$message({
  618. message: "导入成功",
  619. type: "success"
  620. });
  621. //重新读取列表
  622. this.getUser();
  623. } else {
  624. this.$message({
  625. message: res.msg,
  626. type: "error"
  627. });
  628. }
  629. },
  630. error => {
  631. this.$refs.upload.clearFiles();
  632. this.listLoading = false;
  633. this.$message({
  634. message: error,
  635. type: "error"
  636. });
  637. });
  638. }
  639. },
  640. //分页
  641. handleCurrentChange(val) {
  642. this.page = val;
  643. this.getUser();
  644. },
  645. handleSizeChange(val) {
  646. this.size = val;
  647. this.getUser();
  648. },
  649. //获取所有员工的列表
  650. getUser() {
  651. this.listLoading = true;
  652. this.http.post( this.port.manage.list, {
  653. departmentId: this.depData.id,
  654. pageIndex: this.page,
  655. pageSize: this.size,
  656. keyword: this.keyword
  657. },
  658. res => {
  659. this.listLoading = false;
  660. if (res.code == "ok") {
  661. this.list = res.data.records;
  662. this.total = res.data.total;
  663. } else {
  664. this.$message({
  665. message: res.msg,
  666. type: "error"
  667. });
  668. }
  669. },
  670. error => {
  671. this.listLoading = false;
  672. this.$message({
  673. message: error,
  674. type: "error"
  675. });
  676. });
  677. },
  678. resetPwd(user) {
  679. this.$confirm( "确定要为" + user.name + "重置密码吗?", "重置密码", {
  680. confirmButtonText: "确定",
  681. cancelButtonText: "取消",
  682. type: "warning"
  683. })
  684. .then(() => {
  685. this.http.post('/user/resetPwd', { userId: user.id },
  686. res => {
  687. if (res.code == "ok") {
  688. this.$message({
  689. message: "密码已重置为000000,请通知员工及时修改",
  690. type: "success"
  691. });
  692. } else {
  693. this.$message({
  694. message: res.msg,
  695. type: "error"
  696. });
  697. }
  698. },
  699. error => {
  700. this.listLoading = false;
  701. this.$message({
  702. message: error,
  703. type: "error"
  704. });
  705. });
  706. })
  707. .catch(() => {});
  708. },
  709. // 新增、编辑人员
  710. openInsertDialog(i) {
  711. if (i != null) {
  712. var list = JSON.parse(JSON.stringify(this.list[i])) , arr = [] , array = [];
  713. if(list.departmentCascade!='0' && list.departmentCascade!=null) {
  714. if(list.departmentCascade.indexOf(",")>-1) {
  715. arr = list.departmentCascade.split(",");
  716. } else {
  717. arr = [].concat(list.departmentCascade)
  718. }
  719. }
  720. for(var i in arr) {
  721. array.push(parseInt(arr[i]))
  722. }
  723. this.insertForm = {
  724. id: list.id,
  725. name: list.name,
  726. phone: list.phone,
  727. role: list.role,
  728. monthCost:list.monthCost,
  729. cost: list.cost,
  730. departmentId: array.reverse(),
  731. salaryType: list.salaryType,
  732. costApplyDate: list.costApplyDate,
  733. };
  734. this.title = "编辑人员"
  735. } else {
  736. this.insertForm = {
  737. id: null,
  738. name: null,
  739. phone: null,
  740. role: null,
  741. monthCost:null,
  742. cost: null,
  743. departmentId: null,
  744. salaryType:0,
  745. costApplyDate: util.formatDate.format(new Date(), 'yyyy-MM-dd'),
  746. };
  747. this.title = "新增人员"
  748. }
  749. this.dialogVisible = true;
  750. },
  751. submitInsert() {
  752. this.$refs.form1.validate(valid => {
  753. if (valid) {
  754. this.listLoading = true;
  755. var form = {
  756. name: this.insertForm.name,
  757. phone: this.insertForm.phone,
  758. role: this.insertForm.role,
  759. monthCost: this.insertForm.monthCost,
  760. cost: this.insertForm.cost,
  761. salaryType: this.insertForm.salaryType,
  762. };
  763. if (this.insertForm.id != null) {
  764. form.id = this.insertForm.id;
  765. }
  766. if (this.insertForm.costApplyDate != null) {
  767. form.costApplyDate = this.insertForm.costApplyDate;
  768. }
  769. if (this.insertForm.departmentId != null) {
  770. form.departmentId = this.insertForm.departmentId[this.insertForm.departmentId.length-1];
  771. }
  772. this.http.post( this.port.manage.insert, form,
  773. res => {
  774. this.listLoading = false;
  775. if (res.code == "ok") {
  776. this.$message({
  777. message: this.insertForm.id != null ? "修改" : "创建" + "成功",
  778. type: "success"
  779. });
  780. this.dialogVisible = false;
  781. this.getUser();
  782. } else {
  783. this.$message({
  784. message: res.msg,
  785. type: "error"
  786. });
  787. }
  788. },
  789. error => {
  790. this.listLoading = false;
  791. this.$message({
  792. message: error,
  793. type: "error"
  794. });
  795. });
  796. }
  797. });
  798. },
  799. // 切换角色
  800. switchRole(index) {
  801. this.listLoading = true;
  802. this.http.post( this.port.manage.permission, { id: this.list[index].id },
  803. res => {
  804. this.listLoading = false;
  805. if (res.code == "ok") {
  806. this.$message({
  807. message: "切换角色成功",
  808. type: "success"
  809. });
  810. //重新读取列表
  811. this.getUser();
  812. } else {
  813. this.$message({
  814. message: res.msg,
  815. type: "error"
  816. });
  817. }
  818. },
  819. error => {
  820. this.listLoading = false;
  821. this.$message({
  822. message: error,
  823. type: "error"
  824. });
  825. });
  826. },
  827. // 删除用户
  828. setActive(item, isActive) {
  829. var txt = isActive==1?"启用":"停用";
  830. this.$confirm( "确定要"+txt +" " + item.name + " 吗?", "账号"+txt, {
  831. confirmButtonText: "确定",
  832. cancelButtonText: "取消",
  833. type: "warning"
  834. })
  835. .then(() => {
  836. this.listLoading = true;
  837. this.http.post('/user/setActive', { id: item.id, isActive: isActive},
  838. res => {
  839. this.listLoading = false;
  840. if (res.code == "ok") {
  841. this.$message({
  842. message: txt+"成功",
  843. type: "success"
  844. });
  845. //重新读取列表
  846. this.getUser();
  847. } else {
  848. this.$message({
  849. message: res.msg,
  850. type: "error"
  851. });
  852. }
  853. },
  854. error => {
  855. this.listLoading = false;
  856. this.$message({
  857. message: error,
  858. type: "error"
  859. });
  860. });
  861. })
  862. .catch(() => {});
  863. },
  864. // 修改老板的成本
  865. openInsertDialog1(i) {
  866. var list1 = JSON.parse(JSON.stringify(this.list[i])) , arr1 = [] , array1 = [];
  867. if(list1.departmentCascade!='0' && list1.departmentCascade!=null) {
  868. if(list1.departmentCascade.indexOf(",")>-1) {
  869. arr1 = list1.departmentCascade.split(",");
  870. } else {
  871. arr1 = [].concat(list1.departmentCascade)
  872. }
  873. }
  874. for(var i in arr1) {
  875. array1.push(parseInt(arr1[i]))
  876. }
  877. this.insertForm = {
  878. id: list1.id,
  879. name: list1.name,
  880. phone: list1.phone,
  881. role: list1.role,
  882. monthCost:list1.monthCost,
  883. cost: list1.cost,
  884. departmentId: array1.reverse(),
  885. salaryType: list1.salaryType
  886. };
  887. this.dialogVisible1 = true;
  888. },
  889. submitInsert1() {
  890. this.$refs.form1.validate(valid => {
  891. if (valid) {
  892. this.listLoading = true;
  893. var form = {
  894. id: this.insertForm.id,
  895. name: this.insertForm.name,
  896. phone: this.insertForm.phone,
  897. role: this.insertForm.role,
  898. monthCost: this.insertForm.monthCost,
  899. cost: this.insertForm.cost
  900. };
  901. if (this.insertForm.departmentId != null) {
  902. form.departmentId = this.insertForm.departmentId[this.insertForm.departmentId.length-1];
  903. }
  904. if (this.insertForm.costApplyDate != null) {
  905. form.costApplyDate = this.insertForm.costApplyDate;
  906. }
  907. this.http.post( this.port.manage.insert, form,
  908. res => {
  909. this.listLoading = false;
  910. if (res.code == "ok") {
  911. this.$message({
  912. message: "修改成功",
  913. type: "success"
  914. });
  915. this.dialogVisible1 = false;
  916. //重新读取列表
  917. this.getUser();
  918. } else {
  919. this.$message({
  920. message: res.msg,
  921. type: "error"
  922. });
  923. }
  924. },
  925. error => {
  926. this.listLoading = false;
  927. this.$message({
  928. message: error,
  929. type: "error"
  930. });
  931. });
  932. }
  933. });
  934. },
  935. // 获取部门列表
  936. getDepartment() {
  937. this.http.post( this.port.manage.depList, {},
  938. res => {
  939. if (res.code == "ok") {
  940. var list = res.data , list1 = JSON.parse(JSON.stringify(res.data));
  941. list.splice(0,0,{
  942. id: -1,
  943. label: '全部人员',
  944. })
  945. list.push({
  946. id: 0,
  947. label: '未分配',
  948. })
  949. this.data = list;
  950. this.option = this.changeArr(list1);
  951. } else {
  952. this.$message({
  953. message: res.msg,
  954. type: "error"
  955. });
  956. }
  957. },
  958. error => {
  959. this.$message({
  960. message: error,
  961. type: "error"
  962. });
  963. });
  964. },
  965. // 修改数组
  966. changeArr(arr) {
  967. for (var i = 0; i < arr.length; i++) {
  968. if(arr[i].id != -1 && arr[i].id != 0) {
  969. if (arr[i].children != null && arr[i].children.length>0) {
  970. arr[i].children = this.changeArr(arr[i].children);
  971. }
  972. arr[i].id && (arr[i].value = arr[i].id);
  973. delete arr[i].id;
  974. }
  975. }
  976. for(var i in arr) {
  977. if(arr[i].id == -1 || arr[i].id == 0) {
  978. arr.splice(i,1)
  979. }
  980. }
  981. return arr;
  982. },
  983. // 部门列表点击
  984. handleNodeClick(data) {
  985. if(this.depData == null || data.id != this.depData.id) {
  986. this.depData = data;
  987. this.page = 1;
  988. this.getUser();
  989. }
  990. },
  991. // 新增、修改部门
  992. createDepartment(i) {
  993. if(i == -2) {//创建子部门
  994. this.depForm = {
  995. id: null,
  996. name: null,
  997. parentId: null,
  998. managerId: null,
  999. }
  1000. if(this.depData.id != -1 && this.depData.id != 0) {
  1001. this.depForm.parentId = this.depData.id;
  1002. }
  1003. this.depTitle = "新增子部门";
  1004. } else if(i == -1) {//创建一级部门
  1005. this.depForm = {
  1006. id: null,
  1007. name: null,
  1008. parentId: null,
  1009. managerId: null,
  1010. }
  1011. this.depTitle = "新增部门";
  1012. } else {
  1013. this.depForm = {
  1014. id: this.depData.id,
  1015. name: this.depData.label,
  1016. parentId: this.depData.parentId,
  1017. managerId: this.depData.managerId,
  1018. }
  1019. this.depTitle = "编辑部门";
  1020. }
  1021. this.departmentVisible = true;
  1022. },
  1023. submitDepartment() {
  1024. this.$refs.depForm.validate(valid => {
  1025. if (valid) {
  1026. var form = {
  1027. name: this.depForm.name,
  1028. };
  1029. if(this.depForm.id != null) {
  1030. form.id = this.depForm.id
  1031. }
  1032. if(this.depForm.parentId != null) {
  1033. form.parentId = this.depForm.parentId
  1034. }
  1035. if (this.depForm.managerId != null) {
  1036. form.managerId = this.depForm.managerId
  1037. }
  1038. this.http.post( this.depForm.id==null?this.port.manage.add:this.port.manage.edit, form,
  1039. res => {
  1040. if (res.code == "ok") {
  1041. this.$message({
  1042. message: this.depForm.id==null?"新增成功":"修改成功",
  1043. type: "success"
  1044. });
  1045. this.departmentVisible = false;
  1046. if (this.depForm.id !=null) {
  1047. this.depData.label = form.name;
  1048. this.depData.managerId = form.managerId;
  1049. }
  1050. this.getDepartment();
  1051. } else {
  1052. this.$message({
  1053. message: res.msg,
  1054. type: "error"
  1055. });
  1056. }
  1057. },
  1058. error => {
  1059. this.listLoading = false;
  1060. this.$message({
  1061. message: error,
  1062. type: "error"
  1063. });
  1064. });
  1065. }
  1066. });
  1067. },
  1068. // 删除部门
  1069. deleteDep() {
  1070. this.$confirm( "确定要删除部门" + this.depData.label + "吗?", "删除部门", {
  1071. confirmButtonText: "确定",
  1072. cancelButtonText: "取消",
  1073. type: "warning"
  1074. })
  1075. .then(() => {
  1076. this.listLoading = true;
  1077. this.http.post( this.port.manage.del, { id: this.depData.id },
  1078. res => {
  1079. this.listLoading = false;
  1080. if (res.code == "ok") {
  1081. this.$message({
  1082. message: "删除成功",
  1083. type: "success"
  1084. });
  1085. this.depData = {
  1086. id: -1,
  1087. label: '全部人员',
  1088. }
  1089. this.getDepartment();
  1090. this.getUser();
  1091. } else {
  1092. this.$message({
  1093. message: res.msg,
  1094. type: "error"
  1095. });
  1096. }
  1097. },
  1098. error => {
  1099. this.listLoading = false;
  1100. this.$message({
  1101. message: error,
  1102. type: "error"
  1103. });
  1104. });
  1105. })
  1106. .catch(() => {});
  1107. },
  1108. // 关键搜索
  1109. searchList() {
  1110. console.log(this.keyword)
  1111. this.listLoading = true;
  1112. this.http.post( this.port.manage.list, {
  1113. departmentId: this.depData.id,
  1114. pageIndex: this.page,
  1115. pageSize: this.size,
  1116. keyword: this.keyword
  1117. },
  1118. res => {
  1119. this.listLoading = false;
  1120. if (res.code == "ok") {
  1121. this.list = res.data.records;
  1122. this.total = res.data.total;
  1123. } else {
  1124. this.$message({
  1125. message: res.msg,
  1126. type: "error"
  1127. });
  1128. }
  1129. },
  1130. error => {
  1131. this.listLoading = false;
  1132. this.$message({
  1133. message: error,
  1134. type: "error"
  1135. });
  1136. });
  1137. }
  1138. },
  1139. created() {
  1140. let height = window.innerHeight;
  1141. this.tableHeight = height - 195;
  1142. const that = this;
  1143. window.onresize = function temp() {
  1144. that.tableHeight = window.innerHeight - 195;
  1145. };
  1146. },
  1147. mounted() {
  1148. this.deactiveDate = util.formatDate.format(new Date(), 'yyyy-MM-dd');
  1149. this.getDepartment();
  1150. this.getUser();
  1151. this.getCompanyTimeSetting();
  1152. this.getUsers();
  1153. }
  1154. };
  1155. </script>
  1156. <style lang="scss" scoped>
  1157. .left {
  1158. border-right: 1px solid #f2f2f2;
  1159. overflow: hidden;
  1160. .department {
  1161. background:#f2f2f2;
  1162. line-height: 60px;
  1163. color:#666;
  1164. padding:0 10px;
  1165. height:60px;
  1166. font-size: 15px;
  1167. div {
  1168. float: right;
  1169. color: #20a0ff;
  1170. font-size: 14px;
  1171. cursor: pointer;
  1172. }
  1173. }
  1174. .tree {
  1175. overflow: auto;
  1176. }
  1177. }
  1178. .nowTime {
  1179. height: 40px;
  1180. line-height: 40px;
  1181. font-size: 16px;
  1182. color: #20a0ff;
  1183. margin-left: 10px;
  1184. cursor: pointer;
  1185. i {
  1186. margin-right: 10px;
  1187. }
  1188. }
  1189. </style>
  1190. <style lang="scss">
  1191. .tree {
  1192. .el-tree-node__label {
  1193. overflow-x: hidden;
  1194. white-space: nowrap;
  1195. text-overflow: ellipsis;
  1196. }
  1197. }
  1198. .el-divider--horizontal {
  1199. margin: 0px;
  1200. background:#f3f3f3;
  1201. }
  1202. //全局的作用范围
  1203. .el-tree-node__content {
  1204. height:36px;
  1205. }
  1206. </style>