wagonPleaseAdd.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <template>
  2. <!-- 新增请作业页面 -->
  3. <div class="contractDetails">
  4. <page-title>返回</page-title>
  5. <div class="form">
  6. <div class="form_box">
  7. <dil-form label-width="60px" :formId="122" v-model="form1"></dil-form>
  8. </div>
  9. </div>
  10. <div class="formOther">
  11. <div class="form_box">
  12. <el-form label-width="70px">
  13. <div class="preview-group">
  14. <el-form-item label="发货单位">
  15. <el-autocomplete
  16. class="inline-input"
  17. v-model="stateSupplier"
  18. :fetch-suggestions="querySearchSupplier"
  19. placeholder="请输入发货单位名称"
  20. :trigger-on-focus="false"
  21. @select="handleSelectSupplier"
  22. >
  23. <template slot-scope="{ item }">
  24. <div class="name">{{ item.supplierName }}</div>
  25. </template>
  26. </el-autocomplete>
  27. </el-form-item>
  28. <el-form-item label="发站">
  29. <el-autocomplete
  30. class="inline-input"
  31. v-model="sendStation"
  32. :fetch-suggestions="querySearchSendStation"
  33. placeholder="请输入发站名称"
  34. :trigger-on-focus="false"
  35. @select="handleSelectSendStation"
  36. >
  37. <template slot-scope="{ item }">
  38. <div class="name">{{ item.arrivalName }}</div>
  39. </template>
  40. </el-autocomplete>
  41. </el-form-item>
  42. <el-form-item label="到站">
  43. <el-autocomplete
  44. class="inline-input"
  45. v-model="toTheStation"
  46. :fetch-suggestions="querySearchToTheStation"
  47. placeholder="请输入到站名称"
  48. :trigger-on-focus="false"
  49. @select="handleSelectToTheStation"
  50. >
  51. <template slot-scope="{ item }">
  52. <div class="name">{{ item.arrivalName }}</div>
  53. </template>
  54. </el-autocomplete>
  55. </el-form-item>
  56. </div>
  57. </el-form>
  58. </div>
  59. </div>
  60. <div class="trainTransport">
  61. <!-- 确定和取消 -->
  62. <div class="button_box">
  63. <el-button @click="onClickCancel">返回</el-button>
  64. <el-button type="primary" @click="onClickConfirm">确认</el-button>
  65. </div>
  66. </div>
  67. </div>
  68. </template>
  69. <script>
  70. import PageTitle from "@/components/Page/Title";
  71. import { sjTime, isNumber } from "@/utils/sharedJsFile";
  72. import { getCookie } from "@/utils/util.js";
  73. export default {
  74. components: { PageTitle },
  75. data() {
  76. return {
  77. // 表单
  78. form1: {},
  79. supplierId: null,
  80. supplierName: "",
  81. stateSupplier: "",
  82. sendStationId:null,
  83. toTheStationId:1,
  84. sendStation:null,
  85. toTheStation:"老区轨道衡"
  86. };
  87. },
  88. mounted() {
  89. // this.unit();
  90. },
  91. created() {
  92. this.form1 = {
  93. toTheStationId: 1,
  94. };
  95. },
  96. methods: {
  97. handleCheckedCitiesChange(value) {
  98. console.log(value);
  99. },
  100. //发站弹出层
  101. handleSelectSendStation(item) {
  102. this.sendStationId = item.arrivalId;
  103. this.sendStation = item.arrivalName;
  104. },
  105. //以下是发站边输边查搜索
  106. querySearchSendStation(queryString, cb) {
  107. this.axios
  108. .get("/api/v1/uc/getArrivalByLike?index=" + this.sendStation)
  109. .then((res) => {
  110. if (res.data.code == "200") {
  111. var restaurantsSupplier = res.data.data;
  112. console.log(restaurantsSupplier)
  113. var results = queryString
  114. ? restaurantsSupplier.filter(
  115. this.createFilterSendStation(queryString)
  116. )
  117. : restaurantsSupplier;
  118. // 调用 callback 返回建议列表的数据
  119. cb(results);
  120. }
  121. });
  122. },
  123. //发站
  124. createFilterSendStation(queryString) {
  125. return (restaurantsSupplier) => {
  126. return (
  127. restaurantsSupplier.arrivalName
  128. .toLowerCase()
  129. .indexOf(queryString.toLowerCase()) > -1
  130. );
  131. };
  132. },
  133. //到站弹出层
  134. handleSelectToTheStation(item) {
  135. this.toTheStationId = item.arrivalId;
  136. this.toTheStation = item.arrivalName;
  137. },
  138. //以下是到站边输边查搜索
  139. querySearchToTheStation(queryString, cb) {
  140. this.axios
  141. .get("/api/v1/uc/getArrivalByLike?index=" + this.toTheStation)
  142. .then((res) => {
  143. if (res.data.code == "200") {
  144. var restaurantsSupplier = res.data.data;
  145. console.log(restaurantsSupplier)
  146. var results = queryString
  147. ? restaurantsSupplier.filter(
  148. this.createFilterToTheStation(queryString)
  149. )
  150. : restaurantsSupplier;
  151. // 调用 callback 返回建议列表的数据
  152. cb(results);
  153. }
  154. });
  155. },
  156. //到站
  157. createFilterToTheStation(queryString) {
  158. return (restaurantsSupplier) => {
  159. return (
  160. restaurantsSupplier.arrivalName
  161. .toLowerCase()
  162. .indexOf(queryString.toLowerCase()) > -1
  163. );
  164. };
  165. },
  166. //发货单位弹出层
  167. handleSelectSupplier(item) {
  168. this.supplierId = item.supplierId;
  169. item.supplierName = this.supplierName;
  170. },
  171. //以下是发货单位边输边查搜索
  172. querySearchSupplier(queryString, cb) {
  173. this.axios
  174. .post("/api/v1/uc/getSupplierMesByLike?index=" + this.stateSupplier)
  175. .then((res) => {
  176. if (res.data.code == "200") {
  177. var restaurantsSupplier = res.data.data;
  178. var results = queryString
  179. ? restaurantsSupplier.filter(
  180. this.createFilterSupplier(queryString)
  181. )
  182. : restaurantsSupplier;
  183. // 调用 callback 返回建议列表的数据
  184. cb(results);
  185. }
  186. });
  187. },
  188. createFilterSupplier(queryString) {
  189. return (restaurantsSupplier) => {
  190. return (
  191. restaurantsSupplier.value
  192. .toLowerCase()
  193. .indexOf(queryString.toLowerCase()) > -1
  194. );
  195. };
  196. },
  197. // 返回
  198. onClickCancel() {
  199. this.$router.go(-1);
  200. },
  201. // 确认
  202. onClickConfirm() {
  203. let tmstrainPleaseApproveResult = {
  204. resultPlanDate: sjTime(this.form1.resultPlanDate),
  205. resultCategory: this.form1.resultCategory,
  206. supplierId: this.supplierId,
  207. sendStationId: this.sendStationId,
  208. toTheStationId: this.toTheStationId,
  209. resultPleaseNumber: this.form1.resultPleaseNumber,
  210. userId: getCookie("orgCode"),
  211. resultType: 3,
  212. };
  213. function isNumber() {
  214. var value = tmstrainPleaseApproveResult.resultPleaseNumber;
  215. //验证是否为数字
  216. var patrn = /^(-)?\d+(\.\d+)?$/;
  217. if (patrn.exec(value) == null || value == "") {
  218. return false;
  219. } else {
  220. return true;
  221. }
  222. }
  223. var val = this.value;
  224. if (
  225. tmstrainPleaseApproveResult.resultPlanDate == null ||
  226. tmstrainPleaseApproveResult.resultCategory == null ||
  227. tmstrainPleaseApproveResult.supplierId == null ||
  228. tmstrainPleaseApproveResult.sendStationId == null ||
  229. tmstrainPleaseApproveResult.toTheStationId == null ||
  230. tmstrainPleaseApproveResult.resultPleaseNumber == null
  231. )
  232. this.$message.error("存在空值!");
  233. else if (!isNumber(val)) this.$message.error("请车数量必须是数字!");
  234. else
  235. this.axios
  236. .post("/api/v1/tms/addWagonPlease", tmstrainPleaseApproveResult)
  237. .then(() => {
  238. this.$router.go(-1);
  239. this.$message({
  240. type: "success",
  241. message: "新增成功!",
  242. });
  243. });
  244. },
  245. },
  246. };
  247. </script>
  248. <style lang="scss" scoped>
  249. .contractDetails {
  250. .form {
  251. display: flex;
  252. .form_box {
  253. width: 340px;
  254. margin-left: 36%;
  255. margin-top: 30px;
  256. margin-right: 20px;
  257. .el-form {
  258. .preview-group {
  259. .el-form-item {
  260. .el-form-item__label {
  261. display: inline-block;
  262. width: 70px !important;
  263. }
  264. .el-form-item__content {
  265. .inline-input{
  266. width:270px;
  267. }
  268. }
  269. .button_box {
  270. margin-left: 42%;
  271. margin-top: 55px;
  272. }
  273. }
  274. }
  275. }
  276. }
  277. }
  278. }
  279. .trainTransport {
  280. margin-left: 41.25%;
  281. margin-top: 30px;
  282. width: 300px;
  283. .inline-input {
  284. width: 300px;
  285. .button_box {
  286. margin-left: 52.5%;
  287. }
  288. }
  289. }
  290. .formOther {
  291. display: flex;
  292. .form_box {
  293. width: 340px;
  294. margin-left: 36%;
  295. margin-top: 30px;
  296. margin-right: 20px;
  297. .el-form {
  298. .preview-group {
  299. .el-form-item {
  300. .el-form-item__label {
  301. display: inline-block;
  302. width: 70px !important;
  303. }
  304. .el-form-item__content {
  305. .inline-input{
  306. width:250px;
  307. }
  308. }
  309. }
  310. }
  311. }
  312. }
  313. }
  314. </style>