addLoadShip.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <!-- 新增装船作业 -->
  3. <div class="shipTransport">
  4. <page-title>返回</page-title>
  5. <!-- 第一部分 -->
  6. <div class="top">
  7. <el-input placeholder="请输入内容" v-model="input" clearable> </el-input>
  8. <el-button type="primary" class="btn" @click="onclick()">
  9. <i class="el-icon-search"></i>查询
  10. </el-button>
  11. </div>
  12. <dilTable v-bind.sync="option" @radio-change="currentRadioChange">
  13. </dilTable>
  14. <div class="form">
  15. <div class="form_box">
  16. <dil-form :formId="120" v-model="form"></dil-form>
  17. <!-- <el-form :inline="true">
  18. <el-form-item>
  19. <label class="el-form-item__label" style="width: auto;margin: left 2px;"
  20. >含水率</label
  21. >
  22. </el-form-item>
  23. <el-form-item>
  24. <el-input placeholder="" v-model="resultMoistureContent"></el-input>
  25. </el-form-item>
  26. <el-form-item>
  27. <label class="el-form-item__label" style="width: auto"
  28. >合同水分值</label
  29. >
  30. </el-form-item>
  31. <el-form-item>
  32. <el-input
  33. placeholder=""
  34. v-model="contractMoistureValue"
  35. :disabled="true"
  36. ></el-input>
  37. </el-form-item>
  38. <el-form-item>
  39. <label class="el-form-item__label" style="width: auto"
  40. >水分吨位</label
  41. >
  42. </el-form-item>
  43. <el-form-item>
  44. <el-input
  45. placeholder=""
  46. v-model="moistureTonnage"
  47. :disabled="true"
  48. ></el-input>
  49. </el-form-item>
  50. </el-form> -->
  51. </div>
  52. </div>
  53. <div class="button_box_addLoadShip">
  54. <el-button type="primary" @click="makeSure" :loading="isLoading">新增装船作业</el-button>
  55. </div>
  56. </div>
  57. </template>
  58. <script>
  59. import PageTitle from "@/components/Page/Title";
  60. import { sjTime } from "@/utils/sharedJsFile";
  61. import { getCookie } from "@/utils/util.js";
  62. export default {
  63. components: { PageTitle },
  64. data() {
  65. return {
  66. input: "",
  67. resultMoistureContent:"",
  68. moistureTonnage:"",
  69. contractMoistureValue:"",
  70. batchInfactoryId:"",
  71. restaurants: [],
  72. state: "",
  73. isLoading:false,
  74. form: {
  75. waterUnitPrice:null,
  76. },
  77. option: {
  78. // 表格请求数据的地址
  79. requestUrl: "/api/v1/tms/getCapacityList?apiId=138",
  80. // 控制显示当选列
  81. selectionType: "radio",
  82. },
  83. rowMap: {},
  84. unitPrices:[]
  85. };
  86. },
  87. mounted() {
  88. this.getUnitPrice();
  89. },
  90. watch: {
  91. resultMoistureContent() {
  92. this.pipeiContarct();
  93. },
  94. batchId() {
  95. this.pipeiContarct();
  96. },
  97. "form.resultOutWharyTime":{
  98. handler(newVal,oldVal){
  99. this.findUnitPrice();
  100. },
  101. deep: true,
  102. immediate: true
  103. }
  104. },
  105. methods: {
  106. getUnitPrice(){
  107. this.axios
  108. .post("/api/v1/rms/selectbmsshipContractPriceList?apiId=500")
  109. .then((res) => {
  110. this.unitPrices=res.data.data.list;
  111. });
  112. },
  113. findUnitPrice(){
  114. if(this.rowMap && this.form.resultOutWharyTime){
  115. let contract=this.unitPrices.find(item=>
  116. item.portId==this.rowMap.startPortId
  117. && sjTime(this.form.resultOutWharyTime)>=sjTime(item.startTime)
  118. && sjTime(this.form.resultOutWharyTime)<=sjTime(item.endTime));
  119. if(contract){
  120. this.form.waterUnitPrice=contract.unitPrice;
  121. this.form.unitPriceId=contract.resultId;
  122. console.log("contract:",contract);
  123. }
  124. }
  125. },
  126. currentRadioChange(row) {
  127. this.rowMap = row;
  128. this.batchInfactoryId=this.rowMap.batchInfactoryId;
  129. this.findUnitPrice();
  130. },
  131. pipeiContarct() {
  132. if (
  133. this.resultMoistureContent != null &&
  134. this.resultMoistureContent != ""
  135. ) {
  136. let map = {
  137. batchInfactoryId: this.batchInfactoryId,
  138. resultMoistureContent: this.resultMoistureContent,
  139. resultActualInstallations:this.form.resultActualInstallations,
  140. };
  141. this.axios
  142. .post("/api/v1/tms/getMoistureAndInstallations", map)
  143. .then(res => {
  144. if (res.data.code == 200) {
  145. console.log("res" +res.data.data.purchaseContractMoisture);
  146. this.contractMoistureValue =
  147. res.data.data.purchaseContractMoisture;
  148. this.moistureTonnage = res.data.data.resultWaterTonnage;
  149. } else {
  150. this.$message.warning(res.data.data);
  151. }
  152. });
  153. }
  154. },
  155. // 新增
  156. makeSure() {
  157. this.isLoading=true;
  158. if (JSON.stringify(this.rowMap).length == 2) {
  159. this.$message.error("未选择江船");
  160. this.isLoading=false;
  161. return;
  162. }
  163. let mapVal = {
  164. resultActualInstallations: this.form.resultActualInstallations,
  165. resultLoadShipDate: sjTime(this.form.resultLoadShipDate),
  166. resultIsClear: this.form.resultIsClear,
  167. resultArrivalTime: sjTime(this.form.resultLoadShipDate),
  168. resultOutWharyName: this.form.resultOutWharyName,
  169. resultOutWharyTime: sjTime(this.form.resultOutWharyTime),
  170. resultMemo: this.form.resultMemo,
  171. //resultPlannedDate: sjTime(this.form.planDate),
  172. //expectNoticeDate: sjTime(this.form.expectNoticeDate),
  173. resultEmptyHeavyWaterMeter: this.form.resultEmptyHeavyWaterMeter,
  174. resultMoistureContent: this.resultMoistureContent,
  175. //resultInspectionFees: this.form.resultInspectionFees,
  176. contractMoistureValue: this.contractMoistureValue,
  177. moistureTonnage: this.moistureTonnage,
  178. waterUnitPrice:this.form.waterUnitPrice,
  179. unitPriceId:this.form.unitPriceId,
  180. isNeedAssemble:this.form.isNeedAssemble,
  181. userId: getCookie("userId"),
  182. };
  183. console.log("mapVal:",mapVal);
  184. //判断放货数量是否为数字
  185. function isNumber() {
  186. var value = mapVal.resultActualInstallations;
  187. //验证是否为数字
  188. var patrn = /^(-)?\d+(\.\d+)?$/;
  189. if (patrn.exec(value) == null || value == "") {
  190. return false;
  191. } else {
  192. return true;
  193. }
  194. }
  195. var val = this.value;
  196. if (
  197. mapVal.resultActualInstallations == null ||
  198. mapVal.resultLoadShipDate == null ||
  199. mapVal.resultIsClear == null ||
  200. mapVal.resultArrivalTime == null ||
  201. mapVal.resultOutWharyName == null ||
  202. mapVal.resultOutWharyTime == null
  203. ){
  204. this.$message.error("存在空值!");
  205. this.isLoading=false;
  206. }
  207. else if (!isNumber(val)) {
  208. this.$message.warning("实装数量必须为数字!");
  209. this.isLoading=false;
  210. }
  211. else{
  212. this.axios
  213. .post("/api/v1/tms/addLoadShip", {
  214. mapVal: mapVal,
  215. rowMap: this.rowMap,
  216. })
  217. .then((res) => {
  218. if (res.data.code == 200) {
  219. this.$message({
  220. type: "success",
  221. message: "新增成功!",
  222. });
  223. this.$router.go(-1);
  224. } else if (res.data.code == 201) {
  225. this.$message.warning(res.data.data);
  226. } else {
  227. this.$message.error("新增失败!");
  228. }
  229. this.isLoading=false;
  230. })
  231. }
  232. //
  233. // if (
  234. // mapVal.resultActualInstallations == null ||
  235. // // mapVal.portId==null||
  236. // mapVal.resultLoadShipDate == null ||
  237. // mapVal.resultIsClear == null ||
  238. // mapVal.resultPortDeclarationTime == null ||
  239. // mapVal.resultPortDeclarationName == null ||
  240. // mapVal.resultArrivalTime == null ||
  241. // mapVal.resultOutWharyName == null ||
  242. // mapVal.resultOutWharyTime == null
  243. // )
  244. // this.$message.error("存在空值!");
  245. // else if (!isNumber(val)) this.$message.warning("实装数量必须为数字!");
  246. // else
  247. },
  248. handleSelect(item) {
  249. console.log(item);
  250. },
  251. onclick() {
  252. this.option.requestUrl =
  253. "/api/v1/tms/getCapacityList?apiId=138&con=" + this.input;
  254. },
  255. },
  256. };
  257. </script>
  258. <style lang="scss">
  259. .shipTransport {
  260. .form {
  261. display: flex;
  262. .form_box {
  263. width: 320px;
  264. margin-left: 35%;
  265. margin-top: 30px;
  266. margin-right: 20px;
  267. .el-form {
  268. .preview-group {
  269. .el-form-item {
  270. .el-form-item__label {
  271. display: inline-block;
  272. width: 70px !important;
  273. }
  274. .el-form-item__content {
  275. .el-select {
  276. width: 250px;
  277. }
  278. .el-input {
  279. width: 250px;
  280. }
  281. }
  282. }
  283. }
  284. }
  285. }
  286. }
  287. .top {
  288. padding: 1.25rem 0.375rem;
  289. .el-input {
  290. width: 20%;
  291. margin-right: 1.25rem;
  292. }
  293. }
  294. .button_box_addLoadShip {
  295. margin-left: 45%;
  296. }
  297. }
  298. </style>