| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- @extends('layouts.base')
- @section('content')
- @section('title', '打印机管理')
- <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods1.css')}}" />
- <div id="app">
- <div class="all">
- <div class="vue-head">
- <div class="vue-main-title">
- <div class="vue-main-title-left"></div>
- <div class="vue-main-title-content">小票打印机管理</div>
- <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>
- </div>
- <el-table :data="tableData" style="width: 100%">
- <el-table-column prop="id" label="ID" align="center">
- </el-table-column>
- <el-table-column prop="title" label="打印机名称" align="center">
- </el-table-column>
- <el-table-column label="状态" align="center">
- <template slot-scope="scope">
- <el-switch
- v-model="scope.row.status"
- active-color="#29ba9c"
- inactive-color="#dcdfe6"
- :active-value="1"
- :inactive-value="0"
- @change="change(scope.row)"
- >
- </el-switch>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center">
- <template slot-scope="scope">
- <i class="el-icon-edit-outline" @click="edit(scope.row.id)" style="cursor:pointer;font-size:18px;cursor:pointer"></i>
- <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>
- </template>
- </el-table-column>
- </el-table>
-
- </div>
- <div class="vue-page" >
- <el-row>
- <el-col align="right">
- <el-pagination layout="prev, pager, next,jumper" @current-change="search1" :total="total" :page-size="per_page" :current-page="current_page" background></el-pagination>
- </el-col>
- </el-row>
- </div>
- </div>
- </div>
- <script language='javascript'>
- //vue
- var app = new Vue({
- el: "#app",
- delimiters: ['[[', ']]'],
- data() {
- return {
- page: 1,
- tableData: [],
- current_page:1,
- total:1,
- per_page:15,
- urls:{},
- }
- },
- computed: {
- },
- mounted() {
- this.getPrinterList()
- },
- methods: {
- //开启或关闭打印机
- change(item){
- let url=this.urls.edit_url
- this.$http.post(url, {
- printer: {
- id:item.id,
- title: item.title,
- user: item.user,
- ukey: item.ukey,
- printer_sn: item.printer_sn,
- times: item.times,
- status : item.status,
- },
- }).then((res) => {
- if (res.data.result) {
- this.$message.success(res.data.msg)
- this.getPrinterList()
- } else {
- this.$message.error(res.data.msg);
- }
- })
- },
- //获取模板列表数据
- getPrinterList() {
- let url=window.location.href
- this.$http.post(url, {
- page: this.current_page,
- }).then(res => {
- if (res.data.result) {
- this.tableData = res.data.data.list.data
- this.total=res.data.data.list.total
- this.per_page=res.data.data.list.per_page
- this.current_page=res.data.data.list.current_page
- this.urls=res.data.data.urls
- console.log(this.urls)
- } else {
- this.$message.error(res.data.msg);
- }
- })
- },
- //编辑模板
- edit(id) {
- let url=this.urls.edit_url+"&id="+id
- window.location.href = url
- },
- addTemp() {
- let url=this.urls.add_url
- window.location.href = url
- },
- deleteTemp(id) {
- this.$confirm('此操作将永久删除打印机, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- let url=this.urls.del_url
- this.$http.post(url+"&id=" + id, {
- id
- }).then(res => {
- if (res.data.result) {
- this.$message.success(res.data.msg);
- this.getPrinterList()
- } else {
- this.$message.error(res.data.msg);
- }
- })
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '已取消删除'
- });
- });
- },
- search1(page){
- this.current_page = page
- this.getPrinterList()
- },
- handleSearch(){
- this.getPrinterList()
- }
- },
- })
- </script>
- @endsection
|