@@ -11,6 +11,20 @@ const router = new VueRouter({
               | 
            ||
| 11 | 11 | 
                routes  | 
            
| 12 | 12 | 
                })  | 
            
| 13 | 13 | 
                 | 
            
| 14 | 
                +router.beforeEach((to, from, next) => {
               | 
            |
| 15 | 
                + // 导航钩子,全局钩子  | 
            |
| 16 | 
                + var isLogin = sessionStorage.isLogin  | 
            |
| 17 | 
                +      if(!isLogin){
               | 
            |
| 18 | 
                +              if(to.name != 'Login'){
               | 
            |
| 19 | 
                +                    isLogin ? next() : next('/login');
               | 
            |
| 20 | 
                +              }else{
               | 
            |
| 21 | 
                + next();  | 
            |
| 22 | 
                + }  | 
            |
| 23 | 
                +      }else{
               | 
            |
| 24 | 
                + next();  | 
            |
| 25 | 
                + }  | 
            |
| 26 | 
                +})  | 
            |
| 27 | 
                +  | 
            |
| 14 | 28 | 
                 new Vue({
               | 
            
| 15 | 29 | 
                router  | 
            
| 16 | 30 | 
                 }).$mount('#app')
               | 
            
                @@ -29,6 +29,7 @@ export default [{
               | 
            ||
| 29 | 29 | 
                children: [  | 
            
| 30 | 30 | 
                     {
               | 
            
| 31 | 31 | 
                path: 'login',  | 
            
| 32 | 
                + name: 'Login',  | 
            |
| 32 | 33 | 
                component: Login  | 
            
| 33 | 34 | 
                },  | 
            
| 34 | 35 | 
                     {
               | 
            
                @@ -1,7 +1,7 @@  | 
            ||
| 1 | 1 | 
                <template>  | 
            
| 2 | 2 | 
                <div id="login">  | 
            
| 3 | 3 | 
                <div class="body">  | 
            
| 4 | 
                - <p>腾龙后台管理系统</p>  | 
            |
| 4 | 
                + <p>腾龙维修服务系统</p>  | 
            |
| 5 | 5 | 
                <el-form ref="form" :model="form" :rules="rules">  | 
            
| 6 | 6 | 
                <el-form-item label="" prop="account">  | 
            
| 7 | 7 | 
                <el-input placeholder="账户名" v-model="form.account"></el-input>  | 
            
                @@ -42,6 +42,7 @@ export default {
               | 
            ||
| 42 | 42 | 
                             if (response.data.status == 200) {
               | 
            
| 43 | 43 | 
                sessionStorage.isLogin = true  | 
            
| 44 | 44 | 
                sessionStorage.admin_type = response.data.data.admin_type  | 
            
| 45 | 
                + sessionStorage.admin_id = response.data.data.admin_id  | 
            |
| 45 | 46 | 
                               if (response.data.data.admin_type == 1) {
               | 
            
| 46 | 47 | 
                sessionStorage.qrurl = response.data.data.qrurl  | 
            
| 47 | 48 | 
                                 self.$router.replace({path: "/"})
               | 
            
                @@ -1,5 +1,6 @@  | 
            ||
| 1 | 1 | 
                <template lang="html">  | 
            
| 2 | 2 | 
                <div id="maintain">  | 
            
| 3 | 
                + <div class="maintain-content">  | 
            |
| 3 | 4 | 
                <div class="filter">  | 
            
| 4 | 5 | 
                <el-autocomplete  | 
            
| 5 | 6 | 
                popper-class="my-autocomplete"  | 
            
                @@ -19,41 +20,72 @@  | 
            ||
| 19 | 20 | 
                <el-button slot="append" icon="el-icon-search" @click="submit"></el-button>  | 
            
| 20 | 21 | 
                </el-input>  | 
            
| 21 | 22 | 
                </div>  | 
            
| 22 | 
                - <div class="table">  | 
            |
| 23 | 
                + <div class="table">  | 
            |
| 24 | 
                + <el-table  | 
            |
| 25 | 
                + v-loading="loading"  | 
            |
| 26 | 
                + :data="queryRes"  | 
            |
| 27 | 
                + stripe  | 
            |
| 28 | 
                + align="center"  | 
            |
| 29 | 
                + header-align="center"  | 
            |
| 30 | 
                + :empty-text="tableEmptyText">  | 
            |
| 31 | 
                + <el-table-column  | 
            |
| 32 | 
                + prop="model_name"  | 
            |
| 33 | 
                + label="型号"  | 
            |
| 34 | 
                + width="80">  | 
            |
| 35 | 
                + </el-table-column>  | 
            |
| 36 | 
                + <el-table-column  | 
            |
| 37 | 
                + prop="serialNo"  | 
            |
| 38 | 
                + label="序列号"  | 
            |
| 39 | 
                + width="80">  | 
            |
| 40 | 
                + </el-table-column>  | 
            |
| 41 | 
                + <el-table-column  | 
            |
| 42 | 
                + prop="coupon_info[0].coupon_value"  | 
            |
| 43 | 
                + label="维修券金额"  | 
            |
| 44 | 
                + width="100">  | 
            |
| 45 | 
                + </el-table-column>  | 
            |
| 46 | 
                + <el-table-column  | 
            |
| 47 | 
                + prop="coupon_info[0].coupon_expire_at"  | 
            |
| 48 | 
                + label="维修券到期日期"  | 
            |
| 49 | 
                + width="200">  | 
            |
| 50 | 
                + </el-table-column>  | 
            |
| 51 | 
                + <el-table-column  | 
            |
| 52 | 
                + label="状态"  | 
            |
| 53 | 
                + width="80">  | 
            |
| 54 | 
                + <template slot-scope="scope">  | 
            |
| 55 | 
                + <p v-if="!scope.row.submit_during_activity">无优惠券</p>  | 
            |
| 56 | 
                + <p v-else-if="scope.row.has_used">已核销</p>  | 
            |
| 57 | 
                + <p v-else-if="scope.row.coupon_info[0].coupon_has_expired">已过期</p>  | 
            |
| 58 | 
                + <el-button  | 
            |
| 59 | 
                + size="mini"  | 
            |
| 60 | 
                + @click="handleClick(scope.$index, scope.row)" v-else>核销</el-button>  | 
            |
| 61 | 
                + </template>  | 
            |
| 62 | 
                + </el-table-column>  | 
            |
| 63 | 
                + </el-table>  | 
            |
| 64 | 
                + </div>  | 
            |
| 65 | 
                + </div>  | 
            |
| 66 | 
                + <div class="maintain-record">  | 
            |
| 67 | 
                + <h3>核销记录</h3>  | 
            |
| 68 | 
                + <div class="line"></div>  | 
            |
| 23 | 69 | 
                <el-table  | 
            
| 24 | 
                - v-loading="loading"  | 
            |
| 25 | 
                - :data="queryRes"  | 
            |
| 26 | 
                - stripe  | 
            |
| 27 | 
                - style="width: 100%"  | 
            |
| 70 | 
                + :data="maintainRecord"  | 
            |
| 71 | 
                + :cell-style="maintainRecordCellStyle"  | 
            |
| 72 | 
                + :header-cell-style="maintainRecordHeaderCellStyle"  | 
            |
| 73 | 
                + header-align="center"  | 
            |
| 28 | 74 | 
                :empty-text="tableEmptyText">  | 
            
| 29 | 75 | 
                <el-table-column  | 
            
| 30 | 76 | 
                prop="model_name"  | 
            
| 31 | 77 | 
                label="型号"  | 
            
| 32 | 
                - width="200">  | 
            |
| 78 | 
                + width="80">  | 
            |
| 33 | 79 | 
                </el-table-column>  | 
            
| 34 | 80 | 
                <el-table-column  | 
            
| 35 | 81 | 
                prop="serialNo"  | 
            
| 36 | 82 | 
                label="序列号"  | 
            
| 37 | 
                - width="200">  | 
            |
| 83 | 
                + width="80">  | 
            |
| 38 | 84 | 
                </el-table-column>  | 
            
| 39 | 85 | 
                <el-table-column  | 
            
| 40 | 
                - prop="coupon_info[0].coupon_value"  | 
            |
| 41 | 
                - label="优惠券金额"  | 
            |
| 42 | 
                - width="200">  | 
            |
| 43 | 
                - </el-table-column>  | 
            |
| 44 | 
                - <el-table-column  | 
            |
| 45 | 
                - prop="coupon_info[0].coupon_expire_at"  | 
            |
| 46 | 
                - label="优惠券到期日期"  | 
            |
| 47 | 
                - width="200">  | 
            |
| 48 | 
                - </el-table-column>  | 
            |
| 49 | 
                - <el-table-column  | 
            |
| 50 | 
                - label="状态">  | 
            |
| 51 | 
                - <template slot-scope="scope">  | 
            |
| 52 | 
                - <p v-if="scope.row.has_used">已核销</p>  | 
            |
| 53 | 
                - <el-button  | 
            |
| 54 | 
                - size="mini"  | 
            |
| 55 | 
                - @click="handleClick(scope.$index, scope.row)" v-else>核销</el-button>  | 
            |
| 56 | 
                - </template>  | 
            |
| 86 | 
                + prop="used_at"  | 
            |
| 87 | 
                + label="核销日期"  | 
            |
| 88 | 
                + width="100">  | 
            |
| 57 | 89 | 
                </el-table-column>  | 
            
| 58 | 90 | 
                </el-table>  | 
            
| 59 | 91 | 
                </div>  | 
            
                @@ -70,7 +102,10 @@ export default {
               | 
            ||
| 70 | 102 | 
                       selectModel: {},
               | 
            
| 71 | 103 | 
                queryRes: [],  | 
            
| 72 | 104 | 
                loading: false,  | 
            
| 73 | 
                - tableEmptyText: "暂无数据"  | 
            |
| 105 | 
                + tableEmptyText: "暂无数据",  | 
            |
| 106 | 
                + maintainRecord: [],  | 
            |
| 107 | 
                +      maintainRecordCellStyle: {"font-size":"11px"},
               | 
            |
| 108 | 
                +      maintainRecordHeaderCellStyle: {"font-size": "14px"}
               | 
            |
| 74 | 109 | 
                }  | 
            
| 75 | 110 | 
                },  | 
            
| 76 | 111 | 
                   created() {
               | 
            
                @@ -79,6 +114,7 @@ export default {
               | 
            ||
| 79 | 114 | 
                     .then(function (response) {
               | 
            
| 80 | 115 | 
                self.models = response.data.data.models  | 
            
| 81 | 116 | 
                })  | 
            
| 117 | 
                + this.getMaintainRecord()  | 
            |
| 82 | 118 | 
                },  | 
            
| 83 | 119 | 
                   methods: {
               | 
            
| 84 | 120 | 
                     querySearch(queryString, cb) {
               | 
            
                @@ -102,7 +138,8 @@ export default {
               | 
            ||
| 102 | 138 | 
                this.loading = true  | 
            
| 103 | 139 | 
                var self = this  | 
            
| 104 | 140 | 
                       this.$axios.post('admin/querysn', {"model_id": this.selectModel.model_id,
               | 
            
| 105 | 
                - "sn": this.selectSerialNo})  | 
            |
| 141 | 
                + "sn": this.selectSerialNo,  | 
            |
| 142 | 
                + "admin_id": sessionStorage.admin_id})  | 
            |
| 106 | 143 | 
                       .then(function (response) {
               | 
            
| 107 | 144 | 
                         self.$nextTick(function (){
               | 
            
| 108 | 145 | 
                self.loading = false  | 
            
                @@ -111,31 +148,28 @@ export default {
               | 
            ||
| 111 | 148 | 
                self.clear()  | 
            
| 112 | 149 | 
                return  | 
            
| 113 | 150 | 
                }  | 
            
| 114 | 
                -          if (!data.submit_during_activity) {
               | 
            |
| 115 | 
                - self.clear()  | 
            |
| 116 | 
                - self.tableEmptyText = "无优惠券"  | 
            |
| 117 | 
                -          } else {
               | 
            |
| 118 | 
                -            if (data.has_used) {
               | 
            |
| 119 | 
                - self.clear()  | 
            |
| 120 | 
                - self.tableEmptyText = "优惠券已使用"  | 
            |
| 121 | 
                -            } else {
               | 
            |
| 122 | 
                - self.queryRes = [response.data.data]  | 
            |
| 123 | 
                - }  | 
            |
| 151 | 
                +          if (data.coupon_info[0].coupon_value == 0) {
               | 
            |
| 152 | 
                +            data.coupon_info = [{"coupon_expire_at": "-","coupon_value": "-"}]
               | 
            |
| 124 | 153 | 
                }  | 
            
| 125 | 
                - })  | 
            |
| 154 | 
                + self.queryRes = [response.data.data]  | 
            |
| 126 | 155 | 
                 | 
            
| 156 | 
                + })  | 
            |
| 127 | 157 | 
                })  | 
            
| 128 | 158 | 
                },  | 
            
| 129 | 159 | 
                 | 
            
| 130 | 160 | 
                     handleClick(index, row) {
               | 
            
| 131 | 161 | 
                var self = this  | 
            
| 132 | 162 | 
                       this.$axios.post('admin/usecoupon', {"model_id": this.selectModel.model_id,
               | 
            
| 133 | 
                - "sn": this.selectSerialNo})  | 
            |
| 163 | 
                + "sn": this.selectSerialNo,  | 
            |
| 164 | 
                + "admin_id": sessionStorage.admin_id})  | 
            |
| 134 | 165 | 
                       .then(function (response) {
               | 
            
| 135 | 166 | 
                         self.$nextTick(function (){
               | 
            
| 136 | 167 | 
                self.clear()  | 
            
| 137 | 168 | 
                self.tableEmptyText = "暂无数据"  | 
            
| 138 | 
                -          alert("已核销")
               | 
            |
| 169 | 
                + self.getMaintainRecord()  | 
            |
| 170 | 
                +          if (response.status == 200 && response.data.status == 200) {
               | 
            |
| 171 | 
                +            alert("已核销")
               | 
            |
| 172 | 
                + }  | 
            |
| 139 | 173 | 
                })  | 
            
| 140 | 174 | 
                })  | 
            
| 141 | 175 | 
                },  | 
            
                @@ -145,6 +179,20 @@ export default {
               | 
            ||
| 145 | 179 | 
                       this.selectModel = {}
               | 
            
| 146 | 180 | 
                this.selectSerialNo = ""  | 
            
| 147 | 181 | 
                this.selectModelName = ""  | 
            
| 182 | 
                + },  | 
            |
| 183 | 
                +  | 
            |
| 184 | 
                +    getMaintainRecord() {
               | 
            |
| 185 | 
                + var self = this  | 
            |
| 186 | 
                +      this.$axios.post('admin/queryusedsn', {"admin_id": sessionStorage.admin_id})
               | 
            |
| 187 | 
                +      .then(function (response) {
               | 
            |
| 188 | 
                + let logs = response.data.data.logs  | 
            |
| 189 | 
                +        for (var log of logs) {
               | 
            |
| 190 | 
                + let date = new Date(log.used_at)  | 
            |
| 191 | 
                + console.log(date);  | 
            |
| 192 | 
                + log.used_at = date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes()  | 
            |
| 193 | 
                + }  | 
            |
| 194 | 
                + self.maintainRecord = response.data.data.logs  | 
            |
| 195 | 
                + })  | 
            |
| 148 | 196 | 
                }  | 
            
| 149 | 197 | 
                }  | 
            
| 150 | 198 | 
                }  | 
            
                @@ -153,20 +201,43 @@ export default {
               | 
            ||
| 153 | 201 | 
                <style lang="scss">  | 
            
| 154 | 202 | 
                 #maintain {
               | 
            
| 155 | 203 | 
                display: flex;  | 
            
| 156 | 
                - flex-direction: column;  | 
            |
| 157 | 204 | 
                justify-content: center;  | 
            
| 158 | 
                - align-items: center;  | 
            |
| 159 | 
                - width: 100%;  | 
            |
| 160 | 
                - height: 200px;  | 
            |
| 161 | 
                -  .filter {
               | 
            |
| 205 | 
                +  .maintain-content {
               | 
            |
| 162 | 206 | 
                display: flex;  | 
            
| 163 | 
                - flex-direction: row;  | 
            |
| 207 | 
                + flex-direction: column;  | 
            |
| 208 | 
                + justify-content: center;  | 
            |
| 209 | 
                + align-items: center;  | 
            |
| 210 | 
                + width: 700px;  | 
            |
| 211 | 
                + height: 200px;  | 
            |
| 212 | 
                +    .filter {
               | 
            |
| 213 | 
                + display: flex;  | 
            |
| 214 | 
                + flex-direction: row;  | 
            |
| 215 | 
                + }  | 
            |
| 216 | 
                +    .table {
               | 
            |
| 217 | 
                + margin-top: 50px;  | 
            |
| 218 | 
                + width: 80%;  | 
            |
| 219 | 
                + max-width: 900px;  | 
            |
| 220 | 
                + height: 100px;  | 
            |
| 221 | 
                + }  | 
            |
| 164 | 222 | 
                }  | 
            
| 165 | 
                -  .table {
               | 
            |
| 166 | 
                - margin-top: 50px;  | 
            |
| 167 | 
                - width: 80%;  | 
            |
| 168 | 
                - max-width: 900px;  | 
            |
| 169 | 
                - height: 100px;  | 
            |
| 223 | 
                +  .maintain-record {
               | 
            |
| 224 | 
                + display: flex;  | 
            |
| 225 | 
                + flex-direction: column;  | 
            |
| 226 | 
                + justify-content: center;  | 
            |
| 227 | 
                + width: 280px;  | 
            |
| 228 | 
                + background: #fff;  | 
            |
| 229 | 
                +    h3 {
               | 
            |
| 230 | 
                + margin-left: 5px;  | 
            |
| 231 | 
                + }  | 
            |
| 232 | 
                +    .line {
               | 
            |
| 233 | 
                + width: 100%;  | 
            |
| 234 | 
                + height: 1px;  | 
            |
| 235 | 
                + background: #E5EAF2;  | 
            |
| 236 | 
                + }  | 
            |
| 237 | 
                +    .el-table {
               | 
            |
| 238 | 
                + width: 260px;  | 
            |
| 239 | 
                + margin-left: 10px;  | 
            |
| 240 | 
                + }  | 
            |
| 170 | 241 | 
                }  | 
            
| 171 | 242 | 
                }  | 
            
| 172 | 243 | 
                </style>  |