detailsPage.vue 34 KB

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