addStock copy.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="新增入库单" @clickLeft="back">
  4. <!-- @clickRight="handleScan"
  5. right-icon="scan"
  6. > -->
  7. <!--右菜单-->
  8. <template slot="float">
  9. <!-- <view class="nav-icon-caozuo rightNav" @click="getsure">
  10. <u-button type="success" size="small" class="u-reset-button" text="确定"></u-button>
  11. </view> -->
  12. </template>
  13. </uni-nav-bar>
  14. <u-form labelPosition="left" :model="formData" :rules="rules" ref="formRef" labelWidth="260" labelAlign="right" class="baseForm">
  15. <!-- <u-form-item label="入库单号" borderBottom prop="bizNum">
  16. <u-input
  17. :value="formData.bizNum"
  18. disableColor="#ffffff"
  19. placeholder="请选择"
  20. disabled
  21. type="select"
  22. />
  23. </u-form-item> -->
  24. <u-form-item label="物品类型" class="required-form" borderBottom prop="assetType">
  25. <picker
  26. @change="e => handleDictPicker(e, dict[dictEnum.物品类型], 'assetType')"
  27. :value="pickerIndex"
  28. :range="dict[dictEnum.物品类型]"
  29. :disabled="!!(warehousingMaterialList && warehousingMaterialList.length)"
  30. range-key="dictValue">
  31. <u-input :value="warehousingName" :disableColor="!!(warehousingMaterialList && warehousingMaterialList.length) ? '#F5F7FA' : '#fff'" placeholder="请选择" disabled type="select" />
  32. </picker>
  33. <u-icon slot="right" name="arrow-right"></u-icon>
  34. </u-form-item>
  35. <u-form-item label="入库场景" class="required-form" prop="bizScene" borderBottom>
  36. <picker
  37. :disabled="!!(warehousingMaterialList && warehousingMaterialList.length)"
  38. @change="e => handlePicker(e, sceneState, 'bizScene')"
  39. :value="pickerIndex"
  40. :range="sceneState"
  41. range-key="name">
  42. <u-input
  43. :value="getDictName(sceneState, formData.bizScene)"
  44. :disableColor="!!(warehousingMaterialList && warehousingMaterialList.length) ? '#F5F7FA' : '#fff'"
  45. placeholder="请选择"
  46. disabled
  47. type="select" />
  48. </picker>
  49. <u-icon slot="right" name="arrow-right"></u-icon>
  50. </u-form-item>
  51. <u-form-item label="来源单据" prop="documentSource" borderBottom>
  52. <u-input type="text" placeholder="请输入" v-model="formData.documentSource" />
  53. </u-form-item>
  54. <u-form-item label="权属部门" prop="workOrder" borderBottom>
  55. <u-input :value="formData.deptName" disableColor="#ffffff" placeholder="请选择" disabled type="select" @click.native="$refs.treePicker._show()" />
  56. <u-icon slot="right" name="arrow-right"></u-icon>
  57. </u-form-item>
  58. <u-form-item label="入库登记人" prop="createUserName" borderBottom>
  59. <u-input disableColor="#ffffff" :value="formData.createUserName" placeholder="请选择" disabled type="text" />
  60. </u-form-item>
  61. <u-form-item label="审核人部门" prop="verifyDeptName" borderBottom>
  62. <u-input :value="formData.verifyDeptName" disableColor="#ffffff" placeholder="请选择" disabled type="select" clearable @click.native="$refs.verifyTreePicker._show()" />
  63. <view slot="right" style="display: flex; align-item: center">
  64. <u-icon v-show="formData.verifyDeptName" name="close-circle-fill" @click="verifyDeptConfirm([], '')"></u-icon>
  65. <u-icon name="arrow-right"></u-icon>
  66. </view>
  67. </u-form-item>
  68. <u-form-item label="审核人" prop="verifyId" borderBottom>
  69. <picker @change="e => handlePicker(e, userList, 'verifyId', 'verifyName')" :value="pickerIndex" :range="userList" range-key="name">
  70. <u-input :value="formData.verifyName" disableColor="#ffffff" placeholder="请选择" disabled type="select" />
  71. </picker>
  72. <view slot="right" style="display: flex; align-item: center">
  73. <u-icon v-show="formData.verifyName" name="close-circle-fill" @click="handlePicker(null, [], 'verifyId', 'verifyName')"></u-icon>
  74. <u-icon name="arrow-right"></u-icon>
  75. </view>
  76. </u-form-item>
  77. <u-form-item label="供应商" prop="supplierId" borderBottom>
  78. <picker @change="e => handlePicker(e, supplierList, 'supplierId', 'supplierName')" :value="pickerIndex" :range="supplierList" range-key="name">
  79. <u-input :value="formData.supplierName" disableColor="#ffffff" placeholder="请选择" disabled type="select" />
  80. </picker>
  81. <u-icon slot="right" name="arrow-right"></u-icon>
  82. </u-form-item>
  83. <u-form-item label="送货人" prop="deliveryName" borderBottom>
  84. <u-input type="text" placeholder="请输入" v-model="formData.deliveryName" />
  85. </u-form-item>
  86. <u-form-item label="送货人联系方式" prop="deliveryPhone" borderBottom>
  87. <u-input type="text" placeholder="请输入" v-model="formData.deliveryPhone" />
  88. </u-form-item>
  89. <u-form-item label="紧急状态" prop="urgent" borderBottom>
  90. <picker @change="e => handlePicker(e, emergencyState, 'urgent')" :value="pickerIndex" :range="emergencyState" range-key="name">
  91. <u-input :value="getDictName(emergencyState, formData.urgent)" disableColor="#ffffff" placeholder="请选择" disabled type="select" />
  92. </picker>
  93. <u-icon slot="right" name="arrow-right"></u-icon>
  94. </u-form-item>
  95. <!-- <u-form-item label="附件" prop="contentImage" borderBottom>
  96. <u-button type="success" @click="chooseFile">选择文件</u-button>
  97. </u-form-item> -->
  98. <u-form-item label="备注" prop="remark" borderBottom>
  99. <u-textarea confirmType="done" :maxlength="-1" height="80" v-model="formData.remark" placeholder="请输入"></u-textarea>
  100. </u-form-item>
  101. </u-form>
  102. <uni-collapse ref="collapse" v-model="collapseOpen">
  103. <uni-collapse-item :typeOpen="1" title="" name="collapse1" :open="true" :key="detailOpen" :show-animation="true">
  104. <template v-slot:title>
  105. <view class="detail-box">
  106. <view data-v-41027c34="" class="uni-collapse-item__title-wrap">
  107. <view data-v-41027c34="" class="uni-collapse-item__title-box uni-collapse-item__title-box-base">
  108. <!---->
  109. <text data-v-41027c34="" class="tag tag-base"><text></text></text>
  110. <text data-v-41027c34="" class="uni-collapse-item__title-text"><text>入库明细</text></text>
  111. </view>
  112. </view>
  113. <u-button type="success" size="small" class="selectEnterType" text="手动添加" @click.native.stop="selectType"></u-button>
  114. </view>
  115. </template>
  116. <u-form
  117. labelPosition="left"
  118. :model="{ warehousingMaterialList: warehousingMaterialList }"
  119. ref="lisrFormRef"
  120. labelWidth="190"
  121. :rules="listRules"
  122. errorType="none"
  123. labelAlign="right"
  124. :labelStyle="{
  125. fontSize: '28rpx'
  126. }">
  127. <view class="listContent">
  128. <view class="listBox" v-for="(item, index) in warehousingMaterialList" :key="index">
  129. <view class="listTit">
  130. <view class="name">{{ item.assetCode }}</view>
  131. <view class="delete" @click="getDelete(index)">
  132. <uni-icons custom-prefix="iconfont" type="icon-shanchu" size="24" color="#fa3534"></uni-icons>
  133. </view>
  134. </view>
  135. <view class="listCont" :class="{ save: item.isSave }">
  136. <view class="item w100">
  137. <u-form-item :label="`名称`">
  138. {{ item.assetName }}
  139. </u-form-item>
  140. </view>
  141. <view class="item" v-for="(itm, index) in tableHeader" :key="index">
  142. <u-form-item :label="itm.label">
  143. {{ item[itm.prop] }}
  144. </u-form-item>
  145. </view>
  146. <view class="item">
  147. <u-form-item label="批次号" :prop="`warehousingMaterialList.${index}.batchNum`">
  148. <text class="text-primary" @click="handleBatchSetting(item, index)">{{ item.batchNum || '设置' }}</text>
  149. </u-form-item>
  150. </view>
  151. <view class="item">
  152. <u-form-item label="最小包装单元" :prop="`warehousingMaterialList.${index}.measurementUnit`">{{ item.measurementUnit }}{{ item.unit }} /{{ item.minPackUnit }}</u-form-item>
  153. </view>
  154. <view class="item">
  155. <u-form-item label="包装数量" :prop="`warehousingMaterialList.${index}.outInNum`">
  156. {{ item.outInNum }}
  157. </u-form-item>
  158. </view>
  159. <view class="item">
  160. <u-form-item label="单价" prop="univalence">{{ item.univalence }}{{ { yuan: '元', wanyuan: '万元' }[item.univalenceUnit] }}</u-form-item>
  161. </view>
  162. <view class="item">
  163. <u-form-item label="总额" prop="contentImage" :show-overflow-tooltip="true">
  164. {{ calcSum(item.outInNum, item.measurementUnit, item.univalence, item) }}
  165. </u-form-item>
  166. </view>
  167. <view class="item" style="width: 100%">
  168. <u-form-item style="width: 100%" label="仓库" :prop="`warehousingMaterialList.${index}.cargoSpaceCode`">
  169. {{ `${item.warehouseName}-${item.areaName}-${item.shelfCode}-${item.cargoSpaceCode}` }}
  170. </u-form-item>
  171. </view>
  172. </view>
  173. </view>
  174. </view>
  175. </u-form>
  176. </uni-collapse-item>
  177. </uni-collapse>
  178. <view class="footBox">
  179. <view class="reg" @click="getsure">
  180. <uni-icons custom-prefix="iconfont" size="20" color="#fff"></uni-icons>
  181. 提交
  182. </view>
  183. </view>
  184. <ba-tree-picker ref="treePicker" :multiple="false" @select-change="deptConfirm" key="dept" title="选择部门" :localdata="deptList" valueKey="code" textKey="name" childrenKey="children" />
  185. <ba-tree-picker
  186. ref="verifyTreePicker"
  187. key="verify"
  188. :multiple="false"
  189. @select-change="verifyDeptConfirm"
  190. title="选择部门"
  191. :localdata="deptList"
  192. valueKey="code"
  193. textKey="name"
  194. childrenKey="children" />
  195. <WarehouseChoose ref="warehouseChooseRef" />
  196. <!-- <ScanCode></ScanCode> -->
  197. <!-- <l-file ref="lFile" @up-success="upSuccess"></l-file> -->
  198. </view>
  199. </template>
  200. <script>
  201. // import ScanCode from '@/components/ScanCode.vue'
  202. import { post, postJ, get, getJ } from '@/utils/api.js'
  203. import WarehouseChoose from '@/components/WarehouseChoose'
  204. import { warehousingType, sceneState, inputStatus, emergencyState, warehousingMaterialListTable, getDictName, materialType } from '../enum.js'
  205. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  206. // import addDetails from '@/components/addDetails'
  207. import UploadFileNew from '@/components/UploadFileNew'
  208. // import { getRuleNo } from '@/utils/utils.js'
  209. import { tableHeader } from '../common'
  210. import dictMixins from '@/mixins/dictMixins.js'
  211. export default {
  212. components: {
  213. WarehouseChoose,
  214. baTreePicker,
  215. UploadFileNew
  216. },
  217. mixins: [dictMixins],
  218. data() {
  219. return {
  220. collapseOpen: 'collapse1',
  221. curDateType: 'manufactureTime',
  222. emergencyState,
  223. warehousingType,
  224. materialType,
  225. sceneState,
  226. inputStatus,
  227. getDictName,
  228. detailOpen: false,
  229. codeOpen: false,
  230. deptList: [], //部门
  231. supplierList: [], //供应商
  232. formData: {
  233. // bizNum: getRuleNo('IN'),
  234. assetType: '',
  235. bizScene: '',
  236. deptName: '',
  237. deptCode: '',
  238. deptName: '',
  239. createUserName: '',
  240. registerId: '',
  241. verifyId: '',
  242. verifyName: '',
  243. verifyDeptCode: '',
  244. verifyDeptName: '',
  245. // outInTime: '',
  246. deliveryName: '',
  247. deliveryPhone: '',
  248. urgent: '',
  249. contentImage: [],
  250. remark: '',
  251. supplierId: '',
  252. supplierName: ''
  253. },
  254. statusList: [
  255. {
  256. id: 1,
  257. name: '紧急'
  258. },
  259. {
  260. id: 2,
  261. name: '中等'
  262. },
  263. {
  264. id: 1,
  265. name: '普通'
  266. }
  267. ], //紧急状态
  268. pickerIndex: 0,
  269. warehousingMaterialList: [],
  270. userList: [],
  271. rules: {
  272. assetType: {
  273. type: 'number',
  274. required: true,
  275. message: '请选择入库产品类型',
  276. trigger: ['blur', 'change']
  277. },
  278. bizScene: {
  279. type: 'number',
  280. required: true,
  281. message: '请选择入库场景',
  282. trigger: ['blur', 'change']
  283. }
  284. // contentImage: {
  285. // type: 'array',
  286. // required: true,
  287. // message: '请上传附件',
  288. // trigger: ['blur', 'change']
  289. // }
  290. },
  291. settingIndex: 0
  292. }
  293. },
  294. onShow() {
  295. // const _this = this
  296. // uni.$off('scancode') // 每次进来先 移除全局自定义事件监听器
  297. // uni.$on('scancode', function (data) {
  298. // uni.navigateBack({
  299. // delta: 1
  300. // })
  301. // _this.qrContent = data.code.trim()
  302. // _this.handleScan()
  303. // })
  304. this.collapseOpen = 'collapse1'
  305. },
  306. onLoad(options) {
  307. this.requestDict('物品类型')
  308. this.getDept()
  309. this.getSupplier()
  310. const userInfo = uni.getStorageSync('userInfo')
  311. this.formData.createUserName = userInfo.name
  312. this.formData.registerId = userInfo.id
  313. uni.$on('setSelectList', selectList => {
  314. console.log(selectList, '------------------22---------')
  315. if (selectList?.length) {
  316. this.warehousingMaterialList.push(
  317. ...selectList.map(next => {
  318. delete next.updateTime
  319. delete next.createTime
  320. let cur = {}
  321. if (this.formData.bizScene == 5) {
  322. cur = {
  323. cargoSpaceCode: '', //货位编码
  324. cargoSpaceId: '', //货位id
  325. shelfId: '', //货架id
  326. shelfCode: '', //货架名称
  327. areaId: '', //库区id
  328. areaName: '', //库区名称
  329. warehouseId: '', //仓库id
  330. warehouseName: '', //仓库名称
  331. assetType: this.formData.assetType,
  332. expirationDate: '',
  333. batchNum: '',
  334. measurementUnit: '',
  335. bizStatus: 1,
  336. contentImage: [],
  337. ...next
  338. }
  339. } else {
  340. next.realInventoryAmount = next.realInventoryAmount || 0
  341. cur = {
  342. ...next,
  343. cargoSpaceCode: '', //货位编码
  344. cargoSpaceId: '', //货位id
  345. shelfId: '', //货架id
  346. shelfCode: '', //货架名称
  347. areaId: '', //库区id
  348. areaName: '', //库区名称
  349. warehouseId: '', //仓库id
  350. warehouseName: '', //仓库名称
  351. assetType: this.formData.assetType,
  352. expirationDate: '',
  353. batchNum: '',
  354. outInNum: '',
  355. measurementUnit: '',
  356. bizStatus: 1,
  357. contentImage: []
  358. }
  359. }
  360. return cur
  361. })
  362. )
  363. console.log(this.warehousingMaterialList, '------------------this.warehousingMaterialList---------')
  364. setTimeout(() => {
  365. this.detailOpen = !this.detailOpen
  366. this.$refs.collapse && this.$refs.collapse.resize()
  367. }, 0)
  368. }
  369. })
  370. // 明细信息填写
  371. uni.$on('batchNumBack', warehousingMaterialList => {
  372. if (warehousingMaterialList?.length) {
  373. this.warehousingMaterialList = warehousingMaterialList
  374. }
  375. })
  376. },
  377. mounted() {
  378. // this.getAddDetails();
  379. },
  380. computed: {
  381. tableHeader() {
  382. return tableHeader(this.formData.assetType)
  383. },
  384. materialCodeReqList() {
  385. return this.warehousingMaterialList.map(i => i.warehouseLedgerDetails || []).flat()
  386. },
  387. isMaterial() {
  388. return this.formData.assetType == 3
  389. },
  390. warehousingName() {
  391. this.warehousingMaterialList = []
  392. return this.getDictValue('物品类型', this.formData.assetType)
  393. },
  394. listRules() {
  395. return this.warehousingMaterialList.reduce((cur, pre, index) => {
  396. return {
  397. ...cur,
  398. [`warehousingMaterialList.${index}.cargoSpaceCode`]: {
  399. type: 'string',
  400. required: true,
  401. trigger: ['blur', 'change']
  402. },
  403. [`warehousingMaterialList.${index}.measurementUnit`]: {
  404. type: 'string',
  405. required: true,
  406. trigger: ['blur', 'change']
  407. },
  408. [`warehousingMaterialList.${index}.outInNum`]: {
  409. type: 'string',
  410. required: true,
  411. trigger: ['blur', 'change']
  412. },
  413. [`warehousingMaterialList.${index}.batchNum`]: {
  414. type: 'string',
  415. required: true,
  416. trigger: ['blur', 'change']
  417. }
  418. }
  419. }, {})
  420. }
  421. },
  422. methods: {
  423. handleScan() {
  424. if (this.formData.bizScene !== '' && this.formData.bizScene != 5) {
  425. uni.showModal({
  426. title: '提示',
  427. content: '仅退还入库支持扫码,是否清除已选明细并切换至退还入库?',
  428. success: async res => {
  429. if (res.confirm) {
  430. this.warehousingMaterialList = []
  431. this.formData.bizScene = 5
  432. this.getData()
  433. }
  434. }
  435. })
  436. return
  437. }
  438. this.getData()
  439. },
  440. // goScan () {
  441. // uni.navigateTo({
  442. // url: '/pages/ScanCode/ScanCode'
  443. // })
  444. // },
  445. // 根据条码请求设备数据 @_@
  446. getData() {
  447. let par = {
  448. barType: this.qrContent.split('@_@')[1] || 0,
  449. qrContent: this.qrContent
  450. }
  451. uni.showLoading({
  452. title: '加载中',
  453. mask: true
  454. })
  455. postJ(this.apiUrl + '/scan/getAssetInfo', par)
  456. .then(res => {
  457. let data = res.data
  458. console.log(data, 'qrContent')
  459. if (data.assetType === undefined) {
  460. uni.showToast({
  461. title: '请扫码物品码',
  462. icon: 'none'
  463. })
  464. return
  465. } else if (data.source == 2) {
  466. uni.showModal({
  467. title: '提示',
  468. content: '当前物品已在库',
  469. success: async res => {}
  470. })
  471. return
  472. } else if (this.warehousingName && this.formData.assetType != data.assetType) {
  473. uni.showToast({
  474. title: `当前物品不属于${this.warehousingName}分类`,
  475. icon: 'none'
  476. })
  477. return
  478. }
  479. this.setScanMaterial(data)
  480. })
  481. .finally(() => {
  482. uni.hideLoading()
  483. })
  484. },
  485. async setScanMaterial(data) {
  486. this.formData.assetType = data.assetType
  487. this.formData.bizScene = 5
  488. const curMap = {
  489. assetId: 'id',
  490. assetCode: 'informationCode', //编码
  491. assetName: 'informationName', //名称
  492. materialId: 'id',
  493. materialName: 'informationName',
  494. batchNo: '', //批次号
  495. unit: 'measuringUnit', //单位
  496. minPackUnit: 'packingUnit' //最小包装单位
  497. }
  498. let obj = {}
  499. for (const key in curMap) {
  500. obj[key] = (curMap[key] && data.information[curMap[key]]) || ''
  501. }
  502. let detailObj = uni.$u.deepClone(obj)
  503. detailObj.onlyCode = data.assetCode
  504. obj = {
  505. ...data.information,
  506. ...obj,
  507. ...{
  508. cargoSpaceCode: '', //货位编码
  509. cargoSpaceId: '', //货位id
  510. shelfId: '', //货架id
  511. shelfCode: '', //货架名称
  512. areaId: '', //库区id
  513. areaName: '', //库区名称
  514. warehouseId: '', //仓库id
  515. warehouseName: '', //仓库名称
  516. measurementUnit: '',
  517. bizStatus: 1,
  518. contentImage: []
  519. }
  520. }
  521. let warehouseLedgerDetails = [detailObj]
  522. this.warehousingMaterialList.push(obj)
  523. this.$set(this.warehousingMaterialList[this.warehousingMaterialList.length - 1], 'warehouseLedgerDetails', warehouseLedgerDetails)
  524. this.$set(this.warehousingMaterialList[this.warehousingMaterialList.length - 1], 'selfWarehouseLedgerDetails', uni.$u.deepClone(warehouseLedgerDetails))
  525. this.handleBatchSetting(obj, this.warehousingMaterialList.length - 1, true)
  526. },
  527. calcSum(a, b, c, row) {
  528. if ((Number.isNaN(+a) && a !== '') || (Number.isNaN(+b) && b !== '') || (Number.isNaN(+c) && c !== '')) {
  529. return ''
  530. }
  531. return a * b * c + { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
  532. },
  533. handleBatchSetting(item, index, isScan = false) {
  534. this.settingIndex = index
  535. uni.setStorageSync('inputData', item)
  536. uni.setStorageSync('warehousingMaterialList', this.warehousingMaterialList || [])
  537. uni.navigateTo({
  538. url: '/pages/warehouse/enterHouse/batchNumEdit?bizScene=' + this.formData.bizScene + '&assetType=' + this.formData.assetType + '&index=' + index + '&isScan=' + isScan
  539. })
  540. },
  541. chooseFile(file) {
  542. console.log(file)
  543. this.$refs.lFile.upload({
  544. //替换为你的上传接口地址
  545. url: this.apiUrl + '/data/doc/add',
  546. // 服务端接收附件的key
  547. name: 'file',
  548. //根据你接口需求自定义 (优先不传content-type,安卓端无法收到参数再传)
  549. header: {
  550. Authorization: 'bearer eyJhbGciO',
  551. uid: '27682',
  552. client: 'app'
  553. }
  554. // 限制选择附件的大小上限,默认10M
  555. // maxSize: 20,
  556. // 若需要在body单独添加附件名或附件大小如下方式传入组件:
  557. // addName: '后端要的附件名称字段key,此处请勿写name的同值如(file),会覆盖name',
  558. // addSize: '后端要的附件大小字段key'
  559. // body参数直接写key,value,如:
  560. // date: '2020-1-1',
  561. // key2: 'value2',
  562. })
  563. },
  564. // 抬头下拉信息保存
  565. handlePicker(e, list, idKey, nameKey) {
  566. if (idKey) {
  567. this.formData[idKey] = list[e?.detail.value]?.id
  568. }
  569. if (nameKey) {
  570. this.formData[nameKey] = list[e?.detail.value]?.name
  571. }
  572. this.$nextTick(() => {
  573. if (idKey === 'assetType' || idKey === 'bizScene') {
  574. this.$refs.formRef.validateField(idKey)
  575. }
  576. })
  577. },
  578. // 抬头下拉信息保存
  579. handleDictPicker(e, list, idKey, nameKey) {
  580. if (idKey) {
  581. this.formData[idKey] = list[e?.detail.value]?.dictCode
  582. }
  583. if (nameKey) {
  584. this.formData[nameKey] = list[e?.detail.value]?.dictValue
  585. }
  586. this.$nextTick(() => {
  587. if (idKey === 'assetType' || idKey === 'bizScene') {
  588. this.$refs.formRef.validateField(idKey)
  589. }
  590. })
  591. },
  592. // 明细下拉信息保存
  593. handleListPicker(e, list, item, idKey, nameKey) {
  594. if (idKey) {
  595. item[idKey] = list[e.detail.value].id
  596. }
  597. if (nameKey) {
  598. item[nameKey] = list[e.detail.value].name
  599. }
  600. },
  601. //获取仓库信息
  602. handleWarehouseChoose(item) {
  603. this.$refs.warehouseChooseRef.openDefault(item, res => {
  604. Object.assign(item, res)
  605. })
  606. },
  607. //状态
  608. getstatus(e) {
  609. this.formData.houseType = this.statusList[e.detail.value].name
  610. },
  611. //上传附件
  612. getUpFlie(res) {
  613. console.log(res)
  614. let arr = []
  615. res.forEach(item => {
  616. let obj = {
  617. accessUrl: item.accessUrl,
  618. docId: item.docId,
  619. name: item.name,
  620. size: item.size,
  621. url: item.url,
  622. type: 1
  623. }
  624. // obj.type.id = item.type.id;
  625. // obj.type.value = item.type.name;
  626. arr.push(obj)
  627. })
  628. this.formData.attaments = arr
  629. },
  630. //选择入库类别跳转
  631. selectType() {
  632. if (!this.formData.assetType) {
  633. uni.showToast({
  634. title: '请选择入库类型',
  635. icon: 'none'
  636. })
  637. return
  638. }
  639. if (!this.formData.bizScene) {
  640. uni.showToast({
  641. title: '请选择入库场景',
  642. icon: 'none'
  643. })
  644. return
  645. }
  646. uni.navigateTo({
  647. url: '/pages/warehouse/enterHouse/selectEnterType?warehousingType=' + this.formData.assetType + '&warehousingName=' + this.warehousingName + '&bizScene=' + this.formData.bizScene
  648. })
  649. },
  650. //删除
  651. getDelete(index) {
  652. uni.showModal({
  653. title: '提示',
  654. content: '是否删除当前明细',
  655. success: res => {
  656. if (res.confirm) {
  657. this.warehousingMaterialList.splice(index, 1)
  658. }
  659. }
  660. })
  661. },
  662. // 入库操作
  663. listEdit(row) {
  664. this.$set(row, 'isSave', false)
  665. },
  666. listSave(row, index) {
  667. const fileds = [`warehousingMaterialList.${index}.cargoSpaceCode`, `warehousingMaterialList.${index}.batchNum`]
  668. if (this.formData.bizScene != 5) {
  669. fileds.push(...[`warehousingMaterialList.${index}.outInNum`, `warehousingMaterialList.${index}.measurementUnit`])
  670. } else if (this.warehousingMaterialList.some(i => !i.selfWarehouseLedgerDetails?.length)) {
  671. uni.showToast({
  672. title: '请选择资产编号!',
  673. icon: 'none'
  674. })
  675. return
  676. }
  677. Promise.all(
  678. fileds.map(
  679. item =>
  680. new Promise(async (resolve, rej) => {
  681. this.$refs.lisrFormRef.validateField(item, err => {
  682. if (err?.length) {
  683. rej(err)
  684. } else {
  685. resolve()
  686. }
  687. })
  688. })
  689. )
  690. )
  691. .then(res => {
  692. this.$set(row, 'isSave', true)
  693. if (this.formData.bizScene != 5) {
  694. this.createMaterialCode(row)
  695. } else {
  696. // 退还
  697. this.createMaterialCodeReturn(row)
  698. }
  699. })
  700. .catch(err => {
  701. uni.showToast({
  702. icon: 'error',
  703. title: '请填入必填项!'
  704. })
  705. })
  706. },
  707. //入库明细删除
  708. listDel(row, index) {
  709. this.warehousingMaterialList.splice(index, 1)
  710. },
  711. // 入库明细生成条码信息
  712. async createMaterialCode(row) {
  713. // 添加相同物品重新更新明细 原料编码
  714. const list = this.warehousingMaterialList.filter(i => i.assetCode === row.assetCode && i.batchNum === row.batchNum && i.isSave)
  715. const num = list.reduce((num, pre) => {
  716. num += row.isUnpack ? pre.outInNum * pre.measurementUnit : pre.outInNum
  717. return num
  718. }, 0)
  719. const res = await postJ(this.apiUrl + '/outInWarehouse/getAssetNum', {
  720. batchNum: row.batchNum,
  721. assetCode: row.assetCode,
  722. num
  723. })
  724. if (res?.success) {
  725. list.forEach(item => {
  726. if (item.warehouseLedgerDetails?.length) {
  727. item.warehouseLedgerDetails.forEach(i => {
  728. i.onlyCode = res.data.shift().onlyCode
  729. })
  730. } else {
  731. this.$set(
  732. item,
  733. 'warehouseLedgerDetails',
  734. Array.from(new Array(item.isUnpack ? item.outInNum * item.measurementUnit : +item.outInNum), (val, idx) => {
  735. return {
  736. ...item,
  737. onlyCode: res.data.shift().onlyCode,
  738. bizStatus: 1,
  739. contentImage: []
  740. }
  741. })
  742. )
  743. }
  744. })
  745. }
  746. // 添加相同物品,重复批次号 重新更新明细 包装编码
  747. const batchList = this.warehousingMaterialList.filter(i => i.batchNum === row.batchNum && i.isSave)
  748. if (batchList.length) {
  749. const num = batchList.reduce((num, pre) => {
  750. num += +pre.outInNum
  751. return num
  752. }, 0)
  753. const res1 = await postJ(this.apiUrl + '/outInWarehouse/getAssetNum', {
  754. batchNum: row.batchNum,
  755. num
  756. })
  757. if (res1?.success) {
  758. batchList.forEach(item => {
  759. let num = res1.data.shift()?.num
  760. let measurementUnit = item.measurementUnit
  761. if (item.warehouseLedgerDetails?.length) {
  762. item.warehouseLedgerDetails.forEach((i, index) => {
  763. this.$set(i, 'num', num)
  764. if (!item.isUnpack) {
  765. if (index < item.warehouseLedgerDetails.length - 1) {
  766. num = res1.data.shift()?.num
  767. }
  768. } else {
  769. // 拆包的包装编码一致
  770. measurementUnit--
  771. if (measurementUnit === 0 && index < item.warehouseLedgerDetails.length - 1) {
  772. measurementUnit = item.measurementUnit
  773. num = res1.data.shift()?.num
  774. }
  775. }
  776. })
  777. }
  778. })
  779. }
  780. }
  781. },
  782. // 入库明细生成条码信息 退还
  783. async createMaterialCodeReturn(row) {
  784. // 添加相同物品重新更新明细 原料编码
  785. const list = this.warehousingMaterialList.filter(i => i.batchNum === row.batchNum && i.isSave)
  786. // 退还
  787. const res = await postJ(this.apiUrl + '/outInWarehouse/getAssetNum', {
  788. batchNum: row.batchNum,
  789. num: list.reduce((num, pre) => {
  790. num += pre.selfWarehouseLedgerDetails.length
  791. return num
  792. }, 0)
  793. })
  794. if (res?.success) {
  795. list.forEach(item => {
  796. const num = res.data.shift().num
  797. if (item.warehouseLedgerDetails?.length) {
  798. item.warehouseLedgerDetails.forEach(i => {
  799. i.num = num
  800. if (!item.isUnpack) {
  801. // 拆包的包装编码一致
  802. num = res.data.shift()?.num
  803. }
  804. })
  805. } else {
  806. this.$set(
  807. item,
  808. 'warehouseLedgerDetails',
  809. item.selfWarehouseLedgerDetails.map((val, idx) => {
  810. let obj = {
  811. ...val,
  812. bizStatus: 1,
  813. batchNum: item.batchNum,
  814. cargoSpaceCode: item.cargoSpaceCode, //货位编码
  815. cargoSpaceId: item.cargoSpaceId, //货位id
  816. shelfId: item.shelfId, //货架id
  817. shelfCode: item.shelfCode, //货架名称
  818. areaId: item.areaId, //库区id
  819. areaName: item.areaName, //库区名称
  820. warehouseId: item.warehouseId, //仓库id
  821. warehouseName: item.warehouseName, //仓库名称
  822. num
  823. }
  824. if (!item.isUnpack) {
  825. // 拆包的包装编码一致
  826. num = res.data.shift()?.num
  827. }
  828. return obj
  829. })
  830. )
  831. }
  832. })
  833. }
  834. },
  835. //确定提交
  836. getsure() {
  837. this.$refs.formRef.validate().then(res => {
  838. if (!this.warehousingMaterialList?.length) {
  839. uni.showToast({
  840. icon: 'error',
  841. title: '请添加明细!'
  842. })
  843. return
  844. } else if (this.warehousingMaterialList.some(item => !item.warehouseLedgerDetails?.length)) {
  845. uni.showToast({
  846. icon: 'error',
  847. title: '请完善明细信息!'
  848. })
  849. return
  850. }
  851. const params = {
  852. outInWarehouse: { ...this.formData, bizStatus: 1 },
  853. warehouseLedgerInfos: this.warehousingMaterialList
  854. }
  855. postJ(this.apiUrl + '/outInWarehouse/add', params).then(res => {
  856. if (res?.success) {
  857. uni.showToast({
  858. icon: 'success',
  859. title: '保存成功'
  860. })
  861. setTimeout(() => {
  862. uni.navigateBack({
  863. delta: 1
  864. })
  865. }, 1500)
  866. }
  867. })
  868. })
  869. },
  870. // 部门确认
  871. deptConfirm(data, name) {
  872. this.formData.deptName = name
  873. this.formData.deptCode = data[0]
  874. },
  875. // 部门确认
  876. verifyDeptConfirm(data, name) {
  877. this.formData.verifyDeptCode = data[0]
  878. this.formData.verifyDeptName = name
  879. this.formData.verifyId = ''
  880. this.formData.verifyName = ''
  881. this.getUser(data[0])
  882. },
  883. // 获取部门
  884. getDept() {
  885. get(this.apiUrl + '/main/org/dept/effectiveTree').then(res => {
  886. if (res?.success) {
  887. this.deptList = res.data
  888. }
  889. })
  890. },
  891. // 获取供应商
  892. getSupplier() {
  893. post(this.apiUrl + `/main/supplier/list?page=1&size=999`, {
  894. page: 1,
  895. size: 999
  896. }).then(res => {
  897. if (res?.success) {
  898. this.supplierList = res.data.items
  899. }
  900. })
  901. },
  902. // 获取人员
  903. getUser(deptCode) {
  904. post(this.apiUrl + '/main/user/list', {
  905. deptCode,
  906. page: 1,
  907. size: 9999
  908. }).then(res => {
  909. if (res?.success) {
  910. this.userList = res.data.items.map(item => {
  911. item.name = item.trueName
  912. item.id = item.userId
  913. return item
  914. })
  915. }
  916. })
  917. }
  918. }
  919. }
  920. </script>
  921. <style lang="scss" scoped>
  922. .mainBox {
  923. padding-bottom: 120rpx;
  924. /deep/.required-form .u-form-item__body__left__content__label::before {
  925. content: '*';
  926. color: red;
  927. }
  928. }
  929. .picList {
  930. display: flex;
  931. align-items: center;
  932. justify-items: flex-start;
  933. flex-wrap: wrap;
  934. }
  935. /deep/.baseForm {
  936. .u-form-item__body {
  937. padding: 10rpx !important;
  938. }
  939. }
  940. /deep/.picList .u-image {
  941. margin-right: 10rpx;
  942. margin-bottom: 10rpx;
  943. }
  944. /deep/.cLine .u-line:nth-child(1) {
  945. border-bottom: none !important;
  946. }
  947. .detail-box {
  948. position: relative;
  949. display: flex;
  950. justify-content: space-between;
  951. align-items: center;
  952. /deep/uni-button {
  953. margin: 0 !important;
  954. width: 180rpx;
  955. }
  956. }
  957. .footBox {
  958. position: fixed;
  959. left: 0px;
  960. bottom: 0px;
  961. height: 100rpx;
  962. width: 100%;
  963. display: flex;
  964. align-items: center;
  965. justify-content: space-between;
  966. view {
  967. width: 100%;
  968. height: 100%;
  969. text-align: center;
  970. color: #fff;
  971. display: flex;
  972. align-items: center;
  973. justify-content: center;
  974. }
  975. .reg {
  976. background: $u-success-dark;
  977. }
  978. .add {
  979. background: $uni-color-primary;
  980. }
  981. .uni-icons {
  982. margin-right: 8rpx !important;
  983. }
  984. }
  985. .listBox {
  986. padding: 20rpx 10rpx;
  987. border-bottom: 1px #f2f2f2 solid;
  988. position: relative;
  989. &.code {
  990. .label {
  991. width: 120rpx !important;
  992. }
  993. }
  994. .listTit {
  995. width: 100%;
  996. display: flex;
  997. justify-content: space-between;
  998. align-items: center;
  999. /deep/uni-button {
  1000. margin-right: 20rpx;
  1001. width: 100rpx;
  1002. &.assets {
  1003. width: 180rpx;
  1004. }
  1005. }
  1006. .name {
  1007. width: 50%;
  1008. margin-left: 10px;
  1009. overflow: hidden;
  1010. white-space: nowrap;
  1011. -o-text-overflow: ellipsis;
  1012. text-overflow: ellipsis;
  1013. font-size: 30rpx;
  1014. }
  1015. .weight {
  1016. width: 30%;
  1017. font-size: 30rpx;
  1018. margin-left: auto;
  1019. margin-right: 60rpx;
  1020. position: relative;
  1021. display: flex;
  1022. input {
  1023. margin-right: 10rpx;
  1024. border: 1px solid black;
  1025. width: 40%;
  1026. height: 20rpx;
  1027. }
  1028. }
  1029. .weight::after {
  1030. position: absolute;
  1031. right: -30rpx;
  1032. top: 50%;
  1033. content: '';
  1034. background: #eee;
  1035. width: 1px;
  1036. height: 28rpx;
  1037. margin-top: -14rpx;
  1038. }
  1039. }
  1040. .more {
  1041. position: absolute;
  1042. bottom: 26rpx;
  1043. right: 30rpx;
  1044. font-size: 28rpx;
  1045. color: #666;
  1046. }
  1047. }
  1048. .listCont {
  1049. display: flex;
  1050. align-items: center;
  1051. flex-wrap: wrap;
  1052. margin-top: 20rpx;
  1053. margin-left: 10rpx;
  1054. &.save {
  1055. .u-input {
  1056. border: none;
  1057. }
  1058. }
  1059. .u-input {
  1060. border: 1px solid rgb(229, 229, 229);
  1061. height: 15rpx !important;
  1062. }
  1063. .item {
  1064. width: 50%;
  1065. font-size: 28rpx;
  1066. margin-bottom: 10rpx;
  1067. // line-height: 45rpx;
  1068. // overflow: hidden;
  1069. // white-space: nowrap;
  1070. // text-overflow: ellipsis;
  1071. // -o-text-overflow: ellipsis;
  1072. // color: #000;
  1073. // display: flex;
  1074. /deep/.u-form-item__body {
  1075. padding: 0 !important;
  1076. }
  1077. /deep/.u-input__content__field-wrapper__field,
  1078. /deep/.u-form-item {
  1079. font-size: 28rpx !important;
  1080. }
  1081. text.label {
  1082. width: 120rpx;
  1083. display: inline-block;
  1084. text-align: right;
  1085. margin-right: 20rpx;
  1086. margin-bottom: 20rpx;
  1087. }
  1088. /deep/.uni-date__x-input {
  1089. height: 40rpx;
  1090. font-size: 28rpx;
  1091. }
  1092. /deep/.uni-date {
  1093. width: 48%;
  1094. display: inline-block;
  1095. .uni-icons {
  1096. display: none !important;
  1097. }
  1098. .uni-date-x {
  1099. padding: 0 !important;
  1100. }
  1101. }
  1102. }
  1103. .item text {
  1104. color: #666;
  1105. }
  1106. }
  1107. .listBox:last-child {
  1108. border: none !important;
  1109. }
  1110. .textBox {
  1111. border: 1px #f2f2f2 solid;
  1112. height: 160px;
  1113. display: block;
  1114. width: auto !important;
  1115. }
  1116. .saveBtn {
  1117. width: 50%;
  1118. margin: 40rpx auto;
  1119. }
  1120. .top-css {
  1121. border-bottom: 1px solid rgb(207, 204, 204);
  1122. }
  1123. </style>