detailsPage.vue 73 KB

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