index.vue 78 KB

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