index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  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="giftName">
  5. <el-input
  6. v-model="queryParams.giftName"
  7. placeholder="请输入礼品名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <!--<el-form-item label="启用标志" prop="qybz">-->
  14. <!-- <el-select v-model="queryParams.qybz" placeholder="请选择启用标志" clearable size="small">-->
  15. <!-- <el-option-->
  16. <!-- v-for="dict in dict.type.sys_yes_no"-->
  17. <!-- :key="dict.value"-->
  18. <!-- :label="dict.label"-->
  19. <!-- :value="dict.value"-->
  20. <!-- />-->
  21. <!-- </el-select>-->
  22. <!--</el-form-item>-->
  23. <el-form-item>
  24. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  25. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  26. </el-form-item>
  27. </el-form>
  28. <el-row :gutter="10" class="mb8">
  29. <el-col :span="1.5">
  30. <el-button
  31. type="primary"
  32. plain
  33. icon="el-icon-plus"
  34. size="mini"
  35. @click="handleAdd"
  36. v-hasPermi="['canteen:gift:add']"
  37. >新增
  38. </el-button>
  39. </el-col>
  40. <el-col :span="1.5">
  41. <el-button
  42. type="success"
  43. plain
  44. icon="el-icon-edit"
  45. size="mini"
  46. :disabled="single"
  47. @click="handleUpdate"
  48. v-hasPermi="['canteen:gift:edit']"
  49. >修改
  50. </el-button>
  51. </el-col>
  52. <el-col :span="1.5">
  53. <el-button
  54. type="danger"
  55. plain
  56. icon="el-icon-delete"
  57. size="mini"
  58. :disabled="multiple"
  59. @click="handleDelete"
  60. v-hasPermi="['canteen:gift:remove']"
  61. >删除
  62. </el-button>
  63. </el-col>
  64. <el-col :span="1.5">
  65. <el-button
  66. type="warning"
  67. plain
  68. icon="el-icon-download"
  69. size="mini"
  70. :loading="exportLoading"
  71. @click="handleExport"
  72. v-hasPermi="['canteen:gift:export']"
  73. >导出
  74. </el-button>
  75. </el-col>
  76. <el-col :span="1.5">
  77. <el-button
  78. type="warning"
  79. plain
  80. icon="el-icon-edit"
  81. size="mini"
  82. :loading="exportLoading"
  83. @click="noticeShow"
  84. >兑换公告
  85. </el-button>
  86. </el-col>
  87. <el-col :span="1.5">
  88. <div style="padding: 5px">
  89. <el-switch
  90. @change="setNoticeStatus"
  91. v-model="noticeForm.openStatus"
  92. active-text="打开公告"
  93. inactive-text="关闭公告">
  94. </el-switch>
  95. </div>
  96. </el-col>
  97. <el-col :span="1.5">
  98. <el-button
  99. type="primary"
  100. plain
  101. icon="el-icon-time"
  102. size="mini"
  103. :loading="exportLoading"
  104. @click="eventShow"
  105. >活动事件配置
  106. </el-button>
  107. </el-col>
  108. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  109. </el-row>
  110. <el-table v-loading="loading" :data="giftList" @selection-change="handleSelectionChange">
  111. <el-table-column type="selection" width="55" align="center"/>
  112. <el-table-column label="礼品id" align="center" prop="giftId" v-if="false"/>
  113. <el-table-column label="礼品编号" align="center" prop="giftNumber"/>
  114. <el-table-column label="礼品名称" align="center" prop="giftName"/>
  115. <el-table-column label="礼品图片" align="center" prop="giftPictrue">
  116. <template slot-scope="scope">
  117. <img style="width:80px;height:80px;border:none;" :src="baseUrl + scope.row.giftPictrue">
  118. </template>
  119. </el-table-column>
  120. <el-table-column label="礼品价格" align="center" prop="giftPrice"/>
  121. <el-table-column label="库存数量" align="center" prop="amount"/>
  122. <el-table-column label="启用标志" align="center" prop="qybz">
  123. <template slot-scope="scope">
  124. <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.qybz"/>
  125. </template>
  126. </el-table-column>
  127. <!-- <el-table-column label="机构代码" align="center" prop="orgCode">-->
  128. <!-- <template slot-scope="scope">-->
  129. <!-- <div v-for="item in orgList">-->
  130. <!-- <el-tag v-if="item.orgCode === scope.row.orgCode">-->
  131. <!-- {{ item.orgName }}-->
  132. <!-- </el-tag>-->
  133. <!-- </div>-->
  134. <!-- </template>-->
  135. <!-- </el-table-column>-->
  136. <el-table-column label="备注" align="center" prop="remark"/>
  137. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  138. <template slot-scope="scope">
  139. <el-button
  140. size="mini"
  141. type="text"
  142. icon="el-icon-edit"
  143. @click="handleUpdate(scope.row)"
  144. v-hasPermi="['canteen:gift:edit']"
  145. >修改
  146. </el-button>
  147. <el-button
  148. size="mini"
  149. type="text"
  150. icon="el-icon-delete"
  151. @click="handleDelete(scope.row)"
  152. v-hasPermi="['canteen:gift:remove']"
  153. >删除
  154. </el-button>
  155. </template>
  156. </el-table-column>
  157. </el-table>
  158. <pagination
  159. v-show="total>0"
  160. :total="total"
  161. :page.sync="queryParams.pageNum"
  162. :limit.sync="queryParams.pageSize"
  163. @pagination="getList"
  164. />
  165. <!-- 添加或修改礼品登记对话框 -->
  166. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
  167. <el-form ref="form" :model="form" :rules="rules">
  168. <el-form-item label="礼品名称" prop="giftName">
  169. <el-input v-model="form.giftName" placeholder="请输入礼品名称"/>
  170. </el-form-item>
  171. <el-form-item label="礼品图片" prop="giftPictrue">
  172. <imageUpload v-model="form.giftPictrue"/>
  173. </el-form-item>
  174. <el-form-item label="礼品价格" prop="giftPrice">
  175. <el-input v-model="form.giftPrice" placeholder="请输入礼品价格"/>
  176. </el-form-item>
  177. <el-form-item label="库存数量" prop="amount">
  178. <el-input v-model="form.amount" placeholder="请输入库存数量"/>
  179. </el-form-item>
  180. <el-form-item label="启用标志" prop="qybz">
  181. <el-select v-model="form.qybz" placeholder="请选择启用标志">
  182. <el-option
  183. v-for="dict in dict.type.sys_normal_disable"
  184. :key="dict.value"
  185. :label="dict.label"
  186. :value="dict.value"
  187. ></el-option>
  188. </el-select>
  189. </el-form-item>
  190. <!-- <el-form-item label="礼品类型" prop="giftType">-->
  191. <!-- <treeselect v-model="form.giftType" :options="giftTypeOptions" :normalizer="normalizer"-->
  192. <!-- placeholder="请选择礼品类型"/>-->
  193. <!-- </el-form-item>-->
  194. <el-form-item label="详情内容" prop="remark">
  195. <editor v-model="form.giftContent" :min-height="192"/>
  196. </el-form-item>
  197. </el-form>
  198. <div slot="footer" class="dialog-footer">
  199. <el-button type="primary" @click="submitForm">确 定</el-button>
  200. <el-button @click="cancel">取 消</el-button>
  201. </div>
  202. </el-dialog>
  203. <!-- 添加或修改礼品登记对话框 -->
  204. <el-dialog title="设置公告" :visible.sync="noticeForm.open" width="600px" append-to-body>
  205. <el-input v-model="noticeForm.text" placeholder="请输入公告"/>
  206. <div slot="footer" class="dialog-footer">
  207. <el-button type="primary" @click="updateNotice()" v-prevent-re-click>确 定</el-button>
  208. <el-button @click="cancel">取 消</el-button>
  209. </div>
  210. </el-dialog>
  211. <!-- 添加或修改礼品登记对话框 -->
  212. <el-dialog title="活动事件配置" :visible.sync="eventForm.open" width="1600px" append-to-body>
  213. <eventConfig ref="event" :id="eventGiftForm.eventId"></eventConfig>
  214. </el-dialog>
  215. <!-- 绑定活动礼品话框 -->
  216. <el-dialog title="活动事件配置" :visible.sync="eventGiftForm.open" width="1600px" append-to-body>
  217. <el-table v-loading="bindingQueryParams.loading " :data="giftBindingList"
  218. @selection-change="handleSelectionChange2">
  219. <el-table-column type="selection" width="55" align="center"/>
  220. <el-table-column label="礼品编号" align="center" prop="giftNumber"/>
  221. <el-table-column label="礼品名称" align="center" prop="giftName"/>
  222. <el-table-column label="礼品图片" align="center" prop="giftPictrue">
  223. <template slot-scope="scope">
  224. <img style="width:80px;height:80px;border:none;" :src="baseUrl + scope.row.giftPictrue">
  225. </template>
  226. </el-table-column>
  227. <el-table-column label="礼品价格" align="center" prop="giftPrice"/>
  228. <el-table-column label="库存数量" align="center" prop="amount"/>
  229. <el-table-column label="启用标志" align="center" prop="qybz">
  230. <template slot-scope="scope">
  231. <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.qybz"/>
  232. </template>
  233. </el-table-column>
  234. </el-table>
  235. <pagination
  236. v-show="bindingQueryParams.total>0"
  237. :total="bindingQueryParams.total"
  238. :page.sync="bindingQueryParams.pageNum"
  239. :limit.sync="bindingQueryParams.pageSize"
  240. @pagination="getBindingList"
  241. />
  242. <div slot="footer" class="dialog-footer">
  243. <el-button type="primary" @click="submitBindingEventGifts()" v-prevent-re-click>确 定</el-button>
  244. <el-button @click="cancel">取 消</el-button>
  245. </div>
  246. </el-dialog>
  247. </div>
  248. </template>
  249. <script>
  250. import {
  251. listGift,
  252. getGift,
  253. delGift,
  254. addGift,
  255. updateGift,
  256. exportGift,
  257. getNotice,
  258. notice,
  259. getNoticeStatus,
  260. setNoticeStatus,
  261. bindingList
  262. } from '@/api/canteen/gift'
  263. import { getMasterOrgInfos } from '@/api/master-api'
  264. import { listGiftType } from '@/api/canteen/giftType'
  265. import eventConfig from '@/views/eventConfig/event'
  266. import Treeselect from '@riophae/vue-treeselect'
  267. import '@riophae/vue-treeselect/dist/vue-treeselect.css'
  268. import { submitBindingRelation } from '@/api/eventConfig/relation'
  269. export default {
  270. name: 'Gift',
  271. dicts: ['sys_normal_disable'],
  272. components: {
  273. Treeselect, eventConfig
  274. },
  275. data() {
  276. return {
  277. baseUrl: process.env.VUE_APP_BASE_API,
  278. // 遮罩层
  279. loading: true,
  280. // 导出遮罩层
  281. exportLoading: false,
  282. // 选中数组
  283. ids: [],
  284. // 非单个禁用
  285. single: true,
  286. // 非多个禁用
  287. multiple: true,
  288. // 显示搜索条件
  289. showSearch: true,
  290. // 总条数
  291. total: 0,
  292. // 礼品登记表格数据
  293. giftList: [],
  294. giftBindingList: [],
  295. orgList: [],
  296. // 弹出层标题
  297. title: '',
  298. // 是否显示弹出层
  299. open: false,
  300. noticeForm: {
  301. open: false,
  302. text: '',
  303. openStatus: false
  304. },
  305. eventForm: {
  306. open: false,
  307. text: '',
  308. openStatus: false
  309. },
  310. eventGiftForm: {
  311. eventId: '',
  312. eventBusinessIds: [],
  313. businessType: '1',
  314. open: false,
  315. text: '',
  316. openStatus: false
  317. },
  318. // 礼品类型树选项
  319. giftTypeOptions: [],
  320. // 查询参数
  321. queryParams: {
  322. pageNum: 1,
  323. pageSize: 10,
  324. giftName: null,
  325. giftEventType: '1',
  326. qybz: null
  327. },
  328. // 查询参数
  329. bindingQueryParams: {
  330. pageNum: 1,
  331. pageSize: 10,
  332. total: 0,
  333. loading: false
  334. },
  335. // 表单参数
  336. form: {},
  337. // 表单校验
  338. rules: {
  339. giftName: [
  340. { required: true, message: '礼品名称不能为空', trigger: 'blur' }
  341. ],
  342. qybz: [
  343. { required: true, message: '启用标志 0-启用 1-禁用不能为空', trigger: 'change' }
  344. ]
  345. }
  346. }
  347. },
  348. created() {
  349. this.getList()
  350. this.getNotice()
  351. this.getNoticeStatus()
  352. },
  353. methods: {
  354. submitBindingEventGifts() {
  355. submitBindingRelation(this.eventGiftForm).then(re => {
  356. if (re.code === 200) {
  357. this.$modal.msgSuccess('绑定成功')
  358. this.getBindingList()
  359. }
  360. })
  361. },
  362. setNoticeStatus() {
  363. let data = {
  364. 'openStatus': this.noticeForm.openStatus ? 'true' : 'false'
  365. }
  366. setNoticeStatus(data).then(re => {
  367. this.getNoticeStatus()
  368. this.$modal.msgSuccess('更新成功')
  369. })
  370. },
  371. getNoticeStatus() {
  372. getNoticeStatus().then(re => {
  373. this.noticeForm.openStatus = re.msg !== 'false'
  374. })
  375. },
  376. getNotice() {
  377. getNotice().then(re => {
  378. this.noticeForm.text = re.msg
  379. })
  380. },
  381. updateNotice() {
  382. let params = {
  383. 'text': this.noticeForm.text
  384. }
  385. notice(params).then(re => {
  386. this.$modal.msgSuccess('修改成功')
  387. this.getNotice()
  388. this.noticeForm.open = false
  389. })
  390. },
  391. /** 查询礼品登记列表 */
  392. getList() {
  393. this.loading = true
  394. getMasterOrgInfos().then(response => {
  395. this.orgList = response.data
  396. })
  397. listGift(this.queryParams).then(response => {
  398. this.giftList = response.rows
  399. this.giftList.forEach(item => {
  400. item.orgCode = item.jgid
  401. })
  402. this.total = response.total
  403. this.loading = false
  404. })
  405. },
  406. /** 查询礼品登记列表 */
  407. getBindingList() {
  408. this.bindingQueryParams.loading = true
  409. bindingList(this.bindingQueryParams).then(response => {
  410. this.giftBindingList = response.rows
  411. this.eventGiftForm.open = true
  412. setTimeout(() => {
  413. this.eventGiftForm.eventId = this.$refs.event.getEventId()
  414. }, 10)
  415. this.bindingQueryParams.total = response.total
  416. this.bindingQueryParams.loading = false
  417. })
  418. },
  419. /** 查询礼品类型下拉树结构 */
  420. getTreeselect() {
  421. listGiftType().then(response => {
  422. this.giftTypeOptions = []
  423. const data = { id: 0, giftTypeName: '顶级分类', children: [] }
  424. data.children = this.handleTree(response.data, 'id', 'parentId')
  425. this.giftTypeOptions.push(data)
  426. })
  427. },
  428. /** 转换礼品类型数据结构 */
  429. normalizer(node) {
  430. if (node.children && !node.children.length) {
  431. delete node.children
  432. }
  433. return {
  434. id: node.id,
  435. label: node.giftTypeName,
  436. children: node.children
  437. }
  438. },
  439. // 取消按钮
  440. cancel() {
  441. this.open = false
  442. this.noticeForm.open = false
  443. this.eventGiftForm.open = false
  444. this.noticeForm.text = ''
  445. this.reset()
  446. },
  447. // 表单重置
  448. reset() {
  449. this.form = {
  450. giftId: null,
  451. giftNumber: null,
  452. giftName: null,
  453. giftPictrue: null,
  454. giftPrice: null,
  455. amount: null,
  456. qybz: null,
  457. jgid: null,
  458. isDelete: null,
  459. createBy: null,
  460. createTime: null,
  461. updateBy: null,
  462. updateTime: null,
  463. remark: null
  464. }
  465. this.resetForm('form')
  466. },
  467. /** 搜索按钮操作 */
  468. handleQuery() {
  469. this.queryParams.pageNum = 1
  470. this.getList()
  471. },
  472. /** 重置按钮操作 */
  473. resetQuery() {
  474. this.resetForm('queryForm')
  475. this.handleQuery()
  476. },
  477. // 多选框选中数据
  478. handleSelectionChange(selection) {
  479. this.ids = selection.map(item => item.giftId)
  480. this.single = selection.length !== 1
  481. this.multiple = !selection.length
  482. },
  483. // 多选框选中数据
  484. handleSelectionChange2(selection) {
  485. this.eventGiftForm.eventBusinessIds = selection.map(item => item.giftId)
  486. },
  487. /** 新增按钮操作 */
  488. handleAdd() {
  489. this.getTreeselect()
  490. this.reset()
  491. this.open = true
  492. this.title = '添加礼品登记'
  493. this.form.giftEventType = '1'
  494. },
  495. noticeShow() {
  496. this.noticeForm.open = true
  497. },
  498. eventShow() {
  499. this.eventForm.open = true
  500. setTimeout(() => {
  501. this.$refs.event.queryParams.eventType = '1'
  502. this.$refs.event.getList()
  503. }, 100)
  504. },
  505. /** 修改按钮操作 */
  506. handleUpdate(row) {
  507. this.getTreeselect()
  508. this.reset()
  509. const giftId = row.giftId || this.ids
  510. getGift(giftId).then(response => {
  511. this.form = response.data
  512. this.form.giftEventType = '1'
  513. this.open = true
  514. this.title = '修改礼品登记'
  515. })
  516. },
  517. /** 提交按钮 */
  518. submitForm() {
  519. this.$refs['form'].validate(valid => {
  520. if (valid) {
  521. if (this.form.giftId != null) {
  522. updateGift(this.form).then(response => {
  523. this.$modal.msgSuccess('修改成功')
  524. this.open = false
  525. this.getList()
  526. })
  527. } else {
  528. addGift(this.form).then(response => {
  529. this.$modal.msgSuccess('新增成功')
  530. this.open = false
  531. this.getList()
  532. })
  533. }
  534. }
  535. })
  536. },
  537. /** 删除按钮操作 */
  538. handleDelete(row) {
  539. const giftIds = row.giftId || this.ids
  540. this.$modal.confirm('是否确认删除礼品登记编号为"' + giftIds + '"的数据项?').then(function() {
  541. return delGift(giftIds)
  542. }).then(() => {
  543. this.getList()
  544. this.$modal.msgSuccess('删除成功')
  545. }).catch(() => {
  546. })
  547. },
  548. /** 导出按钮操作 */
  549. handleExport() {
  550. const queryParams = this.queryParams
  551. this.$modal.confirm('是否确认导出所有礼品登记数据项?').then(() => {
  552. this.exportLoading = true
  553. return exportGift(queryParams)
  554. }).then(response => {
  555. this.$download.name(response.msg)
  556. this.exportLoading = false
  557. }).catch(() => {
  558. })
  559. }
  560. }
  561. }
  562. </script>