index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
  4. <el-form-item label="用户编号" prop="userCode">
  5. <el-input
  6. v-model="queryParams.userCode"
  7. placeholder="请输入用户编号"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="用户名称" prop="userName">
  14. <el-input
  15. v-model="queryParams.userName"
  16. placeholder="请输入用户名称"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="地点" prop="address">
  23. <el-select v-model="queryParams.address" placeholder="请选择地点" clearable size="small">
  24. <el-option
  25. v-for="dict in dict.type.welfare_apply_addr"
  26. :key="dict.value"
  27. :label="dict.label"
  28. :value="dict.value"
  29. />
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="当前状态" prop="nowStatus">
  33. <el-select v-model="queryParams.nowStatus" placeholder="请选择当前状态" clearable size="small">
  34. <el-option
  35. v-for="dict in dict.type.welfare_apply_status"
  36. :key="dict.value"
  37. :label="dict.label"
  38. :value="dict.value"
  39. />
  40. </el-select>
  41. </el-form-item>
  42. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  43. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  44. </el-form>
  45. <el-row :gutter="10" class="mb8">
  46. <el-col :span="1.5">
  47. <el-button
  48. type="primary"
  49. plain
  50. icon="el-icon-plus"
  51. size="mini"
  52. @click="handleAdd"
  53. v-hasPermi="['event:applyRecord:add']"
  54. >新增
  55. </el-button>
  56. </el-col>
  57. <el-col :span="1.5">
  58. <el-button
  59. type="success"
  60. plain
  61. icon="el-icon-edit"
  62. size="mini"
  63. :disabled="single"
  64. @click="handleUpdate"
  65. v-hasPermi="['event:applyRecord:edit']"
  66. >修改
  67. </el-button>
  68. </el-col>
  69. <el-col :span="1.5">
  70. <el-button
  71. type="danger"
  72. plain
  73. icon="el-icon-delete"
  74. size="mini"
  75. :disabled="multiple"
  76. @click="handleDelete"
  77. v-hasPermi="['event:applyRecord:remove']"
  78. >删除
  79. </el-button>
  80. </el-col>
  81. <el-col :span="1.5">
  82. <el-button
  83. type="warning"
  84. plain
  85. icon="el-icon-download"
  86. size="mini"
  87. :loading="exportLoading"
  88. @click="handleExport"
  89. v-hasPermi="['event:applyRecord:export']"
  90. >导出
  91. </el-button>
  92. </el-col>
  93. <el-col :span="1.5">
  94. <el-button
  95. type="primary"
  96. plain
  97. icon="el-icon-plus"
  98. size="mini"
  99. @click="handleImport"
  100. >导入
  101. </el-button>
  102. </el-col>
  103. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  104. </el-row>
  105. <el-row :gutter="6">
  106. <el-col :span="7">
  107. <el-card class="box-card">
  108. <div slot="header" class="clearfix">
  109. <span>福利领取目录</span>
  110. </div>
  111. <div class="item">
  112. <el-table v-loading="loading" :data="sourceList" @selection-change="handleSelectionChange"
  113. @row-click="rowClick">
  114. <el-table-column label="文件名" align="center" prop="source"/>
  115. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  116. <template slot-scope="scope">
  117. <el-button
  118. size="mini"
  119. type="text"
  120. icon="el-icon-pie-chart"
  121. @click="openStat(scope.row.source)"
  122. >统计
  123. </el-button>
  124. <el-button
  125. size="mini"
  126. type="text"
  127. icon="el-icon-magic-stick"
  128. @click="sourceDoUnregistered(scope.row.source)"
  129. >发布
  130. </el-button>
  131. <el-button
  132. size="mini"
  133. type="text"
  134. icon="el-icon-delete"
  135. @click="doDelSource(scope.row.source)"
  136. >删除
  137. </el-button>
  138. </template>
  139. </el-table-column>
  140. </el-table>
  141. <pagination
  142. v-show="total>0"
  143. :total="sourceQueryParams.total"
  144. :page.sync="sourceQueryParams.pageNum"
  145. :limit.sync="sourceQueryParams.pageSize"
  146. @pagination="getList"
  147. />
  148. </div>
  149. </el-card>
  150. </el-col>
  151. <el-col :span="17">
  152. <el-card class="box-card">
  153. <div slot="header" class="clearfix">
  154. <span>{{ sourceName }}</span>
  155. </div>
  156. <div class="item">
  157. <el-table v-loading="loading" :data="applyRecordList" @selection-change="handleSelectionChange">
  158. <el-table-column type="selection" width="55" align="center"/>
  159. <el-table-column label="用户编号" align="center" prop="userCode"/>
  160. <el-table-column label="用户名称" align="center" prop="userName"/>
  161. <el-table-column label="地点" align="center" prop="address" width="380">
  162. <template slot-scope="scope">
  163. <dict-tag :options="dict.type.welfare_apply_addr" :value="scope.row.address"/>
  164. </template>
  165. </el-table-column>
  166. <el-table-column label="当前状态" align="center" prop="nowStatus">
  167. <template slot-scope="scope">
  168. <dict-tag :options="dict.type.welfare_apply_status" :value="scope.row.nowStatus"/>
  169. </template>
  170. </el-table-column>
  171. <el-table-column label="备注" align="center" prop="remark"/>
  172. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  173. <template slot-scope="scope">
  174. <el-button
  175. size="mini"
  176. type="text"
  177. icon="el-icon-edit"
  178. @click="handleUpdate(scope.row)"
  179. >修改
  180. </el-button>
  181. <el-button
  182. size="mini"
  183. type="text"
  184. icon="el-icon-delete"
  185. @click="handleDelete(scope.row)"
  186. >删除
  187. </el-button>
  188. </template>
  189. </el-table-column>
  190. </el-table>
  191. <pagination
  192. v-show="total>0"
  193. :total="total"
  194. :page.sync="queryParams.pageNum"
  195. :limit.sync="queryParams.pageSize"
  196. @pagination="getList"
  197. />
  198. </div>
  199. </el-card>
  200. </el-col>
  201. </el-row>
  202. <!-- 添加或修改福利报名记录对话框 -->
  203. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
  204. <el-form ref="form" :model="form" :rules="rules">
  205. <el-form-item label="Excel来源" prop="source">
  206. <el-input v-model="form.source" placeholder="请输入Excel来源"/>
  207. </el-form-item>
  208. <el-form-item label="用户编号" prop="userCode">
  209. <el-input v-model="form.userCode" placeholder="请输入用户编号"/>
  210. </el-form-item>
  211. <el-form-item label="用户名称" prop="userName">
  212. <el-input v-model="form.userName" placeholder="请输入用户名称"/>
  213. </el-form-item>
  214. <el-form-item label="地点" prop="address">
  215. <el-select v-model="form.address" placeholder="请选择地点">
  216. <el-option
  217. v-for="dict in dict.type.welfare_apply_addr"
  218. :key="dict.value"
  219. :label="dict.label"
  220. :value="dict.value"
  221. ></el-option>
  222. </el-select>
  223. </el-form-item>
  224. <el-form-item label="当前状态" prop="nowStatus">
  225. <el-select v-model="form.nowStatus" placeholder="请选择当前状态">
  226. <el-option
  227. v-for="dict in dict.type.welfare_apply_status"
  228. :key="dict.value"
  229. :label="dict.label"
  230. :value="dict.value"
  231. ></el-option>
  232. </el-select>
  233. </el-form-item>
  234. <el-form-item label="备注" prop="remark">
  235. <el-input v-model="form.remark" placeholder="请输入备注"/>
  236. </el-form-item>
  237. </el-form>
  238. <div slot="footer" class="dialog-footer">
  239. <el-button type="primary" @click="submitForm">确 定</el-button>
  240. <el-button @click="cancel">取 消</el-button>
  241. </div>
  242. </el-dialog>
  243. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  244. <el-upload
  245. ref="upload"
  246. :limit="1"
  247. accept=".xlsx, .xls"
  248. :headers="upload.headers"
  249. :action="upload.url"
  250. :disabled="upload.isUploading"
  251. :on-progress="handleFileUploadProgress"
  252. :on-success="handleFileSuccess"
  253. :auto-upload="false"
  254. drag
  255. >
  256. <i class="el-icon-upload"></i>
  257. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  258. <div class="el-upload__tip text-center" slot="tip">
  259. <span>仅允许导入xls、xlsx格式文件。</span>
  260. <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;"
  261. @click="importTemplate">下载模板
  262. </el-link>
  263. </div>
  264. </el-upload>
  265. <div slot="footer" class="dialog-footer">
  266. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  267. <el-button @click="cancelTemplate">取 消</el-button>
  268. </div>
  269. </el-dialog>
  270. <el-dialog :title="stat.title" :visible.sync="stat.open" width="900px">
  271. <el-table v-loading="stat.loading" :data="statList" :show-summary="true">
  272. <el-table-column label="部门" align="center" prop="address"/>
  273. <el-table-column label="报名数量" align="center" prop="applyNum"/>
  274. </el-table>
  275. </el-dialog>
  276. </div>
  277. </template>
  278. <script>
  279. import {
  280. listApplyRecord,
  281. sourceListApplyRecord,
  282. statApplyRecord,
  283. doUnregistered,
  284. getApplyRecord,
  285. delApplyRecord,
  286. delSource,
  287. addApplyRecord,
  288. updateApplyRecord,
  289. exportApplyRecord,
  290. importTempApplyRecord
  291. } from '@/api/event/applyRecord'
  292. import { getToken } from '@/utils/auth'
  293. import { exportDetail } from '@/api/canteen/giftDetail'
  294. export default {
  295. name: 'ApplyRecord',
  296. dicts: ['welfare_apply_status', 'welfare_apply_addr'],
  297. data() {
  298. return {
  299. // 遮罩层
  300. loading: true,
  301. // 导出遮罩层
  302. exportLoading: false,
  303. // 选中数组
  304. ids: [],
  305. // 非单个禁用
  306. single: true,
  307. // 非多个禁用
  308. multiple: true,
  309. // 显示搜索条件
  310. showSearch: true,
  311. // 总条数
  312. total: 0,
  313. // 福利报名记录表格数据
  314. applyRecordList: [],
  315. sourceList: [],
  316. statList: [],
  317. // 弹出层标题
  318. title: '',
  319. // 是否显示弹出层
  320. open: false,
  321. // 查询参数
  322. queryParams: {
  323. pageNum: 1,
  324. pageSize: 10,
  325. source: null,
  326. userCode: null,
  327. userName: null,
  328. address: null,
  329. nowStatus: null,
  330. isDelete: null
  331. },
  332. sourceQueryParams: {
  333. pageNum: 1,
  334. pageSize: 10,
  335. total: 0
  336. },
  337. // 表单参数
  338. form: {},
  339. // 表单校验
  340. rules: {},
  341. sourceName: '',
  342. upload: {
  343. // 是否显示弹出层(用户导入)
  344. open: false,
  345. // 弹出层标题(用户导入)
  346. title: '',
  347. // 是否禁用上传
  348. isUploading: false,
  349. // 是否更新已经存在的用户数据
  350. // 设置上传的请求头部
  351. headers: { Authorization: 'Bearer ' + getToken() },
  352. // 上传的地址
  353. url: process.env.VUE_APP_BASE_API + '/event/applyRecord/importData'
  354. },
  355. stat: {
  356. open: false,
  357. title: '统计',
  358. loading: false
  359. }
  360. }
  361. },
  362. created() {
  363. this.getList()
  364. },
  365. methods: {
  366. rowClick(row) {
  367. this.loading = true
  368. this.queryParams.source = row.source
  369. this.sourceName = row.source
  370. listApplyRecord(this.queryParams).then(response => {
  371. this.applyRecordList = response.rows
  372. this.total = response.total
  373. this.loading = false
  374. })
  375. },
  376. /** 查询福利报名记录列表 */
  377. getList() {
  378. this.loading = true
  379. listApplyRecord(this.queryParams).then(response => {
  380. this.applyRecordList = response.rows
  381. this.total = response.total
  382. this.loading = false
  383. })
  384. sourceListApplyRecord(this.sourceQueryParams).then(response => {
  385. this.sourceList = response.rows
  386. this.sourceQueryParams.total = response.total
  387. })
  388. },
  389. openStat(source) {
  390. this.stat.open = true
  391. this.stat.loading = true
  392. this.stat.title = '统计【' + source + '】'
  393. statApplyRecord(source).then(response => {
  394. if (response.code === 200) {
  395. this.statList = response.data
  396. this.stat.loading = false
  397. }
  398. })
  399. },
  400. sourceDoUnregistered(source) {
  401. this.$modal.confirm('发布成功后所有人员都设置为【未报名】状态,确认发布吗?').then(() => {
  402. return doUnregistered(source)
  403. }).then(response => {
  404. if (response.code === 200) {
  405. this.$modal.msgSuccess('发布成功')
  406. this.getList()
  407. } else {
  408. this.$modal.msgError('发布失败')
  409. }
  410. }).catch(() => {
  411. })
  412. },
  413. doDelSource(source) {
  414. this.$modal.confirm('删除后所有信息都将删除,确认删除吗?').then(() => {
  415. return delSource(source)
  416. }).then(response => {
  417. if (response.code === 200) {
  418. this.$modal.msgSuccess('删除成功')
  419. this.getList()
  420. } else {
  421. this.$modal.msgError('删除失败')
  422. }
  423. })
  424. },
  425. // 取消按钮
  426. cancel() {
  427. this.open = false
  428. this.reset()
  429. },
  430. // 表单重置
  431. reset() {
  432. this.form = {
  433. id: null,
  434. source: null,
  435. userCode: null,
  436. userName: null,
  437. address: null,
  438. nowStatus: '0',
  439. isDelete: null,
  440. createBy: null,
  441. createTime: null,
  442. updateBy: null,
  443. updateTime: null,
  444. remark: null
  445. }
  446. this.resetForm('form')
  447. },
  448. /** 搜索按钮操作 */
  449. handleQuery() {
  450. this.queryParams.pageNum = 1
  451. this.getList()
  452. },
  453. /** 重置按钮操作 */
  454. resetQuery() {
  455. this.resetForm('queryForm')
  456. this.handleQuery()
  457. },
  458. // 多选框选中数据
  459. handleSelectionChange(selection) {
  460. this.ids = selection.map(item => item.id)
  461. this.single = selection.length !== 1
  462. this.multiple = !selection.length
  463. },
  464. /** 新增按钮操作 */
  465. handleAdd() {
  466. this.reset()
  467. this.open = true
  468. this.title = '添加福利报名记录'
  469. },
  470. /** 修改按钮操作 */
  471. handleUpdate(row) {
  472. this.reset()
  473. const id = row.id || this.ids
  474. getApplyRecord(id).then(response => {
  475. this.form = response.data
  476. this.open = true
  477. this.title = '修改福利报名记录'
  478. })
  479. },
  480. /** 提交按钮 */
  481. submitForm() {
  482. this.$refs['form'].validate(valid => {
  483. if (valid) {
  484. if (this.form.id != null) {
  485. updateApplyRecord(this.form).then(() => {
  486. this.$modal.msgSuccess('修改成功')
  487. this.open = false
  488. this.getList()
  489. })
  490. } else {
  491. addApplyRecord(this.form).then(() => {
  492. this.$modal.msgSuccess('新增成功')
  493. this.open = false
  494. this.getList()
  495. })
  496. }
  497. }
  498. })
  499. },
  500. /** 删除按钮操作 */
  501. handleDelete(row) {
  502. const ids = row.id || this.ids
  503. this.$modal.confirm('是否确认删除福利报名记录编号为"' + ids + '"的数据项?').then(function() {
  504. return delApplyRecord(ids)
  505. }).then(() => {
  506. this.getList()
  507. this.$modal.msgSuccess('删除成功')
  508. }).catch(() => {
  509. })
  510. },
  511. /** 导出按钮操作 */
  512. handleExport() {
  513. const queryParams = this.queryParams
  514. this.$modal.confirm('是否确认导出所有福利报名记录数据项?').then(() => {
  515. this.exportLoading = true
  516. return exportApplyRecord(queryParams)
  517. }).then(response => {
  518. this.$download.name(response.msg)
  519. this.exportLoading = false
  520. }).catch(() => {
  521. })
  522. },
  523. handleImport() {
  524. this.upload.title = '福利领取人员导入'
  525. this.upload.open = true
  526. },
  527. handleFileUploadProgress(event, file, fileList) {
  528. this.upload.isUploading = true
  529. },
  530. // 文件上传成功处理
  531. handleFileSuccess(response, file, fileList) {
  532. this.upload.open = false
  533. this.upload.isUploading = false
  534. this.$refs.upload.clearFiles()
  535. this.$alert(response.msg, '导入结果', { dangerouslyUseHTMLString: true })
  536. this.cancel()
  537. this.getList()
  538. },
  539. importTemplate() {
  540. importTempApplyRecord().then(response => {
  541. this.$download.name(response.msg)
  542. })
  543. },
  544. submitFileForm() {
  545. this.$refs.upload.submit()
  546. },
  547. cancelTemplate() {
  548. this.upload.open = false
  549. }
  550. }
  551. }
  552. </script>