detailsPage.vue 75 KB

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