index.vue 78 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743
  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: 120px" clearable>
  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. this.xiuRoleId = this.acquireRoleList[0].id
  611. this.handljues = true
  612. console.log('触发了')
  613. },
  614. handTrue() {
  615. var arr = []
  616. for(var i in this.handleSelectionZzjgDate) {
  617. arr.push(this.handleSelectionZzjgDate[i].id)
  618. }
  619. this.http.post('/user/batchUpdateRole', {
  620. userIds: JSON.stringify(arr),
  621. roleId: this.xiuRoleId
  622. },
  623. res => {
  624. if (res.code == "ok") {
  625. this.$message({
  626. message: '操作成功',
  627. type: "success"
  628. });
  629. this.handljues = false
  630. this.getUser()
  631. } else {
  632. this.$message({
  633. message: res.msg,
  634. type: "error"
  635. });
  636. }
  637. },
  638. error => {
  639. this.$message({
  640. message: error,
  641. type: "error"
  642. });
  643. });
  644. },
  645. deleteUser(targetUser) {
  646. this.$confirm("确定要删除该员工吗?", "提示", {
  647. //type: 'warning'
  648. }).then(() => {
  649. this.http.post('/user/deleteUser', {
  650. userId: targetUser.id,
  651. },
  652. res => {
  653. if (res.code == "ok") {
  654. this.$message({
  655. message: '删除成功',
  656. type: "success"
  657. });
  658. this.getUser()
  659. } else {
  660. this.$message({
  661. message: res.msg,
  662. type: "error"
  663. });
  664. }
  665. },
  666. error => {
  667. this.$message({
  668. message: error,
  669. type: "error"
  670. });
  671. });
  672. })
  673. },
  674. chufa(data, b, c, e) {
  675. if(this.depData == null || data.id != this.depData.id) {
  676. // this.depData = data.id
  677. this.depData = data;
  678. this.page = 1;
  679. this.getUser();
  680. }
  681. },
  682. jieDian(a, b, c) {
  683. var ids = a.id
  684. var arrs = this.jDarr
  685. arrs.push(ids)
  686. this.jDarr = arrs
  687. },
  688. shutDown(a, b, c) {
  689. var ids = a.id
  690. var arrs = []
  691. for (var i in this.jDarr) {
  692. if(this.jDarr[i] != ids) {
  693. arrs.push(this.jDarr[i])
  694. }
  695. }
  696. this.jDarr = arrs
  697. },
  698. mouseleave(data,$event){
  699. $event.currentTarget.firstElementChild.nextElementSibling.setAttribute('class','node none')
  700. },
  701. mouseover(data,$event){
  702. $event.currentTarget.lastChild.setAttribute('class','node block');
  703. },
  704. confirmDeactive() {
  705. this.http.post('/user/deactiveUser', {
  706. id: this.deactiveUser.id,
  707. inactiveDate: this.deactiveDate
  708. },
  709. res => {
  710. if (res.code == "ok") {
  711. this.deactiveDialog = false;
  712. this.$message({
  713. message: '停用成功',
  714. type: "success"
  715. });
  716. // this.getUsers();
  717. this.getUser()
  718. } else {
  719. this.$message({
  720. message: res.msg,
  721. type: "error"
  722. });
  723. }
  724. },
  725. error => {
  726. this.$message({
  727. message: error,
  728. type: "error"
  729. });
  730. });
  731. },
  732. showDeactiveDialog(item) {
  733. this.deactiveDialog = true;
  734. this.deactiveUser = item;
  735. },
  736. restrictNumber(targetId) {
  737. let inpu = document.getElementById(targetId);
  738. inpu.value = inpu.value.replace(/[^\d.]/g, ""); //仅保留数字和"."
  739. inpu.value = inpu.value.replace(/\.{2,}/g, "."); //两个连续的"."仅保留第一个"."
  740. inpu.value = inpu.value.replace(".", "$#*").replace(/\./g,'').replace('$#*','.');//去除其他"."
  741. inpu.value = inpu.value.replace(/^(\d+)\.(\d\d).*$/, '$1.$2');;//限制只能输入两个小数
  742. if (inpu.value.indexOf(".") < 0 && inpu.value != "") { //首位是0的话去掉
  743. inpu.value = parseFloat(inpu.value);
  744. }
  745. },
  746. showConfirmDialog() {
  747. if (this.toUserId == null || this.toUserId == '') {
  748. this.$message({
  749. message: '请选择要转让的人员',
  750. type: "error"
  751. });
  752. return;
  753. }
  754. this.$confirm("您将失去超级管理员角色,需要重新登录。确定要转让吗?", "提示", {
  755. //type: 'warning'
  756. }).then(() => {
  757. this.http.post('/user/changeSysManager', {
  758. toUserId: this.toUserId,
  759. myRoleId: this.myRoleId
  760. },
  761. res => {
  762. if (res.code == "ok") {
  763. sessionStorage.removeItem("user");
  764. this.$router.push("/login");
  765. } else {
  766. this.$message({
  767. message: res.msg,
  768. type: "error"
  769. });
  770. }
  771. },
  772. error => {
  773. this.$message({
  774. message: error,
  775. type: "error"
  776. });
  777. });
  778. });
  779. },
  780. transferRole() {
  781. this.transferDialog = true;
  782. this.http.post(this.port.manage.list, {
  783. departmentId: -1,
  784. pageIndex: 1,
  785. pageSize: 99999,
  786. keyword: this.keyword
  787. },
  788. res => {
  789. if (res.code == "ok") {
  790. this.allActiveUsers = res.data.records.filter(u=>u.isActive == 1 && u.id != this.user.id);
  791. } else {
  792. this.$message({
  793. message: res.msg,
  794. type: "error"
  795. });
  796. }
  797. },
  798. error => {
  799. this.$message({
  800. message: error,
  801. type: "error"
  802. });
  803. });
  804. },
  805. showExportDialog() {
  806. this.exportDialogVisible = true;
  807. },
  808. exportUsers() {
  809. this.http.post('/user/exportUsers', {
  810. containInvalid: this.containInvalid
  811. },
  812. res => {
  813. if (res.code == "ok") {
  814. this.exportDialogVisible = false;
  815. var aTag = document.createElement('a');
  816. aTag.download = "全部员工列表.xls";
  817. aTag.href = res.data;
  818. aTag.click();
  819. } else {
  820. this.$message({
  821. message: res.msg,
  822. type: "error"
  823. });
  824. }
  825. },
  826. error => {
  827. this.$message({
  828. message: error,
  829. type: "error"
  830. });
  831. });
  832. },
  833. showSalaryList(item) {
  834. this.userSalaryListDialog = true;
  835. this.userSalaryList = [];
  836. this.http.post('/user/getUserSalaryList', {
  837. id: item.id
  838. },
  839. res => {
  840. if (res.code == "ok") {
  841. this.userSalaryList = res.data;
  842. } else {
  843. this.$message({
  844. message: res.msg,
  845. type: "error"
  846. });
  847. }
  848. },
  849. error => {
  850. this.$message({
  851. message: error,
  852. type: "error"
  853. });
  854. });
  855. },
  856. getUsers() {
  857. this.http.post(this.port.manage.list, {
  858. departmentId: -1,
  859. pageIndex: 1,
  860. pageSize: 99999,
  861. keyword: this.keyword
  862. },
  863. res => {
  864. if (res.code == "ok") {
  865. this.users = res.data.records;
  866. } else {
  867. this.$message({
  868. message: res.msg,
  869. type: "error"
  870. });
  871. }
  872. },
  873. error => {
  874. this.$message({
  875. message: error,
  876. type: "error"
  877. });
  878. });
  879. },
  880. onSalaryTypeChange(value) {
  881. if (value == 1) {
  882. this.insertForm.monthCost = null;
  883. }
  884. },
  885. //选中部门
  886. choseDept(value) {
  887. console.log(value);
  888. },
  889. //月成本输入变化
  890. oninput(e) {
  891. this.insertForm.cost = (this.insertForm.monthCost/this.timeType.monthDays/this.timeType.allday).toFixed(2);
  892. },
  893. // 获取本公司的工作时间设置
  894. getCompanyTimeSetting() {
  895. this.http.post('/time-type/getCompanyTimeSetting',{
  896. companyId: this.user.companyId
  897. },
  898. res => {
  899. if (res.code == "ok") {
  900. this.timeType = res.data;
  901. } else {
  902. this.$message({
  903. message: res.msg,
  904. type: "error"
  905. });
  906. }
  907. },
  908. error => {
  909. this.listLoading = false;
  910. this.$message({
  911. message: error,
  912. type: "error"
  913. });
  914. }
  915. );
  916. },
  917. // 批量导入人员
  918. importUser(item) {
  919. //首先判断文件类型
  920. let str = item.file.name.split(".");
  921. let format = str[str.length - 1];
  922. if (format != "xls" && format != "xlsx") {
  923. this.$message({
  924. message: "请选择.xls或.xlsx文件",
  925. type: "error"
  926. });
  927. } else {
  928. this.listLoading = true;
  929. let formData = new FormData();
  930. formData.append("file", item.file);
  931. this.http.uploadFile( this.port.manage.import, formData,
  932. res => {
  933. this.$refs.upload.clearFiles();
  934. this.listLoading = false;
  935. if (res.code == "ok") {
  936. this.$message({
  937. message: "导入成功",
  938. type: "success"
  939. });
  940. //重新读取列表
  941. this.getUser();
  942. } else {
  943. this.$message({
  944. message: res.msg,
  945. type: "error"
  946. });
  947. }
  948. },
  949. error => {
  950. this.$refs.upload.clearFiles();
  951. this.listLoading = false;
  952. this.$message({
  953. message: error,
  954. type: "error"
  955. });
  956. });
  957. }
  958. },
  959. //分页
  960. handleCurrentChange(val) {
  961. this.page = val;
  962. this.getUser();
  963. },
  964. handleSizeChange(val) {
  965. this.size = val;
  966. this.getUser();
  967. },
  968. //获取所有员工的列表
  969. getUser() {
  970. console.log(12345)
  971. this.listLoading = true;
  972. this.http.post( this.port.manage.list, {
  973. departmentId: this.depData.id,
  974. pageIndex: this.page,
  975. pageSize: this.size,
  976. keyword: this.keyword,
  977. status: this.status,
  978. // role: this.role
  979. roleId: this.roleId
  980. },
  981. res => {
  982. this.listLoading = false;
  983. if (res.code == "ok") {
  984. this.list = res.data.records;
  985. this.total = res.data.total;
  986. } else {
  987. this.$message({
  988. message: res.msg,
  989. type: "error"
  990. });
  991. }
  992. },
  993. error => {
  994. this.listLoading = false;
  995. this.$message({
  996. message: error,
  997. type: "error"
  998. });
  999. });
  1000. },
  1001. resetPwd(user) {
  1002. this.$confirm( "确定要为" + user.name + "重置密码吗?", "重置密码", {
  1003. confirmButtonText: "确定",
  1004. cancelButtonText: "取消",
  1005. type: "warning"
  1006. })
  1007. .then(() => {
  1008. this.http.post('/user/resetPwd', { userId: user.id },
  1009. res => {
  1010. if (res.code == "ok") {
  1011. this.$message({
  1012. message: "密码已重置为000000,请通知员工及时修改",
  1013. type: "success"
  1014. });
  1015. } else {
  1016. this.$message({
  1017. message: res.msg,
  1018. type: "error"
  1019. });
  1020. }
  1021. },
  1022. error => {
  1023. this.listLoading = false;
  1024. this.$message({
  1025. message: error,
  1026. type: "error"
  1027. });
  1028. });
  1029. })
  1030. .catch(() => {});
  1031. },
  1032. // 新增、编辑人员
  1033. openInsertDialog(i) {
  1034. if (i != null) {
  1035. var list = JSON.parse(JSON.stringify(this.list[i])) , arr = [] , array = [];
  1036. if(list.departmentCascade!='0' && list.departmentCascade!=null) {
  1037. if(list.departmentCascade.indexOf(",")>-1) {
  1038. arr = list.departmentCascade.split(",");
  1039. } else {
  1040. arr = [].concat(list.departmentCascade)
  1041. }
  1042. }
  1043. for(var i in arr) {
  1044. array.push(parseInt(arr[i]))
  1045. }
  1046. this.insertForm = {
  1047. id: list.id,
  1048. name: list.name,
  1049. phone: list.phone,
  1050. // role: list.role,
  1051. roleId: list.roleId,
  1052. monthCost:list.monthCost,
  1053. cost: list.cost,
  1054. departmentId: array.reverse(),
  1055. salaryType: list.salaryType,
  1056. costApplyDate: list.costApplyDate,
  1057. };
  1058. this.title = "编辑人员"
  1059. } else {
  1060. this.insertForm = {
  1061. id: null,
  1062. name: null,
  1063. phone: null,
  1064. // role: null,
  1065. roleId: null,
  1066. monthCost:null,
  1067. cost: null,
  1068. departmentId: null,
  1069. salaryType:0,
  1070. costApplyDate: util.formatDate.format(new Date(), 'yyyy-MM-dd'),
  1071. };
  1072. this.title = "新增人员"
  1073. }
  1074. this.dialogVisible = true;
  1075. },
  1076. submitInsert() {
  1077. var form = {}
  1078. this.$refs.form1.validate(valid => {
  1079. if (valid) {
  1080. this.submitLoading = true;
  1081. form = {
  1082. name: this.insertForm.name,
  1083. phone: this.insertForm.phone,
  1084. // role: this.insertForm.role,
  1085. roleId: this.insertForm.roleId,
  1086. monthCost: this.insertForm.monthCost,
  1087. cost: this.insertForm.cost,
  1088. salaryType: this.insertForm.salaryType,
  1089. };
  1090. if (this.insertForm.id != null) {
  1091. form.id = this.insertForm.id;
  1092. }
  1093. if (this.insertForm.costApplyDate != null) {
  1094. form.costApplyDate = this.insertForm.costApplyDate;
  1095. }
  1096. if (this.insertForm.departmentId != null) {
  1097. form.departmentId = this.insertForm.departmentId[this.insertForm.departmentId.length-1];
  1098. }
  1099. }
  1100. });
  1101. console.log(form, '提交的数据')
  1102. // return
  1103. this.http.post( this.port.manage.insert, form,
  1104. res => {
  1105. this.submitLoading = false;
  1106. if (res.code == "ok") {
  1107. this.$message({
  1108. message: this.insertForm.id != null ? "修改" : "创建" + "成功",
  1109. type: "success"
  1110. });
  1111. this.dialogVisible = false;
  1112. this.getUser();
  1113. this.getUsers()
  1114. } else {
  1115. this.$message({
  1116. message: res.msg,
  1117. type: "error"
  1118. });
  1119. }
  1120. },
  1121. error => {
  1122. this.listLoading = false;
  1123. this.$message({
  1124. message: error,
  1125. type: "error"
  1126. });
  1127. });
  1128. },
  1129. // 切换角色
  1130. switchRole(index) {
  1131. this.listLoading = true;
  1132. this.http.post( this.port.manage.permission, { id: this.list[index].id },
  1133. res => {
  1134. this.listLoading = false;
  1135. if (res.code == "ok") {
  1136. this.$message({
  1137. message: "切换角色成功",
  1138. type: "success"
  1139. });
  1140. //重新读取列表
  1141. this.getUser();
  1142. } else {
  1143. this.$message({
  1144. message: res.msg,
  1145. type: "error"
  1146. });
  1147. }
  1148. },
  1149. error => {
  1150. this.listLoading = false;
  1151. this.$message({
  1152. message: error,
  1153. type: "error"
  1154. });
  1155. });
  1156. },
  1157. // 删除用户
  1158. setActive(item, isActive) {
  1159. var txt = isActive==1?"启用":"停用";
  1160. this.$confirm( "确定要"+txt +" " + item.name + " 吗?", "账号"+txt, {
  1161. confirmButtonText: "确定",
  1162. cancelButtonText: "取消",
  1163. type: "warning"
  1164. })
  1165. .then(() => {
  1166. this.listLoading = true;
  1167. this.http.post('/user/setActive', { id: item.id, isActive: isActive},
  1168. res => {
  1169. this.listLoading = false;
  1170. if (res.code == "ok") {
  1171. this.$message({
  1172. message: txt+"成功",
  1173. type: "success"
  1174. });
  1175. //重新读取列表
  1176. this.getUser();
  1177. } else {
  1178. this.$message({
  1179. message: res.msg,
  1180. type: "error"
  1181. });
  1182. }
  1183. },
  1184. error => {
  1185. this.listLoading = false;
  1186. this.$message({
  1187. message: error,
  1188. type: "error"
  1189. });
  1190. });
  1191. })
  1192. .catch(() => {});
  1193. },
  1194. // 修改老板的成本
  1195. openInsertDialog1(i) {
  1196. var list1 = JSON.parse(JSON.stringify(this.list[i])) , arr1 = [] , array1 = [];
  1197. if(list1.departmentCascade!='0' && list1.departmentCascade!=null) {
  1198. if(list1.departmentCascade.indexOf(",")>-1) {
  1199. arr1 = list1.departmentCascade.split(",");
  1200. } else {
  1201. arr1 = [].concat(list1.departmentCascade)
  1202. }
  1203. }
  1204. for(var i in arr1) {
  1205. array1.push(parseInt(arr1[i]))
  1206. }
  1207. console.log(list1)
  1208. this.insertForm = {
  1209. id: list1.id,
  1210. name: list1.name,
  1211. phone: list1.phone,
  1212. role: list1.role,
  1213. monthCost:list1.monthCost,
  1214. cost: list1.cost,
  1215. departmentId: array1.reverse(),
  1216. salaryType: list1.salaryType,
  1217. name: list1.name
  1218. };
  1219. this.dialogVisible1 = true;
  1220. },
  1221. submitInsert1() {
  1222. var form = {}
  1223. this.$refs.form1.validate(valid => {
  1224. if (valid) {
  1225. this.submitLoading = true;
  1226. form = {
  1227. id: this.insertForm.id,
  1228. name: this.insertForm.name,
  1229. phone: this.insertForm.phone,
  1230. // role: this.insertForm.role,
  1231. roleId: this.insertForm.roleId,
  1232. monthCost: this.insertForm.monthCost,
  1233. cost: this.insertForm.cost
  1234. };
  1235. if (this.insertForm.departmentId != null) {
  1236. form.departmentId = this.insertForm.departmentId[this.insertForm.departmentId.length-1];
  1237. }
  1238. if (this.insertForm.costApplyDate != null) {
  1239. form.costApplyDate = this.insertForm.costApplyDate;
  1240. }
  1241. }
  1242. });
  1243. this.http.post( this.port.manage.insert, form,
  1244. res => {
  1245. this.submitLoading = false;
  1246. if (res.code == "ok") {
  1247. this.$message({
  1248. message: "修改成功",
  1249. type: "success"
  1250. });
  1251. this.dialogVisible1 = false;
  1252. //重新读取列表
  1253. this.getUser();
  1254. this.getUsers()
  1255. } else {
  1256. this.$message({
  1257. message: res.msg,
  1258. type: "error"
  1259. });
  1260. }
  1261. },
  1262. error => {
  1263. this.listLoading = false;
  1264. this.$message({
  1265. message: error,
  1266. type: "error"
  1267. });
  1268. });
  1269. },
  1270. // 获取部门列表
  1271. getDepartment() {
  1272. this.http.post( this.port.manage.depList, {},
  1273. res => {
  1274. if (res.code == "ok") {
  1275. var list = res.data , list1 = JSON.parse(JSON.stringify(res.data));
  1276. list.splice(0,0,{
  1277. id: -1,
  1278. label: '全部人员',
  1279. })
  1280. list.push({
  1281. id: 0,
  1282. label: '未分配',
  1283. })
  1284. this.data = list;
  1285. console.log(list, "部门数据")
  1286. this.option = this.changeArr(list1);
  1287. } else {
  1288. this.$message({
  1289. message: res.msg,
  1290. type: "error"
  1291. });
  1292. }
  1293. },
  1294. error => {
  1295. this.$message({
  1296. message: error,
  1297. type: "error"
  1298. });
  1299. });
  1300. },
  1301. // 修改数组
  1302. changeArr(arr) {
  1303. for (var i = 0; i < arr.length; i++) {
  1304. if(arr[i].id != -1 && arr[i].id != 0) {
  1305. if (arr[i].children != null && arr[i].children.length>0) {
  1306. arr[i].children = this.changeArr(arr[i].children);
  1307. }
  1308. arr[i].id && (arr[i].value = arr[i].id);
  1309. delete arr[i].id;
  1310. }
  1311. }
  1312. for(var i in arr) {
  1313. if(arr[i].id == -1 || arr[i].id == 0) {
  1314. arr.splice(i,1)
  1315. }
  1316. }
  1317. return arr;
  1318. },
  1319. // 部门列表点击
  1320. handleNodeClick(data) {
  1321. console.log(data, 999)
  1322. if(this.depData == null || data.id != this.depData.id) {
  1323. this.depData = data;
  1324. this.page = 1;
  1325. this.getUser();
  1326. }
  1327. },
  1328. // 新增、修改部门
  1329. createDepartment(i) {
  1330. setTimeout(() => {
  1331. var that = this
  1332. if(i == -2) {//创建子部门
  1333. that.depForm = {
  1334. id: null,
  1335. name: null,
  1336. parentId: null,
  1337. managerId: null,
  1338. }
  1339. if(that.depData.id != -1 && that.depData.id != 0) {
  1340. that.depForm.parentId = that.depData.id;
  1341. }
  1342. that.depTitle = "新增子部门";
  1343. } else if(i == -1) {//创建一级部门
  1344. that.depForm = {
  1345. id: null,
  1346. name: null,
  1347. parentId: null,
  1348. managerId: null,
  1349. }
  1350. that.depTitle = "新增部门";
  1351. } else {
  1352. if(that.depData.managerId == "null") {
  1353. that.depData.managerId = ''
  1354. }
  1355. if(that.depData.reportAuditUserid == "null") {
  1356. that.depData.reportAuditUserid = ''
  1357. }
  1358. that.depForm = {
  1359. id: that.depData.id,
  1360. name: that.depData.label,
  1361. parentId: that.depData.parentId,
  1362. managerId: that.depData.managerId,
  1363. reportAuditUserid: that.depData.reportAuditUserid
  1364. }
  1365. // if(that.depData.reportAuditUserid != null && that.depData.reportAuditUserid != "null" && that.depData.reportAuditUserid.length > 0) {
  1366. // that.depForm.reportAuditUserid = that.depData.reportAuditUserid
  1367. // }
  1368. that.depTitle = "编辑部门";
  1369. }
  1370. that.departmentVisible = true;
  1371. })
  1372. // if(i == -2) {//创建子部门
  1373. // this.depForm = {
  1374. // id: null,
  1375. // name: null,
  1376. // parentId: null,
  1377. // managerId: null,
  1378. // }
  1379. // if(this.depData.id != -1 && this.depData.id != 0) {
  1380. // this.depForm.parentId = this.depData.id;
  1381. // }
  1382. // this.depTitle = "新增子部门";
  1383. // } else if(i == -1) {//创建一级部门
  1384. // this.depForm = {
  1385. // id: null,
  1386. // name: null,
  1387. // parentId: null,
  1388. // managerId: null,
  1389. // }
  1390. // this.depTitle = "新增部门";
  1391. // } else {
  1392. // if(this.depData.managerId == "null") {
  1393. // this.depData.managerId = ''
  1394. // }
  1395. // if(this.depData.reportAuditUserid == "null") {
  1396. // this.depData.reportAuditUserid = ''
  1397. // }
  1398. // this.depForm = {
  1399. // id: this.depData.id,
  1400. // name: this.depData.label,
  1401. // parentId: this.depData.parentId,
  1402. // managerId: this.depData.managerId,
  1403. // reportAuditUserid: this.depData.reportAuditUserid
  1404. // }
  1405. // // if(this.depData.reportAuditUserid != null && this.depData.reportAuditUserid != "null" && this.depData.reportAuditUserid.length > 0) {
  1406. // // this.depForm.reportAuditUserid = this.depData.reportAuditUserid
  1407. // // }
  1408. // this.depTitle = "编辑部门";
  1409. // }
  1410. // this.departmentVisible = true;
  1411. },
  1412. submitDepartment() {
  1413. this.$refs.depForm.validate(valid => {
  1414. if (valid) {
  1415. var form = {
  1416. name: this.depForm.name,
  1417. };
  1418. if(this.depForm.id != null) {
  1419. form.id = this.depForm.id
  1420. }
  1421. if(this.depForm.parentId != null) {
  1422. form.parentId = this.depForm.parentId
  1423. }
  1424. if (this.depForm.managerId) {
  1425. form.managerId = this.depForm.managerId
  1426. }
  1427. console.log(this.depForm)
  1428. if (this.depForm.reportAuditUserid) {
  1429. form.reportAuditUserid = this.depForm.reportAuditUserid
  1430. }
  1431. this.http.post( this.depForm.id==null?this.port.manage.add:this.port.manage.edit, form,
  1432. res => {
  1433. if (res.code == "ok") {
  1434. this.$message({
  1435. message: this.depForm.id==null?"新增成功":"修改成功",
  1436. type: "success"
  1437. });
  1438. this.departmentVisible = false;
  1439. if (this.depForm.id !=null) {
  1440. this.depData.label = form.name;
  1441. this.depData.managerId = form.managerId;
  1442. }
  1443. this.getDepartment();
  1444. } else {
  1445. this.$message({
  1446. message: res.msg,
  1447. type: "error"
  1448. });
  1449. }
  1450. },
  1451. error => {
  1452. this.listLoading = false;
  1453. this.$message({
  1454. message: error,
  1455. type: "error"
  1456. });
  1457. });
  1458. }
  1459. });
  1460. },
  1461. // 删除部门
  1462. deleteDep() {
  1463. var that = this
  1464. setTimeout(() =>{
  1465. that.$confirm( "确定要删除部门" + that.depData.label + "吗?", "删除部门", {
  1466. confirmButtonText: "确定",
  1467. cancelButtonText: "取消",
  1468. type: "warning"
  1469. })
  1470. .then(() => {
  1471. that.listLoading = true;
  1472. that.http.post( that.port.manage.del, { id: that.depData.id },
  1473. res => {
  1474. that.listLoading = false;
  1475. if (res.code == "ok") {
  1476. that.$message({
  1477. message: "删除成功",
  1478. type: "success"
  1479. });
  1480. that.depData = {
  1481. id: -1,
  1482. label: '全部人员',
  1483. }
  1484. that.getDepartment();
  1485. that.getUser();
  1486. } else {
  1487. that.$message({
  1488. message: res.msg,
  1489. type: "error"
  1490. });
  1491. }
  1492. },
  1493. error => {
  1494. that.listLoading = false;
  1495. that.$message({
  1496. message: error,
  1497. type: "error"
  1498. });
  1499. });
  1500. })
  1501. .catch(() => {});
  1502. },100);
  1503. // this.$confirm( "确定要删除部门" + this.depData.label + "吗?", "删除部门", {
  1504. // confirmButtonText: "确定",
  1505. // cancelButtonText: "取消",
  1506. // type: "warning"
  1507. // })
  1508. // .then(() => {
  1509. // this.listLoading = true;
  1510. // this.http.post( this.port.manage.del, { id: this.depData.id },
  1511. // res => {
  1512. // this.listLoading = false;
  1513. // if (res.code == "ok") {
  1514. // this.$message({
  1515. // message: "删除成功",
  1516. // type: "success"
  1517. // });
  1518. // this.depData = {
  1519. // id: -1,
  1520. // label: '全部人员',
  1521. // }
  1522. // this.getDepartment();
  1523. // this.getUser();
  1524. // } else {
  1525. // this.$message({
  1526. // message: res.msg,
  1527. // type: "error"
  1528. // });
  1529. // }
  1530. // },
  1531. // error => {
  1532. // this.listLoading = false;
  1533. // this.$message({
  1534. // message: error,
  1535. // type: "error"
  1536. // });
  1537. // });
  1538. // })
  1539. // .catch(() => {});
  1540. },
  1541. // 关键搜索
  1542. searchList() {
  1543. console.log(this.keyword)
  1544. this.listLoading = true;
  1545. this.http.post( this.port.manage.list, {
  1546. departmentId: this.depData.id,
  1547. pageIndex: this.page,
  1548. pageSize: this.size,
  1549. keyword: this.keyword
  1550. },
  1551. res => {
  1552. this.listLoading = false;
  1553. if (res.code == "ok") {
  1554. this.list = res.data.records;
  1555. this.total = res.data.total;
  1556. } else {
  1557. this.$message({
  1558. message: res.msg,
  1559. type: "error"
  1560. });
  1561. }
  1562. },
  1563. error => {
  1564. this.listLoading = false;
  1565. this.$message({
  1566. message: error,
  1567. type: "error"
  1568. });
  1569. });
  1570. },
  1571. // 获取角色
  1572. acquireRole() {
  1573. // this.http.post('/permission/getFrontRoleList', {
  1574. this.http.post('/permission/getFrontRoleList', {
  1575. companyId: this.user.companyId
  1576. },
  1577. res => {
  1578. if (res.code == "ok") {
  1579. console.log(res.data, '获取角色')
  1580. this.acquireRoleList = res.data
  1581. var arr = []
  1582. for(var i in res.data) {
  1583. if(res.data[i].rolename != '系统管理员') {
  1584. arr.push(res.data[i])
  1585. }
  1586. }
  1587. this.acquireRoleLists = arr
  1588. } else {
  1589. this.$message({
  1590. message: res.msg,
  1591. type: "error"
  1592. });
  1593. }
  1594. },
  1595. error => {
  1596. this.$message({
  1597. message: error,
  1598. type: "error"
  1599. });
  1600. });
  1601. }
  1602. },
  1603. created() {
  1604. let height = window.innerHeight;
  1605. this.tableHeight = height - 195;
  1606. const that = this;
  1607. window.onresize = function temp() {
  1608. that.tableHeight = window.innerHeight - 195;
  1609. };
  1610. },
  1611. mounted() {
  1612. this.deactiveDate = util.formatDate.format(new Date(), 'yyyy-MM-dd');
  1613. this.getDepartment();
  1614. this.getUser();
  1615. this.getCompanyTimeSetting();
  1616. this.getUsers();
  1617. this.acquireRole();
  1618. this.isDingShow = this.$store.state.isDing;
  1619. }
  1620. };
  1621. </script>
  1622. <style lang="scss" scoped>
  1623. .custom-tree-node {
  1624. flex: 1;
  1625. display: flex;
  1626. align-items: center;
  1627. justify-content: space-between;
  1628. font-size: 14px;
  1629. padding-right: 8px;
  1630. }
  1631. .left {
  1632. border-right: 1px solid #f2f2f2;
  1633. overflow: hidden;
  1634. .department {
  1635. background:#f2f2f2;
  1636. line-height: 60px;
  1637. color:#666;
  1638. padding:0 10px;
  1639. height:60px;
  1640. font-size: 15px;
  1641. div {
  1642. float: right;
  1643. color: #20a0ff;
  1644. font-size: 14px;
  1645. cursor: pointer;
  1646. }
  1647. }
  1648. .tree {
  1649. overflow: auto;
  1650. }
  1651. }
  1652. .nowTime {
  1653. height: 40px;
  1654. line-height: 40px;
  1655. font-size: 16px;
  1656. color: #20a0ff;
  1657. margin-left: 10px;
  1658. cursor: pointer;
  1659. i {
  1660. margin-right: 10px;
  1661. }
  1662. }
  1663. .none {
  1664. display: none;
  1665. }
  1666. .block {
  1667. display: block;
  1668. }
  1669. </style>
  1670. <style lang="scss">
  1671. .tree {
  1672. .el-tree-node__label {
  1673. overflow-x: hidden;
  1674. white-space: nowrap;
  1675. text-overflow: ellipsis;
  1676. }
  1677. }
  1678. .el-divider--horizontal {
  1679. margin: 0px;
  1680. background:#f3f3f3;
  1681. }
  1682. //全局的作用范围
  1683. .el-tree-node__content {
  1684. height:36px;
  1685. }
  1686. </style>