ThreeCodeOperation.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. Three: '',
  125. City: '',
  126. }
  127. }).then(function (res) {
  128. if (res.data.code == 200) {
  129. that.tableData = res.data.data;
  130. that.addData.Id = that.$route.query.id;
  131. if (that.addData.Id == undefined || that.addData.Id == null) {
  132. //添加
  133. that.addData.Status = 1
  134. } else {
  135. //编辑
  136. that.upData();
  137. }
  138. }
  139. }).catch(function (error) {
  140. that.$message.error("网络错误,请稍后重试");
  141. });
  142. },
  143. handleSelect(item) {
  144. console.log(item);
  145. },
  146. addBtn() {
  147. const that = this;
  148. that.addData.CreateUserId = that.userId
  149. that.$refs.addData.validate((valid) => {
  150. if (valid) {
  151. console.log(that.addData)
  152. var url = "/api/Resource/OperationThreeCode"
  153. that.$axios({
  154. method: 'post',
  155. url: url,
  156. headers: {
  157. Authorization: 'Bearer ' + that.token
  158. },
  159. data: that.addData
  160. }).then(function (res) {
  161. console.log(res)
  162. if (res.data.code == 200) {
  163. that.$message({
  164. message: res.data.msg,
  165. type: 'success'
  166. });
  167. that.loading = true;
  168. setTimeout(() => {
  169. that.$router.push('/home/ThreeCode')
  170. }, 3000);
  171. } else {
  172. that.$message.error(res.data.msg);
  173. }
  174. })
  175. } else {
  176. this.$message.error('请完善信息在保存!');
  177. return false;
  178. }
  179. })
  180. },
  181. upData() {
  182. debugger
  183. for (var i = 0; i < this.tableData.pageSource.length; i++) {
  184. if (this.tableData.pageSource[i].id == parseInt(this.addData.Id)) {
  185. this.ThreeCodeData = this.tableData.pageSource[i];
  186. break;
  187. }
  188. }
  189. this.addData.Status = 2;
  190. this.addData.Id = this.ThreeCodeData.id;
  191. this.addData.Three = this.ThreeCodeData.three;
  192. this.addData.Four = this.ThreeCodeData.four;
  193. this.addData.Country = this.ThreeCodeData.country;
  194. this.addData.City = this.ThreeCodeData.city;
  195. this.addData.AirPort = this.ThreeCodeData.airPort;
  196. this.addData.AirPort_En = this.ThreeCodeData.airPort_En;
  197. this.addData.CreateUserId = this.ThreeCodeData.createUserId;
  198. this.addData.Remark = this.ThreeCodeData.remark;
  199. },
  200. },
  201. mounted() {
  202. this.token = JSON.parse(localStorage.getItem('userinif')).token;
  203. this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
  204. this.ThreeCode();
  205. }
  206. }
  207. </script>
  208. <style>
  209. .communal-list {
  210. background-color: #fff;
  211. padding: 10px;
  212. box-shadow: 0 0 5px #0005;
  213. border-radius: 10px;
  214. }
  215. .car_add .communal-title {
  216. display: flex;
  217. font-size: 17px;
  218. font-weight: 600;
  219. color: #555;
  220. margin-bottom: 20px;
  221. justify-content: space-between;
  222. align-items: center;
  223. }
  224. .appraise-box {
  225. display: flex;
  226. flex-wrap: wrap;
  227. justify-content: space-between;
  228. margin: 50px 0;
  229. }
  230. .appraise-box>div {
  231. width: 30%;
  232. }
  233. .communal-box {
  234. display: flex;
  235. }
  236. .communal-box>button {
  237. margin-left: 10px;
  238. padding: 8px 20px;
  239. }
  240. .car_add {
  241. background-color: #fff;
  242. padding: 20px;
  243. box-shadow: 0 0 5px #0005;
  244. border-radius: 10px;
  245. }
  246. @media screen and (max-width: 1700px) {
  247. .appraise-box>div {
  248. width: 48%;
  249. }
  250. .appraise-box>div el-form-item__content {
  251. width: 260px !important;
  252. }
  253. }
  254. </style>