addTwoSectionHandleFee.vue 9.2 KB

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