InRequestForm.vue 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541
  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"
  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"
  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"
  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"
  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"
  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="nowDeliveredQty"
  483. width="160"
  484. >
  485. <template slot-scope="scope">
  486. <el-input
  487. v-model="scope.row.nowDeliveredQty"
  488. :disabled="isFormDisabled"
  489. @change="deliverChange"
  490. />
  491. </template>
  492. </el-table-column>
  493. <el-table-column
  494. label="已出库数量"
  495. align="center"
  496. prop="completedQty"
  497. width="120"
  498. />
  499. <el-table-column
  500. label="源单计划数量"
  501. align="center"
  502. prop="planQty"
  503. width="120"
  504. />
  505. <el-table-column
  506. label="单位"
  507. align="center"
  508. prop="unitName"
  509. width="150"
  510. show-overflow-tooltip
  511. />
  512. <el-table-column
  513. label="行备注"
  514. align="center"
  515. prop="remark"
  516. width="200"
  517. >
  518. <template slot-scope="scope">
  519. <el-input v-model="scope.row.remark" :disabled="isFormDisabled" />
  520. </template>
  521. </el-table-column>
  522. <el-table-column
  523. label="操作"
  524. align="center"
  525. fixed="right"
  526. width="150px"
  527. class-name="small-padding fixed-width"
  528. >
  529. <template v-slot="scope">
  530. <el-button
  531. size="mini"
  532. type="text"
  533. icon="el-icon-delete"
  534. :disabled="isFormDisabled"
  535. @click="handleDelete(scope)"
  536. >删除</el-button
  537. >
  538. </template>
  539. </el-table-column>
  540. </el-table>
  541. </el-tab-pane>
  542. <el-tab-pane label="审批任务" name="approvalTask" lazy>
  543. <ApprovalTask
  544. v-if="
  545. activeName === 'approvalTask' &&
  546. formData.bpmInstanceId !== null &&
  547. formData.bpmInstanceId !== undefined
  548. "
  549. :id="formData.bpmInstanceId"
  550. />
  551. <div v-else class="isNotApproval">暂未开启工作流</div>
  552. </el-tab-pane>
  553. </el-tabs>
  554. <!-- 移除原有的form-footer -->
  555. <!-- 附件上传 -->
  556. <AttachmentUpload ref="attachmentUpload" @files="getFileList" />
  557. </div>
  558. </template>
  559. <script>
  560. import * as InRequestApi from "@/api/wms/output/inrequest";
  561. import DepartMentSelect from "./DepartMentSelect.vue";
  562. import AttachmentUpload from "../../../../wms/incoming/register/components/AttachmentUpload.vue";
  563. // 审批任务
  564. import ApprovalTask from "../../../../wms/quality/iqcInspection/components/ApprovalTaskNew.vue";
  565. // import ShipmentNotification from "./ShipmentNotification.vue";
  566. export default {
  567. name: "OutRequestForm",
  568. components: {
  569. // ShipmentNotification,
  570. DepartMentSelect,
  571. ApprovalTask,
  572. AttachmentUpload,
  573. },
  574. data() {
  575. return {
  576. activeName: "detail",
  577. materialNameList: [],
  578. materialNoList: [],
  579. sourceOrderNoList: [],
  580. allSourceOrderNoList: [],
  581. supplierList: [],
  582. supplierOptions: [],
  583. customerList: [],
  584. businessDescribeList: [],
  585. warehouseList: [],
  586. loadingMaterial: false,
  587. loadingSourceOrder: false,
  588. loadingWarehouse: false,
  589. loadingArea: false,
  590. loadingLocation: false,
  591. areaList: [],
  592. locationList: [],
  593. uploadFiles: [], // 上传的文件
  594. // 页面标题
  595. dialogTitle: "",
  596. // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
  597. formLoading: false,
  598. // 记录当前业务类型下选中的业务分类名称
  599. selectedBusinessDescribe: "",
  600. // 保存当前选中的业务类型整行字典数据
  601. currentBusinessTypeRow: null,
  602. // 保存当前选中的业务分类整行数据
  603. currentBusinessDescribeRow: null,
  604. // 表单参数
  605. formData: {
  606. departmentNo: undefined,
  607. deptCode: undefined,
  608. deptName: undefined,
  609. id: undefined,
  610. requestNo: undefined,
  611. requestType: undefined,
  612. businessType: undefined,
  613. businessCategory: undefined,
  614. businessDescribe: undefined,
  615. businessSubType: undefined,
  616. status: undefined,
  617. priority: undefined,
  618. warehouseId: undefined,
  619. relatedWarehouseId: undefined,
  620. supplierCode: undefined,
  621. customerCode: undefined,
  622. sourceOrderNo: undefined,
  623. expectedTime: undefined,
  624. actualTime: undefined,
  625. totalQty: undefined,
  626. totalSku: undefined,
  627. totalLine: undefined,
  628. remark: undefined,
  629. extendInfo: undefined,
  630. submitter: undefined,
  631. submitTime: undefined,
  632. auditor: undefined,
  633. auditTime: undefined,
  634. erpWriteFlag: undefined,
  635. erpErrMsg: undefined,
  636. erpBackId: undefined,
  637. list: [],
  638. bpmInstanceId: undefined,
  639. areaCode: undefined,
  640. locationCode: undefined,
  641. },
  642. // 表单校验
  643. formRules: {
  644. deptCode: [{ required: true, message: "请选择部门", trigger: "blur" }],
  645. requestNo: [
  646. { required: true, message: "申请单号不能为空", trigger: "blur" },
  647. ],
  648. expectedTime: [
  649. { required: true, message: "预计入库时间不能为空", trigger: "blur" },
  650. ],
  651. requestType: [
  652. {
  653. required: true,
  654. message: "申请类型不能为空",
  655. trigger: "change",
  656. },
  657. ],
  658. businessType: [
  659. {
  660. required: true,
  661. message: "业务类型不能为空",
  662. trigger: "change",
  663. },
  664. ],
  665. businessSubType: [
  666. {
  667. required: true,
  668. message: "业务子类型不能为空",
  669. trigger: "change",
  670. },
  671. ],
  672. priority: [
  673. {
  674. required: true,
  675. message: "优先级不能为空",
  676. trigger: "blur",
  677. },
  678. ],
  679. },
  680. };
  681. },
  682. computed: {
  683. // 判断表单是否不可编辑:路径有id且status>=1
  684. isFormDisabled() {
  685. // 检查是否有id(编辑模式)且status>=1
  686. return this.formData.status && Number(this.formData.status) >= 1;
  687. },
  688. // 计算属性判断修改状态下是否可编辑
  689. isEditable() {
  690. // 有 id 表示是编辑模式,不可编辑
  691. // 没有 id 表示是新增模式,可编辑
  692. return (
  693. this.formData.id === undefined ||
  694. this.formData.id === null ||
  695. this.formData.id === ""
  696. );
  697. },
  698. // 动态获取地点标签
  699. getWarehouseLabel() {
  700. const businessType = this.formData.businessType;
  701. if (businessType === "13") {
  702. return "调入仓库";
  703. }
  704. return "存储地点";
  705. },
  706. // 动态获取部门标签
  707. getDeptLabel() {
  708. const businessType = this.formData.businessType;
  709. if (businessType === "2") {
  710. // 生产领料
  711. return "发料部门";
  712. }
  713. return "部门";
  714. },
  715. // 动态获取部门占位符
  716. getDeptPlaceholder() {
  717. const businessType = this.formData.businessType;
  718. if (businessType === "2") {
  719. // 生产领料
  720. return "请选择发料部门";
  721. }
  722. return "请选择部门";
  723. },
  724. // 动态生成表单验证规则
  725. dynamicFormRules() {
  726. // 从原始规则中只保留基础字段
  727. const baseRules = {
  728. businessType: this.formRules.businessType,
  729. priority: this.formRules.priority,
  730. expectedTime: this.formRules.expectedTime,
  731. };
  732. const rules = { ...baseRules };
  733. const businessType = this.formData.businessType;
  734. // 只有选择了业务类型后,才添加其他字段的验证规则
  735. if (businessType) {
  736. // 生产领料(2)需要的必填字段
  737. if (businessType === "2") {
  738. rules.deptCode = [
  739. {
  740. required: true,
  741. message: this.getDeptLabel + "不能为空",
  742. trigger: "blur",
  743. },
  744. ];
  745. rules.businessDescribe = [
  746. {
  747. required: true,
  748. message: "业务分类名称不能为空",
  749. trigger: "blur",
  750. },
  751. ];
  752. rules.sourceOrderNo = [
  753. { required: true, message: "源单编号不能为空", trigger: "blur" },
  754. ];
  755. rules.warehouseId = [
  756. { required: true, message: "存储地点不能为空", trigger: "blur" },
  757. ];
  758. }
  759. // 采购退料(1)需要的必填字段
  760. else if (businessType === "1") {
  761. // rules.deptCode = [
  762. // { required: true, message: "部门不能为空", trigger: "blur" },
  763. // ];
  764. rules.supplierCode = [
  765. { required: true, message: "供应商不能为空", trigger: "blur" },
  766. ];
  767. rules.sourceOrderNo = [
  768. { required: true, message: "源单编号不能为空", trigger: "blur" },
  769. ];
  770. rules.warehouseId = [
  771. { required: true, message: "存储地点不能为空", trigger: "blur" },
  772. ];
  773. }
  774. // 其他出库(12)需要的必填字段
  775. else if (businessType === "12") {
  776. // rules.deptCode = [
  777. // { required: true, message: "部门不能为空", trigger: "blur" },
  778. // ];
  779. rules.businessDescribe = [
  780. {
  781. required: true,
  782. message: "业务分类名称不能为空",
  783. trigger: "blur",
  784. },
  785. ];
  786. rules.warehouseId = [
  787. { required: true, message: "存储地点不能为空", trigger: "blur" },
  788. ];
  789. } else if (businessType === "13") {
  790. rules.warehouseId = [
  791. { required: true, message: "调入仓库不能为空", trigger: "blur" },
  792. ];
  793. rules.areaCode = [
  794. { required: true, message: "调入区域不能为空", trigger: "blur" },
  795. ];
  796. rules.locationCode = [
  797. { required: true, message: "调入货位不能为空", trigger: "blur" },
  798. ];
  799. }
  800. }
  801. return rules;
  802. },
  803. },
  804. watch: {
  805. "$route.query.id": {
  806. immediate: true,
  807. handler(newId, oldId) {
  808. // 只有当前路由路径包含"/outStorageManage/inrequest/InRequestForm"时才处理,避免标签跳转时错误调用API
  809. if (
  810. this.$route.path.includes("/outStorageManage/inrequest/InRequestForm")
  811. ) {
  812. // 只有当id变化时才执行操作,避免不必要的重复调用
  813. if (newId !== oldId) {
  814. if (newId) {
  815. this.dialogTitle = "修改";
  816. this.open(newId);
  817. } else {
  818. this.dialogTitle = "新增";
  819. this.reset();
  820. }
  821. }
  822. }
  823. },
  824. },
  825. // 监听仓库选择变化,获取对应区域列表
  826. "formData.warehouseId": {
  827. handler(newVal, oldVal) {
  828. if (this.formData.businessType === "13" && newVal) {
  829. this.loadAreaList(newVal);
  830. // 第一次 oldVal 为 undefined,认为是初始化,不清空
  831. if (oldVal === undefined) return;
  832. // 人工切换仓库
  833. this.formData.areaCode = undefined;
  834. this.formData.locationCode = undefined;
  835. this.locationList = [];
  836. } else {
  837. this.areaList = [];
  838. this.locationList = [];
  839. }
  840. },
  841. },
  842. // 监听区域选择变化,获取对应货位列表
  843. "formData.areaCode": {
  844. handler(newVal, oldVal) {
  845. if (
  846. this.formData.businessType === "13" &&
  847. newVal &&
  848. this.formData.warehouseId
  849. ) {
  850. this.loadLocationList(this.formData.warehouseId, newVal);
  851. if (oldVal === undefined) return; // 初始化阶段不清空
  852. this.formData.locationCode = undefined;
  853. } else {
  854. this.locationList = [];
  855. }
  856. },
  857. },
  858. },
  859. created() {
  860. // 一次性获取全部仓库
  861. this.loadWarehouseList();
  862. // 一次性获取全部供应商
  863. InRequestApi.getSupplierPage({ pageSize: 9999 }).then(({ data }) => {
  864. this.supplierList = data.list || [];
  865. this.supplierOptions = this.supplierList;
  866. });
  867. // 一次性获取全部客户编码
  868. InRequestApi.getCustomerPage({ pageSize: 9999 }).then(({ data }) => {
  869. this.customerList = data.list || [];
  870. });
  871. },
  872. methods: {
  873. /* 1. 保证仓库列表就位 */
  874. async loadWarehouseList() {
  875. if (this.warehouseList.length) return; // 已经拿过
  876. const { data } = await InRequestApi.getStockPage({ pageSize: 9999 });
  877. this.warehouseList = data.list || [];
  878. },
  879. // 通用的判断函数判断按钮是否可点击
  880. isButtonDisabled(buttonType) {
  881. const status = Number(this.formData.status);
  882. switch (buttonType) {
  883. case "commit":
  884. return status !== 0; // 提交,status=0时可点击
  885. case "cancel":
  886. return status !== 1; // 撤销,status=1时可点击
  887. case "audit":
  888. return status !== 1; // 审核,status=1时可点击
  889. case "antiAudit":
  890. return status < 2; // 反审核,status>=2时可点击
  891. default:
  892. return true;
  893. }
  894. },
  895. handleDelete(row) {
  896. console.log(row);
  897. this.formData.list.splice(row.$index, 1);
  898. },
  899. selectDepart(item) {
  900. this.formData.deptCode = item.code;
  901. this.formData.deptName = item.name;
  902. },
  903. remoteMaterialSearch(query, type, index) {
  904. if (query) {
  905. this.loadingMaterial = true;
  906. setTimeout(async () => {
  907. try {
  908. const params = {};
  909. if (type === "code") {
  910. params.code = query;
  911. } else {
  912. params.name = query;
  913. }
  914. const {
  915. data: { list },
  916. } = await InRequestApi.getMaterialPage(params);
  917. // 每次搜索都重新赋值,保证列表始终是最新数据
  918. if (type === "code") {
  919. this.materialNoList = list || [];
  920. } else {
  921. this.materialNameList = list || [];
  922. }
  923. } catch (error) {
  924. console.error("搜索物料失败:", error);
  925. // 出错时清空列表
  926. if (type === "code") {
  927. this.materialNoList = [];
  928. } else {
  929. this.materialNameList = [];
  930. }
  931. } finally {
  932. this.loadingMaterial = false;
  933. }
  934. }, 200);
  935. } else {
  936. // 清空对应的列表
  937. if (type === "code") {
  938. this.materialNoList = [];
  939. } else {
  940. this.materialNameList = [];
  941. }
  942. }
  943. },
  944. add() {
  945. if (!this.formData.businessType) {
  946. return this.$message.error("请先选择业务类型");
  947. }
  948. this.formData.list = this.formData.list || [];
  949. this.formData.list.push({});
  950. },
  951. changeMaterial(value, index, type) {
  952. // 根据选择的类型获取对应的列表
  953. const list =
  954. type === "code" ? this.materialNoList : this.materialNameList;
  955. // 查找选中的物料信息
  956. let selectedMaterial = null;
  957. if (type === "code") {
  958. selectedMaterial = list.find((item) => item.code === value);
  959. // 如果在当前列表找不到,尝试从另一个列表找
  960. if (!selectedMaterial) {
  961. selectedMaterial = this.materialNameList.find(
  962. (item) => item.code === value
  963. );
  964. }
  965. } else {
  966. selectedMaterial = list.find((item) => item.name === value);
  967. // 如果在当前列表找不到,尝试从另一个列表找
  968. if (!selectedMaterial) {
  969. selectedMaterial = this.materialNoList.find(
  970. (item) => item.name === value
  971. );
  972. }
  973. }
  974. if (selectedMaterial) {
  975. // 更新表单中的物料信息
  976. const newRow = {
  977. ...this.formData.list[index],
  978. materialNo: selectedMaterial.code,
  979. materialName: selectedMaterial.name,
  980. unitName: selectedMaterial.unit || "",
  981. };
  982. // 更新行数据
  983. this.$set(this.formData.list, index, newRow);
  984. }
  985. },
  986. remoteMethod(query) {
  987. if (query !== "") {
  988. this.sourceOrderNoList = this.allSourceOrderNoList.filter((item) =>
  989. item.sourceOrderNo.toLowerCase().includes(query.toLowerCase())
  990. );
  991. } else {
  992. this.sourceOrderNoList = this.allSourceOrderNoList;
  993. }
  994. },
  995. // 远程搜索调入区域
  996. remoteAreaSearch(query) {
  997. if (query !== "") {
  998. this.loadingArea = true;
  999. setTimeout(async () => {
  1000. try {
  1001. const {
  1002. data: { list },
  1003. } = await InRequestApi.getStockAreaPage({
  1004. areaName: query,
  1005. pageSize: 999,
  1006. });
  1007. this.areaList = list || [];
  1008. } catch (error) {
  1009. console.error("搜索调入区域失败:", error);
  1010. this.areaList = [];
  1011. } finally {
  1012. this.loadingArea = false;
  1013. }
  1014. }, 200);
  1015. } else {
  1016. this.areaList = [];
  1017. }
  1018. },
  1019. // 加载区域列表
  1020. async loadAreaList(warehouseId) {
  1021. this.loadingArea = true;
  1022. try {
  1023. // 通过erpId找到仓库的完整数据
  1024. console.log("warehouseList的长度", this.warehouseList.length);
  1025. const warehouseRow = this.warehouseList.find(
  1026. (w) => w.erpId === warehouseId
  1027. );
  1028. // 获取仓库的id
  1029. const wmsStockId = warehouseRow ? warehouseRow.id : warehouseId;
  1030. const {
  1031. data: { list },
  1032. } = await InRequestApi.getStockAreaPage({
  1033. wmsStockId: wmsStockId,
  1034. pageSize: 9999,
  1035. });
  1036. this.areaList = list || [];
  1037. } catch (error) {
  1038. console.error("加载区域列表失败:", error);
  1039. this.areaList = [];
  1040. } finally {
  1041. this.loadingArea = false;
  1042. }
  1043. },
  1044. // 加载货位列表
  1045. async loadLocationList(warehouseId, areaCode) {
  1046. this.loadingLocation = true;
  1047. try {
  1048. // 通过areaCode找到区域的完整数据
  1049. const area = this.areaList.find((w) => w.areaCode === areaCode);
  1050. // 获取区域的id
  1051. const wmsStockAreaId = area ? area.id : areaCode;
  1052. const {
  1053. data: { list },
  1054. } = await InRequestApi.getStockLocationPage({
  1055. wmsStockAreaId: wmsStockAreaId,
  1056. pageSize: 9999,
  1057. });
  1058. this.locationList = list || [];
  1059. } catch (error) {
  1060. console.error("加载货位列表失败:", error);
  1061. this.locationList = [];
  1062. } finally {
  1063. this.loadingLocation = false;
  1064. }
  1065. },
  1066. // remoteWarehouse(query) {
  1067. // if (query !== "") {
  1068. // const that = this;
  1069. // this.loadingWarehouse = true;
  1070. // setTimeout(async () => {
  1071. // this.loadingWarehouse = false;
  1072. // const {
  1073. // data: { list },
  1074. // } = await InRequestApi.getStockPage({
  1075. // name: query,
  1076. // pageSize: 999,
  1077. // });
  1078. // this.warehouseList = list || [];
  1079. // }, 200);
  1080. // } else {
  1081. // this.warehouseList = [];
  1082. // }
  1083. // },
  1084. // changeSourceOrderNo(value) {
  1085. // this.sourceOrderNoList.map((v) => {
  1086. // if (v.sourceOrderNo == value) {
  1087. // this.formData.list = v.list;
  1088. // }
  1089. // });
  1090. // },
  1091. changeSourceOrderNo(value) {
  1092. (this.sourceOrderNoList || []).forEach((v) => {
  1093. if (v.sourceOrderNo === value) {
  1094. this.formData.list = v.list || [];
  1095. }
  1096. });
  1097. },
  1098. // changeBusinessDescribe(e) {
  1099. // this.businessDescribeList.map((v) => {
  1100. // if (v.label == e) {
  1101. // this.formData.businessCategory = v.value;
  1102. // }
  1103. // });
  1104. // },
  1105. async changeBusinessDescribe(e) {
  1106. // 1. 找到并存储选中的业务分类整行数据
  1107. const selectedRow =
  1108. (this.businessDescribeList || []).find((v) => v.label === e) || {};
  1109. this.currentBusinessDescribeRow = selectedRow;
  1110. // 2. 设置业务分类值
  1111. if (selectedRow) {
  1112. this.formData.businessCategory = selectedRow.value;
  1113. }
  1114. // 3. 记录选中的名称
  1115. this.selectedBusinessDescribe = e;
  1116. // 4. 调用源单接口
  1117. if (this.formData.businessType && this.selectedBusinessDescribe) {
  1118. this.loadingSourceOrder = true;
  1119. try {
  1120. const { data } = await InRequestApi.getSourceOrder({
  1121. businessType: this.formData.businessType,
  1122. businessDescribe: this.selectedBusinessDescribe,
  1123. businessCategory: this.currentBusinessDescribeRow.value,
  1124. id: this.$route.query.id || undefined,
  1125. pageSize: 999,
  1126. });
  1127. this.allSourceOrderNoList = data || [];
  1128. this.sourceOrderNoList = this.allSourceOrderNoList;
  1129. } finally {
  1130. this.loadingSourceOrder = false;
  1131. }
  1132. }
  1133. },
  1134. async changeBusinessType(value) {
  1135. // 1. 先拿到业务类型对应的整条字典
  1136. const dictRow =
  1137. this.getDictDatas("inout_business_type").find(
  1138. (d) => d.value === value
  1139. ) || {};
  1140. this.currentBusinessTypeRow = dictRow; // 整条数据存起来
  1141. // 2. 原有逻辑保持不变
  1142. this.formData.businessType = value;
  1143. this.formData.businessDescribe = "";
  1144. this.formData.businessCategory = "";
  1145. this.formData.sourceOrderNo = "";
  1146. this.formData.list = [];
  1147. this.sourceOrderNoList = [];
  1148. this.allSourceOrderNoList = [];
  1149. this.selectedBusinessDescribe = "";
  1150. this.currentBusinessDescribeRow = null; // 清空业务分类数据
  1151. this.$nextTick(() => this.$refs.formRef.clearValidate());
  1152. const { data } = await InRequestApi.getDictByOrderType({
  1153. orderType: value,
  1154. });
  1155. this.businessDescribeList = data;
  1156. },
  1157. /** 初始化数据 */
  1158. async open(id) {
  1159. this.reset();
  1160. if (!id) {
  1161. // 新增
  1162. this.dialogTitle = "新增";
  1163. this.formData.list = [];
  1164. return;
  1165. }
  1166. /* ---------- 编辑模式 ---------- */
  1167. this.dialogTitle = "修改";
  1168. this.formLoading = true;
  1169. try {
  1170. /* 1. 先保证仓库就位 */
  1171. await this.loadWarehouseList();
  1172. const res = await InRequestApi.getInRequest(id);
  1173. res.data.businessType = res.data.businessType
  1174. ? res.data.businessType.toString()
  1175. : "0";
  1176. res.data.businessDescribe = res.data.businessDescribe
  1177. ? res.data.businessDescribe.toString()
  1178. : "";
  1179. res.data.priority = res.data.priority
  1180. ? res.data.priority.toString()
  1181. : "0";
  1182. res.data.status = res.data.status ? res.data.status.toString() : "0";
  1183. res.data.areaCode = res.data.areaCode
  1184. ? res.data.areaCode.toString()
  1185. : undefined;
  1186. res.data.locationCode = res.data.locationCode
  1187. ? res.data.locationCode.toString()
  1188. : undefined;
  1189. res.data.list = res.data.list || [];
  1190. /* 4. 补业务分类下拉数据(你原来缺的) */
  1191. if (res.data.businessType) {
  1192. const { data: describeList } = await InRequestApi.getDictByOrderType({
  1193. orderType: res.data.businessType,
  1194. });
  1195. this.businessDescribeList = describeList || [];
  1196. }
  1197. /* 5. ★ 关键:如果后端也返回了业务分类名称,顺手把源单列表拉回来 */
  1198. if (res.data.businessType && res.data.businessDescribe) {
  1199. // 找到当前分类整行,拿 value 字段
  1200. const row = this.businessDescribeList.find(
  1201. (v) => v.label === res.data.businessDescribe
  1202. );
  1203. this.currentBusinessDescribeRow = row || null;
  1204. this.loadingSourceOrder = true;
  1205. try {
  1206. const { data: sourceList } = await InRequestApi.getSourceOrder({
  1207. businessType: res.data.businessType,
  1208. businessDescribe: res.data.businessDescribe,
  1209. businessCategory: row?.value,
  1210. id, // 当前单据 id
  1211. pageSize: 999,
  1212. });
  1213. this.allSourceOrderNoList = sourceList || [];
  1214. this.sourceOrderNoList = this.allSourceOrderNoList;
  1215. } finally {
  1216. this.loadingSourceOrder = false;
  1217. }
  1218. }
  1219. /* 3. 现在仓库列表有了,先加载区域/货位 */
  1220. if (res.data.businessType === "13" && res.data.warehouseId) {
  1221. console.log("开始加载区域列表", res.data.warehouseId);
  1222. await this.loadAreaList(res.data.warehouseId);
  1223. console.log(
  1224. "区域下拉",
  1225. this.areaList.map((i) => i.areaCode)
  1226. );
  1227. if (res.data.areaCode) {
  1228. console.log("开始加载货位列表", res.data.areaCode);
  1229. await this.loadLocationList(
  1230. res.data.warehouseId,
  1231. res.data.areaCode
  1232. );
  1233. console.log(
  1234. "货位下拉",
  1235. this.locationList.map((i) => i.locationCode)
  1236. );
  1237. }
  1238. }
  1239. /* 最后再赋值表单数据 */
  1240. this.formData = res.data;
  1241. this.uploadFiles = res.data.filesListVos;
  1242. } finally {
  1243. this.formLoading = false;
  1244. }
  1245. },
  1246. /** 保存按钮 */
  1247. async submitForm() {
  1248. // 校验主表
  1249. await this.$refs["formRef"].validate();
  1250. this.formLoading = true;
  1251. try {
  1252. const data = this.formData;
  1253. data.list = (data.list || [])
  1254. .filter((v) => v.nowDeliveredQty)
  1255. .map(
  1256. ({
  1257. completedQty,
  1258. actualQty,
  1259. stock_code,
  1260. area_code,
  1261. location_code,
  1262. status,
  1263. lineNo,
  1264. inventory_status,
  1265. ...rest
  1266. }) => rest
  1267. );
  1268. // 上传的附件拼接传给后端
  1269. const fileIds = (this.uploadFiles || [])
  1270. .map((item) => {
  1271. return item.id || item.name?.fileId;
  1272. })
  1273. .filter((id) => id && id !== "");
  1274. // 拼接文件ID
  1275. data.fileId = fileIds.join(",");
  1276. // 只有businessType === "13"时才提交areaCode和locationCode
  1277. if (data.businessType !== "13") {
  1278. delete data.areaCode;
  1279. delete data.locationCode;
  1280. }
  1281. // 修改的提交;
  1282. if (data.id) {
  1283. await InRequestApi.updateInRequest(data);
  1284. this.$modal.msgSuccess("修改成功");
  1285. // this.$router.back();//修改时停留在当前页面
  1286. return;
  1287. }
  1288. // 添加的提交
  1289. await InRequestApi.createInRequest(data);
  1290. this.$modal.msgSuccess("新增成功");
  1291. this.$router.back();
  1292. } finally {
  1293. this.formLoading = false;
  1294. }
  1295. },
  1296. /** 提交按钮 */
  1297. async commit() {
  1298. // 业务类型为13时,校验调入仓库、区域、货位
  1299. if (this.formData.businessType === "13") {
  1300. if (!this.formData.warehouseId) {
  1301. this.$modal.msgError("调入仓库不能为空");
  1302. return;
  1303. }
  1304. if (!this.formData.areaCode) {
  1305. this.$modal.msgError("调入区域不能为空");
  1306. return;
  1307. }
  1308. if (!this.formData.locationCode) {
  1309. this.$modal.msgError("调入货位不能为空");
  1310. return;
  1311. }
  1312. }
  1313. const menuId = this.$route.meta.id;
  1314. // 只提取需要的字段
  1315. const requestData = {
  1316. id: this.formData.id,
  1317. menuId: menuId,
  1318. };
  1319. // 接口调用
  1320. await InRequestApi.commitOutRequest(requestData);
  1321. this.$modal.msgSuccess("提交成功");
  1322. // 状态变化
  1323. this.$set(this.formData, "status", "1");
  1324. // 重新获取数据
  1325. const res = await InRequestApi.getInRequest(this.formData.id);
  1326. this.formData.bpmInstanceId = res.data.bpmInstanceId;
  1327. },
  1328. /** 撤销按钮 */
  1329. async cancel() {
  1330. // // 业务类型为13时,校验调入仓库、区域、货位
  1331. // if (this.formData.businessType === "13") {
  1332. // if (!this.formData.warehouseId) {
  1333. // this.$modal.msgError("调入仓库不能为空");
  1334. // return;
  1335. // }
  1336. // if (!this.formData.areaCode) {
  1337. // this.$modal.msgError("调入区域不能为空");
  1338. // return;
  1339. // }
  1340. // if (!this.formData.locationCode) {
  1341. // this.$modal.msgError("调入货位不能为空");
  1342. // return;
  1343. // }
  1344. // }
  1345. const requestData = {
  1346. id: this.formData.id,
  1347. };
  1348. // 接口调用
  1349. await InRequestApi.cancelOutRequest(requestData);
  1350. this.$modal.msgSuccess("撤销成功");
  1351. // 状态变化
  1352. this.$set(this.formData, "status", "0");
  1353. },
  1354. /** 审核按钮 */
  1355. async audit() {
  1356. // 业务类型为13时,校验调入仓库、区域、货位
  1357. if (this.formData.businessType === "13") {
  1358. if (!this.formData.warehouseId) {
  1359. this.$modal.msgError("调入仓库不能为空");
  1360. return;
  1361. }
  1362. if (!this.formData.areaCode) {
  1363. this.$modal.msgError("调入区域不能为空");
  1364. return;
  1365. }
  1366. if (!this.formData.locationCode) {
  1367. this.$modal.msgError("调入货位不能为空");
  1368. return;
  1369. }
  1370. }
  1371. // 检查是否存在工作流实例ID
  1372. if (this.formData.bpmInstanceId) {
  1373. // 如果存在工作流实例,跳转到审批任务tab页
  1374. this.activeName = "approvalTask";
  1375. this.$modal.msgWarning("请在审批任务页面完成审核!");
  1376. return;
  1377. }
  1378. const requestData = {
  1379. id: this.formData.id,
  1380. };
  1381. // 接口调用
  1382. await InRequestApi.auditOutRequest(requestData);
  1383. this.$modal.msgSuccess("审核成功");
  1384. // 状态变化
  1385. this.$set(this.formData, "status", "2");
  1386. },
  1387. /** 反审核按钮 */
  1388. async antiAudit() {
  1389. // // 业务类型为13时,校验调入仓库、区域、货位
  1390. // if (this.formData.businessType === "13") {
  1391. // if (!this.formData.warehouseId) {
  1392. // this.$modal.msgError("调入仓库不能为空");
  1393. // return;
  1394. // }
  1395. // if (!this.formData.areaCode) {
  1396. // this.$modal.msgError("调入区域不能为空");
  1397. // return;
  1398. // }
  1399. // if (!this.formData.locationCode) {
  1400. // this.$modal.msgError("调入货位不能为空");
  1401. // return;
  1402. // }
  1403. // }
  1404. const requestData = {
  1405. id: this.formData.id,
  1406. };
  1407. // 接口调用
  1408. await InRequestApi.antiAuditOutRequest(requestData);
  1409. this.$modal.msgSuccess("反审核成功");
  1410. // 状态变化
  1411. this.$set(this.formData, "status", "0");
  1412. },
  1413. /** 取消按钮 */
  1414. handleCancel() {
  1415. this.reset();
  1416. this.$router.back();
  1417. },
  1418. /** 表单重置 */
  1419. reset() {
  1420. this.formData = {
  1421. id: undefined,
  1422. requestNo: undefined,
  1423. requestType: undefined,
  1424. businessType: undefined,
  1425. businessCategory: undefined,
  1426. businessDescribe: undefined,
  1427. businessSubType: undefined,
  1428. status: undefined,
  1429. priority: undefined,
  1430. warehouseId: undefined,
  1431. relatedWarehouseId: undefined,
  1432. supplierCode: undefined,
  1433. customerCode: undefined,
  1434. sourceOrderNo: undefined,
  1435. expectedTime: undefined,
  1436. actualTime: undefined,
  1437. totalQty: undefined,
  1438. totalSku: undefined,
  1439. totalLine: undefined,
  1440. remark: undefined,
  1441. extendInfo: undefined,
  1442. submitter: undefined,
  1443. submitTime: undefined,
  1444. auditor: undefined,
  1445. auditTime: undefined,
  1446. erpWriteFlag: undefined,
  1447. erpErrMsg: undefined,
  1448. erpBackId: undefined,
  1449. list: [],
  1450. areaCode: undefined,
  1451. locationCode: undefined,
  1452. };
  1453. this.resetForm("formRef");
  1454. },
  1455. // 标签页切换处理
  1456. handleClick(tab, event) {
  1457. // 可以在这里添加标签切换时的逻辑
  1458. console.log(tab, event);
  1459. },
  1460. deliverChange(val) {
  1461. // 这里可以写“本次出入数量”变化后的校验或计算逻辑
  1462. console.log("deliverChange", val);
  1463. },
  1464. // 附件上传
  1465. handleUpload() {
  1466. this.$refs.attachmentUpload.isUploadShow = -1;
  1467. this.$refs.attachmentUpload.title = "上传附件";
  1468. // 直接使用当前组件维护的 uploadFiles,而不是重新获取
  1469. this.$refs.attachmentUpload.fileList = this.uploadFiles || [];
  1470. this.$refs.attachmentUpload.visible = true;
  1471. },
  1472. // 获取上传的附件
  1473. getFileList(data) {
  1474. this.uploadFiles = data;
  1475. },
  1476. // 供应商编码过滤方法
  1477. filterSupplier(keyword) {
  1478. const key = (keyword || "").toLowerCase();
  1479. this.supplierOptions = this.supplierList.filter(
  1480. (item) =>
  1481. item.code.toLowerCase().includes(key) ||
  1482. (item.name && item.name.toLowerCase().includes(key))
  1483. );
  1484. },
  1485. },
  1486. };
  1487. </script>
  1488. <style scoped>
  1489. /* 新增按钮容器样式,将所有按钮放在标题下方 */
  1490. .buttons-container {
  1491. position: relative;
  1492. display: flex;
  1493. gap: 10px;
  1494. padding: 10px 0;
  1495. margin-bottom: 20px;
  1496. }
  1497. /* 调整app-header的位置 */
  1498. .app-header {
  1499. margin-bottom: 10px;
  1500. }
  1501. .app-container {
  1502. min-width: 900px;
  1503. margin: 0 auto;
  1504. overflow-x: auto;
  1505. }
  1506. </style>