HotelDataOperation.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <div v-loading="loading" element-loading-text="跳转中..." class="car_add">
  3. <div class="communal-title">
  4. <div>酒店资料数据</div>
  5. </div>
  6. <div>
  7. <el-form :model="addData" :rules="rules" ref="addData" label-width="100px" class="demo-ruleForm">
  8. <div style="display: flex;">
  9. <div style="width: 49%;">
  10. <el-form-item label="所在城市" prop="City">
  11. <el-input placeholder="所在城市" v-model="addData.City">
  12. </el-input>
  13. </el-form-item>
  14. </div>
  15. <div style="width: 49%;">
  16. <el-form-item label="酒店名称" prop="Name">
  17. <el-input placeholder="酒店名称" v-model="addData.Name">
  18. </el-input>
  19. </el-form-item>
  20. </div>
  21. </div>
  22. <div style="display: flex;">
  23. <div style="width: 49%;">
  24. <el-form-item label="酒店电话" prop="Tel">
  25. <el-input placeholder="酒店电话" v-model="addData.Tel">
  26. </el-input>
  27. </el-form-item>
  28. </div>
  29. <div style="width: 49%;">
  30. <el-form-item label="酒店传真" prop="Fax">
  31. <el-input placeholder="酒店传真" v-model="addData.Fax">
  32. </el-input>
  33. </el-form-item>
  34. </div>
  35. </div>
  36. <div style="display: flex;">
  37. <div style="width: 49%;">
  38. <el-form-item label="酒店星级" prop="Level">
  39. <el-select v-model="addData.Level" filterable placeholder="酒店星级" style="width: 100%;">
  40. <el-option key="★" label="★" value="★">
  41. </el-option>
  42. <el-option key="★★" label="★★" value="★★">
  43. </el-option>
  44. <el-option key="★★★" label="★★★" value="★★★">
  45. </el-option>
  46. <el-option key="★★★★" label="★★★★" value="★★★★">
  47. </el-option>
  48. <el-option key="★★★★★" label="★★★★★" value="★★★★★">
  49. </el-option>
  50. </el-select>
  51. </el-form-item>
  52. </div>
  53. <div style="width: 49%;">
  54. <el-form-item label="酒店地址" prop="Address">
  55. <el-input placeholder="酒店地址" v-model="addData.Address">
  56. </el-input>
  57. </el-form-item>
  58. </div>
  59. </div>
  60. <div style="display :flex;">
  61. <div style="width: 49%;">
  62. <el-form-item label="联系人" prop="Contact">
  63. <el-input placeholder="联系人" v-model="addData.Contact">
  64. </el-input>
  65. </el-form-item>
  66. </div>
  67. <div style="width: 49%;">
  68. <el-form-item label="联系人电话" prop="ContactPhone">
  69. <el-input placeholder="联系人电话" v-model="addData.ContactPhone">
  70. </el-input>
  71. </el-form-item>
  72. </div>
  73. </div>
  74. <div style="display: flex;">
  75. <div style="width: 98%;">
  76. <el-form-item label="备注" prop="Remark">
  77. <el-input type="textarea" :rows="3" placeholder="请输入内容" v-model="addData.Remark"></el-input>
  78. </el-form-item>
  79. </div>
  80. </div>
  81. <el-form-item>
  82. <div style="margin-left: 60%;">
  83. <el-button type="primary" @click="addBtn">保存</el-button>
  84. <router-link to='/home/HotelData'>
  85. <el-button>取消</el-button>
  86. </router-link>
  87. </div>
  88. </el-form-item>
  89. </el-form>
  90. </div>
  91. </div>
  92. </template>
  93. <script>
  94. export default {
  95. data() {
  96. return {
  97. rules: {
  98. Name: [
  99. { required: true, message: '请输入酒店名称', trigger: 'blur' },
  100. ],
  101. Tel: [
  102. { required: true, message: '请输入酒店电话', trigger: 'blur' },
  103. ],
  104. City: [
  105. { required: true, message: '请输入城市', trigger: 'blur' },
  106. ],
  107. Level: [
  108. { required: true, message: '请选择酒店星级', trigger: 'blur' },
  109. ],
  110. Contact: [
  111. { required: true, message: '请输入酒店联系人', trigger: 'blur' },
  112. ],
  113. ContactPhone: [
  114. { required: true, message: '请输入联系人的联系方式', trigger: 'blur' },
  115. ],
  116. Address: [
  117. { required: true, message: '请输入酒店地址', trigger: 'blur' },
  118. ]
  119. },
  120. loading: false,
  121. tableData: [],
  122. currentPage: 1, // 当前页码
  123. pageSize: 15,// 每页的数据条数
  124. input: '',
  125. token: '',
  126. userId: 0,
  127. addData: {
  128. Statu: '',
  129. Id: 0,
  130. City: '',
  131. Name: '',
  132. Level: '',
  133. Address: '',
  134. Tel: '',
  135. Fax: '',
  136. Contact: '',
  137. ContactPhone: '',
  138. OtherInformation: '',
  139. CreateUserId: '',
  140. Remark: '',
  141. },
  142. HotelDataData: {}
  143. }
  144. },
  145. methods: {
  146. HotelData() {
  147. this.loading = true
  148. var url = "/api/Resource/QueryHotelData"
  149. var that = this
  150. this.$axios({
  151. method: 'post',
  152. url: url,
  153. headers: {
  154. Authorization: 'Bearer ' + this.token
  155. },
  156. data: {
  157. portType: 1,
  158. PageIndex: 0,
  159. PageSize: 0,
  160. City: '',
  161. Name: '',
  162. Contact: '',
  163. ContactPhone: '',
  164. }
  165. }).then(function (res) {
  166. console.log(res)
  167. if (res.data.code == 200) {
  168. that.tableData = res.data.data;
  169. that.addData.Id = that.$route.query.id;
  170. if (that.addData.Id == undefined || that.addData.Id == null) {
  171. //添加
  172. that.addData.Status = 1
  173. } else {
  174. //编辑
  175. that.upData();
  176. }
  177. }
  178. that.loading = false
  179. }).catch(function (error) {
  180. that.loading = false
  181. that.$message.error("网络错误,请稍后重试");
  182. });
  183. },
  184. addBtn() {
  185. const that = this;
  186. that.addData.CreateUserId = that.userId
  187. that.$refs.addData.validate((valid) => {
  188. if (valid) {
  189. console.log(that.addData)
  190. var url = "/api/Resource/OperationHotelData"
  191. that.$axios({
  192. method: 'post',
  193. url: url,
  194. headers: {
  195. Authorization: 'Bearer ' + that.token
  196. },
  197. data: that.addData
  198. }).then(function (res) {
  199. console.log(res)
  200. if (res.data.code == 200) {
  201. that.$message({
  202. message: res.data.msg,
  203. type: 'success'
  204. });
  205. that.loading = true;
  206. setTimeout(() => {
  207. that.$router.push('/home/HotelData')
  208. }, 3000);
  209. } else {
  210. that.$message.error(res.data.msg);
  211. }
  212. })
  213. } else {
  214. this.$message.error('请完善信息在保存!');
  215. return false;
  216. }
  217. })
  218. },
  219. upData() {
  220. for (var i = 0; i < this.tableData.length; i++) {
  221. if (this.tableData[i].id == parseInt(this.addData.Id)) {
  222. this.HotelDataData = this.tableData[i];
  223. break;
  224. }
  225. }
  226. this.addData.Status = 2;
  227. this.addData.Id = this.HotelDataData.id;
  228. this.addData.City = this.HotelDataData.city;
  229. this.addData.Name = this.HotelDataData.name;
  230. this.addData.Level = this.HotelDataData.level;
  231. this.addData.Address = this.HotelDataData.address;
  232. this.addData.Tel = this.HotelDataData.tel;
  233. this.addData.Fax = this.HotelDataData.fax;
  234. this.addData.Contact = this.HotelDataData.contact;
  235. this.addData.ContactPhone = this.HotelDataData.contactPhone;
  236. this.addData.OtherInformation = this.HotelDataData.otherInformation;
  237. this.addData.CreateUserId = this.HotelDataData.createUserId;
  238. this.addData.Remark = this.HotelDataData.remark;
  239. },
  240. },
  241. mounted() {
  242. this.token = JSON.parse(localStorage.getItem('userinif')).token;
  243. this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
  244. this.HotelData();
  245. }
  246. }
  247. </script>
  248. <style>
  249. .communal-list {
  250. background-color: #fff;
  251. padding: 10px;
  252. box-shadow: 0 0 5px #0005;
  253. border-radius: 10px;
  254. }
  255. .car_add .communal-title {
  256. display: flex;
  257. font-size: 17px;
  258. font-weight: 600;
  259. color: #555;
  260. margin-bottom: 20px;
  261. justify-content: space-between;
  262. align-items: center;
  263. }
  264. .appraise-box {
  265. display: flex;
  266. flex-wrap: wrap;
  267. justify-content: space-between;
  268. margin: 50px 0;
  269. }
  270. .appraise-box>div {
  271. width: 30%;
  272. }
  273. .communal-box {
  274. display: flex;
  275. }
  276. .communal-box>button {
  277. margin-left: 10px;
  278. padding: 8px 20px;
  279. }
  280. .car_add {
  281. background-color: #fff;
  282. padding: 20px;
  283. box-shadow: 0 0 5px #0005;
  284. border-radius: 10px;
  285. }
  286. @media screen and (max-width: 1700px) {
  287. .appraise-box>div {
  288. width: 48%;
  289. }
  290. .appraise-box>div el-form-item__content {
  291. width: 260px !important;
  292. }
  293. }
  294. </style>