addTwoSectionHandleFee.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <!-- 添加二程船装卸费2-->
  3. <div class="addWagonLoad">
  4. <PageTitle>返回</PageTitle>
  5. <div class="form-box">
  6. <!-- <dil-form :formId="271" v-model="form1" ref="from1"></dil-form> -->
  7. <el-form v-model="form">
  8. <div class="searchSelect">
  9. <span class="text">批次</span>
  10. <el-input class="input" v-model="batchName" disabled> </el-input>
  11. <el-button class="button" type="primary" @click="ondrawer(5)">浏览</el-button>
  12. </div>
  13. <div class="searchSelect">
  14. <span class="text">单价</span>
  15. <el-input class="input" v-model="form.unitPrice" @change="calculate"> </el-input>
  16. </div>
  17. <div class="preview-group">
  18. <el-form-item label="实装吨位">
  19. <el-input v-model="form.realTonnage" type="number" @change="calculate"></el-input>
  20. </el-form-item>
  21. <el-form-item label="水运费用">
  22. <el-input v-model="form.fee" type="number" disabled></el-input>
  23. </el-form-item>
  24. <el-form-item label="开票日期">
  25. <el-date-picker
  26. v-model="form.makeTime"
  27. type="datetime"
  28. placeholder="选择日期">
  29. </el-date-picker>
  30. </el-form-item>
  31. <el-form-item label="上传水运单图片">
  32. <el-upload
  33. class="upload-demo"
  34. style="width: 270px"
  35. ref="upload1"
  36. accept=".pdf , .jpg, .png, .jpeg, .tif, .gif, .pcx, .tga, .exif, .fpx, .svg , .bmp"
  37. action="/api/v1/bms/uploadBmsshipOrder"
  38. :before-upload="beforeUpload"
  39. :multiple="false"
  40. list-type="picture"
  41. :show-file-list="false"
  42. :on-success="handleAvatarSuccess"
  43. :on-error="onError(1)">
  44. <el-input
  45. class="shippingCertificate"
  46. style="width: 270px; display: flex"
  47. placeholder="上传水运单图片(必填项)"
  48. v-model="form.image"
  49. disabled
  50. >
  51. </el-input>
  52. <el-button
  53. size="small"
  54. type="primary"
  55. style="
  56. width: 115px;
  57. height: 35px;
  58. margin-left: 275px;
  59. margin-top: -35px;
  60. display: flex;
  61. "
  62. @click="upCLick(1)">
  63. 点击上传附件</el-button
  64. >
  65. </el-upload>
  66. </el-form-item>
  67. </div>
  68. </el-form>
  69. </div>
  70. <!-- 模态框 -->
  71. <el-drawer
  72. :visible.sync="drawer"
  73. :direction="direction"
  74. :before-close="handleClose"
  75. size="60%"
  76. >
  77. <el-input
  78. placeholder="请输入内容"
  79. v-model="input"
  80. style="margin-top: 10px; margin-left: 20px; width: 250px"
  81. clearable
  82. >
  83. </el-input>
  84. <el-button
  85. type="primary"
  86. class="btn"
  87. @click="onclick(a)"
  88. style="margin-bottom: 15px">
  89. <i class="el-icon-search"></i>查询
  90. </el-button>
  91. <div v-show="a == 5">
  92. <dilTable
  93. v-bind.sync="batchOption"
  94. @radio-change="batchChange"
  95. ></dilTable>
  96. </div>
  97. <div v-show="a == 6">
  98. <dilTable
  99. v-bind.sync="contractPriceOption"
  100. @radio-change="priceChange"
  101. ></dilTable>
  102. </div>
  103. </el-drawer>
  104. <!-- 底部按钮 -->
  105. <div class="button-box">
  106. <el-button @click="cancel">取消</el-button>
  107. <el-button type="primary" @click="makeSure" :loading="isLoading">确定</el-button>
  108. </div>
  109. </div>
  110. </template>
  111. <script>
  112. import PageTitle from "@/components/Page/Title";
  113. import { sjTime } from "@/utils/sharedJsFile";
  114. import { getCookie } from "@/utils/util.js";
  115. import {BigNumber} from 'bignumber.js';
  116. export default {
  117. components: { PageTitle },
  118. data() {
  119. return {
  120. form: {},
  121. portId:null,
  122. ports:[],
  123. isLoading:false,
  124. drawer: false,
  125. direction: "rtl",
  126. a:0,
  127. input:null,
  128. batchId:null,
  129. purchaseOrderId:null,
  130. batchName:null,
  131. cargoPictureUrl: "",
  132. batchOption: {
  133. requestUrl: "/api/v1/uc/getBatchOfNotice?apiId=513",
  134. selectionType: "radio",
  135. map: [],
  136. },
  137. contractPriceOption: {
  138. requestUrl: "/api/v1/rms/selectbmsshipContractPriceList?apiId=500",
  139. selectionType: "radio",
  140. map: [],
  141. }
  142. };
  143. },
  144. mounted() {
  145. //this.getPorts();
  146. },
  147. methods: {
  148. //右侧选中框
  149. ondrawer(num) {
  150. this.drawer = true;
  151. this.a = num;
  152. // 清空当前输入框中的数据
  153. this.input = "";
  154. },
  155. handleClose(done) {
  156. done();
  157. },
  158. onclick(a) {
  159. if(a==5){
  160. this.batchOption.requestUrl =
  161. "/api/v1/uc/getBatchOfNotice?apiId=513&index=" + this.input;
  162. }else if(a==6){
  163. this.contractPriceOption.requestUrl =
  164. "/api/v1/rms/selectbmsshipContractPriceList?apiId=500&con=" + this.input;
  165. }
  166. },
  167. //修改选中
  168. batchChange(selection) {
  169. console.log(selection);
  170. this.batchId=selection.batchId;
  171. this.purchaseOrderId=selection.purchaseOrderId;
  172. this.batchName =selection.materialName + selection.resultForeignShipName;
  173. },
  174. priceChange(selection){
  175. this.form.unitPriceId = selection.resultId;
  176. this.form.unitPrice = selection.unitPrice;
  177. this.calculate();
  178. },
  179. //计算水运费
  180. calculate(){
  181. console.log("能否计算水运费:",this.form.realTonnage && this.form.unitPrice);
  182. if(this.form.realTonnage && this.form.unitPrice){
  183. let fee = new BigNumber(this.form.realTonnage);
  184. this.$set(this.form,'fee',fee.multipliedBy(this.form.unitPrice).toNumber())
  185. console.log(this.form.fee);
  186. }
  187. },
  188. makeSure() {
  189. this.isLoading=true;
  190. let map={
  191. batchId:this.batchId,
  192. purchaseOrderId:this.purchaseOrderId,
  193. unitPrice:this.form.unitPrice,
  194. unitPriceId:this.form.unitPriceId,
  195. realTonnage:this.form.realTonnage,
  196. fee:this.form.fee,
  197. makeTime: sjTime(this.form.makeTime),
  198. image:this.form.image,
  199. feeType:2,
  200. userId:getCookie("userId")
  201. }
  202. console.log(map);
  203. if(map.batchId==null ||
  204. map.purchaseOrderId==null ||
  205. map.unitPrice==null ||
  206. map.realTonnage==null ||
  207. map.fee==null ||
  208. map.makeTime==null ||
  209. map.image==null || map.image==''
  210. ){
  211. this.$message.error("存在空值!");
  212. this.isLoading=false;
  213. }else{
  214. this.axios.post("/api/v1/bms/addPortHandlingFeeSecond",map).then(res => {
  215. if (res.data.code == 200) {
  216. this.$message({
  217. type: "success",
  218. message: "新增成功!"
  219. });
  220. this.cancel();
  221. } else {
  222. this.$message.error(res.data.data);
  223. }
  224. }).then(()=>{
  225. this.isLoading=false;
  226. });
  227. }
  228. },
  229. // 取消
  230. cancel() {
  231. this.$router.go(-1);
  232. },
  233. //查询港口id
  234. getPorts(){
  235. this.axios.post("/api/v1/rms/getPortName?index=").then(res => {
  236. if (res.data.code == 200) {
  237. this.ports=res.data.data;
  238. console.log(this.ports);
  239. } else {
  240. this.$message.error(res.data.data);
  241. }
  242. });
  243. },
  244. beforeUpload(file) {
  245. this.upBool = true;
  246. const isLt2M = file.size < 1024 * 1024 * 0.5;
  247. if (!isLt2M) {
  248. this.$message.error("上传文件大小不能超过500kb!");
  249. } else {
  250. let size = file.size / 1024;
  251. let _URL = window.URL || window.webkitURL;
  252. let img = new Image();
  253. img.src = _URL.createObjectURL(file);
  254. }
  255. return isLt2M;
  256. },
  257. onError(err) {
  258. if (this.upBool) {
  259. if (this.num == 1) {
  260. this.form.image = null;
  261. this.$message.error("上传失败");
  262. }
  263. }
  264. },
  265. handleAvatarSuccess(res, file) {
  266. if (res.code) {
  267. this.upBool = false;
  268. if (this.num == 1) {
  269. this.form.image = res.data;
  270. }
  271. this.$message.success("上传成功");
  272. }
  273. },
  274. upCLick(val) {
  275. this.num = val;
  276. },
  277. }
  278. };
  279. </script>
  280. <style lang="scss">
  281. .searchSelect {
  282. display: flex;
  283. align-items: center;
  284. justify-content: center;
  285. margin: 5px;
  286. .text {
  287. width: 40px;
  288. }
  289. .input {
  290. width: 200px;
  291. }
  292. .button {
  293. margin-left: 6px;
  294. }
  295. }
  296. .button-box {
  297. display: flex;
  298. justify-content: center;
  299. margin: 20px;
  300. .el-button {
  301. width: 80px;
  302. margin: 10px;
  303. }
  304. }
  305. .form-box {
  306. display: flex;
  307. justify-content: center;
  308. .el-form-item {
  309. display: flex;
  310. justify-content: center;
  311. .el-form-item__label {
  312. display: flex;
  313. align-items: center;
  314. }
  315. .el-form-item__content {
  316. .el-input {
  317. .el-input__inner {
  318. width: 250px;
  319. }
  320. }
  321. }
  322. }
  323. }
  324. </style>