form.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. <!-- 首序外协 -->
  2. <template>
  3. <el-drawer title="首序外协信息" :with-header="false" v-model="visible" direction="rtl" size="100%">
  4. <div class="form-container column-container">
  5. <div class="form-btns-container">
  6. <span class="title-label">
  7. <el-icon>
  8. <Document />
  9. </el-icon>
  10. <span>外协单信息</span>
  11. </span>
  12. <el-button v-show="editStatus && form.isSubmit == 1" type="primary" icon="Download" @click="handleExport"
  13. v-hasPermi="['business:firstOutsource:export']">导出</el-button>
  14. <el-button v-show="editStatus && form.isSubmit == 1" type="warning" icon="Download" @click="handlePrint"
  15. v-hasPermi="['business:firstOutsource:export']">
  16. 打印
  17. </el-button>
  18. <el-button v-if="editStatus" type="primary" icon="Finished" @click="handleSubmit">保存</el-button>
  19. <el-button v-if="editStatus && form.isSubmit == 1" type="info" icon="Calendar"
  20. @click="handleViewRecords">历史记录</el-button>
  21. <div class="close-btn" @click="cancel">
  22. <i class="fa fa-times" aria-hidden="true" />
  23. <!-- <span>关闭</span> -->
  24. </div>
  25. </div>
  26. <el-form ref="formRef" class="master-container" :model="form" v-loading="loading" :rules="rules"
  27. label-width="120px">
  28. <el-row :gutter="20">
  29. <el-col :span="6">
  30. <el-form-item label="单据号" prop="formCode">
  31. <el-input v-if="editStatus" v-model="form.formCode" disabled placeholder="系统自动生成" />
  32. <span v-else>{{ form.formCode }}</span>
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="6">
  36. <el-form-item label="表单日期" prop="formDate">
  37. <el-date-picker v-if="editStatus && hasReturnReceiptDetailFlag" clearable v-model="form.formDate"
  38. type="date" value-format="YYYY-MM-DD" placeholder="请选择表单日期" style="width: 100%">
  39. </el-date-picker>
  40. <span v-else>{{ parseTime(form.formDate, "{y}-{m}-{d}") }}</span>
  41. </el-form-item>
  42. </el-col>
  43. <el-col :span="6">
  44. <el-form-item label="外协商名称" prop="supplierName">
  45. <el-input v-if="editStatus && form.isSubmit == 0 && hasReturnReceiptDetailFlag"
  46. v-model="form.supplierName" readonly placeholder="请输入外协商名称">
  47. <template #append>
  48. <el-button icon="Search" @click="handleShowDialogSuppliers" />
  49. </template>
  50. </el-input>
  51. <span v-else>{{ form.supplierName }}</span>
  52. </el-form-item>
  53. </el-col>
  54. <el-col :span="6" v-if="false">
  55. <el-form-item label="运费单价" prop="freightPrice">
  56. <el-input-number v-if="editStatus && hasReturnReceiptDetailFlag" v-model="form.freightPrice" :min="0"
  57. :precision="2" controls-position="right" />
  58. <span v-else>{{ form.freightPrice }}</span>
  59. </el-form-item>
  60. </el-col>
  61. <el-col :span="6" v-if="false">
  62. <el-form-item label="运费总价" prop="freightAmount">
  63. <el-input-number v-if="editStatus && hasReturnReceiptDetailFlag" v-model="form.freightAmount" :min="0"
  64. :precision="2" controls-position="right" />
  65. <span v-else>{{ form.freightAmount }}</span>
  66. </el-form-item>
  67. </el-col>
  68. <el-col :span="6">
  69. <el-form-item label="送货方式" prop="deliveryMethod">
  70. <el-select v-if="editStatus && hasReturnReceiptDetailFlag" v-model="form.deliveryMethod" placeholder="请选择"
  71. @change="handleChangeDeliveryMethod">
  72. <el-option v-for=" dict in deliveryMethod " :key="dict.value" :label="dict.label"
  73. :value="dict.value" />
  74. </el-select>
  75. <span v-else>{{ selectText(form.deliveryMethod, deliveryMethod) }}</span>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="6">
  79. <el-form-item label="带箱方式" prop="packagingMethod">
  80. <el-select v-if="editStatus && hasReturnReceiptDetailFlag" v-model="form.packagingMethod"
  81. placeholder="请选择" @change="handleChangePackagingMethod">
  82. <el-option v-for=" dict in packagingMethod " :key="dict.value" :label="dict.label"
  83. :value="dict.value" />
  84. </el-select>
  85. <span v-else>{{ selectText(form.packagingMethod, packagingMethod) }}</span>
  86. </el-form-item>
  87. </el-col>
  88. <el-col :span="6">
  89. <el-form-item label="结算方式" prop="settlementType">
  90. <el-select v-if="editStatus && hasReturnReceiptDetailFlag" v-model="form.settlementType"
  91. placeholder="请选择">
  92. <el-option v-for=" dict in settlementType " :key="dict.value" :label="dict.label"
  93. :value="dict.value" />
  94. </el-select>
  95. <span v-else>{{ selectText(form.settlementType, settlementType) }}</span>
  96. </el-form-item>
  97. </el-col>
  98. <el-col :span="6">
  99. <el-form-item label="备注" prop="remark">
  100. <el-input v-if="editStatus" v-model.trim="form.remark" placeholder="请输入备注" />
  101. <span v-else>{{ form.remark }}</span>
  102. </el-form-item>
  103. </el-col>
  104. <el-col :span="6">
  105. <el-form-item label="总箱数" prop="remark">
  106. <span>{{ totalCarriersNum }}</span>
  107. </el-form-item>
  108. </el-col>
  109. </el-row>
  110. </el-form>
  111. <!-- 渲染数据区 -->
  112. <div class="form-details-btns-container">
  113. <el-button v-show="editStatus" type="primary" icon="Plus" @click="handleShowDialogProducts"
  114. v-hasPermi="['business:firstOutsource:add']">
  115. 添加外协产品明细
  116. </el-button>
  117. <el-button v-show="editStatus" type="primary" icon="Plus" @click="handleChoiceFurnaceNoInfo()">
  118. 批量选择炉号
  119. </el-button>
  120. </div>
  121. <div class="el-table-container">
  122. <div class="el-table-inner-container">
  123. <el-table v-loading="loading" :data="form.details" size="small" border height="100%"
  124. @selection-change="handleSelectionChange">
  125. <el-table-column type="selection" align="center" width="48" />
  126. <el-table-column label="行号" type="index" align="center" width="48" />
  127. <el-table-column label="批次号" align="center" prop="lotCode" width="104" />
  128. <el-table-column label="产品描述" align="center" prop="productDescription" width="320" />
  129. <el-table-column label="产品数" align="center" width="160" prop="productNum">
  130. </el-table-column>
  131. <el-table-column label="箱数" align="center" prop="newCarrierCount" width="100">
  132. <template #default="scope">
  133. <el-input-number v-if="editStatus && scope.row.hasReturnReceiptDetailFlag" :min="0"
  134. v-model="scope.row.newCarrierCount" :step="1" step-strictly :controls="false" placeholder="箱数"
  135. @blur="handleCarrierNumChange" />
  136. <span v-else>{{ scope.row.newCarrierCount }}</span>
  137. </template>
  138. </el-table-column>
  139. <el-table-column label="炉号" align="center" prop="" width="150">
  140. <template #default="scope">
  141. <el-button link type="primary" icon="Refresh" v-if="editStatus"
  142. @click="handleChoiceFurnaceNoInfo(scope.row)">
  143. {{ scope.row.furnaceNoInfo != null ? scope.row.furnaceNoInfo.furnaceNumber : '选择炉号' }}
  144. </el-button>
  145. <span v-else>{{ scope.row.furnaceNoInfo.furnaceNumber }}</span>
  146. </template>
  147. </el-table-column>
  148. <el-table-column label="外协工序" align="center" prop="processNames" width="320">
  149. <template #default="scope">
  150. <el-input v-if="editStatus && scope.row.hasReturnReceiptDetailFlag" v-model="scope.row.processNames"
  151. readonly placeholder="请选择工序">
  152. <template #append>
  153. <el-button icon="Search" @click="handleShowDialogProcesses(scope.row)" />
  154. </template>
  155. </el-input>
  156. <span v-else>{{ scope.row.processNames }}</span>
  157. </template>
  158. </el-table-column>
  159. <el-table-column label="备注" align="center" prop="remark">
  160. <template #default="scope">
  161. <el-input v-if="editStatus && scope.row.hasReturnReceiptDetailFlag" v-model="scope.row.remark"
  162. placeholder="备注" />
  163. <span v-else>{{ scope.row.remark }}</span>
  164. </template>
  165. </el-table-column>
  166. <el-table-column v-if="editStatus" label="操作" align="center" class-name="small-padding fixed-width"
  167. width="64">
  168. <template #default="scope">
  169. <el-button circle type="danger" v-if="scope.row.hasReturnReceiptDetailFlag" icon="Delete"
  170. @click="handleDelete(scope.$index)" v-hasPermi="['business:firstOutsource:remove']" />
  171. </template>
  172. </el-table-column>
  173. </el-table>
  174. </div>
  175. </div>
  176. </div>
  177. <!-- 外协商选择 -->
  178. <dialog-suppliers ref="dialogSuppliersRef" :single-selected="handleSingleSelectedSupplier" />
  179. <!-- 投产单选择 -->
  180. <dialog-products ref="dialogProductsRef" :supplier-id="form.supplierId"
  181. :multiple-selected="handleMultipleSelectedProducts" />
  182. <!-- 工序选择 -->
  183. <dialog-processes ref="dialogProcessesRef" :multiple-selected="handleMultipleSelectedProcesses" />
  184. <!-- 新箱号选择 -->
  185. <DialogFurnaceNoInfo ref="dialogFurnaceNoInfoRef" :singleSelected="handleSingleSelectFurnaceNoInfo" />
  186. <!-- 历史记录弹窗 -->
  187. <dialog-outsourced-records ref="dialogOutsourcedRecordsRef" />
  188. <!-- 收回明细带回 -->
  189. <!-- <form-details-recycling ref="formDetailsRecyclingRef" :singleSelected="handleSingleSelectedRecycling"/> -->
  190. </el-drawer>
  191. </template>
  192. <script setup>
  193. import {
  194. getOrder,
  195. getFirstOrder,
  196. saveOrder,
  197. carrierForOutsource,
  198. submitOrder,
  199. exportOutsource,
  200. printOutsource,
  201. submitDetails,
  202. submitDetailsOnFirst,
  203. getLotByProductionPlanSub
  204. } from "@/api/business/outsourcedOrder";
  205. import DialogFurnaceNoInfo from "./DialogFurnaceNoInfo";
  206. import dialogSuppliers from "./DialogSuppliers";
  207. import dialogProducts from "./DialogProducts";
  208. import dialogProcesses from "./DialogProcesses";
  209. import dialogOutsourcedRecords from "./DialogOutsourcedRecords"
  210. // import FormDetailsRecycling from "./detailsRecyclingForm";
  211. const { proxy } = getCurrentInstance();
  212. /** 父组件传参 */
  213. const props = defineProps({
  214. getList: {
  215. type: Function,
  216. default: () => { },
  217. },
  218. deliveryMethod: {
  219. type: Array,
  220. default: [],
  221. },
  222. settlementType: {
  223. type: Array,
  224. default: [],
  225. },
  226. packagingMethod: {
  227. type: Array,
  228. default: [],
  229. },
  230. });
  231. const { getList, deliveryMethod, packagingMethod, settlementType } =
  232. toRefs(props);
  233. /** 字典数组区 */
  234. /** 表单抽屉 页变量 */
  235. const loading = ref(false);
  236. const multiple = ref(true);
  237. const visible = ref(false);
  238. const editStatus = ref(true);
  239. const hasReturnReceiptDetailFlag = ref(true);
  240. const totalCarriersNum = ref(0);
  241. const detailInfo = ref({});
  242. const loadingCarrier = ref(false);
  243. const carriers = ref([]);
  244. const webHost = import.meta.env.VITE_APP_BASE_API;
  245. const form = ref({});
  246. const selections = ref([])
  247. // const formatDetails = ref([])
  248. const currentDetail = ref({});
  249. const dialogFurnaceNoInfoRef = ref(null)
  250. const rules = {
  251. supplierName: [
  252. { required: true, message: "外协商名称不能为空", trigger: "change" },
  253. ],
  254. };
  255. /*********************** 方法区 ****************************/
  256. /** 导出按钮操作 */
  257. function handleExport() {
  258. exportOutsource({ id: form.value.id });
  259. }
  260. /** 打印按钮操作 */
  261. function handlePrint() {
  262. printOutsource({ id: form.value.id });
  263. }
  264. /** 打开抽屉 */
  265. function open(row) {
  266. reset();
  267. totalCarriersNum.value = 0
  268. visible.value = true;
  269. if (row) {
  270. editStatus.value = true;
  271. hasReturnReceiptDetailFlag.value = true
  272. console.log(row)
  273. detailInfo.value = row
  274. form.value.id = row.id;
  275. getForm();
  276. } else {
  277. editStatus.value = true;
  278. hasReturnReceiptDetailFlag.value = true
  279. }
  280. }
  281. /** 查询表单信息 */
  282. function getForm() {
  283. loading.value = true;
  284. getFirstOrder(form.value.id).then((response) => {
  285. form.value = response.data;
  286. //如果发出单明细里收回单,主表除了备注之外不能编辑
  287. form.value.details.forEach((item) => {
  288. item.hasReturnReceiptDetailFlag = true
  289. if (item.returnReceiptDetailList && item.returnReceiptDetailList.length > 0) {
  290. hasReturnReceiptDetailFlag.value = false
  291. }
  292. if (item.returnReceiptDetailList && item.returnReceiptDetailList.length > 0 && item.returnReceiptDetailList[0].status == 1) {
  293. item.hasReturnReceiptDetailFlag = false
  294. }
  295. });
  296. form.value.details.forEach((item) => {
  297. item.editStatus = false;
  298. totalCarriersNum.value += item.newCarrierCount == null ? 0 : item.newCarrierCount;
  299. });
  300. editStatus.value = form.value.isSubmit == 1;
  301. if (!detailInfo.value.flag) {
  302. editStatus.value = false
  303. console.log(editStatus.value)
  304. }
  305. console.log(hasReturnReceiptDetailFlag.value)
  306. loading.value = false;
  307. });
  308. }
  309. //改变带箱方式
  310. function handleChangePackagingMethod() {
  311. totalCarriersNum.value = 0
  312. if (!editStatus) {
  313. if (form.value.packagingMethod == 1 && form.value.details.length > 0) {
  314. form.value.details.forEach(item => { item.newCarriers = []; item.carrierIds = []; item.carriers = carriers.value })
  315. } if (form.value.packagingMethod == 0 && form.value.details.length > 0) {
  316. form.value.details.forEach(item => {
  317. item.carriers = carriers.value;
  318. item.newCarriers = [];
  319. item.carrierIds = [];
  320. item.newCarriers.push(...item.originalCarrierList.map(v => ({ id: v.carrierId, code: v.carrierCode })));
  321. item.carriers.push(...item.originalCarrierList.map((v) => ({ value: v.carrierId, label: v.carrierCode })));
  322. item.carrierIds = item.originalCarrierList.map(info => { return info.carrierId })
  323. })
  324. }
  325. } else {
  326. form.value.details.forEach(item => {
  327. console.log(item.editStatus)
  328. if (item.editStatus) {
  329. item.newCarriers = []; item.carrierIds = []; item.carriers = carriers.value
  330. }
  331. })
  332. }
  333. console.log(form.value.details)
  334. for (let i = 0; i < form.value.details.length; i++) {
  335. console.log(form.value.details)
  336. totalCarriersNum.value += form.value.details[i].newCarrierCount == null ? 0 : form.value.details[i].newCarrierCount
  337. }
  338. }
  339. //改变送货方式
  340. function handleChangeDeliveryMethod() {
  341. if (form.value.deliveryMethod == 1) {
  342. form.value.freightAmount = form.value.freightPrice * totalCarriersNum.value;
  343. } else {
  344. form.value.freightAmount = 0.0;
  345. }
  346. }
  347. //打开历史记录弹窗
  348. function handleViewRecords() {
  349. proxy.$refs.dialogOutsourcedRecordsRef.open(form.value.id);
  350. }
  351. function selectText(value, data) {
  352. if (value) {
  353. return data.filter((item) => item.value == value)[0].label;
  354. }
  355. }
  356. /** 取消按钮 */
  357. function cancel() {
  358. visible.value = false;
  359. // reset();
  360. }
  361. const handleDelete = (index) => {
  362. totalCarriersNum.value -= (form.value.details[index].carrierNum == null ? 0 : form.value.details[index].carrierNum);
  363. if (form.value.deliveryMethod == 1) {
  364. form.value.freightAmount = form.value.freightPrice * totalCarriersNum.value;
  365. } else {
  366. form.value.freightAmount = 0.0;
  367. }
  368. form.value.details.splice(index, 1)
  369. handleCarrierNumChange()
  370. };
  371. /** 表单重置 */
  372. function reset() {
  373. // console.log(proxy.parseTime(new Date(), "{y}-{m}-{d}"))
  374. form.value = {
  375. id: null,
  376. tenantId: null,
  377. formCode: null,
  378. formDate: proxy.parseTime(new Date(), "{y}-{m}-{d}"),
  379. supplierId: "0",
  380. supplierName: "",
  381. deliveryMethod: "0",
  382. freightPrice: 0.0,
  383. freightAmount: 0.0,
  384. packagingMethod: "0",
  385. remark: null,
  386. details: [],
  387. isSubmit: 0,
  388. isFirstProcess: 1
  389. };
  390. proxy.resetForm("formRef");
  391. }
  392. /** 保存 */
  393. function saveFrom() {
  394. if (!form.value.details || form.value.details.length == 0) {
  395. proxy.$modal.msgError("请添加产品明细");
  396. return;
  397. }
  398. proxy.$refs["formRef"].validate((valid) => {
  399. for (const item of form.value.details) {
  400. if (!item.processNames) {
  401. proxy.$modal.msgError("请选择" + item.lotCode + "批次的工序");
  402. return;
  403. }
  404. }
  405. if (form.value.packagingMethod == 1) {
  406. console.log("form.value.details", form.value.details);
  407. for (const item of form.value.details) {
  408. if (item.newCarriers.length == 0) {
  409. proxy.$modal.msgError("请选择" + item.lotCode + "批次的新箱号");
  410. return;
  411. }
  412. }
  413. }
  414. if (valid) {
  415. saveOrder(form.value).then((response) => {
  416. if (response.code == 200) {
  417. proxy.$modal.msgSuccess("保存成功");
  418. visible.value = false;
  419. getList.value();
  420. }
  421. });
  422. }
  423. });
  424. }
  425. /** 保存并提交 */
  426. function submitFrom() {
  427. console.log("from", form.value);
  428. proxy.$modal
  429. .confirm("是否确定提交,提交后不可修改,删除")
  430. .then(function () {
  431. return;
  432. })
  433. .then(() => {
  434. if (!form.value.details || form.value.details.length == 0) {
  435. proxy.$modal.msgError("请添加产品明细");
  436. return;
  437. }
  438. proxy.$refs["formRef"].validate((valid) => {
  439. for (const item of form.value.details) {
  440. if (!item.processNames) {
  441. proxy.$modal.msgError("请选择" + item.lotCode + "批次的工序");
  442. return;
  443. }
  444. }
  445. if (form.value.packagingMethod == 1) {
  446. console.log("form.value.details", form.value.details);
  447. for (const item of form.value.details) {
  448. if (item.newCarriers.length == 0) {
  449. proxy.$modal.msgError("请选择" + item.lotCode + "批次的新箱号");
  450. return;
  451. }
  452. }
  453. }
  454. if (valid) {
  455. console.log(form.value);
  456. submitOrder(form.value).then((response) => {
  457. proxy.$modal.msgSuccess("提交成功");
  458. visible.value = false;
  459. getList.value();
  460. });
  461. }
  462. });
  463. })
  464. .catch(() => { });
  465. }
  466. //5.29保存
  467. function handleSubmit() {
  468. if (form.value.isSubmit == 0) {
  469. proxy.$modal
  470. .confirm("是否确定保存,保存后外协商不可编辑!")
  471. .then(function () {
  472. return;
  473. })
  474. .then(() => {
  475. if (!form.value.details || form.value.details.length == 0) {
  476. proxy.$modal.msgError("请添加产品明细");
  477. return;
  478. }
  479. proxy.$refs["formRef"].validate((valid) => {
  480. for (const item of form.value.details) {
  481. if (!item.processNames) {
  482. proxy.$modal.msgError("请选择" + item.lotCode + "批次的工序");
  483. return;
  484. }
  485. }
  486. // 判断是否有批次没有炉号
  487. const unfurnace = form.value.details.find(v => v.furnaceNoInfo == null)
  488. if (unfurnace != null) {
  489. proxy.$modal.msgError("请选择" + unfurnace.lotCode + "批次的炉号")
  490. return
  491. }
  492. if (totalCarriersNum.value == null || totalCarriersNum.value == 0) {
  493. proxy.$modal.msgError("请输入箱数")
  494. return
  495. }
  496. if (valid) {
  497. console.log(form.value)
  498. submitDetailsOnFirst(form.value).then((response) => {
  499. proxy.$modal.msgSuccess("提交成功");
  500. visible.value = false;
  501. getList.value();
  502. });
  503. }
  504. });
  505. })
  506. } else {
  507. if (!form.value.details || form.value.details.length == 0) {
  508. proxy.$modal.msgError("请添加产品明细");
  509. return;
  510. }
  511. proxy.$refs["formRef"].validate((valid) => {
  512. for (const item of form.value.details) {
  513. if (!item.processNames) {
  514. proxy.$modal.msgError("请选择" + item.lotCode + "批次的工序");
  515. return;
  516. }
  517. }
  518. // 判断是否有批次没有炉号
  519. const unfurnace = form.value.details.find(v => v.furnaceNoInfo == null)
  520. if (unfurnace != null) {
  521. proxy.$modal.msgError("请选择" + unfurnace.lotCode + "批次的炉号")
  522. return
  523. }
  524. if (totalCarriersNum.value == null || totalCarriersNum.value == 0) {
  525. proxy.$modal.msgError("请输入箱数")
  526. return
  527. }
  528. if (valid) {
  529. console.log(form.value)
  530. submitDetailsOnFirst(form.value).then((response) => {
  531. proxy.$modal.msgSuccess("提交成功");
  532. visible.value = false;
  533. getList.value();
  534. });
  535. }
  536. });
  537. }
  538. }
  539. /***************************** 外协商对话框相关 *****************************/
  540. // 打开外协商选择对话框
  541. const handleShowDialogSuppliers = () => {
  542. proxy.$refs.dialogSuppliersRef.open();
  543. };
  544. // 外协商选择带回
  545. const handleSingleSelectedSupplier = (data) => {
  546. console.log(data);
  547. form.value.supplierId = data.id;
  548. form.value.lossLimit = data.lossLimit;
  549. form.value.supplierName = data.name;
  550. form.value.deliveryMethod = data.deliveryMethod;
  551. form.value.freightPrice = data.freightPrice;
  552. form.value.settlementType = data.settlementType;
  553. if (form.value.deliveryMethod == 1) {
  554. form.value.freightAmount = form.value.freightPrice * totalCarriersNum.value;
  555. } else {
  556. form.value.freightAmount = 0.0;
  557. }
  558. };
  559. /***************************** 外协收回明细相关 *****************************/
  560. //打开收回明细表单
  561. function handleDetailsRecycling() {
  562. proxy.$refs.formDetailsRecyclingRef.open(row);
  563. }
  564. function handleSingleSelectedRecycling() { }
  565. /***************************** 产品对话框相关 *****************************/
  566. // 打开产品选择对话框
  567. const handleShowDialogProducts = () => {
  568. // const dayworkIds = form.value.details.map((item) => item.dayworkId);
  569. // console.log(dayworkIds);
  570. proxy.$refs.dialogProductsRef.open();
  571. };
  572. // 产品选择带回
  573. const handleMultipleSelectedProducts = (selection) => {
  574. // 获取所有批次信息
  575. const requestData = {
  576. planDetails: selection,
  577. supplierId: form.value.supplierId,
  578. supplierName: form.value.supplierName,
  579. masterId: form.value.id
  580. }
  581. getLotByProductionPlanSub(requestData).then(res => {
  582. // console.log(res)
  583. if (res.code === 200) {
  584. form.value.details.push(...res.data.filter(e => form.value.details.findIndex(t => t.lotId === e.lotId) < 0).map(e => ({ ...e, hasReturnReceiptDetailFlag: true })))
  585. }
  586. })
  587. };
  588. /***************************** 外协工序对话框相关 *****************************/
  589. // 打开外协工序选择对话框
  590. const handleShowDialogProcesses = (row) => {
  591. currentDetail.value = row;
  592. proxy.$refs.dialogProcessesRef.open(row);
  593. };
  594. // 工序选择带回
  595. const handleMultipleSelectedProcesses = (selection) => {
  596. const oldProcesses = currentDetail.value.processes == null ? [] : [...currentDetail.value.processes]
  597. if (
  598. currentDetail.value.returnReceiptDetailList &&
  599. currentDetail.value.returnReceiptDetailList.length > 0 &&
  600. selection.findIndex(e => !oldProcesses.some(v => v.technologicalProcessDetailId == e.id)) >= 0
  601. ) {
  602. proxy.$modal.msgError('已收回批次不能添加新工序')
  603. return
  604. }
  605. currentDetail.value.processes = []
  606. console.log(selection);
  607. const processNames = selection.sort((a, b) => a.processStepNumber - b.processStepNumber).map((item) => item.processAlias);
  608. // 使用join方法将数组转换为以逗号分隔的字符串
  609. let commaSeparatedString = processNames.join(",");
  610. currentDetail.value.processes = [];
  611. currentDetail.value.processNames = commaSeparatedString;
  612. selection.forEach((item) => {
  613. const newProcess = {
  614. processId: item.processId,
  615. processCode: item.processCode,
  616. processAlias: item.processAlias,
  617. processStepNumber: item.processStepNumber,
  618. technologicalProcessDetailId: item.id,
  619. };
  620. currentDetail.value.processes.push(newProcess);
  621. });
  622. };
  623. function handleSelectionChange(selection) {
  624. selections.value = selection
  625. }
  626. // 选择炉号
  627. const handleChoiceFurnaceNoInfo = (row) => {
  628. // 判断选择的产品是不是同一个
  629. const changeFurnaceNoInfo = row ? [row] : selections.value;
  630. let checkSame = true
  631. changeFurnaceNoInfo.forEach(l => {
  632. checkSame = checkSame && l.productId == changeFurnaceNoInfo[0].productId
  633. })
  634. console.log(checkSame)
  635. if (!checkSame) {
  636. proxy.$modal.msgError('请选择相同计划单批量选择炉号')
  637. return
  638. }
  639. if (changeFurnaceNoInfo.length === 0) {
  640. proxy.$modal.msgError('请选择需要变更炉号的计划单')
  641. return
  642. }
  643. dialogFurnaceNoInfoRef.value.open({ details: changeFurnaceNoInfo, queryParams: { ...changeFurnaceNoInfo[0] } })
  644. }
  645. const handleSingleSelectFurnaceNoInfo = (details, info) => {
  646. details.forEach(l => {
  647. l.furnaceNoInfo = info
  648. })
  649. }
  650. function handleCarrierNumChange() {
  651. let sumNum = 0
  652. form.value.details.forEach(v => {
  653. sumNum += (v.newCarrierCount == null ? 0 : v.newCarrierCount)
  654. })
  655. totalCarriersNum.value = sumNum
  656. }
  657. /** 暴露给父组件的方法 */
  658. defineExpose({
  659. open,
  660. });
  661. </script>