SendPurchase.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. <template>
  2. <div style="width: 100%; padding: 0px 15px">
  3. <el-form
  4. :model="formData.data"
  5. :rules="rules"
  6. ref="formDom"
  7. label-position="top"
  8. :disabled="judgeStatus()"
  9. >
  10. <div class="_t">基础信息</div>
  11. <el-row :gutter="10">
  12. <el-col :span="6">
  13. <el-form-item label="采购部门" prop="deptName">
  14. <el-input v-model="formData.data.deptName" placeholder="请输入">
  15. </el-input>
  16. </el-form-item>
  17. </el-col>
  18. <el-col :span="6">
  19. <el-form-item label="采购人" prop="purchaseName">
  20. <el-input v-model="formData.data.purchaseName" placeholder="请输入">
  21. </el-input>
  22. </el-form-item>
  23. </el-col>
  24. <el-col :span="6">
  25. <el-form-item label="采购时间" prop="purchaseTime">
  26. <el-date-picker
  27. v-model="formData.data.purchaseTime"
  28. type="datetime"
  29. placeholder="请选择"
  30. />
  31. </el-form-item>
  32. </el-col>
  33. </el-row>
  34. <el-row :gutter="10">
  35. <el-col :span="8">
  36. <el-form-item label="供应商" prop="supplyId">
  37. <el-select
  38. v-model="formData.data.supplyId"
  39. placeholder="请选择"
  40. @change="handleChangeSupplier"
  41. filterable
  42. style="width: 100%"
  43. >
  44. <el-option
  45. v-for="item in supplierData"
  46. :label="item.name"
  47. :value="item.id"
  48. >
  49. </el-option>
  50. </el-select>
  51. </el-form-item>
  52. </el-col>
  53. </el-row>
  54. <el-form-item label="采购说明" prop="purchaseContent">
  55. <el-input
  56. v-model="formData.data.purchaseContent"
  57. placeholder="请输入"
  58. type="textarea"
  59. >
  60. </el-input>
  61. </el-form-item>
  62. <div class="_t">采购明细</div>
  63. <el-form-item>
  64. <el-button
  65. type="primary"
  66. @click="openProduct = true"
  67. style="margin: 10px 0"
  68. v-if="ids.length == 0"
  69. >
  70. 添加货品
  71. </el-button>
  72. <el-table :data="formData.data.purchaseDetailList">
  73. <el-table-column
  74. prop="goodType"
  75. label="货品类型"
  76. :formatter="(row) => (row.goodType == 1 ? '产品' : '物料')"
  77. />
  78. <el-table-column prop="productCode" label="货品编码" />
  79. <el-table-column prop="productName" label="货品名称" />
  80. <el-table-column prop="productSpec" label="规格型号" />
  81. <el-table-column
  82. prop="productUnit"
  83. label="单位"
  84. :formatter="(row) => dictValueLabel(row.productUnit, productUnit)"
  85. />
  86. <el-table-column
  87. prop="subscribeCount"
  88. label="申购数量"
  89. v-if="ids.length > 0"
  90. />
  91. <el-table-column
  92. prop="purchaseCount"
  93. label="已采购数量"
  94. v-if="ids.length > 0"
  95. />
  96. <el-table-column prop="count" label="本次采购" min-width="150">
  97. <template #default="{ row, $index }">
  98. <el-form-item
  99. :prop="'purchaseDetailList.' + $index + '.count'"
  100. :rules="rules.count"
  101. :inline-message="true"
  102. >
  103. <el-input-number
  104. onmousewheel="return false;"
  105. v-model="row.count"
  106. :precision="2"
  107. :controls="false"
  108. :min="0"
  109. @change="handleChangeAmount"
  110. />
  111. </el-form-item>
  112. </template>
  113. </el-table-column>
  114. <el-table-column prop="price" label="单价" min-width="150">
  115. <template #default="{ row, $index }">
  116. <el-form-item
  117. :prop="'purchaseDetailList.' + $index + '.price'"
  118. :rules="rules.price"
  119. :inline-message="true"
  120. >
  121. <el-input-number
  122. onmousewheel="return false;"
  123. v-model="row.price"
  124. :precision="2"
  125. :controls="false"
  126. :min="0"
  127. @change="handleChangeAmount"
  128. />
  129. </el-form-item>
  130. </template>
  131. </el-table-column>
  132. <el-table-column prop="amount" label="金额" />
  133. <el-table-column prop="zip" label="操作" width="100">
  134. <template #default="{ $index }">
  135. <el-button
  136. type="primary"
  137. link
  138. @click="handleRemove($index, 20)"
  139. :disabled="formData.data.purchaseDetailList.length === 1"
  140. >删除</el-button
  141. >
  142. </template>
  143. </el-table-column>
  144. </el-table>
  145. </el-form-item>
  146. <el-row>
  147. <el-col :span="4">
  148. <el-form-item label="商品金额小计" prop="productAmount">
  149. <el-input
  150. v-model="formData.data.productAmount"
  151. placeholder="请输入"
  152. disabled
  153. />
  154. </el-form-item>
  155. </el-col>
  156. </el-row>
  157. <div class="_t">其他收费项目</div>
  158. <el-form-item>
  159. <el-button type="primary" style="margin: 10px 0" @click="handleAdd">
  160. 添加
  161. </el-button>
  162. <el-table :data="formData.data.otherFeeList">
  163. <el-table-column prop="name" label="收费项目" min-width="150">
  164. <template #default="{ row, $index }">
  165. <el-form-item
  166. :prop="'otherFeeList.' + $index + '.name'"
  167. :rules="rulesOne.name"
  168. :inline-message="true"
  169. >
  170. <el-autocomplete
  171. v-model="row.name"
  172. :fetch-suggestions="querySearchPerson"
  173. clearable
  174. class="inline-input w-50"
  175. placeholder="请输入"
  176. @select="(val) => handlePerson(val, $index)"
  177. >
  178. </el-autocomplete>
  179. </el-form-item>
  180. </template>
  181. </el-table-column>
  182. <el-table-column prop="price" label="金额" min-width="150">
  183. <template #default="{ row, $index }">
  184. <el-form-item
  185. :prop="'otherFeeList.' + $index + '.price'"
  186. :rules="rulesOne.price"
  187. :inline-message="true"
  188. >
  189. <el-input-number
  190. v-model="row.price"
  191. :precision="2"
  192. :controls="false"
  193. @change="handleChangeAmount"
  194. />
  195. </el-form-item>
  196. </template>
  197. </el-table-column>
  198. <el-table-column prop="remark" label="备注" min-width="150">
  199. <template #default="{ row, $index }">
  200. <el-form-item
  201. :prop="'otherFeeList.' + $index + '.remark'"
  202. :inline-message="true"
  203. >
  204. <el-input v-model="row.remark" placeholder="请输入" />
  205. </el-form-item>
  206. </template>
  207. </el-table-column>
  208. <el-table-column prop="zip" label="操作" width="100">
  209. <template #default="{ $index }">
  210. <el-button type="primary" link @click="handleRemove($index, 10)"
  211. >删除</el-button
  212. >
  213. </template>
  214. </el-table-column>
  215. </el-table>
  216. </el-form-item>
  217. <el-row>
  218. <el-col :span="4">
  219. <el-form-item label="其他收费小计" prop="otherAmount">
  220. <el-input
  221. v-model="formData.data.otherAmount"
  222. placeholder="请输入"
  223. disabled
  224. />
  225. </el-form-item>
  226. </el-col>
  227. </el-row>
  228. <!-- <div class="_t">采购总金额</div> -->
  229. <el-row>
  230. <el-col :span="4">
  231. <el-form-item label="采购总金额" prop="amount">
  232. <el-input
  233. v-model="formData.data.amount"
  234. placeholder="请输入"
  235. disabled
  236. />
  237. </el-form-item>
  238. </el-col>
  239. </el-row>
  240. </el-form>
  241. <el-dialog
  242. v-if="openProduct"
  243. v-model="openProduct"
  244. title="选择货品"
  245. width="70%"
  246. append-to-body
  247. >
  248. <SelectGoods
  249. :selectList="acquireSelectList()"
  250. @cancel="openProduct = false"
  251. @pushGoods="pushGoods"
  252. ></SelectGoods>
  253. </el-dialog>
  254. </div>
  255. </template>
  256. <script setup>
  257. import SelectGoods from "@/components/product/SelectGoods";
  258. import { ElMessage, ElMessageBox } from "element-plus";
  259. import useUserStore from "@/store/modules/user";
  260. import { onActivated } from "vue";
  261. const route = useRoute();
  262. const { proxy } = getCurrentInstance();
  263. // 接收父组件的传值
  264. const props = defineProps({
  265. queryData: String,
  266. });
  267. let formData = reactive({
  268. data: {
  269. purchaseTime: "",
  270. purchaseDetailList: [],
  271. otherFeeList: [],
  272. },
  273. });
  274. let rules = ref({
  275. deptName: [{ required: true, message: "请输入采购部门", trigger: "blur" }],
  276. purchaseName: [
  277. { required: true, message: "请输入采购人名称", trigger: "blur" },
  278. ],
  279. purchaseTime: [
  280. { required: true, message: "请选择采购时间", trigger: "change" },
  281. ],
  282. supplyId: [{ required: true, message: "请选择供应商", trigger: "change" }],
  283. count: [{ required: true, message: "请输入本次采购数量", trigger: "blur" }],
  284. price: [{ required: true, message: "请输入单价", trigger: "blur" }],
  285. remark: [{ required: true, message: "请输入备注", trigger: "blur" }],
  286. });
  287. let rulesOne = ref({
  288. name: [{ required: true, message: "请输入名称", trigger: "blur" }],
  289. price: [{ required: true, message: "请输入金额", trigger: "blur" }],
  290. });
  291. let openProduct = ref(false);
  292. // 物品相应逻辑
  293. const handleRemove = (index, type) => {
  294. if (type === 20) {
  295. formData.data.purchaseDetailList.splice(index, 1);
  296. return ElMessage({
  297. message: "删除成功!",
  298. type: "success",
  299. });
  300. } else {
  301. formData.data.otherFeeList.splice(index, 1);
  302. }
  303. handleChangeAmount();
  304. };
  305. const handleAdd = () => {
  306. formData.data.otherFeeList.push({
  307. name: "",
  308. price: undefined,
  309. remark: "",
  310. });
  311. };
  312. const pushGoods = (goods) => {
  313. if (goods && goods.length > 0) {
  314. let afterFiltering = [];
  315. if (
  316. formData.data.purchaseDetailList &&
  317. formData.data.purchaseDetailList.length > 0
  318. ) {
  319. afterFiltering = goods.filter((item) => {
  320. let data = formData.data.purchaseDetailList.filter(
  321. (itemProduct) => itemProduct.bussinessId === item.id
  322. );
  323. if (data && data.length > 0) {
  324. return false;
  325. }
  326. return true;
  327. });
  328. } else {
  329. afterFiltering = goods;
  330. }
  331. const arr = afterFiltering.map((x) => ({
  332. goodType: x.goodType,
  333. productCode: x.code,
  334. productName: x.name,
  335. productSpec: x.spec,
  336. productUnit: x.unit,
  337. count: 0,
  338. price: 0,
  339. bussinessId: x.id,
  340. amount: 0,
  341. }));
  342. formData.data.purchaseDetailList =
  343. formData.data.purchaseDetailList.concat(arr);
  344. openProduct.value = false;
  345. const ids = formData.data.purchaseDetailList.map((x) => x.bussinessId);
  346. if (formData.data.supplyId && ids.length > 0) {
  347. handleChangeSupplier(formData.data.supplyId);
  348. }
  349. return ElMessage({
  350. message: "添加成功!",
  351. type: "success",
  352. });
  353. } else {
  354. ElMessage("请选择至少一件物品");
  355. }
  356. };
  357. // 提交方法
  358. const formDom = ref(null);
  359. const handleSubmit = async () => {
  360. const vaild = await formDom.value.validate();
  361. if (vaild) {
  362. if (formData.data.purchaseDetailList.length > 0) {
  363. const list = formData.data.purchaseDetailList;
  364. for (let i = 0; i < list.length; i++) {
  365. const e = list[i];
  366. if (ids.value.length > 0) {
  367. if (e.count == 0) {
  368. ElMessage({
  369. message: "本次采购数量不能为0!",
  370. type: "info",
  371. });
  372. return false;
  373. }
  374. // if (Number(e.subscribeCount) - Number(e.purchaseCount) > 0) {
  375. // if (e.count == 0) {
  376. // ElMessage({
  377. // message: "本次采购数量不能为0!",
  378. // type: "info",
  379. // });
  380. // return false;
  381. // }
  382. // }
  383. // if (e.count + Number(e.purchaseCount) > Number(e.subscribeCount)) {
  384. // ElMessage({
  385. // message: "本次采购数量和已采购数量和不可大于申购数量!",
  386. // type: "info",
  387. // });
  388. // return false;
  389. // }
  390. } else {
  391. if (e.count == 0) {
  392. ElMessage({
  393. message: "本次采购数量不能为0!",
  394. type: "info",
  395. });
  396. return false;
  397. }
  398. }
  399. }
  400. return true;
  401. }
  402. ElMessage({
  403. message: "请添加采购明细!",
  404. type: "info",
  405. });
  406. return false;
  407. }
  408. return false;
  409. };
  410. const ids = ref([]);
  411. const getDetails = () => {
  412. if (props.queryData.type && props.queryData.type === "handoverSlip") {
  413. proxy.post("/contractProduct/getListDetail", ids.value).then((res) => {
  414. formData.data.purchaseDetailList = res.map((x) => {
  415. let obj = {
  416. ...x,
  417. dataResource: "1", //来源写死外销合同采购
  418. dataResourceId: x.id,
  419. bussinessId: x.productId,
  420. subscribeCount: x.quantity || x.sumPackQuantity || 0,
  421. purchaseCount: x.sumPurchaseCount || 0,
  422. count: x.expendQuantity || 0,
  423. price: null,
  424. amount: null,
  425. };
  426. delete obj.id;
  427. return obj;
  428. });
  429. });
  430. } else {
  431. proxy.post("/subscribeDetail/detail", { ids: ids.value }).then((res) => {
  432. formData.data.purchaseDetailList = res.map((x) => ({
  433. subscribeDetailId: x.id,
  434. bussinessId: x.bussinessId,
  435. goodType: x.productDefinition,
  436. productCode: x.productCode,
  437. productName: x.productName,
  438. productSpec: x.productSpec,
  439. productUnit: x.productUnit,
  440. purchaseCount: x.purchaseCount,
  441. subscribeCount: x.count,
  442. count: 0,
  443. price: null,
  444. amount: null,
  445. }));
  446. });
  447. }
  448. };
  449. // 获取供应商数据
  450. const supplierData = ref([]);
  451. const otherFeeListData = ref([]);
  452. const getSupplierList = async (req) => {
  453. proxy
  454. .post("/supplierInfo/page", { pageNum: 1, pageSize: 9999 })
  455. .then((res) => {
  456. supplierData.value = res.rows;
  457. });
  458. };
  459. const emit = defineEmits(["auxiliaryChange"]);
  460. let auxiliaryData = ref([
  461. {
  462. label: "供应商最近采购",
  463. data: [],
  464. },
  465. {
  466. label: "产品价格",
  467. data: [],
  468. },
  469. ]);
  470. const auxiliaryChange = (data) => {
  471. emit("auxiliaryChange", data);
  472. };
  473. const getAuxiliaryData = (supplyId, productIdList) => {
  474. if (supplyId && productIdList.length > 0) {
  475. proxy
  476. .post("/subscribe/decisionAid", {
  477. supplyId: supplyId,
  478. productIdList: productIdList,
  479. })
  480. .then((res) => {
  481. // 获取数组长度
  482. let dataLength = auxiliaryData.value.length;
  483. // 供应商最近采购
  484. const recentlyArr = [
  485. {
  486. label: "合同编号",
  487. value: "",
  488. fn: () => {},
  489. num: 1,
  490. },
  491. {
  492. label: "下单日期",
  493. value: "",
  494. num: 1,
  495. },
  496. {
  497. label: "合同金额",
  498. value: "",
  499. num: 1,
  500. },
  501. ];
  502. auxiliaryData.value[dataLength - 2].data = res.purchaseList.map(
  503. (x, index) => {
  504. return recentlyArr.map((y, sonIndex) => {
  505. let obj = { ...y };
  506. let value = "";
  507. if (sonIndex === 0) {
  508. value = x.code;
  509. } else if (sonIndex === 1) {
  510. value = x.createTime;
  511. } else {
  512. value = x.currency + " " + proxy.moneyFormat(x.amount, 2);
  513. }
  514. obj.value = value;
  515. return obj;
  516. });
  517. }
  518. );
  519. // 产品价格
  520. const arrConfig = [
  521. {
  522. label: "产品名称",
  523. value: "",
  524. num: 1,
  525. },
  526. {
  527. label: "最近价格",
  528. value: "",
  529. num: 1,
  530. },
  531. {
  532. label: "历史最高",
  533. value: "",
  534. num: 1,
  535. },
  536. {
  537. label: "历史最低",
  538. value: "",
  539. num: 1,
  540. },
  541. ];
  542. auxiliaryData.value[dataLength - 1].data = res.productPriceList.map(
  543. (x, index) => {
  544. return arrConfig.map((y, sonIndex) => {
  545. let obj = { ...y };
  546. let value = "";
  547. if (sonIndex === 0) {
  548. value = x.name;
  549. } else if (sonIndex === 1) {
  550. value = x.lastPrice;
  551. } else if (sonIndex === 2) {
  552. value = x.maxPrice;
  553. } else {
  554. value = x.minPrice;
  555. }
  556. obj.value = value;
  557. return obj;
  558. });
  559. }
  560. );
  561. auxiliaryChange(auxiliaryData.value);
  562. });
  563. } else {
  564. if (props.queryData.type === "handoverSlip" && props.queryData.arr) {
  565. let arrConfig = [
  566. {
  567. label: "合同编号",
  568. value: "",
  569. fn: () => {},
  570. num: 1,
  571. },
  572. {
  573. label: "下单日期",
  574. value: "",
  575. num: 1,
  576. },
  577. ];
  578. auxiliaryData.value[0].data = contractData.value.map((x, index) => {
  579. return arrConfig.map((y, sonIndex) => {
  580. let obj = { ...y };
  581. let value = "";
  582. if (sonIndex === 0) {
  583. value = contractData.value[index].contractCode;
  584. } else if (sonIndex === 1) {
  585. value = contractData.value[index].claimTime;
  586. }
  587. obj.value = value;
  588. return obj;
  589. });
  590. });
  591. auxiliaryChange(auxiliaryData.value);
  592. }
  593. }
  594. };
  595. // 供应商改变逻辑
  596. const handleChangeSupplier = (val) => {
  597. const ids = formData.data.purchaseDetailList.map((x) => x.bussinessId);
  598. if (val && ids.length > 0) {
  599. getAuxiliaryData(val, ids);
  600. proxy
  601. .post("/supplierPrice/getSupplierPriceByProductIds", {
  602. supplierInfoId: val,
  603. productIdList: ids,
  604. })
  605. .then((res) => {
  606. if (res && Object.keys(res).length > 0) {
  607. for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
  608. const e = formData.data.purchaseDetailList[i];
  609. for (const key in res) {
  610. if (e.bussinessId === key) {
  611. e.price = Number(res[key]);
  612. }
  613. }
  614. }
  615. } else {
  616. for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
  617. const e = formData.data.purchaseDetailList[i];
  618. e.price = 0;
  619. }
  620. }
  621. handleChangeAmount();
  622. });
  623. }
  624. };
  625. const handleChangeProductAmount = () => {
  626. let sum = 0;
  627. for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
  628. const e = formData.data.purchaseDetailList[i];
  629. e.amount = parseFloat(e.count * e.price).toFixed(2);
  630. sum += Number(e.amount);
  631. }
  632. formData.data.productAmount = parseFloat(sum).toFixed(2);
  633. };
  634. const handleChangeOtherAmount = () => {
  635. let sum = 0;
  636. for (let i = 0; i < formData.data.otherFeeList.length; i++) {
  637. const e = formData.data.otherFeeList[i];
  638. sum += Number(e.price);
  639. }
  640. formData.data.otherAmount = parseFloat(sum).toFixed(2);
  641. };
  642. // 计算采购总金额
  643. const handleChangeAmount = () => {
  644. handleChangeProductAmount();
  645. handleChangeOtherAmount();
  646. let sum = 0;
  647. for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
  648. const e = formData.data.purchaseDetailList[i];
  649. e.amount = parseFloat(e.count * e.price).toFixed(2);
  650. sum += Number(e.amount);
  651. }
  652. for (let i = 0; i < formData.data.otherFeeList.length; i++) {
  653. const e = formData.data.otherFeeList[i];
  654. sum += Number(e.price);
  655. }
  656. formData.data.amount = parseFloat(sum).toFixed(2);
  657. };
  658. const productUnit = ref([]);
  659. const getDict = () => {
  660. proxy.getDictOne(["unit"]).then((res) => {
  661. productUnit.value = res["unit"].map((x) => ({
  662. label: x.dictValue,
  663. value: x.dictKey,
  664. }));
  665. });
  666. proxy.get("/purchaseOtherFee/listName").then((res) => {
  667. otherFeeListData.value = res.data.map((x) => ({ ...x, value: x.name }));
  668. });
  669. };
  670. getDict();
  671. const createFilter = (queryString) => {
  672. return (restaurant) => {
  673. return (
  674. restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
  675. );
  676. };
  677. };
  678. const querySearchPerson = (queryString, callback) => {
  679. const results = queryString
  680. ? otherFeeListData.value.filter(createFilter(queryString))
  681. : otherFeeListData.value;
  682. callback(results);
  683. };
  684. const handlePerson = (item, index) => {
  685. formData.data.otherFeeList[index].name = item.name;
  686. formData.data.otherFeeList[index].price = item.price ? item.price : 0;
  687. formData.data.otherFeeList[index].remark = item.remark ? item.remark : "";
  688. };
  689. watch(
  690. props.queryData,
  691. () => {
  692. if (
  693. props.queryData &&
  694. (route.query.processType == 10 ||
  695. route.query.processType == 20 ||
  696. route.query.processType == 30)
  697. ) {
  698. for (const key in props.queryData) {
  699. formData.data[key] = props.queryData[key];
  700. }
  701. const ids = formData.data.purchaseDetailList.map((x) => x.bussinessId);
  702. if (formData.data.supplyId && ids.length > 0) {
  703. getAuxiliaryData(formData.data.supplyId, ids);
  704. }
  705. }
  706. },
  707. {
  708. deep: true,
  709. }
  710. );
  711. const judgeStatus = () => {
  712. if (route.query.processType == 20 || route.query.processType == 10) {
  713. return true;
  714. }
  715. if (props.queryData.recordList && props.queryData.recordList.length > 0) {
  716. let data = props.queryData.recordList.filter(
  717. (item) => item.status === 2 && item.nodeType !== 1
  718. );
  719. if (data && data.length > 0) {
  720. return true;
  721. }
  722. }
  723. return false;
  724. };
  725. // 获取用户信息并赋默认值
  726. const userInfo = useUserStore().user;
  727. const contractData = ref([]);
  728. onMounted(() => {
  729. formData.data.purchaseTime = proxy.parseTime(new Date());
  730. formData.data.deptName = userInfo.dept.deptName;
  731. formData.data.purchaseName = userInfo.nickName;
  732. getSupplierList();
  733. if (props.queryData.ids) {
  734. ids.value = props.queryData.ids.split(",") || [];
  735. getDetails();
  736. }
  737. if (props.queryData.type === "handoverSlip" && props.queryData.arr) {
  738. formData.data.dataResourceId = JSON.parse(
  739. props.queryData.arr
  740. )[0].contractId;
  741. formData.data.dataResource = "1"; //外销合同采购
  742. contractData.value = JSON.parse(props.queryData.arr);
  743. auxiliaryData.value.unshift({
  744. label: "关联销售合同",
  745. data: [],
  746. });
  747. getAuxiliaryData();
  748. }
  749. });
  750. const getFormData = () => {
  751. return formData.data;
  752. };
  753. // 向父组件暴露
  754. defineExpose({
  755. getFormData,
  756. handleSubmit,
  757. });
  758. const acquireSelectList = () => {
  759. let data = [];
  760. if (
  761. formData.data.purchaseDetailList &&
  762. formData.data.purchaseDetailList.length > 0
  763. ) {
  764. data = formData.data.purchaseDetailList.map((item) => {
  765. return {
  766. id: item.bussinessId,
  767. name: item.productName,
  768. };
  769. });
  770. }
  771. return data;
  772. };
  773. </script>
  774. <style lang="scss" scoped>
  775. ._t {
  776. margin-bottom: 5px;
  777. font-size: 14px;
  778. }
  779. </style>