index.vue 66 KB

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