add.vue 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <el-form
  5. :model="formData"
  6. ref="formName"
  7. label-width="110px"
  8. :rules="rules"
  9. >
  10. <el-row :gutter="20">
  11. <!-- <el-col :span="8">
  12. <el-form-item label="出库单号" prop="bizNum">
  13. <el-input :value="formData.bizNum" disabled /></el-form-item
  14. ></el-col> -->
  15. <el-col :span="8">
  16. <el-form-item label="出库场景" prop="bizType">
  17. <el-select
  18. filterable
  19. placeholder="请选择"
  20. v-model="formData.bizType"
  21. clearable
  22. @change="handleBizSceneChange"
  23. :disabled="
  24. !!(warehousingMaterialList && warehousingMaterialList.length)
  25. "
  26. >
  27. <el-option
  28. v-for="item in outputSceneState"
  29. :key="item.code"
  30. :value="item.code + ''"
  31. :label="item.label"
  32. ></el-option>
  33. </el-select> </el-form-item
  34. ></el-col>
  35. <el-col :span="8">
  36. <el-form-item
  37. :label="
  38. formData.bizType == 3
  39. ? '销售订单'
  40. : formData.bizType == 4
  41. ? '领料单'
  42. : '来源单据'
  43. "
  44. prop="documentSource"
  45. :rules="[
  46. { required: true, message: '请选择来源单据', trigger: 'change' }
  47. ]"
  48. v-if="formData.extInfo.assetType == 7 && formData.bizType == 4"
  49. >
  50. <el-select
  51. filterable
  52. v-model="formData.documentSource"
  53. :disabled="
  54. !!(formData.documentSource && warehousingMaterialList.length)
  55. "
  56. clearable
  57. placeholder="请输入"
  58. @change="handleDocumentSourceChange"
  59. >
  60. <el-option
  61. v-for="item in options"
  62. :key="item"
  63. :label="item"
  64. :value="item"
  65. >
  66. </el-option> </el-select
  67. ></el-form-item>
  68. <el-form-item
  69. :label="
  70. formData.bizType == 3
  71. ? '销售订单'
  72. : formData.bizType == 4
  73. ? '领料单'
  74. : '来源单据'
  75. "
  76. v-else
  77. prop="documentSource"
  78. >
  79. <el-input
  80. @input="$forceUpdate()"
  81. placeholder="请输入"
  82. @change="handleDocumentSourceChange"
  83. v-model="formData.documentSource"
  84. @click.native="
  85. formData.bizType == 4
  86. ? handlePickorder()
  87. : formData.bizType == 3
  88. ? handleEom()
  89. : null
  90. "
  91. >
  92. <el-button
  93. v-if="formData.bizType == 4 || formData.bizType == 3"
  94. slot="append"
  95. icon="el-icon-circle-close"
  96. @click.stop="onClear"
  97. ></el-button>
  98. </el-input>
  99. </el-form-item>
  100. </el-col>
  101. <el-col :span="8">
  102. <el-form-item label="出库物品类型" prop="extInfo.assetType">
  103. <!-- <DictSelection
  104. dictName="类型用途"
  105. :disabled="
  106. !!(warehousingMaterialList && warehousingMaterialList.length)
  107. "
  108. clearable
  109. v-model="formData.extInfo.assetType"
  110. @itemChange="handleChange"
  111. /> -->
  112. <!-- <el-select
  113. :disabled="
  114. !!(warehousingMaterialList && warehousingMaterialList.length)
  115. "
  116. clearable
  117. v-model="formData.extInfo.assetType"
  118. @change="handleChanges"
  119. >
  120. <el-option
  121. v-for="(item, index) in codeList"
  122. :key="index"
  123. :label="item.dictValue"
  124. :value="item.dictCode"
  125. ></el-option>
  126. </el-select> -->
  127. <selectTree
  128. ref="trees"
  129. class="form-ipt"
  130. :isBindPlan="
  131. !!(warehousingMaterialList && warehousingMaterialList.length)
  132. "
  133. size="medium"
  134. style="width: 100%"
  135. clearable
  136. :options="codeList"
  137. :props="{
  138. value: 'id',
  139. label: 'name',
  140. children: 'children'
  141. }"
  142. @getValue="codeListValue"
  143. :isAll="false"
  144. />
  145. </el-form-item>
  146. </el-col>
  147. <el-col :span="8">
  148. <el-form-item label="权属部门" prop="deptName">
  149. <el-input
  150. placeholder="权属部门"
  151. disabled
  152. v-model="formData.extInfo.deptName"
  153. clearable
  154. />
  155. </el-form-item>
  156. <!-- <selectTree
  157. ref="tree"
  158. style="width: 100%"
  159. size="medium"
  160. :initStr="formData.deptName"
  161. clearable
  162. :options="treeList"
  163. :props="{
  164. value: 'code',
  165. label: 'name',
  166. children: 'children'
  167. }"
  168. @getValue="deptClick"
  169. /> -->
  170. </el-col>
  171. <el-col :span="8">
  172. <el-form-item label="出库登记人">
  173. <el-input
  174. placeholder="登记人"
  175. disabled
  176. v-model="formData.extInfo.createUserName"
  177. clearable /></el-form-item
  178. ></el-col>
  179. <!-- <el-col :span="8">
  180. <el-form-item label="出库时间" prop="outInTime">
  181. <el-date-picker
  182. v-model="formData.outInTime"
  183. clearable
  184. type="datetime"
  185. value-format="yyyy-MM-dd HH:mm:ss"
  186. placeholder="选择日期"
  187. >
  188. </el-date-picker></el-form-item
  189. ></el-col> -->
  190. <el-col :span="8">
  191. <el-form-item label="领料人" prop="fromUser">
  192. <el-select
  193. v-model="formData.fromUser"
  194. filterable
  195. placeholder="请选择领料人"
  196. >
  197. <el-option
  198. v-for="item in fromUserList"
  199. :key="item.id"
  200. :label="item.name"
  201. :value="item.id"
  202. @click.native="
  203. () => (formData.extInfo.fromUserPhone = item.phone)
  204. "
  205. >
  206. </el-option>
  207. </el-select> </el-form-item
  208. ></el-col>
  209. <el-col :span="8">
  210. <el-form-item label="领料人联系方式" prop="fromUserPhone">
  211. <el-input
  212. placeholder="请输入"
  213. disabled
  214. v-model="formData.extInfo.fromUserPhone"
  215. clearable /></el-form-item
  216. ></el-col>
  217. <!-- <el-col :span="8">
  218. <el-form-item label="紧急状态" prop="urgent">
  219. <el-select
  220. filterable
  221. placeholder="请选择"
  222. v-model="formData.extInfo.urgent"
  223. clearable
  224. >
  225. <el-option
  226. v-for="item in emergencyState"
  227. :key="item.code"
  228. :value="item.code"
  229. :label="item.label"
  230. ></el-option>
  231. </el-select> </el-form-item
  232. ></el-col> -->
  233. <el-col :span="8">
  234. <el-form-item label="审核人部门" prop="verifyDeptName">
  235. <selectTree
  236. ref="tree"
  237. class="form-ipt"
  238. size="medium"
  239. style="width: 100%"
  240. clearable
  241. :options="treeList"
  242. :props="{
  243. value: 'code',
  244. label: 'name',
  245. children: 'children'
  246. }"
  247. @getValue="auditorDeptClick"
  248. />
  249. </el-form-item>
  250. </el-col>
  251. <el-col :span="8">
  252. <el-form-item label="审核人" prop="verifyId">
  253. <el-select
  254. filterable
  255. class="form-ipt"
  256. style="width: 100%"
  257. v-model="formData.verifyId"
  258. placeholder="请选择"
  259. >
  260. <el-option
  261. v-for="item in staffList"
  262. :key="item.id"
  263. :label="item.name"
  264. :value="item.id"
  265. @click.native="() => (formData.verifyName = item.name)"
  266. >
  267. </el-option>
  268. </el-select>
  269. </el-form-item>
  270. </el-col>
  271. <!-- <el-col :span="24">
  272. <el-form-item label="附件" prop="contentImage">
  273. <selectUpload @getImgs="upload" :initData="uploadList" />
  274. </el-form-item>
  275. </el-col> -->
  276. <el-col :span="24">
  277. <el-form-item label="备注" prop="remark">
  278. <el-input
  279. v-model="formData.remark"
  280. clearable
  281. type="textarea"
  282. placeholder="请详细说明"
  283. :rows="4"
  284. ></el-input>
  285. </el-form-item>
  286. </el-col>
  287. </el-row>
  288. </el-form>
  289. <div class="material">
  290. <div class="flex">
  291. <div><span class="red">*</span>出库明细</div>
  292. <div>
  293. <el-button type="primary" @click="addStock">添加</el-button>
  294. </div>
  295. </div>
  296. <div class="mt10 form-table">
  297. <el-form
  298. ref="warehousingMaterialListRef"
  299. :model="{ warehousingMaterialList: warehousingMaterialList }"
  300. :show-message="false"
  301. >
  302. <el-table
  303. ref="multipleTable"
  304. :data="warehousingMaterialList"
  305. tooltip-effect="dark"
  306. style="width: 100%"
  307. stripe
  308. :header-cell-style="{ background: '#EEEEEE', border: 'none' }"
  309. >
  310. <el-table-column label="序号" type="index" width="50">
  311. </el-table-column>
  312. <el-table-column
  313. label="物品编码"
  314. prop="assetCode"
  315. ></el-table-column>
  316. <el-table-column
  317. label="客户编码"
  318. v-if="formData.bizType == 3"
  319. prop="contactCode"
  320. >
  321. <template slot-scope="{ row }">
  322. {{ row.customCode }}
  323. </template>
  324. </el-table-column>
  325. <el-table-column
  326. label="供应商编码"
  327. v-if="formData.bizType == 4"
  328. prop="assetCode"
  329. >
  330. <template slot-scope="{ row }">
  331. {{ row.supplierCode }}
  332. </template>
  333. </el-table-column>
  334. <el-table-column
  335. label="物品名称"
  336. prop="assetName"
  337. ></el-table-column>
  338. <el-table-column
  339. v-for="(item, index) in tableHeader"
  340. :key="index"
  341. align="center"
  342. :label="item.label"
  343. width="150"
  344. :prop="item.prop"
  345. >
  346. <template slot-scope="{ row }">
  347. <template v-if="item.formatter">{{
  348. item.formatter(row)
  349. }}</template>
  350. <template v-else>{{ row[item.prop] }}</template>
  351. </template>
  352. </el-table-column>
  353. <!-- <el-table-column label="类型" prop="materialId">
  354. <template slot-scope="{ row, $index }">
  355. {{ row.materialId }}
  356. </template>
  357. </el-table-column> -->
  358. <el-table-column
  359. label="出库数量"
  360. prop=""
  361. align="center"
  362. width="350px"
  363. >
  364. <template slot-scope="{ row, $index }">
  365. <el-row :gutter="4">
  366. <!-- <el-col :span="9">
  367. <el-input type="text" :value="row.selfSum" disabled>
  368. <template slot="append">
  369. {{ row.unit }}
  370. </template>
  371. </el-input></el-col
  372. > -->
  373. <el-col :span="9" v-if="!row.isUnpack">
  374. <el-input type="text" disabled :value="row.outInNum">
  375. <template slot="append">
  376. {{ row.minPackUnit }}
  377. </template>
  378. </el-input>
  379. </el-col>
  380. <el-col :span="6">
  381. <el-button type="text" @click="handleSetting(row, $index)"
  382. >出库明细选择</el-button
  383. ></el-col
  384. >
  385. </el-row>
  386. </template>
  387. </el-table-column>
  388. <el-table-column label="操作" width="200">
  389. <template slot-scope="{ row, $index }">
  390. <el-button type="text" @click="listDel(row, $index)"
  391. >删除</el-button
  392. >
  393. </template>
  394. </el-table-column>
  395. </el-table>
  396. </el-form>
  397. </div>
  398. <div class="mt20">
  399. <el-tabs v-model="activeName" type="card">
  400. <el-tab-pane :label="`${title}明细`" name="a">
  401. <el-table
  402. ref="multipleTable"
  403. :data="materialCodeReqList"
  404. tooltip-effect="dark"
  405. style="width: 100%"
  406. stripe
  407. :header-cell-style="rowClass"
  408. >
  409. <el-table-column label="序号" type="index" width="50">
  410. </el-table-column>
  411. <el-table-column
  412. :label="`${title}编码`"
  413. min-width="100"
  414. prop="sourceBizNo"
  415. ></el-table-column>
  416. <el-table-column
  417. label="批次号"
  418. prop="sourceBatchNo"
  419. ></el-table-column>
  420. <el-table-column label="生产日期" width="200">
  421. <template slot-scope="{ row }">
  422. <span v-if="row.dateType === 2">
  423. {{ row.produceTime }}
  424. </span>
  425. </template>
  426. </el-table-column>
  427. <el-table-column label="采购日期" width="200">
  428. <template slot-scope="{ row }">
  429. <span v-if="row.dateType === 1">
  430. {{ row.procureTime }}
  431. </span>
  432. </template>
  433. </el-table-column>
  434. <el-table-column
  435. label="最小包装单元"
  436. align="center"
  437. prop="modelType"
  438. >
  439. <template slot-scope="{ row, $index }">
  440. <template v-if="!row.isUnpack">
  441. {{ row.measurementUnit }}{{ row.unit }}/{{
  442. row.minUnit
  443. }}</template
  444. >
  445. </template>
  446. </el-table-column>
  447. <el-table-column
  448. label="包装编码"
  449. prop="packageNo"
  450. ></el-table-column>
  451. <el-table-column
  452. label="货位"
  453. prop="pathName"
  454. show-overflow-tooltip
  455. >
  456. </el-table-column>
  457. <el-table-column label="转消耗" prop="">
  458. <template slot-scope="{ row }">
  459. <el-checkbox v-model="row.isTransferAsset"></el-checkbox>
  460. </template>
  461. </el-table-column>
  462. </el-table>
  463. </el-tab-pane>
  464. </el-tabs>
  465. </div>
  466. </div>
  467. <div class="center mt20">
  468. <el-button type="primary" @click="handleSave" :loading="saveLoading"
  469. >保存</el-button
  470. >
  471. <el-button @click="$router.go(-1)">返回</el-button>
  472. </div>
  473. </el-card>
  474. <AssetsDialog
  475. ref="assetsDialogRef"
  476. :title="title"
  477. :warehousingMaterialList="warehousingMaterialList"
  478. :assetType="formData.extInfo.assetType"
  479. @selectTableData="onSelectTableData"
  480. />
  481. <!-- 选桶号 -->
  482. <detailSelect
  483. ref="detailSelectRef"
  484. :title="title"
  485. :tableHeader="tableHeader"
  486. />
  487. <!-- 转资产 -->
  488. <!-- <TurnToAsset ref="turnToAssetRef" /> -->
  489. <!-- 选择仓库 -->
  490. <WareHouseDailog ref="wareHouseDailogRef"></WareHouseDailog>
  491. <!-- 选领料单 -->
  492. <pickOrder ref="pickOrderRef" @success="pickOrderRow" />
  493. <!-- 销售订单 -->
  494. <eom ref="eomRef" @success="eomSuccess" />
  495. </div>
  496. </template>
  497. <script>
  498. import outin from '@/api/warehouseManagement/outin';
  499. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  500. import { getTreeByPid, getTreeByGroup } from '@/api/classifyManage';
  501. import selectUpload from '@/components/selectUpload';
  502. import upload from '@/components/uploadImg';
  503. import pickOrder from './components/pickOrder.vue';
  504. import {
  505. warehousingType,
  506. outputSceneState,
  507. emergencyState,
  508. materialType
  509. } from '@/utils/dict/index';
  510. import selectTree from '@/components/selectTree';
  511. import AssetsDialog from '../components/AssetsDialog.vue';
  512. import outputType from '../components/outputType.vue';
  513. // import TurnToAsset from '../components/TurnToAsset/index.vue'
  514. import WareHouseDailog from '../components/WareHouseDailog.vue';
  515. // import supplier from '@/api/main/supplier';
  516. // import org from '@/api/main/org';
  517. // import user from '@/api/main/user';
  518. import { tableHeader } from '../common';
  519. import detailSelect from './components/detailSelect';
  520. import eom from './components/eom.vue';
  521. export default {
  522. components: {
  523. pickOrder,
  524. selectUpload,
  525. selectTree,
  526. AssetsDialog,
  527. WareHouseDailog,
  528. upload,
  529. detailSelect,
  530. // TurnToAsset,
  531. outputType,
  532. eom
  533. },
  534. data() {
  535. return {
  536. llList: [],
  537. codeList: [],
  538. materialType,
  539. warehousingType,
  540. outputSceneState,
  541. emergencyState,
  542. saveLoading: false,
  543. title: '',
  544. tableData2: [],
  545. uploadList: [],
  546. fromUserList: [], //人员数组
  547. warehousingMaterialList: [],
  548. activeName: 'a',
  549. treeList: [],
  550. staffList: [],
  551. formData: {
  552. extInfo: {
  553. assetType: '', //物品类型
  554. deptCode: '', //部门code
  555. deptName: '', //部门名称
  556. verifyDeptCode: '', //审核部门编码
  557. verifyDeptName: '', //审核部门名称
  558. deliveryName: '', //送货人名称
  559. fromUserPhone: '', //送货人电话
  560. documentSource: '', //销售订单
  561. urgent: '', //紧急状态
  562. supplierId: '', //供应商ID
  563. supplierName: '', //供应商名称
  564. createUserName: '', //创建人名字
  565. contentImage: [] //图片数组
  566. },
  567. fromUser: '', //送货人
  568. bizType: '', //物品类型
  569. verifyId: '', //审核人Id
  570. verifyName: '', //审核人名称
  571. createUserId: '',
  572. remark: ''
  573. },
  574. rules: {
  575. // 'extInfo.assetType': {
  576. // required: true,
  577. // message: '请选择出库产品类型',
  578. // trigger: 'change'
  579. // },
  580. bizType: {
  581. required: true,
  582. message: '请选择出库场景',
  583. trigger: 'change'
  584. },
  585. fromUser: {
  586. required: true,
  587. message: '请选择领料人',
  588. trigger: 'change'
  589. }
  590. },
  591. options: [],
  592. loading: false,
  593. onSelectTableDataVal: []
  594. // shouldTriggerPickorder: true
  595. };
  596. },
  597. computed: {
  598. tableHeader() {
  599. return tableHeader(this.formData.extInfo.assetType);
  600. },
  601. // 条码信息
  602. materialCodeReqList() {
  603. return this.warehousingMaterialList
  604. .map((i) => i.warehouseLedgerDetails || [])
  605. .flat();
  606. }
  607. },
  608. created() {
  609. this.initData();
  610. },
  611. methods: {
  612. onClear() {
  613. this.formData.documentSource = '';
  614. this.warehousingMaterialList = [];
  615. this.$forceUpdate();
  616. },
  617. eomSuccess(row) {
  618. console.log(row);
  619. this.formData.extInfo.assetType = row.tableData[0].productId;
  620. this.$refs.trees.valueTitle = row.tableData[0].productName;
  621. this.title = row.tableData[0].productName;
  622. this.formData.documentSource = row.orderNo;
  623. this.onSelectTableData(row.tableData, 1);
  624. this.$forceUpdate();
  625. },
  626. pickOrderRow(row) {
  627. row.tableData = [];
  628. this.formData.documentSource = row.code;
  629. for (const key in row.orderInfoList) {
  630. if (row.orderInfoList[key].bomDetailDTOS.length != 0) {
  631. for (const i in row.orderInfoList[key].bomDetailDTOS) {
  632. row.tableData.push({
  633. ...row.orderInfoList[key].bomDetailDTOS[i],
  634. code: row.orderInfoList[key].bomDetailDTOS[i].categoryCode,
  635. name: row.orderInfoList[key].bomDetailDTOS[i].categoryName,
  636. modelType: row.orderInfoList[key].bomDetailDTOS[i].model,
  637. id: row.orderInfoList[key].bomDetailDTOS[i].categoryId
  638. });
  639. }
  640. }
  641. if (row.orderInfoList[key].instanceList.length != 0) {
  642. for (const j in row.orderInfoList[key].instanceList) {
  643. row.tableData.push({
  644. ...row.orderInfoList[key].instanceList[j],
  645. code: row.orderInfoList[key].instanceList[j].categoryCode,
  646. name: row.orderInfoList[key].instanceList[j].categoryName,
  647. modelType: row.orderInfoList[key].instanceList[j].model,
  648. id: row.orderInfoList[key].instanceList[j].categoryId
  649. });
  650. }
  651. }
  652. }
  653. const uniqueItems = [];
  654. const uniqueIds = new Set();
  655. row.tableData.forEach((item) => {
  656. if (!uniqueIds.has(item.code)) {
  657. uniqueIds.add(item.code);
  658. uniqueItems.push(item);
  659. }
  660. });
  661. row.tableData = uniqueItems;
  662. console.log(row);
  663. this.onSelectTableData(row.tableData, 1);
  664. this.$forceUpdate();
  665. },
  666. handleEom() {
  667. this.$refs.eomRef.open();
  668. },
  669. handlePickorder() {
  670. this.$refs.pickOrderRef.open();
  671. },
  672. async handleDocumentSourceChange() {
  673. // this.formData.documentSource = '';
  674. if (!this.formData.documentSource) {
  675. if (this.formData.bizType == 4) {
  676. this.warehousingMaterialList = [];
  677. }
  678. return;
  679. }
  680. if (
  681. !(this.formData.extInfo.assetType == 7 && this.formData.bizType == 4)
  682. ) {
  683. return;
  684. }
  685. const loading = this.$loading({ fullscreen: true });
  686. const res = await getSparePartsInfo({
  687. code: this.formData.documentSource
  688. });
  689. if (res?.success && res.data.length) {
  690. const curMap = {
  691. assetId: 'classificationId',
  692. assetCode: 'informationCode', //编码
  693. assetName: 'informationName', //名称
  694. materialId: 'classificationId',
  695. materialName: 'informationName',
  696. batchNo: '', //批次号
  697. unit: 'measuringUnit', //单位
  698. minPackUnit: 'packingUnit' //最小包装单位
  699. };
  700. res.data.forEach((item) => {
  701. let obj = {};
  702. for (const key in curMap) {
  703. obj[key] = curMap[key] ? item[curMap[key]] : '';
  704. }
  705. obj.curId =
  706. obj.assetCode +
  707. (obj.measurementUnit || '') +
  708. (obj.minPackUnit || '') +
  709. (obj.unit || '');
  710. console.log(obj.curId);
  711. const index = this.warehousingMaterialList.findIndex(
  712. (i) => i.curId === obj.curId
  713. );
  714. if (index === -1) {
  715. Object.assign(obj, item);
  716. obj.sparePartsNum = item.num;
  717. this.warehousingMaterialList.push(obj);
  718. } else {
  719. this.warehousingMaterialList[index].sparePartsNum = item.num;
  720. }
  721. });
  722. }
  723. loading.close();
  724. },
  725. // 备品备件来源单号
  726. async remoteMethod(code) {
  727. // if (code !== '') {
  728. // this.loading = true
  729. const res = await getDocumentSource({ code });
  730. if (res?.success) {
  731. this.options = res.data;
  732. }
  733. // this.loading = false
  734. // } else {
  735. // this.options = []
  736. // }
  737. },
  738. rowClass({ row, column, rowIndex, columnIndex }) {
  739. if (rowIndex === 1) {
  740. return {
  741. display: 'none',
  742. background: '#EEEEEE',
  743. border: 'none'
  744. };
  745. }
  746. return { background: '#EEEEEE', border: 'none' };
  747. },
  748. // 部门 点击事件
  749. async auditorDeptClick(data) {
  750. console.log(data);
  751. this.formData.extInfo.verifyDeptCode = data?.id;
  752. this.formData.extInfo.verifyDeptName = data?.name;
  753. this.formData.verifyId = '';
  754. this.formData.verifyName = '';
  755. this.$refs.formName.validateField('verifyDeptName');
  756. if (data) {
  757. this.getStaffList(data);
  758. }
  759. },
  760. async getStaffList(data) {
  761. let res = await warehouseDefinition.getUserPage({
  762. groupId: data.id,
  763. size: 9999,
  764. page: 1
  765. });
  766. this.staffList = res.list;
  767. },
  768. // // 转资产
  769. // turnToAssets (row) {
  770. // this.$refs.turnToAssetRef
  771. // .open(row.transferCurVal)
  772. // .then(({ code, name }) => {
  773. // row.transferType = name
  774. // row.materialId = code
  775. // row.materialName = name.split('/').pop()
  776. // row.transferType = name
  777. // this.$set(row, 'transferCurVal', code)
  778. // })
  779. // },
  780. handleSetting(row) {
  781. row.bizTypes = this.formData.bizType;
  782. this.$refs.detailSelectRef
  783. .open(row, row.warehouseLedgerDetails || [])
  784. .then((res) => {
  785. console.log(res);
  786. console.log(row);
  787. this.$set(
  788. row,
  789. 'warehouseLedgerDetails',
  790. (res || []).map((item) => {
  791. delete item.updateTime;
  792. delete item.createTime;
  793. this.$set(item, 'isTransferAsset', false);
  794. item.isUnpack = row.isUnpack;
  795. return item;
  796. })
  797. );
  798. this.$set(row, 'outInNum', res.length);
  799. this.$set(row, 'minPackUnit', res[0].minPackUnit);
  800. this.$set(
  801. row,
  802. 'selfSum',
  803. row.warehouseLedgerDetails.reduce((sum, pre) => {
  804. if (row.isUnpack) {
  805. return ++sum;
  806. }
  807. return sum + pre.measurementUnit;
  808. }, 0)
  809. );
  810. });
  811. },
  812. // 仓库编辑
  813. handleWareHouse(row) {
  814. this.$refs.wareHouseDailogRef.open(row);
  815. },
  816. // 出库操作
  817. listEdit(row) {
  818. this.$set(row, 'isSave', false);
  819. },
  820. //出库明细删除
  821. listDel(row, index) {
  822. this.warehousingMaterialList.splice(index, 1);
  823. if (this.warehousingMaterialList.length == 0) {
  824. this.formData.documentSource = '';
  825. }
  826. },
  827. // 出库明细生成条码信息
  828. async createMaterialCode(row) {
  829. let arr = [];
  830. const res = await getAssetNum({
  831. assetCode: row.assetCode,
  832. num: row.outInNum || 1
  833. });
  834. if (res?.success) {
  835. delete row.createTime;
  836. arr = Array.from(new Array(res.data.length), (val, idx) => ({
  837. ...row,
  838. num: res.data[idx],
  839. bizStatus: 2,
  840. isTransferAsset: false
  841. }));
  842. }
  843. return arr;
  844. },
  845. handleSave() {
  846. this.$refs.formName.validate(async (valid) => {
  847. if (valid) {
  848. if (!this.warehousingMaterialList?.length) {
  849. return this.$message.error('请添加出库明细!');
  850. } else if (
  851. this.warehousingMaterialList.some(
  852. (item) => !item.warehouseLedgerDetails?.length
  853. )
  854. ) {
  855. return this.$message.error('请完善出库明细数据!');
  856. }
  857. console.log('qqqq===>', this.warehousingMaterialList);
  858. let arr = this.warehousingMaterialList.map((item) => {
  859. return {
  860. batchNo: item.batchNo,
  861. categoryId: item.id,
  862. count: item.outInNum,
  863. num: item.outInNum,
  864. minPackingCount: item.selfSum,
  865. packingCount: item.outInNum,
  866. outInDetailRecordAddPOList: item.warehouseLedgerDetails,
  867. ...item
  868. // position: `${item.warehouseName}-${item.areaName}-${item.shelfCode}-${item.cargoSpaceCode}`,
  869. // // pathIds: item.categoryLevelPathId.toString(),
  870. // pathIds: `${item.warehouseId},${item.areaId},${item.shelfId},${item.cargoSpaceId}`,
  871. // totalMoney:
  872. // item.outInNum * item.minPackingCount * item.univalence
  873. };
  874. });
  875. arr.forEach((item) => {
  876. delete item.id;
  877. delete item.warehouseLedgerDetails;
  878. if (item.outInDetailRecordAddPOList.length > 0) {
  879. let list = item.outInDetailRecordAddPOList.map((it) => {
  880. return {
  881. positionId: it.positionId,
  882. code: it.sourceBizNo,
  883. dateType: it.dateType,
  884. dateValue: it.dateValue,
  885. minUnit: it.minUnit,
  886. batchNo: it.sourceBatchNo,
  887. position: it.pathName,
  888. // minPositionId: it.cargoSpaceId,
  889. minPositionId: it.minPositionId,
  890. name: it.name,
  891. pathIds: it.pathIds,
  892. unit: it.unit,
  893. packageNo: it.packageNo,
  894. minPackingCount: it.minPackingCount,
  895. procureTime: it.procureTime,
  896. produceTime: it.produceTime
  897. // num: it.minPackingCount
  898. };
  899. });
  900. item.outInDetailRecordAddPOList = list;
  901. }
  902. });
  903. let obj = { ...this.formData, type: 2 };
  904. for (const key in arr) {
  905. arr[key].count = arr[key].outInNum;
  906. }
  907. obj.outInDetailAddPOList = arr;
  908. obj.extInfo.documentSource = obj.documentSource;
  909. this.saveLoading = true;
  910. // console.log('明细', this.warehousingMaterialList);
  911. // const categoryLevelId = this.$refs.assetsDialogRef.materialType;
  912. // let newObj = {
  913. // inOutAddPO: {
  914. // ...this.formData,
  915. // ...this.formData.extInfo,
  916. // bizStatus: 2
  917. // },
  918. // warehouseLedgerInfos: this.handelArr(
  919. // this.warehousingMaterialList,
  920. // categoryLevelId
  921. // )
  922. // };
  923. // delete newObj.inOutAddPO.extInfo;
  924. console.log('2222', obj);
  925. const res = await outin.save(obj);
  926. if (res.code == 0) {
  927. this.$message.success('保存成功!');
  928. }
  929. this.saveLoading = false;
  930. this.$router.push('/warehouseManagement/outgoingManagement');
  931. if (res?.success) {
  932. this.$message.success('保存成功!');
  933. this.$router.go(-1);
  934. }
  935. }
  936. });
  937. },
  938. handelArr(arr, id) {
  939. for (const key in arr) {
  940. arr[key].inLedgerId = arr[key].id;
  941. arr[key].categoryLevelId = id;
  942. for (const k in arr[key].warehouseLedgerDetails) {
  943. arr[key].warehouseLedgerDetails[k].ledgerDetailId =
  944. arr[key].warehouseLedgerDetails[k].id;
  945. arr[key].warehouseLedgerDetails[k].inDetailId = arr[key].inLedgerId;
  946. arr[key].warehouseLedgerDetails[k].isTransferAsset = arr[key]
  947. .warehouseLedgerDetails[k].isTransferAsset
  948. ? 1
  949. : 0;
  950. arr[key].warehouseLedgerDetails[k].bizStatus = 2;
  951. }
  952. }
  953. return arr;
  954. // let newArr = arr.map((item) => {
  955. // return { ...item, ledgerId: item.id };
  956. // });
  957. // newArr.map((item) => {
  958. // item.warehouseLedgerDetails.map((ite) => {
  959. // return { ...ite, ledgerDetailId: ite.id, ledgerId: item.id };
  960. // });
  961. // });
  962. // return newArr;
  963. },
  964. //添加明细
  965. onSelectTableData(val, e) {
  966. // if (e == 1) {
  967. // this.llList = val;
  968. // } else {
  969. // this.llList = [];
  970. // }
  971. // .concat(this.llList)
  972. // if (this.warehousingMaterialList.length != 0) {
  973. // val = this.warehousingMaterialList.concat(val);
  974. // }
  975. this.onSelectTableDataVal = val;
  976. this.warehousingMaterialList = val.map((next) => {
  977. delete next.updateTime;
  978. delete next.createTime;
  979. return {
  980. ...next,
  981. realInventoryAmount: 0,
  982. // cargoSpaceCode: '', //货位编码
  983. // cargoSpaceId: '', //货位id
  984. // shelfId: '', //货架id
  985. // shelfCode: '', //货架名称
  986. // areaId: '', //库区id
  987. // areaName: '', //库区名称
  988. // warehouseId: '', //仓库id
  989. // warehouseName: '', //仓库名称
  990. assetType: this.formData.extInfo.assetType,
  991. outInNum: '',
  992. assetCode: next.code,
  993. assetName: next.name,
  994. bizStatus: 2,
  995. contactCode: next.contactCode
  996. };
  997. });
  998. console.log('sasasasa===>>>', this.warehousingMaterialList);
  999. },
  1000. codeListValue(val) {
  1001. console.log(val);
  1002. this.formData.extInfo.assetType = val.id;
  1003. this.$forceUpdate();
  1004. this.title = val?.name;
  1005. this.selectEquiType = val?.id;
  1006. console.log(this.title);
  1007. },
  1008. async initData() {
  1009. const { data } = await getTreeByGroup({ type: 1 });
  1010. this.codeList = data;
  1011. const res = await warehouseDefinition.tree();
  1012. this.treeList = this.$util.toTreeData({
  1013. data: res,
  1014. idField: 'id',
  1015. parentIdField: 'parentId'
  1016. });
  1017. let res22 = await warehouseDefinition.getUserPage({
  1018. size: -1,
  1019. page: 1
  1020. });
  1021. this.fromUserList = res22.list;
  1022. // /
  1023. // const res111 = await warehouseDefinition.list();
  1024. // this.warehouseList = res111.list;
  1025. // console.log('res=====', res);
  1026. const info = JSON.parse(localStorage.getItem('info'));
  1027. let obj = res.find(
  1028. (item) => item.id === info.deptId[info.deptId.length - 1]
  1029. );
  1030. // console.log('obj=====', obj);
  1031. this.formData.extInfo.deptName = obj.name;
  1032. this.formData.extInfo.deptCode = obj.id;
  1033. this.formData.extInfo.createUserName = info.name;
  1034. this.formData.createUserId = info.userId;
  1035. },
  1036. addStock() {
  1037. if (!this.title) return this.$message.error('请选择出库产品类型');
  1038. if (!this.formData.bizType && this.formData.bizType !== 0)
  1039. return this.$message.error('请选择出库场景');
  1040. if (this.formData.bizType == 4 && !this.formData.documentSource) {
  1041. return this.$message.error('请选择来源单据');
  1042. }
  1043. this.$refs.assetsDialogRef.open();
  1044. },
  1045. handleChange(data) {
  1046. this.title = data?.dictValue;
  1047. if (this.formData.bizType == 4) {
  1048. this.formData.documentSource = '';
  1049. }
  1050. },
  1051. handleChanges(code) {
  1052. const data = this.codeList.find((item) => item.dictCode == code);
  1053. this.title = data?.dictValue;
  1054. this.selectEquiType = data?.dictCode;
  1055. if (this.formData.bizType == 4) {
  1056. this.formData.documentSource = '';
  1057. }
  1058. },
  1059. handleBizSceneChange() {
  1060. if (this.formData.extInfo.assetType == 7) {
  1061. this.formData.extInfo.documentSource = '';
  1062. }
  1063. this.formData.documentSource = '';
  1064. },
  1065. getSupplier() {
  1066. return new Promise((resolve, reject) => {
  1067. supplier.list({ page: 1, size: 999 }).then((res) => {
  1068. if (res.success) {
  1069. resolve(res);
  1070. }
  1071. });
  1072. });
  1073. },
  1074. upload(data) {
  1075. this.formData.contentImage = data;
  1076. this.$refs.formName.validateField('contentImage');
  1077. },
  1078. deptClick(data) {
  1079. this.formData.deptName = data?.name;
  1080. this.formData.deptCode = data?.code;
  1081. }
  1082. }
  1083. };
  1084. </script>
  1085. <style lang="scss" scoped>
  1086. ::v-deep.form-table {
  1087. .el-form-item {
  1088. margin-bottom: 0;
  1089. }
  1090. .el-input__inner {
  1091. padding: 0 10px;
  1092. }
  1093. }
  1094. .p20 {
  1095. padding: 20px;
  1096. }
  1097. .el-select,
  1098. .el-date-editor {
  1099. width: 100%;
  1100. }
  1101. .el-form-item {
  1102. margin-bottom: 22px;
  1103. }
  1104. .material {
  1105. margin-top: 20px;
  1106. .flex {
  1107. display: flex;
  1108. justify-content: space-between;
  1109. font-size: 14px;
  1110. align-items: center;
  1111. .red {
  1112. color: #ff4949;
  1113. }
  1114. }
  1115. }
  1116. .mt10 {
  1117. margin-top: 10px;
  1118. }
  1119. .mt20 {
  1120. margin-top: 20px;
  1121. }
  1122. .center {
  1123. text-align: center;
  1124. }
  1125. </style>