addLoadShip.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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">新增装船作业</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. form: {
  74. waterUnitPrice:null,
  75. },
  76. option: {
  77. // 表格请求数据的地址
  78. requestUrl: "/api/v1/tms/getCapacityList?apiId=138",
  79. // 控制显示当选列
  80. selectionType: "radio",
  81. },
  82. rowMap: {},
  83. unitPrices:[]
  84. };
  85. },
  86. mounted() {
  87. this.getUnitPrice();
  88. },
  89. watch: {
  90. resultMoistureContent() {
  91. this.pipeiContarct();
  92. },
  93. batchId() {
  94. this.pipeiContarct();
  95. },
  96. "form.resultOutWharyTime":{
  97. handler(newVal,oldVal){
  98. this.findUnitPrice();
  99. },
  100. deep: true,
  101. immediate: true
  102. }
  103. },
  104. methods: {
  105. getUnitPrice(){
  106. this.axios
  107. .post("/api/v1/rms/selectbmsshipContractPriceList?apiId=500")
  108. .then((res) => {
  109. this.unitPrices=res.data.data.list;
  110. });
  111. },
  112. findUnitPrice(){
  113. if(this.rowMap && this.form.resultOutWharyTime){
  114. let contract=this.unitPrices.find(item=>
  115. item.portId==this.rowMap.startPortId
  116. && sjTime(this.form.resultOutWharyTime)>=sjTime(item.startTime)
  117. && sjTime(this.form.resultOutWharyTime)<=sjTime(item.endTime));
  118. if(contract){
  119. this.form.waterUnitPrice=contract.unitPrice;
  120. this.form.unitPriceId=contract.resultId;
  121. console.log("contract:",contract);
  122. }
  123. }
  124. },
  125. currentRadioChange(row) {
  126. this.rowMap = row;
  127. this.batchInfactoryId=this.rowMap.batchInfactoryId;
  128. this.findUnitPrice();
  129. },
  130. pipeiContarct() {
  131. if (
  132. this.resultMoistureContent != null &&
  133. this.resultMoistureContent != ""
  134. ) {
  135. let map = {
  136. batchInfactoryId: this.batchInfactoryId,
  137. resultMoistureContent: this.resultMoistureContent,
  138. resultActualInstallations:this.form.resultActualInstallations,
  139. };
  140. this.axios
  141. .post("/api/v1/tms/getMoistureAndInstallations", map)
  142. .then(res => {
  143. if (res.data.code == 200) {
  144. console.log("res" +res.data.data.purchaseContractMoisture);
  145. this.contractMoistureValue =
  146. res.data.data.purchaseContractMoisture;
  147. this.moistureTonnage = res.data.data.resultWaterTonnage;
  148. } else {
  149. this.$message.warning(res.data.data);
  150. }
  151. });
  152. }
  153. },
  154. // 新增
  155. makeSure() {
  156. if (JSON.stringify(this.rowMap).length == 2) {
  157. this.$message.error("未选择江船");
  158. return;
  159. }
  160. let mapVal = {
  161. resultActualInstallations: this.form.resultActualInstallations,
  162. resultLoadShipDate: sjTime(this.form.resultLoadShipDate),
  163. resultIsClear: this.form.resultIsClear,
  164. resultArrivalTime: sjTime(this.form.resultArrivalTime),
  165. resultOutWharyName: this.form.resultOutWharyName,
  166. resultOutWharyTime: sjTime(this.form.resultOutWharyTime),
  167. resultMemo: this.form.resultMemo,
  168. //resultPlannedDate: sjTime(this.form.planDate),
  169. //expectNoticeDate: sjTime(this.form.expectNoticeDate),
  170. resultEmptyHeavyWaterMeter: this.form.resultEmptyHeavyWaterMeter,
  171. resultMoistureContent: this.resultMoistureContent,
  172. //resultInspectionFees: this.form.resultInspectionFees,
  173. contractMoistureValue: this.contractMoistureValue,
  174. moistureTonnage: this.moistureTonnage,
  175. waterUnitPrice:this.form.waterUnitPrice,
  176. unitPriceId:this.form.unitPriceId,
  177. //isNeedAssemble:this.form.isNeedAssemble,
  178. userId: getCookie("userId"),
  179. };
  180. console.log("mapVal:",mapVal);
  181. //判断放货数量是否为数字
  182. function isNumber() {
  183. var value = mapVal.resultActualInstallations;
  184. //验证是否为数字
  185. var patrn = /^(-)?\d+(\.\d+)?$/;
  186. if (patrn.exec(value) == null || value == "") {
  187. return false;
  188. } else {
  189. return true;
  190. }
  191. }
  192. var val = this.value;
  193. if (
  194. mapVal.resultActualInstallations == null ||
  195. mapVal.resultLoadShipDate == null ||
  196. mapVal.resultIsClear == null ||
  197. mapVal.resultArrivalTime == null ||
  198. mapVal.resultOutWharyName == null ||
  199. mapVal.resultOutWharyTime == null
  200. )
  201. this.$message.error("存在空值!");
  202. else if (!isNumber(val)) this.$message.warning("实装数量必须为数字!");
  203. else
  204. this.axios
  205. .post("/api/v1/tms/addLoadShip", {
  206. mapVal: mapVal,
  207. rowMap: this.rowMap,
  208. })
  209. .then((res) => {
  210. if (res.data.code == 200) {
  211. this.$message({
  212. type: "success",
  213. message: "新增成功!",
  214. });
  215. this.$router.go(-1);
  216. } else if (res.data.code == 201) {
  217. this.$message.warning(res.data.data);
  218. } else {
  219. this.$message.error("新增失败!");
  220. }
  221. this.$refs["table"].resetField();
  222. });
  223. // if (
  224. // mapVal.resultActualInstallations == null ||
  225. // // mapVal.portId==null||
  226. // mapVal.resultLoadShipDate == null ||
  227. // mapVal.resultIsClear == null ||
  228. // mapVal.resultPortDeclarationTime == null ||
  229. // mapVal.resultPortDeclarationName == null ||
  230. // mapVal.resultArrivalTime == null ||
  231. // mapVal.resultOutWharyName == null ||
  232. // mapVal.resultOutWharyTime == null
  233. // )
  234. // this.$message.error("存在空值!");
  235. // else if (!isNumber(val)) this.$message.warning("实装数量必须为数字!");
  236. // else
  237. },
  238. handleSelect(item) {
  239. console.log(item);
  240. },
  241. onclick() {
  242. this.option.requestUrl =
  243. "/api/v1/tms/getCapacityList?apiId=138&con=" + this.input;
  244. },
  245. },
  246. };
  247. </script>
  248. <style lang="scss">
  249. .shipTransport {
  250. .form {
  251. display: flex;
  252. .form_box {
  253. width: 320px;
  254. margin-left: 35%;
  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. .el-select {
  266. width: 250px;
  267. }
  268. .el-input {
  269. width: 250px;
  270. }
  271. }
  272. }
  273. }
  274. }
  275. }
  276. }
  277. .top {
  278. padding: 1.25rem 0.375rem;
  279. .el-input {
  280. width: 20%;
  281. margin-right: 1.25rem;
  282. }
  283. }
  284. .button_box_addLoadShip {
  285. margin-left: 45%;
  286. }
  287. }
  288. </style>