detailsPage.vue 39 KB

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