wagonPleaseAdd.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <!-- 新增请作业页面 -->
  3. <div class="contractDetails">
  4. <page-title>返回</page-title>
  5. <div class="form">
  6. <div class="form_box">
  7. <dil-form :formId="122" v-model="form1" ></dil-form>
  8. </div>
  9. </div>
  10. <div class="fromOther">
  11. <el-form
  12. :inline="true"
  13. class="demo-form-inline"
  14. label-width="80px"
  15. >
  16. <el-form-item label="发货单位">
  17. <el-autocomplete
  18. class="inline-input"
  19. v-model="stateSupplier"
  20. :fetch-suggestions="querySearchSupplier"
  21. placeholder="请输入发货单位名称"
  22. :trigger-on-focus="false"
  23. @select="handleSelectSupplier"
  24. >
  25. <template slot-scope="{ item }">
  26. <div class="name">{{ item.supplierName }}</div>
  27. </template>
  28. </el-autocomplete>
  29. </el-form-item>
  30. </el-form>
  31. </div>
  32. <div class="trainTransport">
  33. <!-- 确定和取消 -->
  34. <div class="button_box">
  35. <el-button @click="onClickCancel">返回</el-button>
  36. <el-button type="primary" @click="onClickConfirm">确认</el-button>
  37. </div>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import PageTitle from "@/components/Page/Title";
  43. import { sjTime, isNumber } from "@/utils/sharedJsFile";
  44. import { getCookie } from "@/utils/util.js";
  45. export default {
  46. components: { PageTitle },
  47. data() {
  48. return {
  49. // 表单
  50. form1: {},
  51. supplierId: null,
  52. supplierName: "",
  53. stateSupplier: "",
  54. };
  55. },
  56. mounted() {
  57. // this.unit();
  58. },
  59. methods: {
  60. handleCheckedCitiesChange(value) {
  61. console.log(value);
  62. },
  63. //发货单位弹出层
  64. handleSelectSupplier(item) {
  65. this.supplierId = item.supplierId;
  66. item.supplierName = this.supplierName;
  67. },
  68. //以下是发货单位边输边查搜索
  69. querySearchSupplier(queryString, cb) {
  70. this.axios
  71. .post("/api/v1/uc/getSupplierMesByLike?index=" + this.stateSupplier)
  72. .then((res) => {
  73. if (res.data.code == "200") {
  74. var restaurantsSupplier = res.data.data;
  75. var results = queryString
  76. ? restaurantsSupplier.filter(
  77. this.createFilterSupplier(queryString)
  78. )
  79. : restaurantsSupplier;
  80. // 调用 callback 返回建议列表的数据
  81. cb(results);
  82. }
  83. });
  84. },
  85. createFilterSupplier(queryString) {
  86. return (restaurantsSupplier) => {
  87. return (
  88. restaurantsSupplier.value
  89. .toLowerCase()
  90. .indexOf(queryString.toLowerCase()) > -1
  91. );
  92. };
  93. },
  94. // 返回
  95. onClickCancel() {
  96. this.$router.go(-1);
  97. },
  98. // 确认
  99. onClickConfirm() {
  100. let tmstrainPleaseApproveResult = {
  101. resultPlanDate: sjTime(this.form1.resultPlanDate),
  102. resultCategory: this.form1.resultCategory,
  103. supplierId: this.supplierId,
  104. sendStationId: this.form1.sendStationId,
  105. toTheStationId: this.form1.toTheStationId,
  106. resultPleaseNumber: this.form1.resultPleaseNumber,
  107. userId: getCookie("orgCode"),
  108. resultType: 3,
  109. };
  110. function isNumber() {
  111. var value = tmstrainPleaseApproveResult.resultPleaseNumber;
  112. //验证是否为数字
  113. var patrn = /^(-)?\d+(\.\d+)?$/;
  114. if (patrn.exec(value) == null || value == "") {
  115. return false;
  116. } else {
  117. return true;
  118. }
  119. }
  120. var val = this.value;
  121. if (
  122. tmstrainPleaseApproveResult.resultPlanDate == null ||
  123. tmstrainPleaseApproveResult.resultCategory == null ||
  124. tmstrainPleaseApproveResult.supplierId == null ||
  125. tmstrainPleaseApproveResult.sendStationId == null ||
  126. tmstrainPleaseApproveResult.toTheStationId == null ||
  127. tmstrainPleaseApproveResult.resultPleaseNumber == null
  128. )
  129. this.$message.error("存在空值!");
  130. else if (!isNumber(val)) this.$message.error("请车数量必须是数字!");
  131. else
  132. this.axios
  133. .post("/api/v1/tms/addWagonPlease", tmstrainPleaseApproveResult)
  134. .then(() => {
  135. this.$message({
  136. type: "success",
  137. message: "新增成功!",
  138. });
  139. this.$router.go(-1);
  140. });
  141. },
  142. },
  143. };
  144. </script>
  145. <style lang="scss">
  146. .contractDetails {
  147. .form {
  148. display: flex;
  149. .form_box {
  150. width: 340px;
  151. margin-left: 35%;
  152. margin-top: 30px;
  153. margin-right: 20px;
  154. .el-form {
  155. .preview-group {
  156. .el-form-item {
  157. .el-form-item__label {
  158. display: inline-block;
  159. width: 70px !important;
  160. }
  161. .el-form-item__content {
  162. .el-select {
  163. width: 250px;
  164. }
  165. .el-input {
  166. width: 250px;
  167. }
  168. }
  169. .button_box {
  170. margin-left: 42%;
  171. margin-top: 55px;
  172. }
  173. }
  174. .fromOther {
  175. margin-left: 34.5%;
  176. width: 50%;
  177. .inline-input {
  178. width: 300px;
  179. .button_box {
  180. margin-left: 45%;
  181. }
  182. }
  183. }
  184. }
  185. }
  186. }
  187. }
  188. }
  189. </style>