template.php 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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/add-template'})">添加模板
  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. <el-table v-loading="loading" border :data="list" style="width: 100%;margin-bottom: 15px">
  151. <el-table-column prop="name" label="模板名称"></el-table-column>
  152. <el-table-column prop="ticket_nam" label="小票名称"></el-table-column>
  153. <el-table-column prop="status" label="状态">
  154. <template slot-scope="scope">
  155. <div v-if="scope.row.status==1">启用</div>
  156. <div v-if="scope.row.status==0">禁用</div>
  157. </template>
  158. </el-table-column>
  159. <el-table-column label="操作">
  160. <template slot-scope="scope">
  161. <el-button type="text" @click="handle('edit', scope.row.id)" size="small" circle>编辑</el-button>
  162. <el-button v-if="scope.row.status==1" type="text" @click="send('set_status',scope.row)" size="small" circle>禁用</el-button>
  163. <el-button v-if="scope.row.status==0" type="text" @click="send('set_status',scope.row)" size="small" circle>启用</el-button>
  164. <el-button type="text" @click="send('delete_template', scope.row.id)" size="small" circle>删除</el-button>
  165. </template>
  166. </el-table-column>
  167. </el-table>
  168. <div flex="box:last cross:center">
  169. <div></div>
  170. <div>
  171. <el-pagination v-if="pagination" :page-size="pagination.defaultPageSize"
  172. style="display: inline-block;float: right;" background @current-change="handle('pageChange', $event)"
  173. layout="prev, pager, next" :total="pagination.totalCount">
  174. </el-pagination>
  175. </div>
  176. </div>
  177. </div>
  178. </el-card>
  179. </div>
  180. <script>
  181. const app = new Vue({
  182. el: '#app',
  183. data: {
  184. page: 1,
  185. pageCount: 0,
  186. list: [],
  187. type: [],
  188. loading: false,
  189. pagination: null,
  190. },
  191. mounted() {
  192. this.send('get_list');
  193. },
  194. methods:{
  195. send(type, data=null){
  196. let self = this;
  197. switch(type){
  198. case 'get_list':
  199. let params = {
  200. r: 'printer/default/template',
  201. page: self.page
  202. };
  203. request({
  204. params: params,
  205. method: 'get',
  206. }).then(e=>{
  207. self.loading = false;
  208. if (e.data.code == 0){
  209. this.list=e.data.data.list;
  210. this.pagination = e.data.data.pagination;
  211. } else {
  212. self.$message.error(e.data.msg);
  213. }
  214. }).catch(e=>{
  215. self.loading = false;
  216. self.$message.error(e.data.msg);
  217. })
  218. break;
  219. case 'set_status':
  220. if(data.status==1){
  221. data.status=0;
  222. }else{
  223. data.status=1;
  224. }
  225. request({
  226. params: {
  227. r: 'printer/default/set-template-status'
  228. },
  229. method: 'post',
  230. data: {
  231. id: data.id,status:data.status
  232. }
  233. }).then(e => {
  234. if (e.data.code === 0) {
  235. this.$message.success(e.data.msg);
  236. } else {
  237. this.$message.error(e.data.msg);
  238. }
  239. }).catch(e=>{
  240. this.loading = false;
  241. this.$message.error(e.data.msg);
  242. })
  243. break;
  244. case 'delete_template':
  245. this.$confirm('删除这条模板信息, 是否继续?','提示',{
  246. confirmButtonText: '确定',
  247. cancelButtonText: '取消',
  248. type: 'warning'
  249. }).then(()=>{
  250. request({
  251. params: {
  252. r: 'printer/default/set-template-status'
  253. },
  254. method: 'post',
  255. data: {
  256. id: data,status:-1
  257. }
  258. }).then(e => {
  259. if (e.data.code === 0) {
  260. this.$message.success(e.data.msg);
  261. this.send('get_list');
  262. } else {
  263. this.$message.error(e.data.msg);
  264. }
  265. }).catch(e=>{
  266. this.loading = false;
  267. this.$message.error(e.data.msg);
  268. })
  269. }).catch(()=>{
  270. })
  271. break;
  272. }
  273. },
  274. handle(type, param1 = null) {
  275. switch (type) {
  276. case 'pageChange':
  277. this.page = param1;
  278. this.send('get_list');
  279. break;
  280. case 'edit':
  281. let info = {r: 'printer/default/edit-template',id:param1};
  282. navigateTo(info)
  283. }
  284. }
  285. },
  286. })
  287. </script>