detailsPage.vue 43 KB

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