index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" size="small" v-show="showSearch" label-width="68px">
  4. <el-form-item>
  5. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  6. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  7. </el-form-item>
  8. </el-form>
  9. <el-row :gutter="10" class="mb8">
  10. <el-col :span="1.5">
  11. <el-button
  12. type="primary"
  13. plain
  14. icon="el-icon-plus"
  15. size="mini"
  16. @click="handleAdd"
  17. v-hasPermi="['branch:member:add']"
  18. >新增</el-button>
  19. </el-col>
  20. <el-col :span="1.5">
  21. <el-button
  22. type="success"
  23. plain
  24. icon="el-icon-edit"
  25. size="mini"
  26. :disabled="single"
  27. @click="handleUpdate"
  28. v-hasPermi="['branch:member:edit']"
  29. >修改</el-button>
  30. </el-col>
  31. <el-col :span="1.5">
  32. <el-button
  33. type="danger"
  34. plain
  35. icon="el-icon-delete"
  36. size="mini"
  37. :disabled="multiple"
  38. @click="handleDelete"
  39. v-hasPermi="['branch:member:remove']"
  40. >删除</el-button>
  41. </el-col>
  42. <el-col :span="1.5">
  43. <el-button
  44. type="info"
  45. plain
  46. icon="el-icon-upload2"
  47. size="mini"
  48. @click="handleImport"
  49. v-hasPermi="['branch:member:edit']"
  50. >导入</el-button>
  51. </el-col>
  52. <el-col :span="1.5">
  53. <el-button
  54. type="warning"
  55. plain
  56. icon="el-icon-download"
  57. size="mini"
  58. @click="handleExport"
  59. v-hasPermi="['branch:member:export']"
  60. >导出</el-button>
  61. </el-col>
  62. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  63. </el-row>
  64. <el-table v-loading="loading" :data="memberList" @selection-change="handleSelectionChange" :height="clientHeight" border>
  65. <el-table-column type="selection" width="55" align="center" />
  66. <el-table-column label="姓名" align="center" prop="nickName"/>
  67. <el-table-column label="性别" align="center" prop="sex" :formatter="sysUserSexFormat"/>
  68. <el-table-column label="出生年月" align="center" prop="birthday">
  69. <template slot-scope="scope">
  70. <span>{{ parseTime(scope.row.birthday, '{y}-{m}-{d}') }}</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="学历" align="center" prop="educationLevel" :formatter="educationLevelFormat"/>
  74. <el-table-column label="入职时间" align="center" prop="workEntryTime">
  75. <template slot-scope="scope">
  76. <span>{{ parseTime(scope.row.workEntryTime, '{y}-{m}-{d}') }}</span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="现岗位" align="center" prop="postString"/>
  80. <el-table-column label="入党时间" align="center" prop="partyEntryTime">
  81. <template slot-scope="scope">
  82. <span>{{ parseTime(scope.row.partyEntryTime, '{y}-{m}-{d}') }}</span>
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="委员分工" align="center" prop="roleString"/>
  86. <el-table-column label="任职时间" align="center" prop="labourEntryTime">
  87. <template slot-scope="scope">
  88. <span>{{ parseTime(scope.row.labourEntryTime, '{y}-{m}-{d}') }}</span>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="离任时间" align="center" prop="labourLeaveTime">
  92. <template slot-scope="scope">
  93. <span>{{ parseTime(scope.row.labourLeaveTime, '{y}-{m}-{d}') }}</span>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  97. <template slot-scope="scope">
  98. <el-button
  99. size="mini"
  100. type="text"
  101. icon="el-icon-edit"
  102. @click="handleUpdate(scope.row)"
  103. v-hasPermi="['branch:member:edit']"
  104. >修改</el-button>
  105. <el-button
  106. size="mini"
  107. type="text"
  108. icon="el-icon-delete"
  109. @click="handleDelete(scope.row)"
  110. v-hasPermi="['branch:member:remove']"
  111. >删除</el-button>
  112. </template>
  113. </el-table-column>
  114. </el-table>
  115. <pagination
  116. v-show="total>0"
  117. :total="total"
  118. :page.sync="queryParams.pageNum"
  119. :limit.sync="queryParams.pageSize"
  120. @pagination="getList"
  121. />
  122. <!-- 添加或修改支部成员管理对话框 -->
  123. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  124. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  125. <el-row>
  126. <el-col :span="12">
  127. <el-form-item label="绑定用户" prop="userId">
  128. <el-select v-model="form.userId" placeholder="请选择绑定用户">
  129. <el-option
  130. v-for="dict in userList"
  131. :key="dict.dictValue"
  132. :label="dict.dictLabel"
  133. :value="dict.dictValue"
  134. ></el-option>
  135. </el-select>
  136. </el-form-item>
  137. </el-col>
  138. <el-col :span="12">
  139. <el-form-item label="成员类型" prop="memberType">
  140. <el-select v-model="form.memberType" placeholder="请选择成员类型">
  141. <el-option
  142. v-for="dict in memberTypeOptions"
  143. :key="dict.dictValue"
  144. :label="dict.dictLabel"
  145. :value="dict.dictValue"
  146. ></el-option>
  147. </el-select>
  148. </el-form-item>
  149. </el-col>
  150. <el-col :span="12">
  151. <el-form-item label="出生年月" prop="birthday">
  152. <el-date-picker clearable size="small" style="width: 200px"
  153. v-model="form.birthday"
  154. type="date"
  155. value-format="yyyy-MM-dd"
  156. placeholder="选择出生年月">
  157. </el-date-picker>
  158. </el-form-item>
  159. </el-col>
  160. <el-col :span="12">
  161. <el-form-item label="学历" prop="educationLevel">
  162. <el-select v-model="form.educationLevel" placeholder="请选择学历">
  163. <el-option
  164. v-for="dict in educationLevelOptions"
  165. :key="dict.dictValue"
  166. :label="dict.dictLabel"
  167. :value="dict.dictValue"
  168. ></el-option>
  169. </el-select>
  170. </el-form-item>
  171. </el-col>
  172. <el-col :span="12">
  173. <el-form-item label="入职时间" prop="workEntryTime">
  174. <el-date-picker clearable size="small" style="width: 200px"
  175. v-model="form.workEntryTime"
  176. type="date"
  177. value-format="yyyy-MM-dd"
  178. placeholder="选择入职时间">
  179. </el-date-picker>
  180. </el-form-item>
  181. </el-col>
  182. <el-col :span="12">
  183. <el-form-item label="入党时间" prop="partyEntryTime">
  184. <el-date-picker clearable size="small" style="width: 200px"
  185. v-model="form.partyEntryTime"
  186. type="date"
  187. value-format="yyyy-MM-dd"
  188. placeholder="选择入党时间">
  189. </el-date-picker>
  190. </el-form-item>
  191. </el-col>
  192. <el-col :span="12">
  193. <el-form-item label="任职时间" prop="labourEntryTime">
  194. <el-date-picker clearable size="small" style="width: 200px"
  195. v-model="form.labourEntryTime"
  196. type="date"
  197. value-format="yyyy-MM-dd"
  198. placeholder="选择任职时间">
  199. </el-date-picker>
  200. </el-form-item>
  201. </el-col>
  202. <el-col :span="12">
  203. <el-form-item label="离任时间" prop="labourLeaveTime">
  204. <el-date-picker clearable size="small" style="width: 200px"
  205. v-model="form.labourLeaveTime"
  206. type="date"
  207. value-format="yyyy-MM-dd"
  208. placeholder="选择离任时间">
  209. </el-date-picker>
  210. </el-form-item>
  211. </el-col>
  212. <el-col :span="12">
  213. <el-form-item label="归属部门" prop="deptId">
  214. <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
  215. </el-form-item>
  216. </el-col>
  217. </el-row>
  218. </el-form>
  219. <div slot="footer" class="dialog-footer">
  220. <el-button type="primary" @click="submitForm">确 定</el-button>
  221. <el-button @click="cancel">取 消</el-button>
  222. </div>
  223. </el-dialog>
  224. <!-- 用户导入对话框 -->
  225. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  226. <el-upload
  227. ref="upload"
  228. :limit="1"
  229. accept=".xlsx, .xls"
  230. :headers="upload.headers"
  231. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  232. :disabled="upload.isUploading"
  233. :on-progress="handleFileUploadProgress"
  234. :on-success="handleFileSuccess"
  235. :auto-upload="false"
  236. drag
  237. >
  238. <i class="el-icon-upload"></i>
  239. <div class="el-upload__text">
  240. 将文件拖到此处,或
  241. <em>点击上传</em>
  242. </div>
  243. <div class="el-upload__tip" slot="tip">
  244. <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
  245. <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
  246. </div>
  247. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  248. </el-upload>
  249. <div slot="footer" class="dialog-footer">
  250. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  251. <el-button @click="upload.open = false">取 消</el-button>
  252. </div>
  253. </el-dialog>
  254. </div>
  255. </template>
  256. <script>
  257. import { listMember, getMember, delMember, addMember, updateMember, exportMember, importTemplate} from "@/api/branch/member";
  258. import { treeselect } from "@/api/system/dept";
  259. import { getToken } from "@/utils/auth";
  260. import Treeselect from "@riophae/vue-treeselect";
  261. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  262. import { listUser} from "@/api/system/user";
  263. export default {
  264. name: "Member",
  265. components: { Treeselect },
  266. data() {
  267. return {
  268. // 遮罩层
  269. loading: true,
  270. // 选中数组
  271. ids: [],
  272. // 非单个禁用
  273. single: true,
  274. // 非多个禁用
  275. multiple: true,
  276. // 显示搜索条件
  277. showSearch: false,
  278. // 总条数
  279. total: 0,
  280. // 支部成员管理表格数据
  281. memberList: [],
  282. // 弹出层标题
  283. title: "",
  284. // 部门树选项
  285. deptOptions: undefined,
  286. clientHeight:300,
  287. // 是否显示弹出层
  288. open: false,
  289. // 成员类型字典
  290. memberTypeOptions: [],
  291. // 学历字典
  292. educationLevelOptions: [],
  293. // 用户性别字典
  294. sysUserSexOptions: [],
  295. // 成员民族字典
  296. memberEthnicOptions: [],
  297. // 用户列表
  298. userList: [],
  299. // 用户导入参数
  300. upload: {
  301. // 是否显示弹出层(用户导入)
  302. open: false,
  303. // 弹出层标题(用户导入)
  304. title: "",
  305. // 是否禁用上传
  306. isUploading: false,
  307. // 是否更新已经存在的用户数据
  308. updateSupport: 0,
  309. // 设置上传的请求头部
  310. headers: { Authorization: "Bearer " + getToken() },
  311. // 上传的地址
  312. url: process.env.VUE_APP_BASE_API + "/branch/member/importData"
  313. },
  314. // 查询参数
  315. queryParams: {
  316. pageNum: 1,
  317. pageSize: 20,
  318. memberId: null,
  319. userId: null,
  320. memberType: null,
  321. birthday: null,
  322. educationLevel: null,
  323. workJoinTime: null,
  324. workEntryTime: null,
  325. partyEntryTime: null,
  326. currentPost: null,
  327. labourDivision: null,
  328. labourEntryTime: null,
  329. labourLeaveTime: null,
  330. entryTime: null,
  331. leaveTime: null,
  332. isLeague: null,
  333. applyTime: null,
  334. formCreateTime: null,
  335. currentMentor: null,
  336. planDevelopDuration: null,
  337. isTrained: null,
  338. remarks: null,
  339. deptId: null,
  340. },
  341. // 表单参数
  342. form: {
  343. },
  344. // 表单校验
  345. rules: {
  346. userId: [
  347. { required: true, message: "绑定用户不能为空", trigger: "blur" }
  348. ],
  349. memberType: [
  350. { required: true, message: "成员类型不能为空", trigger: "blur" }
  351. ],
  352. }
  353. };
  354. },
  355. watch: {
  356. // 根据名称筛选部门树
  357. deptName(val) {
  358. this.$refs.tree.filter(val);
  359. }
  360. },
  361. created() {
  362. //设置表格高度对应屏幕高度
  363. this.$nextTick(() => {
  364. this.clientHeight = document.body.clientHeight -250
  365. })
  366. this.getList();
  367. this.getTreeselect();
  368. this.getDicts("member_education_level").then(response => {
  369. this.educationLevelOptions = response.data;
  370. });
  371. this.getDicts("member_type").then(response => {
  372. this.memberTypeOptions = response.data;
  373. });
  374. this.getDicts("sys_user_sex").then(response => {
  375. this.sysUserSexOptions = response.data;
  376. });
  377. this.getDicts("member_ethnic").then(response => {
  378. this.memberEthnicOptions = response.data;
  379. });
  380. this.getUserList();
  381. },
  382. methods: {
  383. /** 查询用户列表 */
  384. getUserList() {
  385. listUser().then(response => {
  386. let rows = response.rows;
  387. let userList = [];
  388. for(let i = 0; i < rows.length; i++) {
  389. if (rows[i].userName != "admin") {
  390. let user = { "dictValue" : rows[i].userId, "dictLabel" : rows[i].nickName};
  391. userList.push(user);
  392. }
  393. }
  394. this.userList = userList;
  395. });
  396. },
  397. /** 查询支部成员管理列表 */
  398. getList() {
  399. this.loading = true;
  400. listMember(this.queryParams).then(response => {
  401. let rows = response.rows;
  402. let memberList = [];
  403. for (let i = 0; i < rows.length; i++) {
  404. if (rows[i].memberType == "2" || rows[i].memberType == "3") {//党员、党委
  405. memberList.push(rows[i]);
  406. }
  407. }
  408. this.memberList = memberList;
  409. for (let i = 0; i < this.memberList.length; i++) {
  410. let posts = Array.from(this.memberList[i].posts);
  411. let roles = Array.from(this.memberList[i].roles);
  412. let roleString = "";
  413. let postString = "";
  414. for (let j = 0; j < roles.length; j++) {
  415. if (j > 0) {
  416. roleString += "\n兼" + roles[j].roleName;
  417. } else {
  418. roleString += roles[j].roleName;
  419. }
  420. }
  421. for (let j = 0; j < posts.length; j++) {
  422. if (j > 0) {
  423. postString += "\n兼" + posts[j].postName;
  424. } else {
  425. postString += posts[j].postName;
  426. }
  427. }
  428. this.memberList[i].roleString = roleString;
  429. this.memberList[i].postString = postString;
  430. }
  431. this.total = response.total;
  432. this.loading = false;
  433. });
  434. },
  435. /** 查询部门下拉树结构 */
  436. getTreeselect() {
  437. treeselect().then(response => {
  438. this.deptOptions = response.data;
  439. });
  440. },
  441. // 学历字典翻译
  442. educationLevelFormat(row, column) {
  443. return this.selectDictLabel(this.educationLevelOptions, row.educationLevel);
  444. },
  445. // 成员类型字典翻译
  446. memberTypeFormat(row, column) {
  447. return this.selectDictLabel(this.memberTypeOptions, row.memberType);
  448. },
  449. // 用户性别字典翻译
  450. sysUserSexFormat(row, column) {
  451. return this.selectDictLabel(this.sysUserSexOptions, row.sex);
  452. },
  453. // 用户性别字典翻译
  454. memberEthnicFormat(row, column) {
  455. return this.selectDictLabel(this.memberEthnicOptions, row.ethnic);
  456. },
  457. // 用户列表字典翻译
  458. userListFormat(row, column) {
  459. return this.selectDictLabel(this.userList, row.userId);
  460. },
  461. // 现培养人字典翻译
  462. currentMentorFormat(row, column) {
  463. return this.selectDictLabel(this.userList, row.currentMentor);
  464. },
  465. // 取消按钮
  466. cancel() {
  467. this.open = false;
  468. this.reset();
  469. },
  470. // 表单重置
  471. reset() {
  472. this.form = {
  473. memberId: null,
  474. userId: null,
  475. memberType: null,
  476. birthday: null,
  477. educationLevel: null,
  478. workJoinTime: null,
  479. workEntryTime: null,
  480. partyEntryTime: null,
  481. currentPost: null,
  482. labourDivision: null,
  483. labourEntryTime: null,
  484. labourLeaveTime: null,
  485. entryTime: null,
  486. leaveTime: null,
  487. isLeague: null,
  488. applyTime: null,
  489. formCreateTime: null,
  490. currentMentor: null,
  491. planDevelopDuration: null,
  492. isTrained: null,
  493. remarks: null,
  494. delFlag: null,
  495. createBy: null,
  496. createTime: null,
  497. updateBy: null,
  498. updateTime: null,
  499. deptId: null,
  500. };
  501. this.resetForm("form");
  502. },
  503. /** 搜索按钮操作 */
  504. handleQuery() {
  505. this.queryParams.pageNum = 1;
  506. this.getList();
  507. },
  508. /** 重置按钮操作 */
  509. resetQuery() {
  510. this.resetForm("queryForm");
  511. this.handleQuery();
  512. },
  513. // 多选框选中数据
  514. handleSelectionChange(selection) {
  515. this.ids = selection.map(item => item.memberId)
  516. this.single = selection.length!==1
  517. this.multiple = !selection.length
  518. },
  519. /** 新增按钮操作 */
  520. handleAdd() {
  521. this.reset();
  522. this.form.memberType = "3";
  523. this.open = true;
  524. this.title = "添加委员信息";
  525. },
  526. /** 修改按钮操作 */
  527. handleUpdate(row) {
  528. this.reset();
  529. const memberId = row.memberId || this.ids
  530. getMember(memberId).then(response => {
  531. this.form = response.data;
  532. this.open = true;
  533. this.title = "修改委员信息";
  534. });
  535. },
  536. /** 提交按钮 */
  537. submitForm() {
  538. this.$refs["form"].validate(valid => {
  539. if (valid) {
  540. if (this.form.memberId != null) {
  541. updateMember(this.form).then(response => {
  542. this.$modal.msgSuccess("修改成功");
  543. this.open = false;
  544. this.getList();
  545. });
  546. } else {
  547. console.log(this.form);
  548. addMember(this.form).then(response => {
  549. this.$modal.msgSuccess("新增成功");
  550. this.open = false;
  551. this.getList();
  552. });
  553. }
  554. }
  555. });
  556. },
  557. /** 删除按钮操作 */
  558. handleDelete(row) {
  559. const memberIds = row.memberId || this.ids;
  560. this.$confirm('是否确认删除?', "警告", {
  561. confirmButtonText: "确定",
  562. cancelButtonText: "取消",
  563. type: "warning"
  564. }).then(function() {
  565. return delMember(memberIds);
  566. }).then(() => {
  567. this.getList();
  568. this.msgSuccess("删除成功");
  569. })
  570. },
  571. /** 导出按钮操作 */
  572. handleExport() {
  573. const queryParams = this.queryParams;
  574. this.$confirm('是否确认导出所有委员会名册数据项?', "警告", {
  575. confirmButtonText: "确定",
  576. cancelButtonText: "取消",
  577. type: "warning"
  578. }).then(function() {
  579. return exportMember(queryParams);
  580. }).then(response => {
  581. this.download(response.msg);
  582. })
  583. },
  584. /** 导入按钮操作 */
  585. handleImport() {
  586. this.upload.title = "导入";
  587. this.upload.open = true;
  588. },
  589. /** 下载模板操作 */
  590. importTemplate() {
  591. importTemplate().then(response => {
  592. this.download(response.msg);
  593. });
  594. },
  595. // 文件上传中处理
  596. handleFileUploadProgress(event, file, fileList) {
  597. this.upload.isUploading = true;
  598. },
  599. // 文件上传成功处理
  600. handleFileSuccess(response, file, fileList) {
  601. this.upload.open = false;
  602. this.upload.isUploading = false;
  603. this.$refs.upload.clearFiles();
  604. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  605. this.getList();
  606. },
  607. // 提交上传文件
  608. submitFileForm() {
  609. this.$refs.upload.submit();
  610. }
  611. }
  612. };
  613. </script>
  614. <style>
  615. /** 文本换行符处理 */
  616. .el-table .cell{
  617. white-space: pre-wrap;
  618. }
  619. /** textarea字体 */
  620. textarea {
  621. font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
  622. }
  623. </style>