edit.vue 36 KB

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