detailsPage.vue 62 KB

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