index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="游戏" prop="gameId">
  5. <el-select v-model="queryParams.gameId" placeholder="请选择" @change="initGameItemList">
  6. <el-option
  7. v-for="item in typeList"
  8. :key="item.value"
  9. :label="item.label"
  10. :value="item.value"
  11. ></el-option>
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="开奖选项" prop="gameLotterySucc">
  15. <el-select v-model="queryParams.gameLotterySuccItem" placeholder="请选择" clearable>
  16. <el-option
  17. v-for="dict in gameItemShowList"
  18. :key="dict.value"
  19. :label="dict.label"
  20. :value="dict.value"
  21. />
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="游戏期号" prop="gameDate">
  25. <el-input
  26. v-model="queryParams.gameDate"
  27. placeholder="请输入游戏期号"
  28. clearable
  29. @keyup.enter.native="handleQuery"
  30. />
  31. </el-form-item>
  32. <!-- <el-form-item label="是否开奖" prop="isLottery">
  33. <el-select v-model="queryParams.isLottery" placeholder="请选择是否开奖" clearable>
  34. <el-option
  35. v-for="dict in dict.type.app_game_is_open"
  36. :key="dict.value"
  37. :label="dict.label"
  38. :value="dict.value"
  39. />
  40. </el-select>
  41. </el-form-item>-->
  42. <!-- <el-form-item label="记录时间" prop="gameRecordDate">
  43. <el-date-picker clearable
  44. v-model="queryParams.gameRecordDate"
  45. type="date"
  46. value-format="yyyy-MM-dd"
  47. placeholder="请选择记录时间">
  48. </el-date-picker>
  49. </el-form-item>-->
  50. <el-form-item>
  51. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  52. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  53. </el-form-item>
  54. </el-form>
  55. <el-row :gutter="10" class="mb8">
  56. <el-col :span="1.5">
  57. <el-button
  58. type="primary"
  59. plain
  60. icon="el-icon-plus"
  61. size="mini"
  62. @click="handleKj"
  63. >手动开奖</el-button>
  64. </el-col>
  65. <el-col :span="1.5">
  66. <el-button
  67. type="primary"
  68. plain
  69. icon="el-icon-plus"
  70. size="mini"
  71. @click="handleAdd"
  72. v-hasPermi="['business:lottery:add']"
  73. >新增</el-button>
  74. </el-col>
  75. <el-col :span="1.5">
  76. <el-button
  77. type="success"
  78. plain
  79. icon="el-icon-edit"
  80. size="mini"
  81. :disabled="single"
  82. @click="handleUpdate"
  83. v-hasPermi="['business:lottery:edit']"
  84. >修改</el-button>
  85. </el-col>
  86. <el-col :span="1.5">
  87. <el-button
  88. type="danger"
  89. plain
  90. icon="el-icon-delete"
  91. size="mini"
  92. :disabled="multiple"
  93. @click="handleDelete"
  94. v-hasPermi="['business:lottery:remove']"
  95. >删除</el-button>
  96. </el-col>
  97. <el-col :span="1.5">
  98. <el-button
  99. type="warning"
  100. plain
  101. icon="el-icon-download"
  102. size="mini"
  103. @click="handleExport"
  104. v-hasPermi="['business:lottery:export']"
  105. >导出</el-button>
  106. </el-col>
  107. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  108. </el-row>
  109. <el-table v-loading="loading" :data="lotteryList" @selection-change="handleSelectionChange">
  110. <el-table-column type="selection" width="55" align="center" />
  111. <el-table-column label="主键ID" align="center" prop="id" />
  112. <el-table-column label="游戏" align="center" prop="gameId">
  113. <template slot-scope="scope">
  114. <span>{{ getTypeName(scope.row.gameId) }}</span>
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="游戏期号" align="center" prop="gameDate" />
  118. <el-table-column label="是否开奖" align="center" prop="isLottery">
  119. <template slot-scope="scope">
  120. <dict-tag :options="dict.type.app_game_is_open" :value="scope.row.isLottery"/>
  121. </template>
  122. </el-table-column>
  123. <el-table-column label="开奖选项" align="center" prop="gameLotterySucc">
  124. <template slot-scope="scope">
  125. <span>{{ getItemName(scope.row.gameLotterySucc,scope.row.gameId) }}</span>
  126. </template>
  127. </el-table-column>
  128. <el-table-column label="记录时间" align="center" prop="gameRecordDate" width="180">
  129. <template slot-scope="scope">
  130. <span>{{ parseTime(scope.row.gameRecordDate, '{y}-{m}-{d}') }}</span>
  131. </template>
  132. </el-table-column>
  133. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  134. <template slot-scope="scope">
  135. <el-button
  136. size="mini"
  137. type="text"
  138. icon="el-icon-edit"
  139. @click="handleUpdate(scope.row)"
  140. v-hasPermi="['business:lottery:edit']"
  141. >修改</el-button>
  142. <el-button
  143. size="mini"
  144. type="text"
  145. icon="el-icon-delete"
  146. @click="handleDelete(scope.row)"
  147. v-hasPermi="['business:lottery:remove']"
  148. >删除</el-button>
  149. </template>
  150. </el-table-column>
  151. </el-table>
  152. <pagination
  153. v-show="total>0"
  154. :total="total"
  155. :page.sync="queryParams.pageNum"
  156. :limit.sync="queryParams.pageSize"
  157. @pagination="getList"
  158. />
  159. <!-- 添加或修改游戏开奖记录对话框 -->
  160. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  161. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  162. <el-form-item label="游戏类型" prop="classId">
  163. <el-select v-model="form.classId" placeholder="请选择">
  164. <el-option
  165. v-for="item in gameClassifyList"
  166. :key="item.value"
  167. :label="item.label"
  168. :value="item.value"
  169. ></el-option>
  170. </el-select>
  171. </el-form-item>
  172. <el-form-item label="游戏ID" prop="gameId">
  173. <el-select v-model="form.gameId" placeholder="请选择">
  174. <el-option
  175. v-for="item in typeList"
  176. :key="item.value"
  177. :label="item.label"
  178. :value="item.value"
  179. ></el-option>
  180. </el-select>
  181. </el-form-item>
  182. <el-form-item label="游戏期号" prop="gameDate">
  183. <el-input v-model="form.gameDate" placeholder="请输入游戏期号" />
  184. </el-form-item>
  185. <el-form-item label="是否开奖 0 否 1 是" prop="isLottery">
  186. <el-select v-model="form.isLottery" placeholder="请选择是否开奖 0 否 1 是">
  187. <el-option
  188. v-for="dict in dict.type.app_game_is_open"
  189. :key="dict.value"
  190. :label="dict.label"
  191. :value="dict.value"
  192. ></el-option>
  193. </el-select>
  194. </el-form-item>
  195. <el-form-item label="开奖选项" prop="gameLotterySucc">
  196. <el-input v-model="form.gameLotterySucc" placeholder="请输入开奖选项" />
  197. </el-form-item>
  198. <el-form-item label="记录时间" prop="gameRecordDate">
  199. <el-date-picker clearable
  200. v-model="form.gameRecordDate"
  201. type="date"
  202. value-format="yyyy-MM-dd"
  203. placeholder="请选择记录时间">
  204. </el-date-picker>
  205. </el-form-item>
  206. </el-form>
  207. <div slot="footer" class="dialog-footer">
  208. <el-button type="primary" @click="submitForm">确 定</el-button>
  209. <el-button @click="cancel">取 消</el-button>
  210. </div>
  211. </el-dialog>
  212. <!-- 手动开奖 -->
  213. <el-dialog :title="title" :visible.sync="kjOpen" width="500px" append-to-body>
  214. <el-form ref="kjForm" :model="kjForm" :rules="kjRules" label-width="80px">
  215. <el-form-item label="游戏类型" prop="classId">
  216. <el-select v-model="kjForm.classId" placeholder="请选择" @change="changeClass">
  217. <el-option
  218. v-for="item in gameClassifyList"
  219. :key="item.value"
  220. :label="item.label"
  221. :value="item.value"
  222. ></el-option>
  223. </el-select>
  224. </el-form-item>
  225. <el-form-item label="游戏" prop="gameId" >
  226. <el-select v-model="kjForm.gameId" placeholder="请选择" @change="changeGame">
  227. <el-option
  228. v-for="item in kjGamelist"
  229. :key="item.value"
  230. :label="item.label"
  231. :value="item.value"
  232. ></el-option>
  233. </el-select>
  234. </el-form-item>
  235. <el-form-item label="开奖选项" prop="gameLotterySucc">
  236. <el-select v-model="kjForm.gameLotterySucc" placeholder="请选择">
  237. <el-option
  238. v-for="dict in kjGameItemList"
  239. :key="dict.value"
  240. :label="dict.label"
  241. :value="dict.value"
  242. ></el-option>
  243. </el-select>
  244. </el-form-item>
  245. <el-form-item label="游戏期号" prop="gameDate">
  246. <el-input v-model="kjForm.gameDate" placeholder="请输入游戏期号" />
  247. </el-form-item>
  248. <el-form-item label="是否开奖" prop="isLottery">
  249. <el-select v-model="kjForm.isLottery" placeholder="请选择">
  250. <el-option
  251. v-for="dict in dict.type.app_game_is_open"
  252. :key="dict.value"
  253. :label="dict.label"
  254. :value="dict.value"
  255. ></el-option>
  256. </el-select>
  257. </el-form-item>
  258. </el-form>
  259. <div slot="footer" class="dialog-footer">
  260. <el-button type="primary" @click="submitKjForm">确 定</el-button>
  261. <el-button @click="cancel">取 消</el-button>
  262. </div>
  263. </el-dialog>
  264. </div>
  265. </template>
  266. <script>
  267. import { listLottery, getLottery, delLottery, addLottery, updateLottery,allList,kjLottery } from "@/api/business/lottery";
  268. import {allGameList } from "@/api/business/game_item";
  269. import {listClassifyGame } from "@/api/business/game";
  270. export default {
  271. name: "Lottery",
  272. dicts: ['app_game_is_open'],
  273. data() {
  274. return {
  275. // 遮罩层
  276. loading: true,
  277. // 选中数组
  278. ids: [],
  279. // 非单个禁用
  280. single: true,
  281. // 非多个禁用
  282. multiple: true,
  283. // 显示搜索条件
  284. showSearch: true,
  285. // 总条数
  286. total: 0,
  287. // 游戏开奖记录表格数据
  288. lotteryList: [],
  289. // 弹出层标题
  290. title: "",
  291. // 是否显示弹出层
  292. open: false,
  293. kjOpen:false,
  294. typeMap:{},
  295. typeList:[],
  296. gameItemMap:{},
  297. gameItemList:[],
  298. gameItemShowList:[],
  299. gameClassifyList:[],
  300. kjGamelist:[],
  301. kjGameItemList:[],
  302. // 查询参数
  303. queryParams: {
  304. pageNum: 1,
  305. pageSize: 10,
  306. classId: null,
  307. gameId: null,
  308. gameDate: null,
  309. isLottery: null,
  310. gameLotterySucc: null,
  311. gameLotterySuccItem: null,
  312. gameRecordDate: null
  313. },
  314. // 表单参数
  315. form: {},
  316. kjForm:{},
  317. // 表单校验
  318. rules: {
  319. classId: [
  320. { required: true, message: "游戏类型ID不能为空", trigger: "blur" }
  321. ],
  322. gameId: [
  323. { required: true, message: "游戏ID不能为空", trigger: "blur" }
  324. ],
  325. },
  326. // 表单校验
  327. kjRules: {
  328. classId: [
  329. { required: true, message: "游戏类型不能为空", trigger: "blur" }
  330. ],
  331. gameId: [
  332. { required: true, message: "游戏不能为空", trigger: "blur" }
  333. ],
  334. gameLotterySucc: [
  335. { required: true, message: "游戏选项不能为空", trigger: "blur" }
  336. ],
  337. gameDate: [
  338. { required: true, message: "游戏期号不能为空", trigger: "blur" }
  339. ],
  340. isLottery: [
  341. { required: true, message: "是否开奖不能为空", trigger: "blur" }
  342. ],
  343. }
  344. };
  345. },
  346. created() {
  347. var that = this;
  348. allList().then(response => {
  349. if(response.data){
  350. for(var i in response.data){
  351. var item = response.data[i];
  352. that.gameItemMap[item.itemLocation.toString() + "_" + item.gameId] = item.itemName;
  353. that.gameItemList.push({
  354. value:item.itemLocation+"_"+item.gameId,
  355. label:item.itemName,
  356. gameId:item.gameId
  357. })
  358. }
  359. }
  360. });
  361. listClassifyGame().then(response => {
  362. if(response.data){
  363. for(var i in response.data){
  364. var item = response.data[i];
  365. that.gameClassifyList.push({
  366. value:item.id,
  367. label:item.name
  368. })
  369. }
  370. }
  371. });
  372. allGameList().then(response => {
  373. if(response.data){
  374. for(var i in response.data){
  375. var item = response.data[i];
  376. that.typeMap[item.id.toString()] = item.name;
  377. that.typeList.push({
  378. value:item.id,
  379. label:item.name,
  380. classId:item.classifyId
  381. })
  382. }
  383. }
  384. this.getList();
  385. })
  386. },
  387. methods: {
  388. initGameItemList(val){
  389. this.gameItemShowList = [];
  390. for(var i in this.gameItemList){
  391. var item = this.gameItemList[i];
  392. if(item.gameId == val){
  393. this.gameItemShowList.push(item);
  394. }
  395. }
  396. },
  397. changeClass(val){
  398. var that = this;
  399. that.kjGamelist = [];
  400. that.kjForm.gameId = null;
  401. that.kjForm.gameLotterySucc = null;
  402. for(var i in that.typeList){
  403. var item = that.typeList[i];
  404. if(item["classId"] == val){
  405. that.kjGamelist.push(item);
  406. }
  407. }
  408. },
  409. changeGame(val){
  410. var that = this;
  411. that.kjGameItemList = [];
  412. that.kjForm.gameLotterySucc = null;
  413. for(var i in that.gameItemList){
  414. var item = that.gameItemList[i];
  415. console.log(item["gameId"],val)
  416. if(item["gameId"] == val){
  417. that.kjGameItemList.push({
  418. value:item["value"].split("_")[0],
  419. label:item["label"],
  420. gameId:item["gameId"]
  421. });
  422. }
  423. }
  424. },
  425. getTypeName(id) {
  426. return this.typeMap[id.toString()];
  427. },
  428. getItemName(id,gameId) {
  429. let that = this;
  430. let val = "";
  431. let arr = id.split(",")
  432. for(var i in arr){
  433. var item = arr[i];
  434. if(val != ""){
  435. val += ",";
  436. }
  437. val += that.gameItemMap[item+"_"+gameId]
  438. }
  439. return val;
  440. },
  441. /** 查询游戏开奖记录列表 */
  442. getList() {
  443. this.loading = true;
  444. listLottery(this.queryParams).then(response => {
  445. this.lotteryList = response.rows;
  446. this.total = response.total;
  447. this.loading = false;
  448. });
  449. },
  450. // 取消按钮
  451. cancel() {
  452. this.open = false;
  453. this.kjOpen = false;
  454. this.reset();
  455. this.resetKj();
  456. },
  457. // 表单重置
  458. reset() {
  459. this.form = {
  460. id: null,
  461. classId: null,
  462. gameId: null,
  463. gameDate: null,
  464. isLottery: null,
  465. gameLotterySucc: null,
  466. gameRecordDate: null
  467. };
  468. this.resetForm("form");
  469. },
  470. resetKj() {
  471. this.kjForm = {
  472. id: null,
  473. classId: null,
  474. gameId: null,
  475. gameDate: null,
  476. isLottery: null,
  477. gameLotterySucc: null,
  478. gameRecordDate: null
  479. };
  480. this.resetForm("form");
  481. },
  482. /** 搜索按钮操作 */
  483. handleQuery() {
  484. if(this.queryParams.gameLotterySuccItem){
  485. this.queryParams.gameLotterySucc = this.queryParams.gameLotterySuccItem.split("_")[0];
  486. }
  487. this.queryParams.pageNum = 1;
  488. this.getList();
  489. },
  490. /** 重置按钮操作 */
  491. resetQuery() {
  492. this.queryParams.gameLotterySuccItem = null;
  493. this.resetForm("queryForm");
  494. this.handleQuery();
  495. },
  496. // 多选框选中数据
  497. handleSelectionChange(selection) {
  498. this.ids = selection.map(item => item.id)
  499. this.single = selection.length!==1
  500. this.multiple = !selection.length
  501. },
  502. /** 新增按钮操作 */
  503. handleAdd() {
  504. this.reset();
  505. this.open = true;
  506. this.title = "添加游戏开奖记录";
  507. },
  508. /** 新增按钮操作 */
  509. handleKj() {
  510. this.resetKj();
  511. this.kjOpen = true;
  512. this.title = "手动开奖";
  513. },
  514. /** 修改按钮操作 */
  515. handleUpdate(row) {
  516. this.reset();
  517. const id = row.id || this.ids
  518. getLottery(id).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.id != null) {
  529. updateLottery(this.form).then(response => {
  530. this.$modal.msgSuccess("修改成功");
  531. this.open = false;
  532. this.getList();
  533. });
  534. } else {
  535. addLottery(this.form).then(response => {
  536. this.$modal.msgSuccess("新增成功");
  537. this.open = false;
  538. this.getList();
  539. });
  540. }
  541. }
  542. });
  543. },
  544. /** 提交按钮 */
  545. submitKjForm() {
  546. this.$refs["kjForm"].validate(valid => {
  547. if (valid) {
  548. kjLottery(this.kjForm).then(response => {
  549. this.$modal.msgSuccess(response.msg);
  550. this.open = false;
  551. this.getList();
  552. });
  553. }
  554. });
  555. },
  556. /** 删除按钮操作 */
  557. handleDelete(row) {
  558. const ids = row.id || this.ids;
  559. this.$modal.confirm('是否确认删除游戏开奖记录编号为"' + ids + '"的数据项?').then(function() {
  560. return delLottery(ids);
  561. }).then(() => {
  562. this.getList();
  563. this.$modal.msgSuccess("删除成功");
  564. }).catch(() => {});
  565. },
  566. /** 导出按钮操作 */
  567. handleExport() {
  568. this.download('business/lottery/export', {
  569. ...this.queryParams
  570. }, `lottery_${new Date().getTime()}.xlsx`)
  571. }
  572. }
  573. };
  574. </script>