index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  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 label="年份" prop="year">
  5. <el-date-picker size="small" style="width: 200px"
  6. v-model="queryParams.year"
  7. type="year"
  8. value-format="yyyy"
  9. placeholder="选择年份">
  10. </el-date-picker>
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  14. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  15. </el-form-item>
  16. </el-form>
  17. <el-row :gutter="10" class="mb8">
  18. <el-col :span="1.5">
  19. <el-button
  20. type="primary"
  21. plain
  22. icon="el-icon-plus"
  23. size="mini"
  24. @click="handleAdd"
  25. v-hasPermi="['branch:manage:add']"
  26. >新增
  27. </el-button>
  28. </el-col>
  29. <el-col :span="1.5">
  30. <el-button
  31. type="success"
  32. plain
  33. icon="el-icon-edit"
  34. size="mini"
  35. :disabled="single"
  36. @click="handleUpdate"
  37. v-hasPermi="['branch:manage:edit']"
  38. >修改
  39. </el-button>
  40. </el-col>
  41. <el-col :span="1.5">
  42. <el-button
  43. type="danger"
  44. plain
  45. icon="el-icon-delete"
  46. size="mini"
  47. :disabled="multiple"
  48. @click="handleDelete"
  49. v-hasPermi="['branch:manage:remove']"
  50. >删除
  51. </el-button>
  52. </el-col>
  53. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  54. </el-row>
  55. <el-table v-loading="loading" :data="manageList" @selection-change="handleSelectionChange" :height="clientHeight"
  56. border>
  57. <el-table-column type="selection" width="55" align="center"/>
  58. <el-table-column label="月度" align="center" prop="monthly" width="100">
  59. <template slot-scope="scope">
  60. {{ scope.row.monthly }}月
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="课件描述" align="center" prop="describe" min-width="180"/>
  64. <el-table-column label="课件附件" align="center" prop="filesId" width="180">
  65. <template slot-scope="scope">
  66. <el-button
  67. size="mini"
  68. type="text"
  69. icon="el-icon-folder"
  70. @click="openFileDialog(scope.row)"
  71. >查看附件
  72. </el-button>
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="备注" align="center" prop="remarks" width="150"/>
  76. <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  77. <template slot-scope="scope">
  78. <el-button
  79. size="mini"
  80. type="text"
  81. icon="el-icon-edit"
  82. @click="handleUpdate(scope.row)"
  83. v-hasPermi="['branch:manage:edit']"
  84. >修改
  85. </el-button>
  86. <el-button
  87. size="mini"
  88. type="text"
  89. icon="el-icon-delete"
  90. @click="handleDelete(scope.row)"
  91. v-hasPermi="['branch:manage:remove']"
  92. >删除
  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="date">
  108. <el-date-picker size="small" style="width: 200px"
  109. v-model="form.date"
  110. type="month"
  111. placeholder="选择月度">
  112. </el-date-picker>
  113. </el-form-item>
  114. <el-form-item label="课件描述" prop="describe">
  115. <el-input v-model="form.describe" placeholder="请输入课件描述"/>
  116. </el-form-item>
  117. <el-form-item label="备注" prop="remarks">
  118. <el-input v-model="form.remarks" placeholder="请输入备注"/>
  119. </el-form-item>
  120. <el-form-item label="归属部门" prop="deptId">
  121. <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门"/>
  122. </el-form-item>
  123. </el-form>
  124. <div slot="footer" class="dialog-footer">
  125. <el-button type="primary" @click="submitForm">确 定</el-button>
  126. <el-button @click="cancel">取 消</el-button>
  127. </div>
  128. </el-dialog>
  129. <!-- 用户导入对话框 -->
  130. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  131. <el-upload
  132. ref="upload"
  133. :limit="1"
  134. accept=".xlsx, .xls"
  135. :headers="upload.headers"
  136. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  137. :disabled="upload.isUploading"
  138. :on-progress="handleFileUploadProgress"
  139. :on-success="handleFileSuccess"
  140. :auto-upload="false"
  141. drag
  142. >
  143. <i class="el-icon-upload"></i>
  144. <div class="el-upload__text">
  145. 将文件拖到此处,或
  146. <em>点击上传</em>
  147. </div>
  148. <div class="el-upload__tip" slot="tip">
  149. <el-checkbox v-model="upload.updateSupport"/>
  150. 是否更新已经存在的用户数据
  151. <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
  152. </div>
  153. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  154. </el-upload>
  155. <div slot="footer" class="dialog-footer">
  156. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  157. <el-button @click="upload.open = false">取 消</el-button>
  158. </div>
  159. </el-dialog>
  160. <el-dialog title="附件详情" :visible.sync="file.open" width="60%" append-to-body>
  161. <el-row :gutter="10" class="mb8">
  162. <el-col :span="1.5">
  163. <el-upload
  164. ref="doc"
  165. :headers="file.doc.headers"
  166. :action="file.doc.url"
  167. :disabled="file.doc.isUploading"
  168. :on-progress="handleFileDocProgress"
  169. :on-success="handleFileDocSuccess"
  170. :auto-upload="true"
  171. :file-list="file.fileList"
  172. >
  173. <el-button type="primary"><i class="el-icon-upload"></i> 点击上传</el-button>
  174. </el-upload>
  175. </el-col>
  176. </el-row>
  177. <el-table :data="file.dataList">
  178. <el-table-column label="附件名称" align="center">
  179. <template slot-scope="scope">
  180. <el-button
  181. size="mini"
  182. type="text"
  183. icon="el-icon-document"
  184. @click="handleSee(scope.row.url)">
  185. {{ scope.row.name }}
  186. </el-button>
  187. </template>
  188. </el-table-column>
  189. <el-table-column label="上传人" align="center" prop="creater"/>
  190. <el-table-column label="上传时间" align="center" prop="createdate">
  191. <template slot-scope="scope">
  192. <span>{{ parseTime(scope.row.createdate, '{y}-{m}-{d}') }}</span>
  193. </template>
  194. </el-table-column>
  195. <el-table-column label="操作" align="center">
  196. <template slot-scope="scope">
  197. <el-button
  198. size="mini"
  199. type="text"
  200. icon="el-icon-delete"
  201. @click="handleFileDelete(scope.row)"
  202. >删除
  203. </el-button>
  204. </template>
  205. </el-table-column>
  206. </el-table>
  207. </el-dialog>
  208. </div>
  209. </template>
  210. <script>
  211. import {
  212. addManage,
  213. delManage,
  214. exportManage,
  215. getManage,
  216. importTemplate,
  217. listManage,
  218. updateManage
  219. } from "@/api/branch/manage";
  220. import {treeselect} from "@/api/system/dept";
  221. import {getToken} from "@/utils/auth";
  222. import Treeselect from "@riophae/vue-treeselect";
  223. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  224. import {listFile} from "../../../api/branch/file";
  225. import {delManageFile} from "../../../api/branch/manage";
  226. export default {
  227. name: "Manage",
  228. components: {Treeselect},
  229. data() {
  230. return {
  231. file: {
  232. id: null,
  233. open: false,
  234. fileList: [],
  235. dataList: [],
  236. doc: {
  237. file: "",
  238. // 是否显示弹出层(报告附件)
  239. open: false,
  240. // 弹出层标题(报告附件)
  241. title: "",
  242. // 是否禁用上传
  243. isUploading: false,
  244. // 设置上传的请求头部
  245. headers: {Authorization: "Bearer " + getToken()},
  246. // 上传的地址
  247. url: process.env.VUE_APP_BASE_API + "/branch/file/uploadFile",
  248. },
  249. },
  250. // 遮罩层
  251. loading: true,
  252. // 选中数组
  253. ids: [],
  254. // 非单个禁用
  255. single: true,
  256. // 非多个禁用
  257. multiple: true,
  258. // 显示搜索条件
  259. showSearch: true,
  260. // 总条数
  261. total: 0,
  262. // 支部党课学习资料管理表格数据
  263. manageList: [],
  264. // 弹出层标题
  265. title: "",
  266. // 部门树选项
  267. deptOptions: undefined,
  268. clientHeight: 300,
  269. // 是否显示弹出层
  270. open: false,
  271. // 主键id字典
  272. manageIdOptions: [],
  273. // 月度字典
  274. monthlyOptions: [],
  275. // 年份字典
  276. yearOptions: [],
  277. // 课件描述字典
  278. describeOptions: [],
  279. // 备注字典
  280. remarksOptions: [],
  281. // 删除标志字典
  282. delFlagOptions: [],
  283. // 创建者字典
  284. createByOptions: [],
  285. // 创建时间字典
  286. createTimeOptions: [],
  287. // 更新者字典
  288. updateByOptions: [],
  289. // 更新时间字典
  290. updateTimeOptions: [],
  291. // 部门id字典
  292. deptIdOptions: [],
  293. // 附件id字典
  294. filesIdOptions: [],
  295. // 用户导入参数
  296. upload: {
  297. // 是否显示弹出层(用户导入)
  298. open: false,
  299. // 弹出层标题(用户导入)
  300. title: "",
  301. // 是否禁用上传
  302. isUploading: false,
  303. // 是否更新已经存在的用户数据
  304. updateSupport: 0,
  305. // 设置上传的请求头部
  306. headers: {Authorization: "Bearer " + getToken()},
  307. // 上传的地址
  308. url: process.env.VUE_APP_BASE_API + "/branch/manage/importData"
  309. },
  310. // 查询参数
  311. queryParams: {
  312. pageNum: 1,
  313. pageSize: 20,
  314. manageId: null,
  315. monthly: null,
  316. year: (new Date().getFullYear())+"",
  317. describe: null,
  318. remarks: null,
  319. deptId: null,
  320. filesId: null,
  321. },
  322. // 表单参数
  323. form: {},
  324. // 表单校验
  325. rules: {
  326. date: [
  327. {required: true, message: "月度不能为空", trigger: "blur"}
  328. ],
  329. }
  330. };
  331. },
  332. watch: {
  333. // 根据名称筛选部门树
  334. deptName(val) {
  335. this.$refs.tree.filter(val);
  336. }
  337. },
  338. created() {
  339. //设置表格高度对应屏幕高度
  340. this.$nextTick(() => {
  341. this.clientHeight = document.body.clientHeight - 270
  342. })
  343. this.getList();
  344. this.getTreeselect();
  345. },
  346. methods: {
  347. handleSee(url) {
  348. window.open(process.env.VUE_APP_BASE_API + url);
  349. },
  350. handleFileDelete(row) {
  351. delManageFile({filesId:row.id,manageId:this.file.id}).then(res=>{
  352. this.$modal.msgSuccess("删除成功");
  353. this.getFileList(this.file.id);
  354. })
  355. },
  356. //附件上传中处理
  357. handleFileDocProgress(event, file, fileList) {
  358. this.file.doc.file = file;
  359. },
  360. //附件上传成功处理
  361. handleFileDocSuccess(response, file, fileList) {
  362. updateManage({filesId: response.data, manageId: this.file.id}).then(response => {
  363. this.$modal.msgSuccess("上传成功");
  364. this.getFileList(this.file.id)
  365. });
  366. },
  367. openFileDialog(row) {
  368. this.file.open = true;
  369. this.file.id = row.manageId;
  370. this.getFileList(row.manageId);
  371. },
  372. getFileList(manageId) {
  373. getManage(manageId).then(res => {
  374. let filesId = res.data.filesId.split(',');
  375. listFile({filesId: filesId}).then(result => {
  376. this.file.dataList = result.rows
  377. })
  378. })
  379. },
  380. /** 查询支部党课学习资料管理列表 */
  381. getList() {
  382. this.loading = true;
  383. listManage(this.queryParams).then(response => {
  384. this.manageList = response.rows;
  385. this.total = response.total;
  386. this.loading = false;
  387. });
  388. },
  389. /** 查询部门下拉树结构 */
  390. getTreeselect() {
  391. treeselect().then(response => {
  392. this.deptOptions = response.data;
  393. });
  394. },
  395. // 取消按钮
  396. cancel() {
  397. this.open = false;
  398. this.reset();
  399. },
  400. // 表单重置
  401. reset() {
  402. this.form = {
  403. manageId: null,
  404. monthly: null,
  405. year: null,
  406. describe: null,
  407. remarks: null,
  408. delFlag: null,
  409. createBy: null,
  410. createTime: null,
  411. updateBy: null,
  412. updateTime: null,
  413. deptId: null,
  414. filesId: null,
  415. date : new Date(),
  416. };
  417. this.resetForm("form");
  418. },
  419. /** 搜索按钮操作 */
  420. handleQuery() {
  421. this.queryParams.pageNum = 1;
  422. this.getList();
  423. },
  424. /** 重置按钮操作 */
  425. resetQuery() {
  426. this.resetForm("queryForm");
  427. this.handleQuery();
  428. },
  429. // 多选框选中数据
  430. handleSelectionChange(selection) {
  431. this.ids = selection.map(item => item.manageId)
  432. this.single = selection.length !== 1
  433. this.multiple = !selection.length
  434. },
  435. /** 新增按钮操作 */
  436. handleAdd() {
  437. this.reset();
  438. this.open = true;
  439. this.title = "添加支部党课学习资料管理";
  440. },
  441. /** 修改按钮操作 */
  442. handleUpdate(row) {
  443. this.reset();
  444. const manageId = row.manageId || this.ids
  445. getManage(manageId).then(response => {
  446. this.form = response.data;
  447. this.form.date=new Date();
  448. this.form.date.setMonth(response.data.monthly - 1);
  449. this.form.date.setFullYear(response.data.year);
  450. console.log(this.date)
  451. this.open = true;
  452. this.title = "修改支部党课学习资料管理";
  453. });
  454. },
  455. /** 提交按钮 */
  456. submitForm() {
  457. this.form.year = this.form.date.getFullYear();
  458. this.form.monthly = (this.form.date.getMonth() + 1);
  459. this.$refs["form"].validate(valid => {
  460. if (valid) {
  461. if (this.form.manageId != null) {
  462. updateManage(this.form).then(response => {
  463. this.$modal.msgSuccess("修改成功");
  464. this.open = false;
  465. this.getList();
  466. });
  467. } else {
  468. addManage(this.form).then(response => {
  469. this.$modal.msgSuccess("新增成功");
  470. this.open = false;
  471. this.getList();
  472. });
  473. }
  474. }
  475. });
  476. },
  477. /** 删除按钮操作 */
  478. handleDelete(row) {
  479. const manageIds = row.manageId || this.ids;
  480. this.$confirm('是否确认删除?', "警告", {
  481. confirmButtonText: "确定",
  482. cancelButtonText: "取消",
  483. type: "warning"
  484. }).then(function () {
  485. return delManage(manageIds);
  486. }).then(() => {
  487. this.getList();
  488. this.msgSuccess("删除成功");
  489. })
  490. },
  491. /** 导出按钮操作 */
  492. handleExport() {
  493. const queryParams = this.queryParams;
  494. this.$confirm('是否确认导出所有支部党课学习资料管理数据项?', "警告", {
  495. confirmButtonText: "确定",
  496. cancelButtonText: "取消",
  497. type: "warning"
  498. }).then(function () {
  499. return exportManage(queryParams);
  500. }).then(response => {
  501. this.download(response.msg);
  502. })
  503. },
  504. /** 导入按钮操作 */
  505. handleImport() {
  506. this.upload.title = "用户导入";
  507. this.upload.open = true;
  508. },
  509. /** 下载模板操作 */
  510. importTemplate() {
  511. importTemplate().then(response => {
  512. this.download(response.msg);
  513. });
  514. },
  515. // 文件上传中处理
  516. handleFileUploadProgress(event, file, fileList) {
  517. this.upload.isUploading = true;
  518. },
  519. // 文件上传成功处理
  520. handleFileSuccess(response, file, fileList) {
  521. this.upload.open = false;
  522. this.upload.isUploading = false;
  523. this.$refs.upload.clearFiles();
  524. this.$alert(response.msg, "导入结果", {dangerouslyUseHTMLString: true});
  525. this.getList();
  526. },
  527. // 提交上传文件
  528. submitFileForm() {
  529. this.$refs.upload.submit();
  530. }
  531. }
  532. };
  533. </script>
  534. <style>
  535. /** 文本换行符处理 */
  536. .el-table .cell {
  537. white-space: pre-wrap;
  538. }
  539. /** textarea字体 */
  540. textarea {
  541. font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
  542. }
  543. </style>