index.vue 77 KB

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