index.vue 71 KB

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