Browse Source

添加酒店的修改、添加、删除资料

wangh 2 years ago
parent
commit
58b0f0452b

+ 5 - 0
src/components/Resource/CarData.vue

@@ -119,6 +119,11 @@ export default {
                             value: item.unitArea,
                         });
                     });
+                    if (that.tableDatas.slice((that.currentPage - 1) * that.pageSize, that.currentPage * that.pageSize).length == 0) {
+                        if (that.currentPage > 1) {
+                            that.currentPage = that.currentPage - 1;
+                        }
+                    }
                 }
                 that.loading = false
             }).catch(function (error) {

+ 8 - 2
src/components/Resource/HotelData.vue

@@ -7,7 +7,7 @@
                     <el-input @input="Inquireclick()" placeholder="城市/名称/联系人" v-model="input" clearable
                         style="width: 350px;">
                     </el-input>
-                    <router-link to="/home/ThreeCodeOperation">
+                    <router-link to="/home/HotelDataOperation">
                         <el-button type="primary" style="margin-left: 10px;">新增</el-button>
                     </router-link>
 
@@ -94,6 +94,11 @@ export default {
                     debugger
                     that.tableData = res.data.data;
                     that.tableDatas = that.tableData;
+                    if (that.tableDatas.slice((that.currentPage - 1) * that.pageSize, that.currentPage * that.pageSize).length == 0) {
+                        if (that.currentPage > 1) {
+                            that.currentPage = that.currentPage - 1;
+                        }
+                    }
                 }
                 that.loading = false
             }).catch(function (error) {
@@ -125,12 +130,13 @@ export default {
 
         upDate(index, row) {
             this.$router.push({
-                path: "/home/ThreeCodeOperation",
+                path: "/home/HotelDataOperation",
                 query: { id: row.id }
             })
         },
 
         del(index, row) {
+            debugger
             var url = "/api/Resource/DelHotelData"
             var that = this
             this.$axios({

+ 311 - 0
src/components/Resource/HotelDataOperation.vue

@@ -0,0 +1,311 @@
+<template>
+    <div v-loading="loading" element-loading-text="跳转中..." class="car_add">
+        <div class="communal-title">
+            <div>酒店资料数据</div>
+        </div>
+        <div>
+            <el-form :model="addData" :rules="rules" ref="addData" label-width="100px" class="demo-ruleForm">
+                <div style="display: flex;">
+                    <div style="width: 49%;">
+                        <el-form-item label="所在城市" prop="City">
+                            <el-input placeholder="所在城市" v-model="addData.City">
+                            </el-input>
+                        </el-form-item>
+                    </div>
+                    <div style="width: 49%;">
+                        <el-form-item label="酒店名称" prop="Name">
+                            <el-input placeholder="酒店名称" v-model="addData.Name">
+                            </el-input>
+                        </el-form-item>
+                    </div>
+                </div>
+                <div style="display: flex;">
+                    <div style="width: 49%;">
+                        <el-form-item label="酒店电话" prop="Tel">
+                            <el-input placeholder="酒店电话" v-model="addData.Tel">
+                            </el-input>
+                        </el-form-item>
+                    </div>
+
+                    <div style="width: 49%;">
+                        <el-form-item label="酒店传真" prop="Fax">
+                            <el-input placeholder="酒店传真" v-model="addData.Fax">
+                            </el-input>
+                        </el-form-item>
+                    </div>
+                </div>
+                <div style="display: flex;">
+                    <div style="width: 49%;">
+                        <el-form-item label="酒店星级" prop="Level">
+                            <el-select v-model="addData.Level" filterable placeholder="酒店星级" style="width: 100%;">
+                                <el-option key="★" label="★" value="★">
+                                </el-option>
+                                <el-option key="★★" label="★★" value="★★">
+                                </el-option>
+                                <el-option key="★★★" label="★★★" value="★★★">
+                                </el-option>
+                                <el-option key="★★★★" label="★★★★" value="★★★★">
+                                </el-option>
+                                <el-option key="★★★★★" label="★★★★★" value="★★★★★">
+                                </el-option>
+                            </el-select>
+                        </el-form-item>
+                    </div>
+                    <div style="width: 49%;">
+                        <el-form-item label="酒店地址" prop="Address">
+                            <el-input placeholder="酒店地址" v-model="addData.Address">
+                            </el-input>
+                        </el-form-item>
+                    </div>
+                </div>
+                <div style="display :flex;">
+                    <div style="width: 49%;">
+                        <el-form-item label="联系人" prop="Contact">
+                            <el-input placeholder="联系人" v-model="addData.Contact">
+                            </el-input>
+                        </el-form-item>
+                    </div>
+                    <div style="width: 49%;">
+                        <el-form-item label="联系人电话" prop="ContactPhone">
+                            <el-input placeholder="联系人电话" v-model="addData.ContactPhone">
+                            </el-input>
+                        </el-form-item>
+                    </div>
+
+                </div>
+                <div style="display: flex;">
+                    <div style="width: 98%;">
+                        <el-form-item label="备注" prop="Remark">
+                            <el-input type="textarea" :rows="3" placeholder="请输入内容" v-model="addData.Remark"></el-input>
+                        </el-form-item>
+                    </div>
+                </div>
+
+                <el-form-item>
+                    <div style="margin-left: 60%;">
+                        <el-button type="primary" @click="addBtn">保存</el-button>
+                        <router-link to='/home/HotelData'>
+                            <el-button>取消</el-button>
+                        </router-link>
+                    </div>
+                </el-form-item>
+            </el-form>
+        </div>
+    </div>
+</template>
+<script>
+export default {
+    data() {
+        return {
+            rules: {
+                Name: [
+                    { required: true, message: '请输入酒店名称', trigger: 'blur' },
+                ],
+                Tel: [
+                    { required: true, message: '请输入酒店电话', trigger: 'blur' },
+                ],
+                City: [
+                    { required: true, message: '请输入城市', trigger: 'blur' },
+                ],
+                Level: [
+                    { required: true, message: '请选择酒店星级', trigger: 'blur' },
+
+                ],
+                Contact: [
+                    { required: true, message: '请输入酒店联系人', trigger: 'blur' },
+                ],
+                ContactPhone: [
+                    { required: true, message: '请输入联系人的联系方式', trigger: 'blur' },
+                ],
+                Address: [
+                    { required: true, message: '请输入酒店地址', trigger: 'blur' },
+                ]
+            },
+            loading: false,
+            tableData: [],
+            currentPage: 1, // 当前页码
+            pageSize: 15,// 每页的数据条数
+            input: '',
+            token: '',
+            userId: 0,
+            addData: {
+                Statu: '',
+                Id: 0,
+                City: '',
+                Name: '',
+                Level: '',
+                Address: '',
+                Tel: '',
+                Fax: '',
+                Contact: '',
+                ContactPhone: '',
+                OtherInformation: '',
+                CreateUserId: '',
+                Remark: '',
+            },
+            HotelDataData: {}
+
+        }
+    },
+    methods: {
+        HotelData() {
+            this.loading = true
+            var url = "/api/Resource/QueryHotelData"
+            var that = this
+            this.$axios({
+                method: 'post',
+                url: url,
+                headers: {
+                    Authorization: 'Bearer ' + this.token
+                },
+                data: {
+                    portType: 1,
+                }
+            }).then(function (res) {
+                console.log(res)
+                debugger
+                if (res.data.code == 200) {
+                    that.tableData = res.data.data;
+                    that.addData.Id = that.$route.query.id;
+                    if (that.addData.Id == undefined || that.addData.Id == null) {
+                        //添加
+                        that.addData.Status = 1
+                    } else {
+                        //编辑
+                        that.upData();
+                    }
+                }
+                that.loading = false
+            }).catch(function (error) {
+                that.loading = false
+                that.$message.error("网络错误,请稍后重试");
+            });
+        },
+
+        addBtn() {
+            const that = this;
+            debugger
+            that.addData.CreateUserId = that.userId
+            that.$refs.addData.validate((valid) => {
+                if (valid) {
+                    debugger
+                    console.log(that.addData)
+                    var url = "/api/Resource/OperationHotelData"
+                    that.$axios({
+                        method: 'post',
+                        url: url,
+                        headers: {
+                            Authorization: 'Bearer ' + that.token
+                        },
+                        data: that.addData
+                    }).then(function (res) {
+                        console.log(res)
+                        debugger
+                        if (res.data.code == 200) {
+                            that.$message({
+                                message: res.data.msg,
+                                type: 'success'
+                            });
+                            that.loading = true;
+                            setTimeout(() => {
+                                that.$router.push('/home/HotelData')
+                            }, 3000);
+                        } else {
+                            that.$message.error(res.data.msg);
+                        }
+                    })
+                } else {
+                    this.$message.error('请完善信息在保存!');
+                    return false;
+                }
+            })
+        },
+        upData() {
+            debugger
+            for (var i = 0; i < this.tableData.length; i++) {
+                if (this.tableData[i].id == parseInt(this.addData.Id)) {
+                    debugger
+                    this.HotelDataData = this.tableData[i];
+                    break;
+                }
+            }
+            this.addData.Status = 2;
+            this.addData.Id = this.HotelDataData.id;
+            this.addData.City = this.HotelDataData.city;
+            this.addData.Name = this.HotelDataData.name;
+            this.addData.Level = this.HotelDataData.level;
+            this.addData.Address = this.HotelDataData.address;
+            this.addData.Tel = this.HotelDataData.tel;
+            this.addData.Fax = this.HotelDataData.fax;
+            this.addData.Contact = this.HotelDataData.contact;
+            this.addData.ContactPhone = this.HotelDataData.contactPhone;
+            this.addData.OtherInformation = this.HotelDataData.otherInformation;
+            this.addData.CreateUserId = this.HotelDataData.createUserId;
+            this.addData.Remark = this.HotelDataData.remark;
+        },
+    },
+
+    mounted() {
+        debugger
+        this.token = JSON.parse(localStorage.getItem('userinif')).token;
+        this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
+        this.HotelData();
+
+    }
+}
+</script>
+<style>
+.communal-list {
+    background-color: #fff;
+    padding: 10px;
+    box-shadow: 0 0 5px #0005;
+    border-radius: 10px;
+}
+
+.car_add .communal-title {
+    display: flex;
+    font-size: 17px;
+    font-weight: 600;
+    color: #555;
+    margin-bottom: 20px;
+    justify-content: space-between;
+    align-items: center;
+}
+
+.appraise-box {
+    display: flex;
+    flex-wrap: wrap;
+    justify-content: space-between;
+    margin: 50px 0;
+}
+
+.appraise-box>div {
+    width: 30%;
+}
+
+.communal-box {
+    display: flex;
+}
+
+.communal-box>button {
+    margin-left: 10px;
+    padding: 8px 20px;
+}
+
+.car_add {
+    background-color: #fff;
+    padding: 20px;
+    box-shadow: 0 0 5px #0005;
+    border-radius: 10px;
+}
+
+@media screen and (max-width: 1700px) {
+    .appraise-box>div {
+        width: 48%;
+    }
+
+    .appraise-box>div el-form-item__content {
+        width: 260px !important;
+    }
+}
+</style>

+ 5 - 0
src/components/Resource/LocalGuide.vue

@@ -101,6 +101,11 @@ export default {
                             value: item.unitArea,
                         });
                     });
+                    if (that.tableDatas.slice((that.currentPage - 1) * that.pageSize, that.currentPage * that.pageSize).length == 0) {
+                        if (that.currentPage > 1) {
+                            that.currentPage = that.currentPage - 1;
+                        }
+                    }
                 }
                 that.loading = false
             }).catch(function (error) {

+ 5 - 0
src/components/Resource/ThreeCode.vue

@@ -94,6 +94,11 @@ export default {
                     debugger
                     that.tableData = res.data.data;
                     that.tableDatas = that.tableData;
+                    if (that.tableDatas.slice((that.currentPage - 1) * that.pageSize, that.currentPage * that.pageSize).length == 0) {
+                        if (that.currentPage > 1) {
+                            that.currentPage = that.currentPage - 1;
+                        }
+                    }
                 }
                 that.loading = false
             }).catch(function (error) {

+ 5 - 0
src/components/system/Company.vue

@@ -257,6 +257,11 @@ export default {
                             label: item.companyName
                         });
                     });
