ThreeCodeOperation.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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="Three">
  11. <el-input placeholder="三字码" v-model="addData.Three">
  12. </el-input>
  13. </el-form-item>
  14. </div>
  15. <div style="width: 49%;">
  16. <el-form-item label="四字码" prop="Four">
  17. <el-input placeholder="四字码" v-model="addData.Four">
  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="Country">
  25. <el-input placeholder="国家" v-model="addData.Country">
  26. </el-input>
  27. </el-form-item>
  28. </div>
  29. <div style="width: 49%;">
  30. <el-form-item label="城市" prop="City">
  31. <el-input placeholder="城市" v-model="addData.City">
  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="AirPort">
  39. <el-input placeholder="机场名" v-model="addData.AirPort">
  40. </el-input>
  41. </el-form-item>
  42. </div>
  43. <div style="width: 49%;">
  44. <el-form-item label="机场英文名" prop="AirPort_En">
  45. <el-input placeholder="机场英文名" v-model="addData.AirPort_En">
  46. </el-input>
  47. </el-form-item>
  48. </div>
  49. </div>
  50. <div style="display: flex;">
  51. <div style="width: 98%;">
  52. <el-form-item label="备注" prop="Remark">
  53. <el-input type="textarea" :rows="3" placeholder="请输入内容" v-model="addData.Remark"></el-input>
  54. </el-form-item>
  55. </div>
  56. </div>
  57. <el-form-item>
  58. <div style="margin-left: 60%;">
  59. <el-button type="primary" @click="addBtn">保存</el-button>
  60. <router-link to='/home/ThreeCode'>
  61. <el-button>取消</el-button>
  62. </router-link>
  63. </div>
  64. </el-form-item>
  65. </el-form>
  66. </div>
  67. </div>
  68. </template>
  69. <script>
  70. export default {
  71. data() {
  72. return {
  73. rules: {
  74. Three: [
  75. { required: true, message: '请输入三字码', trigger: 'blur' },
  76. ],
  77. Country: [
  78. { required: true, message: '请输入国家', trigger: 'blur' },
  79. ],
  80. City: [
  81. { required: true, message: '请输入城市', trigger: 'blur' },
  82. ],
  83. AirPort: [
  84. { required: true, message: '请输入机场名', trigger: 'blur' },
  85. ],
  86. AirPort_En: [
  87. { required: true, message: '请输入机场英文名', trigger: 'blur' },
  88. ],
  89. },
  90. loading: false,
  91. tableData: [],
  92. currentPage: 1, // 当前页码
  93. pageSize: 15,// 每页的数据条数
  94. input: '',
  95. token: '',
  96. userId: 0,
  97. addData: {
  98. Status: '',
  99. Id: 0,
  100. Three: '',
  101. Four: '',
  102. Country: '',
  103. City: '',
  104. AirPort: '',
  105. AirPort_En: '',
  106. CreateUserId: '',
  107. Remark: ''
  108. },
  109. ThreeCodeData: {}
  110. }
  111. },
  112. methods: {
  113. ThreeCode() {
  114. var url = "/api/Resource/QueryThreeCode"
  115. var that = this
  116. this.$axios({
  117. method: 'post',
  118. url: url,
  119. headers: {
  120. Authorization: 'Bearer ' + this.token
  121. },
  122. data: {
  123. portType: 1,
  124. }
  125. }).then(function (res) {
  126. if (res.data.code == 200) {
  127. debugger
  128. that.tableData = res.data.data;
  129. that.addData.Id = that.$route.query.id;
  130. if (that.addData.Id == undefined || that.addData.Id == null) {
  131. //添加
  132. that.addData.Status = 1
  133. } else {
  134. //编辑
  135. that.upData();
  136. }
  137. }
  138. }).catch(function (error) {
  139. that.$message.error("网络错误,请稍后重试");
  140. });
  141. },
  142. handleSelect(item) {
  143. console.log(item);
  144. },
  145. addBtn() {
  146. const that = this;
  147. debugger
  148. that.addData.CreateUserId = that.userId
  149. that.$refs.addData.validate((valid) => {
  150. if (valid) {
  151. debugger
  152. console.log(that.addData)
  153. var url = "/api/Resource/OperationThreeCode"
  154. that.$axios({
  155. method: 'post',
  156. url: url,
  157. headers: {
  158. Authorization: 'Bearer ' + that.token
  159. },
  160. data: that.addData
  161. }).then(function (res) {
  162. console.log(res)
  163. debugger
  164. if (res.data.code == 200) {
  165. that.$message({
  166. message: res.data.msg,
  167. type: 'success'
  168. });
  169. that.loading = true;
  170. setTimeout(() => {
  171. that.$router.push('/home/ThreeCode')
  172. }, 3000);
  173. } else {
  174. that.$message.error(res.data.msg);
  175. }
  176. })
  177. } else {
  178. this.$message.error('请完善信息在保存!');
  179. return false;
  180. }
  181. })
  182. },
  183. upData() {
  184. debugger
  185. for (var i = 0; i < this.tableData.length; i++) {
  186. if (this.tableData[i].id == parseInt(this.addData.Id)) {
  187. debugger
  188. this.ThreeCodeData = this.tableData[i];
  189. break;
  190. }
  191. }
  192. this.addData.Status = 2;
  193. this.addData.Id = this.ThreeCodeData.id;
  194. this.addData.Three = this.ThreeCodeData.three;
  195. this.addData.Four = this.ThreeCodeData.four;
  196. this.addData.Country = this.ThreeCodeData.country;
  197. this.addData.City = this.ThreeCodeData.city;
  198. this.addData.AirPort = this.ThreeCodeData.airPort;
  199. this.addData.AirPort_En = this.ThreeCodeData.airPort_En;
  200. this.addData.CreateUserId = this.ThreeCodeData.createUserId;
  201. this.addData.Remark = this.ThreeCodeData.remark;
  202. },
  203. },
  204. mounted() {
  205. debugger
  206. this.token = JSON.parse(localStorage.getItem('userinif')).token;
  207. this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
  208. this.ThreeCode();
  209. }
  210. }
  211. </script>
  212. <style>
  213. .communal-list {
  214. background-color: #fff;
  215. padding: 10px;
  216. box-shadow: 0 0 5px #0005;
  217. border-radius: 10px;
  218. }
  219. .car_add .communal-title {
  220. display: flex;
  221. font-size: 17px;
  222. font-weight: 600;
  223. color: #555;
  224. margin-bottom: 20px;
  225. justify-content: space-between;
  226. align-items: center;
  227. }
  228. .appraise-box {
  229. display: flex;
  230. flex-wrap: wrap;
  231. justify-content: space-between;
  232. margin: 50px 0;
  233. }
  234. .appraise-box>div {
  235. width: 30%;
  236. }
  237. .communal-box {
  238. display: flex;
  239. }
  240. .communal-box>button {
  241. margin-left: 10px;
  242. padding: 8px 20px;
  243. }
  244. .car_add {
  245. background-color: #fff;
  246. padding: 20px;
  247. box-shadow: 0 0 5px #0005;
  248. border-radius: 10px;
  249. }
  250. @media screen and (max-width: 1700px) {
  251. .appraise-box>div {
  252. width: 48%;
  253. }
  254. .appraise-box>div el-form-item__content {
  255. width: 260px !important;
  256. }
  257. }
  258. </style>