wagonPleaseAdd.vue 5.2 KB

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