detailsPage.vue 35 KB

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