+                    if (that.tableDatas.slice((that.currentPage - 1) * that.pageSize, that.currentPage * that.pageSize).length == 0) {
+                        if (that.currentPage > 1) {
+                            that.currentPage = that.currentPage - 1;
+                        }
+                    }
                 }
             }).catch(function (error) {
                 that.$message.error("网络错误,请稍后重试");

+ 5 - 0
src/components/system/Department.vue

@@ -207,6 +207,11 @@ export default {
                             label: item.depName
                         });
                     });
+                    if (that.tableDatas.slice((that.currentPage - 1) * that.pageSize, that.currentPage * that.pageSize).length == 0) {
+                        if (that.currentPage > 1) {
+                            that.currentPage = that.currentPage - 1;
+                        }
+                    }
                 }
             })
         },

+ 5 - 1
src/components/system/JobPost.vue

@@ -229,7 +229,11 @@ export default {
                     debugger
                     that.tableDatas = res.data.data;
                     that.tableData = that.tableDatas
-
+                    if (that.tableDatas.slice((that.currentPage - 1) * that.pageSize, that.currentPage * that.pageSize).length == 0) {
+                        if (that.currentPage > 1) {
+                            that.currentPage = that.currentPage - 1;
+                        }
+                    }
                 }
             })
         },

+ 5 - 0
src/components/system/User.vue

