warehouseManagementIoss.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. <template>
  2. <div class="container">
  3. <el-row>
  4. <el-col :span="20">
  5. <h2 class="bg-left title">&nbsp;&nbsp;盘损当期仓损</h2>
  6. </el-col>
  7. <el-col :span="4" class="bg-right">
  8. <el-button
  9. class="bg-bottom"
  10. type="primary"
  11. size="small"
  12. @click="returnWarehouse()"
  13. ><img
  14. width="6"
  15. height="10"
  16. style="vertical-align: bottom; margin-right: 3px"
  17. src="../../../public/img/lujing.png"
  18. alt=""
  19. />返回</el-button
  20. >
  21. </el-col>
  22. </el-row>
  23. <div class="center">
  24. <ws-form ref="deptBudgetList" :model="deptBudgetList" :rules="rules">
  25. <h2>
  26. {{ this.$route.query.warehouseName }}
  27. <span class="position"> {{ this.$route.query.binNumber }}仓位 </span>
  28. </h2>
  29. <!-- 货名 -->
  30. <ws-form-item
  31. label="货名:"
  32. span="1"
  33. prop="goodsName"
  34. class="goodsname"
  35. >
  36. <ws-select
  37. v-model="deptBudgetList.goodsName"
  38. placeholder=""
  39. class="typeselect"
  40. @change="changeioss"
  41. >
  42. <ws-option
  43. v-for="item in goodnameList"
  44. :key="item.constKey"
  45. :label="item.goodsName"
  46. :value="item.goodsName"
  47. />
  48. </ws-select>
  49. </ws-form-item>
  50. <!--当期累计入库量-->
  51. <ws-form-item
  52. label="当期累计入库量(吨):"
  53. span="1"
  54. prop="cumulativeStockIn"
  55. class="readonly"
  56. >
  57. {{ deptBudgetList.cumulativeStockIn }}
  58. </ws-form-item>
  59. <!--实际库存(吨)-->
  60. <ws-form-item
  61. label="实际库存(吨):"
  62. span="1"
  63. prop="physicalInventory"
  64. class="readonly"
  65. >
  66. <ws-input
  67. v-model="deptBudgetList.physicalInventory"
  68. placeholder=""
  69. maxlength="100"
  70. size="small"
  71. />
  72. </ws-form-item>
  73. <!--当期累计出库量(吨)-->
  74. <ws-form-item
  75. label="当期累计出库量(吨):"
  76. span="1"
  77. prop="cumulativeStockOut"
  78. class="readonly"
  79. >
  80. {{ deptBudgetList.cumulativeStockOut }}
  81. </ws-form-item>
  82. <!--损耗量(吨)-->
  83. <ws-form-item
  84. label="损耗量(吨):"
  85. span="1"
  86. prop="ioss"
  87. class="readonly"
  88. >
  89. {{ ioss1 > 0 ? ioss1 : 0 }}
  90. </ws-form-item>
  91. <!--应余库存(吨)-->
  92. <ws-form-item
  93. label="应余库存(吨):"
  94. span="1"
  95. prop="surplusInventory"
  96. class="readonly"
  97. >
  98. {{ surplusInventory1 > 0 ? surplusInventory1 : 0 }}
  99. </ws-form-item>
  100. <!--库损比例-->
  101. <ws-form-item
  102. label="库损比例:"
  103. span="1"
  104. prop="inventoryRatio"
  105. class="readonly"
  106. >
  107. <!-- .占比=损耗量÷(累计入库-实际库存) -->
  108. <span class="proportion" v-show="inventoryRatio1 > 3"
  109. >{{ inventoryRatio1 > 0 ? inventoryRatio1 : 0 }} {{ '‰' }}</span
  110. >
  111. <span class="proportion1" v-show="inventoryRatio1 < 3"
  112. >{{ inventoryRatio1 > 0 ? inventoryRatio1 : 0 }} {{ '‰' }}</span
  113. >
  114. </ws-form-item>
  115. <p class="fontsize">
  116. 注:提交成功后,当期实际库存将作为下一期的初始库存。
  117. </p>
  118. </ws-form>
  119. <div style="text-align: right; padding: 10px">
  120. <el-button
  121. class="bg-bottom-up"
  122. type="primary"
  123. size="small"
  124. @click="submit()"
  125. >提交</el-button
  126. >
  127. </div>
  128. </div>
  129. </div>
  130. </template>
  131. <script>
  132. import { goodsname, ioss, submitioss } from '@/model/warehouse/index'
  133. import Pagination from '@/components/Pagination'
  134. import WsUpload from '@/components/WsUpload'
  135. import { mapActions, mapGetters, mapState } from 'vuex'
  136. // import { dayjs, fmoney, EventBus } from 'base-core-lib'
  137. import { dayjs } from 'base-core-lib'
  138. export default {
  139. name: 'viewSpareMoney',
  140. components: {
  141. WsUpload,
  142. Pagination,
  143. },
  144. watch: {
  145. vesselId(val) {
  146. this.loaddata()
  147. },
  148. isShow(val) {
  149. this.showType = val
  150. },
  151. },
  152. data() {
  153. return {
  154. //弹出框
  155. dialogViewSpareMoney: false,
  156. dialogApproveFormVisible: false,
  157. // 船舶类型
  158. monetaryKey: null,
  159. // 表格显示数据
  160. tableDate: [],
  161. // 是否显示
  162. showType: true,
  163. // 年
  164. year: '',
  165. deptBudgetTotal: 0,
  166. currentPage: 1,
  167. pageSize: 10,
  168. searchType: 1,
  169. searchKeyWord: '',
  170. contractType: 2,
  171. startDate: null,
  172. endDate: null,
  173. // 提交类型
  174. submitType: true,
  175. selectpackingMethod: {},
  176. goodnameList: [],
  177. size: 10,
  178. compId: sessionStorage.getItem('ws-pf_compId'),
  179. deptCircularPage: {},
  180. packtypeList: {},
  181. deptBudgetList1: [],
  182. date: {
  183. year: dayjs().format('YYYY'),
  184. month: dayjs().format('MM'),
  185. },
  186. contractList: [],
  187. deptBudgetList: {
  188. physicalInventory: 0,
  189. },
  190. historyList: [],
  191. rules: {
  192. netWeight: [
  193. {
  194. required: true,
  195. type: 'number',
  196. message: '请输入活动名称',
  197. trigger: 'blur',
  198. },
  199. ],
  200. },
  201. pickerBeginDateBefore: {
  202. disabledDate: (time) => {
  203. return time.getTime() > Date.now()
  204. },
  205. },
  206. accessoryTFs: false,
  207. }
  208. },
  209. computed: {
  210. ...mapGetters([
  211. 'userInfo',
  212. 'isFullScren',
  213. 'tagWel',
  214. 'tagList',
  215. 'isCollapse',
  216. 'tag',
  217. 'logsLen',
  218. 'logsFlag',
  219. 'language',
  220. ]),
  221. ioss1: function () {
  222. return (
  223. this.deptBudgetList.cumulativeStockIn -
  224. this.deptBudgetList.cumulativeStockOut -
  225. this.deptBudgetList.physicalInventory
  226. )
  227. },
  228. surplusInventory1: function () {
  229. return (
  230. this.deptBudgetList.cumulativeStockIn -
  231. this.deptBudgetList.cumulativeStockOut
  232. )
  233. },
  234. inventoryRatio1: function () {
  235. var loss =
  236. this.deptBudgetList.cumulativeStockIn -
  237. this.deptBudgetList.cumulativeStockOut -
  238. this.deptBudgetList.physicalInventory
  239. var defect =
  240. this.deptBudgetList.cumulativeStockIn -
  241. this.deptBudgetList.physicalInventory
  242. if (loss / defect == 1) {
  243. var num = 0
  244. } else {
  245. // .占比=损耗量÷(累计入库-实际库存)
  246. num = Math.floor((loss / defect) * 1000000) / 1000
  247. }
  248. // this.deptBudgetList.inventoryRatio = this.deptBudgetList.inventoryRatio.toFixed(3)
  249. // this.deptBudgetList.inventoryRatio = num
  250. return num
  251. },
  252. },
  253. activated() {
  254. //cg.viewBudget
  255. //cg.viewSpareMoney
  256. // this.getVesselData();
  257. this.deptBudgetList.baseId = this.$route.query.baseId
  258. this.deptBudgetList.positionId = this.$route.query.positionId
  259. this.deptBudgetList.warehouseName = this.$route.query.warehouseName
  260. this.deptBudgetList.binNumber = this.$route.query.binNumber
  261. this.deptBudgetList1.warehouseName = this.$route.query.warehouseName
  262. this.deptBudgetList1.binNumber = this.deptBudgetList.binNumber
  263. this.deptBudgetList1.baseId = this.$route.query.baseId
  264. this.deptBudgetList1.positionId = this.deptBudgetList.positionId
  265. this.loaddata()
  266. this.showType = this.isShow
  267. },
  268. methods: {
  269. //返回按钮
  270. returnWarehouse() {
  271. this.deptBudgetList = {}
  272. this.$router.push({ path: 'warehouseManagementList' })
  273. },
  274. //提交按钮
  275. submit() {
  276. if (!this.deptBudgetList.goodsName) {
  277. this.$message({
  278. message: '货名不能为空!',
  279. type: 'warning',
  280. })
  281. return
  282. }
  283. if (!this.deptBudgetList.physicalInventory) {
  284. this.$message({
  285. message: '实际库存不能为空!',
  286. type: 'warning',
  287. })
  288. return
  289. }
  290. if (this.deptBudgetList.physicalInventory <= 0) {
  291. this.$message({
  292. message: '实际库存输入错误!',
  293. type: 'warning',
  294. })
  295. return
  296. }
  297. if (
  298. this.deptBudgetList.cumulativeStockIn -
  299. this.deptBudgetList.physicalInventory <=
  300. 0
  301. ) {
  302. return
  303. }
  304. this.$refs.deptBudgetList.validate((valid) => {
  305. if (valid) {
  306. this.deptBudgetList.surplusInventory =
  307. this.deptBudgetList.cumulativeStockIn -
  308. this.deptBudgetList.cumulativeStockOut
  309. this.deptBudgetList.loss =
  310. this.deptBudgetList.cumulativeStockIn -
  311. this.deptBudgetList.cumulativeStockOut -
  312. this.deptBudgetList.physicalInventory
  313. this.deptBudgetList.inventoryRatio =
  314. Math.floor(
  315. ((this.deptBudgetList.cumulativeStockIn -
  316. this.deptBudgetList.cumulativeStockOut -
  317. this.deptBudgetList.physicalInventory) /
  318. (this.deptBudgetList.cumulativeStockIn -
  319. this.deptBudgetList.physicalInventory)) *
  320. 1000000
  321. ) / 1000
  322. // this.deptBudgetList.inventoryRatio = inventoryRatio1
  323. this.deptBudgetList.baseId = this.deptBudgetList1.baseId
  324. this.deptBudgetList.positionId = this.deptBudgetList1.positionId
  325. this.deptBudgetList.binNumber = this.deptBudgetList1.binNumber
  326. this.deptBudgetList.warehouseName = this.deptBudgetList1.warehouseName
  327. this.deptBudgetList.qualityInspector = this.userInfo.showRoleName
  328. for (var i = 0; i < this.goodnameList.length; i++) {
  329. if (
  330. this.goodnameList[i].goodsName == this.deptBudgetList.goodsName
  331. ) {
  332. this.deptBudgetList.goodsNameKey =
  333. this.goodnameList[i].goodsNameKey
  334. }
  335. }
  336. this.deptBudgetList.compId = this.compId
  337. this.deptBudgetList.contractType = 1
  338. submitioss(this.deptBudgetList)
  339. .toPromise()
  340. .then((response) => {
  341. this.$message.success('提交成功')
  342. this.deptBudgetList = {}
  343. this.$router.push({ path: 'warehouseManagementList' })
  344. })
  345. } else {
  346. //EventBus.$emit('error', this.$t('showMessage.asteriskRequired'))
  347. return false
  348. }
  349. })
  350. },
  351. dateFormat(fmt, date) {
  352. let ret
  353. const opt = {
  354. 'Y+': date.getFullYear().toString(), // 年
  355. 'm+': (date.getMonth() + 1).toString(), // 月
  356. 'd+': date.getDate().toString(), // 日
  357. 'H+': date.getHours().toString(), // 时
  358. // "M+": date.getMinutes().toString(), // 分
  359. // "S+": date.getSeconds().toString() // 秒
  360. // 有其他格式化字符需求可以继续添加,必须转化成字符串
  361. }
  362. for (let k in opt) {
  363. ret = new RegExp('(' + k + ')').exec(fmt)
  364. if (ret) {
  365. fmt = fmt.replace(
  366. ret[1],
  367. ret[1].length == 1 ? opt[k] : opt[k].padStart(ret[1].length, '0')
  368. )
  369. }
  370. }
  371. return fmt
  372. },
  373. handleClose() {
  374. this.accessoryTFs = false
  375. },
  376. handleSizeChange(val) {
  377. console.log(`每页 ${val} 条`)
  378. this.pageSize = val
  379. this.getList()
  380. },
  381. handleCurrentChange(val) {
  382. this.currentPage = val
  383. console.log(`当前页: ${val}`)
  384. this.getList()
  385. },
  386. changeioss(e) {
  387. if (!this.deptBudgetList.baseId) {
  388. this.deptBudgetList.baseId = this.$route.query.baseId
  389. this.deptBudgetList.positionId = this.deptBudgetList1.positionId
  390. this.deptBudgetList.binNumber = this.deptBudgetList1.binNumber
  391. }
  392. for (var i = 0; i < this.goodnameList.length; i++) {
  393. if (this.goodnameList[i].goodsName == e) {
  394. this.deptBudgetList.goodsNameKey = this.goodnameList[i].goodsNameKey
  395. }
  396. }
  397. this.ioss()
  398. },
  399. ioss() {
  400. ioss({
  401. baseId: this.$route.query.baseId,
  402. positionId: this.$route.query.positionId,
  403. goodsNameKey: this.deptBudgetList.goodsNameKey,
  404. goodsName: this.deptBudgetList.goodsName,
  405. })
  406. .toPromise()
  407. .then((response) => {
  408. this.deptBudgetList = response
  409. })
  410. },
  411. loaddata() {
  412. // 货名
  413. goodsname({ positionId: this.$route.query.positionId })
  414. .toPromise()
  415. .then((response) => {
  416. this.goodnameList = response
  417. })
  418. },
  419. selecttaskType(e) {
  420. for (var i = 0; i < this.taskTypeList.length; i++) {
  421. if (this.taskTypeList[i].value == e) {
  422. this.searchType = this.taskTypeList[i].type
  423. }
  424. }
  425. },
  426. },
  427. }
  428. </script>
  429. <style lang="scss" scoped>
  430. .container {
  431. padding: 20px;
  432. }
  433. .center {
  434. top: 50px;
  435. width: 40%;
  436. height: 700px;
  437. margin: 0 auto;
  438. }
  439. /deep/.el-form-item__label {
  440. width: 160px;
  441. }
  442. /deep/.el-input--small {
  443. width: 70%;
  444. }
  445. /deep/.bg-right {
  446. padding-right: 10px;
  447. text-align: right;
  448. }
  449. .container .bg-bottom {
  450. margin: 15px 0px;
  451. }
  452. //仓位
  453. .position {
  454. background: #afb5cb;
  455. border-radius: 2px;
  456. font-size: 12px;
  457. color: #ffffff;
  458. line-height: 20px;
  459. display: inline-grid;
  460. padding: 2px 4px;
  461. }
  462. //表格
  463. .readonly {
  464. width: 49%;
  465. display: inline-flex;
  466. height: 40px;
  467. }
  468. /deep/.el-form-item__label {
  469. width: 170px;
  470. text-align: left;
  471. font-size: 14px;
  472. font-family: PingFangSC-Regular, PingFang SC;
  473. font-weight: 400;
  474. color: #8890b1;
  475. line-height: 16px;
  476. }
  477. //下拉框
  478. .goodsname {
  479. width: 40%;
  480. }
  481. .goodsname:first-child {
  482. width: 140px;
  483. }
  484. //注意字体
  485. .fontsize {
  486. width: 312px;
  487. height: 17px;
  488. font-size: 12px;
  489. font-family: PingFangSC-Regular, PingFang SC;
  490. font-weight: 400;
  491. color: #afb5cb;
  492. line-height: 17px;
  493. }
  494. //比例文字
  495. .proportion {
  496. color: #ff2c58;
  497. }
  498. .proportion1 {
  499. color: black;
  500. }
  501. .title {
  502. position: relative;
  503. }
  504. .title::before {
  505. content: '';
  506. display: inline-block;
  507. width: 5px;
  508. height: 30px;
  509. background: #5473e8;
  510. position: absolute;
  511. left: 0;
  512. }
  513. </style>