warehouseReceiptAdd.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. //创建仓单
  2. <template>
  3. <div class="center">
  4. <el-row>
  5. <el-col :span="12">
  6. <h2 class="bg-left titleup">创建仓单</h2>
  7. </el-col>
  8. <el-col :span="12" class="bg-right">
  9. <el-button class="bg-bottom" type="primary" size="small" @click="cancel"><img width="6" height="10"
  10. style="vertical-align: bottom; margin-right: 3px" src="../../../public/img/lujing.png" alt="" />返回
  11. </el-button>
  12. </el-col>
  13. </el-row>
  14. <el-form :inline="true" ref="deptBudgetList" label-position="right" class="content2" :rules="rules"
  15. :model="deptBudgetList" label-width="120px">
  16. <div class="title1">申请信息</div>
  17. <!-- <ws-info-table class="el-table"> -->
  18. <el-form-item label="业务编号" prop="billNo" class="forlist">
  19. <el-col>
  20. <el-input v-model="deptBudgetList.billNo" placeholder="请输入任务编号" maxlength="20" size="small" disabled>
  21. </el-input>
  22. </el-col>
  23. </el-form-item>
  24. <el-form-item label="名头" prop="renown" class="forlist">
  25. <el-select v-model="deptBudgetList.renown" placeholder="请选择名头" @change="changeCompOptionList">
  26. <el-option :label="item.compName" :key="index" :value="item.compId" v-for="(item,index) in compOptionList">
  27. </el-option>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item label="仓库名称" prop="warehouseName" class="forlist">
  31. <el-select v-model="deptBudgetList.warehouseName" filterable placeholder="请选择仓库" @change="changeWarehouse">
  32. <el-option v-for="(item,index) in warehouseList" :key='index' :label="item.warehouseName" :value="item.id">
  33. </el-option>
  34. </el-select>
  35. </el-form-item>
  36. <el-form-item label="仓位号" prop="warehouseNo" class="forlist">
  37. <el-select v-model="deptBudgetList.warehouseNo" placeholder="请选择仓位号" @change="changeWarehouseNo">
  38. <el-option :label="item.binNumber" :value="item.id" v-for="(item,index) in cwNumberList" :key='index'>
  39. </el-option>
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item label="仓库地址" prop="warehouseAddress" class="forlist">
  43. <el-input disabled v-model="deptBudgetList.warehouseAddress" placeholder="请输入仓库地址" size="small"></el-input>
  44. </el-form-item>
  45. <el-form-item prop="goodsName" label="货名">
  46. <el-select v-model="deptBudgetList.goodsName" placeholder="请选择货名" @change="changeGoodsName">
  47. <el-option :label="item.goodsName" :value="item.id" v-for="(item,index) in goodsList" :key='index' >
  48. </el-option>
  49. </el-select>
  50. </el-form-item>
  51. <el-form-item prop="grade" label="品级">
  52. <el-select v-model="deptBudgetList.grade" placeholder="请选择品级">
  53. <el-option label="一等" value="一等"></el-option>
  54. <el-option label="二等" value="二等"></el-option>
  55. <el-option label="三等" value="三等"></el-option>
  56. <el-option label="等外" value="等外"></el-option>
  57. </el-select>
  58. </el-form-item>
  59. <el-form-item label="现有储量" prop="nowWeight" class="forlist">
  60. <el-input disabled v-model="deptBudgetList.nowWeight" placeholder="请输入现有储量" size="small"></el-input>
  61. </el-form-item>
  62. <el-form-item label="可用储量(吨)" prop="useWeight" class="forlist">
  63. <el-input disabled v-model="deptBudgetList.useWeight" placeholder="请输入可用储量" size="small"></el-input>
  64. </el-form-item>
  65. <el-form-item label="本单重量(吨)" prop="weight" class="forlist">
  66. <el-input v-model="deptBudgetList.weight" placeholder="输入本次仓单申请所需的重量" size="small" @input='inputChange'>
  67. </el-input>
  68. </el-form-item>
  69. <el-form-item label="单价(元/吨)" prop="unitPrice" class="forlist">
  70. <el-input v-model="deptBudgetList.unitPrice" placeholder="输入粮食单价" size="small" @input='inputChange'></el-input>
  71. </el-form-item>
  72. <el-form-item label="总价值(元)" prop="totalValue" class="forlist">
  73. <el-input disabled v-model="deptBudgetList.totalValue" placeholder="自动计算,不可编辑" size="small"></el-input>
  74. </el-form-item>
  75. <el-form-item label="申请比例(%)" prop="applicationProportion" class="forlist">
  76. <el-input v-model="deptBudgetList.applicationProportion" placeholder="输入申请比例" size="small"></el-input>
  77. </el-form-item>
  78. <el-form-item label="申请金额(元)" prop="interest" class="forlist">
  79. <el-input v-model="deptBudgetList.interest" placeholder="输入申请金额" size="small"></el-input>
  80. </el-form-item>
  81. <div>附件</div>
  82. <ws-upload ref="upload" :comp-id="compId" :appendix-ids="deptBudgetList.appendix" :size-limit="size"
  83. @onChange="onChange" accept=".jpg, .jpeg, .png, .pdf, .doc, .zip, .rar" />
  84. <div>外审部门</div>
  85. <el-form-item prop="bank" label="银行">
  86. <el-select v-model="deptBudgetList.bank" placeholder="请选择银行" @change="bankChange">
  87. <el-option :label="item.constValue" :value="item.constValue" v-for="(item,index) in bankList" :key="index"></el-option>
  88. </el-select>
  89. </el-form-item>
  90. <el-form-item label="第三方" span="1" prop="three" class="forlist">
  91. <el-select v-model="deptBudgetList.three" placeholder="无" @change="threeChange">
  92. <el-option :label="item1.constValue" :value="item1.constValue" v-for="(item1,index) in threeList" :key="index"></el-option>
  93. <!-- <el-option label="第三方2" value="three2"></el-option> -->
  94. </el-select>
  95. </el-form-item>
  96. <div>
  97. <el-button @click='inoutput' type="primary">出入库记录</el-button>
  98. <el-button @click='submit' type="primary">提交审核</el-button>
  99. </div>
  100. <!-- </ws-info-table> -->
  101. </el-form>
  102. </div>
  103. </template>
  104. <script>
  105. import {
  106. getcompList,
  107. } from '@/model/signIn/index'
  108. import {
  109. addList,
  110. getbillno,
  111. WarehouseReceiptBankList,
  112. } from '@/model/tradeServicesManagement/index'
  113. import {
  114. selectWarehouseSelf,
  115. } from '@/model/houseSelfCollect/index'
  116. import WsUpload from '@/components/WsUpload'
  117. export default {
  118. components: {
  119. WsUpload,
  120. },
  121. data() {
  122. return {
  123. deptBudgetList: {
  124. warehouseName: '',
  125. warehouseNo: '',
  126. compId: '',
  127. renown: '',
  128. grade: '',
  129. bank: '',
  130. three: '',
  131. goodsName:"",
  132. },
  133. size: 10,
  134. compId: '',
  135. warehouseList: [],
  136. compOptionList: [],
  137. cwNumberList: [],
  138. goodsList: [],
  139. rules: {
  140. // unitPrice: [
  141. // { required: true, message: '单价不能为空!', trigger: 'blur' },
  142. // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
  143. // ],
  144. },
  145. bankList:[],
  146. threeList:[],
  147. }
  148. },
  149. activated() {
  150. this.compId = localStorage.getItem('ws-pf_compId')
  151. this.deptBudgetList.compId = this.compId
  152. let i = localStorage.getItem("pageUp")
  153. if(i != 1){
  154. this.getcompList()
  155. this.getList()
  156. }
  157. },
  158. methods: {
  159. inputChange(e) {
  160. if (this.deptBudgetList.unitPrice && this.deptBudgetList.weight) {
  161. this.deptBudgetList.totalValue = this.deptBudgetList.unitPrice * this.deptBudgetList.weight
  162. }
  163. },
  164. //银行改变
  165. bankChange(e){
  166. this.deptBudgetList.bank = e
  167. },
  168. //第三方
  169. threeChange(e){
  170. this.deptBudgetList.three = e
  171. },
  172. getList() {
  173. // this.deptBudgetList.grade = '二等'
  174. WarehouseReceiptBankList({constId:"BANK1"}).toPromise().then((response) => {
  175. this.bankList = response
  176. })
  177. WarehouseReceiptBankList({constId:"THREE1"}).toPromise().then((response) => {
  178. this.threeList = response
  179. })
  180. // 获取业务编号
  181. getbillno().toPromise().then((response) => {
  182. this.deptBudgetList.billNo = response
  183. })
  184. // this.getWarehouse()
  185. },
  186. getcompList() {
  187. //获取公司名头
  188. getcompList()
  189. .toPromise()
  190. .then((res) => {
  191. this.compOptionList = res
  192. this.deptBudgetList.renown = res[0].compName
  193. this.changeCompOptionList(res[0].compId)
  194. })
  195. .catch((err) => {})
  196. },
  197. getWarehouse() {
  198. //获取仓库
  199. selectWarehouseSelf({
  200. compId: this.compId
  201. }).toPromise()
  202. .then(response => {
  203. this.warehouseList = response
  204. this.deptBudgetList.warehouseName = response[0].warehouseName
  205. this.deptBudgetList.warehouseAddress = response[0].warehousePrivate + response[0].warehouseCity + response[0].warehouseArea + response[0].detailedAddress
  206. if(response[0].positionInfos){
  207. this.deptBudgetList.warehouseNoId = response[0].positionInfos.length != 0 ? response[0].positionInfos[0].id : ''
  208. this.cwNumberList = response[0].positionInfos
  209. this.deptBudgetList.warehouseNo = response[0].positionInfos.length != 0 ? response[0].positionInfos[0].binNumber : ''
  210. this.deptBudgetList.baseId = response[0].positionInfos.length != 0 ? response[0].positionInfos[0].baseId : ''
  211. }
  212. if(response[0].goodsNameInfos){
  213. this.goodsList = []
  214. for(let i = 0 ; i < response[0].goodsNameInfos.length ; i++){
  215. if(response[0].goodsNameInfos[i].binNumber == this.deptBudgetList.warehouseNo ){
  216. this.goodsList.push(response[0].goodsNameInfos[i])
  217. }
  218. }
  219. if(this.goodsList.length > 0 ){
  220. this.deptBudgetList.nowWeight = response[0].goodsNameInfos.length != 0 ? response[0].goodsNameInfos[0].storage : ''
  221. this.deptBudgetList.useWeight = response[0].goodsNameInfos[0].useStorage
  222. this.deptBudgetList.goodsName = this.goodsList[0].goodsName
  223. this.deptBudgetList.goodsNameKey = response[0].goodsNameInfos.length != 0 ? response[0].goodsNameInfos[0].goodsNameKey : ''
  224. }else {
  225. this.deptBudgetList.nowWeight = ""
  226. this.deptBudgetList.useWeight = ""
  227. this.deptBudgetList.goodsName =""
  228. this.deptBudgetList.goodsNameKey = ""
  229. }
  230. }
  231. this.deptBudgetList.warehouseId = response[0].id
  232. if (!this.deptBudgetList.renown) this.deptBudgetList.renown = this.compOptionList[0].compName
  233. if (!this.deptBudgetList.renownId) this.deptBudgetList.renownId = this.compOptionList[0].compId
  234. })
  235. },
  236. //货名切换
  237. changeGoodsName(val) {
  238. let _data = this.goodsList
  239. for (let i = 0; i < _data.length; i++) {
  240. if (_data[i].id == val) {
  241. this.deptBudgetList.goodsNameKey = _data[i].goodsNameKey
  242. this.deptBudgetList.goodsName = _data[i].goodsName
  243. this.deptBudgetList.nowWeight = _data[i].storage
  244. this.deptBudgetList.useWeight = _data[i].useStorage
  245. return
  246. }
  247. }
  248. },
  249. //银行切换
  250. changeBank(val) {
  251. this.deptBudgetList.bankId = 'changebankId'
  252. },
  253. //第三方切换
  254. changeThree(val) {
  255. this.deptBudgetList.threeId = 'changethreeId'
  256. },
  257. //仓位号切换
  258. changeWarehouseNo(val) {
  259. let _data = this.cwNumberList
  260. for (let i = 0; i < _data.length; i++) {
  261. if (_data[i].id == val) {
  262. this.deptBudgetList.warehouseNoId = _data[i].id
  263. this.deptBudgetList.warehouseNo = _data[i].binNumber
  264. this.deptBudgetList.baseId = _data.baseId
  265. }
  266. }
  267. this.goodsList = []
  268. for(let j = 0 ; j < this.warehouseList.length ; j++){
  269. if(this.deptBudgetList.warehouseName == this.warehouseList[j].warehouseName){
  270. for(let _num = 0 ; _num < this.warehouseList[j].goodsNameInfos.length; _num++ ){
  271. if( this.deptBudgetList.warehouseNo == this.warehouseList[j].goodsNameInfos[_num].binNumber){
  272. this.goodsList.push(this.warehouseList[j].goodsNameInfos[_num])
  273. }
  274. }
  275. }
  276. }
  277. if(this.goodsList.length == 0){
  278. this.deptBudgetList.goodsName = ""
  279. }else{
  280. this.deptBudgetList.goodsName = this.goodsList[0].goodsName
  281. }
  282. },
  283. // 名头切换
  284. changeCompOptionList(val) {
  285. let _data = this.compOptionList
  286. for (let i = 0; i < _data.length; i++) {
  287. if (_data[i].compId == val) {
  288. this.deptBudgetList.renownId = _data[i].compId
  289. this.deptBudgetList.renown = _data[i].compName
  290. this.compId = val
  291. this.getWarehouse()
  292. }
  293. }
  294. },
  295. //仓库切换
  296. changeWarehouse(val) {
  297. console.log('切换后仓库数据', val)
  298. let _data = this.warehouseList
  299. for (let i = 0; i < _data.length; i++) {
  300. if (_data[i].id == val) {
  301. this.deptBudgetList.warehouseName = _data[i].warehouseName
  302. this.cwNumberList = _data[i].positionInfos.length != 0 ? _data[i].positionInfos : []
  303. this.deptBudgetList.warehouseNo = _data[i].positionInfos.length != 0 ? _data[i].positionInfos[0].binNumber : ''
  304. this.deptBudgetList.warehouseAddress = _data[i].warehousePrivate + _data[i].warehouseCity + _data[i].warehouseArea + _data[i].detailedAddress
  305. // this.goodsList = _data[i].goodsNameInfos.length != 0 ? _data[i].goodsNameInfos : []
  306. this.deptBudgetList.nowWeight = _data[i].goodsNameInfos.length != 0 ? _data[i].goodsNameInfos[0].storage : ''
  307. this.deptBudgetList.useWeight =_data[i].goodsNameInfos.length!=0?_data[i].goodsNameInfos[0].useStorage:''
  308. this.deptBudgetList.goodsName = _data[i].goodsNameInfos.length != 0 ? _data[i].goodsNameInfos[0].goodsName : ''
  309. this.deptBudgetList.warehouseId = _data[i].id
  310. this.deptBudgetList.goodsNameKey = _data[i].goodsNameInfos.length != 0 ? _data[i].goodsNameInfos[0].goodsNameKey : ''
  311. this.deptBudgetList.warehouseNoId = _data[i].positionInfos.length != 0 ? _data[i].positionInfos[0].id : ''
  312. this.deptBudgetList.baseId = _data[i].positionInfos.length != 0 ? _data[i].positionInfos[0].baseId : ''
  313. }
  314. }
  315. this.changeWarehouseNo(this.deptBudgetList.warehouseId)
  316. },
  317. inoutput() {
  318. this.$router.push({
  319. name: 'inOutRecord',
  320. query: {
  321. baseId: this.deptBudgetList.baseId,
  322. positionId: this.deptBudgetList.warehouseNoId,
  323. warehouseName: this.deptBudgetList.warehouseName,
  324. warehouseNo:this.deptBudgetList.warehouseNo,
  325. nowWeight:this.deptBudgetList.nowWeight
  326. }
  327. })
  328. },
  329. validate() {
  330. function _Validate(min, max, saveNum, type, inputVal) {
  331. let _val1 = inputVal
  332. let _pointVal1 = _val1.toString().split('.')[1]
  333. if (_pointVal1 == undefined) _pointVal1 = 0
  334. if (typeof(_pointVal1) == 'string') _pointVal1 = _pointVal1.length
  335. if (Number(_val1) <= Number(max) && Number(_val1) >= Number(min) && _pointVal1 <= saveNum) {
  336. return false
  337. }
  338. return true
  339. }
  340. if (!this.deptBudgetList.weight || _Validate(0, this.deptBudgetList.useWeight, 3, '', this.deptBudgetList
  341. .weight)) {
  342. if (!this.deptBudgetList.weight) {
  343. this.$message.error('本单重量不能为空!');
  344. } else {
  345. this.$message.error('本单重量输入错误且本单重量不可超过可用重量!');
  346. }
  347. return false
  348. }
  349. if (!this.deptBudgetList.unitPrice || _Validate(1, 20000, 3, '', this.deptBudgetList
  350. .unitPrice)) {
  351. if (!this.deptBudgetList.unitPrice) {
  352. this.$message.error('单价不能为空!');
  353. } else {
  354. this.$message.error('单价输入错误,1-20000之间,最多保留3位小数!');
  355. }
  356. return false
  357. }
  358. if (!this.deptBudgetList.totalValue) {
  359. this.$message.error('总价值不能为空!');
  360. return false
  361. }
  362. if (!this.deptBudgetList.applicationProportion || _Validate(10, 100, 2, '', this.deptBudgetList
  363. .applicationProportion)) {
  364. if (!this.deptBudgetList.applicationProportion) {
  365. this.$message.error('申请比例不能为空!');
  366. } else {
  367. this.$message.error('申请比例输入错误,10-100之间,最多保留2位小数!');
  368. }
  369. return false
  370. }
  371. if (!this.deptBudgetList.interest || _Validate(1, 1000000000, 2, '', this.deptBudgetList
  372. .interest)) {
  373. if (!this.deptBudgetList.interest) {
  374. this.$message.error('申请金额不能为空!');
  375. } else {
  376. this.$message.error('申请金额输入错误,1-10亿之间,最多保留2位小数!');
  377. }
  378. return false
  379. }
  380. if (!this.deptBudgetList.appendix) {
  381. this.$message.error('附件不能为空!');
  382. return false
  383. } else if (this.deptBudgetList.appendix.split(',').length > 30) {
  384. this.$message.error('附件数量需小于30!');
  385. return false
  386. }
  387. if (!this.deptBudgetList.bank) {
  388. this.$message.error('银行不能为空!');
  389. return false
  390. }
  391. if (!this.deptBudgetList.three) {
  392. this.$message.error('第三方不能为空!')
  393. return false
  394. }
  395. return true
  396. },
  397. submit() {
  398. let isValidate = false
  399. isValidate = this.validate()
  400. if (isValidate) {
  401. this.$confirm(`确定提交审核?`, {
  402. cancelButtonText: '取消',
  403. confirmButtonText: '确定',
  404. type: 'warning',
  405. }).then(() => {
  406. addList(this.deptBudgetList).toPromise().then((response) => {
  407. // this.tableData = response.records
  408. localStorage.removeItem("pageUp")
  409. this.$message.success('提交成功')
  410. this.$router.push({
  411. path: 'warehouseReceiptRegulation'
  412. })
  413. }).catch((req) => {
  414. // this.tableData = response.records
  415. this.$message.error('提交失败')
  416. })
  417. })
  418. }
  419. },
  420. onChange() {
  421. this.$refs.upload
  422. .handleSaveBill()
  423. .then(async response => {
  424. this.deptBudgetList.appendix = response
  425. })
  426. .catch(res => {
  427. EventBus.$emit('error', (JSON.parse(res) || {}).message)
  428. this.$refs.upload.clearFiles()
  429. })
  430. },
  431. cancel() {
  432. localStorage.removeItem("pageUp")
  433. this.$router.push({
  434. path: 'warehouseReceiptRegulation'
  435. })
  436. },
  437. },
  438. }
  439. </script>
  440. <style lang="scss" scoped>
  441. /deep/.el-form-item__content {
  442. width: 400px;
  443. }
  444. /deep/.el-select {
  445. width: 100%;
  446. }
  447. .el-form {
  448. overflow: scroll;
  449. height: 94vh;
  450. }
  451. .bg-left {
  452. padding-left: 30px;
  453. }
  454. .bg-bottom {
  455. margin: 15px 0px;
  456. }
  457. .titleup {
  458. position: relative;
  459. }
  460. .titleup::before {
  461. content: '';
  462. display: inline-block;
  463. width: 5px;
  464. height: 30px;
  465. background: #5473e8;
  466. position: absolute;
  467. left: 0;
  468. }
  469. .bg-right {
  470. padding-right: 10px;
  471. text-align: right;
  472. }
  473. .center {
  474. background: #f6f7fc;
  475. }
  476. .content2 {
  477. background: white;
  478. // padding:0 200px;
  479. // text-align: center;
  480. padding-left: 40px;
  481. }
  482. .title1 {
  483. font-size: 20px;
  484. font-weight: 600;
  485. margin: 20px 0;
  486. }
  487. </style>