detailsPage.vue 73 KB

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