index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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="请选择">
  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="itemName">
  15. <el-input
  16. v-model="queryParams.itemName"
  17. placeholder="请输入选项名称"
  18. clearable
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  24. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <el-row :gutter="10" class="mb8">
  28. <el-col :span="1.5">
  29. <el-button
  30. type="primary"
  31. plain
  32. icon="el-icon-plus"
  33. size="mini"
  34. @click="handleAdd"
  35. v-hasPermi="['business:game_item:add']"
  36. >新增</el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button
  40. type="success"
  41. plain
  42. icon="el-icon-edit"
  43. size="mini"
  44. :disabled="single"
  45. @click="handleUpdate"
  46. v-hasPermi="['business:game_item:edit']"
  47. >修改</el-button>
  48. </el-col>
  49. <el-col :span="1.5">
  50. <el-button
  51. type="danger"
  52. plain
  53. icon="el-icon-delete"
  54. size="mini"
  55. :disabled="multiple"
  56. @click="handleDelete"
  57. v-hasPermi="['business:game_item:remove']"
  58. >删除</el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="warning"
  63. plain
  64. icon="el-icon-download"
  65. size="mini"
  66. @click="handleExport"
  67. v-hasPermi="['business:game_item:export']"
  68. >导出</el-button>
  69. </el-col>
  70. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  71. </el-row>
  72. <el-table v-loading="loading" :data="game_itemList" @selection-change="handleSelectionChange">
  73. <el-table-column type="selection" width="55" align="center" />
  74. <el-table-column label="主键ID" align="center" prop="id" />
  75. <el-table-column label="游戏" align="center" prop="gameId">
  76. <template slot-scope="scope">
  77. <span>{{ getTypeName(scope.row.gameId) }}</span>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="选项名称" align="center" prop="itemName" />
  81. <el-table-column label="选项倍数" align="center" prop="itemMultiple" />
  82. <el-table-column label="选项值" align="center" prop="itemLocation" />
  83. <el-table-column label="每期投注上限" align="center" prop="bettingMoney" />
  84. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  85. <template slot-scope="scope">
  86. <el-button
  87. size="mini"
  88. type="text"
  89. icon="el-icon-edit"
  90. @click="handleUpdate(scope.row)"
  91. v-hasPermi="['business:game_item:edit']"
  92. >修改</el-button>
  93. <el-button
  94. size="mini"
  95. type="text"
  96. icon="el-icon-delete"
  97. @click="handleDelete(scope.row)"
  98. v-hasPermi="['business:game_item:remove']"
  99. >删除</el-button>
  100. </template>
  101. </el-table-column>
  102. </el-table>
  103. <pagination
  104. v-show="total>0"
  105. :total="total"
  106. :page.sync="queryParams.pageNum"
  107. :limit.sync="queryParams.pageSize"
  108. @pagination="getList"
  109. />
  110. <!-- 添加或修改游戏选项对话框 -->
  111. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  112. <el-form ref="form" :model="form" :rules="rules" label-width="30%">
  113. <el-form-item label="游戏ID" prop="gameId">
  114. <el-input v-model="form.gameId" placeholder="请输入游戏ID" />
  115. </el-form-item>
  116. <el-form-item label="选项名称" prop="itemName">
  117. <el-input v-model="form.itemName" placeholder="请输入选项名称" />
  118. </el-form-item>
  119. <el-form-item label="选项倍数" prop="itemMultiple">
  120. <el-input v-model="form.itemMultiple" placeholder="请输入选项倍数" />
  121. </el-form-item>
  122. <el-form-item label="选项值" prop="itemLocation">
  123. <el-input v-model="form.itemLocation" placeholder="请输入选项值" disabled/>
  124. </el-form-item>
  125. <el-form-item label="每期投注上限金额" prop="bettingMoney">
  126. <el-input v-model="form.bettingMoney" placeholder="请输入" />
  127. </el-form-item>
  128. </el-form>
  129. <div slot="footer" class="dialog-footer">
  130. <el-button type="primary" @click="submitForm">确 定</el-button>
  131. <el-button @click="cancel">取 消</el-button>
  132. </div>
  133. </el-dialog>
  134. </div>
  135. </template>
  136. <script>
  137. import { listGame_item, getGame_item, delGame_item, addGame_item, updateGame_item,allGameList } from "@/api/business/game_item";
  138. export default {
  139. name: "Game_item",
  140. data() {
  141. return {
  142. // 遮罩层
  143. loading: true,
  144. // 选中数组
  145. ids: [],
  146. // 非单个禁用
  147. single: true,
  148. // 非多个禁用
  149. multiple: true,
  150. // 显示搜索条件
  151. showSearch: true,
  152. // 总条数
  153. total: 0,
  154. // 游戏选项表格数据
  155. game_itemList: [],
  156. // 弹出层标题
  157. title: "",
  158. // 是否显示弹出层
  159. open: false,
  160. typeMap:{},
  161. typeList:[],
  162. // 查询参数
  163. queryParams: {
  164. pageNum: 1,
  165. pageSize: 10,
  166. gameId: null,
  167. itemName: null,
  168. itemMultiple: null,
  169. itemLocation: null
  170. },
  171. // 表单参数
  172. form: {},
  173. // 表单校验
  174. rules: {
  175. }
  176. };
  177. },
  178. created() {
  179. var that = this;
  180. allGameList().then(response => {
  181. if(response.data){
  182. for(var i in response.data){
  183. var item = response.data[i];
  184. that.typeMap[item.id.toString()] = item.name;
  185. that.typeList.push({
  186. value:item.id,
  187. label:item.name
  188. })
  189. }
  190. }
  191. this.getList();
  192. })
  193. },
  194. methods: {
  195. getTypeName(id) {
  196. return this.typeMap[id.toString()];
  197. },
  198. /** 查询游戏选项列表 */
  199. getList() {
  200. this.loading = true;
  201. listGame_item(this.queryParams).then(response => {
  202. this.game_itemList = response.rows;
  203. this.total = response.total;
  204. this.loading = false;
  205. });
  206. },
  207. // 取消按钮
  208. cancel() {
  209. this.open = false;
  210. this.reset();
  211. },
  212. // 表单重置
  213. reset() {
  214. this.form = {
  215. id: null,
  216. gameId: null,
  217. itemName: null,
  218. itemMultiple: null,
  219. itemLocation: null
  220. };
  221. this.resetForm("form");
  222. },
  223. /** 搜索按钮操作 */
  224. handleQuery() {
  225. this.queryParams.pageNum = 1;
  226. this.getList();
  227. },
  228. /** 重置按钮操作 */
  229. resetQuery() {
  230. this.resetForm("queryForm");
  231. this.handleQuery();
  232. },
  233. // 多选框选中数据
  234. handleSelectionChange(selection) {
  235. this.ids = selection.map(item => item.id)
  236. this.single = selection.length!==1
  237. this.multiple = !selection.length
  238. },
  239. /** 新增按钮操作 */
  240. handleAdd() {
  241. this.reset();
  242. this.open = true;
  243. this.title = "添加游戏选项";
  244. },
  245. /** 修改按钮操作 */
  246. handleUpdate(row) {
  247. this.reset();
  248. const id = row.id || this.ids
  249. getGame_item(id).then(response => {
  250. this.form = response.data;
  251. this.open = true;
  252. this.title = "修改游戏选项";
  253. });
  254. },
  255. /** 提交按钮 */
  256. submitForm() {
  257. this.$refs["form"].validate(valid => {
  258. if (valid) {
  259. if (this.form.id != null) {
  260. updateGame_item(this.form).then(response => {
  261. this.$modal.msgSuccess("修改成功");
  262. this.open = false;
  263. this.getList();
  264. });
  265. } else {
  266. addGame_item(this.form).then(response => {
  267. this.$modal.msgSuccess("新增成功");
  268. this.open = false;
  269. this.getList();
  270. });
  271. }
  272. }
  273. });
  274. },
  275. /** 删除按钮操作 */
  276. handleDelete(row) {
  277. const ids = row.id || this.ids;
  278. this.$modal.confirm('是否确认删除游戏选项编号为"' + ids + '"的数据项?').then(function() {
  279. return delGame_item(ids);
  280. }).then(() => {
  281. this.getList();
  282. this.$modal.msgSuccess("删除成功");
  283. }).catch(() => {});
  284. },
  285. /** 导出按钮操作 */
  286. handleExport() {
  287. this.download('business/game_item/export', {
  288. ...this.queryParams
  289. }, `game_item_${new Date().getTime()}.xlsx`)
  290. }
  291. }
  292. };
  293. </script>