Nessuna descrizione

index.vue 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <div class="app-container calendar-list-container">
  3. <div v-show="visible.secondLayer">
  4. <div class="app-container">
  5. <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="名稱" v-model="listQuery.name">
  6. </el-input>
  7. <!-- <el-select clearable @change='handleFilter' style="width: 120px" class="filter-item" v-model="listQuery.chipsSort" placeholder="點數">
  8. <el-option v-for="item in chipsSortOptions" :key="item.label" :label="item.label" :value="item.key">
  9. </el-option>
  10. </el-select>
  11. <el-select clearable @change='handleFilter' style="width: 120px" class="filter-item" v-model="listQuery.updatedSort" placeholder="更新時間">
  12. <el-option v-for="item in updatedSortOptions" :key="item.label" :label="item.label" :value="item.key">
  13. </el-option>
  14. </el-select> -->
  15. <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜尋</el-button>
  16. <el-button class="filter-item" @click="handleCreate" type="primary" icon="el-icon-edit">創建</el-button>
  17. <el-button class="filter-item" type="danger" v-waves icon="el-icon-warning" @click="handlereset">歸零</el-button>
  18. </div>
  19. <el-table :data="list" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row
  20. style="width: 100%">
  21. <!-- <el-table-column align="center" label='ID' >
  22. <template slot-scope="scope">
  23. {{scope.row.id}}
  24. </template>
  25. </el-table-column> -->
  26. <el-table-column label="名稱" align="center">
  27. <template slot-scope="scope">
  28. {{scope.row.WeChatUser.name}}
  29. </template>
  30. </el-table-column>
  31. <el-table-column label="點數" align="center">
  32. <template slot-scope="scope">
  33. <span>{{scope.row.WeChatUser.GambleMember.chips}}</span>
  34. </template>
  35. </el-table-column>
  36. <el-table-column label="代理商" align="center">
  37. <template slot-scope="scope">
  38. <el-button v-if="noAgent(scope.row.WeChatUser.GambleMember)" type="primary" size="mini" icon="el-icon-edit" @click="handleAgentUpdate(scope.row)">代理商設定</el-button>
  39. <span v-if="haveAgent(scope.row.WeChatUser.GambleMember)">{{scope.row.WeChatUser.GambleMember.GambleAgent.name}}</span>
  40. </template>
  41. </el-table-column>
  42. <el-table-column align="center" label="操作" width="350">
  43. <template slot-scope="scope">
  44. <el-button v-if="haveAgent(scope.row.WeChatUser.GambleMember)" type="primary" size="mini" icon="el-icon-edit" @click="handleChipsMangement(scope.row)">分數管理</el-button>
  45. <router-link to="/room/index/gambleMember/index/chipsHistory">
  46. <el-button type="primary" size="mini" icon="el-icon-tickets" @click="handleLog(scope.row)">分數紀錄</el-button>
  47. </router-link>
  48. <router-link to="/room/index/gambleMember/index/gameHistory">
  49. <el-button type="primary" size="mini" icon="el-icon-tickets" @click="handlePage(scope.row)">歷史查詢</el-button>
  50. </router-link>
  51. </template>
  52. </el-table-column>
  53. </el-table>
  54. <div v-show="!listLoading" class="pagination-container">
  55. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.page"
  56. :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
  57. </el-pagination>
  58. </div>
  59. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :before-close="handleDialogClose" center>
  60. <el-tabs v-model="activeName" @tab-click="handleClick" type="card">
  61. <el-tab-pane label="上下分" name="deposit">
  62. <el-form :rules="rules" ref="depositForm" :model="temp" label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'>
  63. <!-- <el-form-item label="ID" prop="id">
  64. <el-input v-model="temp.id" :disabled="true"></el-input>
  65. </el-form-item> -->
  66. <el-form-item label="名稱" prop="name">
  67. <el-input v-if="dialogStatus=='deposit'" v-model="temp.WeChatUser.name" :disabled="true"></el-input>
  68. </el-form-item>
  69. <el-form-item label="點數" prop="chips">
  70. <el-input v-model="temp.WeChatUser.GambleMember.chips" :disabled="true"></el-input>
  71. </el-form-item>
  72. <el-form-item v-if="dialogStatus=='deposit'" label="上下分" prop="depositChips">
  73. <el-input placeholder="請輸入上下分" v-model="temp.depositChips"></el-input>
  74. </el-form-item>
  75. </el-form>
  76. </el-tab-pane>
  77. <el-tab-pane label="獎懲" name="reward">
  78. <el-form :rules="rules" ref="rewardForm" :model="temp" label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'>
  79. <!-- <el-form-item label="ID" prop="id">
  80. <el-input v-model="temp.id" :disabled="true"></el-input>
  81. </el-form-item> -->
  82. <el-form-item label="名稱" prop="name">
  83. <el-input v-model="temp.WeChatUser.name" :disabled="true"></el-input>
  84. </el-form-item>
  85. <el-form-item label="點數" prop="chips">
  86. <el-input v-model="temp.WeChatUser.GambleMember.chips" :disabled="true"></el-input>
  87. </el-form-item>
  88. <el-form-item v-if="dialogStatus=='reward'" label="獎懲" prop="rewardChips">
  89. <el-input placeholder="請輸入獎懲點數" v-model="temp.rewardChips"></el-input>
  90. </el-form-item>
  91. </el-form>
  92. </el-tab-pane>
  93. </el-tabs>
  94. <div slot="footer" class="dialog-footer">
  95. <el-button @click="handleDialogClose">取 消</el-button>
  96. <el-button v-if="dialogStatus=='reward'" type="primary" @click="rewardChips">確 定</el-button>
  97. <el-button v-if="dialogStatus=='deposit'" type="primary" @click="depositChips">確 定</el-button>
  98. </div>
  99. </el-dialog>
  100. <el-dialog title="所屬代理商" :visible.sync="dialogUpdateFormVisible" :before-close="handleDialogClose" center>
  101. <el-form :rules="rules" :model="temp" ref="updateForm" label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'>
  102. <el-form-item label="使用者" prop="id">
  103. <el-input v-model="temp.WeChatUser.GambleMember.name" :disabled="true"></el-input>
  104. </el-form-item>
  105. <el-form-item label="代理商" prop="name">
  106. <multiselect v-model="updateFormData" :options="agentLIstOptions" @search-change="getRemoteAgentList" placeholder="代理商搜尋" selectLabel="選擇"
  107. deselectLabel="删除" track-by="key" :internalSearch="false" label="key">
  108. <span slot='noResult'>無結果</span>
  109. </multiselect>
  110. </el-form-item>
  111. </el-form>
  112. <div slot="footer" class="dialog-footer">
  113. <el-button @click="handleDialogClose">取 消</el-button>
  114. <el-button type="primary" @click="updateData">確 定</el-button>
  115. </div>
  116. </el-dialog>
  117. <el-dialog title="會員創建" :visible.sync="dialogCreateFormVisible" :before-close="handleDialogClose" center>
  118. <el-form :rules="rules" :model="tempCreate" ref="createForm" label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'>
  119. <el-form-item label="名稱" prop="id">
  120. <el-input v-model="tempCreate.name"></el-input>
  121. </el-form-item>
  122. </el-form>
  123. <div slot="footer" class="dialog-footer">
  124. <el-button @click="handleDialogClose">取 消</el-button>
  125. <el-button type="primary" @click="createData">確 定</el-button>
  126. </div>
  127. </el-dialog>
  128. </div>
  129. <router-view></router-view>
  130. </div>
  131. </template>
  132. <script>
  133. import { mapGetters, mapActions } from 'vuex'
  134. // TODO 需更改抓取此房間人員
  135. import { fetchWeChatMemberList, chipsDeposit, chipsReward, createGambleMember, fetchAgentList, updateBelongAgent } from '@/api/gambleMember'
  136. import { resetWechatRoomMembersChips, createWechatMember } from '@/api/room'
  137. import waves from '@/directive/waves' // 水波纹指令
  138. import Multiselect from 'vue-multiselect'// 使用的一个多选框组件,element-ui的select不能满足所有需求
  139. import 'vue-multiselect/dist/vue-multiselect.min.css'// 多选框组件css
  140. export default {
  141. name: 'gambleMemberTable',
  142. components: { Multiselect },
  143. directives: {
  144. waves
  145. },
  146. data() {
  147. return {
  148. list: null,
  149. total: null,
  150. listLoading: true,
  151. listQuery: {
  152. page: 1,
  153. limit: 20,
  154. name: '',
  155. chipsSort: '',
  156. updatedSort: ''
  157. },
  158. tempCreate: {
  159. name: '',
  160. },
  161. dialogCreateFormVisible: false,
  162. temp: {
  163. id: '',
  164. WeChatUser: {
  165. GambleMember: {
  166. GambleAgent: {},
  167. },
  168. },
  169. depositChips: '',
  170. rewardChips: '',
  171. },
  172. dialogFormVisible: false,
  173. dialogStatus: '',
  174. textMap: {
  175. deposit: '上下分',
  176. reward: '獎懲'
  177. },
  178. chipsSortOptions: [{ label: '多 -> 少', key: 'DESC' }, { label: '少 -> 多', key: 'ASC' }],
  179. updatedSortOptions: [{ label: '新 -> 舊', key: 'DESC' }, { label: '舊 -> 新', key: 'ASC' }],
  180. rules: {
  181. rewardChips: [{ pattern: /^-?\d+$/, required: true, message: '請輸入整數', trigger: 'change' }],
  182. depositChips: [{ pattern: /^-?\d+$/, required: true, message: '請輸入整數', trigger: 'change' }],
  183. },
  184. activeName: 'deposit',
  185. dialogUpdateFormVisible: false,
  186. updateFormData: {},
  187. agentLIstOptions: [],
  188. }
  189. },
  190. created() {
  191. console.log('sssss', this.data.secondLayer)
  192. this.SetVisible(2)
  193. this.getList()
  194. },
  195. destroyed() {
  196. this.SetVisible(1)
  197. },
  198. computed: {
  199. ...mapGetters([
  200. 'visible',
  201. 'data',
  202. // 'query'
  203. ])
  204. },
  205. methods: {
  206. ...mapActions([
  207. 'SetVisible',
  208. 'SetData',
  209. // 'SetQuery'
  210. ]),
  211. getList() {
  212. this.listLoading = true
  213. fetchWeChatMemberList(this.data.secondLayer, this.listQuery).then(response => {
  214. this.list = response.data.rows
  215. this.total = response.data.count
  216. this.listLoading = false
  217. })
  218. },
  219. handleChipsMangement(row) {
  220. this.temp = Object.assign({}, row) // copy obj
  221. this.dialogStatus = 'deposit'
  222. this.dialogFormVisible = true
  223. this.$nextTick(() => {
  224. this.$refs['depositForm'].clearValidate()
  225. this.$refs['rewardForm'].clearValidate()
  226. })
  227. },
  228. depositChips() {
  229. this.$refs['depositForm'].validate((valid) => {
  230. if (valid) {
  231. const tempData = Object.assign({}, this.temp)
  232. chipsDeposit(tempData).then(() => {
  233. for (const v of this.list) {
  234. if (v.id === this.temp.id) {
  235. const index = this.list.indexOf(v)
  236. this.list.splice(index, 1, this.temp)
  237. break
  238. }
  239. }
  240. this.dialogFormVisible = false
  241. this.$notify({
  242. title: '成功',
  243. message: '操作成功',
  244. type: 'success',
  245. duration: 2000
  246. })
  247. this.getList()
  248. })
  249. }
  250. })
  251. },
  252. resetTemp() {
  253. this.temp = {
  254. id: '',
  255. WeChatUser: {
  256. GambleMember: {
  257. GambleAgent: {},
  258. depositChips: '',
  259. rewardChips: '',
  260. },
  261. }
  262. }
  263. },
  264. handlePage(row) {
  265. const temp = Object.assign({}, row) // copy obj
  266. this.SetVisible(3)
  267. this.SetData({layer:3, data: temp.WeChatUser.GambleMember})
  268. },
  269. handleLog(row) {
  270. const temp = Object.assign({}, row) // copy obj
  271. this.SetVisible(3)
  272. this.SetData({layer:3, data: temp.WeChatUser.GambleMember})
  273. },
  274. handleFilter() {
  275. this.listQuery.page = 1
  276. this.getList()
  277. },
  278. handleSizeChange(val) {
  279. this.listQuery.limit = val
  280. this.getList()
  281. },
  282. handleCurrentChange(val) {
  283. this.listQuery.page = val
  284. this.getList()
  285. },
  286. handleClick(tab, event) {
  287. this.dialogStatus = tab.name;
  288. },
  289. handleDialogClose() {
  290. this.activeName = 'deposit';
  291. this.dialogFormVisible = false;
  292. this.dialogUpdateFormVisible = false;
  293. },
  294. rewardChips() {
  295. this.$refs['rewardForm'].validate((valid) => {
  296. if (valid) {
  297. const tempData = Object.assign({}, this.temp)
  298. chipsReward(tempData).then(() => {
  299. for (const v of this.list) {
  300. if (v.id === this.temp.id) {
  301. const index = this.list.indexOf(v)
  302. this.list.splice(index, 1, this.temp)
  303. break
  304. }
  305. }
  306. this.dialogFormVisible = false
  307. this.$notify({
  308. title: '成功',
  309. message: '操作成功',
  310. type: 'success',
  311. duration: 2000
  312. })
  313. this.getList()
  314. })
  315. }
  316. })
  317. this.activeName = 'deposit';
  318. },
  319. handleAgentUpdate(row) {
  320. this.temp = Object.assign({}, row) // copy obj
  321. this.dialogUpdateFormVisible = true;
  322. this.$nextTick(() => {
  323. this.$refs['updateForm'].clearValidate()
  324. })
  325. },
  326. updateData() {
  327. this.$refs['updateForm'].validate((valid) => {
  328. if (valid) {
  329. const tempMember = Object.assign({}, this.temp.WeChatUser.GambleMember)
  330. const tempAgent = Object.assign({}, this.updateFormData.value)
  331. updateBelongAgent(tempMember, tempAgent).then(() => {
  332. for (const v of this.list) {
  333. if (v.id === this.temp.id) {
  334. const index = this.list.indexOf(v)
  335. this.list.splice(index, 1, this.temp)
  336. break
  337. }
  338. }
  339. this.dialogUpdateFormVisible = false
  340. this.$notify({
  341. title: '成功',
  342. message: '操作成功',
  343. type: 'success',
  344. duration: 2000
  345. })
  346. this.getList()
  347. })
  348. }
  349. })
  350. },
  351. getRemoteAgentList(query) {
  352. fetchAgentList(query).then(response => {
  353. if (!response.data.rows) return
  354. this.agentLIstOptions = response.data.rows.map(v => ({
  355. key: v.GambleMember.name,
  356. value: v.GambleMember
  357. }))
  358. })
  359. },
  360. handlereset() {
  361. this.$confirm('此操作將把此房間所有會員點數歸零, 是否繼續?', '提示', {
  362. confirmButtonText: '確定',
  363. cancelButtonText: '取消',
  364. type: 'warning'
  365. }).then(() => {
  366. resetWechatRoomMembersChips(this.data.secondLayer).then(response => {
  367. this.$message({
  368. type: 'success',
  369. message: '歸零成功!'
  370. });
  371. this.getList();
  372. }).catch((err)=>{
  373. console.log('22222')
  374. this.$message({
  375. type: 'error',
  376. message: '歸零失敗'
  377. });
  378. })
  379. }).catch(() => {
  380. this.$message({
  381. type: 'info',
  382. message: '已取消歸零'
  383. });
  384. });
  385. },
  386. haveAgent(GambleMember) {
  387. return GambleMember.GambleAgent?true:false;
  388. },
  389. noAgent(GambleMember) {
  390. return GambleMember.GambleAgent?false:true;
  391. // console.log('GambleAgent', GambleMember)
  392. },
  393. handleCreate() {
  394. this.dialogCreateFormVisible = true
  395. this.$nextTick(() => {
  396. this.$refs['createForm'].clearValidate()
  397. })
  398. },
  399. createData() {
  400. this.$refs['createForm'].validate((valid) => {
  401. if (valid) {
  402. const temp = Object.assign({}, this.tempCreate)
  403. createWechatMember(this.data.secondLayer, temp).then(() => {
  404. for (const v of this.list) {
  405. if (v.id === this.tempCreate.id) {
  406. const index = this.list.indexOf(v)
  407. this.list.splice(index, 1, this.tempCreate)
  408. break
  409. }
  410. }
  411. this.dialogCreateFormVisible = false
  412. this.$notify({
  413. title: '成功',
  414. message: '操作成功',
  415. type: 'success',
  416. duration: 2000
  417. })
  418. this.getList()
  419. })
  420. }
  421. })
  422. },
  423. },
  424. // watch: {
  425. // activeName: (val) => {
  426. // console.log('test', val);
  427. // }
  428. // }
  429. }
  430. </script>