detailsPage.vue 63 KB

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