addStock.vue 40 KB

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