index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" 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:study: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:study: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:study: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:study: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:study: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="studyList" @selection-change="handleSelectionChange" :height="clientHeight" border>
  65. <el-table-column type="selection" width="55" align="center" />
  66. <el-table-column label="时间" align="center" prop="studyTime" width="100">
  67. <template slot-scope="scope">
  68. <span>{{ parseTime(scope.row.studyTime, '{y}-{m}-{d}') }}</span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="地点" align="center" prop="studyVenue" />
  72. <el-table-column label="授课人" align="center" prop="lecturerString" width="120" />
  73. <el-table-column label="记录人" align="center" prop="recorderString" width="120" />
  74. <el-table-column label="参加人员" align="center" prop="participantsString" width="120" />
  75. <el-table-column label="缺席人员" align="center" prop="absenteesString" width="120" />
  76. <el-table-column label="内容" align="center" prop="contents" width="350" />
  77. <el-table-column label="备注" align="center" prop="remarks"/>
  78. <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  79. <template slot-scope="scope">
  80. <el-button
  81. size="mini"
  82. type="text"
  83. icon="el-icon-edit"
  84. @click="handleUpdate(scope.row)"
  85. v-hasPermi="['branch:study:edit']"
  86. >修改</el-button>
  87. <el-button
  88. size="mini"
  89. type="text"
  90. icon="el-icon-delete"
  91. @click="handleDelete(scope.row)"
  92. v-hasPermi="['branch:study:remove']"
  93. >删除</el-button>
  94. </template>
  95. </el-table-column>
  96. </el-table>
  97. <pagination
  98. v-show="total>0"
  99. :total="total"
  100. :page.sync="queryParams.pageNum"
  101. :limit.sync="queryParams.pageSize"
  102. @pagination="getList"
  103. />
  104. <!-- 添加或修改支部党课学习对话框 -->
  105. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  106. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  107. <el-form-item label="时间" prop="studyTime">
  108. <el-date-picker clearable size="small" style="width: 200px"
  109. v-model="form.studyTime"
  110. type="date"
  111. value-format="yyyy-MM-dd"
  112. placeholder="选择时间">
  113. </el-date-picker>
  114. </el-form-item>
  115. <el-form-item label="地点" prop="studyVenue">
  116. <el-input v-model="form.studyVenue" placeholder="请输入地点" />
  117. </el-form-item>
  118. <el-form-item label="授课人" prop="lecturer">
  119. <el-select v-model="form.lecturer" multiple placeholder="请选择授课人">
  120. <el-option
  121. v-for="dict in userList"
  122. :key="dict.dictValue"
  123. :label="dict.dictLabel"
  124. :value="dict.dictValue"
  125. ></el-option>
  126. </el-select>
  127. </el-form-item>
  128. <el-form-item label="记录人" prop="recorder">
  129. <el-select v-model="form.recorder" multiple placeholder="请选择记录人">
  130. <el-option
  131. v-for="dict in userList"
  132. :key="dict.dictValue"
  133. :label="dict.dictLabel"
  134. :value="dict.dictValue"
  135. ></el-option>
  136. </el-select>
  137. </el-form-item>
  138. <el-form-item label="参加人员" prop="participants">
  139. <el-select v-model="form.participants" multiple placeholder="请选择参加人员">
  140. <el-option
  141. v-for="dict in userList"
  142. :key="dict.dictValue"
  143. :label="dict.dictLabel"
  144. :value="dict.dictValue"
  145. ></el-option>
  146. </el-select>
  147. </el-form-item>
  148. <el-form-item label="缺席人员" prop="absentees">
  149. <el-select v-model="form.absentees" multiple placeholder="请选择缺席人员">
  150. <el-option
  151. v-for="dict in userList"
  152. :key="dict.dictValue"
  153. :label="dict.dictLabel"
  154. :value="dict.dictValue"
  155. ></el-option>
  156. </el-select>
  157. </el-form-item>
  158. <el-form-item label="内容" prop="contents">
  159. <el-input v-model="form.contents" placeholder="请输入内容" type="textarea" rows="4" />
  160. </el-form-item>
  161. <el-form-item label="备注" prop="remarks">
  162. <el-input v-model="form.remarks" placeholder="请输入备注" />
  163. </el-form-item>
  164. <el-form-item label="归属部门" prop="deptId">
  165. <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
  166. </el-form-item>
  167. </el-form>
  168. <div slot="footer" class="dialog-footer">
  169. <el-button type="primary" @click="submitForm">确 定</el-button>
  170. <el-button @click="cancel">取 消</el-button>
  171. </div>
  172. </el-dialog>
  173. <!-- 用户导入对话框 -->
  174. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  175. <el-upload
  176. ref="upload"
  177. :limit="1"
  178. accept=".xlsx, .xls"
  179. :headers="upload.headers"
  180. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  181. :disabled="upload.isUploading"
  182. :on-progress="handleFileUploadProgress"
  183. :on-success="handleFileSuccess"
  184. :auto-upload="false"
  185. drag
  186. >
  187. <i class="el-icon-upload"></i>
  188. <div class="el-upload__text">
  189. 将文件拖到此处,或
  190. <em>点击上传</em>
  191. </div>
  192. <div class="el-upload__tip" slot="tip">
  193. <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
  194. <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
  195. </div>
  196. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  197. </el-upload>
  198. <div slot="footer" class="dialog-footer">
  199. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  200. <el-button @click="upload.open = false">取 消</el-button>
  201. </div>
  202. </el-dialog>
  203. </div>
  204. </template>
  205. <script>
  206. import { listStudy, getStudy, delStudy, addStudy, updateStudy, exportStudy, importTemplate} from "@/api/branch/study";
  207. import { treeselect } from "@/api/system/dept";
  208. import { getToken } from "@/utils/auth";
  209. import Treeselect from "@riophae/vue-treeselect";
  210. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  211. import { listUser} from "@/api/system/user";
  212. export default {
  213. name: "Study",
  214. components: { Treeselect },
  215. data() {
  216. return {
  217. // 遮罩层
  218. loading: true,
  219. // 选中数组
  220. ids: [],
  221. // 非单个禁用
  222. single: true,
  223. // 非多个禁用
  224. multiple: true,
  225. // 显示搜索条件
  226. showSearch: false,
  227. // 总条数
  228. total: 0,
  229. // 支部党课学习表格数据
  230. studyList: [],
  231. // 弹出层标题
  232. title: "",
  233. // 部门树选项
  234. deptOptions: undefined,
  235. clientHeight:300,
  236. // 是否显示弹出层
  237. open: false,
  238. // 用户导入参数
  239. upload: {
  240. // 是否显示弹出层(用户导入)
  241. open: false,
  242. // 弹出层标题(用户导入)
  243. title: "",
  244. // 是否禁用上传
  245. isUploading: false,
  246. // 是否更新已经存在的用户数据
  247. updateSupport: 0,
  248. // 设置上传的请求头部
  249. headers: { Authorization: "Bearer " + getToken() },
  250. // 上传的地址
  251. url: process.env.VUE_APP_BASE_API + "/branch/study/importData"
  252. },
  253. // 查询参数
  254. queryParams: {
  255. pageNum: 1,
  256. pageSize: 20,
  257. studyId: null,
  258. studyTime: null,
  259. studyVenue: null,
  260. lecturer: null,
  261. recorder: null,
  262. participants: null,
  263. absentees: null,
  264. contents: null,
  265. remarks: null,
  266. },
  267. // 表单参数
  268. form: {},
  269. // 表单校验
  270. rules: {
  271. studyTime: [
  272. { required: true, message: "时间不能为空", trigger: "blur" }
  273. ],
  274. studyVenue: [
  275. { required: true, message: "地点不能为空", trigger: "blur" }
  276. ],
  277. deptId: [
  278. { required: true, message: "归属部门不能为空", trigger: "blur" }
  279. ],
  280. },
  281. // 用户列表
  282. userList: [],
  283. };
  284. },
  285. watch: {
  286. // 根据名称筛选部门树
  287. deptName(val) {
  288. this.$refs.tree.filter(val);
  289. }
  290. },
  291. created() {
  292. //设置表格高度对应屏幕高度
  293. this.$nextTick(() => {
  294. this.clientHeight = document.body.clientHeight -250
  295. })
  296. this.getList();
  297. this.getTreeselect();
  298. },
  299. methods: {
  300. /** 查询用户列表 */
  301. getUserList() {
  302. listUser().then(response => {
  303. let rows = response.rows;
  304. let userList = [];
  305. for(let i = 0; i < rows.length; i++) {
  306. if (rows[i].userName != "admin") {
  307. let user = { "dictValue" : rows[i].userId, "dictLabel" : rows[i].nickName};
  308. userList.push(user);
  309. }
  310. }
  311. this.userList = userList;
  312. });
  313. },
  314. /** 查询支部党课学习列表 */
  315. getList() {
  316. this.loading = true;
  317. listUser().then(response => {
  318. let rows = response.rows;
  319. let userList = [];
  320. for (let i = 0; i < rows.length; i++) {
  321. if (rows[i].userName != "admin") {
  322. let user = {"dictValue": rows[i].userId, "dictLabel": rows[i].nickName};
  323. userList.push(user);
  324. }
  325. }
  326. this.userList = userList;
  327. listStudy(this.queryParams).then(response => {
  328. this.studyList = response.rows;
  329. for (let i = 0; i < this.studyList.length; i++) {
  330. if (this.studyList[i].lecturer != null) {
  331. let lecturer = this.studyList[i].lecturer.split(",");
  332. let lecturerString = "";
  333. for (let j = 0; j < lecturer.length; j++) {
  334. if (j > 0) {
  335. lecturerString += "、" + this.selectDictLabel(this.userList, lecturer[j]);
  336. } else {
  337. lecturerString += this.selectDictLabel(this.userList, lecturer[j]);
  338. }
  339. }
  340. this.studyList[i].lecturerString = lecturerString;
  341. }
  342. if (this.studyList[i].recorder != null) {
  343. let recorder = this.studyList[i].recorder.split(",");
  344. let recorderString = "";
  345. for (let j = 0; j < recorder.length; j++) {
  346. if (j > 0) {
  347. recorderString += "、" + this.selectDictLabel(this.userList, recorder[j]);
  348. } else {
  349. recorderString += this.selectDictLabel(this.userList, recorder[i]);
  350. }
  351. }
  352. this.studyList[i].recorderString = recorderString;
  353. }
  354. if (this.studyList[i].participants != null) {
  355. let participants = this.studyList[i].participants.split(",");
  356. let participantsString = "";
  357. for (let j = 0; j < participants.length; j++) {
  358. if (j > 0) {
  359. participantsString += "、" + this.selectDictLabel(this.userList, participants[j]);
  360. } else {
  361. participantsString += this.selectDictLabel(this.userList, participants[j]);
  362. }
  363. }
  364. this.studyList[i].participantsString = participantsString;
  365. }
  366. if (this.studyList[i].absentees != null) {
  367. let absentees = this.studyList[i].absentees.split(",");
  368. let absenteesString = "";
  369. for (let j = 0; j < absentees.length; j++) {
  370. if (j > 0) {
  371. absenteesString += "、" + this.selectDictLabel(this.userList, absentees[j]);
  372. } else {
  373. absenteesString += this.selectDictLabel(this.userList, absentees[j]);
  374. }
  375. }
  376. this.studyList[i].absenteesString = absenteesString;
  377. }
  378. }
  379. this.total = response.total;
  380. this.loading = false;
  381. });
  382. });
  383. },
  384. /** 查询部门下拉树结构 */
  385. getTreeselect() {
  386. treeselect().then(response => {
  387. this.deptOptions = response.data;
  388. });
  389. },
  390. // 取消按钮
  391. cancel() {
  392. this.open = false;
  393. this.reset();
  394. },
  395. // 表单重置
  396. reset() {
  397. this.form = {
  398. studyId: null,
  399. studyTime: null,
  400. studyVenue: null,
  401. lecturer: null,
  402. recorder: null,
  403. participants: null,
  404. absentees: null,
  405. contents: null,
  406. remarks: null,
  407. delFlag: null,
  408. createBy: null,
  409. createTime: null,
  410. updateBy: null,
  411. updateTime: null,
  412. };
  413. this.resetForm("form");
  414. },
  415. /** 搜索按钮操作 */
  416. handleQuery() {
  417. this.queryParams.pageNum = 1;
  418. this.getList();
  419. },
  420. /** 重置按钮操作 */
  421. resetQuery() {
  422. this.resetForm("queryForm");
  423. this.handleQuery();
  424. },
  425. // 多选框选中数据
  426. handleSelectionChange(selection) {
  427. this.ids = selection.map(item => item.studyId)
  428. this.single = selection.length!==1
  429. this.multiple = !selection.length
  430. },
  431. /** 新增按钮操作 */
  432. handleAdd() {
  433. this.reset();
  434. this.open = true;
  435. this.title = "添加支部党课学习";
  436. },
  437. /** 修改按钮操作 */
  438. handleUpdate(row) {
  439. this.reset();
  440. const studyId = row.studyId || this.ids
  441. getStudy(studyId).then(response => {
  442. this.form = response.data;
  443. if (this.form.lecturer != null) {
  444. this.form.lecturer = this.form.lecturer.split(",").map(Number);
  445. }
  446. if (this.form.recorder != null) {
  447. this.form.recorder = this.form.recorder.split(",").map(Number);
  448. }
  449. if (this.form.participants != null) {
  450. this.form.participants = this.form.participants.split(",").map(Number);
  451. }
  452. if (this.form.absentees != null) {
  453. this.form.absentees = this.form.absentees.split(",").map(Number);
  454. }
  455. this.open = true;
  456. this.title = "修改支部党课学习";
  457. });
  458. },
  459. /** 提交按钮 */
  460. submitForm() {
  461. if (this.form.lecturer != null) {
  462. this.form.lecturer = this.form.lecturer.join();
  463. }
  464. if (this.form.recorder != null) {
  465. this.form.recorder = this.form.recorder.join();
  466. }
  467. if (this.form.participants != null) {
  468. this.form.participants = this.form.participants.join();
  469. }
  470. if (this.form.absentees != null) {
  471. this.form.absentees = this.form.absentees.join();
  472. }
  473. this.$refs["form"].validate(valid => {
  474. if (valid) {
  475. if (this.form.studyId != null) {
  476. updateStudy(this.form).then(response => {
  477. this.$modal.msgSuccess("修改成功");
  478. this.open = false;
  479. this.getList();
  480. });
  481. } else {
  482. addStudy(this.form).then(response => {
  483. this.$modal.msgSuccess("新增成功");
  484. this.open = false;
  485. this.getList();
  486. });
  487. }
  488. }
  489. });
  490. },
  491. /** 删除按钮操作 */
  492. handleDelete(row) {
  493. const studyIds = row.studyId || this.ids;
  494. this.$confirm('是否确认删除?', "警告", {
  495. confirmButtonText: "确定",
  496. cancelButtonText: "取消",
  497. type: "warning"
  498. }).then(function() {
  499. return delStudy(studyIds);
  500. }).then(() => {
  501. this.getList();
  502. this.msgSuccess("删除成功");
  503. })
  504. },
  505. /** 导出按钮操作 */
  506. handleExport() {
  507. const queryParams = this.queryParams;
  508. this.$confirm('是否确认导出所有支部党课学习数据项?', "警告", {
  509. confirmButtonText: "确定",
  510. cancelButtonText: "取消",
  511. type: "warning"
  512. }).then(function() {
  513. return exportStudy(queryParams);
  514. }).then(response => {
  515. this.download(response.msg);
  516. })
  517. },
  518. /** 导入按钮操作 */
  519. handleImport() {
  520. this.upload.title = "用户导入";
  521. this.upload.open = true;
  522. },
  523. /** 下载模板操作 */
  524. importTemplate() {
  525. importTemplate().then(response => {
  526. this.download(response.msg);
  527. });
  528. },
  529. // 文件上传中处理
  530. handleFileUploadProgress(event, file, fileList) {
  531. this.upload.isUploading = true;
  532. },
  533. // 文件上传成功处理
  534. handleFileSuccess(response, file, fileList) {
  535. this.upload.open = false;
  536. this.upload.isUploading = false;
  537. this.$refs.upload.clearFiles();
  538. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  539. this.getList();
  540. },
  541. // 提交上传文件
  542. submitFileForm() {
  543. this.$refs.upload.submit();
  544. }
  545. }
  546. };
  547. </script>
  548. <style>
  549. /** 文本换行符处理 */
  550. .el-table .cell{
  551. white-space: pre-wrap;
  552. }
  553. /** textarea字体 */
  554. textarea {
  555. font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
  556. }
  557. </style>