index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. <template>
  2. <div class="pageIndexClass">
  3. <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" :selectConfig="selectConfig"
  4. :row-class-name="getRowClass" highlight-current-row @get-list="getList">
  5. <template #code="{ item }">
  6. <div v-if="Number(item.sumPayMoney) > Number(item.amount)" style="cursor: pointer; color: #f54a45" @click="handleClickCode(item)">
  7. {{ item.code }}
  8. </div>
  9. <div v-else style="cursor: pointer; color: #409eff" @click="handleClickCode(item)">
  10. {{ item.code }}
  11. </div>
  12. </template>
  13. <template #amount="{ item }">
  14. <div>
  15. <span style="padding-right: 4px">{{ item.currency }}</span>
  16. <span>{{ moneyFormat(item.amount, 2) }}</span>
  17. </div>
  18. </template>
  19. <template #sumPayMoney="{ item }">
  20. <div>
  21. <span style="padding-right: 4px">{{ item.currency }}</span>
  22. <span>{{ moneyFormat(item.sumPayMoney, 2) }}</span>
  23. </div>
  24. </template>
  25. <template #payStatus="{ item }">
  26. <div style="width:100%">
  27. <span :class="{'tag-active':item.payStatus==20,'tag-active-1':item.payStatus==10}">{{dictValueLabel(item.payStatus, payStatus)}}</span>
  28. </div>
  29. </template>
  30. </byTable>
  31. <el-dialog title="打印" v-if="openPdf" v-model="openPdf" width="920px">
  32. <PurchasePDF :rowData="rowData"></PurchasePDF>
  33. <!-- <PurchasePDFOne :rowData="rowData"></PurchasePDFOne> -->
  34. <!-- <PurchasePDFOneNew :rowData="rowData" ref="PdfDom"></PurchasePDFOneNew> -->
  35. <!-- <template #footer ref="printBtn">
  36. <el-button @click="openPdf = false" size="default">关闭</el-button>
  37. <el-button type="primary" v-print="printObj" size="default">打印</el-button>
  38. <el-button type="primary" @click="clickDownload()" size="default">下载PDF</el-button>
  39. <el-button type="primary" @click="exportExcel()" size="default">导出Excel</el-button>
  40. </template> -->
  41. </el-dialog>
  42. <el-dialog title="到货登记" v-model="arrivalDialog" width="70%" destroy-on-close>
  43. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="formDom" v-loading="submitLoading">
  44. <template #details>
  45. <div style="width:100%;padding:0 15px">
  46. <el-table :data="formData.data.purchaseProductList">
  47. <el-table-column label="商品图片" width="80">
  48. <template #default="{ row }">
  49. <div v-if="row.fileUrl">
  50. <img :src="row.fileUrl" class="pic" @click="openImg(row.fileUrl)" />
  51. </div>
  52. </template>
  53. </el-table-column>
  54. <el-table-column prop="productCode" label="商品编码" width="160" />
  55. <el-table-column prop="productName" label="商品名称" min-width="130" />
  56. <el-table-column label="尺寸 (cm)" width="140">
  57. <template #default="{ row, $index }">
  58. <div style="width: 100%">
  59. {{row.productLength}} * {{row.productWidth}} * {{row.productHeight}}
  60. </div>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="采购数量" prop="quantity" width="100" />
  64. <el-table-column label="已到货数量" prop="quantity" width="100" />
  65. <el-table-column prop="contractMoney" label="到货数量" width="130">
  66. <template #default="{ row, $index }">
  67. <el-form-item :prop="'purchaseProductList.' + $index + '.contractMoney'" :rules="rules.contractMoney" :inline-message="true"
  68. class="margin-b-0">
  69. <el-input-number onmousewheel="return false;" v-model="row.contractMoney" placeholder="请输入" style="width: 100%" :precision="0"
  70. :controls="false" :min="0" />
  71. </el-form-item>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. </div>
  76. </template>
  77. </byForm>
  78. <template #footer>
  79. <el-button @click="arrivalDialog = false" size="defualt" v-debounce>取 消</el-button>
  80. <el-button type="primary" @click="submitForm()" size="defualt" v-debounce>
  81. 确 定
  82. </el-button>
  83. </template>
  84. </el-dialog>
  85. </div>
  86. </template>
  87. <script setup>
  88. import { computed, ref } from "vue";
  89. import byTable from "@/components/byTable/index";
  90. import byForm from "@/components/byForm/index";
  91. import { ElMessage, ElMessageBox } from "element-plus";
  92. import PurchasePDF from "@/components/PDF/purchasePDF.vue";
  93. // import PurchasePDFOne from "@/components/PDF/purchasePDFOne.vue";
  94. // import PurchasePDFOneNew from "@/components/PDF/purchasePDFOneNew.vue";
  95. const route = useRoute();
  96. const { proxy } = getCurrentInstance();
  97. const supplierList = ref([]);
  98. const status = ref([
  99. {
  100. label: "草稿",
  101. value: 0,
  102. },
  103. {
  104. label: "审批中",
  105. value: 10,
  106. },
  107. {
  108. label: "驳回",
  109. value: 20,
  110. },
  111. {
  112. label: "已采购",
  113. value: 30,
  114. },
  115. {
  116. label: "变更中",
  117. value: 60,
  118. },
  119. {
  120. label: "已变更",
  121. value: 70,
  122. },
  123. {
  124. label: "作废",
  125. value: 88,
  126. },
  127. {
  128. label: "终止",
  129. value: 99,
  130. },
  131. ]);
  132. const payStatus = ref([
  133. {
  134. label: "未付款",
  135. value: 0,
  136. },
  137. {
  138. label: "部分付款",
  139. value: 10,
  140. },
  141. {
  142. label: "已付款",
  143. value: 20,
  144. },
  145. ]);
  146. const sourceList = ref({
  147. data: [],
  148. pagination: {
  149. total: 0,
  150. pageNum: 1,
  151. pageSize: 10,
  152. keyword: "",
  153. status: "",
  154. payStatus: "",
  155. },
  156. });
  157. const loading = ref(false);
  158. const companyData = ref([]);
  159. const selectConfig = computed(() => {
  160. return [
  161. {
  162. label: "归属公司",
  163. prop: "companyId",
  164. data: companyData.value,
  165. },
  166. {
  167. label: "采购状态",
  168. prop: "status",
  169. data: status.value,
  170. },
  171. {
  172. label: "付款状态",
  173. prop: "payStatus",
  174. data: payStatus.value,
  175. },
  176. ];
  177. });
  178. const config = computed(() => {
  179. return [
  180. {
  181. attrs: {
  182. label: "归属公司",
  183. prop: "companyName",
  184. width: 130,
  185. },
  186. },
  187. {
  188. attrs: {
  189. label: "采购单号",
  190. slot: "code",
  191. width: 180,
  192. },
  193. },
  194. {
  195. attrs: {
  196. label: "供应商",
  197. prop: "sellCorporationId",
  198. "min-width": 220,
  199. },
  200. render(type) {
  201. return proxy.dictValueLabel(type, supplierList.value);
  202. },
  203. },
  204. {
  205. attrs: {
  206. label: "采购金额",
  207. slot: "amount",
  208. width: 140,
  209. },
  210. },
  211. {
  212. attrs: {
  213. label: "已付款金额",
  214. slot: "sumPayMoney",
  215. width: 140,
  216. },
  217. },
  218. {
  219. attrs: {
  220. label: "采购人",
  221. prop: "userName",
  222. width: 140,
  223. },
  224. },
  225. {
  226. attrs: {
  227. label: "采购时间",
  228. prop: "createTime",
  229. width: 160,
  230. },
  231. },
  232. {
  233. attrs: {
  234. label: "采购状态",
  235. prop: "status",
  236. width: 140,
  237. },
  238. render(type) {
  239. return proxy.dictValueLabel(type, status.value);
  240. },
  241. },
  242. {
  243. attrs: {
  244. label: "付款状态",
  245. prop: "payStatus",
  246. slot: "payStatus",
  247. width: 140,
  248. },
  249. // render(type) {
  250. // return proxy.dictValueLabel(type, payStatus.value);
  251. // },
  252. },
  253. {
  254. attrs: {
  255. label: "操作",
  256. width: 200,
  257. align: "right",
  258. fixed: "right",
  259. },
  260. renderHTML(row) {
  261. return proxy.isCurrentCompanyData(row.companyId)
  262. ? [
  263. row.status == 30
  264. ? {
  265. attrs: {
  266. label: "变更",
  267. type: "primary",
  268. text: true,
  269. },
  270. el: "button",
  271. click() {
  272. handleChange(row);
  273. },
  274. }
  275. : {},
  276. row.status == 30
  277. ? {
  278. attrs: {
  279. label: "到货登记",
  280. type: "primary",
  281. text: true,
  282. },
  283. el: "button",
  284. click() {
  285. handleArrival(row);
  286. },
  287. }
  288. : {},
  289. {
  290. attrs: {
  291. label: "打印",
  292. type: "primary",
  293. text: true,
  294. },
  295. el: "button",
  296. click() {
  297. handlePrintPdf(row);
  298. },
  299. },
  300. // && Number(row.amount) > Number(row.sumPayMoney)
  301. row.status == 10 ||
  302. (row.status == 30 && Number(row.sumPayMoney) == 0)
  303. ? {
  304. attrs: {
  305. label: "作废",
  306. type: "danger",
  307. text: true,
  308. },
  309. el: "button",
  310. click() {
  311. ElMessageBox.confirm(
  312. "此操作将作废该数据, 是否继续?",
  313. "提示",
  314. {
  315. confirmButtonText: "确定",
  316. cancelButtonText: "取消",
  317. type: "warning",
  318. }
  319. ).then(() => {
  320. proxy
  321. .post("/ehsdPurchase/cancellation", {
  322. id: row.id,
  323. status: 88,
  324. })
  325. .then(() => {
  326. ElMessage({
  327. message: "作废成功",
  328. type: "success",
  329. });
  330. getList();
  331. });
  332. });
  333. },
  334. }
  335. : {},
  336. row.status == 30 && Number(row.amount) > Number(row.sumPayMoney)
  337. ? {
  338. attrs: {
  339. label: "终止",
  340. type: "primary",
  341. text: true,
  342. },
  343. el: "button",
  344. click() {
  345. ElMessageBox.confirm(
  346. "此操作将终止该数据, 是否继续?",
  347. "提示",
  348. {
  349. confirmButtonText: "确定",
  350. cancelButtonText: "取消",
  351. type: "warning",
  352. }
  353. ).then(() => {
  354. proxy
  355. .post("/ehsdPurchase/edit", {
  356. id: row.id,
  357. status: 99,
  358. })
  359. .then(() => {
  360. ElMessage({
  361. message: "终止",
  362. type: "success",
  363. });
  364. getList();
  365. });
  366. });
  367. },
  368. }
  369. : {},
  370. ]
  371. : [];
  372. },
  373. },
  374. ];
  375. });
  376. const getDict = () => {
  377. proxy
  378. .post("/supplierInfo/page", { pageNum: 1, pageSize: 999 })
  379. .then((res) => {
  380. supplierList.value = res.rows.map((item) => {
  381. return {
  382. ...item,
  383. label: item.name,
  384. value: item.id,
  385. };
  386. });
  387. });
  388. proxy
  389. .get("/tenantDept/list", {
  390. pageNum: 1,
  391. pageSize: 9999,
  392. keyword: "",
  393. tenantId: proxy.useUserStore().user.tenantId,
  394. type: 0,
  395. })
  396. .then((res) => {
  397. companyData.value = res.data.map((x) => ({
  398. ...x,
  399. label: x.deptName,
  400. value: x.deptId,
  401. }));
  402. // treeData.value = proxy.handleTree(res.data, "deptId");
  403. });
  404. };
  405. const getList = async (req) => {
  406. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  407. loading.value = true;
  408. proxy.post("/ehsdPurchase/page", sourceList.value.pagination).then((res) => {
  409. console.log(res);
  410. sourceList.value.data = res.rows;
  411. sourceList.value.pagination.total = res.total;
  412. setTimeout(() => {
  413. loading.value = false;
  414. }, 200);
  415. });
  416. };
  417. getDict();
  418. if (route.query.code) {
  419. sourceList.value.pagination.keyword = route.query.code;
  420. }
  421. getList();
  422. const openPdf = ref(false);
  423. const pdfData = ref({});
  424. const rowData = ref({});
  425. const handlePrintPdf = (row) => {
  426. rowData.value = {
  427. id: row.id,
  428. code: row.code,
  429. };
  430. rowData.value = row;
  431. openPdf.value = true;
  432. };
  433. const clickDownload = () => {
  434. proxy.getPdf("购销合同" + rowData.value.code);
  435. };
  436. const pdfDom = ref(null);
  437. const printObj = ref({
  438. id: "pdfDom",
  439. popTitle: "",
  440. extraCss:
  441. "https://cdn.bootcdn.net/ajax/libs/animate.css/4.1.1/animate.compat.css, https://cdn.bootcdn.net/ajax/libs/hover.css/2.3.1/css/hover-min.css",
  442. extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
  443. });
  444. const handleClickCode = (row) => {
  445. // let submitType = row.dataResource > 0 ? "10" : "20";
  446. proxy.$router.push({
  447. path: "/platform_manage/process/processApproval",
  448. query: {
  449. flowKey: "purchase_flow",
  450. id: row.flowId,
  451. processType: 20,
  452. businessId: row.id,
  453. // submitType,
  454. },
  455. });
  456. };
  457. const getRowClass = ({ row }) => {
  458. if (Number(row.sumPayMoney) > Number(row.amount)) {
  459. return "redClass";
  460. }
  461. return "";
  462. };
  463. const handleChange = (row) => {
  464. let submitType = row.dataResource > 0 ? "10" : "20";
  465. let type = "";
  466. if (row.dataResource == 1) {
  467. type = 1;
  468. } else if (row.dataResource == 2) {
  469. type = 2;
  470. }
  471. proxy.$router.push({
  472. path: "/platform_manage/process/processApproval",
  473. query: {
  474. flowKey: "purchase_update_flow",
  475. flowName: "采购合同变更",
  476. random: proxy.random(),
  477. businessId: row.id,
  478. submitType,
  479. type,
  480. },
  481. });
  482. };
  483. const formData = reactive({
  484. data: {},
  485. });
  486. const formOption = reactive({
  487. inline: true,
  488. labelWidth: 110,
  489. itemWidth: 100,
  490. rules: [],
  491. });
  492. const formConfig = computed(() => {
  493. return [
  494. {
  495. type: "title1",
  496. title: "基本信息",
  497. },
  498. {
  499. type: "input",
  500. prop: "code",
  501. label: "采购单号",
  502. itemWidth: 50,
  503. disabled: true,
  504. },
  505. {
  506. type: "input",
  507. prop: "sellCorporationName",
  508. label: "供应商",
  509. itemWidth: 50,
  510. disabled: true,
  511. },
  512. {
  513. type: "date",
  514. prop: "aa",
  515. label: "到货日期",
  516. itemType: "date",
  517. itemWidth: 50,
  518. },
  519. {
  520. type: "title1",
  521. title: "到货明细",
  522. },
  523. {
  524. type: "slot",
  525. slotName: "details",
  526. label: "",
  527. },
  528. ];
  529. });
  530. const rules = ref({
  531. productSn: [{ required: true, message: "请输入商品Sn", trigger: "blur" }],
  532. type: [{ required: true, message: "请选择售后类型", trigger: "change" }],
  533. remark: [{ required: true, message: "请输入售后说明", trigger: "blur" }],
  534. contactName: [
  535. { required: true, message: "请输入客户联系人", trigger: "blur" },
  536. ],
  537. contactInfo: [
  538. { required: true, message: "请输入客户联系方式", trigger: "blur" },
  539. ],
  540. afterSalesPersonId: [
  541. { required: true, message: "请选择售后人员", trigger: "change" },
  542. ],
  543. quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
  544. });
  545. const formDom = ref(null);
  546. const arrivalDialog = ref(false);
  547. const handleArrival = (row) => {
  548. proxy.post("/ehsdPurchase/detail", { id: row.id }).then((res) => {
  549. formData.data = res;
  550. if (
  551. formData.data.purchaseProductList &&
  552. formData.data.purchaseProductList.length > 0
  553. ) {
  554. let productIds = formData.data.purchaseProductList.map(
  555. (x) => x.productId
  556. );
  557. proxy.getFileData({
  558. businessIdList: productIds,
  559. data: formData.data.purchaseProductList,
  560. att: "productId",
  561. businessType: "0",
  562. fileAtt: "fileList",
  563. filePathAtt: "fileUrl",
  564. });
  565. }
  566. });
  567. arrivalDialog.value = true;
  568. };
  569. const submitForm = () => {
  570. formDom.value.handleSubmit(() => {
  571. submitLoading.value = true;
  572. proxy.post("/afterSalesRecord/add", formData.data).then(
  573. (res) => {
  574. ElMessage({
  575. message: "操作成功",
  576. type: "success",
  577. });
  578. dialogVisible.value = false;
  579. submitLoading.value = false;
  580. getList();
  581. },
  582. (err) => {
  583. submitLoading.value = false;
  584. }
  585. );
  586. });
  587. };
  588. const PdfDom = ref(null);
  589. const exportExcel = () => {
  590. PdfDom.value.exportExcel();
  591. };
  592. </script>
  593. <style lang="scss" scoped>
  594. .tenant {
  595. padding: 20px;
  596. }
  597. ::v-deep(.el-input-number .el-input__inner) {
  598. text-align: left;
  599. }
  600. .baseRow {
  601. min-height: 24px;
  602. border-top: 1px solid black;
  603. border-left: 1px solid black;
  604. }
  605. .contentRow {
  606. border-right: 1px solid black;
  607. line-height: 24px;
  608. padding-left: 4px;
  609. }
  610. </style>
  611. <style>
  612. .redClass {
  613. color: #f54a45 !important;
  614. }
  615. </style>