index.vue 17 KB

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