index.vue 19 KB

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