detailsPage.vue 39 KB

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