InRequestForm.vue 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631
  1. <template>
  2. <div class="app-container">
  3. <!-- 左上角按钮容器 -->
  4. <div class="buttons-container">
  5. <el-button
  6. type="primary"
  7. :disabled="formLoading || isFormDisabled"
  8. plain
  9. size="mini"
  10. @click="submitForm"
  11. >保 存</el-button
  12. >
  13. <!-- 提交菜单 -->
  14. <el-dropdown class="ml-5" trigger="click">
  15. <el-button type="primary" size="mini" plain>
  16. 提交菜单
  17. <i class="el-icon-arrow-down el-icon--right" />
  18. </el-button>
  19. <el-dropdown-menu slot="dropdown">
  20. <el-dropdown-item
  21. :disabled="isButtonDisabled('commit')"
  22. @click.native="commit"
  23. >提交</el-dropdown-item
  24. >
  25. <el-dropdown-item
  26. :disabled="isButtonDisabled('cancel')"
  27. @click.native="cancel"
  28. >撤销</el-dropdown-item
  29. >
  30. </el-dropdown-menu>
  31. </el-dropdown>
  32. <!-- 审批菜单 -->
  33. <el-dropdown class="ml-5 mr-5" trigger="click">
  34. <el-button type="warning" size="mini" plain>
  35. 审批菜单
  36. <i class="el-icon-arrow-down el-icon--right" />
  37. </el-button>
  38. <el-dropdown-menu slot="dropdown">
  39. <el-dropdown-item
  40. :disabled="isButtonDisabled('audit')"
  41. @click.native="audit"
  42. >审核</el-dropdown-item
  43. >
  44. <el-dropdown-item
  45. :disabled="isButtonDisabled('antiAudit')"
  46. @click.native="antiAudit"
  47. >反审核</el-dropdown-item
  48. >
  49. </el-dropdown-menu>
  50. </el-dropdown>
  51. <el-button
  52. type="primary"
  53. plain
  54. size="mini"
  55. :disabled="isFormDisabled"
  56. @click="add()"
  57. >新增明细</el-button
  58. >
  59. <el-button plain size="mini" @click="handleCancel">返 回</el-button>
  60. </div>
  61. <el-tabs v-model="activeName" @tab-click="handleClick">
  62. <el-tab-pane label="明细信息" name="detail">
  63. <el-form
  64. ref="formRef"
  65. v-loading="formLoading"
  66. :model="formData"
  67. :rules="dynamicFormRules"
  68. label-width="150px"
  69. >
  70. <el-row :gutter="20">
  71. <el-col :span="12"
  72. ><el-form-item label="业务类型" prop="businessType">
  73. <el-select
  74. v-model="formData.businessType"
  75. placeholder="请选择业务类型"
  76. :disabled="!isEditable"
  77. @change="changeBusinessType"
  78. >
  79. <el-option
  80. v-for="dict in getDictDatas('inout_business_type')"
  81. :key="dict.value"
  82. :label="dict.label"
  83. :value="dict.value"
  84. />
  85. </el-select> </el-form-item
  86. ></el-col>
  87. <el-col :span="12">
  88. <el-form-item label="申请单号" prop="remark">
  89. <el-input
  90. v-model="formData.requestNo"
  91. :disabled="true"
  92. placeholder="保存后自动生成"
  93. /> </el-form-item
  94. ></el-col>
  95. <el-col :span="12">
  96. <el-form-item :label="getDeptLabel" prop="deptCode">
  97. <DepartMentSelect
  98. ref="departMentSelect"
  99. v-model="formData.deptCode"
  100. :disabled="isFormDisabled || formData.businessType == null"
  101. :placeholder="getDeptPlaceholder"
  102. clearable
  103. @change="selectDepart"
  104. />
  105. </el-form-item>
  106. </el-col>
  107. <el-col :span="12"
  108. ><el-form-item label="业务分类名称" prop="businessDescribe">
  109. <el-select
  110. v-model="formData.businessDescribe"
  111. :disabled="
  112. isFormDisabled || (formData.businessType ? false : true)
  113. "
  114. filterable
  115. placeholder="请选择业务类型"
  116. @change="changeBusinessDescribe"
  117. >
  118. <el-option
  119. v-for="dict in businessDescribeList"
  120. :key="dict.label"
  121. :label="dict.label"
  122. :value="dict.label"
  123. />
  124. </el-select> </el-form-item
  125. ></el-col>
  126. <el-col :span="12"
  127. ><el-form-item label="优先级" prop="priority">
  128. <el-select
  129. v-model="formData.priority"
  130. :disabled="
  131. isFormDisabled || (formData.businessType ? false : true)
  132. "
  133. placeholder="请选择优先级"
  134. >
  135. <el-option
  136. v-for="dict in getDictDatas('priority')"
  137. :key="dict.value"
  138. :label="dict.label"
  139. :value="dict.value"
  140. />
  141. </el-select>
  142. </el-form-item>
  143. </el-col>
  144. <el-col :span="12">
  145. <el-form-item label="供应商编码" prop="supplierCode">
  146. <el-select
  147. v-model="formData.supplierCode"
  148. :disabled="
  149. isFormDisabled || (formData.businessType ? false : true)
  150. "
  151. placeholder="请选择供应商编码"
  152. clearable
  153. filterable
  154. :filter-method="filterSupplier"
  155. >
  156. <el-option
  157. v-for="item in supplierOptions"
  158. :key="item.code"
  159. :label="`${item.code} ${item.name}`"
  160. :value="item.code"
  161. >
  162. <span style="display: inline-block; width: 120px">{{
  163. item.code
  164. }}</span>
  165. <span style="color: #8492a6; font-size: 13px">{{
  166. item.name
  167. }}</span>
  168. </el-option>
  169. </el-select>
  170. </el-form-item>
  171. </el-col>
  172. <el-col :span="12">
  173. <el-form-item label="客户编码" prop="customerCode">
  174. <el-select
  175. v-model="formData.customerCode"
  176. :disabled="
  177. isFormDisabled || (formData.businessType ? false : true)
  178. "
  179. placeholder="请选择客户编码"
  180. clearable
  181. filterable
  182. >
  183. <el-option
  184. v-for="item in customerList"
  185. :key="item.erpId"
  186. :label="`${item.code} ${item.name || ''}`"
  187. :value="item.code"
  188. />
  189. <!-- <el-option
  190. v-for="item in customerList"
  191. :key="item.code"
  192. :value="item.code"
  193. >
  194. <span style="display: inline-block; width: 120px">{{
  195. item.code
  196. }}</span>
  197. <span>{{ item.name }}</span>
  198. </el-option> -->
  199. </el-select>
  200. </el-form-item>
  201. </el-col>
  202. <!-- <el-col :span="12">
  203. <el-form-item label="源单编号" prop="sourceOrderNo">
  204. <el-select
  205. v-model="formData.sourceOrderNo"
  206. filterable
  207. remote
  208. :disabled="
  209. isFormDisabled || (formData.businessType ? false : true)
  210. "
  211. reserve-keyword
  212. placeholder="请输入源单编号"
  213. :remote-method="remoteMethod"
  214. :loading="loadingSourceOrder"
  215. @change="changeSourceOrderNo"
  216. >
  217. <el-option
  218. v-for="item in sourceOrderNoList"
  219. :key="item.sourceOrderNo"
  220. :label="item.sourceOrderNo"
  221. :value="item.sourceOrderNo"
  222. />
  223. </el-select>
  224. </el-form-item>
  225. </el-col> -->
  226. <el-col :span="12">
  227. <el-form-item label="源单编号" prop="sourceOrderNo">
  228. <el-select
  229. v-model="formData.sourceOrderNo"
  230. filterable
  231. remote
  232. :disabled="isFormDisabled || formData.businessType == null"
  233. reserve-keyword
  234. placeholder="请输入源单编号"
  235. :remote-method="remoteMethod"
  236. :loading="loadingSourceOrder"
  237. clearable
  238. @change="changeSourceOrderNo"
  239. >
  240. <el-option
  241. v-for="item in sourceOrderNoList"
  242. :key="item.sourceOrderNo"
  243. :label="item.sourceOrderNo"
  244. :value="item.sourceOrderNo"
  245. />
  246. </el-select>
  247. </el-form-item>
  248. </el-col>
  249. <el-col :span="12">
  250. <el-form-item label="预计出入库时间" prop="expectedTime">
  251. <el-date-picker
  252. v-model="formData.expectedTime"
  253. :disabled="
  254. isFormDisabled || (formData.businessType ? false : true)
  255. "
  256. clearable
  257. type="date"
  258. value-format="timestamp"
  259. placeholder="选择预计出入库时间"
  260. /> </el-form-item
  261. ></el-col>
  262. <el-col :span="12">
  263. <el-form-item label="实际出入库时间" prop="actualTime">
  264. <el-date-picker
  265. v-model="formData.actualTime"
  266. clearable
  267. :disabled="true"
  268. type="date"
  269. value-format="timestamp"
  270. placeholder="选择实际出入库时间"
  271. /> </el-form-item
  272. ></el-col>
  273. <el-col :span="12">
  274. <el-form-item label="备注" prop="remark">
  275. <el-input
  276. v-model="formData.remark"
  277. :disabled="
  278. isFormDisabled || (formData.businessType ? false : true)
  279. "
  280. placeholder="请输入备注"
  281. /> </el-form-item
  282. ></el-col>
  283. <!-- <el-col :span="12">
  284. <el-form-item label="存储地点" prop="warehouseId">
  285. <el-select
  286. v-model="formData.warehouseId"
  287. filterable
  288. remote
  289. :disabled="
  290. isFormDisabled || (formData.businessType ? false : true)
  291. "
  292. reserve-keyword
  293. placeholder="请输入存储地点"
  294. :remote-method="remoteWarehouse"
  295. :loading="loadingWarehouse"
  296. >
  297. <el-option
  298. v-for="item in warehouseList"
  299. :key="item.erpId"
  300. :label="item.name"
  301. :value="item.erpId"
  302. />
  303. </el-select>
  304. </el-form-item>
  305. </el-col> -->
  306. <el-col :span="12">
  307. <el-form-item :label="getWarehouseLabel" prop="warehouseId">
  308. <el-select
  309. v-model="formData.warehouseId"
  310. :disabled="isFormDisabled || formData.businessType == null"
  311. placeholder="请选择仓库"
  312. clearable
  313. filterable
  314. >
  315. <el-option
  316. v-for="item in warehouseList"
  317. :key="item.erpId"
  318. :label="item.name"
  319. :value="item.erpId"
  320. />
  321. </el-select>
  322. </el-form-item>
  323. </el-col>
  324. <el-col v-if="formData.businessType === '13'" :span="12">
  325. <el-form-item label="调入区域" prop="areaCode">
  326. <el-select
  327. v-model="formData.areaCode"
  328. :disabled="isFormDisabled || formData.businessType == null"
  329. filterable
  330. placeholder="请输入调入区域"
  331. clearable
  332. >
  333. <el-option
  334. v-for="item in areaList"
  335. :key="item.id"
  336. :label="item.name"
  337. :value="item.areaCode"
  338. />
  339. </el-select>
  340. </el-form-item>
  341. </el-col>
  342. <el-col v-if="formData.businessType === '13'" :span="12">
  343. <el-form-item label="调入货位" prop="locationCode">
  344. <el-select
  345. v-model="formData.locationCode"
  346. :disabled="isFormDisabled || formData.businessType == null"
  347. filterable
  348. placeholder="请输入调入货位"
  349. clearable
  350. >
  351. <el-option
  352. v-for="item in locationList"
  353. :key="item.id"
  354. :label="item.name"
  355. :value="item.locationCode"
  356. />
  357. </el-select>
  358. </el-form-item>
  359. </el-col>
  360. <el-col :span="12">
  361. <el-form-item label="状态" prop="status" aria-disabled="true">
  362. <el-select
  363. v-model="formData.status"
  364. disabled
  365. placeholder="请选择状态"
  366. >
  367. <el-option
  368. v-for="dict in getDictDatas('in_out_status')"
  369. :key="dict.value"
  370. :label="dict.label"
  371. :value="dict.value"
  372. />
  373. </el-select>
  374. </el-form-item>
  375. </el-col>
  376. <el-col :span="8" class="text-right">
  377. <el-button
  378. type="primary"
  379. plain
  380. style="width: 60%"
  381. icon="el-icon-upload2"
  382. @click="handleUpload"
  383. >附件上传</el-button
  384. >
  385. </el-col>
  386. </el-row>
  387. </el-form>
  388. <!-- <el-tabs v-model="activeName" @tab-click="handleClick">
  389. <el-tab-pane label="明细信息" name="detail"> -->
  390. <el-table :data="formData.list" border size="mini">
  391. <el-table-column
  392. label="源单编号"
  393. align="center"
  394. prop="sourceRequestId"
  395. width="160"
  396. show-overflow-tooltip
  397. />
  398. <el-table-column
  399. label="源单行号"
  400. align="center"
  401. prop="sourceLineNo"
  402. width="160"
  403. show-overflow-tooltip
  404. />
  405. <el-table-column
  406. label="物料编码"
  407. align="center"
  408. prop="materialNo"
  409. width="200"
  410. show-overflow-tooltip
  411. >
  412. <template v-slot="scope">
  413. <el-select
  414. v-model="scope.row.materialNo"
  415. filterable
  416. remote
  417. reserve-keyword
  418. :disabled="isFormDisabled"
  419. placeholder="请选择物料编码"
  420. :remote-method="
  421. (query) => remoteMaterialSearch(query, 'code', scope.$index)
  422. "
  423. :loading="loadingMaterial"
  424. @change="(value) => changeMaterial(value, scope.$index, 'code')"
  425. >
  426. <el-option
  427. v-for="item in materialNoList"
  428. :key="item.code"
  429. :label="item.code"
  430. :value="item.code"
  431. />
  432. </el-select>
  433. </template>
  434. </el-table-column>
  435. <el-table-column
  436. label="物料名称"
  437. align="center"
  438. prop="materialName"
  439. width="200"
  440. show-overflow-tooltip
  441. >
  442. <template v-slot="scope">
  443. <el-select
  444. v-model="scope.row.materialName"
  445. filterable
  446. remote
  447. reserve-keyword
  448. :disabled="isFormDisabled"
  449. placeholder="请选择物料名称"
  450. :remote-method="
  451. (query) => remoteMaterialSearch(query, 'name', scope.$index)
  452. "
  453. :loading="loadingMaterial"
  454. @change="(value) => changeMaterial(value, scope.$index, 'name')"
  455. >
  456. <el-option
  457. v-for="item in materialNameList"
  458. :key="item.code"
  459. :label="item.name"
  460. :value="item.name"
  461. />
  462. </el-select>
  463. </template>
  464. </el-table-column>
  465. <el-table-column
  466. label="客户编码"
  467. align="center"
  468. prop="customerCode"
  469. width="150"
  470. show-overflow-tooltip
  471. />
  472. <el-table-column
  473. label="客户名称"
  474. align="center"
  475. prop="customerName"
  476. width="160"
  477. show-overflow-tooltip
  478. />
  479. <el-table-column
  480. label="存储地点"
  481. align="center"
  482. prop="locationName"
  483. width="150"
  484. show-overflow-tooltip
  485. />
  486. <el-table-column
  487. label="合格类型"
  488. align="center"
  489. prop="qcType"
  490. width="160"
  491. show-overflow-tooltip
  492. />
  493. <el-table-column
  494. label="退扣数量"
  495. align="center"
  496. prop="returnDeductQty"
  497. width="160"
  498. >
  499. <template slot-scope="scope">
  500. <el-input
  501. v-model="scope.row.returnDeductQty"
  502. :disabled="isFormDisabled"
  503. @change="(val) => calculateNowDeliveredQty(scope.row)"
  504. />
  505. </template>
  506. </el-table-column>
  507. <el-table-column
  508. label="退补数量"
  509. align="center"
  510. prop="returnSupplyQty"
  511. width="160"
  512. >
  513. <template slot-scope="scope">
  514. <el-input
  515. v-model="scope.row.returnSupplyQty"
  516. :disabled="isFormDisabled"
  517. @change="(val) => calculateNowDeliveredQty(scope.row)"
  518. />
  519. </template>
  520. </el-table-column>
  521. <el-table-column
  522. label="本次申请数量"
  523. align="center"
  524. prop="nowDeliveredQty"
  525. width="160"
  526. >
  527. <template slot-scope="scope">
  528. <el-input
  529. v-model="scope.row.nowDeliveredQty"
  530. :disabled="isFormDisabled"
  531. @change="deliverChange"
  532. />
  533. </template>
  534. </el-table-column>
  535. <el-table-column
  536. label="已出库数量"
  537. align="center"
  538. prop="completedQty"
  539. width="120"
  540. />
  541. <el-table-column
  542. label="源单计划数量"
  543. align="center"
  544. prop="planQty"
  545. width="120"
  546. />
  547. <el-table-column
  548. label="单位"
  549. align="center"
  550. prop="unitName"
  551. width="150"
  552. show-overflow-tooltip
  553. />
  554. <el-table-column
  555. label="行备注"
  556. align="center"
  557. prop="remark"
  558. width="200"
  559. >
  560. <template slot-scope="scope">
  561. <el-input v-model="scope.row.remark" :disabled="isFormDisabled" />
  562. </template>
  563. </el-table-column>
  564. <el-table-column
  565. label="操作"
  566. align="center"
  567. fixed="right"
  568. width="150px"
  569. class-name="small-padding fixed-width"
  570. >
  571. <template v-slot="scope">
  572. <el-button
  573. size="mini"
  574. type="text"
  575. icon="el-icon-delete"
  576. :disabled="isFormDisabled"
  577. @click="handleDelete(scope)"
  578. >删除</el-button
  579. >
  580. </template>
  581. </el-table-column>
  582. </el-table>
  583. </el-tab-pane>
  584. <el-tab-pane label="审批任务" name="approvalTask" lazy>
  585. <ApprovalTask
  586. v-if="
  587. activeName === 'approvalTask' &&
  588. formData.bpmInstanceId !== null &&
  589. formData.bpmInstanceId !== undefined
  590. "
  591. :id="formData.bpmInstanceId"
  592. />
  593. <div v-else class="isNotApproval">暂未开启工作流</div>
  594. </el-tab-pane>
  595. </el-tabs>
  596. <!-- 移除原有的form-footer -->
  597. <!-- 附件上传 -->
  598. <AttachmentUpload ref="attachmentUpload" @files="getFileList" />
  599. </div>
  600. </template>
  601. <script>
  602. import * as InRequestApi from "@/api/wms/output/inrequest";
  603. import DepartMentSelect from "./DepartMentSelect.vue";
  604. import AttachmentUpload from "../../../../wms/incoming/register/components/AttachmentUpload.vue";
  605. // 审批任务
  606. import ApprovalTask from "../../../../wms/quality/iqcInspection/components/ApprovalTaskNew.vue";
  607. // import ShipmentNotification from "./ShipmentNotification.vue";
  608. export default {
  609. name: "OutRequestForm",
  610. components: {
  611. // ShipmentNotification,
  612. DepartMentSelect,
  613. ApprovalTask,
  614. AttachmentUpload,
  615. },
  616. data() {
  617. return {
  618. activeName: "detail",
  619. materialNameList: [],
  620. materialNoList: [],
  621. sourceOrderNoList: [],
  622. allSourceOrderNoList: [],
  623. supplierList: [],
  624. supplierOptions: [],
  625. customerList: [],
  626. businessDescribeList: [],
  627. warehouseList: [],
  628. loadingMaterial: false,
  629. loadingSourceOrder: false,
  630. loadingWarehouse: false,
  631. loadingArea: false,
  632. loadingLocation: false,
  633. areaList: [],
  634. locationList: [],
  635. uploadFiles: [], // 上传的文件
  636. // 页面标题
  637. dialogTitle: "",
  638. // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
  639. formLoading: false,
  640. // 记录当前业务类型下选中的业务分类名称
  641. selectedBusinessDescribe: "",
  642. // 保存当前选中的业务类型整行字典数据
  643. currentBusinessTypeRow: null,
  644. // 保存当前选中的业务分类整行数据
  645. currentBusinessDescribeRow: null,
  646. // 表单参数
  647. formData: {
  648. departmentNo: undefined,
  649. deptCode: undefined,
  650. deptName: undefined,
  651. id: undefined,
  652. requestNo: undefined,
  653. requestType: undefined,
  654. businessType: undefined,
  655. businessCategory: undefined,
  656. businessDescribe: undefined,
  657. businessSubType: undefined,
  658. status: undefined,
  659. priority: undefined,
  660. warehouseId: undefined,
  661. relatedWarehouseId: undefined,
  662. supplierCode: undefined,
  663. customerCode: undefined,
  664. sourceOrderNo: undefined,
  665. expectedTime: undefined,
  666. actualTime: undefined,
  667. totalQty: undefined,
  668. totalSku: undefined,
  669. totalLine: undefined,
  670. remark: undefined,
  671. extendInfo: undefined,
  672. submitter: undefined,
  673. submitTime: undefined,
  674. auditor: undefined,
  675. auditTime: undefined,
  676. erpWriteFlag: undefined,
  677. erpErrMsg: undefined,
  678. erpBackId: undefined,
  679. list: [],
  680. bpmInstanceId: undefined,
  681. areaCode: undefined,
  682. locationCode: undefined,
  683. },
  684. // 表单校验
  685. formRules: {
  686. deptCode: [{ required: true, message: "请选择部门", trigger: "blur" }],
  687. requestNo: [
  688. { required: true, message: "申请单号不能为空", trigger: "blur" },
  689. ],
  690. expectedTime: [
  691. { required: true, message: "预计入库时间不能为空", trigger: "blur" },
  692. ],
  693. requestType: [
  694. {
  695. required: true,
  696. message: "申请类型不能为空",
  697. trigger: "change",
  698. },
  699. ],
  700. businessType: [
  701. {
  702. required: true,
  703. message: "业务类型不能为空",
  704. trigger: "change",
  705. },
  706. ],
  707. businessSubType: [
  708. {
  709. required: true,
  710. message: "业务子类型不能为空",
  711. trigger: "change",
  712. },
  713. ],
  714. priority: [
  715. {
  716. required: true,
  717. message: "优先级不能为空",
  718. trigger: "blur",
  719. },
  720. ],
  721. },
  722. };
  723. },
  724. computed: {
  725. // 判断表单是否不可编辑:路径有id且status>=1
  726. isFormDisabled() {
  727. // 检查是否有id(编辑模式)且status>=1
  728. return this.formData.status && Number(this.formData.status) >= 1;
  729. },
  730. // 计算属性判断修改状态下是否可编辑
  731. isEditable() {
  732. // 有 id 表示是编辑模式,不可编辑
  733. // 没有 id 表示是新增模式,可编辑
  734. return (
  735. this.formData.id === undefined ||
  736. this.formData.id === null ||
  737. this.formData.id === ""
  738. );
  739. },
  740. // 动态获取地点标签
  741. getWarehouseLabel() {
  742. const businessType = this.formData.businessType;
  743. if (businessType === "13") {
  744. return "调入仓库";
  745. }
  746. return "存储地点";
  747. },
  748. // 动态获取部门标签
  749. getDeptLabel() {
  750. const businessType = this.formData.businessType;
  751. if (businessType === "2") {
  752. // 生产领料
  753. return "发料部门";
  754. }
  755. return "部门";
  756. },
  757. // 动态获取部门占位符
  758. getDeptPlaceholder() {
  759. const businessType = this.formData.businessType;
  760. if (businessType === "2") {
  761. // 生产领料
  762. return "请选择发料部门";
  763. }
  764. return "请选择部门";
  765. },
  766. // 动态生成表单验证规则
  767. dynamicFormRules() {
  768. // 从原始规则中只保留基础字段
  769. const baseRules = {
  770. businessType: this.formRules.businessType,
  771. priority: this.formRules.priority,
  772. expectedTime: this.formRules.expectedTime,
  773. };
  774. const rules = { ...baseRules };
  775. const businessType = this.formData.businessType;
  776. // 只有选择了业务类型后,才添加其他字段的验证规则
  777. if (businessType) {
  778. // 生产领料(2)需要的必填字段
  779. if (businessType === "2") {
  780. rules.deptCode = [
  781. {
  782. required: true,
  783. message: this.getDeptLabel + "不能为空",
  784. trigger: "blur",
  785. },
  786. ];
  787. rules.businessDescribe = [
  788. {
  789. required: true,
  790. message: "业务分类名称不能为空",
  791. trigger: "blur",
  792. },
  793. ];
  794. rules.sourceOrderNo = [
  795. { required: true, message: "源单编号不能为空", trigger: "blur" },
  796. ];
  797. rules.warehouseId = [
  798. { required: true, message: "存储地点不能为空", trigger: "blur" },
  799. ];
  800. }
  801. // 采购退料(1)需要的必填字段
  802. else if (businessType === "1") {
  803. // rules.deptCode = [
  804. // { required: true, message: "部门不能为空", trigger: "blur" },
  805. // ];
  806. rules.businessDescribe = [
  807. {
  808. required: true,
  809. message: "业务分类名称不能为空",
  810. trigger: "blur",
  811. },
  812. ];
  813. rules.supplierCode = [
  814. { required: true, message: "供应商不能为空", trigger: "blur" },
  815. ];
  816. rules.sourceOrderNo = [
  817. { required: true, message: "源单编号不能为空", trigger: "blur" },
  818. ];
  819. rules.warehouseId = [
  820. { required: true, message: "存储地点不能为空", trigger: "blur" },
  821. ];
  822. }
  823. // 其他出库(12)需要的必填字段
  824. else if (businessType === "12") {
  825. // rules.deptCode = [
  826. // { required: true, message: "部门不能为空", trigger: "blur" },
  827. // ];
  828. rules.businessDescribe = [
  829. {
  830. required: true,
  831. message: "业务分类名称不能为空",
  832. trigger: "blur",
  833. },
  834. ];
  835. rules.warehouseId = [
  836. { required: true, message: "存储地点不能为空", trigger: "blur" },
  837. ];
  838. } else if (businessType === "13") {
  839. rules.warehouseId = [
  840. { required: true, message: "调入仓库不能为空", trigger: "blur" },
  841. ];
  842. rules.areaCode = [
  843. { required: true, message: "调入区域不能为空", trigger: "blur" },
  844. ];
  845. rules.locationCode = [
  846. { required: true, message: "调入货位不能为空", trigger: "blur" },
  847. ];
  848. }
  849. }
  850. return rules;
  851. },
  852. },
  853. watch: {
  854. "$route.query.id": {
  855. immediate: true,
  856. handler(newId, oldId) {
  857. // 只有当前路由路径包含"/outStorageManage/inrequest/InRequestForm"时才处理,避免标签跳转时错误调用API
  858. if (
  859. this.$route.path.includes("/outStorageManage/inrequest/InRequestForm")
  860. ) {
  861. // 只有当id变化时才执行操作,避免不必要的重复调用
  862. if (newId !== oldId) {
  863. if (newId) {
  864. this.dialogTitle = "修改";
  865. this.open(newId);
  866. } else {
  867. this.dialogTitle = "新增";
  868. this.reset();
  869. }
  870. }
  871. }
  872. },
  873. },
  874. // 监听仓库选择变化,获取对应区域列表
  875. "formData.warehouseId": {
  876. handler(newVal, oldVal) {
  877. if (this.formData.businessType === "13" && newVal) {
  878. this.loadAreaList(newVal);
  879. // 第一次 oldVal 为 undefined,认为是初始化,不清空
  880. if (oldVal === undefined) return;
  881. // 人工切换仓库
  882. this.formData.areaCode = undefined;
  883. this.formData.locationCode = undefined;
  884. this.locationList = [];
  885. } else {
  886. this.areaList = [];
  887. this.locationList = [];
  888. }
  889. },
  890. },
  891. // 监听区域选择变化,获取对应货位列表
  892. "formData.areaCode": {
  893. handler(newVal, oldVal) {
  894. if (
  895. this.formData.businessType === "13" &&
  896. newVal &&
  897. this.formData.warehouseId
  898. ) {
  899. this.loadLocationList(this.formData.warehouseId, newVal);
  900. if (oldVal === undefined) return; // 初始化阶段不清空
  901. this.formData.locationCode = undefined;
  902. } else {
  903. this.locationList = [];
  904. }
  905. },
  906. },
  907. },
  908. created() {
  909. // 一次性获取全部仓库
  910. this.loadWarehouseList();
  911. // 一次性获取全部供应商
  912. InRequestApi.getSupplierPage({ pageSize: 9999 }).then(({ data }) => {
  913. this.supplierList = data.list || [];
  914. this.supplierOptions = this.supplierList;
  915. });
  916. // 一次性获取全部客户编码
  917. InRequestApi.getCustomerPage({ pageSize: 9999 }).then(({ data }) => {
  918. this.customerList = data.list || [];
  919. });
  920. },
  921. methods: {
  922. /* 1. 保证仓库列表就位 */
  923. async loadWarehouseList() {
  924. if (this.warehouseList.length) return; // 已经拿过
  925. const { data } = await InRequestApi.getStockPage({ pageSize: 9999 });
  926. this.warehouseList = data.list || [];
  927. },
  928. // 通用的判断函数判断按钮是否可点击
  929. isButtonDisabled(buttonType) {
  930. const status = Number(this.formData.status);
  931. switch (buttonType) {
  932. case "commit":
  933. return status !== 0; // 提交,status=0时可点击
  934. case "cancel":
  935. return status !== 1; // 撤销,status=1时可点击
  936. case "audit":
  937. return status !== 1; // 审核,status=1时可点击
  938. case "antiAudit":
  939. return status < 2; // 反审核,status>=2时可点击
  940. default:
  941. return true;
  942. }
  943. },
  944. handleDelete(row) {
  945. console.log(row);
  946. this.formData.list.splice(row.$index, 1);
  947. },
  948. selectDepart(item) {
  949. this.formData.deptCode = item.code;
  950. this.formData.deptName = item.name;
  951. },
  952. remoteMaterialSearch(query, type, index) {
  953. if (query) {
  954. this.loadingMaterial = true;
  955. setTimeout(async () => {
  956. try {
  957. const params = {};
  958. if (type === "code") {
  959. params.code = query;
  960. } else {
  961. params.name = query;
  962. }
  963. const {
  964. data: { list },
  965. } = await InRequestApi.getMaterialPage(params);
  966. // 每次搜索都重新赋值,保证列表始终是最新数据
  967. if (type === "code") {
  968. this.materialNoList = list || [];
  969. } else {
  970. this.materialNameList = list || [];
  971. }
  972. } catch (error) {
  973. console.error("搜索物料失败:", error);
  974. // 出错时清空列表
  975. if (type === "code") {
  976. this.materialNoList = [];
  977. } else {
  978. this.materialNameList = [];
  979. }
  980. } finally {
  981. this.loadingMaterial = false;
  982. }
  983. }, 200);
  984. } else {
  985. // 清空对应的列表
  986. if (type === "code") {
  987. this.materialNoList = [];
  988. } else {
  989. this.materialNameList = [];
  990. }
  991. }
  992. },
  993. add() {
  994. if (!this.formData.businessType) {
  995. return this.$message.error("请先选择业务类型");
  996. }
  997. this.formData.list = this.formData.list || [];
  998. this.formData.list.push({});
  999. },
  1000. changeMaterial(value, index, type) {
  1001. // 根据选择的类型获取对应的列表
  1002. const list =
  1003. type === "code" ? this.materialNoList : this.materialNameList;
  1004. // 查找选中的物料信息
  1005. let selectedMaterial = null;
  1006. if (type === "code") {
  1007. selectedMaterial = list.find((item) => item.code === value);
  1008. // 如果在当前列表找不到,尝试从另一个列表找
  1009. if (!selectedMaterial) {
  1010. selectedMaterial = this.materialNameList.find(
  1011. (item) => item.code === value
  1012. );
  1013. }
  1014. } else {
  1015. selectedMaterial = list.find((item) => item.name === value);
  1016. // 如果在当前列表找不到,尝试从另一个列表找
  1017. if (!selectedMaterial) {
  1018. selectedMaterial = this.materialNoList.find(
  1019. (item) => item.name === value
  1020. );
  1021. }
  1022. }
  1023. if (selectedMaterial) {
  1024. // 更新表单中的物料信息
  1025. const newRow = {
  1026. ...this.formData.list[index],
  1027. materialNo: selectedMaterial.code,
  1028. materialName: selectedMaterial.name,
  1029. unitName: selectedMaterial.unit || "",
  1030. };
  1031. // 更新行数据
  1032. this.$set(this.formData.list, index, newRow);
  1033. }
  1034. },
  1035. // 本地过滤
  1036. // remoteMethod(query) {
  1037. // if (query !== "") {
  1038. // this.sourceOrderNoList = this.allSourceOrderNoList.filter((item) =>
  1039. // item.sourceOrderNo.toLowerCase().includes(query.toLowerCase())
  1040. // );
  1041. // } else {
  1042. // this.sourceOrderNoList = this.allSourceOrderNoList;
  1043. // }
  1044. // },
  1045. remoteMethod(query) {
  1046. if (!query) {
  1047. // 清空:恢复全部
  1048. this.sourceOrderNoList = this.allSourceOrderNoList;
  1049. } else if (query.length <= 4) {
  1050. // 1-4个字符:本地过滤
  1051. this.sourceOrderNoList = this.allSourceOrderNoList.filter((item) =>
  1052. item.sourceOrderNo.toLowerCase().includes(query.toLowerCase())
  1053. );
  1054. } else {
  1055. // 超过4个字符:远程搜索
  1056. this.loading = true;
  1057. InRequestApi.getSourceOrder({
  1058. businessType: this.formData.businessType,
  1059. businessDescribe: this.selectedBusinessDescribe,
  1060. businessCategory: this.currentBusinessDescribeRow?.value,
  1061. sourceOrderNo: query,
  1062. pageSize: 100,
  1063. })
  1064. .then(({ data }) => {
  1065. this.sourceOrderNoList = data || [];
  1066. })
  1067. .catch(() => {
  1068. this.sourceOrderNoList = [];
  1069. })
  1070. .finally(() => {
  1071. this.loading = false;
  1072. });
  1073. }
  1074. },
  1075. // 远程搜索调入区域
  1076. remoteAreaSearch(query) {
  1077. if (query !== "") {
  1078. this.loadingArea = true;
  1079. setTimeout(async () => {
  1080. try {
  1081. const {
  1082. data: { list },
  1083. } = await InRequestApi.getStockAreaPage({
  1084. areaName: query,
  1085. pageSize: 999,
  1086. });
  1087. this.areaList = list || [];
  1088. } catch (error) {
  1089. console.error("搜索调入区域失败:", error);
  1090. this.areaList = [];
  1091. } finally {
  1092. this.loadingArea = false;
  1093. }
  1094. }, 200);
  1095. } else {
  1096. this.areaList = [];
  1097. }
  1098. },
  1099. // 加载区域列表
  1100. async loadAreaList(warehouseId) {
  1101. this.loadingArea = true;
  1102. try {
  1103. // 通过erpId找到仓库的完整数据
  1104. console.log("warehouseList的长度", this.warehouseList.length);
  1105. const warehouseRow = this.warehouseList.find(
  1106. (w) => w.erpId === warehouseId
  1107. );
  1108. // 获取仓库的id
  1109. const wmsStockId = warehouseRow ? warehouseRow.id : warehouseId;
  1110. const {
  1111. data: { list },
  1112. } = await InRequestApi.getStockAreaPage({
  1113. wmsStockId: wmsStockId,
  1114. pageSize: 9999,
  1115. });
  1116. this.areaList = list || [];
  1117. } catch (error) {
  1118. console.error("加载区域列表失败:", error);
  1119. this.areaList = [];
  1120. } finally {
  1121. this.loadingArea = false;
  1122. }
  1123. },
  1124. // 加载货位列表
  1125. async loadLocationList(warehouseId, areaCode) {
  1126. this.loadingLocation = true;
  1127. try {
  1128. // 通过areaCode找到区域的完整数据
  1129. const area = this.areaList.find((w) => w.areaCode === areaCode);
  1130. // 获取区域的id
  1131. const wmsStockAreaId = area ? area.id : areaCode;
  1132. const {
  1133. data: { list },
  1134. } = await InRequestApi.getStockLocationPage({
  1135. wmsStockAreaId: wmsStockAreaId,
  1136. pageSize: 9999,
  1137. });
  1138. this.locationList = list || [];
  1139. } catch (error) {
  1140. console.error("加载货位列表失败:", error);
  1141. this.locationList = [];
  1142. } finally {
  1143. this.loadingLocation = false;
  1144. }
  1145. },
  1146. // remoteWarehouse(query) {
  1147. // if (query !== "") {
  1148. // const that = this;
  1149. // this.loadingWarehouse = true;
  1150. // setTimeout(async () => {
  1151. // this.loadingWarehouse = false;
  1152. // const {
  1153. // data: { list },
  1154. // } = await InRequestApi.getStockPage({
  1155. // name: query,
  1156. // pageSize: 999,
  1157. // });
  1158. // this.warehouseList = list || [];
  1159. // }, 200);
  1160. // } else {
  1161. // this.warehouseList = [];
  1162. // }
  1163. // },
  1164. // changeSourceOrderNo(value) {
  1165. // this.sourceOrderNoList.map((v) => {
  1166. // if (v.sourceOrderNo == value) {
  1167. // this.formData.list = v.list;
  1168. // }
  1169. // });
  1170. // },
  1171. changeSourceOrderNo(value) {
  1172. (this.sourceOrderNoList || []).forEach((v) => {
  1173. if (v.sourceOrderNo === value) {
  1174. this.formData.list = v.list || [];
  1175. }
  1176. });
  1177. },
  1178. // changeBusinessDescribe(e) {
  1179. // this.businessDescribeList.map((v) => {
  1180. // if (v.label == e) {
  1181. // this.formData.businessCategory = v.value;
  1182. // }
  1183. // });
  1184. // },
  1185. async changeBusinessDescribe(e) {
  1186. // 1. 找到并存储选中的业务分类整行数据
  1187. const selectedRow =
  1188. (this.businessDescribeList || []).find((v) => v.label === e) || {};
  1189. this.currentBusinessDescribeRow = selectedRow;
  1190. // 2. 设置业务分类值
  1191. if (selectedRow) {
  1192. this.formData.businessCategory = selectedRow.value;
  1193. }
  1194. // 3. 记录选中的名称
  1195. this.selectedBusinessDescribe = e;
  1196. // 4. 调用源单接口
  1197. if (this.formData.businessType && this.selectedBusinessDescribe) {
  1198. this.loadingSourceOrder = true;
  1199. try {
  1200. const { data } = await InRequestApi.getSourceOrder({
  1201. businessType: this.formData.businessType,
  1202. businessDescribe: this.selectedBusinessDescribe,
  1203. businessCategory: this.currentBusinessDescribeRow.value,
  1204. id: this.$route.query.id || undefined,
  1205. pageSize: 999,
  1206. });
  1207. this.allSourceOrderNoList = data || [];
  1208. this.sourceOrderNoList = this.allSourceOrderNoList;
  1209. } finally {
  1210. this.loadingSourceOrder = false;
  1211. }
  1212. }
  1213. },
  1214. async changeBusinessType(value) {
  1215. // 1. 先拿到业务类型对应的整条字典
  1216. const dictRow =
  1217. this.getDictDatas("inout_business_type").find(
  1218. (d) => d.value === value
  1219. ) || {};
  1220. this.currentBusinessTypeRow = dictRow; // 整条数据存起来
  1221. // 2. 原有逻辑保持不变
  1222. this.formData.businessType = value;
  1223. this.formData.businessDescribe = "";
  1224. this.formData.businessCategory = "";
  1225. this.formData.sourceOrderNo = "";
  1226. this.formData.list = [];
  1227. this.sourceOrderNoList = [];
  1228. this.allSourceOrderNoList = [];
  1229. this.selectedBusinessDescribe = "";
  1230. this.currentBusinessDescribeRow = null; // 清空业务分类数据
  1231. this.$nextTick(() => this.$refs.formRef.clearValidate());
  1232. const { data } = await InRequestApi.getDictByOrderType({
  1233. orderType: value,
  1234. });
  1235. this.businessDescribeList = data;
  1236. },
  1237. /** 初始化数据 */
  1238. async open(id) {
  1239. this.reset();
  1240. if (!id) {
  1241. // 新增
  1242. this.dialogTitle = "新增";
  1243. this.formData.list = [];
  1244. return;
  1245. }
  1246. /* ---------- 编辑模式 ---------- */
  1247. this.dialogTitle = "修改";
  1248. this.formLoading = true;
  1249. try {
  1250. /* 1. 先保证仓库就位 */
  1251. await this.loadWarehouseList();
  1252. const res = await InRequestApi.getInRequest(id);
  1253. res.data.businessType = res.data.businessType
  1254. ? res.data.businessType.toString()
  1255. : "0";
  1256. res.data.businessDescribe = res.data.businessDescribe
  1257. ? res.data.businessDescribe.toString()
  1258. : "";
  1259. res.data.priority = res.data.priority
  1260. ? res.data.priority.toString()
  1261. : "0";
  1262. res.data.status = res.data.status ? res.data.status.toString() : "0";
  1263. res.data.areaCode = res.data.areaCode
  1264. ? res.data.areaCode.toString()
  1265. : undefined;
  1266. res.data.locationCode = res.data.locationCode
  1267. ? res.data.locationCode.toString()
  1268. : undefined;
  1269. res.data.list = res.data.list || [];
  1270. /* 4. 补业务分类下拉数据(你原来缺的) */
  1271. if (res.data.businessType) {
  1272. const { data: describeList } = await InRequestApi.getDictByOrderType({
  1273. orderType: res.data.businessType,
  1274. });
  1275. this.businessDescribeList = describeList || [];
  1276. }
  1277. /* 5. ★ 关键:如果后端也返回了业务分类名称,顺手把源单列表拉回来 */
  1278. if (res.data.businessType && res.data.businessDescribe) {
  1279. // 找到当前分类整行,拿 value 字段
  1280. const row = this.businessDescribeList.find(
  1281. (v) => v.label === res.data.businessDescribe
  1282. );
  1283. this.currentBusinessDescribeRow = row || null;
  1284. this.loadingSourceOrder = true;
  1285. try {
  1286. const { data: sourceList } = await InRequestApi.getSourceOrder({
  1287. businessType: res.data.businessType,
  1288. businessDescribe: res.data.businessDescribe,
  1289. businessCategory: row?.value,
  1290. id, // 当前单据 id
  1291. pageSize: 999,
  1292. });
  1293. this.allSourceOrderNoList = sourceList || [];
  1294. this.sourceOrderNoList = this.allSourceOrderNoList;
  1295. } finally {
  1296. this.loadingSourceOrder = false;
  1297. }
  1298. }
  1299. /* 3. 现在仓库列表有了,先加载区域/货位 */
  1300. if (res.data.businessType === "13" && res.data.warehouseId) {
  1301. console.log("开始加载区域列表", res.data.warehouseId);
  1302. await this.loadAreaList(res.data.warehouseId);
  1303. console.log(
  1304. "区域下拉",
  1305. this.areaList.map((i) => i.areaCode)
  1306. );
  1307. if (res.data.areaCode) {
  1308. console.log("开始加载货位列表", res.data.areaCode);
  1309. await this.loadLocationList(
  1310. res.data.warehouseId,
  1311. res.data.areaCode
  1312. );
  1313. console.log(
  1314. "货位下拉",
  1315. this.locationList.map((i) => i.locationCode)
  1316. );
  1317. }
  1318. }
  1319. /* 最后再赋值表单数据 */
  1320. this.formData = res.data;
  1321. this.uploadFiles = res.data.filesListVos;
  1322. } finally {
  1323. this.formLoading = false;
  1324. }
  1325. },
  1326. /** 保存按钮 */
  1327. async submitForm() {
  1328. // 校验主表
  1329. await this.$refs["formRef"].validate();
  1330. this.formLoading = true;
  1331. try {
  1332. const data = this.formData;
  1333. data.list = (data.list || [])
  1334. .filter((v) => v.nowDeliveredQty)
  1335. .map(
  1336. ({
  1337. completedQty,
  1338. actualQty,
  1339. stock_code,
  1340. area_code,
  1341. location_code,
  1342. status,
  1343. lineNo,
  1344. inventory_status,
  1345. ...rest
  1346. }) => rest
  1347. );
  1348. // 上传的附件拼接传给后端
  1349. const fileIds = (this.uploadFiles || [])
  1350. .map((item) => {
  1351. return item.id || item.name?.fileId;
  1352. })
  1353. .filter((id) => id && id !== "");
  1354. // 拼接文件ID
  1355. data.fileId = fileIds.join(",");
  1356. // 只有businessType === "13"时才提交areaCode和locationCode
  1357. if (data.businessType !== "13") {
  1358. delete data.areaCode;
  1359. delete data.locationCode;
  1360. }
  1361. // 修改的提交;
  1362. if (data.id) {
  1363. await InRequestApi.updateInRequest(data);
  1364. this.$modal.msgSuccess("修改成功");
  1365. // 提交成功后刷新数据
  1366. await this.open(data.id);
  1367. // this.$router.back();//修改时停留在当前页面
  1368. return;
  1369. }
  1370. // 添加的提交
  1371. await InRequestApi.createInRequest(data);
  1372. this.$modal.msgSuccess("新增成功");
  1373. this.$router.back();
  1374. } finally {
  1375. this.formLoading = false;
  1376. }
  1377. },
  1378. /** 提交按钮 */
  1379. async commit() {
  1380. // 业务类型为13时,校验调入仓库、区域、货位
  1381. if (this.formData.businessType === "13") {
  1382. if (!this.formData.warehouseId) {
  1383. this.$modal.msgError("调入仓库不能为空");
  1384. return;
  1385. }
  1386. if (!this.formData.areaCode) {
  1387. this.$modal.msgError("调入区域不能为空");
  1388. return;
  1389. }
  1390. if (!this.formData.locationCode) {
  1391. this.$modal.msgError("调入货位不能为空");
  1392. return;
  1393. }
  1394. }
  1395. const menuId = this.$route.meta.id;
  1396. // 只提取需要的字段
  1397. const requestData = {
  1398. id: this.formData.id,
  1399. menuId: menuId,
  1400. };
  1401. // 接口调用
  1402. await InRequestApi.commitOutRequest(requestData);
  1403. this.$modal.msgSuccess("提交成功");
  1404. // 提交成功后刷新数据
  1405. await this.open(this.formData.id);
  1406. // 状态变化
  1407. this.$set(this.formData, "status", "1");
  1408. // 重新获取数据
  1409. const res = await InRequestApi.getInRequest(this.formData.id);
  1410. this.formData.bpmInstanceId = res.data.bpmInstanceId;
  1411. },
  1412. /** 撤销按钮 */
  1413. async cancel() {
  1414. // // 业务类型为13时,校验调入仓库、区域、货位
  1415. // if (this.formData.businessType === "13") {
  1416. // if (!this.formData.warehouseId) {
  1417. // this.$modal.msgError("调入仓库不能为空");
  1418. // return;
  1419. // }
  1420. // if (!this.formData.areaCode) {
  1421. // this.$modal.msgError("调入区域不能为空");
  1422. // return;
  1423. // }
  1424. // if (!this.formData.locationCode) {
  1425. // this.$modal.msgError("调入货位不能为空");
  1426. // return;
  1427. // }
  1428. // }
  1429. const requestData = {
  1430. id: this.formData.id,
  1431. };
  1432. // 接口调用
  1433. await InRequestApi.cancelOutRequest(requestData);
  1434. this.$modal.msgSuccess("撤销成功");
  1435. // 状态变化
  1436. this.$set(this.formData, "status", "0");
  1437. },
  1438. /** 审核按钮 */
  1439. async audit() {
  1440. // 业务类型为13时,校验调入仓库、区域、货位
  1441. if (this.formData.businessType === "13") {
  1442. if (!this.formData.warehouseId) {
  1443. this.$modal.msgError("调入仓库不能为空");
  1444. return;
  1445. }
  1446. if (!this.formData.areaCode) {
  1447. this.$modal.msgError("调入区域不能为空");
  1448. return;
  1449. }
  1450. if (!this.formData.locationCode) {
  1451. this.$modal.msgError("调入货位不能为空");
  1452. return;
  1453. }
  1454. }
  1455. // 检查是否存在工作流实例ID
  1456. if (this.formData.bpmInstanceId) {
  1457. // 如果存在工作流实例,跳转到审批任务tab页
  1458. this.activeName = "approvalTask";
  1459. this.$modal.msgWarning("请在审批任务页面完成审核!");
  1460. return;
  1461. }
  1462. const requestData = {
  1463. id: this.formData.id,
  1464. };
  1465. // 接口调用
  1466. await InRequestApi.auditOutRequest(requestData);
  1467. this.$modal.msgSuccess("审核成功");
  1468. // 状态变化
  1469. this.$set(this.formData, "status", "2");
  1470. },
  1471. /** 反审核按钮 */
  1472. async antiAudit() {
  1473. // // 业务类型为13时,校验调入仓库、区域、货位
  1474. // if (this.formData.businessType === "13") {
  1475. // if (!this.formData.warehouseId) {
  1476. // this.$modal.msgError("调入仓库不能为空");
  1477. // return;
  1478. // }
  1479. // if (!this.formData.areaCode) {
  1480. // this.$modal.msgError("调入区域不能为空");
  1481. // return;
  1482. // }
  1483. // if (!this.formData.locationCode) {
  1484. // this.$modal.msgError("调入货位不能为空");
  1485. // return;
  1486. // }
  1487. // }
  1488. const requestData = {
  1489. id: this.formData.id,
  1490. };
  1491. // 接口调用
  1492. await InRequestApi.antiAuditOutRequest(requestData);
  1493. this.$modal.msgSuccess("反审核成功");
  1494. // 状态变化
  1495. this.$set(this.formData, "status", "0");
  1496. },
  1497. /** 取消按钮 */
  1498. handleCancel() {
  1499. this.reset();
  1500. this.$router.back();
  1501. },
  1502. /** 表单重置 */
  1503. reset() {
  1504. this.formData = {
  1505. id: undefined,
  1506. requestNo: undefined,
  1507. requestType: undefined,
  1508. businessType: undefined,
  1509. businessCategory: undefined,
  1510. businessDescribe: undefined,
  1511. businessSubType: undefined,
  1512. status: undefined,
  1513. priority: undefined,
  1514. warehouseId: undefined,
  1515. relatedWarehouseId: undefined,
  1516. supplierCode: undefined,
  1517. customerCode: undefined,
  1518. sourceOrderNo: undefined,
  1519. expectedTime: undefined,
  1520. actualTime: undefined,
  1521. totalQty: undefined,
  1522. totalSku: undefined,
  1523. totalLine: undefined,
  1524. remark: undefined,
  1525. extendInfo: undefined,
  1526. submitter: undefined,
  1527. submitTime: undefined,
  1528. auditor: undefined,
  1529. auditTime: undefined,
  1530. erpWriteFlag: undefined,
  1531. erpErrMsg: undefined,
  1532. erpBackId: undefined,
  1533. list: [],
  1534. areaCode: undefined,
  1535. locationCode: undefined,
  1536. };
  1537. this.resetForm("formRef");
  1538. },
  1539. // 标签页切换处理
  1540. handleClick(tab, event) {
  1541. // 可以在这里添加标签切换时的逻辑
  1542. console.log(tab, event);
  1543. },
  1544. deliverChange(val) {
  1545. // 这里可以写“本次出入数量”变化后的校验或计算逻辑
  1546. console.log("deliverChange", val);
  1547. },
  1548. // 计算本次申请数量 = 退补数量 + 退扣数量
  1549. calculateNowDeliveredQty(row) {
  1550. const returnSupplyQty = Number(row.returnSupplyQty) || 0;
  1551. const returnDeductQty = Number(row.returnDeductQty) || 0;
  1552. row.nowDeliveredQty = returnSupplyQty + returnDeductQty;
  1553. },
  1554. // 附件上传
  1555. handleUpload() {
  1556. this.$refs.attachmentUpload.isUploadShow = -1;
  1557. this.$refs.attachmentUpload.title = "上传附件";
  1558. // 直接使用当前组件维护的 uploadFiles,而不是重新获取
  1559. this.$refs.attachmentUpload.fileList = this.uploadFiles || [];
  1560. this.$refs.attachmentUpload.visible = true;
  1561. },
  1562. // 获取上传的附件
  1563. getFileList(data) {
  1564. this.uploadFiles = data;
  1565. },
  1566. // 供应商编码过滤方法
  1567. filterSupplier(keyword) {
  1568. const key = (keyword || "").toLowerCase();
  1569. this.supplierOptions = this.supplierList.filter(
  1570. (item) =>
  1571. item.code.toLowerCase().includes(key) ||
  1572. (item.name && item.name.toLowerCase().includes(key))
  1573. );
  1574. },
  1575. },
  1576. };
  1577. </script>
  1578. <style scoped>
  1579. /* 新增按钮容器样式,将所有按钮放在标题下方 */
  1580. .buttons-container {
  1581. position: relative;
  1582. display: flex;
  1583. gap: 10px;
  1584. padding: 10px 0;
  1585. margin-bottom: 20px;
  1586. }
  1587. /* 调整app-header的位置 */
  1588. .app-header {
  1589. margin-bottom: 10px;
  1590. }
  1591. .app-container {
  1592. min-width: 900px;
  1593. margin: 0 auto;
  1594. overflow-x: auto;
  1595. }
  1596. </style>