WdlyPurchase.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <template>
  2. <div class="form">
  3. <van-tabs v-model:active="active">
  4. <van-tab title="采购信息" />
  5. <van-tab title="采购明细" />
  6. <van-tab title="其他费用" />
  7. <div class="common-process-card" v-show="active == 0">
  8. <testForm
  9. v-model="formData.data"
  10. :formOption="formOption"
  11. :formConfig="formConfig"
  12. :rules="rules"
  13. ref="formDom1"
  14. >
  15. </testForm>
  16. </div>
  17. <div class="common-process-card" v-show="active == 1">
  18. <testForm
  19. v-model="formData.data"
  20. :formOption="formOptionOne"
  21. :formConfig="formConfigOne"
  22. :rules="rules"
  23. ref="formDom2"
  24. >
  25. </testForm>
  26. </div>
  27. <div class="common-process-card" v-show="active == 2">
  28. <testForm
  29. v-model="formData.data"
  30. :formOption="formOptionTwo"
  31. :formConfig="formConfigTwo"
  32. :rules="rules"
  33. ref="formDom3"
  34. >
  35. </testForm>
  36. </div>
  37. </van-tabs>
  38. </div>
  39. </template>
  40. <script setup>
  41. import {
  42. ref,
  43. getCurrentInstance,
  44. onMounted,
  45. defineProps,
  46. defineExpose,
  47. watch,
  48. reactive,
  49. toRefs,
  50. } from "vue";
  51. import { useRoute } from "vue-router";
  52. import testForm from "@/components/testForm/index.vue";
  53. import { getUserInfo } from "@/utils/auth";
  54. import { showFailToast } from "vant";
  55. // 接收父组件的传值
  56. const props = defineProps({
  57. queryData: Object,
  58. });
  59. const refProps = toRefs(props);
  60. const proxy = getCurrentInstance().proxy;
  61. const route = useRoute();
  62. const active = ref(0);
  63. const tabsChange = () => {
  64. active.value++;
  65. };
  66. const formData = reactive({
  67. data: {
  68. purchaseDetailList: [],
  69. },
  70. });
  71. const formDom1 = ref(null);
  72. const formDom2 = ref(null);
  73. const formDom3 = ref(null);
  74. const formOption = reactive({
  75. readonly: false,
  76. disabled: false,
  77. labelAlign: "top",
  78. scroll: true,
  79. labelWidth: "62pk",
  80. hiddenSubmitBtn: true,
  81. });
  82. const formOptionOne = reactive({
  83. readonly: false,
  84. disabled: false,
  85. labelAlign: "top",
  86. scroll: true,
  87. labelWidth: "62pk",
  88. hiddenSubmitBtn: true,
  89. btnConfig: {
  90. isNeed: false,
  91. prop: "purchaseDetailList",
  92. plain: true,
  93. listTitle: "采购明细",
  94. listConfig: [
  95. {
  96. type: "input",
  97. label: "物品编码",
  98. prop: "productCustomCode",
  99. itemType: "text",
  100. readonly: true,
  101. },
  102. {
  103. type: "input",
  104. label: "物品名称",
  105. prop: "productName",
  106. itemType: "text",
  107. readonly: true,
  108. },
  109. {
  110. type: "picker",
  111. label: "单位",
  112. prop: "productUnit",
  113. itemType: "onePicker",
  114. showPicker: false,
  115. fieldNames: {
  116. text: "label",
  117. value: "value",
  118. },
  119. data: [],
  120. },
  121. {
  122. type: "input",
  123. label: "申购数量",
  124. prop: "subscribeCount",
  125. itemType: "text",
  126. readonly: true,
  127. },
  128. {
  129. type: "input",
  130. label: "已采购数量",
  131. prop: "purchaseCount",
  132. itemType: "text",
  133. readonly: true,
  134. },
  135. {
  136. type: "input",
  137. label: "本次采购",
  138. prop: "count",
  139. itemType: "text",
  140. readonly: true,
  141. },
  142. {
  143. type: "input",
  144. label: "单价",
  145. prop: "price",
  146. itemType: "text",
  147. readonly: true,
  148. },
  149. {
  150. type: "input",
  151. label: "金额",
  152. prop: "amount",
  153. itemType: "text",
  154. readonly: true,
  155. },
  156. ],
  157. clickFn: () => {},
  158. deleteFn: (index) => {},
  159. },
  160. });
  161. const formOptionTwo = reactive({
  162. readonly: false,
  163. disabled: false,
  164. labelAlign: "top",
  165. scroll: true,
  166. labelWidth: "62pk",
  167. hiddenSubmitBtn: true,
  168. btnConfig: {
  169. isNeed: false,
  170. prop: "otherFeeList",
  171. plain: true,
  172. listTitle: "采购明细",
  173. listConfig: [
  174. {
  175. type: "input",
  176. label: "费用名称",
  177. prop: "name",
  178. itemType: "text",
  179. readonly: true,
  180. },
  181. {
  182. type: "input",
  183. label: "金额",
  184. prop: "price",
  185. itemType: "text",
  186. readonly: true,
  187. },
  188. {
  189. type: "input",
  190. label: "备注",
  191. prop: "remark",
  192. itemType: "textarea",
  193. readonly: true,
  194. },
  195. ],
  196. clickFn: () => {},
  197. deleteFn: (index) => {},
  198. },
  199. });
  200. const formConfig = reactive([
  201. {
  202. type: "title",
  203. title: "基本信息",
  204. },
  205. {
  206. type: "input",
  207. label: "采购部门",
  208. prop: "deptName",
  209. itemType: "text",
  210. readonly: true,
  211. },
  212. {
  213. type: "input",
  214. label: "采购人",
  215. prop: "purchaseName",
  216. itemType: "text",
  217. readonly: true,
  218. },
  219. {
  220. type: "picker",
  221. label: "采购时间",
  222. prop: "purchaseTime",
  223. itemType: "datePickerTime",
  224. readonly: true,
  225. },
  226. {
  227. type: "title",
  228. title: "合同信息",
  229. },
  230. {
  231. type: "picker",
  232. label: "供应商",
  233. prop: "supplyId",
  234. itemType: "onePicker",
  235. showPicker: false,
  236. fieldNames: {
  237. text: "name",
  238. value: "id",
  239. },
  240. data: [],
  241. },
  242. {
  243. type: "picker",
  244. label: "是否合同",
  245. prop: "isAgreement",
  246. itemType: "onePicker",
  247. showPicker: false,
  248. fieldNames: {
  249. text: "label",
  250. value: "value",
  251. },
  252. data: [
  253. {
  254. label: "是",
  255. value: "1",
  256. },
  257. {
  258. label: "否",
  259. value: "0",
  260. },
  261. ],
  262. },
  263. {
  264. type: "picker",
  265. label: "付款方式",
  266. prop: "paymentMethod",
  267. itemType: "onePicker",
  268. showPicker: false,
  269. fieldNames: {
  270. text: "label",
  271. value: "value",
  272. },
  273. data: [],
  274. },
  275. {
  276. type: "input",
  277. label: "采购单号",
  278. prop: "contractCode",
  279. itemType: "text",
  280. readonly: true,
  281. },
  282. {
  283. type: "input",
  284. label: "采购总金额",
  285. prop: "amount",
  286. itemType: "text",
  287. readonly: true,
  288. },
  289. {
  290. type: "title",
  291. title: "其他信息",
  292. },
  293. {
  294. type: "input",
  295. label: "采购说明",
  296. prop: "purchaseContent",
  297. itemType: "textarea",
  298. readonly: true,
  299. },
  300. ]);
  301. const formConfigOne = reactive([
  302. {
  303. type: "input",
  304. label: "明细金额小计",
  305. prop: "productAmount",
  306. itemType: "text",
  307. readonly: true,
  308. },
  309. ]);
  310. const formConfigTwo = reactive([
  311. {
  312. type: "input",
  313. label: "运费",
  314. prop: "freight",
  315. itemType: "text",
  316. readonly: true,
  317. },
  318. {
  319. type: "input",
  320. label: "优惠",
  321. prop: "preferential",
  322. itemType: "text",
  323. readonly: true,
  324. },
  325. {
  326. type: "input",
  327. label: "其他费用小计",
  328. prop: "otherAmount",
  329. itemType: "text",
  330. readonly: true,
  331. },
  332. ]);
  333. const rules = {
  334. contractType: [
  335. { required: true, message: proxy.t("contract.contractTypeMsg") },
  336. ],
  337. contractTemplateId: [
  338. { required: true, message: proxy.t("contract.contractTemplateIdMsg") },
  339. ],
  340. sellCorporationId: [
  341. { required: true, message: proxy.t("contract.sellCorporationIdMsg") },
  342. ],
  343. buyCorporationId: [
  344. { required: true, message: proxy.t("contract.buyCorporationIdMsg") },
  345. ],
  346. sellCity: [{ required: true, message: proxy.t("contract.cityMsg") }],
  347. countryCity: [{ required: true, message: proxy.t("contract.cityMsg") }],
  348. sellAddress: [{ required: true, message: proxy.t("contract.addressMsg") }],
  349. buyAddress: [{ required: true, message: proxy.t("contract.addressMsg") }],
  350. sellContactName: [
  351. { required: true, message: proxy.t("contract.contactNameMsg") },
  352. ],
  353. };
  354. const productUnit = ref([]);
  355. const fundsPaymentMethod = ref([]);
  356. const supplierData = ref([]);
  357. const getDict = () => {
  358. let query = {
  359. pageNum: 1,
  360. pageSize: 999,
  361. tenantId: getUserInfo().tenantId,
  362. };
  363. proxy
  364. .post("/supplierInfo/page", { pageNum: 1, pageSize: 9999 })
  365. .then((res) => {
  366. supplierData.value = res.data.rows;
  367. formConfig[5].data = supplierData.value;
  368. });
  369. proxy
  370. .post("/dictTenantData/page", {
  371. ...query,
  372. dictCode: "unit",
  373. })
  374. .then((res) => {
  375. if (res.data.rows && res.data.rows.length > 0) {
  376. productUnit.value = res.data.rows.map((item) => {
  377. return {
  378. label: item.dictValue,
  379. value: item.dictKey,
  380. };
  381. });
  382. formOptionOne.btnConfig.listConfig[2].data = productUnit.value;
  383. }
  384. });
  385. proxy
  386. .post("/dictTenantData/page", {
  387. ...query,
  388. dictCode: "funds_payment_method",
  389. })
  390. .then((res) => {
  391. if (res.data.rows && res.data.rows.length > 0) {
  392. fundsPaymentMethod.value = res.data.rows.map((item) => {
  393. return {
  394. label: item.dictValue,
  395. value: item.dictKey,
  396. };
  397. });
  398. formConfig[7].data = fundsPaymentMethod.value;
  399. }
  400. });
  401. };
  402. getDict();
  403. const handleSubmit = async () => {
  404. const flag = true;
  405. if (flag) {
  406. return formData.data;
  407. }
  408. };
  409. let status = ref(true);
  410. defineExpose({
  411. handleSubmit,
  412. tabsChange,
  413. });
  414. onMounted(() => {
  415. let val = route.query.businessId;
  416. proxy
  417. .post("/purchase/detail", {
  418. id: val,
  419. })
  420. .then((res) => {
  421. let jsonData = {};
  422. if (res.data.victoriatouristJson) {
  423. jsonData = JSON.parse(res.data.victoriatouristJson);
  424. }
  425. for (const key in res.data) {
  426. formData.data[key] = res.data[key];
  427. }
  428. for (const key in jsonData) {
  429. formData.data[key] = jsonData[key];
  430. }
  431. // formData.data = { ...res.data, ...jsonData };
  432. formData.data.purchaseDetailList = formData.data.purchaseDetailList.map(
  433. (x) => ({
  434. ...x,
  435. subscribeCount: x.subscribeQuantity,
  436. purchaseCount: x.purchaseQuantity,
  437. })
  438. );
  439. formData.data.productAmount = formData.data.purchaseDetailList.reduce(
  440. (val, x) => (val += x.price * x.count),
  441. 0
  442. );
  443. formData.data.productAmount = formData.data.productAmount.toFixed(2);
  444. formData.data.otherAmount = formData.data.otherFeeList.reduce(
  445. (val, x) => (val += Number(x.price)),
  446. 0
  447. );
  448. formData.data.otherAmount = formData.data.otherAmount.toFixed(2);
  449. console.log(formDom1.value.formDataShowLabelOne, "qwdq");
  450. formDom1.value.formDataShowLabelOne();
  451. formDom2.value.formDataListShowLabelOne();
  452. });
  453. // proxy.post("/fileInfo/getList", { businessIdList: [val] }).then((fileObj) => {
  454. // formData.data.fileList = fileObj[val] || [];
  455. // if (formData.data.fileList && formData.data.fileList.length > 0) {
  456. // fileList.value = formData.data.fileList.map((item) => {
  457. // return {
  458. // raw: item,
  459. // name: item.fileName,
  460. // url: item.fileUrl,
  461. // };
  462. // });
  463. // }
  464. // });
  465. });
  466. </script>
  467. <style lang="scss" scoped></style>