detailsPage.vue 61 KB

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