edit.vue 37 KB

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