detailsPage.vue 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198
  1. <template>
  2. <div class="borderless">
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <!-- <i class="back-icon el-icon-arrow-left"></i><i style="font-style:normal">返回管理列表</i>-->
  6. <el-button
  7. type="danger"
  8. style="border: none;background: none;color: red"
  9. icon="el-icon-arrow-left"
  10. @click="backToList"
  11. >返回列表
  12. </el-button>
  13. </div>
  14. <el-button type="info" class="sell-customer-btn" @click="saveSell"
  15. >生成销售单</el-button
  16. >
  17. <el-button type="success" class="copy-customer-btn" disabled>
  18. 复制新单
  19. </el-button>
  20. <el-button
  21. class="add-customer-btn"
  22. type="primary"
  23. :disabled="disabled"
  24. @click="editCustomer"
  25. :loading="subLoading"
  26. >{{ form.id ? "确认修改" : "确认新增" }}
  27. </el-button>
  28. </div>
  29. <div style="margin-top: 60px;margin-bottom:35px">
  30. <containerTitle title="基础信息"></containerTitle>
  31. <basic-container style="margin-bottom: 10px">
  32. <avue-form ref="form" v-model="form" :option="option">
  33. <template slot="portOfLoad">
  34. <port-info
  35. v-model="form.portOfLoad"
  36. :disabled="detailData.status == 1"
  37. />
  38. </template>
  39. <template slot="portOfDestination">
  40. <port-info
  41. v-model="form.portOfDestination"
  42. :disabled="detailData.status == 1"
  43. />
  44. </template>
  45. <template slot="corpId">
  46. <select-component
  47. v-model="form.corpId"
  48. :configuration="configuration"
  49. :disabled="detailData.status == 1"
  50. ></select-component>
  51. </template>
  52. <template slot="boxNumber">
  53. <el-input
  54. size="mini"
  55. v-model="form.boxNumber"
  56. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/,
  57. "$1.$2")'
  58. placeholder="请输入 起订量"
  59. :disabled="detailData.status == 1"
  60. />
  61. </template>
  62. <template slot="minOrder">
  63. <el-input
  64. size="mini"
  65. v-model="form.minOrder"
  66. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/,
  67. "$1.$2")'
  68. placeholder="请输入 起订量"
  69. :disabled="detailData.status == 1"
  70. />
  71. </template>
  72. <template slot="predictOceanFreight">
  73. <el-input
  74. size="mini"
  75. v-model="form.predictOceanFreight"
  76. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/,
  77. "$1.$2")'
  78. placeholder="请输入 预计海运费"
  79. :disabled="detailData.status == 1"
  80. />
  81. </template>
  82. <template slot="referenceOceanFreight">
  83. <el-input
  84. size="mini"
  85. v-model="form.referenceOceanFreight"
  86. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/,
  87. "$1.$2")'
  88. placeholder="请输入 参考海运费"
  89. :disabled="detailData.status == 1"
  90. />
  91. </template>
  92. <template slot="oceanFreight">
  93. <el-input
  94. size="mini"
  95. v-model="form.oceanFreight"
  96. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/,
  97. "$1.$2")'
  98. placeholder="请输入 实际海运费"
  99. :disabled="detailData.status == 1"
  100. />
  101. </template>
  102. </avue-form>
  103. </basic-container>
  104. <containerTitle title="商品信息"></containerTitle>
  105. <basic-container>
  106. <avue-crud
  107. ref="crud"
  108. :data="data"
  109. :option="tableOption"
  110. @row-del="rowDel"
  111. :summary-method="summaryMethod"
  112. @saveColumn="saveColumn"
  113. >
  114. <template slot="menuLeft">
  115. <el-button
  116. type="primary"
  117. icon="el-icon-plus"
  118. size="small"
  119. @click.stop="newDetails"
  120. :disabled="detailData.status == 1"
  121. >新增明细</el-button
  122. >
  123. <el-button
  124. type="info"
  125. icon="el-icon-printer"
  126. size="small"
  127. @click.stop="openReport()"
  128. >报 表</el-button
  129. >
  130. <el-button
  131. type="info"
  132. size="small"
  133. @click.stop="savePurchase"
  134. :disabled="detailData.status == 1"
  135. >采购询价</el-button
  136. >
  137. <el-button
  138. type="info"
  139. size="small"
  140. @click.stop="saveShipping"
  141. :disabled="detailData.status == 1"
  142. >船务询价</el-button
  143. >
  144. </template>
  145. <template slot="menu" slot-scope="{ row, index }">
  146. <el-button
  147. size="small"
  148. icon="el-icon-edit"
  149. type="text"
  150. @click="rowCell(row, index)"
  151. :disabled="disabled"
  152. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button
  153. >
  154. <el-button
  155. size="small"
  156. icon="el-icon-edit"
  157. type="text"
  158. @click="rowDel(row, index)"
  159. :disabled="detailData.status == 1"
  160. >删 除</el-button
  161. >
  162. </template>
  163. <template slot="itemType" slot-scope="{ row }">
  164. <el-select
  165. v-if="row.$cellEdit"
  166. v-model="row.itemType"
  167. filterable
  168. allow-create
  169. default-first-option
  170. placeholder="请输入"
  171. size="small"
  172. @focus="itemTypeFocus(row)"
  173. >
  174. <el-option
  175. v-for="(item, index) in itemtypeList"
  176. :key="index"
  177. :label="item.value"
  178. :value="item.value"
  179. >
  180. </el-option>
  181. </el-select>
  182. <span v-else>{{ row.itemType }}</span>
  183. </template>
  184. <template slot="cname" slot-scope="{ row, index }">
  185. <el-button
  186. size="small"
  187. type="text"
  188. @click="rePick(row, index)"
  189. :disabled="disabled"
  190. class="picker"
  191. style="padding:4px 10px;float:left"
  192. >选择</el-button
  193. >
  194. <span> {{ row.cname }}</span>
  195. </template>
  196. <template slot="priorityReferrer" slot-scope="{ row }">
  197. <el-checkbox
  198. :disabled="!row.$cellEdit"
  199. v-model="row.priorityReferrer"
  200. :true-label="1"
  201. :false-label="0"
  202. />
  203. </template>
  204. <template slot="corpId" slot-scope="{ row, index }">
  205. <customer-dialog
  206. v-if="row.$cellEdit"
  207. v-model="row.corpName"
  208. :cropIndex="index"
  209. @getcorpId="getcorpId"
  210. ></customer-dialog>
  211. <span v-else>{{ row.corpName }}</span>
  212. </template>
  213. <template slot="purchaseAmount" slot-scope="{ row }">
  214. <el-input
  215. v-if="row.$cellEdit"
  216. v-model="row.purchaseAmount"
  217. size="small"
  218. placeholder="请输入"
  219. @change="priceChange(row)"
  220. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  221. ></el-input>
  222. <span v-else>{{ row.purchaseAmount | micrometerFormat }}</span>
  223. </template>
  224. <template slot="price" slot-scope="{ row }">
  225. <el-input
  226. v-if="row.$cellEdit"
  227. v-model="row.price"
  228. size="small"
  229. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  230. @change="priceChange(row)"
  231. ></el-input>
  232. <span v-else>{{ row.price | micrometerFormat }}</span>
  233. </template>
  234. <template slot="amount" slot-scope="{ row }">
  235. <span>{{ row.amount | micrometerFormat }}</span>
  236. </template>
  237. <template slot="orderQuantity" slot-scope="{ row }">
  238. <el-input
  239. v-if="row.$cellEdit"
  240. v-model="row.orderQuantity"
  241. size="small"
  242. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  243. @change="priceChange(row)"
  244. ></el-input>
  245. <span v-else>{{ row.orderQuantity }}</span>
  246. </template>
  247. <template slot="discount" slot-scope="{ row }">
  248. <el-input
  249. v-if="row.$cellEdit"
  250. v-model="row.discount"
  251. size="small"
  252. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  253. @change="discountChange(row)"
  254. ></el-input>
  255. <span v-else>{{ row.discount | isDiscount }}</span>
  256. </template>
  257. <template slot="insurance" slot-scope="{ row }">
  258. <el-input
  259. v-if="row.$cellEdit"
  260. v-model="row.insurance"
  261. size="small"
  262. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  263. @change="priceChange(row)"
  264. ></el-input>
  265. <span v-else>{{ row.insurance | micrometerFormat }}</span>
  266. </template>
  267. <template slot="freight" slot-scope="{ row }">
  268. <el-input
  269. v-if="row.$cellEdit"
  270. v-model="row.freight"
  271. size="small"
  272. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  273. @change="priceChange(row)"
  274. ></el-input>
  275. <span v-else>{{ row.freight | micrometerFormat }}</span>
  276. </template>
  277. <template slot="taxRate" slot-scope="{ row }">
  278. <el-input
  279. v-if="row.$cellEdit"
  280. v-model="row.taxRate"
  281. size="small"
  282. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  283. @change="taxRateChange(row)"
  284. ></el-input>
  285. <span v-else>{{ row.taxRate | isPercentage }}</span>
  286. </template>
  287. </avue-crud>
  288. </basic-container>
  289. <fee-info
  290. ref="feeInfo"
  291. :orderFeesList="orderFeesList"
  292. :disabled="detailData.status == 1"
  293. feeUrl="/blade-purchase-sales/orderfees/update"
  294. />
  295. </div>
  296. <el-dialog
  297. title="导入商品"
  298. append-to-body
  299. class="el-dialogDeep"
  300. :visible.sync="dialogVisible"
  301. width="60%"
  302. :close-on-click-modal="false"
  303. :destroy-on-close="true"
  304. :close-on-press-escape="false"
  305. @close="closeGoods"
  306. top="10vh"
  307. v-dialog-drag
  308. >
  309. <span>
  310. <el-row>
  311. <el-col :span="5">
  312. <div>
  313. <el-scrollbar>
  314. <basic-container style="margin-top:45px">
  315. <avue-tree :option="treeOption" @node-click="nodeClick" />
  316. </basic-container>
  317. </el-scrollbar>
  318. </div>
  319. </el-col>
  320. <el-col :span="19">
  321. <avue-crud
  322. :option="goodsOption"
  323. :table-loading="loading"
  324. :data="goodsList"
  325. ref="goodsCrud"
  326. @refresh-change="refreshChange"
  327. @selection-change="selectionChange"
  328. @row-click="rowClick"
  329. :page.sync="page"
  330. @on-load="onLoad"
  331. @saveColumn="saveGoodsColumn"
  332. ></avue-crud>
  333. </el-col>
  334. </el-row>
  335. </span>
  336. <span slot="footer" class="dialog-footer">
  337. <el-button @click="dialogVisible = false">取 消</el-button>
  338. <el-button
  339. type="primary"
  340. @click="importGoods"
  341. :disabled="selectionList.length == 0"
  342. >导入</el-button
  343. >
  344. </span>
  345. </el-dialog>
  346. <report-dialog
  347. :switchDialog="switchDialog"
  348. :reportId="form.id"
  349. reportName="客户询价"
  350. @onClose="onClose()"
  351. ></report-dialog>
  352. </div>
  353. </template>
  354. <script>
  355. import tableOption from "./config/customerContact.json";
  356. import goodsOption from "./config/commodity.json";
  357. import feeInfo from "@/components/fee-info/main";
  358. import customerDialog from "@/components/customer-dialog/main";
  359. import {
  360. detail,
  361. submit,
  362. delItem,
  363. getDeptLazyTree,
  364. getGoods,
  365. savePurchase,
  366. saveShipping,
  367. getPorts,
  368. getSpecification,
  369. saveSell
  370. } from "@/api/basicData/customerInquiry";
  371. import reportDialog from "@/components/report-dialog/main";
  372. import { isDiscount, isPercentage, micrometerFormat } from "@/util/validate";
  373. import { contrastObj, contrastList } from "@/util/contrastData";
  374. import _ from "lodash";
  375. export default {
  376. name: "detailsPageEdit",
  377. data() {
  378. return {
  379. itemtypeList: [],
  380. configuration: {
  381. multipleChoices: false,
  382. multiple: false,
  383. collapseTags: false,
  384. placeholder: "请点击右边按钮选择",
  385. dicData: []
  386. },
  387. switchDialog: false,
  388. form: {
  389. orderStatus: "录入"
  390. },
  391. disabled: false,
  392. dialogVisible: false,
  393. tableOption: {},
  394. option: {
  395. menuBtn: false,
  396. labelWidth: 100,
  397. column: [
  398. {
  399. label: "客户名称",
  400. prop: "corpId",
  401. rules: [
  402. {
  403. required: true,
  404. message: "",
  405. trigger: "blur"
  406. }
  407. ],
  408. span: 16,
  409. slot: true
  410. },
  411. {
  412. label: "系统号",
  413. prop: "sysNo",
  414. span: 8,
  415. disabled: true
  416. },
  417. {
  418. label: "联系人",
  419. prop: "corpAttn",
  420. span: 8
  421. },
  422. {
  423. label: "电话",
  424. prop: "corpTel",
  425. span: 8
  426. },
  427. {
  428. label: "订单状态",
  429. prop: "orderStatus",
  430. span: 8,
  431. type: "select",
  432. dicUrl: "/api/blade-system/dict-biz/dictionary?code=order_status",
  433. props: {
  434. label: "dictValue",
  435. value: "dictValue"
  436. }
  437. },
  438. {
  439. label: "起运港",
  440. prop: "portOfLoad",
  441. span: 8,
  442. type: "select",
  443. filterable: true,
  444. dicData: [],
  445. props: {
  446. label: "name",
  447. value: "name"
  448. }
  449. },
  450. {
  451. label: "目的港",
  452. prop: "portOfDestination",
  453. span: 8,
  454. type: "select",
  455. filterable: true,
  456. dicData: [],
  457. props: {
  458. label: "name",
  459. value: "name"
  460. }
  461. },
  462. {
  463. label: "运输方式",
  464. prop: "transport",
  465. span: 8,
  466. type: "select",
  467. dicUrl: "/api/blade-system/dict-biz/dictionary?code=mode_transport",
  468. props: {
  469. label: "dictValue",
  470. value: "dictValue"
  471. }
  472. },
  473. {
  474. label: "价格条款",
  475. prop: "priceTerms",
  476. span: 8,
  477. type: "select",
  478. dicUrl: "/api/blade-system/dict-biz/dictionary?code=pricing_terms",
  479. props: {
  480. label: "dictValue",
  481. value: "dictValue"
  482. }
  483. },
  484. {
  485. label: "条款说明",
  486. prop: "priceTermsDescription",
  487. span: 16
  488. },
  489. {
  490. label: "收款方式",
  491. prop: "paymentType",
  492. span: 8,
  493. type: "select",
  494. dicUrl: "/api/blade-system/dict-biz/dictionary?code=payment_term",
  495. props: {
  496. label: "dictValue",
  497. value: "dictValue"
  498. }
  499. },
  500. {
  501. label: "收款说明",
  502. prop: "paymentTypeDescription",
  503. span: 16
  504. },
  505. {
  506. label: "订单日期",
  507. prop: "businesDate",
  508. span: 8,
  509. type: "date",
  510. format: "yyyy-MM-dd",
  511. valueFormat: "yyyy-MM-dd 00:00:00",
  512. rules: [
  513. {
  514. required: true,
  515. message: "",
  516. trigger: "blur"
  517. }
  518. ]
  519. },
  520. {
  521. label: "有效日期",
  522. prop: "dateValidity",
  523. span: 8,
  524. type: "date",
  525. format: "yyyy-MM-dd",
  526. valueFormat: "yyyy-MM-dd 00:00:00"
  527. },
  528. {
  529. label: "订单号",
  530. prop: "orderNo",
  531. span: 8
  532. },
  533. {
  534. label: "币别",
  535. prop: "currency",
  536. span: 8,
  537. type: "select",
  538. dicUrl: "/api/blade-system/dict-biz/dictionary?code=currency",
  539. props: {
  540. label: "dictValue",
  541. value: "dictValue"
  542. },
  543. change: ({ value }) => {
  544. if (value == "人民币") {
  545. this.form.exchangeRate = 1;
  546. }
  547. if (value == "美元") {
  548. this.form.exchangeRate = 6.3843;
  549. }
  550. }
  551. },
  552. {
  553. label: "汇率",
  554. prop: "exchangeRate",
  555. span: 8,
  556. slot: true,
  557. row: true,
  558. disabled: true
  559. },
  560. {
  561. label: "箱型",
  562. prop: "boxPile",
  563. span: 8
  564. },
  565. {
  566. label: "箱量",
  567. prop: "boxNumber",
  568. span: 8
  569. },
  570. {
  571. label: "起订量",
  572. prop: "minOrder",
  573. span: 8
  574. },
  575. {
  576. label: "预计海运费",
  577. prop: "predictOceanFreight",
  578. span: 8
  579. },
  580. {
  581. label: "参考海运费",
  582. prop: "referenceOceanFreight",
  583. span: 8
  584. },
  585. {
  586. label: "实际海运费",
  587. prop: "oceanFreight",
  588. span: 8
  589. },
  590. {
  591. label: "毛利额",
  592. prop: "grossProfit",
  593. span: 8,
  594. disabled: true
  595. },
  596. {
  597. label: "毛利率",
  598. prop: "grossProfitRate",
  599. span: 8,
  600. row: true,
  601. append: "%",
  602. disabled: true
  603. },
  604. {
  605. label: "备注",
  606. prop: "orderRemark",
  607. type: "textarea",
  608. minRows: 2,
  609. span: 8
  610. },
  611. {
  612. label: "采购备注",
  613. prop: "purchaseRemark",
  614. type: "textarea",
  615. minRows: 2,
  616. span: 8
  617. },
  618. {
  619. label: "船务备注",
  620. prop: "shippingRemark",
  621. type: "textarea",
  622. minRows: 2,
  623. span: 8
  624. }
  625. ]
  626. },
  627. treeOption: {
  628. nodeKey: "id",
  629. lazy: true,
  630. treeLoad: function(node, resolve) {
  631. const parentId = node.level === 0 ? 0 : node.data.id;
  632. getDeptLazyTree(parentId).then(res => {
  633. resolve(
  634. res.data.data.map(item => {
  635. return {
  636. ...item,
  637. leaf: !item.hasChildren
  638. };
  639. })
  640. );
  641. });
  642. },
  643. addBtn: false,
  644. menu: false,
  645. size: "small",
  646. props: {
  647. label: "title",
  648. value: "value",
  649. children: "children"
  650. }
  651. },
  652. page: {
  653. pageSize: 10,
  654. currentPage: 1,
  655. total: 0
  656. },
  657. loading: false,
  658. goodsOption: {},
  659. data: [],
  660. goodsList: [],
  661. selectionList: [],
  662. treeDeptId: null,
  663. orderFeesList: [],
  664. oldform: {
  665. orderStatus: "录入"
  666. },
  667. olddata: [],
  668. oldorderFeesList: [],
  669. reData: null,
  670. subLoading: false
  671. };
  672. },
  673. props: {
  674. detailData: {
  675. type: Object
  676. }
  677. },
  678. components: {
  679. reportDialog,
  680. feeInfo,
  681. customerDialog
  682. },
  683. async created() {
  684. this.tableOption = await this.getColumnData(
  685. this.getColumnName(1),
  686. tableOption
  687. );
  688. this.goodsOption = await this.getColumnData(
  689. this.getColumnName(26),
  690. goodsOption
  691. );
  692. if (this.detailData.id) {
  693. this.getDetail(this.detailData.id);
  694. }
  695. if (this.detailData.status == 1) {
  696. this.option.disabled = true;
  697. }
  698. this.getWorkDicts("product_properties").then(res => {
  699. this.findObject(this.tableOption.column, "itemProp").dicData =
  700. res.data.data;
  701. });
  702. getPorts().then(res => {
  703. this.findObject(this.option.column, "portOfLoad").dicData = res.data;
  704. this.findObject(this.option.column, "portOfDestination").dicData =
  705. res.data;
  706. });
  707. },
  708. filters: {
  709. isDiscount(val) {
  710. return isDiscount(val);
  711. },
  712. isPercentage(val) {
  713. return isPercentage(val);
  714. },
  715. micrometerFormat(val) {
  716. return micrometerFormat(val);
  717. }
  718. },
  719. methods: {
  720. saveSell() {
  721. if (!this.form.id) {
  722. return this.$message.error("此单据没有提交记录,请先提交");
  723. }
  724. this.$confirm("是否生成销售单?", {
  725. confirmButtonText: "确定",
  726. cancelButtonText: "取消",
  727. type: "warning"
  728. }).then(() => {
  729. saveSell(this.form.id).then(res => {
  730. if (res.data.code == 200) {
  731. this.$message.success("生成成功");
  732. }
  733. });
  734. });
  735. },
  736. rePick(row, index) {
  737. this.reData = {
  738. ...row,
  739. index: index
  740. };
  741. this.newDetails();
  742. },
  743. getcorpId(row) {
  744. this.data[row.index].corpId = row.id;
  745. },
  746. rowCell(row, index) {
  747. if (row.$cellEdit == true) {
  748. this.$set(row, "$cellEdit", false);
  749. } else {
  750. this.$set(row, "$cellEdit", true);
  751. }
  752. },
  753. itemTypeFocus(row) {
  754. this.itemtypeList = [];
  755. getSpecification({ goodId: row.itemId }).then(res => {
  756. const data = res.data.data;
  757. this.itemtypeList = data.map(item => ({ value: item }));
  758. });
  759. },
  760. priceChange(row) {
  761. const sum = _.multiply(
  762. _.add(
  763. Number(
  764. _.multiply(
  765. row.price ? row.price : 0,
  766. row.orderQuantity ? row.orderQuantity : 0
  767. )
  768. ),
  769. Number(
  770. _.add(
  771. Number(row.insurance ? row.insurance : 0),
  772. Number(row.freight ? row.freight : 0)
  773. )
  774. )
  775. ),
  776. _.divide(row.discount ? row.discount : 10, 10)
  777. );
  778. row.amount = Number(sum ? sum : 0).toFixed(2);
  779. let amountSum = 0;
  780. let purchaseAmountSum = 0;
  781. let grossProfitRate = 0;
  782. let grossProfit = 0;
  783. this.data.forEach(e => {
  784. amountSum = _.add(amountSum, Number(e.amount));
  785. purchaseAmountSum = _.add(
  786. purchaseAmountSum,
  787. Number(
  788. _.multiply(
  789. Number(e.purchaseAmount ? e.purchaseAmount : 0),
  790. Number(e.orderQuantity)
  791. )
  792. )
  793. );
  794. grossProfit = _.subtract(amountSum, purchaseAmountSum);
  795. grossProfitRate = _.multiply(
  796. _.divide(_.subtract(amountSum, purchaseAmountSum), amountSum),
  797. 100
  798. );
  799. this.form.grossProfit = Number(grossProfit ? grossProfit : 0).toFixed(
  800. 2
  801. );
  802. this.form.grossProfitRate = Number(
  803. grossProfitRate ? grossProfitRate : 0
  804. ).toFixed(2);
  805. });
  806. },
  807. discountChange(row) {
  808. if (row.discount >= 10) {
  809. row.discount = null;
  810. this.$message.error("请正确输入折扣");
  811. }
  812. this.priceChange(row);
  813. },
  814. taxRateChange(row) {
  815. if (row.taxRate > 100) {
  816. row.taxRate = 0;
  817. this.$message.error("请正确输入税率");
  818. }
  819. },
  820. grossProfitRateChange(row) {
  821. if (row >= 100) {
  822. this.form.grossProfitRate = 0;
  823. this.$message.error("毛利率不能超过100%");
  824. }
  825. },
  826. saveShipping() {
  827. if (!this.form.id) {
  828. return this.$message.error("此单据没有提交记录,请先提交");
  829. }
  830. this.$confirm("是否生成船务询价单?", {
  831. confirmButtonText: "确定",
  832. cancelButtonText: "取消",
  833. type: "warning"
  834. }).then(() => {
  835. saveShipping(this.form.id).then(res => {
  836. if (res.data.code == 200) {
  837. this.$message.success("生成成功");
  838. }
  839. });
  840. });
  841. },
  842. savePurchase() {
  843. if (!this.form.id) {
  844. return this.$message.error("此单据没有提交记录,请先提交");
  845. }
  846. this.$confirm("是否生成采购询价单?", {
  847. confirmButtonText: "确定",
  848. cancelButtonText: "取消",
  849. type: "warning"
  850. }).then(() => {
  851. savePurchase(this.form.id).then(res => {
  852. if (res.data.code == 200) {
  853. this.$message.success("生成成功");
  854. }
  855. });
  856. });
  857. },
  858. rowSave(row) {
  859. this.$set(row, "$cellEdit", false);
  860. },
  861. rowDel(row, index) {
  862. this.$confirm("确定删除数据?", {
  863. confirmButtonText: "确定",
  864. cancelButtonText: "取消",
  865. type: "warning"
  866. }).then(() => {
  867. if (row.id) {
  868. delItem(row.id).then(res => {
  869. this.$message({
  870. type: "success",
  871. message: "删除成功!"
  872. });
  873. this.data.splice(index, 1);
  874. });
  875. } else {
  876. this.$message({
  877. type: "success",
  878. message: "删除成功!"
  879. });
  880. this.data.splice(index, 1);
  881. }
  882. });
  883. },
  884. importGoods() {
  885. if (this.reData) {
  886. console.log(this.reData);
  887. if (this.selectionList.length != 1) {
  888. return this.$message.error("重新选择的时候只能选择一条数据");
  889. } else {
  890. this.selectionList.forEach(e => {
  891. this.data.forEach((item, index) => {
  892. if (index == this.reData.index) {
  893. item.itemId = e.id;
  894. item.code = e.code;
  895. item.cname = e.cname;
  896. item.priceCategory = e.goodsTypeName;
  897. item.itemUrl = e.url;
  898. item.itemProp = this.reData.itemProp;
  899. item.itemDescription = e.cnameDescription;
  900. item.itemType = this.reData.itemType;
  901. item.tradeTerms = this.reData.tradeTerms;
  902. item.price = this.reData.price;
  903. item.orderQuantity = this.reData.orderQuantity;
  904. item.insurance = this.reData.insurance;
  905. item.freight = this.reData.freight;
  906. item.discount = this.reData.discount;
  907. item.amount = this.reData.amount;
  908. item.taxRate = this.reData.taxRate;
  909. item.unit = e.unit;
  910. item.remarks = this.reData.remarks;
  911. item.$cellEdit = true;
  912. }
  913. });
  914. });
  915. }
  916. } else {
  917. this.selectionList.forEach(e => {
  918. this.data.push({
  919. itemId: e.id,
  920. code: e.code,
  921. cname: e.cname,
  922. priceCategory: e.goodsTypeName,
  923. itemUrl: e.url,
  924. itemProp: null,
  925. itemDescription: e.cnameDescription,
  926. itemType: null,
  927. tradeTerms: null,
  928. price: 0,
  929. orderQuantity: 0,
  930. insurance: 0,
  931. freight: 0,
  932. discount: null,
  933. amount: 0,
  934. taxRate: 0,
  935. unit: e.unit,
  936. remarks: null,
  937. $cellEdit: true
  938. });
  939. });
  940. }
  941. this.dialogVisible = false;
  942. },
  943. closeGoods() {
  944. this.selectionList = [];
  945. this.treeDeptId = "";
  946. this.reData = null;
  947. },
  948. selectionChange(list) {
  949. this.selectionList = list;
  950. },
  951. rowClick(row) {
  952. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  953. },
  954. nodeClick(data) {
  955. this.treeDeptId = data.id;
  956. this.page.currentPage = 1;
  957. this.onLoad(this.page);
  958. },
  959. //费用查询
  960. onLoad(page, params = {}) {
  961. this.loading = true;
  962. getGoods(page.currentPage, page.pageSize, this.treeDeptId)
  963. .then(res => {
  964. const data = res.data.data;
  965. this.page.total = data.total;
  966. this.goodsList = data.records;
  967. if (this.page.total) {
  968. this.goodsOption.height = window.innerHeight - 550;
  969. } else {
  970. this.goodsOption.height = window.innerHeight - 475;
  971. }
  972. })
  973. .finally(() => {
  974. this.loading = false;
  975. });
  976. },
  977. //商品明细导入
  978. newDetails() {
  979. this.dialogVisible = !this.dialogVisible;
  980. },
  981. getDetail(id) {
  982. detail(id).then(res => {
  983. this.form = res.data.data;
  984. this.data = res.data.data.orderItemsList;
  985. this.orderFeesList = res.data.data.orderFeesList;
  986. this.configuration.dicData = this.form.corpName;
  987. this.oldform = res.data.data;
  988. this.olddata = this.deepClone(res.data.data.orderItemsList);
  989. this.oldorderFeesList = this.deepClone(res.data.data.orderFeesList);
  990. });
  991. },
  992. //修改提交触发
  993. editCustomer(status) {
  994. this.$refs["form"].validate((valid, done) => {
  995. done();
  996. if (valid) {
  997. let orderFeesList = this.$refs.feeInfo.submitData();
  998. if (this.data.length > 0) {
  999. for (let i = 0; i < this.data.length; i++) {
  1000. if (this.data[i].corpId == null) {
  1001. return this.$message.error(`请输入第${i + 1}行的供应商`);
  1002. }
  1003. }
  1004. }
  1005. for (let i = 0; i < orderFeesList.length; i++) {
  1006. if (orderFeesList[i].corpId == null) {
  1007. return this.$message.error(`请输入第${i + 1}行的结算中心`);
  1008. }
  1009. if (orderFeesList[i].price == 0) {
  1010. return this.$message.error(`请正确输入第${i + 1}行的销售价`);
  1011. }
  1012. if (orderFeesList[i].orderQuantity == 0) {
  1013. return this.$message.error(`请正确输入第${i + 1}行的数量`);
  1014. }
  1015. }
  1016. this.subLoading = true;
  1017. submit({
  1018. ...this.form,
  1019. orderItemsList: this.data,
  1020. orderFeesList: orderFeesList
  1021. })
  1022. .then(res => {
  1023. if (res.data.code == 200) {
  1024. this.$message.success(this.form.id ? "修改成功" : "提交成功");
  1025. this.form = res.data.data;
  1026. this.data = res.data.data.orderItemsList;
  1027. this.orderFeesList = res.data.data.orderFeesList;
  1028. this.oldform = res.data.data;
  1029. this.olddata = this.deepClone(res.data.data.orderItemsList);
  1030. this.oldorderFeesList = this.deepClone(
  1031. res.data.data.orderFeesList
  1032. );
  1033. if (status == "goBack") {
  1034. this.$emit("goBack");
  1035. }
  1036. }
  1037. console.log("then");
  1038. })
  1039. .finally(() => {
  1040. console.log("finally");
  1041. this.subLoading = false;
  1042. });
  1043. } else {
  1044. return false;
  1045. }
  1046. });
  1047. },
  1048. //返回列表
  1049. backToList() {
  1050. let orderFeesList = this.$refs.feeInfo.submitData();
  1051. if (
  1052. contrastObj(this.form, this.oldform) ||
  1053. contrastList(this.data, this.olddata) ||
  1054. contrastList(orderFeesList, this.oldorderFeesList)
  1055. ) {
  1056. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  1057. confirmButtonText: "确定",
  1058. cancelButtonText: "取消",
  1059. type: "warning"
  1060. })
  1061. .then(() => {
  1062. this.editCustomer("goBack");
  1063. })
  1064. .catch(() => {
  1065. this.$emit("goBack");
  1066. });
  1067. } else {
  1068. this.$emit("goBack");
  1069. }
  1070. },
  1071. openReport() {
  1072. this.switchDialog = !this.switchDialog;
  1073. },
  1074. onClose(val) {
  1075. this.switchDialog = val;
  1076. },
  1077. summaryMethod({ columns, data }) {
  1078. const sums = [];
  1079. if (columns.length > 0) {
  1080. columns.forEach((item, index) => {
  1081. sums[0] = "合计";
  1082. if (
  1083. item.property == "orderQuantity" ||
  1084. item.property == "amount" ||
  1085. item.property == "insurance" ||
  1086. item.property == "freight"
  1087. ) {
  1088. let qtySum = 0;
  1089. let amountSum = 0;
  1090. let insuranceSum = 0;
  1091. let freightSum = 0;
  1092. data.forEach(e => {
  1093. qtySum = _.add(qtySum, Number(e.orderQuantity));
  1094. amountSum = _.add(amountSum, Number(e.amount));
  1095. insuranceSum = _.add(insuranceSum, Number(e.insurance));
  1096. freightSum = _.add(freightSum, Number(e.freight));
  1097. });
  1098. //数量总计
  1099. if (item.property == "orderQuantity") {
  1100. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  1101. }
  1102. //金额总计
  1103. if (item.property == "amount") {
  1104. sums[index] = micrometerFormat(amountSum);
  1105. }
  1106. //保险总计
  1107. if (item.property == "insurance") {
  1108. sums[index] = micrometerFormat(insuranceSum);
  1109. }
  1110. //运费总计
  1111. if (item.property == "freight") {
  1112. sums[index] = micrometerFormat(freightSum);
  1113. }
  1114. }
  1115. });
  1116. }
  1117. return sums;
  1118. },
  1119. async saveColumn() {
  1120. const inSave = await this.saveColumnData(
  1121. this.getColumnName(1),
  1122. this.tableOption
  1123. );
  1124. if (inSave) {
  1125. this.$message.success("保存成功");
  1126. //关闭窗口
  1127. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  1128. }
  1129. },
  1130. async saveGoodsColumn() {
  1131. const inSave = await this.saveColumnData(
  1132. this.getColumnName(26),
  1133. this.goodsOption
  1134. );
  1135. if (inSave) {
  1136. this.$message.success("保存成功");
  1137. //关闭窗口
  1138. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  1139. }
  1140. }
  1141. }
  1142. };
  1143. </script>
  1144. <style lang="scss" scoped>
  1145. .customer-head {
  1146. position: fixed;
  1147. top: 105px;
  1148. width: 100%;
  1149. margin-left: -10px;
  1150. height: 62px;
  1151. background: #ffffff;
  1152. box-shadow: 0 4px 12px 0px rgba(232, 232, 235, 1);
  1153. z-index: 999;
  1154. }
  1155. .customer-back {
  1156. cursor: pointer;
  1157. line-height: 62px;
  1158. font-size: 16px;
  1159. color: #323233;
  1160. font-weight: 400;
  1161. }
  1162. .back-icon {
  1163. line-height: 64px;
  1164. font-size: 20px;
  1165. margin-right: 8px;
  1166. }
  1167. .sell-customer-btn {
  1168. position: fixed;
  1169. right: 244px;
  1170. top: 115px;
  1171. }
  1172. .copy-customer-btn {
  1173. position: fixed;
  1174. right: 140px;
  1175. top: 115px;
  1176. }
  1177. .add-customer-btn {
  1178. position: fixed;
  1179. right: 36px;
  1180. top: 115px;
  1181. }
  1182. ::v-deep .el-form-item {
  1183. margin-bottom: 8px;
  1184. }
  1185. ::v-deep .el-form-item__error {
  1186. display: none;
  1187. }
  1188. ::v-deep .select-component {
  1189. display: flex;
  1190. }
  1191. </style>