酒店预订平台
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

521 rader
21 KiB

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