detailsPage.vue 38 KB

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