addCapacity.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <!-- 添加运力信息 -->
  3. <div class="addWagonLoad">
  4. <PageTitle>返回</PageTitle>
  5. <el-divider content-position="left">运力信息</el-divider>
  6. <div class="form_box" style="margin-right: 10rem">
  7. <dil-form :formId="309" v-model="form1" ref="from1"></dil-form>
  8. </div>
  9. <div class="inputBox">
  10. <span class="text">所属单位类型</span>
  11. <el-autocomplete
  12. v-model="state"
  13. @input="onInput"
  14. :fetch-suggestions="querySearch"
  15. placeholder="边输入边查询"
  16. :trigger-on-focus="false"
  17. @select="handleSelect"
  18. ></el-autocomplete>
  19. </div>
  20. <div class="button_box">
  21. <el-button @click="cancel">取消</el-button>
  22. <el-button type="primary" @click="makeSure">确定</el-button>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. import PageTitle from "@/components/Page/Title";
  28. export default {
  29. components: { PageTitle },
  30. data() {
  31. return {
  32. form1: {},
  33. // value: undefined,
  34. carrierIds:"",
  35. state: "",
  36. restaurants: [],
  37. };
  38. },
  39. mounted() {},
  40. methods: {
  41. onInput() {
  42. this.axios.post(
  43. "/api/v1/rms/getCarrierName?state="+this.state,
  44. )
  45. .then((res) => {
  46. if(res.data.code == "200"){
  47. res.data.data.forEach(element => {
  48. this.restaurants.push({
  49. value:element.carrierName,
  50. carrierIds:element.carrierId
  51. })
  52. });
  53. }
  54. });
  55. },
  56. querySearch(queryString, cb) {
  57. var restaurants = this.restaurants;
  58. var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
  59. // 调用 callback 返回建议列表的数据
  60. cb(results);
  61. },
  62. createFilter(queryString) {
  63. return (restaurant) => {
  64. return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
  65. };
  66. },
  67. handleSelect(item){
  68. this.carrierIds=item.carrierIds;
  69. console.log(item)
  70. },
  71. makeSure() {
  72. // console.log(this.form1)
  73. let RmsCapacity={
  74. capacityTypeId:this.form1.capacityTypeId,
  75. capacityNumber:this.form1.capacityNumber.toUpperCase(),
  76. number:this.capacityNumber,
  77. capacityCorlor:this.form1.capacityCorlor,
  78. capacityOwneris:this.form1.capacityOwneris,
  79. capacityVip:this.form1.capacityVip,
  80. capacityBlacklist:this.form1.capacityBlacklist,
  81. // carrierId:this.form1.carrierId,
  82. state:this.state,
  83.         carrierName:this.state,
  84.         carrierIds: this.carrierIds,
  85. };
  86. // console.log("RmsCapacity",RmsCapacity)
  87. if(
  88. RmsCapacity.capacityNumber==null ||
  89. RmsCapacity.capacityCorlor==null ||
  90. RmsCapacity.capacityOwneris==null ||
  91. RmsCapacity.capacityVip==null ||
  92. RmsCapacity.capacityBlacklist==null ||
  93. RmsCapacity.carrierIds==null
  94. )this.$message.error("存在空值!");
  95. else
  96. this.axios
  97. .post(
  98. "/api/v1/rms/insertCapacity", RmsCapacity
  99. )
  100. .then((res) => {
  101. console.log("res.data.code",res.data.code);
  102. if (res.data.code == 200) {
  103. this.$message({
  104. type: "success",
  105. message: "新增成功!",
  106. });
  107. // this.$refs.table.refreshData();
  108. this.$router.go(-1);
  109. } else {
  110. this.$message.error("新增失败,可能存在重复!");
  111. }
  112. // this.$refs['table'].resetField();
  113. });
  114. },
  115. // 取消
  116. cancel() {
  117. this.$router.go(-1);
  118. },
  119. },
  120. };
  121. </script>
  122. <style lang='scss' >
  123. .addWagonLoad {
  124. .form_box {
  125. width: 100%;
  126. margin-top: 30px;
  127. display: flex;
  128. justify-content: center;
  129. .el-form-item{
  130. display: flex;
  131. justify-content: center;
  132. .el-form-item__label{
  133. display: flex;
  134. align-items: center;
  135. }
  136. .el-form-item__content{
  137. .el-select{
  138. width: 250px;
  139. }
  140. .el-input{
  141. width: 250px;
  142. }
  143. }
  144. }
  145. }
  146. .inputBox{
  147. display: flex;
  148. justify-content: center;
  149. margin-bottom: 30px;
  150. .text{
  151. text-align: right;
  152. display: flex;
  153. align-items: center;
  154. margin-right: 5px;
  155. }
  156. .input{
  157. width: 250px;
  158. }
  159. }
  160. .button_box{
  161. display: flex;
  162. justify-content: center;
  163. .el-button{
  164. width: 80px;
  165. margin-right: 10px;
  166. }
  167. }
  168. }
  169. </style>