detailsPage.vue 63 KB

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