list.blade.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. @extends('layouts.base')
  2. @section('content')
  3. @section('title', '打印机管理')
  4. <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods1.css')}}" />
  5. <div id="app">
  6. <div class="all">
  7. <div class="vue-head">
  8. <div class="vue-main-title">
  9. <div class="vue-main-title-left"></div>
  10. <div class="vue-main-title-content">小票打印机管理</div>
  11. <div class="vue-main-title-right"><el-button style="margin-top:10px;color: #FFFFFF;background-color: #29ba9c;" @click="addTemp"> <i class="el-icon-plus"></i> 添加打印机</el-button></div>
  12. </div>
  13. <el-table :data="tableData" style="width: 100%">
  14. <el-table-column prop="id" label="ID" align="center">
  15. </el-table-column>
  16. <el-table-column prop="title" label="打印机名称" align="center">
  17. </el-table-column>
  18. <el-table-column label="状态" align="center">
  19. <template slot-scope="scope">
  20. <el-switch
  21. v-model="scope.row.status"
  22. active-color="#29ba9c"
  23. inactive-color="#dcdfe6"
  24. :active-value="1"
  25. :inactive-value="0"
  26. @change="change(scope.row)"
  27. >
  28. </el-switch>
  29. </template>
  30. </el-table-column>
  31. <el-table-column label="操作" align="center">
  32. <template slot-scope="scope">
  33. <i class="el-icon-edit-outline" @click="edit(scope.row.id)" style="cursor:pointer;font-size:18px;cursor:pointer"></i>
  34. <i v-if="urls.del_url" class="el-icon-delete-solid" style="cursor:pointer;font-size:18px;cursor:pointer" @click="deleteTemp(scope.row.id)"></i>
  35. </template>
  36. </el-table-column>
  37. </el-table>
  38. </div>
  39. <div class="vue-page" >
  40. <el-row>
  41. <el-col align="right">
  42. <el-pagination layout="prev, pager, next,jumper" @current-change="search1" :total="total" :page-size="per_page" :current-page="current_page" background></el-pagination>
  43. </el-col>
  44. </el-row>
  45. </div>
  46. </div>
  47. </div>
  48. <script language='javascript'>
  49. //vue
  50. var app = new Vue({
  51. el: "#app",
  52. delimiters: ['[[', ']]'],
  53. data() {
  54. return {
  55. page: 1,
  56. tableData: [],
  57. current_page:1,
  58. total:1,
  59. per_page:15,
  60. urls:{},
  61. }
  62. },
  63. computed: {
  64. },
  65. mounted() {
  66. this.getPrinterList()
  67. },
  68. methods: {
  69. //开启或关闭打印机
  70. change(item){
  71. let url=this.urls.edit_url
  72. this.$http.post(url, {
  73. printer: {
  74. id:item.id,
  75. title: item.title,
  76. user: item.user,
  77. ukey: item.ukey,
  78. printer_sn: item.printer_sn,
  79. times: item.times,
  80. status : item.status,
  81. },
  82. }).then((res) => {
  83. if (res.data.result) {
  84. this.$message.success(res.data.msg)
  85. this.getPrinterList()
  86. } else {
  87. this.$message.error(res.data.msg);
  88. }
  89. })
  90. },
  91. //获取模板列表数据
  92. getPrinterList() {
  93. let url=window.location.href
  94. this.$http.post(url, {
  95. page: this.current_page,
  96. }).then(res => {
  97. if (res.data.result) {
  98. this.tableData = res.data.data.list.data
  99. this.total=res.data.data.list.total
  100. this.per_page=res.data.data.list.per_page
  101. this.current_page=res.data.data.list.current_page
  102. this.urls=res.data.data.urls
  103. console.log(this.urls)
  104. } else {
  105. this.$message.error(res.data.msg);
  106. }
  107. })
  108. },
  109. //编辑模板
  110. edit(id) {
  111. let url=this.urls.edit_url+"&id="+id
  112. window.location.href = url
  113. },
  114. addTemp() {
  115. let url=this.urls.add_url
  116. window.location.href = url
  117. },
  118. deleteTemp(id) {
  119. this.$confirm('此操作将永久删除打印机, 是否继续?', '提示', {
  120. confirmButtonText: '确定',
  121. cancelButtonText: '取消',
  122. type: 'warning'
  123. }).then(() => {
  124. let url=this.urls.del_url
  125. this.$http.post(url+"&id=" + id, {
  126. id
  127. }).then(res => {
  128. if (res.data.result) {
  129. this.$message.success(res.data.msg);
  130. this.getPrinterList()
  131. } else {
  132. this.$message.error(res.data.msg);
  133. }
  134. })
  135. }).catch(() => {
  136. this.$message({
  137. type: 'info',
  138. message: '已取消删除'
  139. });
  140. });
  141. },
  142. search1(page){
  143. this.current_page = page
  144. this.getPrinterList()
  145. },
  146. handleSearch(){
  147. this.getPrinterList()
  148. }
  149. },
  150. })
  151. </script>
  152. @endsection