Explorar o código

feat: debug config

wangyuan %!s(int64=2) %!d(string=hai) anos
pai
achega
3536e7a014

+ 1 - 1
ittpc/config/index.js

@@ -51,7 +51,7 @@ module.exports = {
     // Paths
     assetsRoot: path.resolve(__dirname, '../dist'),
     assetsSubDirectory: 'static',
-    assetsPublicPath: '/',
+    assetsPublicPath: './',
 
     /**
      * Source Maps

+ 15 - 1
ittpc/src/request/request.js

@@ -23,6 +23,12 @@ const getAppointmentListURL = BASE_API + '/get/appointment/list/v1'
 // 取消预约
 const cancelAppointmentURL = BASE_API + '/cancel/appointment/v1'
 
+// 地区列表
+const getRegionListURL = BASE_API + '/get/region/list/v1'
+
+// 配置地区可预约次数
+const setRegionConfigURL = BASE_API + '/set/region/config/v1'
+
 export const pwdLogin = (data) => {
   return request.post(pwdLoginURL, data)
 }
@@ -49,4 +55,12 @@ export const getAppointmentList = (data) => {
 
 export const cancelAppointment = (data) => {
   return request.post(cancelAppointmentURL, data)
-}
+}
+
+export const getRegionList = (data) => {
+  return request.post(getRegionListURL, data)
+}
+
+export const setRegionConfig = (data) => {
+  return request.post(setRegionConfigURL, data)
+}

+ 0 - 1
ittpc/src/router/index.js

@@ -12,7 +12,6 @@ import Config from '@/views/modules/config/config'
 Vue.use(Router)
 
 const router = new Router({
-  mode: 'history',
   routes: [
     {
       path: '/login',

+ 108 - 25
ittpc/src/views/modules/config/config.vue

@@ -1,81 +1,106 @@
 <template>
   <div class="config-page" v-loading="loading" element-loading-text="加载中" element-loading-spinner="el-icon-loading">
     <el-row>
-      <el-col :span="24" style="padding:0 20px;">
+      <el-col :span="4" style="padding:0 20px;">
         <h3>地区维护+预约次数配置</h3>
       </el-col>
+      <el-col :span="3" style="padding:0 20px;">
+        <el-button type="primary" size="mini" style="margin:18px 0" @click="handleRefresh">刷新</el-button>
+      </el-col>
     </el-row>
     <el-row>
       <el-col :span="24" style="padding:0 20px;">
         <el-table :data="tableData" border stripe style="width: 100%" size="small" max-height="700">
-          <el-table-column prop="province" label="省"></el-table-column>
-          <el-table-column prop="city" label="市"></el-table-column>
-          <el-table-column prop="county" label="区"></el-table-column>
-          <el-table-column prop="status" label="状态"></el-table-column>
-          <el-table-column prop="times" label="预约次数配置">
+          <el-table-column type="index" align="center" label="序号"></el-table-column>
+          <el-table-column prop="province" label="省" align="center"></el-table-column>
+          <el-table-column prop="city" label="市" align="center"></el-table-column>
+          <el-table-column prop="county" label="区" align="center"></el-table-column>
+          <el-table-column label="状态" align="center">
+            <!-- 状态 true 启用 false 禁用 -->
+            <template slot-scope="scope">
+              <span v-if="scope.row.status" style="color:#45A6B5">启用</span>
+              <span v-else style="color:#F56C6C">禁用</span>
+            </template>
+          </el-table-column>
+          <el-table-column prop="times" label="预约次数配置" align="center">
             <template slot-scope="scope">
               <el-button type="text" size="small" @click="handleEdit(scope.row)">编辑</el-button>
               <el-button type="text" size="small" @click="handleView(scope.row)">查看</el-button>
             </template>
           </el-table-column>
-          <el-table-column label="操作">
+          <!-- <el-table-column label="操作">
             <template slot-scope="scope">
               <el-button type="text" size="small" @click="handleOpen(scope.row)">开启</el-button>
               <el-button type="text" size="small" @click="handleClose(scope.row)">关闭</el-button>
             </template>
-          </el-table-column>
+          </el-table-column> -->
         </el-table>
       </el-col>
     </el-row>
-    <el-dialog :title=" isEdit ? '编辑预约次数' : '查看预约次数'" :visible.sync="dialogVisible" width="35%">
-      <h3>浙江省杭州市上城区:</h3>
+    <el-dialog :title=" isEdit ? '编辑预约次数' : '查看预约次数'" :visible.sync="dialogVisible" width="35%" @close="handleDialogClose" @open="handleDialogOpen">
+      <h3>{{editObj.province}}{{editObj.city}}{{editObj.county}}:</h3>
       <div class="8-12 dialog-item">
-        <span>08:00-12:00,预约</span>
+        <span>08:30-12:00,预约</span>
         <el-input-number :disabled="!isEdit" v-model="firstVal" size="small" class="num-input" controls-position="right" :min="1" :max="1000"></el-input-number>
         <span>次</span>
       </div>
       <div class="13-18 dialog-item">
-        <span>13:00-18:00,预约</span>
+        <span>12:30-17:00,预约</span>
         <el-input-number :disabled="!isEdit" v-model="secendVal" size="small" class="num-input" controls-position="right" :min="1" :max="1000"></el-input-number>
         <span>次</span>
       </div>
       <div class="19-21 dialog-item">
-        <span>19:00-21:00,预约</span>
+        <span>18:30-21:30,预约</span>
         <el-input-number :disabled="!isEdit" v-model="threeVal" size="small" class="num-input" controls-position="right" :min="1" :max="1000"></el-input-number>
         <span>次</span>
       </div>
       <span slot="footer" class="dialog-footer">
         <el-button @click="dialogVisible = false" size="small" style="width:100px;">取 消</el-button>
-        <el-button type="primary" @click="dialogVisible = false" size="small" style="width:100px;">确 定</el-button>
+        <el-button type="primary" :loading="configLoading" @click="handleSubmitConfig" size="small" style="width:100px;">确 定</el-button>
       </span>
     </el-dialog>
   </div>
 </template>
 
 <script>
+import { getRegionList, setRegionConfig } from '@/request/request'
 export default {
   name: 'config',
   data() {
     return {
       loading: false,
+      configLoading: false,
       dialogVisible: false,
-      tableData: [
-        {
-          province: '河南省',
-          city: '信阳市',
-          county: '固始县'
-        }
-      ],
+      tableData: [],
       isEdit: false,
       firstVal: '',
       secendVal: '',
-      threeVal: ''
+      threeVal: '',
+      editObj: {
+        province: '',
+        city: '',
+        county: '',
+        configId: ''
+      }
     };
   },
   mounted() {
-
+    this.getRegionListFn()
   },
   methods: {
+    handleRefresh () {
+      this.getRegionListFn()
+    },
+    getRegionListFn() {
+      this.loading = true
+      getRegionList({}).then(res => {
+        this.loading = false
+        this.tableData = res.data || []
+      }).catch(e => {
+        this.loading = false
+        console.log(e);
+      })
+    },
     handleOpen () {
       this.$confirm('确定开启吗?').then( _=> {
         console.log('ok')
@@ -86,13 +111,71 @@ export default {
         console.log('ok')
       }).catch(_ => {});
     },
-    handleView () {
+    handleDialogClose () {
+      this.firstVal = 1
+      this.secendVal = 1
+      this.threeVal = 1
+    },
+    handleDialogOpen () {
+      this.firstVal = this.findDurationTotal(1)
+      this.secendVal = this.findDurationTotal(2)
+      this.threeVal = this.findDurationTotal(3)
+    },
+    handleView (row) {
+      this.editObj = { ...row }
+      this.firstVal = this.findDurationTotal(1)
+      this.secendVal = this.findDurationTotal(2)
+      this.threeVal = this.findDurationTotal(3)
       this.dialogVisible = true
       this.isEdit = false
     },
-    handleEdit () {
+    handleEdit (row) {
+      this.editObj = { ...row }
       this.dialogVisible = true
       this.isEdit = true
+    },
+    handleSubmitConfig () {
+      if (this.isEdit) {
+        let configData = {
+          configId: this.editObj.configId,
+          configValList:[
+            {
+              duration:1,
+              total: this.firstVal
+            },
+            {
+              duration:2,
+              total: this.secendVal
+            },
+            {
+              duration:3,
+              total: this.threeVal
+            }
+          ]
+        }
+        this.configLoading = true
+        setRegionConfig(configData).then(res => {
+          this.configLoading = false
+          this.$message({
+            message: '配置成功',
+            type: 'success'
+          })
+          this.dialogVisible = false
+          this.getRegionListFn()
+        }).catch(e => {
+          console.log(e)
+          this.configLoading = false
+        })
+      } else {
+        this.dialogVisible = false
+      }
+    },
+    findDurationTotal (duration) {
+      let configValue = this.editObj.configValue
+      let item = configValue.find(item => {
+        return item.duration == duration
+      })
+      return item.total
     }
   },
 };