@@ -269,6 +269,11 @@ export default {
                 if (res.data.code == 200) {
                     that.tableDatas = res.data.data;
                     that.tableData = that.tableDatas
+                    if (that.tableDatas.slice((that.currentPage - 1) * that.pageSize, that.currentPage * that.pageSize).length == 0) {
+                        if (that.currentPage > 1) {
+                            that.currentPage = that.currentPage - 1;
+                        }
+                    }
                 }
             })
         },

+ 1 - 1
src/main.js

@@ -9,7 +9,7 @@ import './assets/icon/iconfont.css'
 import store from './store/index.js';
 
 import axios from 'axios';
-//axios.defaults.baseURL = 'http://localhost:5256/'
+axios.defaults.baseURL = 'http://localhost:5256/'
 import { Message } from "element-ui";
 Vue.prototype.$message = Message
 Vue.prototype.$axios = axios;

+ 6 - 0
src/router/index.js

@@ -33,6 +33,7 @@ import ThreeCode from '@/components/Resource/ThreeCode'
 import ThreeCodeOperation from '@/components/Resource/ThreeCodeOperation'
 import HotelData from '@/components/Resource/HotelData'
 import visaform from '@/components/OP/visaform'
+import HotelDataOperation from '@/components/Resource/HotelDataOperation'
 Vue.use(Router)
 
 export default new Router({
@@ -183,6 +184,11 @@ export default new Router({
           path: '/home/visaform',
           name: 'visaform',
           component: visaform
+        },
+        {
+          path: '/home/HotelDataOperation',
+          name: 'HotelDataOperation',
+          component: HotelDataOperation
         }
       ]
     },