detailsPage.vue 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  1. <template>
  2. <div class="borderless" v-loading="loading">
  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. <div class="add-customer-btn" v-if="showBut">
  15. <el-button type="info" @click="saveSell">生成销售单</el-button>
  16. <el-button type="success" disabled>
  17. 复制新单
  18. </el-button>
  19. <el-button
  20. type="primary"
  21. :disabled="disabled"
  22. @click="editCustomer"
  23. :loading="subLoading"
  24. v-if="detailData.status != 1"
  25. >{{ form.id ? "确认修改" : "确认新增" }}
  26. </el-button>
  27. </div>
  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. showBut: true
  672. };
  673. },
  674. props: {
  675. detailData: {
  676. type: Object
  677. }
  678. },
  679. components: {
  680. reportDialog,
  681. feeInfo,
  682. customerDialog
  683. },
  684. async created() {
  685. this.tableOption = await this.getColumnData(
  686. this.getColumnName(1),
  687. tableOption
  688. );
  689. this.goodsOption = await this.getColumnData(
  690. this.getColumnName(26),
  691. goodsOption
  692. );
  693. if (this.detailData.id) {
  694. this.getDetail(this.detailData.id);
  695. }
  696. if (this.detailData.status == 1) {
  697. this.option.disabled = true;
  698. }
  699. this.getWorkDicts("product_properties").then(res => {
  700. this.findObject(this.tableOption.column, "itemProp").dicData =
  701. res.data.data;
  702. });
  703. getPorts().then(res => {
  704. this.findObject(this.option.column, "portOfLoad").dicData = res.data;
  705. this.findObject(this.option.column, "portOfDestination").dicData =
  706. res.data;
  707. });
  708. },
  709. filters: {
  710. isDiscount(val) {
  711. return isDiscount(val);
  712. },
  713. isPercentage(val) {
  714. return isPercentage(val);
  715. },
  716. micrometerFormat(val) {
  717. return micrometerFormat(val);
  718. }
  719. },
  720. methods: {
  721. saveSell() {
  722. if (!this.form.id) {
  723. return this.$message.error("此单据没有提交记录,请先提交");
  724. }
  725. this.$confirm("是否生成销售单?", {
  726. confirmButtonText: "确定",
  727. cancelButtonText: "取消",
  728. type: "warning"
  729. }).then(() => {
  730. saveSell(this.form.id).then(res => {
  731. if (res.data.code == 200) {
  732. this.$message.success("生成成功");
  733. }
  734. });
  735. });
  736. },
  737. rePick(row, index) {
  738. this.reData = {
  739. ...row,
  740. index: index
  741. };
  742. this.newDetails();
  743. },
  744. getcorpId(row) {
  745. this.data[row.index].corpId = row.id;
  746. },
  747. rowCell(row, index) {
  748. if (row.$cellEdit == true) {
  749. this.$set(row, "$cellEdit", false);
  750. } else {
  751. this.$set(row, "$cellEdit", true);
  752. }
  753. },
  754. itemTypeFocus(row) {
  755. this.itemtypeList = [];
  756. getSpecification({ goodId: row.itemId }).then(res => {
  757. const data = res.data.data;
  758. this.itemtypeList = data.map(item => ({ value: item }));
  759. });
  760. },
  761. priceChange(row) {
  762. const sum = _.multiply(
  763. _.add(
  764. Number(
  765. _.multiply(
  766. row.price ? row.price : 0,
  767. row.orderQuantity ? row.orderQuantity : 0
  768. )
  769. ),
  770. Number(
  771. _.add(
  772. Number(row.insurance ? row.insurance : 0),
  773. Number(row.freight ? row.freight : 0)
  774. )
  775. )
  776. ),
  777. _.divide(row.discount ? row.discount : 10, 10)
  778. );
  779. row.amount = Number(sum ? sum : 0).toFixed(2);
  780. let amountSum = 0;
  781. let purchaseAmountSum = 0;
  782. let grossProfitRate = 0;
  783. let grossProfit = 0;
  784. this.data.forEach(e => {
  785. amountSum = _.add(amountSum, Number(e.amount));
  786. purchaseAmountSum = _.add(
  787. purchaseAmountSum,
  788. Number(
  789. _.multiply(
  790. Number(e.purchaseAmount ? e.purchaseAmount : 0),
  791. Number(e.orderQuantity)
  792. )
  793. )
  794. );
  795. grossProfit = _.subtract(amountSum, purchaseAmountSum);
  796. grossProfitRate = _.multiply(
  797. _.divide(_.subtract(amountSum, purchaseAmountSum), amountSum),
  798. 100
  799. );
  800. this.form.grossProfit = Number(grossProfit ? grossProfit : 0).toFixed(
  801. 2
  802. );
  803. this.form.grossProfitRate = Number(
  804. grossProfitRate ? grossProfitRate : 0
  805. ).toFixed(2);
  806. });
  807. },
  808. discountChange(row) {
  809. if (row.discount >= 10) {
  810. row.discount = null;
  811. this.$message.error("请正确输入折扣");
  812. }
  813. this.priceChange(row);
  814. },
  815. taxRateChange(row) {
  816. if (row.taxRate > 100) {
  817. row.taxRate = 0;
  818. this.$message.error("请正确输入税率");
  819. }
  820. },
  821. grossProfitRateChange(row) {
  822. if (row >= 100) {
  823. this.form.grossProfitRate = 0;
  824. this.$message.error("毛利率不能超过100%");
  825. }
  826. },
  827. saveShipping() {
  828. if (!this.form.id) {
  829. return this.$message.error("此单据没有提交记录,请先提交");
  830. }
  831. this.$confirm("是否生成船务询价单?", {
  832. confirmButtonText: "确定",
  833. cancelButtonText: "取消",
  834. type: "warning"
  835. }).then(() => {
  836. saveShipping(this.form.id).then(res => {
  837. if (res.data.code == 200) {
  838. this.$message.success("生成成功");
  839. }
  840. });
  841. });
  842. },
  843. savePurchase() {
  844. if (!this.form.id) {
  845. return this.$message.error("此单据没有提交记录,请先提交");
  846. }
  847. this.$confirm("是否生成采购询价单?", {
  848. confirmButtonText: "确定",
  849. cancelButtonText: "取消",
  850. type: "warning"
  851. }).then(() => {
  852. savePurchase(this.form.id).then(res => {
  853. if (res.data.code == 200) {
  854. this.$message.success("生成成功");
  855. }
  856. });
  857. });
  858. },
  859. rowSave(row) {
  860. this.$set(row, "$cellEdit", false);
  861. },
  862. rowDel(row, index) {
  863. this.$confirm("确定删除数据?", {
  864. confirmButtonText: "确定",
  865. cancelButtonText: "取消",
  866. type: "warning"
  867. }).then(() => {
  868. if (row.id) {
  869. delItem(row.id).then(res => {
  870. this.$message({
  871. type: "success",
  872. message: "删除成功!"
  873. });
  874. this.data.splice(index, 1);
  875. });
  876. } else {
  877. this.$message({
  878. type: "success",
  879. message: "删除成功!"
  880. });
  881. this.data.splice(index, 1);
  882. }
  883. });
  884. },
  885. importGoods() {
  886. if (this.reData) {
  887. console.log(this.reData);
  888. if (this.selectionList.length != 1) {
  889. return this.$message.error("重新选择的时候只能选择一条数据");
  890. } else {
  891. this.selectionList.forEach(e => {
  892. this.data.forEach((item, index) => {
  893. if (index == this.reData.index) {
  894. item.itemId = e.id;
  895. item.code = e.code;
  896. item.cname = e.cname;
  897. item.priceCategory = e.goodsTypeName;
  898. item.itemUrl = e.url;
  899. item.itemProp = this.reData.itemProp;
  900. item.itemDescription = e.cnameDescription;
  901. item.itemType = this.reData.itemType;
  902. item.tradeTerms = this.reData.tradeTerms;
  903. item.price = this.reData.price;
  904. item.orderQuantity = this.reData.orderQuantity;
  905. item.insurance = this.reData.insurance;
  906. item.freight = this.reData.freight;
  907. item.discount = this.reData.discount;
  908. item.amount = this.reData.amount;
  909. item.taxRate = this.reData.taxRate;
  910. item.unit = e.unit;
  911. item.remarks = this.reData.remarks;
  912. item.$cellEdit = true;
  913. }
  914. });
  915. });
  916. }
  917. } else {
  918. this.selectionList.forEach(e => {
  919. this.data.push({
  920. itemId: e.id,
  921. code: e.code,
  922. cname: e.cname,
  923. priceCategory: e.goodsTypeName,
  924. itemUrl: e.url,
  925. itemProp: null,
  926. itemDescription: e.cnameDescription,
  927. itemType: null,
  928. tradeTerms: null,
  929. price: 0,
  930. orderQuantity: 0,
  931. insurance: 0,
  932. freight: 0,
  933. discount: null,
  934. amount: 0,
  935. taxRate: 0,
  936. unit: e.unit,
  937. remarks: null,
  938. $cellEdit: true
  939. });
  940. });
  941. }
  942. this.dialogVisible = false;
  943. },
  944. closeGoods() {
  945. this.selectionList = [];
  946. this.treeDeptId = "";
  947. this.reData = null;
  948. },
  949. selectionChange(list) {
  950. this.selectionList = list;
  951. },
  952. rowClick(row) {
  953. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  954. },
  955. nodeClick(data) {
  956. this.treeDeptId = data.id;
  957. this.page.currentPage = 1;
  958. this.onLoad(this.page);
  959. },
  960. //费用查询
  961. onLoad(page, params = {}) {
  962. this.loading = true;
  963. getGoods(page.currentPage, page.pageSize, this.treeDeptId)
  964. .then(res => {
  965. const data = res.data.data;
  966. this.page.total = data.total;
  967. this.goodsList = data.records;
  968. if (this.page.total) {
  969. this.goodsOption.height = window.innerHeight - 550;
  970. } else {
  971. this.goodsOption.height = window.innerHeight - 475;
  972. }
  973. })
  974. .finally(() => {
  975. this.loading = false;
  976. });
  977. },
  978. //商品明细导入
  979. newDetails() {
  980. this.dialogVisible = !this.dialogVisible;
  981. },
  982. getDetail(id) {
  983. this.loading = true;
  984. this.showBut = false;
  985. detail(id)
  986. .then(res => {
  987. this.form = res.data.data;
  988. this.data = res.data.data.orderItemsList;
  989. this.orderFeesList = res.data.data.orderFeesList;
  990. this.configuration.dicData = this.form.corpName;
  991. this.oldform = res.data.data;
  992. this.olddata = this.deepClone(res.data.data.orderItemsList);
  993. this.oldorderFeesList = this.deepClone(res.data.data.orderFeesList);
  994. })
  995. .finally(() => {
  996. this.loading = false;
  997. this.showBut = true;
  998. });
  999. },
  1000. //修改提交触发
  1001. editCustomer(status) {
  1002. this.$refs["form"].validate((valid, done) => {
  1003. done();
  1004. if (valid) {
  1005. let orderFeesList = this.$refs.feeInfo.submitData();
  1006. if (this.data.length > 0) {
  1007. for (let i = 0; i < this.data.length; i++) {
  1008. if (this.data[i].corpId == null) {
  1009. return this.$message.error(`请输入第${i + 1}行的供应商`);
  1010. }
  1011. }
  1012. }
  1013. for (let i = 0; i < orderFeesList.length; i++) {
  1014. if (orderFeesList[i].corpId == null) {
  1015. return this.$message.error(`请输入第${i + 1}行的结算中心`);
  1016. }
  1017. if (orderFeesList[i].price == 0) {
  1018. return this.$message.error(`请正确输入第${i + 1}行的销售价`);
  1019. }
  1020. if (orderFeesList[i].orderQuantity == 0) {
  1021. return this.$message.error(`请正确输入第${i + 1}行的数量`);
  1022. }
  1023. }
  1024. this.subLoading = true;
  1025. submit({
  1026. ...this.form,
  1027. orderItemsList: this.data,
  1028. orderFeesList: orderFeesList
  1029. })
  1030. .then(res => {
  1031. if (res.data.code == 200) {
  1032. this.$message.success(this.form.id ? "修改成功" : "提交成功");
  1033. this.form = res.data.data;
  1034. this.data = res.data.data.orderItemsList;
  1035. this.orderFeesList = res.data.data.orderFeesList;
  1036. this.oldform = res.data.data;
  1037. this.olddata = this.deepClone(res.data.data.orderItemsList);
  1038. this.oldorderFeesList = this.deepClone(
  1039. res.data.data.orderFeesList
  1040. );
  1041. if (status == "goBack") {
  1042. this.$emit("goBack");
  1043. }
  1044. }
  1045. })
  1046. .finally(() => {
  1047. this.subLoading = false;
  1048. });
  1049. } else {
  1050. return false;
  1051. }
  1052. });
  1053. },
  1054. //返回列表
  1055. backToList() {
  1056. let orderFeesList = this.$refs.feeInfo.submitData();
  1057. if (
  1058. contrastObj(this.form, this.oldform) ||
  1059. contrastList(this.data, this.olddata) ||
  1060. contrastList(orderFeesList, this.oldorderFeesList)
  1061. ) {
  1062. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  1063. confirmButtonText: "确定",
  1064. cancelButtonText: "取消",
  1065. type: "warning"
  1066. })
  1067. .then(() => {
  1068. this.editCustomer("goBack");
  1069. })
  1070. .catch(() => {
  1071. this.$emit("goBack");
  1072. });
  1073. } else {
  1074. this.$emit("goBack");
  1075. }
  1076. },
  1077. openReport() {
  1078. this.switchDialog = !this.switchDialog;
  1079. },
  1080. onClose(val) {
  1081. this.switchDialog = val;
  1082. },
  1083. summaryMethod({ columns, data }) {
  1084. const sums = [];
  1085. if (columns.length > 0) {
  1086. columns.forEach((item, index) => {
  1087. sums[0] = "合计";
  1088. if (
  1089. item.property == "orderQuantity" ||
  1090. item.property == "amount" ||
  1091. item.property == "insurance" ||
  1092. item.property == "freight"
  1093. ) {
  1094. let qtySum = 0;
  1095. let amountSum = 0;
  1096. let insuranceSum = 0;
  1097. let freightSum = 0;
  1098. data.forEach(e => {
  1099. qtySum = _.add(qtySum, Number(e.orderQuantity));
  1100. amountSum = _.add(amountSum, Number(e.amount));
  1101. insuranceSum = _.add(insuranceSum, Number(e.insurance));
  1102. freightSum = _.add(freightSum, Number(e.freight));
  1103. });
  1104. //数量总计
  1105. if (item.property == "orderQuantity") {
  1106. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  1107. }
  1108. //金额总计
  1109. if (item.property == "amount") {
  1110. sums[index] = micrometerFormat(amountSum);
  1111. }
  1112. //保险总计
  1113. if (item.property == "insurance") {
  1114. sums[index] = micrometerFormat(insuranceSum);
  1115. }
  1116. //运费总计
  1117. if (item.property == "freight") {
  1118. sums[index] = micrometerFormat(freightSum);
  1119. }
  1120. }
  1121. });
  1122. }
  1123. return sums;
  1124. },
  1125. async saveColumn() {
  1126. const inSave = await this.saveColumnData(
  1127. this.getColumnName(1),
  1128. this.tableOption
  1129. );
  1130. if (inSave) {
  1131. this.$message.success("保存成功");
  1132. //关闭窗口
  1133. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  1134. }
  1135. },
  1136. async saveGoodsColumn() {
  1137. const inSave = await this.saveColumnData(
  1138. this.getColumnName(26),
  1139. this.goodsOption
  1140. );
  1141. if (inSave) {
  1142. this.$message.success("保存成功");
  1143. //关闭窗口
  1144. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  1145. }
  1146. }
  1147. }
  1148. };
  1149. </script>
  1150. <style lang="scss" scoped>
  1151. .customer-head {
  1152. position: fixed;
  1153. top: 105px;
  1154. width: 100%;
  1155. margin-left: -10px;
  1156. height: 62px;
  1157. background: #ffffff;
  1158. box-shadow: 0 4px 12px 0px rgba(232, 232, 235, 1);
  1159. z-index: 999;
  1160. }
  1161. .customer-back {
  1162. cursor: pointer;
  1163. line-height: 62px;
  1164. font-size: 16px;
  1165. color: #323233;
  1166. font-weight: 400;
  1167. }
  1168. .back-icon {
  1169. line-height: 64px;
  1170. font-size: 20px;
  1171. margin-right: 8px;
  1172. }
  1173. .sell-customer-btn {
  1174. position: fixed;
  1175. right: 244px;
  1176. top: 115px;
  1177. }
  1178. .copy-customer-btn {
  1179. position: fixed;
  1180. right: 140px;
  1181. top: 115px;
  1182. }
  1183. .add-customer-btn {
  1184. position: fixed;
  1185. right: 36px;
  1186. top: 115px;
  1187. }
  1188. ::v-deep .el-form-item {
  1189. margin-bottom: 8px;
  1190. }
  1191. ::v-deep .el-form-item__error {
  1192. display: none;
  1193. }
  1194. ::v-deep .select-component {
  1195. display: flex;
  1196. }
  1197. </style>