index.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <style>
  2. .form-body {
  3. padding: 20px 0;
  4. background-color: #fff;
  5. margin-bottom: 20px;
  6. }
  7. .form-button {
  8. margin: 0;
  9. }
  10. .form-button .el-form-item__content {
  11. margin-left: 0!important;
  12. }
  13. .button-item {
  14. padding: 9px 25px;
  15. }
  16. .app-share {
  17. padding-top: 12px;
  18. border-top: 1px solid #e2e2e2;
  19. margin-top: -20px;
  20. }
  21. .app-share .app-share-bg {
  22. position: relative;
  23. width: 310px;
  24. height: 360px;
  25. background-repeat: no-repeat;
  26. background-size: contain;
  27. background-position: center
  28. }
  29. .app-share .app-share-bg .title {
  30. width: 160px;
  31. height: 29px;
  32. line-height: 1;
  33. word-break: break-all;
  34. text-overflow: ellipsis;
  35. display: -webkit-box;
  36. -webkit-box-orient: vertical;
  37. -webkit-line-clamp: 2;
  38. overflow: hidden;
  39. }
  40. .app-share .app-share-bg .pic-image {
  41. background-repeat: no-repeat;
  42. background-position: 0 0;
  43. background-size: cover;
  44. width: 160px;
  45. height: 130px;
  46. }
  47. .goods-list {
  48. flex-wrap: wrap;
  49. margin-top: 10px;
  50. /* cursor: move; */
  51. }
  52. .goods-item,
  53. .goods-add {
  54. width: 50px;
  55. height: 50px;
  56. position: relative;
  57. border: 1px solid #e2e2e2;
  58. margin-right: 15px;
  59. margin-bottom: 15px;
  60. }
  61. .goods-add .el-button {
  62. width: 100%;
  63. height: 100%;
  64. border: none;
  65. border-radius: 0;
  66. padding: 0;
  67. }
  68. .goods-delete {
  69. position: absolute;
  70. left: calc(100% - 13px);
  71. top: -13px;
  72. width: 25px;
  73. height: 25px;
  74. line-height: 25px;
  75. padding: 0 0;
  76. visibility: hidden;
  77. z-index: 1;
  78. }
  79. .goods-delete .el-icon-close {
  80. position: absolute;
  81. top: 6px;
  82. left: 6px;
  83. }
  84. .goods-item:hover .goods-delete {
  85. visibility: visible;
  86. }
  87. .goods-pic {
  88. background-size: cover;
  89. background-position: center;
  90. width: 100%;
  91. height: 100%;
  92. background-color: #f6f6f6;
  93. background-repeat: no-repeat;
  94. }
  95. .input-item {
  96. display: inline-block;
  97. width: 250px;
  98. margin: 0;
  99. }
  100. .input-item .el-input__inner {
  101. border-right: 0;
  102. }
  103. .input-item .el-input__inner:hover {
  104. border: 1px solid #dcdfe6;
  105. border-right: 0;
  106. outline: 0;
  107. }
  108. .input-item .el-input__inner:focus {
  109. border: 1px solid #dcdfe6;
  110. border-right: 0;
  111. outline: 0;
  112. }
  113. .input-item .el-input-group__append {
  114. background-color: #fff;
  115. border-left: 0;
  116. width: 10%;
  117. padding: 0;
  118. }
  119. .input-item .el-input-group__append .el-button {
  120. padding: 0;
  121. }
  122. .input-item .el-input-group__append .el-button {
  123. margin: 0;
  124. }
  125. .customize-share-title {
  126. position: relative;
  127. margin-top: 10px;
  128. }
  129. .customize-share-title .del-btn {
  130. position: absolute;
  131. top: -10px;
  132. left: 70px;
  133. }
  134. </style>
  135. <div id="app">
  136. <el-card shadow="never" style="border:0" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  137. <div slot="header">
  138. <span>打印机列表</span>
  139. </div>
  140. <div >
  141. <el-button style="float: left; margin: 20px" type="primary" size="small"
  142. @click="$navigate({r: 'printer/default/edit-printer'})">添加打印机
  143. </el-button>
  144. </div>
  145. <div class="table-body">
  146. <div id="qrcode-info" style="position: fixed;top: 10000000000px;">
  147. <!-- 二维码 -->
  148. <div id="qrcode" style="width:100px; height:100px; margin-top:15px;"></div>
  149. </div>
  150. <!-- <div class="input-item">
  151. <el-input @keyup.enter.native="handle('search')" size="small" placeholder="请输入用户ID/昵称/手机号" v-model="keyword"
  152. clearable @clear="handle('search')">
  153. <el-button slot="append" icon="el-icon-search" @click="handle('search')"></el-button>
  154. </el-input>
  155. </div> -->
  156. <el-table v-loading="loading" border :data="list" style="width: 100%;margin-bottom: 15px">
  157. <el-table-column prop="name" label="打印机名称"></el-table-column>
  158. <el-table-column prop="type" label="打印设置" min-width="300">
  159. <template slot-scope="scope">
  160. <el-tag style='margin-left:5px' v-for="key in scope.row.type">{{type[key]}}</el-tag>
  161. </template>
  162. </el-table-column>
  163. <el-table-column prop="status" label="状态">
  164. <template slot-scope="scope">
  165. <div v-if="scope.row.status==1">启用</div>
  166. <div v-if="scope.row.status==0">禁用</div>
  167. </template>
  168. </el-table-column>
  169. <el-table-column label="操作">
  170. <template slot-scope="scope">
  171. <el-button type="text" @click="handle('edit', scope.row.id)" size="small" circle>编辑</el-button>
  172. <el-button v-if="scope.row.status==1" type="text" @click="send('set_status',scope.row)" size="small" circle>禁用</el-button>
  173. <el-button v-if="scope.row.status==0" type="text" @click="send('set_status',scope.row)" size="small" circle>启用</el-button>
  174. <el-button type="text" @click="send('delete_printer', scope.row.id)" size="small" circle>删除</el-button>
  175. </template>
  176. </el-table-column>
  177. </el-table>
  178. <div flex="box:last cross:center">
  179. <div></div>
  180. <div>
  181. <el-pagination v-if="pagination" :page-size="pagination.defaultPageSize"
  182. style="display: inline-block;float: right;" background @current-change="handle('pageChange', $event)"
  183. layout="prev, pager, next" :total="pagination.totalCount">
  184. </el-pagination>
  185. </div>
  186. </div>
  187. </div>
  188. </el-card>
  189. </div>
  190. <script>
  191. const app = new Vue({
  192. el: '#app',
  193. data: {
  194. page: 1,
  195. pageCount: 0,
  196. list: [],
  197. type: [],
  198. loading: false,
  199. pagination: null,
  200. },
  201. mounted() {
  202. this.send('get_list');
  203. },
  204. methods:{
  205. send(type, data=null){
  206. let self = this;
  207. switch(type){
  208. case 'get_list':
  209. let params = {
  210. r: 'printer/default/index',
  211. page: self.page
  212. };
  213. request({
  214. params: params,
  215. method: 'get',
  216. }).then(e=>{
  217. self.loading = false;
  218. if (e.data.code == 0){
  219. self.list = e.data.data.list.list;
  220. self.type = e.data.data.type;
  221. self.pagination = e.data.data.list.pagination;
  222. } else {
  223. self.$message.error(e.data.msg);
  224. }
  225. }).catch(e=>{
  226. self.loading = false;
  227. self.$message.error(e.data.msg);
  228. })
  229. break;
  230. case 'set_status':
  231. if(data.status==1){
  232. data.status=0;
  233. }else{
  234. data.status=1;
  235. }
  236. request({
  237. params: {
  238. r: 'printer/default/edit'
  239. },
  240. method: 'post',
  241. data: {
  242. id: data.id,name:data.name,status:data.status,type:data.type,set_type:1
  243. }
  244. }).then(e => {
  245. if (e.data.code === 0) {
  246. this.$message.success(e.data.msg);
  247. } else {
  248. this.$message.error(e.data.msg);
  249. }
  250. }).catch(e=>{
  251. this.loading = false;
  252. this.$message.error(e.data.msg);
  253. })
  254. break;
  255. case 'delete_printer':
  256. this.$confirm('删除这条打印机信息, 是否继续?','提示',{
  257. confirmButtonText: '确定',
  258. cancelButtonText: '取消',
  259. type: 'warning'
  260. }).then(()=>{
  261. request({
  262. params: {
  263. r: 'printer/default/delete-printer'
  264. },
  265. method: 'post',
  266. data: {
  267. id: data,status:-1,set_type:1
  268. }
  269. }).then(e => {
  270. if (e.data.code === 0) {
  271. this.$message.success(e.data.msg);
  272. this.send('get_list');
  273. } else {
  274. this.$message.error(e.data.msg);
  275. }
  276. }).catch(e=>{
  277. this.loading = false;
  278. this.$message.error(e.data.msg);
  279. })
  280. }).catch(()=>{
  281. })
  282. break;
  283. }
  284. },
  285. handle(type, param1 = null) {
  286. switch (type) {
  287. case 'pageChange':
  288. this.page = param1;
  289. this.send('get_list');
  290. break;
  291. case 'edit':
  292. let info = {r: 'printer/default/edit-printer',id:param1};
  293. navigateTo(info)
  294. }
  295. }
  296. },
  297. })
  298. </script>