detailsPage.vue 79 KB

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