addShipmentInstructions.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <!-- 装船指令新增页面 -->
  3. <div class="shipTransport">
  4. <page-title>返回</page-title>
  5. <div class="form">
  6. <div class="form_box">
  7. <dil-form :formId="114" v-model="form1" ref="from1"></dil-form>
  8. <span> 二程:海港-江港</span>
  9. <el-switch
  10. v-model="status"
  11. active-color="#13ce66"
  12. inactive-color="#909399"
  13. @change="changeStatus"
  14. >
  15. </el-switch>
  16. </div>
  17. <div class="liulan">
  18. <el-button type="primary" class="btn" @click="onDrawer">浏览</el-button>
  19. </div>
  20. </div>
  21. <!-- 确定和取消 -->
  22. <div class="button_box">
  23. <el-button @click="cancel">取消</el-button>
  24. <el-button type="primary" @click="makeSure">确定</el-button>
  25. </div>
  26. <!-- 模态框 -->
  27. <el-drawer
  28. :visible.sync="drawer"
  29. :direction="direction"
  30. :before-close="handleClose"
  31. size="45%"
  32. >
  33. <el-input
  34. placeholder="请输入内容"
  35. v-model="input"
  36. style="margin-top: 10px; margin-left: 20px; width: 250px"
  37. clearable
  38. >
  39. </el-input>
  40. <el-button
  41. type="primary"
  42. class="btn"
  43. @click="onclick()"
  44. style="margin-bottom: 15px"
  45. >
  46. <i class="el-icon-search"></i>查询
  47. </el-button>
  48. <dilTable
  49. v-bind.sync="options"
  50. @radio-change="currentRadioChange1"
  51. ></dilTable>
  52. </el-drawer>
  53. </div>
  54. </template>
  55. <script>
  56. import PageTitle from "@/components/Page/Title";
  57. import { sjTime, isNumber } from "@/utils/sharedJsFile";
  58. export default {
  59. components: { PageTitle },
  60. data() {
  61. return {
  62. drawer: false,
  63. direction: "rtl",
  64. input: "",
  65. options: {
  66. requestUrl: "/api/v1/tms/getBatchListForInstruction?apiId=383",
  67. selectionType: "radio",
  68. maplist: [],
  69. },
  70. status: false,
  71. form1: {},
  72. value: undefined,
  73. batchId: "",
  74. };
  75. },
  76. mounted() {},
  77. methods: {
  78. onDrawer() {
  79. this.drawer = true;
  80. },
  81. changeStatus() {
  82. // this.status=!this.status;
  83. console.log(this.status);
  84. // console.log("aaa",this.status);
  85. },
  86. onclick() {
  87. this.options.requestUrl =
  88. "/api/v1/tms/getBatchListForInstruction?apiId=383&con=" + this.input;
  89. },
  90. currentRadioChange1(selection) {
  91. this.maplist = selection;
  92. if (JSON.stringify(this.maplist).length > 2) {
  93. this.$set(
  94. this.form1,
  95. "batchId",
  96. selection.resultForeignShipName +
  97. "-" +
  98. selection.materialName +
  99. "-" +
  100. selection.infactoryShipName
  101. );
  102. this.batchId = selection.batchId;
  103. }
  104. },
  105. handleClose(done) {
  106. done();
  107. },
  108. // 确定
  109. makeSure() {
  110. if (this.batchId == "" || this.batchId == undefined) {
  111. this.$message.warning("请选择批次号");
  112. return;
  113. }
  114. let omsshipShipmentInstructions = {
  115. batchId: this.maplist.batchId,
  116. instructionsTotalTonnage: this.form1.instructionsTotalTonnage,
  117. instructionTime: sjTime(this.form1.instructionTime),
  118. statu: this.status,
  119. transportPortName: this.form1.transportPortName,
  120. handoverMethod: this.form1.handoverMethod,
  121. };
  122. //判断合计吨位是否为数字
  123. function isNumber() {
  124. var value = omsshipShipmentInstructions.instructionsTotalTonnage;
  125. //验证是否为数字
  126. var patrn = /^(-)?\d+(\.\d+)?$/;
  127. if (patrn.exec(value) == null || value == "") {
  128. return false;
  129. } else {
  130. return true;
  131. }
  132. }
  133. var val = this.value;
  134. if (
  135. omsshipShipmentInstructions.batchId == null ||
  136. omsshipShipmentInstructions.instructionsTotalTonnage == null ||
  137. omsshipShipmentInstructions.instructionTime == null
  138. )
  139. this.$message.error("存在空值!");
  140. else if (!isNumber(val)) this.$message.warning("合计吨位请填写数字");
  141. else
  142. this.axios
  143. .post(
  144. "/api/v1/tms/addShipmentInstructions",
  145. omsshipShipmentInstructions
  146. )
  147. .then((res) => {
  148. if (res.data.code == "200") {
  149. this.$message({
  150. type: "success",
  151. message: "新增成功",
  152. });
  153. }
  154. this.$router.go(-1);
  155. });
  156. },
  157. // 取消
  158. cancel() {
  159. this.$router.go(-1);
  160. },
  161. },
  162. };
  163. </script>
  164. <style lang="scss">
  165. .shipTransport {
  166. .form {
  167. display: flex;
  168. .form_box {
  169. width: 320px;
  170. margin-left: 35%;
  171. margin-top: 30px;
  172. margin-right: 20px;
  173. .el-form {
  174. .preview-group {
  175. .el-form-item {
  176. .el-form-item__label {
  177. display: inline-block;
  178. width: 70px !important;
  179. }
  180. .el-form-item__content {
  181. .el-select {
  182. width: 250px;
  183. }
  184. .el-input {
  185. width: 250px;
  186. }
  187. }
  188. }
  189. }
  190. }
  191. }
  192. }
  193. .liulan {
  194. width: 120px;
  195. margin-top: 30px;
  196. .el-button {
  197. width: 100px !important;
  198. margin: auto;
  199. }
  200. .btn {
  201. margin-top: 0px;
  202. }
  203. .btn1 {
  204. margin-top: 13px;
  205. }
  206. .btn2 {
  207. margin-top: 67px;
  208. }
  209. }
  210. .button_box {
  211. margin-left: 42.5%;
  212. }
  213. }
  214. </style>