酒店预订平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.html 17 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <!-- import CSS -->
  6. <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
  7. </head>
  8. <body>
  9. <div id="app" class="table">
  10. <div>
  11. <div class="header-search">
  12. <span>名称:</span>
  13. <el-input v-model="search.hotel_name" style="width: 120px;" placeholder="请输入内容"></el-input>
  14. <span>手机号:</span>
  15. <el-input v-model="search.hotel_phone" style="width: 120px;" placeholder="请输入内容"></el-input>
  16. <span>省份</span>
  17. <el-select v-model="search.province" placeholder="请选择" style="width: 120px;" clearable>
  18. <el-option
  19. v-for="item in province"
  20. :key="item.value"
  21. :label="item.name"
  22. :value="item.value">
  23. </el-option>
  24. </el-select>
  25. <span>市</span>
  26. <el-select v-model="search.city" placeholder="请选择" style="width: 120px;" clearable>
  27. <el-option
  28. v-for="item in city"
  29. :key="item.value"
  30. :label="item.name"
  31. :value="item.value">
  32. </el-option>
  33. </el-select>
  34. <span>区</span>
  35. <el-select v-model="search.area" placeholder="请选择" style="width: 120px;" clearable>
  36. <el-option
  37. v-for="item in area"
  38. :key="item.value"
  39. :label="item.name"
  40. :value="item.value">
  41. </el-option>
  42. </el-select>
  43. <el-button type="primary" icon="el-icon-search" @click="getData(1)">搜索</el-button>
  44. <el-button type="primary" icon="el-icon-plus" @click="edit(null)">新增</el-button>
  45. </div>
  46. <el-table ref="multipleTable" :data="tableData" border tooltip-effect="dark"
  47. style="font-size:12px;width: 100%;margin-top: 12px">
  48. <el-table-column prop="id" label="酒店ID" min-width="50"></el-table-column>
  49. <el-table-column prop="hotel_name" label="名称" min-width="180"></el-table-column>
  50. <el-table-column prop="hotel_phone" label="手机号" min-width="100"></el-table-column>
  51. <el-table-column prop="province_name" label="省" min-width="90"></el-table-column>
  52. <el-table-column prop="city_name" label="市" min-width="90"></el-table-column>
  53. <el-table-column prop="area_name" label="区" min-width="90"></el-table-column>
  54. <el-table-column prop="detail_address" label="详细地址" min-width="250"></el-table-column>
  55. <el-table-column prop="create_time" label="创建时间" min-width="80"></el-table-column>
  56. <el-table-column prop="update_time" label="更新时间" min-width="80"></el-table-column>
  57. <el-table-column label="操作" min-width="180">
  58. <template slot-scope="scope">
  59. <el-button-group>
  60. <el-button type="primary" size="mini" @click="edit(scope.row)" icon="el-icon-edit">编辑</el-button>
  61. <el-button type="danger" size="mini" icon="el-icon-delete" @click="delAll(scope.row.id)">删除</el-button>
  62. </el-button-group>
  63. </template>
  64. </el-table-column>
  65. </el-table>
  66. <el-pagination
  67. :page-size="search.pageSize"
  68. :pager-count="11"
  69. layout="total, sizes, prev, pager, next, jumper"
  70. :total="total"
  71. :current-page="search.pageNum"
  72. :page-sizes="[10, 20, 30, 40, 50]"
  73. @size-change="sizeChange"
  74. @current-change="getData"
  75. @prev-click="getData"
  76. @next-click="getData"
  77. ></el-pagination>
  78. </div>
  79. <transition name="bounce" v-if="editShow">
  80. <el-dialog title="付款单详情" :visible.sync="editShow" width="90%" top="15px">
  81. <el-form ref="form" label-width="100px" style="width: 100%;padding-bottom: 20px">
  82. <div style="display: flex;width: 100%">
  83. <el-form-item v-if="editType" label="ID:" style="width: 80%">
  84. <div v-html="editData.id"></div>
  85. </el-form-item>
  86. </div>
  87. <div>
  88. <el-form-item label="名称:" style="width: 80%">
  89. <el-input v-model="editData.hotel_name" style="width: 280px;" placeholder="请输入内容"></el-input>
  90. </el-form-item>
  91. </div>
  92. <div>
  93. <el-form-item label="手机号:" style="width: 80%">
  94. <el-input v-model="editData.hotel_phone" style="width: 120px;" placeholder="请输入内容"></el-input>
  95. </el-form-item>
  96. </div>
  97. <div style="display: flex">
  98. <el-form-item label="省:" >
  99. <el-select v-model="editData.province" placeholder="请选择" style="width: 120px;" clearable>
  100. <el-option v-for="item in province" :key="item.value" :label="item.name" :value="item.value"></el-option>
  101. </el-select>
  102. </el-form-item>
  103. <el-form-item label="市:" >
  104. <el-select v-model="editData.city" placeholder="请选择" style="width: 120px;" clearable>
  105. <el-option v-for="item in edit_city" :key="item.value" :label="item.name" :value="item.value"></el-option>
  106. </el-select>
  107. </el-form-item>
  108. <el-form-item label="区:" >
  109. <el-select v-model="editData.area" placeholder="请选择" style="width: 120px;" clearable>
  110. <el-option v-for="item in edit_area" :key="item.value" :label="item.name" :value="item.value"></el-option>
  111. </el-select>
  112. </el-form-item>
  113. </div>
  114. <div>
  115. <el-form-item label="详细地址:" style="width: 80%">
  116. <el-input v-model="editData.detail_address" style="width: 580px;" placeholder="请输入内容"></el-input>
  117. </el-form-item>
  118. </div>
  119. <div>
  120. <el-button type="primary" @click="editDoing()" >保存</el-button>
  121. </div>
  122. </el-form>
  123. </el-dialog>
  124. </transition>
  125. </div>
  126. </body>
  127. <!-- import Vue before Element -->
  128. <script src="/assets/js/vue/vue.js"></script>
  129. <!-- import JavaScript -->
  130. <script src="/assets/js/vue/index.js"></script>
  131. <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  132. <script>
  133. new Vue({
  134. el: '#app',
  135. data: function () {
  136. return {
  137. search: {
  138. hotel_name: "",
  139. hotel_phone: "",
  140. province:"",
  141. city:"",
  142. area: "",
  143. pageSize:10,
  144. pageNum: 1
  145. },
  146. total: 0,
  147. tableData: [],
  148. editShow: false,
  149. editType: false,
  150. editData: {
  151. },
  152. province: [],
  153. city: [],
  154. area:[],
  155. edit_city_set:3,
  156. edit_city: [],
  157. edit_area:[],
  158. }
  159. },
  160. created() {
  161. this.getProvince();
  162. this.getData(1)
  163. },
  164. watch: {
  165. "search.province" : function (newVal,oldVal){
  166. this.city = []
  167. this.area = []
  168. this.search.city=""
  169. this.search.area=""
  170. if (newVal==''){
  171. return false;
  172. }
  173. let row = {
  174. "province":newVal
  175. }
  176. axios.post("/hotel.php/ajax/areaList", row).then((response) => {
  177. let data = response.data;
  178. if (data.flag) {
  179. this.city = data.data;
  180. } else {
  181. this.$message.error(data.msg);
  182. }
  183. }).catch(function (error) {
  184. console.log(error);
  185. });
  186. },
  187. "search.city" : function (newVal,oldVal){
  188. this.area = []
  189. this.search.area=""
  190. if (newVal == "") {
  191. return false;
  192. }
  193. let row = {
  194. province:this.search.province,
  195. city:newVal
  196. }
  197. axios.post("/hotel.php/ajax/areaList", row).then((response) => {
  198. let data = response.data;
  199. if (data.flag) {
  200. this.area = data.data;
  201. } else {
  202. this.$message.error(data.msg);
  203. }
  204. }).catch(function (error) {
  205. console.log(error);
  206. });
  207. },
  208. "editData.province" : function (newVal,oldVal){
  209. if (this.edit_city_set==3) {
  210. this.edit_city = []
  211. this.edit_area = []
  212. this.editData.city=""
  213. this.editData.area=""
  214. }
  215. if (newVal==''){
  216. return false;
  217. }
  218. let row = {
  219. "province":newVal
  220. }
  221. axios.post("/hotel.php/ajax/areaList", row).then((response) => {
  222. let data = response.data;
  223. if (data.flag) {
  224. this.edit_city = data.data;
  225. this.edit_city_set++;
  226. } else {
  227. this.$message.error(data.msg);
  228. }
  229. }).catch(function (error) {
  230. console.log(error);
  231. });
  232. },
  233. "editData.city" : function (newVal,oldVal){
  234. if (this.edit_city_set==3) {
  235. this.edit_area = []
  236. this.editData.area=""
  237. }
  238. if (newVal == "") {
  239. return false;
  240. }
  241. let row = {
  242. province:this.editData.province,
  243. city:newVal
  244. }
  245. axios.post("/hotel.php/ajax/areaList", row).then((response) => {
  246. let data = response.data;
  247. if (data.flag) {
  248. this.edit_area = data.data;
  249. this.edit_city_set++;
  250. } else {
  251. this.$message.error(data.msg);
  252. }
  253. }).catch(function (error) {
  254. console.log(error);
  255. });
  256. }
  257. },
  258. methods: {
  259. getProvince(){
  260. axios.post("/hotel.php/ajax/areaList", {}).then((response) => {
  261. let data = response.data;
  262. if (data.flag) {
  263. this.province = data.data;
  264. } else {
  265. this.$message.error(data.msg);
  266. }
  267. }).catch(function (error) {
  268. console.log(error);
  269. });
  270. },
  271. sizeChange(pageSize) {
  272. this.search.pageSize = pageSize;
  273. this.getData(this.search.pageNum)
  274. },
  275. //獲取列表
  276. getData(page) {
  277. this.search.pageNum = page;
  278. axios.post("/hotel.php/cf_hotel_info/getList", this.search).then((response) => {
  279. let data = response.data;
  280. if (data.flag) {
  281. this.tableData = data.data.list;
  282. this.total = data.data.total;
  283. } else {
  284. this.$message.error(response.msg);
  285. }
  286. }).catch(function (error) {
  287. console.log(error);
  288. });
  289. },
  290. edit(info) {
  291. if (info == null) {
  292. this.editType = false;
  293. this.editData = {
  294. hotel_name: "",
  295. hotel_phone: "",
  296. province:"",
  297. city:"",
  298. area: "",
  299. detail_address:""
  300. }
  301. } else {
  302. this.edit_city_set = 1;
  303. this.editType = true;
  304. this.editData = {
  305. id:info.id,
  306. hotel_name: info.hotel_name,
  307. hotel_phone: info.hotel_phone,
  308. province:info.province,
  309. province_name:info.province_name,
  310. city:info.city,
  311. city_name:info.city_name,
  312. area: info.area,
  313. area_name:info.area_name,
  314. detail_address:info.detail_address
  315. }
  316. }
  317. this.editShow = true;
  318. },
  319. setAreaName(){
  320. for (let i = 0; i < this.province.length; i++) {
  321. if (this.province[i].value == this.editData.province) {
  322. this.editData.province_name = this.province[i].name;
  323. break
  324. }
  325. }
  326. for (let i = 0; i < this.edit_city.length; i++) {
  327. if (this.edit_city[i].value == this.editData.city) {
  328. this.editData.city_name = this.edit_city[i].name;
  329. break
  330. }
  331. }
  332. for (let i = 0; i < this.edit_area.length; i++) {
  333. if (this.edit_area[i].value == this.editData.area) {
  334. this.editData.area_name = this.edit_area[i].name;
  335. break;
  336. }
  337. }
  338. },
  339. editDoing(){
  340. if (this.editData.hotel_name==''){
  341. this.$message.error("名称不能为空");return false;
  342. }
  343. if (this.editData.hotel_phone==''){
  344. this.$message.error("手机号不能为空");return false;
  345. }
  346. if (this.editData.province==''){
  347. this.$message.error("省不能为空");return false;
  348. }
  349. if (this.editData.city==''){
  350. this.$message.error("市不能为空");return false;
  351. }
  352. if (this.editData.area==''){
  353. this.$message.error("区不能为空");return false;
  354. }
  355. this.setAreaName();
  356. axios.post("/hotel.php/cf_hotel_info/save", this.editData).then( (response)=> {
  357. let data = response.data;
  358. console.log(this.tableData);
  359. if (data.flag) {
  360. this.$message({
  361. message: '保存成功!',
  362. type: 'success'
  363. });
  364. this.editShow = false;
  365. this.getData(1);
  366. } else {
  367. this.$message.error(data.msg);
  368. }
  369. }).catch(function (error) {
  370. this.$message.error("保存失败");
  371. console.log(error);
  372. });
  373. },
  374. delAll(id){
  375. this.$confirm('确定删除酒店?', '提示', {
  376. confirmButtonText: '确定',
  377. cancelButtonText: '取消',
  378. type: 'warning'
  379. }).then(() => {
  380. let param = {
  381. id: id
  382. }
  383. axios.post("/hotel.php/cf_hotel_info/delAll", param).then((response) => {
  384. let data = response.data;
  385. if (data.flag) {
  386. this.getData(this.search.pageNum)
  387. this.$message.success("保存成功");
  388. } else {
  389. this.$message.error(response.msg);
  390. }
  391. }).catch(function (error) {
  392. console.log(error);
  393. });
  394. }).catch(() => {
  395. this.$message({
  396. type: 'info',
  397. message: '已取消'
  398. });
  399. this.getData(this.search.pageNum)
  400. })
  401. }
  402. }
  403. })
  404. </script>
  405. <style lang="scss" scoped>
  406. .el-table thead {
  407. background-color: #5a5e66 !important;
  408. }
  409. .header-search {
  410. font-size: 14px;
  411. font-weight: 900;
  412. }
  413. body {
  414. background-color: white;
  415. }
  416. .table {
  417. width: 100%;
  418. font-size: 12px;
  419. margin-top: 12px;
  420. background-color: white;
  421. }
  422. .el-form-item{
  423. margin-bottom: 5px !important;
  424. }
  425. </style>
  426. </html>