index.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950
  1. <template>
  2. <div class="tenant">
  3. <!-- <Banner /> -->
  4. <div class="content">
  5. <byTable
  6. :source="sourceList.data"
  7. :pagination="sourceList.pagination"
  8. :config="config"
  9. :loading="loading"
  10. highlight-current-row
  11. :statConfig="statConfig"
  12. :selectConfig="selectConfig"
  13. :table-events="{
  14. //element talbe事件都能传
  15. }"
  16. :action-list="[
  17. {
  18. text: '新增采购',
  19. action: () => start(),
  20. },
  21. ]"
  22. @get-list="getList"
  23. >
  24. <template #code="{ item }">
  25. <div
  26. style="cursor: pointer; color: #409eff"
  27. @click="handleClickCode(item)"
  28. >
  29. {{ item.code }}
  30. </div>
  31. </template>
  32. <template #contractCode="{ item }">
  33. <div
  34. style="cursor: pointer; color: #409eff"
  35. @click="handleClickcontractCode(item)"
  36. >
  37. {{ item.contractCode }}
  38. </div>
  39. </template>
  40. </byTable>
  41. </div>
  42. <el-dialog
  43. title="到货通知"
  44. v-model="dialogVisible"
  45. width="800"
  46. v-loading="loading"
  47. >
  48. <el-form
  49. :model="formData.data"
  50. :rules="rules"
  51. ref="formDom"
  52. label-position="top"
  53. >
  54. <div style="margin-bottom: 10px; font-size: 14px">基础信息</div>
  55. <el-row>
  56. <el-col :span="8">
  57. <el-form-item label="供应商" prop="supplyId">
  58. <el-select
  59. v-model="formData.data.supplyId"
  60. placeholder="请选择"
  61. style="width: 100%"
  62. disabled
  63. >
  64. <el-option
  65. v-for="item in supplierData"
  66. :label="item.name"
  67. :value="item.id"
  68. >
  69. </el-option>
  70. </el-select>
  71. </el-form-item>
  72. </el-col>
  73. </el-row>
  74. <el-row>
  75. <el-col :span="6">
  76. <el-form-item label="采购单号" prop="code">
  77. <el-input
  78. v-model="formData.data.code"
  79. placeholder="请输入"
  80. disabled
  81. >
  82. </el-input>
  83. </el-form-item>
  84. </el-col>
  85. </el-row>
  86. <div style="margin-bottom: 10px; font-size: 14px">到货明细</div>
  87. <el-form-item>
  88. <el-table :data="formData.data.arrivalDetailList">
  89. <el-table-column
  90. prop="goodType"
  91. label="货品类型"
  92. :formatter="(row) => (row.goodType == 1 ? '产品' : '物料')"
  93. />
  94. <el-table-column prop="productCode" label="货品编码" />
  95. <el-table-column prop="productName" label="货品名称" />
  96. <el-table-column prop="productSpec" label="规格型号" />
  97. <el-table-column
  98. prop="productUnit"
  99. label="单位"
  100. :formatter="(row) => dictValueLabel(row.productUnit, productUnit)"
  101. />
  102. <el-table-column prop="purchaseCount" label="采购数量" />
  103. <el-table-column prop="sumArrivalCount" label="已到货" />
  104. <el-table-column prop="count" label="本次到货" min-width="150">
  105. <template #default="{ row, $index }">
  106. <el-form-item
  107. :prop="'arrivalDetailList.' + $index + '.count'"
  108. :rules="rules.count"
  109. :inline-message="true"
  110. >
  111. <el-input-number
  112. v-model="row.count"
  113. :precision="2"
  114. :controls="false"
  115. :min="0"
  116. @change="handleChangeAmount"
  117. />
  118. </el-form-item>
  119. </template>
  120. </el-table-column>
  121. </el-table>
  122. </el-form-item>
  123. </el-form>
  124. <template #footer>
  125. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  126. <el-button
  127. type="primary"
  128. @click="submitForm()"
  129. size="large"
  130. :loading="submitLoading"
  131. >
  132. 确 定
  133. </el-button>
  134. </template>
  135. </el-dialog>
  136. <el-dialog title="打印" v-if="openPdf" v-model="openPdf" width="840px">
  137. <!-- <div id="pdfDom" ref="pdfDom" style="width: 776px">
  138. <div style="border: 1px solid #000; border-collapse: collapse">
  139. <div style="text-align: right; padding: 2px 4px 0 0">
  140. 合同号:{{ pdfData.code }}
  141. </div>
  142. <div class="title">购销合同</div>
  143. <div style="display: flex">
  144. <div style="display: flex; width: 50%; padding-right: 20px">
  145. <div style="width: 60px">买方:</div>
  146. <div style="width: calc(100% - 60px)">
  147. <div>福建宏星电子科技有限公司</div>
  148. <div>福建省福州市鼓楼区软件大道89号福州软件园A区28号楼五层</div>
  149. </div>
  150. </div>
  151. <div style="display: flex; width: 50%; padding-left: 20px">
  152. <div style="width: 60px">卖方:</div>
  153. <div style="width: calc(100% - 60px)">
  154. {{ pdfData.supplyName }}
  155. </div>
  156. </div>
  157. </div>
  158. <div style="display: flex">
  159. <div style="display: flex; width: 50%; padding-right: 20px">
  160. <div style="width: 60px">经手人:</div>
  161. <div style="width: calc(100% - 60px)">
  162. {{ pdfData.purchaseName }}
  163. </div>
  164. </div>
  165. <div style="display: flex; width: 50%; padding-left: 20px">
  166. <div style="width: 60px">经手人:</div>
  167. <div style="width: calc(100% - 60px)">
  168. {{ pdfData.contactPerson }}
  169. </div>
  170. </div>
  171. </div>
  172. <div>买卖双方经协商,一致同意签订以下合同</div>
  173. <div>货物名称、规格型号、单位、数量、单价及金额:</div>
  174. <table border="1" style="width: 100%" class="table">
  175. <tr>
  176. <td style="width: 70px">序号</td>
  177. <td>品名</td>
  178. <td>规格型号</td>
  179. <td style="width: 60px">单位</td>
  180. <td style="width: 60px">数量</td>
  181. <td style="width: 100px">单价</td>
  182. <td style="width: 100px">金额</td>
  183. </tr>
  184. <tr
  185. v-for="(row, index) in pdfData.purchaseDetailList"
  186. :key="row.id"
  187. >
  188. <td style="width: 70px">{{ index + 1 }}</td>
  189. <td>{{ row.productName }}</td>
  190. <td>{{ row.productSpec }}</td>
  191. <td style="width: 60px">{{ row.productUnitName }}</td>
  192. <td style="width: 60px">{{ row.count }}</td>
  193. <td style="width: 100px">
  194. <span v-if="pdfData.currency">{{ pdfData.currency }}</span
  195. >{{ row.price }}
  196. </td>
  197. <td style="width: 100px">
  198. <span v-if="pdfData.currency">{{ pdfData.currency }}</span
  199. >{{ row.amount }}
  200. </td>
  201. </tr>
  202. <tr>
  203. <td colspan="4" style="text-align: right">其他收费项目:</td>
  204. <td></td>
  205. <td></td>
  206. <td>
  207. <span v-if="pdfData.currency">{{ pdfData.currency }}</span
  208. >{{ pdfData.otherMoney }}
  209. </td>
  210. </tr>
  211. <tr>
  212. <td colspan="4" style="text-align: right">合计:</td>
  213. <td>{{ pdfData.countTotal }}</td>
  214. <td></td>
  215. <td>
  216. <span v-if="pdfData.currency">{{ pdfData.currency }}</span
  217. >{{ pdfData.amount }}
  218. </td>
  219. </tr>
  220. <tr>
  221. <td colspan="7" style="text-align: left">
  222. 合计人民币金额(大写):{{ pdfData.moneyChinese }}
  223. </td>
  224. </tr>
  225. <tr>
  226. <td>交货地点:</td>
  227. <td colspan="6" style="text-align: left">
  228. 福建省福州市鼓楼区软件大道89号福州软件园A区28号楼五层
  229. </td>
  230. </tr>
  231. <tr>
  232. <td>保修期:</td>
  233. <td colspan="6" style="text-align: left">一年</td>
  234. </tr>
  235. <tr>
  236. <td colspan="7" style="text-align: left; padding: 0px">
  237. <div style="padding: 2px 0px">
  238. 一、交货地点:福州软件园A区28座5层。
  239. </div>
  240. <div style="padding: 2px 0px">
  241. 二、运输方式及运费:买方承担。
  242. </div>
  243. <div style="padding: 2px 0px">
  244. 三、质量要求:样品品质、型号、规格、数量如同买方确认上表规格所示,不符合则由卖方承担责任。
  245. </div>
  246. <div style="padding: 2px 0px">
  247. 四、交货时间:2023年4月13日。
  248. </div>
  249. <div style="padding: 2px 0px">五、付款方式:银行转账。</div>
  250. <div style="padding: 2px 0px">六、保修期:一年。</div>
  251. <div style="padding: 2px 0px">
  252. 七、本合同经买卖双方签字盖章后生效,传真件有效。
  253. </div>
  254. <div style="padding: 2px 0px">
  255. 八、解决合同纠纷:原双方另有约定外,均按《中华人民共和国合同法》有关规定处理。
  256. </div>
  257. <div style="padding: 2px 0px">九、其他约定事项:友好解决。</div>
  258. </td>
  259. </tr>
  260. </table>
  261. <div style="display: flex">
  262. <div style="width: 50%; padding-right: 20px">
  263. <div>买方:</div>
  264. <div>单位名称:福建宏星电子科技有限公司</div>
  265. <div>
  266. 地址:福建省福州市鼓楼区软件大道89号福州软件园A区28号楼五层
  267. </div>
  268. <div>电话:</div>
  269. <div>传真:</div>
  270. <div style="opacity: 0">|</div>
  271. <div style="margin-top: auto">代表人签字:</div>
  272. </div>
  273. <div style="width: 50%; padding-left: 20px">
  274. <div>卖方:</div>
  275. <div>单位名称:{{ pdfData.supplyName }}</div>
  276. <div>统一社会信用代码:</div>
  277. <div>开户银行:{{ pdfData.openingBank }}</div>
  278. <div>帐号:{{ pdfData.accountOpening }}</div>
  279. <div>
  280. 地址:<span
  281. v-if="
  282. pdfData.supplyAddress && pdfData.supplyAddress.countryName
  283. "
  284. >{{ pdfData.supplyAddress.countryName }}</span
  285. >
  286. <span
  287. v-if="
  288. pdfData.supplyAddress && pdfData.supplyAddress.provinceName
  289. "
  290. >,{{ pdfData.supplyAddress.provinceName }}</span
  291. >
  292. <span
  293. v-if="pdfData.supplyAddress && pdfData.supplyAddress.cityName"
  294. >,{{ pdfData.supplyAddress.cityName }}</span
  295. >
  296. <span
  297. v-if="
  298. pdfData.supplyAddress && pdfData.supplyAddress.areaDetail
  299. "
  300. >,{{ pdfData.supplyAddress.areaDetail }}</span
  301. >
  302. </div>
  303. <div>电话:{{ pdfData.contactNumber }}</div>
  304. <div>代表人签字:</div>
  305. </div>
  306. </div>
  307. <div
  308. style="
  309. padding: 30px 0px 20px 0;
  310. text-align: right;
  311. border-top: 1px solid #000;
  312. "
  313. >
  314. 签订日期:{{ pdfData.approvedDate }}
  315. </div>
  316. </div>
  317. </div> -->
  318. <PurchasePDF :rowData="rowData"></PurchasePDF>
  319. <template #footer ref="printBtn">
  320. <el-button @click="openPdf = false" size="large">关闭</el-button>
  321. <el-button type="primary" v-print="printObj" size="large"
  322. >打印</el-button
  323. >
  324. <el-button type="primary" @click="clickDownload()" size="large"
  325. >下载PDF</el-button
  326. >
  327. </template>
  328. </el-dialog>
  329. </div>
  330. </template>
  331. <script setup>
  332. import { ElMessage, ElMessageBox } from "element-plus";
  333. import byTable from "@/components/byTable/index";
  334. import byForm from "@/components/byForm/index";
  335. import { NumberToChinese } from "@/utils/util.js";
  336. import PurchasePDF from "@/components/PDF/purchasePDF.vue";
  337. const loading = ref(false);
  338. const submitLoading = ref(false);
  339. const sourceList = ref({
  340. data: [],
  341. pagination: {
  342. total: 3,
  343. pageNum: 1,
  344. pageSize: 10,
  345. },
  346. });
  347. let dialogVisible = ref(false);
  348. let modalType = ref("add");
  349. let rules = ref({
  350. count: [{ required: true, message: "请输入本次到货", trigger: "blur" }],
  351. });
  352. const { proxy } = getCurrentInstance();
  353. const statusData = ref([
  354. {
  355. label: "审批中",
  356. value: "10",
  357. },
  358. {
  359. label: "驳回",
  360. value: "20",
  361. },
  362. {
  363. label: "已采购",
  364. value: "30",
  365. },
  366. {
  367. label: "终止",
  368. value: "99",
  369. },
  370. {
  371. label: "已作废",
  372. value: "88",
  373. },
  374. ]);
  375. const arrivalStatus = ref([
  376. {
  377. label: "未到货",
  378. value: "0",
  379. },
  380. {
  381. label: "部分到货",
  382. value: "10",
  383. },
  384. {
  385. label: "已到货",
  386. value: "20",
  387. },
  388. ]);
  389. const paymentStatus = ref([
  390. {
  391. label: "未付款",
  392. value: "0",
  393. },
  394. {
  395. label: "部分付款",
  396. value: "10",
  397. },
  398. {
  399. label: "已付款",
  400. value: "20",
  401. },
  402. ]);
  403. const headerData = ref({
  404. sumOrderCount: 0,
  405. sumPurchaseMoney: 0,
  406. noArrivalOrderCount: 0,
  407. noArrivalPurchaseMoney: 0,
  408. partArrivalOrderCount: 0,
  409. partArrivalPurchaseMoney: 0,
  410. alArrivalPurchaseMoney: 0,
  411. alArrivalOrderCount: 0,
  412. });
  413. const getHeaderData = () => {
  414. proxy.post("/purchase/statisticsPurchaseHead").then((res) => {
  415. headerData.value = res;
  416. });
  417. };
  418. const statConfig = computed(() => [
  419. {
  420. label: "统计",
  421. data: [
  422. //一个卡牌多数据配置
  423. {
  424. label: "合计",
  425. type: 2,
  426. data: [
  427. {
  428. label: "订单数",
  429. num: headerData.value.sumOrderCount,
  430. color: "#C280FF",
  431. },
  432. {
  433. label: "采购金额",
  434. num: proxy.moneyFormat(headerData.value.sumPurchaseMoney, 2),
  435. color: "#C280FF",
  436. },
  437. ],
  438. },
  439. {
  440. label: "未到货",
  441. data: [
  442. {
  443. label: "订单数",
  444. num: headerData.value.noArrivalOrderCount,
  445. color: "#0084FF",
  446. },
  447. {
  448. label: "采购金额",
  449. num: proxy.moneyFormat(headerData.value.noArrivalPurchaseMoney, 2),
  450. color: "#0084FF",
  451. },
  452. ],
  453. },
  454. {
  455. label: "部分到货",
  456. data: [
  457. {
  458. label: "订单数",
  459. num: headerData.value.partArrivalOrderCount,
  460. color: "#0084FF",
  461. },
  462. {
  463. label: "采购金额",
  464. num: proxy.moneyFormat(
  465. headerData.value.partArrivalPurchaseMoney,
  466. 2
  467. ),
  468. color: "#0084FF",
  469. },
  470. ],
  471. },
  472. {
  473. label: "已到货",
  474. data: [
  475. {
  476. label: "订单数",
  477. num: headerData.value.alArrivalOrderCount,
  478. color: "#0084FF",
  479. },
  480. {
  481. label: "采购金额",
  482. num: proxy.moneyFormat(headerData.value.alArrivalPurchaseMoney, 2),
  483. color: "#0084FF",
  484. },
  485. ],
  486. },
  487. ],
  488. },
  489. ]);
  490. const selectConfig = reactive([
  491. {
  492. label: "采购状态",
  493. prop: "purchaseStatus",
  494. data: statusData.value,
  495. },
  496. {
  497. label: "到货状态",
  498. prop: "arrivalStatus",
  499. data: arrivalStatus.value,
  500. },
  501. {
  502. label: "付款状态",
  503. prop: "payStatus",
  504. data: paymentStatus.value,
  505. },
  506. ]);
  507. const config = computed(() => {
  508. return [
  509. {
  510. attrs: {
  511. label: "采购单号",
  512. prop: "code",
  513. slot: "code",
  514. },
  515. },
  516. {
  517. attrs: {
  518. label: "关联销售合同",
  519. prop: "contractCode",
  520. slot: "contractCode",
  521. },
  522. },
  523. {
  524. attrs: {
  525. label: "供应商",
  526. prop: "supplyName",
  527. },
  528. },
  529. {
  530. attrs: {
  531. label: "采购金额",
  532. prop: "amount",
  533. width: 120,
  534. },
  535. render(amount) {
  536. return proxy.moneyFormat(amount, 2);
  537. },
  538. },
  539. {
  540. attrs: {
  541. label: "已付款金额(CNY)",
  542. prop: "paySumAmount",
  543. width: 160,
  544. },
  545. render(amount) {
  546. return proxy.moneyFormat(amount, 2);
  547. },
  548. },
  549. {
  550. attrs: {
  551. label: "采购人",
  552. prop: "purchaseName",
  553. },
  554. },
  555. {
  556. attrs: {
  557. label: "采购时间",
  558. prop: "createTime",
  559. width: 155,
  560. },
  561. },
  562. {
  563. attrs: {
  564. label: "采购状态",
  565. prop: "purchaseStatus",
  566. width: 80,
  567. },
  568. render(status) {
  569. return proxy.dictValueLabel(status, statusData.value);
  570. },
  571. },
  572. {
  573. attrs: {
  574. label: "到货状态",
  575. prop: "arrivalStatus",
  576. width: 80,
  577. },
  578. render(status) {
  579. return proxy.dictValueLabel(status, arrivalStatus.value);
  580. },
  581. },
  582. {
  583. attrs: {
  584. label: "付款状态",
  585. prop: "payStatus",
  586. width: 80,
  587. },
  588. render(status) {
  589. return proxy.dictValueLabel(status, paymentStatus.value);
  590. },
  591. },
  592. {
  593. attrs: {
  594. label: "操作",
  595. width: "250",
  596. align: "center",
  597. fixed: "right",
  598. },
  599. renderHTML(row) {
  600. return [
  601. {
  602. attrs: {
  603. label: "打印",
  604. type: "primary",
  605. text: true,
  606. },
  607. el: "button",
  608. click() {
  609. handlePrintPdf(row);
  610. },
  611. },
  612. row.purchaseStatus == 30
  613. ? {
  614. attrs: {
  615. label: "到货通知",
  616. type: "primary",
  617. text: true,
  618. },
  619. el: "button",
  620. click() {
  621. handleArrival(row);
  622. },
  623. }
  624. : {},
  625. row.purchaseStatus != 88
  626. ? {
  627. attrs: {
  628. label: "作废",
  629. type: "primary",
  630. text: true,
  631. },
  632. el: "button",
  633. click() {
  634. handleEditOne(row);
  635. },
  636. }
  637. : {},
  638. {
  639. attrs: {
  640. label: "终止",
  641. type: "primary",
  642. text: true,
  643. },
  644. el: "button",
  645. click() {
  646. handleEdit(row, 99);
  647. },
  648. },
  649. ];
  650. },
  651. },
  652. ];
  653. });
  654. let formData = reactive({
  655. data: {
  656. type: "1",
  657. },
  658. });
  659. const formOption = reactive({
  660. inline: true,
  661. labelWidth: 100,
  662. itemWidth: 100,
  663. rules: [],
  664. });
  665. const formDom = ref(null);
  666. const formConfig = computed(() => {
  667. return [
  668. {
  669. type: "radio",
  670. prop: "name",
  671. label: "供应商类型",
  672. required: true,
  673. border: true,
  674. data: [
  675. { label: "贸易商", value: "1" },
  676. { label: "工厂", value: "2" },
  677. ],
  678. },
  679. {
  680. type: "input",
  681. prop: "name",
  682. label: "供应商名称",
  683. required: true,
  684. },
  685. {
  686. type: "slot",
  687. slotName: "address",
  688. label: "地址",
  689. required: true,
  690. },
  691. {
  692. type: "slot",
  693. slotName: "contact",
  694. label: "联系信息",
  695. required: true,
  696. },
  697. {
  698. type: "slot",
  699. slotName: "fileSlot",
  700. label: "上传附件",
  701. },
  702. {
  703. type: "input",
  704. label: "备注",
  705. prop: "remakes",
  706. itemType: "textarea",
  707. },
  708. ];
  709. });
  710. const getList = async (req) => {
  711. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  712. loading.value = true;
  713. proxy.post("/purchase/page", sourceList.value.pagination).then((message) => {
  714. console.log(message);
  715. sourceList.value.data = message.rows;
  716. sourceList.value.pagination.total = message.total;
  717. setTimeout(() => {
  718. loading.value = false;
  719. }, 200);
  720. });
  721. };
  722. const submitForm = async () => {
  723. formDom.value.validate((vaild) => {
  724. if (vaild) {
  725. const list = formData.data.arrivalDetailList;
  726. const total = list.reduce((total, x) => (total += Number(x.count)), 0);
  727. if (!(total > 0)) {
  728. return ElMessage({
  729. message: `本次到货不能为0!`,
  730. type: "info",
  731. });
  732. }
  733. let sum = 0;
  734. for (let i = 0; i < list.length; i++) {
  735. const e = list[i];
  736. delete e.id;
  737. if (
  738. Number(e.sumArrivalCount) + Number(e.count) >=
  739. Number(e.purchaseCount)
  740. ) {
  741. sum += 1;
  742. }
  743. }
  744. formData.data.arrivalStatus = sum === list.length ? "20" : "10";
  745. proxy.post("/arrival/add", formData.data).then((res) => {
  746. ElMessage({
  747. message: `操作成功!`,
  748. type: "success",
  749. });
  750. dialogVisible.value = false;
  751. getList();
  752. });
  753. }
  754. });
  755. };
  756. const getDtl = (row) => {
  757. modalType.value = "edit";
  758. proxy.post("/productionProcesses/detail", { id: row.id }).then((res) => {
  759. formData.data = res;
  760. dialogVisible.value = true;
  761. });
  762. };
  763. const handleEdit = (row, status) => {
  764. let purchaseStatusName = status == 88 ? "作废" : "终止";
  765. const data = { ...row, purchaseStatus: status };
  766. // 弹窗提示是否删除
  767. ElMessageBox.confirm(
  768. `此操作将${purchaseStatusName}该数据, 是否继续?`,
  769. "提示",
  770. {
  771. confirmButtonText: "确定",
  772. cancelButtonText: "取消",
  773. type: "warning",
  774. }
  775. ).then(() => {
  776. // 删除
  777. proxy.post("/purchase/edit", data).then((res) => {
  778. ElMessage({
  779. message: `${purchaseStatusName}成功`,
  780. type: "success",
  781. });
  782. getList();
  783. });
  784. });
  785. };
  786. const handleEditOne = (row) => {
  787. const data = { id: row.id, purchaseStatus: 88 };
  788. // 弹窗提示是否删除
  789. ElMessageBox.confirm(`此操作将作废该数据, 是否继续?`, "提示", {
  790. confirmButtonText: "确定",
  791. cancelButtonText: "取消",
  792. type: "warning",
  793. }).then(() => {
  794. // 删除
  795. proxy.post("/sale/purchase/cancellation", data).then((res) => {
  796. ElMessage({
  797. message: `作废成功`,
  798. type: "success",
  799. });
  800. getList();
  801. });
  802. });
  803. };
  804. const supplierData = ref([]);
  805. const productUnit = ref([]);
  806. const getDict = async (req) => {
  807. proxy
  808. .post("/supplierInfo/page", { pageNum: 1, pageSize: 9999 })
  809. .then((res) => {
  810. supplierData.value = res.rows;
  811. });
  812. proxy.getDictOne(["unit"]).then((res) => {
  813. productUnit.value = res["unit"].map((x) => ({
  814. label: x.dictValue,
  815. value: x.dictKey,
  816. }));
  817. });
  818. };
  819. const handleArrival = (row) => {
  820. proxy.post("/purchase/detail", { id: row.id }).then((res) => {
  821. formData.data = {
  822. purchaseId: row.id,
  823. code: res.code,
  824. supplyId: res.supplyId,
  825. arrivalDetailList: res.purchaseDetailList.map((x) => {
  826. let obj = {
  827. ...x,
  828. purchaseDetailId: x.id,
  829. purchaseCount: x.count,
  830. count: Number(x.count) - Number(x.sumArrivalCount),
  831. };
  832. delete obj.status;
  833. return obj;
  834. }),
  835. arrivalStatus: "",
  836. };
  837. dialogVisible.value = true;
  838. });
  839. };
  840. getDict();
  841. getHeaderData();
  842. getList();
  843. const start = () => {
  844. proxy.$router.replace({
  845. path: "/platform_manage/process/processApproval",
  846. query: {
  847. flowKey: "purchase_flow",
  848. ids: "",
  849. flowName: "采购申请",
  850. random: proxy.random(),
  851. },
  852. });
  853. };
  854. const handleClickCode = (row) => {
  855. proxy.$router.push({
  856. path: "/platform_manage/process/processApproval",
  857. query: {
  858. flowKey: row.processInstanceId,
  859. id: row.flowId,
  860. processType: 20,
  861. },
  862. });
  863. };
  864. const handleClickcontractCode = (row) => {
  865. proxy.$router.push({
  866. name: "Contract",
  867. query: {
  868. code: row.contractCode,
  869. },
  870. });
  871. };
  872. const openPdf = ref(false);
  873. const pdfData = ref({});
  874. const rowData = ref({});
  875. const handlePrintPdf = (row) => {
  876. rowData.value = {
  877. id: row.id,
  878. code: row.code,
  879. };
  880. openPdf.value = true;
  881. };
  882. const clickDownload = () => {
  883. proxy.getPdf("购销合同" + rowData.value.code);
  884. };
  885. const pdfDom = ref(null);
  886. const printObj = ref({
  887. id: "pdfDom",
  888. popTitle: "",
  889. extraCss:
  890. "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",
  891. extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
  892. });
  893. </script>
  894. <style lang="scss" scoped>
  895. .tenant {
  896. padding: 20px;
  897. }
  898. #pdfDom {
  899. font-size: 12px;
  900. color: #000000;
  901. padding: 60px 30px;
  902. .title {
  903. font-size: 16px;
  904. font-weight: 700;
  905. margin-top: 10px;
  906. margin-bottom: 20px;
  907. text-align: center;
  908. }
  909. .table {
  910. // width: calc(100% + 2px) !important;
  911. border-collapse: collapse;
  912. border-spacing: 0;
  913. // margin-left: -1px;
  914. // margin-right: -1px;
  915. td {
  916. text-align: center;
  917. padding: 8px 0px;
  918. }
  919. // tr td:last-child {
  920. // border-right: 0 !important;
  921. // }
  922. }
  923. .flex-top-bottom {
  924. display: flex;
  925. justify-content: space-between;
  926. margin: 5px 0px;
  927. }
  928. }
  929. </style>