index.vue 8.7 KB

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