酒店预订平台
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.
 
 
 
 
 
 

442 lines
17 KiB

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