detailsPage.vue 50 KB

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