warehouseManagementIoss.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  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 = ((loss / defect)*100).toFixed(3)
  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. this.$message({
  303. message: '实际库存输入错误!',
  304. type: 'warning',
  305. })
  306. return
  307. }
  308. this.$refs.deptBudgetList.validate((valid) => {
  309. if (valid) {
  310. this.deptBudgetList.surplusInventory =
  311. this.deptBudgetList.cumulativeStockIn -
  312. this.deptBudgetList.cumulativeStockOut
  313. this.deptBudgetList.loss =
  314. this.deptBudgetList.cumulativeStockIn -
  315. this.deptBudgetList.cumulativeStockOut -
  316. this.deptBudgetList.physicalInventory
  317. this.deptBudgetList.inventoryRatio =
  318. Math.floor(
  319. ((this.deptBudgetList.cumulativeStockIn -
  320. this.deptBudgetList.cumulativeStockOut -
  321. this.deptBudgetList.physicalInventory) /
  322. (this.deptBudgetList.cumulativeStockIn -
  323. this.deptBudgetList.physicalInventory)) *
  324. 1000000
  325. ) / 1000
  326. // this.deptBudgetList.inventoryRatio = inventoryRatio1
  327. this.deptBudgetList.baseId = this.deptBudgetList1.baseId
  328. this.deptBudgetList.positionId = this.deptBudgetList1.positionId
  329. this.deptBudgetList.binNumber = this.deptBudgetList1.binNumber
  330. this.deptBudgetList.warehouseName = this.deptBudgetList1.warehouseName
  331. this.deptBudgetList.qualityInspector = this.userInfo.showRoleName
  332. for (var i = 0; i < this.goodnameList.length; i++) {
  333. if (
  334. this.goodnameList[i].goodsName == this.deptBudgetList.goodsName
  335. ) {
  336. this.deptBudgetList.goodsNameKey =
  337. this.goodnameList[i].goodsNameKey
  338. }
  339. }
  340. this.deptBudgetList.compId = this.compId
  341. this.deptBudgetList.contractType = 1
  342. submitioss(this.deptBudgetList)
  343. .toPromise()
  344. .then((response) => {
  345. this.$message.success('提交成功')
  346. this.deptBudgetList = {}
  347. this.$router.push({ path: 'warehouseManagementList' })
  348. })
  349. } else {
  350. //EventBus.$emit('error', this.$t('showMessage.asteriskRequired'))
  351. return false
  352. }
  353. })
  354. },
  355. dateFormat(fmt, date) {
  356. let ret
  357. const opt = {
  358. 'Y+': date.getFullYear().toString(), // 年
  359. 'm+': (date.getMonth() + 1).toString(), // 月
  360. 'd+': date.getDate().toString(), // 日
  361. 'H+': date.getHours().toString(), // 时
  362. // "M+": date.getMinutes().toString(), // 分
  363. // "S+": date.getSeconds().toString() // 秒
  364. // 有其他格式化字符需求可以继续添加,必须转化成字符串
  365. }
  366. for (let k in opt) {
  367. ret = new RegExp('(' + k + ')').exec(fmt)
  368. if (ret) {
  369. fmt = fmt.replace(
  370. ret[1],
  371. ret[1].length == 1 ? opt[k] : opt[k].padStart(ret[1].length, '0')
  372. )
  373. }
  374. }
  375. return fmt
  376. },
  377. handleClose() {
  378. this.accessoryTFs = false
  379. },
  380. handleSizeChange(val) {
  381. console.log(`每页 ${val} 条`)
  382. this.pageSize = val
  383. this.getList()
  384. },
  385. handleCurrentChange(val) {
  386. this.currentPage = val
  387. console.log(`当前页: ${val}`)
  388. this.getList()
  389. },
  390. changeioss(e) {
  391. if (!this.deptBudgetList.baseId) {
  392. this.deptBudgetList.baseId = this.$route.query.baseId
  393. this.deptBudgetList.positionId = this.deptBudgetList1.positionId
  394. this.deptBudgetList.binNumber = this.deptBudgetList1.binNumber
  395. }
  396. for (var i = 0; i < this.goodnameList.length; i++) {
  397. if (this.goodnameList[i].goodsName == e) {
  398. this.deptBudgetList.goodsNameKey = this.goodnameList[i].goodsNameKey
  399. }
  400. }
  401. this.ioss()
  402. },
  403. ioss() {
  404. ioss({
  405. baseId: this.$route.query.baseId,
  406. positionId: this.$route.query.positionId,
  407. goodsNameKey: this.deptBudgetList.goodsNameKey,
  408. goodsName: this.deptBudgetList.goodsName,
  409. })
  410. .toPromise()
  411. .then((response) => {
  412. this.deptBudgetList = response
  413. })
  414. },
  415. loaddata() {
  416. // 货名
  417. goodsname({ positionId: this.$route.query.positionId })
  418. .toPromise()
  419. .then((response) => {
  420. this.goodnameList = response
  421. })
  422. },
  423. selecttaskType(e) {
  424. for (var i = 0; i < this.taskTypeList.length; i++) {
  425. if (this.taskTypeList[i].value == e) {
  426. this.searchType = this.taskTypeList[i].type
  427. }
  428. }
  429. },
  430. },
  431. }
  432. </script>
  433. <style lang="scss" scoped>
  434. .container {
  435. padding: 20px;
  436. }
  437. .center {
  438. top: 50px;
  439. width: 40%;
  440. height: 700px;
  441. margin: 0 auto;
  442. }
  443. /deep/.el-form-item__label {
  444. width: 160px;
  445. }
  446. /deep/.el-input--small {
  447. width: 70%;
  448. }
  449. /deep/.bg-right {
  450. padding-right: 10px;
  451. text-align: right;
  452. }
  453. .container .bg-bottom {
  454. margin: 15px 0px;
  455. }
  456. //仓位
  457. .position {
  458. background: #afb5cb;
  459. border-radius: 2px;
  460. font-size: 12px;
  461. color: #ffffff;
  462. line-height: 20px;
  463. display: inline-grid;
  464. padding: 2px 4px;
  465. }
  466. //表格
  467. .readonly {
  468. width: 49%;
  469. display: inline-flex;
  470. height: 40px;
  471. }
  472. /deep/.el-form-item__label {
  473. width: 170px;
  474. text-align: left;
  475. font-size: 14px;
  476. font-family: PingFangSC-Regular, PingFang SC;
  477. font-weight: 400;
  478. color: #8890b1;
  479. line-height: 16px;
  480. }
  481. //下拉框
  482. .goodsname {
  483. width: 40%;
  484. }
  485. .goodsname:first-child {
  486. width: 140px;
  487. }
  488. //注意字体
  489. .fontsize {
  490. width: 312px;
  491. height: 17px;
  492. font-size: 12px;
  493. font-family: PingFangSC-Regular, PingFang SC;
  494. font-weight: 400;
  495. color: #afb5cb;
  496. line-height: 17px;
  497. }
  498. //比例文字
  499. .proportion {
  500. color: #ff2c58;
  501. }
  502. .proportion1 {
  503. color: black;
  504. }
  505. .title {
  506. position: relative;
  507. }
  508. .title::before {
  509. content: '';
  510. display: inline-block;
  511. width: 5px;
  512. height: 30px;
  513. background: #5473e8;
  514. position: absolute;
  515. left: 0;
  516. }
  517. </style>