detailsPage.vue 62 KB

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