edit.vue 38 KB

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