index.vue 20 KB

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