edit.vue 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270
  1. <template>
  2. <view class="mainBox" :class="{ isOut: activeName === 'output' }">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="调拨明细" @clickLeft="back" v-if="navShow">
  4. <template slot="right"><text class="text-danger" @click="handleDelete" v-if="id">删除调拨</text></template>
  5. </uni-nav-bar>
  6. <view class="tool-wrapper">
  7. <u-form labelPosition="left" :model="formData" :rules="rules" ref="formRef" labelWidth="180"
  8. labelAlign="right" class="baseForm">
  9. <u-form-item label="调拨条数" prop="createUserName" borderBottom>
  10. <view class="flex-center" style="width: 100%;">
  11. <view>
  12. <text> {{ assetsList.length + preAssetsList.length }}</text>
  13. </view>
  14. <view class="btn required" @click="$refs.typeSettingRef.open(formData)">调拨类型设置</view>
  15. </view>
  16. </u-form-item>
  17. <u-form-item label="调拨编码" prop="code" borderBottom>
  18. <u-input disableColor="#ffffff" v-model="formData.code" disabled type="text" />
  19. </u-form-item>
  20. <u-form-item label="调拨单名称" prop="name" borderBottom class="required-form">
  21. <u-input disableColor="#ffffff" v-model="formData.name" placeholder="请输入" type="text" />
  22. </u-form-item>
  23. <u-form-item label="调拨类型" prop="dialType" borderBottom>
  24. <u-input disableColor="#ffffff" v-model="dialTypeOptions[formData.dialType]" disabled type="text" />
  25. </u-form-item>
  26. <u-form-item label="调出仓库" prop="warehouseName" borderBottom>
  27. <text
  28. style="height: 24px;padding:6px 9px;">{{ formData.warehouseName }}{{ formData.cargoSpace ? '(' + formData.cargoSpace + ')' : '' }}</text>
  29. </u-form-item>
  30. <u-form-item label="调入仓库" prop="inWarehouseName" borderBottom>
  31. <text
  32. style="height: 24px;padding:6px 9px;">{{ formData.inWarehouseName }}{{ formData.inCargoSpace ? '(' + formData.inCargoSpace + ')' : '' }}</text>
  33. </u-form-item>
  34. </u-form>
  35. <!-- <view class="tabs">
  36. <view class="tab-item" :class="{ active: activeName === 'output' }" @click="activeName = 'output'">待调出({{ assetsList.length }})</view>
  37. <view class="tab-item" :class="{ active: activeName === 'input' }" @click="activeName = 'input'">预调入({{ preAssetsList.length }})</view>
  38. </view> -->
  39. <view v-if="activeName === 'output'">
  40. <view class="operations flex-center">
  41. <text @click="goScanCode">扫码添加</text>
  42. <text @click="handleWarehouseChoose('output')">手动添加</text>
  43. <text @click="handleWarehouseChoose('input')">调入货位</text>
  44. <!-- <text @click="deleteMaterial">删除选中</text> -->
  45. </view>
  46. </view>
  47. <!-- <view class="wrapper">
  48. <u-list class="listContent">
  49. <view class="listBox" v-for="(item, index) in assetsList">
  50. <view class="listBox-con">
  51. <view class="listBox-top">
  52. <view class="listBox-name">
  53. {{ item.categoryName }}
  54. </view>
  55. <view class="listBox-code">
  56. {{ item.categoryCode }}
  57. </view>
  58. </view>
  59. <view class="listBox-bottom">
  60. <view>牌号:{{ item.brandNum }}</view>
  61. <view>型号:{{ item.modelType }}</view>
  62. <view>规格:{{ item.specification }}</view>
  63. <view>批次号:{{ item.batchNo }}</view>
  64. <view>计量数量:{{ item.measureQuantity }}({{ item.measureUnit }})</view>
  65. <view class="w100">包装编码:{{ item.packageNo }}</view>
  66. <view>包装数量:{{ item.packingQuantity }}({{ item.packingUnit }})</view>
  67. <view>重量:{{ item.weight }}({{ item.weightUnit }})</view>
  68. <view>发货条码:{{ item.barcodes }}</view>
  69. <view>物料代号:{{ item.materielDesignation }}</view>
  70. <view>客户代号:{{ item.clientCode }}</view>
  71. <view>刻码:{{ item.engrave }}</view>
  72. <view>仓库:{{ item.warehouseName }}</view>
  73. </view>
  74. </view>
  75. </view>
  76. <u-empty class="noDate" style="margin-top: 20vh" v-if="!assetsList.length"></u-empty>
  77. </u-list>
  78. </view> -->
  79. <!-- <view class="search-box">
  80. <uni-easyinput prefixIcon="search" v-model="outputFilter" placeholder="编码、名称、货位"></uni-easyinput>
  81. </view> -->
  82. <!-- <view class="select-box flex-center">
  83. <text
  84. >已选{{ assetsList.filter(i => i.checked).length }}/{{
  85. assetsList.length
  86. }}</text
  87. >
  88. <text class="btn" @click="assetsSelectAll = !assetsSelectAll"
  89. >全选</text
  90. >
  91. </view> -->
  92. <template v-else>
  93. <view class="operations">
  94. <text @click="removeOutput" style="margin-right: 20rpx">移除选中</text>
  95. <text @click="deleteOutput">删除选中</text>
  96. </view>
  97. <view class="search-box">
  98. <uni-easyinput prefixIcon="search" v-model="inputFilter" placeholder="编码、名称、货位"></uni-easyinput>
  99. </view>
  100. <view class="select-box flex-center">
  101. <text>已选 {{ preAssetsList.filter(i => i.inputChecked).length }}/{{ preAssetsList.length }}</text>
  102. <text class="btn" @click="preAssetsSelectAll = !preAssetsSelectAll">全选</text>
  103. </view>
  104. </template>
  105. </view>
  106. <view class="list-container" v-if="activeName === 'output'">
  107. <AssetsCard v-for="(item, index) in assetsList" :key="index" :item="item" :index="index+Number(1)"
  108. @deleteItem="deleteItem(item)" type="output"></AssetsCard>
  109. </view>
  110. <view class="list-container" v-if="activeName === 'input'">
  111. <AssetsCard v-for="(item, index) in preAssetsListRender" :key="index" :item="item" :index="index+Number(1)"
  112. type="input">
  113. </AssetsCard>
  114. </view>
  115. <!-- <u-button type="success" class="preview-box" :plain="true" @click="handlePreview">预览</u-button> -->
  116. <u-button type="" class="preview-box" :plain="true" @click="add">调入</u-button>
  117. <WarehouseChoose ref="warehouseChooseRef" :selfClose="selfClose" />
  118. <!-- <CargoSpaceInfoDialog ref="cargoSpaceInfoDialogRef" @cancel="navShow = true" @success="cargoSpaceInfoConfirm" :assetsList="assetsList" :preAssetsList="preAssetsList" /> -->
  119. <CargoSpaceInfoDialog ref="cargoSpaceInfoDialogRef" @cancel="navShow = true" @success="cargoSpaceInfoConfirm" />
  120. <TypeSetting ref="typeSettingRef" @getPopupInfo="getPopupInfo" />
  121. <PreInventory ref="preInventoryRef" />
  122. <!-- <ScanCode @scancodedate="scancodedate"></ScanCode> -->
  123. </view>
  124. </template>
  125. <script>
  126. import ScanCode from '@/components/ScanCode.vue'
  127. import PreInventory from './components/PreInventory'
  128. import AssetsCard from './components/AssetsCard'
  129. import TypeSetting from './components/TypeSetting'
  130. import WarehouseChoose from '@/components/WarehouseChoose'
  131. import CargoSpaceInfoDialog from './components/CargoSpaceInfoDialog'
  132. import {
  133. getCode,
  134. allotApplySave
  135. } from '@/api/warehouseManagement'
  136. export default {
  137. components: {
  138. TypeSetting,
  139. ScanCode,
  140. PreInventory,
  141. AssetsCard,
  142. WarehouseChoose,
  143. CargoSpaceInfoDialog
  144. },
  145. data() {
  146. return {
  147. transferOrderId: '', // 调拨单ID
  148. searchVal: '',
  149. activeName: 'output',
  150. selfClose: true,
  151. dialTypeOptions: {
  152. 1: '库内调拨',
  153. 2: '库外调拨'
  154. },
  155. formData: {
  156. // dialNumber: getRuleNo('ALLOT'),
  157. dialType: '',
  158. warehouseId: '',
  159. warehouseName: '',
  160. inWarehouseId: '',
  161. inWarehouseName: '',
  162. deptCode: '',
  163. deptName: '',
  164. verifyId: '',
  165. verifyName: '',
  166. warehouse: {},
  167. inWarehouse: {}
  168. },
  169. assetsList: [], //已选资产列表
  170. preAssetsList: [], //预调入资产列表
  171. inputFilter: '',
  172. outputFilter: '',
  173. navShow: true,
  174. isCamera: false,
  175. id: '',
  176. rules: {
  177. name: {
  178. required: true,
  179. errorMessage: '请输入调拨名称',
  180. }
  181. }
  182. }
  183. },
  184. async onLoad(options) {
  185. if (options.id) {
  186. this.id = options.id
  187. this._getDetail(options.id)
  188. }
  189. const code = await getCode('transfer_no')
  190. console.log('code---', code)
  191. this.formData.code = code
  192. uni.$on('setSelectList', async data => {
  193. if (data?.length) {
  194. console.log('setSelectList--data------------', data)
  195. this.assetsList = data
  196. }
  197. })
  198. this.$forceUpdate()
  199. console.log(this.formData.code)
  200. },
  201. onShow() {
  202. const _this = this
  203. uni.$off('inventoryAllocationScanView') // 每次进来先 移除全局自定义事件监听器
  204. uni.$on('inventoryAllocationScanView', function(data) {
  205. _this.setScanMaterial(data)
  206. })
  207. console.log('onShow')
  208. uni.$off('scancodedate') // 每次进来先 移除全局自定义事件监听器
  209. uni.$on('scancodedate', function(data) {
  210. _this.scancodedate(data)
  211. })
  212. },
  213. onUnload() {
  214. uni.$off('scancodedate')
  215. },
  216. onHide() {
  217. uni.$off('scancodedate')
  218. },
  219. computed: {
  220. assetsSelectAll: {
  221. set(val) {
  222. this.assetsList.forEach(item => {
  223. item.checked = val
  224. })
  225. return val
  226. },
  227. get() {
  228. return !this.assetsList.some(item => !item.checked)
  229. }
  230. },
  231. preAssetsSelectAll: {
  232. set(val) {
  233. this.preAssetsList.forEach(item => {
  234. item.inputChecked = val
  235. })
  236. return val
  237. },
  238. get() {
  239. return !this.preAssetsList.some(item => !item.inputChecked)
  240. }
  241. },
  242. // 做前端过滤 编码areaName、名称assetCode、货位shelfCode、批次
  243. assetsListRender() {
  244. return this.assetsList.filter(({
  245. assetName = '',
  246. assetCode = '',
  247. outWarehouseAreaName = '',
  248. outWarehouseAreaGoodsCode = '',
  249. outGoodsAllocationCode = ''
  250. }) => {
  251. if (this.outputFilter) {
  252. if (
  253. assetName.indexOf(this.outputFilter) !== -1 ||
  254. assetCode.indexOf(this.outputFilter) !== -1 ||
  255. outWarehouseAreaName.indexOf(this.outputFilter) !== -1 ||
  256. outWarehouseAreaGoodsCode.indexOf(this.outputFilter) !== -1 ||
  257. outGoodsAllocationCode.indexOf(this.outputFilter) !== -1
  258. ) {
  259. return true
  260. }
  261. return false
  262. }
  263. return true
  264. })
  265. },
  266. // 做前端过滤 编码、名称、货位、批次
  267. preAssetsListRender() {
  268. return this.preAssetsList.filter(({
  269. areaName = '',
  270. assetCode = '',
  271. inWarehouseAreaName = '',
  272. inWarehouseAreaGoodsCode = '',
  273. inGoodsAllocationCode = ''
  274. }) => {
  275. if (this.inputFilter) {
  276. if (
  277. areaName.indexOf(this.inputFilter) !== -1 ||
  278. assetCode.indexOf(this.inputFilter) !== -1 ||
  279. inWarehouseAreaName.indexOf(this.inputFilter) !== -1 ||
  280. inWarehouseAreaGoodsCode.indexOf(this.inputFilter) !== -1 ||
  281. inGoodsAllocationCode.indexOf(this.inputFilter) !== -1
  282. ) {
  283. return true
  284. }
  285. return false
  286. }
  287. return true
  288. })
  289. }
  290. },
  291. beforeDestroy() {
  292. uni.$off('setSelectList')
  293. },
  294. methods: {
  295. goScanCode() {
  296. if (!this.formData.warehouseId) {
  297. uni.showToast({
  298. title: '请设置调拨类型!',
  299. icon: 'none'
  300. })
  301. return
  302. }
  303. let warehouse = {}
  304. warehouse.id = this.formData.warehouseId
  305. warehouse.name = this.formData.warehouseName
  306. this.$refs.warehouseChooseRef.open({
  307. ...warehouse,
  308. type: 'output'
  309. }, res => {
  310. if (this.formData.dialType === 1) {
  311. if (!res.areaId) {
  312. uni.showToast({
  313. title: '请选择库区',
  314. icon: 'none'
  315. })
  316. return
  317. }
  318. }
  319. this.formData.cargoSpace = this.getLocation(res)
  320. this.formData.warehouse = res
  321. this.$refs.warehouseChooseRef.cancel()
  322. this.$forceUpdate()
  323. uni.navigateTo({
  324. url: '/pages/warehouse/components/scanCodeList'
  325. })
  326. })
  327. },
  328. add() {
  329. if (!this.formData.name) {
  330. uni.showToast({
  331. title: '请填入调拨名称!',
  332. icon: 'none'
  333. })
  334. return
  335. }
  336. console.log('---------this.assetsList---------------')
  337. console.log(this.assetsList)
  338. console.log(this.formData)
  339. let isBoolen = true
  340. if (this.formData.warehouse.areaId && this.formData.warehouse.shelfId && this.formData.warehouse
  341. .cargoSpaceId) {
  342. isBoolen = this.assetsList.every(
  343. item =>
  344. item.warehouseId == this.formData.warehouseId &&
  345. item.areaId == this.formData.warehouse.areaId &&
  346. item.goodsShelfId == this.formData.warehouse.shelfId &&
  347. item.goodsAllocationId == this.formData.warehouse.cargoSpaceId
  348. )
  349. } else if (this.formData.warehouse.areaId && this.formData.warehouse.shelfId) {
  350. isBoolen = this.assetsList.every(
  351. item => item.warehouseId == this.formData.warehouseId && item.areaId == this.formData.warehouse
  352. .areaId && item.goodsShelfId == this.formData.warehouse.shelfId
  353. )
  354. } else if (this.formData.warehouse.areaId) {
  355. isBoolen = this.assetsList.every(item => item.warehouseId == this.formData.warehouseId && item
  356. .areaId == this.formData.warehouse.areaId)
  357. } else {
  358. isBoolen = this.assetsList.every(item => item.warehouseId == this.formData.warehouseId)
  359. }
  360. if (!isBoolen) {
  361. uni.showToast({
  362. title: '请检查调拨明细!',
  363. icon: 'none'
  364. })
  365. return
  366. }
  367. if (this.assetsList.length > 0) {
  368. if (this.formData.dialType == 1) {
  369. // 库内
  370. this.submit(2)
  371. } else {
  372. // 库外
  373. this.submit(1)
  374. }
  375. } else {
  376. uni.showToast({
  377. title: '请选择调出物品!',
  378. icon: 'none'
  379. })
  380. }
  381. },
  382. submit(status) {
  383. if (this.assetsList.length > 0) {
  384. let params = {
  385. categoryCode: this.assetsList.map(item => item.categoryCode).join(','),
  386. categoryName: this.assetsList.map(item => item.categoryName).join(','),
  387. allotApplyAddPOBuilders: this.assetsList.map(item => {
  388. return {
  389. outInDetailRecordId: item.id,
  390. warehouseId: this.formData.warehouseId,
  391. warehouseName: this.formData.warehouseName,
  392. areaId: this.formData.warehouse.areaId,
  393. areaName: this.formData.warehouse.areaName,
  394. goodsAllocationId: this.formData.warehouse.cargoSpaceCode,
  395. goodsAllocationName: this.formData.warehouse.cargoSpaceId,
  396. goodsShelfId: this.formData.warehouse.shelfId,
  397. goodsShelfName: this.formData.warehouse.shelfCode,
  398. targetAreaId: this.formData.inWarehouse.areaId,
  399. targetAreaName: this.formData.inWarehouse.areaName,
  400. targetGoodsAllocationId: this.formData.inWarehouse.cargoSpaceId,
  401. targetGoodsAllocationName: this.formData.inWarehouse.cargoSpaceCode,
  402. targetGoodsShelfId: this.formData.inWarehouse.shelfId,
  403. targetGoodsShelfName: this.formData.inWarehouse.shelfCode,
  404. targetWarehouseId: this.formData.inWarehouseId,
  405. targetWarehouseName: this.formData.inWarehouseName
  406. }
  407. }),
  408. allotCode: this.formData.code,
  409. name: this.formData.name,
  410. id: this.transferOrderId,
  411. sourceWarehouse: this.formData.warehouseName,
  412. sourceWarehouseId: this.formData.warehouseId,
  413. targetWarehouse: this.formData.inWarehouseName,
  414. targetWarehouseId: this.formData.inWarehouseId,
  415. status: status,
  416. type: this.formData.dialType
  417. }
  418. console.log('params------------', params)
  419. uni.showLoading({
  420. title: '保存中...'
  421. })
  422. allotApplySave(params).then(() => {
  423. uni.hideLoading()
  424. uni.navigateTo({
  425. url: '/pages/warehouse/inventoryAllocation/index'
  426. })
  427. })
  428. }
  429. },
  430. scancodedate(data) {
  431. this.qrContent = data.code.trim()
  432. this.getData()
  433. },
  434. handleScan() {
  435. const _this = this
  436. uni.scanCode({
  437. onlyFromCamera: true,
  438. success: function(res) {
  439. console.log('条码类型:' + res.scanType)
  440. console.log('条码内容:' + res.result)
  441. _this.isCamera = true
  442. _this.qrContent = res.result.trim()
  443. _this.getData()
  444. }
  445. })
  446. },
  447. // 根据条码请求设备数据 @_@
  448. getData() {
  449. if (!this.formData.warehouseId) {
  450. uni.showToast({
  451. title: '请设置调拨类型!',
  452. icon: 'none'
  453. })
  454. return
  455. }
  456. let par = {
  457. barType: this.qrContent.split('@_@')[1] || 0,
  458. qrContent: this.qrContent
  459. }
  460. // uni.showLoading({
  461. // title: '加载中',
  462. // mask: true
  463. // })
  464. // postJ(this.apiUrl + '/scan/getAssetInfo', par)
  465. // .then(res => {
  466. // let data = res.data
  467. // console.log(data, 'qrContent')
  468. // if (data.assetType === undefined) {
  469. // uni.showToast({
  470. // title: '请扫码物品码',
  471. // icon: 'none'
  472. // })
  473. // return
  474. // } else if (data?.warehouseDetail?.bizStatus != 1) {
  475. // uni.showModal({
  476. // title: '提示',
  477. // content: `当前物品不在仓库内`,
  478. // success: async res => {}
  479. // })
  480. // return
  481. // } else if (data.underApproval) {
  482. // uni.showModal({
  483. // title: '提示',
  484. // content: `【${data.assetCode}】正在待审批单据中`,
  485. // success: async res => {}
  486. // })
  487. // return
  488. // } else if (data.information.takeStockPattern) {
  489. // uni.showModal({
  490. // title: '提示',
  491. // content:
  492. // '该物品为批量盘点模式,不可扫码。如需扫码,请将该物品类型在物品信息表中修改为逐个模式。',
  493. // success: async res => {}
  494. // })
  495. // return
  496. // } else if (
  497. // data.warehouseDetail?.warehouseId !== this.formData.warehouseId
  498. // ) {
  499. // uni.showToast({
  500. // title: `请选择${this.formData.warehouseName}仓库下的物品`,
  501. // icon: 'none'
  502. // })
  503. // return
  504. // }
  505. // uni.setStorageSync('inventoryAllocationScan', data)
  506. // uni.navigateTo({
  507. // url: '/pages/warehouse/inventoryAllocation/scanView?emitName=inventoryAllocationScanView&key=inventoryAllocationScan'
  508. // })
  509. // })
  510. // .finally(() => {
  511. // uni.hideLoading()
  512. // })
  513. },
  514. setScanMaterial(data) {
  515. console.log(data, '--------------------')
  516. const curMap = {
  517. assetId: 'id',
  518. assetCode: 'informationCode', //编码
  519. assetName: 'informationName', //名称
  520. materialId: 'id',
  521. materialName: 'informationName',
  522. batchNo: 'batchNum', //批次号
  523. unit: 'measuringUnit', //单位
  524. minPackUnit: 'packingUnit' //最小包装单位
  525. }
  526. let detail = {}
  527. for (const key in curMap) {
  528. detail[key] = (curMap[key] && data.information[curMap[key]]) || ''
  529. }
  530. const obj = {
  531. ...data.information,
  532. ...data.warehouseDetail,
  533. specification: data.information?.specification || data.warehouseDetail?.specification,
  534. detailReqList: [{
  535. ...data.warehouseDetail,
  536. ...detail,
  537. onlyCode: data.assetCode,
  538. batchNo: data.warehouseDetail?.batchNum
  539. }],
  540. amount: 1,
  541. curId: data.warehouseDetail?.cargoSpaceId + data.warehouseDetail?.assetCode
  542. }
  543. const item = this.assetsList.find(itm => itm.curId === obj.curId)
  544. const preItem = this.preAssetsList.find(itm => itm.curId === obj.curId)
  545. const detailReqList = item?.detailReqList || []
  546. const preDetailReqList = preItem?.detailReqList || []
  547. if (item && detailReqList.find(i => i.onlyCode === data.assetCode)) {
  548. uni.showModal({
  549. title: '提示',
  550. content: '该物品已添加至待调入,请勿重复添加',
  551. success: async res => {}
  552. })
  553. return
  554. }
  555. if (preItem && preDetailReqList.find(i => i.onlyCode === data.assetCode)) {
  556. uni.showModal({
  557. title: '提示',
  558. content: '该物品已添加至预调入,请勿重复添加',
  559. success: async res => {}
  560. })
  561. return
  562. }
  563. console.log('this.obj-----------', obj)
  564. // if (item) {
  565. // if (obj.takeStockPattern) {
  566. // obj.amount = 1
  567. // } else {
  568. // obj.detailReqList.push(...detailReqList)
  569. // obj.amount = 1
  570. // }
  571. // }
  572. this.cargoSpaceInfoConfirm([obj])
  573. },
  574. // 带调出删除
  575. deleteItem(item) {
  576. uni.showModal({
  577. title: '提示',
  578. content: '确定删除当前数据?',
  579. success: async res => {
  580. if (res.confirm) {
  581. const index = this.assetsList.findIndex(i => i.curId === item.curId)
  582. if (index > -1) {
  583. this.assetsList.splice(index, 1)
  584. }
  585. }
  586. }
  587. })
  588. },
  589. handleDelete() {
  590. // uni.showModal({
  591. // title: '提示',
  592. // content: '确定删除当前调拨?',
  593. // success: async res => {
  594. // if (res.confirm) {
  595. // const res = await get(
  596. // this.apiUrl + `/conventionalStockTransfer/delete/${this.id}`,
  597. // {},
  598. // true
  599. // )
  600. // if (res.success) {
  601. // uni.showToast({
  602. // title: '删除成功!',
  603. // mask: true
  604. // })
  605. // setTimeout(() => {
  606. // uni.navigateBack({
  607. // delta: 1
  608. // })
  609. // }, 1500)
  610. // }
  611. // }
  612. // }
  613. // })
  614. },
  615. async _getDetail(id) {
  616. // const res = await get(
  617. // this.apiUrl +
  618. // `/conventionalStockTransfer/details/conventionalStockTransfer/${id}`
  619. // )
  620. if (res?.success) {
  621. this.formData = res.data.conventionalStockTransfer
  622. const assetsList = [],
  623. preAssetsList = []
  624. res.data.stockTransferInfoList.forEach(item => {
  625. let obj = {
  626. batchNum: item.batchNo,
  627. curId: item.outGoodsAllocationId + item.assetCode,
  628. ...item
  629. }
  630. if (obj.inGoodsAllocationId) {
  631. obj.inputChecked = false
  632. preAssetsList.push(obj)
  633. } else {
  634. if (!obj.takeStockPattern) {
  635. obj.curDetailReqList = uni.$u.deepClone(obj.detailReqList)
  636. }
  637. assetsList.push(obj)
  638. }
  639. })
  640. this.assetsList = assetsList
  641. this.preAssetsList = preAssetsList
  642. }
  643. },
  644. handleDetail(item) {
  645. this.$refs.detailRef.open(item, this.cargoSpaceId, res => {
  646. if (this.type === 'output') {
  647. this.$set(item, 'curDetailReqList', res)
  648. } else {
  649. this.$set(
  650. item,
  651. 'detailReqList',
  652. res.filter(i => i.checked)
  653. )
  654. }
  655. })
  656. },
  657. //退回待调出
  658. removeOutput() {
  659. if (!this.preAssetsList.some(i => i.inputChecked)) {
  660. uni.showToast({
  661. title: '请选择数据',
  662. icon: 'none'
  663. })
  664. return
  665. }
  666. uni.showModal({
  667. title: '提示',
  668. content: '确定移除当前选中?',
  669. success: res => {
  670. if (res.confirm) {
  671. for (let i = 0; i < this.preAssetsList.length; i++) {
  672. console.log(this.preAssetsList[i])
  673. if (this.preAssetsList[i].inputChecked) {
  674. const index = this.assetsList.findIndex(itm => itm.curId == this
  675. .preAssetsList[i].curId)
  676. if (index > -1) {
  677. if (this.preAssetsList[i].takeStockPattern) {
  678. this.assetsList[index].amount += this.preAssetsList[i].amount
  679. } else {
  680. this.assetsList[index].detailReqList.push(
  681. ...this.preAssetsList[i].detailReqList.map(itm => {
  682. itm.checked = false
  683. return itm
  684. })
  685. )
  686. this.assetsList[index].curDetailReqList = uni.$u.deepClone(this
  687. .assetsList[index].detailReqList)
  688. this.assetsList[index].amount = this.assetsList[index]
  689. .detailReqList.length
  690. }
  691. } else {
  692. const obj = uni.$u.deepClone(this.preAssetsList[i])
  693. if (obj.takeStockPattern) {
  694. obj.curAmount = obj.amount
  695. } else {
  696. obj.curDetailReqList = obj.detailReqList
  697. obj.amount = obj.curDetailReqList.length
  698. }
  699. this.assetsList.push(obj)
  700. }
  701. this.preAssetsList.splice(i, 1)
  702. i--
  703. }
  704. }
  705. }
  706. }
  707. })
  708. },
  709. // 删除数据
  710. deleteOutput() {
  711. if (!this.preAssetsList.some(i => i.inputChecked)) {
  712. uni.showToast({
  713. title: '请选择数据',
  714. icon: 'none'
  715. })
  716. return
  717. }
  718. uni.showModal({
  719. title: '提示',
  720. content: '确定删除当前选中?',
  721. success: res => {
  722. if (res.confirm) {
  723. this.preAssetsList = this.preAssetsList.filter(i => !i.inputChecked)
  724. }
  725. }
  726. })
  727. },
  728. // 删除物料
  729. deleteMaterial() {
  730. this.assetsList = this.assetsList.filter(i => !i.checked)
  731. },
  732. // 预览
  733. handlePreview() {
  734. if (!this.preAssetsList.length) {
  735. uni.showToast({
  736. title: '请选择调拨资产',
  737. icon: 'none'
  738. })
  739. return
  740. }
  741. if (!this.formData.createUserName) {
  742. const userInfo = uni.getStorageSync('userInfo');
  743. (this.formData.createUserId = userInfo.id), (this.formData.createUserName = userInfo.name)
  744. }
  745. const params = {
  746. conventionalStockTransferReq: this.formData,
  747. infoReqList: this.preAssetsList.map(i => {
  748. delete i.curDetailReqList
  749. if (!i.takeStockPattern) {
  750. i.detailReqList = i.detailReqList.map(itm => {
  751. itm.dialType = this.formData.dialType
  752. let obj = {
  753. ...i,
  754. ...itm,
  755. produceId: itm.id
  756. }
  757. delete obj.detailReqList
  758. return obj
  759. })
  760. }
  761. return {
  762. batchNo: i.batchNum,
  763. ...i
  764. }
  765. })
  766. }
  767. delete params.conventionalStockTransferReq.createTime
  768. const storageKey = Date.now() + ''
  769. uni.removeStorageSync('inventoryAllocation_preview')
  770. uni.setStorageSync('inventoryAllocation_preview', {
  771. [storageKey]: {
  772. params,
  773. assetsList: this.assetsList
  774. }
  775. })
  776. if (!this.preAssetsList.length) {
  777. return this.$message.error('请选择调拨资产')
  778. }
  779. uni.navigateTo({
  780. url: '/pages/warehouse/inventoryAllocation/preview?id=' + storageKey
  781. })
  782. },
  783. // 获取当前调入调出信息
  784. getLocation(warehouse) {
  785. let cargoSpace = ''
  786. if (warehouse.areaName) {
  787. if (warehouse.shelfCode) {
  788. if (warehouse.cargoSpaceCode) {
  789. cargoSpace = warehouse.areaName + '-' + warehouse.shelfCode + '-' + warehouse.cargoSpaceCode
  790. } else {
  791. cargoSpace = warehouse.areaName + '-' + warehouse.shelfCode
  792. }
  793. } else {
  794. cargoSpace = warehouse.areaName
  795. }
  796. }
  797. return cargoSpace
  798. },
  799. //获取仓库信息
  800. handleWarehouseChoose(type) {
  801. if (!this.formData.warehouseId) {
  802. uni.showToast({
  803. title: '请设置调拨类型!',
  804. icon: 'none'
  805. })
  806. return
  807. }
  808. let warehouse = {}
  809. if (this.formData.dialType === 1) {
  810. warehouse.id = this.formData.warehouseId
  811. warehouse.name = this.formData.warehouseName
  812. this.$refs.warehouseChooseRef.open({
  813. ...warehouse,
  814. type
  815. }, res => {
  816. console.log('库内调拨好了~~~')
  817. console.log(res)
  818. if (type === 'output') {
  819. // 调出货位
  820. if (!res.areaId) {
  821. uni.showToast({
  822. title: '请选择库区',
  823. icon: 'none'
  824. })
  825. return
  826. }
  827. this.navShow = false
  828. this.formData.cargoSpace = this.getLocation(res)
  829. this.formData.warehouse = res
  830. this.$refs.cargoSpaceInfoDialogRef.open(res)
  831. } else {
  832. // 调入货位
  833. if (this.formData.warehouse.areaId && this.formData.warehouse.shelfId && this.formData
  834. .warehouse.cargoSpaceId) {
  835. // 调出库区/货架/货位
  836. console.log(res)
  837. console.log(this.formData)
  838. if (res.areaId && res.shelfId && res.cargoSpaceId) {
  839. if (this.formData.warehouse.areaId == res.areaId && this.formData.warehouse
  840. .shelfId == res.shelfId && this.formData.warehouse.cargoSpaceId == res
  841. .cargoSpaceId) {
  842. uni.showToast({
  843. title: '库区/货架/货位重复',
  844. icon: 'none'
  845. })
  846. return
  847. }
  848. } else {
  849. uni.showToast({
  850. title: '库区/货架/货位不能为空',
  851. icon: 'none'
  852. })
  853. return
  854. }
  855. } else if (this.formData.warehouse.areaId && this.formData.warehouse.shelfId && !this
  856. .formData.warehouse.cargoSpaceId) {
  857. // 调出库区/货架
  858. if (res.areaId && res.shelfId) {
  859. if (this.formData.warehouse.areaId == res.areaId && this.formData.warehouse
  860. .shelfId == res.shelfId) {
  861. uni.showToast({
  862. title: '库区/货架重复',
  863. icon: 'none'
  864. })
  865. return
  866. }
  867. } else {
  868. uni.showToast({
  869. title: '库区/货架不能为空',
  870. icon: 'none'
  871. })
  872. return
  873. }
  874. } else if (this.formData.warehouse.areaId && !this.formData.warehouse.shelfId && !this
  875. .formData.warehouse.cargoSpaceId) {
  876. // 调出库区
  877. if (res.areaId) {
  878. if (this.formData.warehouse.areaId == res.areaId) {
  879. uni.showToast({
  880. title: '库区重复',
  881. icon: 'none'
  882. })
  883. return
  884. }
  885. } else {
  886. uni.showToast({
  887. title: '请选择库区',
  888. icon: 'none'
  889. })
  890. return
  891. }
  892. }
  893. this.formData.inCargoSpace = this.getLocation(res)
  894. this.formData.inWarehouse = res
  895. }
  896. this.$refs.warehouseChooseRef.cancel()
  897. this.$forceUpdate()
  898. console.log(this.formData)
  899. })
  900. } else if (this.formData.dialType === 2) {
  901. if (type == 'output') {
  902. warehouse.id = this.formData.warehouseId
  903. warehouse.name = this.formData.warehouseName
  904. } else {
  905. warehouse.id = this.formData.inWarehouseId
  906. warehouse.name = this.formData.inWarehouseName
  907. }
  908. this.$refs.warehouseChooseRef.open({
  909. ...warehouse,
  910. type
  911. }, res => {
  912. console.log('库外调拨好了~~~')
  913. console.log(res)
  914. if (type === 'output') {
  915. this.navShow = false
  916. this.formData.cargoSpace = this.getLocation(res)
  917. this.formData.warehouse = res
  918. this.$refs.cargoSpaceInfoDialogRef.open(res)
  919. } else {
  920. this.formData.inCargoSpace = this.getLocation(res)
  921. this.formData.inWarehouse = res
  922. }
  923. this.$refs.warehouseChooseRef.cancel()
  924. this.$forceUpdate()
  925. console.log(this.formData)
  926. })
  927. }
  928. },
  929. // handleWarehouseChoose(type) {
  930. // if (!this.formData.warehouseId) {
  931. // uni.showToast({
  932. // title: '请设置调拨类型!',
  933. // icon: 'none'
  934. // })
  935. // return
  936. // }
  937. // if (
  938. // type == 'input' &&
  939. // !this.assetsList.filter(item => {
  940. // return (item.takeStockPattern && item.curAmount > 0) || (!item.takeStockPattern && item.curDetailReqList?.filter(p => p.checked).length > 0)
  941. // }).length
  942. // ) {
  943. // uni.showToast({
  944. // title: '请选择待调入资产!',
  945. // icon: 'none'
  946. // })
  947. // return
  948. // }
  949. // let warehouse = {}
  950. // if (this.formData.dialType === 1) {
  951. // warehouse.id = this.formData.warehouseId
  952. // warehouse.name = this.formData.warehouseName
  953. // this.$refs.warehouseChooseRef.open({ ...warehouse, type }, res => {
  954. // if (type === 'output') {
  955. // this.navShow = false
  956. // this.$refs.cargoSpaceInfoDialogRef.open(res)
  957. // } else {
  958. // this.inputConfirm(res)
  959. // }
  960. // })
  961. // } else if (this.formData.dialType === 2) {
  962. // if (type == 'output') {
  963. // warehouse.id = this.formData.warehouseId
  964. // warehouse.name = this.formData.warehouseName
  965. // } else {
  966. // warehouse.id = this.formData.inWarehouseId
  967. // warehouse.name = this.formData.inWarehouseName
  968. // }
  969. // this.$refs.warehouseChooseRef.open({ ...warehouse, type }, res => {
  970. // if (type === 'output') {
  971. // this.navShow = false
  972. // this.$refs.cargoSpaceInfoDialogRef.open(res)
  973. // } else {
  974. // this.inputConfirm(res)
  975. // }
  976. // })
  977. // }
  978. // },
  979. // 选中调入库区
  980. inputConfirm(data) {
  981. this.$refs.warehouseChooseRef.cancel()
  982. this.navShow = false
  983. this.$refs.preInventoryRef
  984. .open(this.assetsList, data)
  985. .then(() => {
  986. for (let i = 0; i < this.assetsList.length; i++) {
  987. const item = this.assetsList[i]
  988. let obj = uni.$u.deepClone(item)
  989. if (item.takeStockPattern && item.curAmount > 0) {
  990. obj.amount = obj.curAmount
  991. delete obj.curAmount
  992. if (item.curAmount == item.amount) {
  993. this.assetsList.splice(i, 1)
  994. i--
  995. } else {
  996. item.amount -= item.curAmount
  997. item.curAmount = 0
  998. }
  999. this.preAssetsList.push({
  1000. ...obj,
  1001. inGoodsAllocationCode: data.cargoSpaceCode,
  1002. inGoodsAllocationId: data.cargoSpaceId,
  1003. inWarehouseAreaGoodsCode: data.shelfCode,
  1004. inWarehouseAreaGoodsId: data.shelfId,
  1005. inWarehouseAreaId: data.areaId,
  1006. inWarehouseAreaName: data.areaName,
  1007. inWarehouseId: data.warehouseId,
  1008. inWarehouseName: data.warehouseName,
  1009. inputChecked: false
  1010. })
  1011. }
  1012. if (!item.takeStockPattern && item.curDetailReqList.filter(p => p.checked)?.length) {
  1013. obj.detailReqList = obj.curDetailReqList.filter(p => p.checked)
  1014. obj.amount = obj.detailReqList.length
  1015. if (obj.amount === item.detailReqList.length) {
  1016. this.assetsList.splice(i, 1)
  1017. i--
  1018. } else {
  1019. item.curDetailReqList = item.curDetailReqList.filter(p => !p.checked)
  1020. item.detailReqList = uni.$u.deepClone(item.curDetailReqList)
  1021. item.amount = item.detailReqList.length
  1022. }
  1023. this.preAssetsList.push({
  1024. ...obj,
  1025. inGoodsAllocationCode: data.cargoSpaceCode,
  1026. inGoodsAllocationId: data.cargoSpaceId,
  1027. inWarehouseAreaGoodsCode: data.shelfCode,
  1028. inWarehouseAreaGoodsId: data.shelfId,
  1029. inWarehouseAreaId: data.areaId,
  1030. inWarehouseAreaName: data.areaName,
  1031. inWarehouseId: data.warehouseId,
  1032. inWarehouseName: data.warehouseName,
  1033. inputChecked: false
  1034. })
  1035. }
  1036. }
  1037. this.activeName = 'input'
  1038. })
  1039. .finally(() => (this.navShow = true))
  1040. },
  1041. //调出资产
  1042. cargoSpaceInfoConfirm(assetsList) {
  1043. console.log('assetsList-------', assetsList)
  1044. this.$refs.warehouseChooseRef.cancel()
  1045. this.assetsList = assetsList
  1046. // // 已添加物品
  1047. // this.assetsList.forEach(item => {
  1048. // const index = assetsList.findIndex(i => i.curId === item.curId)
  1049. // if (index > -1) {
  1050. // let obj = assetsList.splice(index, 1)[0]
  1051. // item.amount += obj.amount
  1052. // if (obj.takeStockPattern) {
  1053. // item.curAmount += obj.amount
  1054. // } else {
  1055. // const list = obj.detailReqList.filter(i => item.detailReqList.find(itm => i.onlyCode !== itm.onlyCode))
  1056. // if (list.length > 0) {
  1057. // item.detailReqList.push(...list)
  1058. // item.curDetailReqList.push(...uni.$u.deepClone(list).map(i => ({ ...i, checked: true })))
  1059. // }
  1060. // }
  1061. // }
  1062. // })
  1063. // // 未添加
  1064. // this.assetsList.push(
  1065. // ...assetsList.map(i => {
  1066. // if (!i.takeStockPattern) {
  1067. // i.curDetailReqList = uni.$u.deepClone(i.detailReqList).map(i => ({ ...i, checked: true }))
  1068. // } else {
  1069. // i.curAmount = i.amount
  1070. // }
  1071. // return {
  1072. // ...i,
  1073. // outGoodsAllocationCode: i.cargoSpaceCode,
  1074. // outGoodsAllocationId: i.cargoSpaceId,
  1075. // outWarehouseAreaGoodsCode: i.shelfCode,
  1076. // outWarehouseAreaGoodsId: i.shelfId,
  1077. // outWarehouseAreaId: i.areaId,
  1078. // outWarehouseAreaName: i.areaName,
  1079. // outWarehouseId: i.warehouseId,
  1080. // outWarehouseName: i.warehouseName
  1081. // }
  1082. // })
  1083. // )
  1084. // console.log('this.assetsList-----------', this.assetsList)
  1085. },
  1086. getPopupInfo(warehouse) {
  1087. // if (warehouse.warehouseName !== this.formData.warehouseName) {
  1088. // this.assetsList = []
  1089. // this.preAssetsList = []
  1090. // }
  1091. this.assetsList = []
  1092. this.formData.cargoSpace = ''
  1093. this.formData.inCargoSpace = ''
  1094. this.formData.warehouse = {}
  1095. this.formData.inWarehouse = {}
  1096. Object.assign(this.formData, warehouse)
  1097. }
  1098. }
  1099. }
  1100. </script>
  1101. <style lang="scss" scoped>
  1102. $fixedHeight: 580rpx;
  1103. $fixedHeightOut: 480rpx;
  1104. .flex-center {
  1105. display: flex;
  1106. justify-content: space-between;
  1107. align-items: center;
  1108. // padding: 10rpx 20rpx;
  1109. // box-sizing: border-box;
  1110. .flex_input {
  1111. flex: 1;
  1112. display: flex;
  1113. align-items: center;
  1114. .u-input {
  1115. padding: 0 !important;
  1116. }
  1117. }
  1118. }
  1119. .btn {
  1120. color: $theme-color;
  1121. font-size: 32rpx;
  1122. }
  1123. .isOut .tool-wrapper {
  1124. // height: $fixedHeightOut;
  1125. }
  1126. .tool-wrapper {
  1127. position: fixed;
  1128. left: 0;
  1129. height: $fixedHeight;
  1130. width: 100vw;
  1131. font-size: 28rpx;
  1132. color: #333;
  1133. background-color: #fff;
  1134. z-index: 1;
  1135. .required::before {
  1136. content: '*';
  1137. color: red;
  1138. }
  1139. .info {
  1140. background-color: rgba(242, 242, 242, 0.792156862745098);
  1141. margin: 8rpx 0;
  1142. }
  1143. // .tabs {
  1144. // background-color: rgba(242, 242, 242, 0.792156862745098);
  1145. // padding-top: 20rpx;
  1146. // display: flex;
  1147. // justify-content: space-between;
  1148. // margin-bottom: 20rpx;
  1149. // .tab-item {
  1150. // padding-top: 20rpx;
  1151. // flex: 1;
  1152. // display: flex;
  1153. // justify-content: center;
  1154. // align-items: center;
  1155. // &.active {
  1156. // background: linear-gradient(180deg, rgba(75, 121, 2, 1) 0%, rgba(255, 255, 255, 1) 12%);
  1157. // }
  1158. // }
  1159. // }
  1160. .operations {
  1161. font-size: 32rpx;
  1162. padding: 10rpx 40rpx;
  1163. color: $theme-color;
  1164. }
  1165. .search-box {
  1166. padding: 10rpx;
  1167. }
  1168. .select-box {
  1169. border-bottom: 1rpx solid #d7d7d7;
  1170. white-space: nowrap;
  1171. }
  1172. }
  1173. /deep/.baseForm {
  1174. .u-form-item__body {
  1175. padding: 4px !important;
  1176. }
  1177. .assetType_box {
  1178. padding: 12rpx 18rpx;
  1179. width: 100%;
  1180. overflow: hidden;
  1181. white-space: nowrap;
  1182. text-overflow: ellipsis;
  1183. font-size: 30rpx;
  1184. }
  1185. }
  1186. /deep/.required-form .u-form-item__body__left__content__label::before {
  1187. content: '*';
  1188. color: red;
  1189. }
  1190. /deep/.u-form-item__body {
  1191. padding: 0 !important;
  1192. }
  1193. /deep/.u-input__content__field-wrapper__field,
  1194. /deep/.u-form-item {
  1195. font-size: 28rpx !important;
  1196. }
  1197. .isOut .list-container {
  1198. // padding-top: $fixedHeightOut;
  1199. margin-top: 10px;
  1200. }
  1201. .list-container {
  1202. padding-top: $fixedHeight;
  1203. padding-bottom: 80rpx;
  1204. }
  1205. .preview-box {
  1206. position: fixed;
  1207. bottom: 0;
  1208. width: 100vw !important;
  1209. border: 1px solid $theme-color;
  1210. color: $theme-color;
  1211. }
  1212. </style>