index.vue 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730
  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" v-if="permissions.structurePersonnel">
  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">
  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">
  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">
  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. // return
  1090. this.http.post( this.port.manage.insert, form,
  1091. res => {
  1092. this.submitLoading = false;
  1093. if (res.code == "ok") {
  1094. this.$message({
  1095. message: this.insertForm.id != null ? "修改" : "创建" + "成功",
  1096. type: "success"
  1097. });
  1098. this.dialogVisible = false;
  1099. this.getUser();
  1100. this.getUsers()
  1101. } else {
  1102. this.$message({
  1103. message: res.msg,
  1104. type: "error"
  1105. });
  1106. }
  1107. },
  1108. error => {
  1109. this.listLoading = false;
  1110. this.$message({
  1111. message: error,
  1112. type: "error"
  1113. });
  1114. });
  1115. },
  1116. // 切换角色
  1117. switchRole(index) {
  1118. this.listLoading = true;
  1119. this.http.post( this.port.manage.permission, { id: this.list[index].id },
  1120. res => {
  1121. this.listLoading = false;
  1122. if (res.code == "ok") {
  1123. this.$message({
  1124. message: "切换角色成功",
  1125. type: "success"
  1126. });
  1127. //重新读取列表
  1128. this.getUser();
  1129. } else {
  1130. this.$message({
  1131. message: res.msg,
  1132. type: "error"
  1133. });
  1134. }
  1135. },
  1136. error => {
  1137. this.listLoading = false;
  1138. this.$message({
  1139. message: error,
  1140. type: "error"
  1141. });
  1142. });
  1143. },
  1144. // 删除用户
  1145. setActive(item, isActive) {
  1146. var txt = isActive==1?"启用":"停用";
  1147. this.$confirm( "确定要"+txt +" " + item.name + " 吗?", "账号"+txt, {
  1148. confirmButtonText: "确定",
  1149. cancelButtonText: "取消",
  1150. type: "warning"
  1151. })
  1152. .then(() => {
  1153. this.listLoading = true;
  1154. this.http.post('/user/setActive', { id: item.id, isActive: isActive},
  1155. res => {
  1156. this.listLoading = false;
  1157. if (res.code == "ok") {
  1158. this.$message({
  1159. message: txt+"成功",
  1160. type: "success"
  1161. });
  1162. //重新读取列表
  1163. this.getUser();
  1164. } else {
  1165. this.$message({
  1166. message: res.msg,
  1167. type: "error"
  1168. });
  1169. }
  1170. },
  1171. error => {
  1172. this.listLoading = false;
  1173. this.$message({
  1174. message: error,
  1175. type: "error"
  1176. });
  1177. });
  1178. })
  1179. .catch(() => {});
  1180. },
  1181. // 修改老板的成本
  1182. openInsertDialog1(i) {
  1183. var list1 = JSON.parse(JSON.stringify(this.list[i])) , arr1 = [] , array1 = [];
  1184. if(list1.departmentCascade!='0' && list1.departmentCascade!=null) {
  1185. if(list1.departmentCascade.indexOf(",")>-1) {
  1186. arr1 = list1.departmentCascade.split(",");
  1187. } else {
  1188. arr1 = [].concat(list1.departmentCascade)
  1189. }
  1190. }
  1191. for(var i in arr1) {
  1192. array1.push(parseInt(arr1[i]))
  1193. }
  1194. console.log(list1)
  1195. this.insertForm = {
  1196. id: list1.id,
  1197. name: list1.name,
  1198. phone: list1.phone,
  1199. role: list1.role,
  1200. monthCost:list1.monthCost,
  1201. cost: list1.cost,
  1202. departmentId: array1.reverse(),
  1203. salaryType: list1.salaryType,
  1204. name: list1.name
  1205. };
  1206. this.dialogVisible1 = true;
  1207. },
  1208. submitInsert1() {
  1209. var form = {}
  1210. this.$refs.form1.validate(valid => {
  1211. if (valid) {
  1212. this.submitLoading = true;
  1213. form = {
  1214. id: this.insertForm.id,
  1215. name: this.insertForm.name,
  1216. phone: this.insertForm.phone,
  1217. // role: this.insertForm.role,
  1218. roleId: this.insertForm.roleId,
  1219. monthCost: this.insertForm.monthCost,
  1220. cost: this.insertForm.cost
  1221. };
  1222. if (this.insertForm.departmentId != null) {
  1223. form.departmentId = this.insertForm.departmentId[this.insertForm.departmentId.length-1];
  1224. }
  1225. if (this.insertForm.costApplyDate != null) {
  1226. form.costApplyDate = this.insertForm.costApplyDate;
  1227. }
  1228. }
  1229. });
  1230. this.http.post( this.port.manage.insert, form,
  1231. res => {
  1232. this.submitLoading = false;
  1233. if (res.code == "ok") {
  1234. this.$message({
  1235. message: "修改成功",
  1236. type: "success"
  1237. });
  1238. this.dialogVisible1 = false;
  1239. //重新读取列表
  1240. this.getUser();
  1241. this.getUsers()
  1242. } else {
  1243. this.$message({
  1244. message: res.msg,
  1245. type: "error"
  1246. });
  1247. }
  1248. },
  1249. error => {
  1250. this.listLoading = false;
  1251. this.$message({
  1252. message: error,
  1253. type: "error"
  1254. });
  1255. });
  1256. },
  1257. // 获取部门列表
  1258. getDepartment() {
  1259. this.http.post( this.port.manage.depList, {},
  1260. res => {
  1261. if (res.code == "ok") {
  1262. var list = res.data , list1 = JSON.parse(JSON.stringify(res.data));
  1263. list.splice(0,0,{
  1264. id: -1,
  1265. label: '全部人员',
  1266. })
  1267. list.push({
  1268. id: 0,
  1269. label: '未分配',
  1270. })
  1271. this.data = list;
  1272. console.log(list, "部门数据")
  1273. this.option = this.changeArr(list1);
  1274. } else {
  1275. this.$message({
  1276. message: res.msg,
  1277. type: "error"
  1278. });
  1279. }
  1280. },
  1281. error => {
  1282. this.$message({
  1283. message: error,
  1284. type: "error"
  1285. });
  1286. });
  1287. },
  1288. // 修改数组
  1289. changeArr(arr) {
  1290. for (var i = 0; i < arr.length; i++) {
  1291. if(arr[i].id != -1 && arr[i].id != 0) {
  1292. if (arr[i].children != null && arr[i].children.length>0) {
  1293. arr[i].children = this.changeArr(arr[i].children);
  1294. }
  1295. arr[i].id && (arr[i].value = arr[i].id);
  1296. delete arr[i].id;
  1297. }
  1298. }
  1299. for(var i in arr) {
  1300. if(arr[i].id == -1 || arr[i].id == 0) {
  1301. arr.splice(i,1)
  1302. }
  1303. }
  1304. return arr;
  1305. },
  1306. // 部门列表点击
  1307. handleNodeClick(data) {
  1308. console.log(data, 999)
  1309. if(this.depData == null || data.id != this.depData.id) {
  1310. this.depData = data;
  1311. this.page = 1;
  1312. this.getUser();
  1313. }
  1314. },
  1315. // 新增、修改部门
  1316. createDepartment(i) {
  1317. setTimeout(() => {
  1318. var that = this
  1319. if(i == -2) {//创建子部门
  1320. that.depForm = {
  1321. id: null,
  1322. name: null,
  1323. parentId: null,
  1324. managerId: null,
  1325. }
  1326. if(that.depData.id != -1 && that.depData.id != 0) {
  1327. that.depForm.parentId = that.depData.id;
  1328. }
  1329. that.depTitle = "新增子部门";
  1330. } else if(i == -1) {//创建一级部门
  1331. that.depForm = {
  1332. id: null,
  1333. name: null,
  1334. parentId: null,
  1335. managerId: null,
  1336. }
  1337. that.depTitle = "新增部门";
  1338. } else {
  1339. if(that.depData.managerId == "null") {
  1340. that.depData.managerId = ''
  1341. }
  1342. if(that.depData.reportAuditUserid == "null") {
  1343. that.depData.reportAuditUserid = ''
  1344. }
  1345. that.depForm = {
  1346. id: that.depData.id,
  1347. name: that.depData.label,
  1348. parentId: that.depData.parentId,
  1349. managerId: that.depData.managerId,
  1350. reportAuditUserid: that.depData.reportAuditUserid
  1351. }
  1352. // if(that.depData.reportAuditUserid != null && that.depData.reportAuditUserid != "null" && that.depData.reportAuditUserid.length > 0) {
  1353. // that.depForm.reportAuditUserid = that.depData.reportAuditUserid
  1354. // }
  1355. that.depTitle = "编辑部门";
  1356. }
  1357. that.departmentVisible = true;
  1358. })
  1359. // if(i == -2) {//创建子部门
  1360. // this.depForm = {
  1361. // id: null,
  1362. // name: null,
  1363. // parentId: null,
  1364. // managerId: null,
  1365. // }
  1366. // if(this.depData.id != -1 && this.depData.id != 0) {
  1367. // this.depForm.parentId = this.depData.id;
  1368. // }
  1369. // this.depTitle = "新增子部门";
  1370. // } else if(i == -1) {//创建一级部门
  1371. // this.depForm = {
  1372. // id: null,
  1373. // name: null,
  1374. // parentId: null,
  1375. // managerId: null,
  1376. // }
  1377. // this.depTitle = "新增部门";
  1378. // } else {
  1379. // if(this.depData.managerId == "null") {
  1380. // this.depData.managerId = ''
  1381. // }
  1382. // if(this.depData.reportAuditUserid == "null") {
  1383. // this.depData.reportAuditUserid = ''
  1384. // }
  1385. // this.depForm = {
  1386. // id: this.depData.id,
  1387. // name: this.depData.label,
  1388. // parentId: this.depData.parentId,
  1389. // managerId: this.depData.managerId,
  1390. // reportAuditUserid: this.depData.reportAuditUserid
  1391. // }
  1392. // // if(this.depData.reportAuditUserid != null && this.depData.reportAuditUserid != "null" && this.depData.reportAuditUserid.length > 0) {
  1393. // // this.depForm.reportAuditUserid = this.depData.reportAuditUserid
  1394. // // }
  1395. // this.depTitle = "编辑部门";
  1396. // }
  1397. // this.departmentVisible = true;
  1398. },
  1399. submitDepartment() {
  1400. this.$refs.depForm.validate(valid => {
  1401. if (valid) {
  1402. var form = {
  1403. name: this.depForm.name,
  1404. };
  1405. if(this.depForm.id != null) {
  1406. form.id = this.depForm.id
  1407. }
  1408. if(this.depForm.parentId != null) {
  1409. form.parentId = this.depForm.parentId
  1410. }
  1411. if (this.depForm.managerId) {
  1412. form.managerId = this.depForm.managerId
  1413. }
  1414. console.log(this.depForm)
  1415. if (this.depForm.reportAuditUserid) {
  1416. form.reportAuditUserid = this.depForm.reportAuditUserid
  1417. }
  1418. this.http.post( this.depForm.id==null?this.port.manage.add:this.port.manage.edit, form,
  1419. res => {
  1420. if (res.code == "ok") {
  1421. this.$message({
  1422. message: this.depForm.id==null?"新增成功":"修改成功",
  1423. type: "success"
  1424. });
  1425. this.departmentVisible = false;
  1426. if (this.depForm.id !=null) {
  1427. this.depData.label = form.name;
  1428. this.depData.managerId = form.managerId;
  1429. }
  1430. this.getDepartment();
  1431. } else {
  1432. this.$message({
  1433. message: res.msg,
  1434. type: "error"
  1435. });
  1436. }
  1437. },
  1438. error => {
  1439. this.listLoading = false;
  1440. this.$message({
  1441. message: error,
  1442. type: "error"
  1443. });
  1444. });
  1445. }
  1446. });
  1447. },
  1448. // 删除部门
  1449. deleteDep() {
  1450. var that = this
  1451. setTimeout(() =>{
  1452. that.$confirm( "确定要删除部门" + that.depData.label + "吗?", "删除部门", {
  1453. confirmButtonText: "确定",
  1454. cancelButtonText: "取消",
  1455. type: "warning"
  1456. })
  1457. .then(() => {
  1458. that.listLoading = true;
  1459. that.http.post( that.port.manage.del, { id: that.depData.id },
  1460. res => {
  1461. that.listLoading = false;
  1462. if (res.code == "ok") {
  1463. that.$message({
  1464. message: "删除成功",
  1465. type: "success"
  1466. });
  1467. that.depData = {
  1468. id: -1,
  1469. label: '全部人员',
  1470. }
  1471. that.getDepartment();
  1472. that.getUser();
  1473. } else {
  1474. that.$message({
  1475. message: res.msg,
  1476. type: "error"
  1477. });
  1478. }
  1479. },
  1480. error => {
  1481. that.listLoading = false;
  1482. that.$message({
  1483. message: error,
  1484. type: "error"
  1485. });
  1486. });
  1487. })
  1488. .catch(() => {});
  1489. },100);
  1490. // this.$confirm( "确定要删除部门" + this.depData.label + "吗?", "删除部门", {
  1491. // confirmButtonText: "确定",
  1492. // cancelButtonText: "取消",
  1493. // type: "warning"
  1494. // })
  1495. // .then(() => {
  1496. // this.listLoading = true;
  1497. // this.http.post( this.port.manage.del, { id: this.depData.id },
  1498. // res => {
  1499. // this.listLoading = false;
  1500. // if (res.code == "ok") {
  1501. // this.$message({
  1502. // message: "删除成功",
  1503. // type: "success"
  1504. // });
  1505. // this.depData = {
  1506. // id: -1,
  1507. // label: '全部人员',
  1508. // }
  1509. // this.getDepartment();
  1510. // this.getUser();
  1511. // } else {
  1512. // this.$message({
  1513. // message: res.msg,
  1514. // type: "error"
  1515. // });
  1516. // }
  1517. // },
  1518. // error => {
  1519. // this.listLoading = false;
  1520. // this.$message({
  1521. // message: error,
  1522. // type: "error"
  1523. // });
  1524. // });
  1525. // })
  1526. // .catch(() => {});
  1527. },
  1528. // 关键搜索
  1529. searchList() {
  1530. console.log(this.keyword)
  1531. this.listLoading = true;
  1532. this.http.post( this.port.manage.list, {
  1533. departmentId: this.depData.id,
  1534. pageIndex: this.page,
  1535. pageSize: this.size,
  1536. keyword: this.keyword
  1537. },
  1538. res => {
  1539. this.listLoading = false;
  1540. if (res.code == "ok") {
  1541. this.list = res.data.records;
  1542. this.total = res.data.total;
  1543. } else {
  1544. this.$message({
  1545. message: res.msg,
  1546. type: "error"
  1547. });
  1548. }
  1549. },
  1550. error => {
  1551. this.listLoading = false;
  1552. this.$message({
  1553. message: error,
  1554. type: "error"
  1555. });
  1556. });
  1557. },
  1558. // 获取角色
  1559. acquireRole() {
  1560. // this.http.post('/permission/getFrontRoleList', {
  1561. this.http.post('/permission/getFrontRoleList', {
  1562. companyId: this.user.companyId
  1563. },
  1564. res => {
  1565. if (res.code == "ok") {
  1566. console.log(res.data, '获取角色')
  1567. this.acquireRoleList = res.data
  1568. var arr = []
  1569. for(var i in res.data) {
  1570. if(res.data[i].rolename != '系统管理员') {
  1571. arr.push(res.data[i])
  1572. }
  1573. }
  1574. this.acquireRoleLists = arr
  1575. } else {
  1576. this.$message({
  1577. message: res.msg,
  1578. type: "error"
  1579. });
  1580. }
  1581. },
  1582. error => {
  1583. this.$message({
  1584. message: error,
  1585. type: "error"
  1586. });
  1587. });
  1588. }
  1589. },
  1590. created() {
  1591. let height = window.innerHeight;
  1592. this.tableHeight = height - 195;
  1593. const that = this;
  1594. window.onresize = function temp() {
  1595. that.tableHeight = window.innerHeight - 195;
  1596. };
  1597. },
  1598. mounted() {
  1599. this.deactiveDate = util.formatDate.format(new Date(), 'yyyy-MM-dd');
  1600. this.getDepartment();
  1601. this.getUser();
  1602. this.getCompanyTimeSetting();
  1603. this.getUsers();
  1604. this.acquireRole();
  1605. this.isDingShow = this.$store.state.isDing;
  1606. }
  1607. };
  1608. </script>
  1609. <style lang="scss" scoped>
  1610. .custom-tree-node {
  1611. flex: 1;
  1612. display: flex;
  1613. align-items: center;
  1614. justify-content: space-between;
  1615. font-size: 14px;
  1616. padding-right: 8px;
  1617. }
  1618. .left {
  1619. border-right: 1px solid #f2f2f2;
  1620. overflow: hidden;
  1621. .department {
  1622. background:#f2f2f2;
  1623. line-height: 60px;
  1624. color:#666;
  1625. padding:0 10px;
  1626. height:60px;
  1627. font-size: 15px;
  1628. div {
  1629. float: right;
  1630. color: #20a0ff;
  1631. font-size: 14px;
  1632. cursor: pointer;
  1633. }
  1634. }
  1635. .tree {
  1636. overflow: auto;
  1637. }
  1638. }
  1639. .nowTime {
  1640. height: 40px;
  1641. line-height: 40px;
  1642. font-size: 16px;
  1643. color: #20a0ff;
  1644. margin-left: 10px;
  1645. cursor: pointer;
  1646. i {
  1647. margin-right: 10px;
  1648. }
  1649. }
  1650. .none {
  1651. display: none;
  1652. }
  1653. .block {
  1654. display: block;
  1655. }
  1656. </style>
  1657. <style lang="scss">
  1658. .tree {
  1659. .el-tree-node__label {
  1660. overflow-x: hidden;
  1661. white-space: nowrap;
  1662. text-overflow: ellipsis;
  1663. }
  1664. }
  1665. .el-divider--horizontal {
  1666. margin: 0px;
  1667. background:#f3f3f3;
  1668. }
  1669. //全局的作用范围
  1670. .el-tree-node__content {
  1671. height:36px;
  1672. }
  1673. </style>