edit.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949
  1. <template>
  2. <view class="mainBox" :class="{ isOut: activeName === 'output' }">
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. title="调拨明细"
  8. @clickLeft="back"
  9. v-if="navShow"
  10. >
  11. <template slot="right"
  12. ><text class="text-danger" @click="handleDelete" v-if="id"
  13. >删除调拨</text
  14. ></template
  15. >
  16. </uni-nav-bar>
  17. <view class="tool-wrapper">
  18. <view class="flex-center">
  19. <!-- <text>调拨单号 {{ formData.dialNumber }}</text> -->
  20. <view class="flex-center">
  21. <text>调拨条数 {{ assetsList.length + preAssetsList.length }}</text>
  22. </view>
  23. <text class="btn required" @click="$refs.typeSettingRef.open(formData)"
  24. >调拨类型设置</text
  25. ></view
  26. >
  27. <view class="flex-center info">
  28. <text class=""
  29. >调拨类型:{{
  30. formData.dialType == 1 ? '库内调拨' : '库外调拨'
  31. }}</text
  32. >
  33. </view>
  34. <view class="flex-center info">
  35. <text>调出仓库:{{ formData.warehouseName }}</text>
  36. <text>调入仓库:{{ formData.inWarehouseName }}</text>
  37. </view>
  38. <view class="tabs">
  39. <view
  40. class="tab-item"
  41. :class="{ active: activeName === 'output' }"
  42. @click="activeName = 'output'"
  43. >待调出({{ assetsList.length }})</view
  44. >
  45. <view
  46. class="tab-item"
  47. :class="{ active: activeName === 'input' }"
  48. @click="activeName = 'input'"
  49. >预调入({{ preAssetsList.length }})</view
  50. >
  51. </view>
  52. <template v-if="activeName === 'output'">
  53. <view class="operations flex-center">
  54. <text @click="handleScan">扫码添加</text>
  55. <text @click="handleWarehouseChoose('output')">手动添加</text>
  56. <text @click="handleWarehouseChoose('input')">调入货位</text>
  57. <!-- <text @click="deleteMaterial">删除选中</text> -->
  58. </view>
  59. <view class="search-box">
  60. <uni-easyinput
  61. prefixIcon="search"
  62. v-model="outputFilter"
  63. placeholder="编码、名称、货位"
  64. >
  65. </uni-easyinput>
  66. </view>
  67. <!-- <view class="select-box flex-center">
  68. <text
  69. >已选{{ assetsList.filter(i => i.checked).length }}/{{
  70. assetsList.length
  71. }}</text
  72. >
  73. <text class="btn" @click="assetsSelectAll = !assetsSelectAll"
  74. >全选</text
  75. >
  76. </view> -->
  77. </template>
  78. <template v-else>
  79. <view class="operations">
  80. <text @click="removeOutput" style="margin-right: 20rpx"
  81. >移除选中</text
  82. >
  83. <text @click="deleteOutput">删除选中</text>
  84. </view>
  85. <view class="search-box">
  86. <uni-easyinput
  87. prefixIcon="search"
  88. v-model="inputFilter"
  89. placeholder="编码、名称、货位"
  90. >
  91. </uni-easyinput>
  92. </view>
  93. <view class="select-box flex-center">
  94. <text
  95. >已选 {{ preAssetsList.filter(i => i.inputChecked).length }}/{{
  96. preAssetsList.length
  97. }}</text
  98. >
  99. <text class="btn" @click="preAssetsSelectAll = !preAssetsSelectAll"
  100. >全选</text
  101. >
  102. </view>
  103. </template>
  104. </view>
  105. <view class="list-container" v-if="activeName === 'output'">
  106. <AssetsCard
  107. v-for="(item, index) in assetsListRender"
  108. :key="index"
  109. :item="item"
  110. @deleteItem="deleteItem(item)"
  111. type="output"
  112. ></AssetsCard>
  113. </view>
  114. <view class="list-container" v-if="activeName === 'input'">
  115. <AssetsCard
  116. v-for="(item, index) in preAssetsListRender"
  117. :key="index"
  118. :item="item"
  119. type="input"
  120. ></AssetsCard>
  121. </view>
  122. <u-button
  123. type="success"
  124. class="preview-box"
  125. :plain="true"
  126. @click="handlePreview"
  127. >预览</u-button
  128. >
  129. <WarehouseChoose ref="warehouseChooseRef" :selfClose="true" />
  130. <CargoSpaceInfoDialog
  131. ref="cargoSpaceInfoDialogRef"
  132. @cancel="navShow = true"
  133. @success="cargoSpaceInfoConfirm"
  134. :assetsList="assetsList"
  135. :preAssetsList="preAssetsList"
  136. />
  137. <TypeSetting ref="typeSettingRef" @getPopupInfo="getPopupInfo" />
  138. <PreInventory ref="preInventoryRef" />
  139. <!-- <ScanCode @scancodedate="scancodedate"></ScanCode> -->
  140. </view>
  141. </template>
  142. <script>
  143. import ScanCode from '@/components/ScanCode.vue'
  144. import PreInventory from './components/PreInventory'
  145. import AssetsCard from './components/AssetsCard'
  146. import TypeSetting from './components/TypeSetting'
  147. import WarehouseChoose from '@/components/WarehouseChoose'
  148. import CargoSpaceInfoDialog from './components/CargoSpaceInfoDialog'
  149. import { get, postJ } from '@/utils/api.js'
  150. export default {
  151. components: {
  152. TypeSetting,
  153. ScanCode,
  154. PreInventory,
  155. AssetsCard,
  156. WarehouseChoose,
  157. CargoSpaceInfoDialog
  158. },
  159. data () {
  160. return {
  161. searchVal: '',
  162. activeName: 'output',
  163. formData: {
  164. // dialNumber: getRuleNo('ALLOT'),
  165. dialType: 1,
  166. warehouseId: '',
  167. warehouseName: '',
  168. inWarehouseId: '',
  169. inWarehouseName: '',
  170. deptCode: '',
  171. deptName: '',
  172. verifyId: '',
  173. verifyName: ''
  174. },
  175. assetsList: [], //已选资产列表
  176. preAssetsList: [], //预调入资产列表
  177. inputFilter: '',
  178. outputFilter: '',
  179. navShow: true,
  180. isCamera: false,
  181. id: ''
  182. }
  183. },
  184. onLoad (options) {
  185. if (options.id) {
  186. this.id = options.id
  187. this._getDetail(options.id)
  188. }
  189. },
  190. onShow () {
  191. const _this = this
  192. uni.$off('inventoryAllocationScanView') // 每次进来先 移除全局自定义事件监听器
  193. uni.$on('inventoryAllocationScanView', function (data) {
  194. _this.setScanMaterial(data)
  195. })
  196. console.log('onShow')
  197. uni.$off('scancodedate') // 每次进来先 移除全局自定义事件监听器
  198. uni.$on('scancodedate', function (data) {
  199. _this.scancodedate(data)
  200. })
  201. },
  202. onUnload () {
  203. uni.$off('scancodedate')
  204. },
  205. onHide () {
  206. uni.$off('scancodedate')
  207. },
  208. computed: {
  209. assetsSelectAll: {
  210. set (val) {
  211. this.assetsList.forEach(item => {
  212. item.checked = val
  213. })
  214. return val
  215. },
  216. get () {
  217. return !this.assetsList.some(item => !item.checked)
  218. }
  219. },
  220. preAssetsSelectAll: {
  221. set (val) {
  222. this.preAssetsList.forEach(item => {
  223. item.inputChecked = val
  224. })
  225. return val
  226. },
  227. get () {
  228. return !this.preAssetsList.some(item => !item.inputChecked)
  229. }
  230. },
  231. // 做前端过滤 编码areaName、名称assetCode、货位shelfCode、批次
  232. assetsListRender () {
  233. return this.assetsList.filter(
  234. ({
  235. assetName = '',
  236. assetCode = '',
  237. outWarehouseAreaName = '',
  238. outWarehouseAreaGoodsCode = '',
  239. outGoodsAllocationCode = ''
  240. }) => {
  241. if (this.outputFilter) {
  242. if (
  243. assetName.indexOf(this.outputFilter) !== -1 ||
  244. assetCode.indexOf(this.outputFilter) !== -1 ||
  245. outWarehouseAreaName.indexOf(this.outputFilter) !== -1 ||
  246. outWarehouseAreaGoodsCode.indexOf(this.outputFilter) !== -1 ||
  247. outGoodsAllocationCode.indexOf(this.outputFilter) !== -1
  248. ) {
  249. return true
  250. }
  251. return false
  252. }
  253. return true
  254. }
  255. )
  256. },
  257. // 做前端过滤 编码、名称、货位、批次
  258. preAssetsListRender () {
  259. return this.preAssetsList.filter(
  260. ({
  261. areaName = '',
  262. assetCode = '',
  263. inWarehouseAreaName = '',
  264. inWarehouseAreaGoodsCode = '',
  265. inGoodsAllocationCode = ''
  266. }) => {
  267. if (this.inputFilter) {
  268. if (
  269. areaName.indexOf(this.inputFilter) !== -1 ||
  270. assetCode.indexOf(this.inputFilter) !== -1 ||
  271. inWarehouseAreaName.indexOf(this.inputFilter) !== -1 ||
  272. inWarehouseAreaGoodsCode.indexOf(this.inputFilter) !== -1 ||
  273. inGoodsAllocationCode.indexOf(this.inputFilter) !== -1
  274. ) {
  275. return true
  276. }
  277. return false
  278. }
  279. return true
  280. }
  281. )
  282. }
  283. },
  284. methods: {
  285. scancodedate (data) {
  286. this.qrContent = data.code.trim()
  287. this.getData()
  288. },
  289. handleScan () {
  290. const _this = this
  291. uni.scanCode({
  292. onlyFromCamera: true,
  293. success: function (res) {
  294. console.log('条码类型:' + res.scanType)
  295. console.log('条码内容:' + res.result)
  296. _this.isCamera = true
  297. _this.qrContent = res.result.trim()
  298. _this.getData()
  299. }
  300. })
  301. },
  302. // 根据条码请求设备数据 @_@
  303. getData () {
  304. if (!this.formData.warehouseId) {
  305. uni.showToast({
  306. title: '请设置调拨类型!',
  307. icon: 'none'
  308. })
  309. return
  310. }
  311. let par = {
  312. barType: this.qrContent.split('@_@')[1] || 0,
  313. qrContent: this.qrContent
  314. }
  315. uni.showLoading({
  316. title: '加载中',
  317. mask: true
  318. })
  319. postJ(this.apiUrl + '/scan/getAssetInfo', par)
  320. .then(res => {
  321. let data = res.data
  322. console.log(data, 'qrContent')
  323. if (data.assetType === undefined) {
  324. uni.showToast({
  325. title: '请扫码物品码',
  326. icon: 'none'
  327. })
  328. return
  329. } else if (data?.warehouseDetail?.bizStatus != 1) {
  330. uni.showModal({
  331. title: '提示',
  332. content: `当前物品不在仓库内`,
  333. success: async res => {}
  334. })
  335. return
  336. } else if (data.underApproval) {
  337. uni.showModal({
  338. title: '提示',
  339. content: `【${data.assetCode}】正在待审批单据中`,
  340. success: async res => {}
  341. })
  342. return
  343. } else if (data.information.takeStockPattern) {
  344. uni.showModal({
  345. title: '提示',
  346. content:
  347. '该物品为批量盘点模式,不可扫码。如需扫码,请将该物品类型在物品信息表中修改为逐个模式。',
  348. success: async res => {}
  349. })
  350. return
  351. } else if (
  352. data.warehouseDetail?.warehouseId !== this.formData.warehouseId
  353. ) {
  354. uni.showToast({
  355. title: `请选择${this.formData.warehouseName}仓库下的物品`,
  356. icon: 'none'
  357. })
  358. return
  359. }
  360. uni.setStorageSync('inventoryAllocationScan', data)
  361. uni.navigateTo({
  362. url: '/pages/warehouse/inventoryAllocation/scanView?emitName=inventoryAllocationScanView&key=inventoryAllocationScan'
  363. })
  364. })
  365. .finally(() => {
  366. uni.hideLoading()
  367. })
  368. },
  369. setScanMaterial (data) {
  370. console.log(data, '--------------------')
  371. const curMap = {
  372. assetId: 'id',
  373. assetCode: 'informationCode', //编码
  374. assetName: 'informationName', //名称
  375. materialId: 'id',
  376. materialName: 'informationName',
  377. batchNo: 'batchNum', //批次号
  378. unit: 'measuringUnit', //单位
  379. minPackUnit: 'packingUnit' //最小包装单位
  380. }
  381. let detail = {}
  382. for (const key in curMap) {
  383. detail[key] = (curMap[key] && data.information[curMap[key]]) || ''
  384. }
  385. const obj = {
  386. ...data.information,
  387. ...data.warehouseDetail,
  388. specification:
  389. data.information?.specification ||
  390. data.warehouseDetail?.specification,
  391. detailReqList: [
  392. {
  393. ...data.warehouseDetail,
  394. ...detail,
  395. onlyCode: data.assetCode,
  396. batchNo: data.warehouseDetail?.batchNum
  397. }
  398. ],
  399. amount: 1,
  400. curId:
  401. data.warehouseDetail?.cargoSpaceId + data.warehouseDetail?.assetCode
  402. }
  403. const item = this.assetsList.find(itm => itm.curId === obj.curId)
  404. const preItem = this.preAssetsList.find(itm => itm.curId === obj.curId)
  405. const detailReqList = item?.detailReqList || []
  406. const preDetailReqList = preItem?.detailReqList || []
  407. if (item && detailReqList.find(i => i.onlyCode === data.assetCode)) {
  408. uni.showModal({
  409. title: '提示',
  410. content: '该物品已添加至待调入,请勿重复添加',
  411. success: async res => {}
  412. })
  413. return
  414. }
  415. if (
  416. preItem &&
  417. preDetailReqList.find(i => i.onlyCode === data.assetCode)
  418. ) {
  419. uni.showModal({
  420. title: '提示',
  421. content: '该物品已添加至预调入,请勿重复添加',
  422. success: async res => {}
  423. })
  424. return
  425. }
  426. console.log('this.obj-----------', obj)
  427. // if (item) {
  428. // if (obj.takeStockPattern) {
  429. // obj.amount = 1
  430. // } else {
  431. // obj.detailReqList.push(...detailReqList)
  432. // obj.amount = 1
  433. // }
  434. // }
  435. this.cargoSpaceInfoConfirm([obj])
  436. },
  437. // 带调出删除
  438. deleteItem (item) {
  439. uni.showModal({
  440. title: '提示',
  441. content: '确定删除当前数据?',
  442. success: async res => {
  443. if (res.confirm) {
  444. const index = this.assetsList.findIndex(i => i.curId === item.curId)
  445. if (index > -1) {
  446. this.assetsList.splice(index, 1)
  447. }
  448. }
  449. }
  450. })
  451. },
  452. handleDelete () {
  453. uni.showModal({
  454. title: '提示',
  455. content: '确定删除当前调拨?',
  456. success: async res => {
  457. if (res.confirm) {
  458. const res = await get(
  459. this.apiUrl + `/conventionalStockTransfer/delete/${this.id}`,
  460. {},
  461. true
  462. )
  463. if (res.success) {
  464. uni.showToast({
  465. title: '删除成功!',
  466. mask: true
  467. })
  468. setTimeout(() => {
  469. uni.navigateBack({
  470. delta: 1
  471. })
  472. }, 1500)
  473. }
  474. }
  475. }
  476. })
  477. },
  478. async _getDetail (id) {
  479. const res = await get(
  480. this.apiUrl +
  481. `/conventionalStockTransfer/details/conventionalStockTransfer/${id}`
  482. )
  483. if (res?.success) {
  484. this.formData = res.data.conventionalStockTransfer
  485. const assetsList = [],
  486. preAssetsList = []
  487. res.data.stockTransferInfoList.forEach(item => {
  488. let obj = {
  489. batchNum: item.batchNo,
  490. curId: item.outGoodsAllocationId + item.assetCode,
  491. ...item
  492. }
  493. if (obj.inGoodsAllocationId) {
  494. obj.inputChecked = false
  495. preAssetsList.push(obj)
  496. } else {
  497. if (!obj.takeStockPattern) {
  498. obj.curDetailReqList = uni.$u.deepClone(obj.detailReqList)
  499. }
  500. assetsList.push(obj)
  501. }
  502. })
  503. this.assetsList = assetsList
  504. this.preAssetsList = preAssetsList
  505. }
  506. },
  507. handleDetail (item) {
  508. this.$refs.detailRef.open(item, this.cargoSpaceId, res => {
  509. if (this.type === 'output') {
  510. this.$set(item, 'curDetailReqList', res)
  511. } else {
  512. this.$set(
  513. item,
  514. 'detailReqList',
  515. res.filter(i => i.checked)
  516. )
  517. }
  518. })
  519. },
  520. //退回待调出
  521. removeOutput () {
  522. if (!this.preAssetsList.some(i => i.inputChecked)) {
  523. uni.showToast({
  524. title: '请选择数据',
  525. icon: 'none'
  526. })
  527. return
  528. }
  529. uni.showModal({
  530. title: '提示',
  531. content: '确定移除当前选中?',
  532. success: res => {
  533. if (res.confirm) {
  534. for (let i = 0; i < this.preAssetsList.length; i++) {
  535. console.log(this.preAssetsList[i])
  536. if (this.preAssetsList[i].inputChecked) {
  537. const index = this.assetsList.findIndex(
  538. itm => itm.curId == this.preAssetsList[i].curId
  539. )
  540. if (index > -1) {
  541. if (this.preAssetsList[i].takeStockPattern) {
  542. this.assetsList[index].amount +=
  543. this.preAssetsList[i].amount
  544. } else {
  545. this.assetsList[index].detailReqList.push(
  546. ...this.preAssetsList[i].detailReqList.map(itm => {
  547. itm.checked = false
  548. return itm
  549. })
  550. )
  551. this.assetsList[index].curDetailReqList = uni.$u.deepClone(
  552. this.assetsList[index].detailReqList
  553. )
  554. this.assetsList[index].amount =
  555. this.assetsList[index].detailReqList.length
  556. }
  557. } else {
  558. const obj = uni.$u.deepClone(this.preAssetsList[i])
  559. if (obj.takeStockPattern) {
  560. obj.curAmount = obj.amount
  561. } else {
  562. obj.curDetailReqList = obj.detailReqList
  563. obj.amount = obj.curDetailReqList.length
  564. }
  565. this.assetsList.push(obj)
  566. }
  567. this.preAssetsList.splice(i, 1)
  568. i--
  569. }
  570. }
  571. }
  572. }
  573. })
  574. },
  575. // 删除数据
  576. deleteOutput () {
  577. if (!this.preAssetsList.some(i => i.inputChecked)) {
  578. uni.showToast({
  579. title: '请选择数据',
  580. icon: 'none'
  581. })
  582. return
  583. }
  584. uni.showModal({
  585. title: '提示',
  586. content: '确定删除当前选中?',
  587. success: res => {
  588. if (res.confirm) {
  589. this.preAssetsList = this.preAssetsList.filter(i => !i.inputChecked)
  590. }
  591. }
  592. })
  593. },
  594. // 删除物料
  595. deleteMaterial () {
  596. this.assetsList = this.assetsList.filter(i => !i.checked)
  597. },
  598. // 预览
  599. handlePreview () {
  600. if (!this.preAssetsList.length) {
  601. uni.showToast({
  602. title: '请选择调拨资产',
  603. icon: 'none'
  604. })
  605. return
  606. }
  607. if (!this.formData.createUserName) {
  608. const userInfo = uni.getStorageSync('userInfo')
  609. ;(this.formData.createUserId = userInfo.id),
  610. (this.formData.createUserName = userInfo.name)
  611. }
  612. const params = {
  613. conventionalStockTransferReq: this.formData,
  614. infoReqList: this.preAssetsList.map(i => {
  615. delete i.curDetailReqList
  616. if (!i.takeStockPattern) {
  617. i.detailReqList = i.detailReqList.map(itm => {
  618. itm.dialType = this.formData.dialType
  619. let obj = {
  620. ...i,
  621. ...itm,
  622. produceId: itm.id
  623. }
  624. delete obj.detailReqList
  625. return obj
  626. })
  627. }
  628. return {
  629. batchNo: i.batchNum,
  630. ...i
  631. }
  632. })
  633. }
  634. delete params.conventionalStockTransferReq.createTime
  635. const storageKey = Date.now() + ''
  636. uni.removeStorageSync('inventoryAllocation_preview')
  637. uni.setStorageSync('inventoryAllocation_preview', {
  638. [storageKey]: { params, assetsList: this.assetsList }
  639. })
  640. if (!this.preAssetsList.length) {
  641. return this.$message.error('请选择调拨资产')
  642. }
  643. uni.navigateTo({
  644. url: '/pages/warehouse/inventoryAllocation/preview?id=' + storageKey
  645. })
  646. },
  647. //获取仓库信息
  648. handleWarehouseChoose (type) {
  649. if (!this.formData.warehouseId) {
  650. uni.showToast({
  651. title: '请设置调拨类型!',
  652. icon: 'none'
  653. })
  654. return
  655. }
  656. if (
  657. type == 'input' &&
  658. !this.assetsList.filter(item => {
  659. return (
  660. (item.takeStockPattern && item.curAmount > 0) ||
  661. (!item.takeStockPattern &&
  662. item.curDetailReqList?.filter(p => p.checked).length > 0)
  663. )
  664. }).length
  665. ) {
  666. uni.showToast({
  667. title: '请选择待调入资产!',
  668. icon: 'none'
  669. })
  670. return
  671. }
  672. let warehouse = {}
  673. if (this.formData.dialType === 1) {
  674. warehouse.id = this.formData.warehouseId
  675. warehouse.name = this.formData.warehouseName
  676. this.$refs.warehouseChooseRef.open({ ...warehouse, type }, res => {
  677. if (type === 'output') {
  678. this.navShow = false
  679. this.$refs.cargoSpaceInfoDialogRef.open(res)
  680. } else {
  681. this.inputConfirm(res)
  682. }
  683. })
  684. } else if (this.formData.dialType === 2) {
  685. if (type == 'output') {
  686. warehouse.id = this.formData.warehouseId
  687. warehouse.name = this.formData.warehouseName
  688. } else {
  689. warehouse.id = this.formData.inWarehouseId
  690. warehouse.name = this.formData.inWarehouseName
  691. }
  692. this.$refs.warehouseChooseRef.open({ ...warehouse, type }, res => {
  693. if (type === 'output') {
  694. this.navShow = false
  695. this.$refs.cargoSpaceInfoDialogRef.open(res)
  696. } else {
  697. this.inputConfirm(res)
  698. }
  699. })
  700. }
  701. },
  702. // 选中调入库区
  703. inputConfirm (data) {
  704. this.$refs.warehouseChooseRef.cancel()
  705. this.navShow = false
  706. this.$refs.preInventoryRef
  707. .open(this.assetsList, data)
  708. .then(() => {
  709. for (let i = 0; i < this.assetsList.length; i++) {
  710. const item = this.assetsList[i]
  711. let obj = uni.$u.deepClone(item)
  712. if (item.takeStockPattern && item.curAmount > 0) {
  713. obj.amount = obj.curAmount
  714. delete obj.curAmount
  715. if (item.curAmount == item.amount) {
  716. this.assetsList.splice(i, 1)
  717. i--
  718. } else {
  719. item.amount -= item.curAmount
  720. item.curAmount = 0
  721. }
  722. this.preAssetsList.push({
  723. ...obj,
  724. inGoodsAllocationCode: data.cargoSpaceCode,
  725. inGoodsAllocationId: data.cargoSpaceId,
  726. inWarehouseAreaGoodsCode: data.shelfCode,
  727. inWarehouseAreaGoodsId: data.shelfId,
  728. inWarehouseAreaId: data.areaId,
  729. inWarehouseAreaName: data.areaName,
  730. inWarehouseId: data.warehouseId,
  731. inWarehouseName: data.warehouseName,
  732. inputChecked: false
  733. })
  734. }
  735. if (
  736. !item.takeStockPattern &&
  737. item.curDetailReqList.filter(p => p.checked)?.length
  738. ) {
  739. obj.detailReqList = obj.curDetailReqList.filter(p => p.checked)
  740. obj.amount = obj.detailReqList.length
  741. if (obj.amount === item.detailReqList.length) {
  742. this.assetsList.splice(i, 1)
  743. i--
  744. } else {
  745. item.curDetailReqList = item.curDetailReqList.filter(
  746. p => !p.checked
  747. )
  748. item.detailReqList = uni.$u.deepClone(item.curDetailReqList)
  749. item.amount = item.detailReqList.length
  750. }
  751. this.preAssetsList.push({
  752. ...obj,
  753. inGoodsAllocationCode: data.cargoSpaceCode,
  754. inGoodsAllocationId: data.cargoSpaceId,
  755. inWarehouseAreaGoodsCode: data.shelfCode,
  756. inWarehouseAreaGoodsId: data.shelfId,
  757. inWarehouseAreaId: data.areaId,
  758. inWarehouseAreaName: data.areaName,
  759. inWarehouseId: data.warehouseId,
  760. inWarehouseName: data.warehouseName,
  761. inputChecked: false
  762. })
  763. }
  764. }
  765. this.activeName = 'input'
  766. })
  767. .finally(() => (this.navShow = true))
  768. },
  769. //调出资产
  770. cargoSpaceInfoConfirm (assetsList) {
  771. this.$refs.warehouseChooseRef.cancel()
  772. // 已添加物品
  773. this.assetsList.forEach(item => {
  774. const index = assetsList.findIndex(i => i.curId === item.curId)
  775. if (index > -1) {
  776. let obj = assetsList.splice(index, 1)[0]
  777. item.amount += obj.amount
  778. if (obj.takeStockPattern) {
  779. item.curAmount += obj.amount
  780. } else {
  781. const list = obj.detailReqList.filter(i =>
  782. item.detailReqList.find(itm => i.onlyCode !== itm.onlyCode)
  783. )
  784. if (list.length > 0) {
  785. item.detailReqList.push(...list)
  786. item.curDetailReqList.push(
  787. ...uni.$u.deepClone(list).map(i => ({ ...i, checked: true }))
  788. )
  789. }
  790. }
  791. }
  792. })
  793. // 未添加
  794. this.assetsList.push(
  795. ...assetsList.map(i => {
  796. if (!i.takeStockPattern) {
  797. i.curDetailReqList = uni.$u
  798. .deepClone(i.detailReqList)
  799. .map(i => ({ ...i, checked: true }))
  800. } else {
  801. i.curAmount = i.amount
  802. }
  803. return {
  804. ...i,
  805. outGoodsAllocationCode: i.cargoSpaceCode,
  806. outGoodsAllocationId: i.cargoSpaceId,
  807. outWarehouseAreaGoodsCode: i.shelfCode,
  808. outWarehouseAreaGoodsId: i.shelfId,
  809. outWarehouseAreaId: i.areaId,
  810. outWarehouseAreaName: i.areaName,
  811. outWarehouseId: i.warehouseId,
  812. outWarehouseName: i.warehouseName
  813. }
  814. })
  815. )
  816. console.log('this.assetsList-----------', this.assetsList)
  817. },
  818. getPopupInfo (warehouse) {
  819. if (warehouse.warehouseName !== this.formData.warehouseName) {
  820. this.assetsList = []
  821. this.preAssetsList = []
  822. }
  823. Object.assign(this.formData, warehouse)
  824. }
  825. }
  826. }
  827. </script>
  828. <style lang="scss" scoped>
  829. $fixedHeight: 560rpx;
  830. $fixedHeightOut: 450rpx;
  831. .flex-center {
  832. display: flex;
  833. justify-content: space-between;
  834. align-items: center;
  835. padding: 10rpx 5rpx;
  836. }
  837. .btn {
  838. color: #70b603;
  839. font-size: 32rpx;
  840. }
  841. .isOut .tool-wrapper {
  842. height: $fixedHeightOut;
  843. }
  844. .tool-wrapper {
  845. position: fixed;
  846. left: 0;
  847. height: $fixedHeight;
  848. width: 100vw;
  849. font-size: 28rpx;
  850. color: #333;
  851. background-color: #fff;
  852. z-index: 1;
  853. .required::before {
  854. content: '*';
  855. color: red;
  856. }
  857. .info {
  858. background-color: rgba(242, 242, 242, 0.792156862745098);
  859. margin: 8rpx 0;
  860. }
  861. .tabs {
  862. background-color: rgba(242, 242, 242, 0.792156862745098);
  863. padding-top: 20rpx;
  864. display: flex;
  865. justify-content: space-between;
  866. margin-bottom: 20rpx;
  867. .tab-item {
  868. padding-top: 20rpx;
  869. flex: 1;
  870. display: flex;
  871. justify-content: center;
  872. align-items: center;
  873. &.active {
  874. background: linear-gradient(
  875. 180deg,
  876. rgba(75, 121, 2, 1) 0%,
  877. rgba(255, 255, 255, 1) 12%
  878. );
  879. }
  880. }
  881. }
  882. .operations {
  883. font-size: 32rpx;
  884. padding: 10rpx 40rpx;
  885. color: rgba(75, 121, 2, 1);
  886. }
  887. .search-box {
  888. padding: 10rpx;
  889. }
  890. .select-box {
  891. border-bottom: 1rpx solid #d7d7d7;
  892. white-space: nowrap;
  893. }
  894. }
  895. .isOut .list-container {
  896. padding-top: $fixedHeightOut;
  897. }
  898. .list-container {
  899. padding-top: $fixedHeight;
  900. padding-bottom: 80rpx;
  901. }
  902. .preview-box {
  903. position: fixed;
  904. bottom: 0;
  905. width: 100vw !important;
  906. }
  907. </style>