index.vue 71 KB

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