goodsInfo.vue 80 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714
  1. <template>
  2. <trade-card title="商品信息">
  3. <avue-crud ref="crud" :data="data" :option="tableOption" @row-del="rowDel" :summary-method="summaryMethod"
  4. @saveColumn="saveColumn" @resetColumn="resetColumn" :cell-style="cellStyle" v-model="goodsForm"
  5. :before-close="beforeClose" @row-save="handleRowSave" @row-update="handleRowUpdate">
  6. <template slot="menuLeft">
  7. <el-row>
  8. <!-- <el-button type="primary" icon="el-icon-plus" size="small" @click.stop="addGoods"
  9. :disabled="detailData.status == 1">导入商品</el-button> -->
  10. <!-- <el-button type="primary" icon="el-icon-plus" size="small" @click.stop="addLibrary"
  11. :disabled="detailData.status == 1">出口价格库</el-button> -->
  12. <el-button type="primary" icon="el-icon-printer" size="small" @click.stop="openReport()">报表打印
  13. </el-button>
  14. <el-button type="warning" size="small" @click.stop="savePurchase"
  15. :disabled="detailData.status == 1">
  16. 采购询价
  17. </el-button>
  18. <el-button type="warning" size="small" @click.stop="saveShipping"
  19. :disabled="detailData.status == 1">
  20. 船务询价
  21. </el-button>
  22. <el-button type="warning" size="small" @click="cnameData">刷新基础资料</el-button>
  23. <el-button type="success" size="small" @click="calculate(1)" :disabled="detailData.status == 1"
  24. :loading="calculateLoading">分摊国内费用
  25. </el-button>
  26. <el-button type="success" size="small" @click="calculate(2)" :disabled="detailData.status == 1"
  27. :loading="calculateLoading">分摊海运费到单价
  28. </el-button>
  29. <el-button type="success" size="small" @click="oceanUSD" :disabled="detailData.status == 1">海运费单列
  30. </el-button>
  31. <!-- <el-popover placement="top" width="160" v-model="visible">
  32. <div style="text-align: center;">
  33. <el-input-number v-model="priceAD" size="small" :controls="false"></el-input-number> %
  34. </div>
  35. <div style="text-align: right; margin: 0">
  36. <el-button size="mini" type="text" @click="visible = false">取消</el-button>
  37. <el-button size="mini" type="text" @click="submitPriceAD">确定</el-button>
  38. </div>
  39. <el-button type="success" size="small" slot="reference"
  40. :disabled="detailData.status == 1">调整出厂价</el-button>
  41. </el-popover> -->
  42. <el-button type="success" size="small" @click="inPriceAD"
  43. :disabled="detailData.status == 1">调整出厂价</el-button>
  44. </el-row>
  45. </template>
  46. <template slot="headerSerial">
  47. <el-button type="primary" icon="el-icon-plus" size="mini" @click.stop="addRow"
  48. :disabled="detailData.status == 1" circle></el-button>
  49. </template>
  50. <template slot="codeHeader" slot-scope="{column}">
  51. <span style="color: #409EFF;cursor: pointer" @click.stop="khEdit('cname')">{{ column.label }}</span>
  52. </template>
  53. <template slot="orderQuantity" slot-scope="{row}">
  54. {{ row.orderQuantity | decimalFormat2 }}
  55. </template>
  56. <template slot="amount" slot-scope="{row}">
  57. {{ row.amount | decimalFormat2 }}
  58. </template>
  59. <template slot="partsCost" slot-scope="{row}">
  60. {{ row.partsCost | decimalFormat2 }}
  61. </template>
  62. <template slot="partsPrice" slot-scope="{row}">
  63. {{ row.partsPrice | decimalFormat2 }}
  64. </template>
  65. <template slot="productPrice" slot-scope="{row}">
  66. {{ row.productPrice | decimalFormat2 }}
  67. </template>
  68. <template slot="outFactoryPrice" slot-scope="{row}">
  69. {{ row.outFactoryPrice }}
  70. </template>
  71. <template slot="shareAmount" slot-scope="{row}">
  72. {{ row.shareAmount | decimalFormat2 }}
  73. </template>
  74. <template slot="internationalAmount" slot-scope="{row}">
  75. {{ row.internationalAmount | decimalFormat2 }}
  76. </template>
  77. <template slot="price" slot-scope="{row}">
  78. {{ row.price | decimalFormat2 }}
  79. </template>
  80. <template slot="purchaseCost" slot-scope="{row}">
  81. {{ row.purchaseCost | decimalFormat2 }}
  82. </template>
  83. <template slot="purchaseAmount" slot-scope="{row}">
  84. {{ row.purchaseAmount | decimalFormat2 }}
  85. </template>
  86. //操作栏
  87. <template slot="menu" slot-scope="{ row, index }">
  88. <div style="display:flex;justify-content: center;">
  89. <el-button size="small" icon="el-icon-edit" type="text" @click="rowCell(row, index)"
  90. :disabled="disabled || detailData.status == 1">{{ row.$cellEdit ? "保存" : "修改" }}
  91. </el-button>
  92. <el-button size="small" icon="el-icon-delete" type="text" @click="rowDel(row, index)"
  93. :disabled="detailData.status == 1">删除</el-button>
  94. <div v-if="!goodsEditShow"
  95. style="display:flex;flex-direction: column;justify-content: center;margin-left: 10px;">
  96. <el-tooltip effect="dark" content="向上移动" placement="top">
  97. <i v-if="index != 0" :disabled="detailData.status == 1" class="el-icon-arrow-up"
  98. @click="moveUp(row, index)" style="color:#409EFF;"></i>
  99. </el-tooltip>
  100. <el-tooltip effect="dark" content="向下移动" placement="bottom"> <i
  101. v-if="index != (data.length - 1)" :disabled="detailData.status == 1"
  102. class="el-icon-arrow-down" @click="moveDown(row, index)" style="color:#409EFF;"></i>
  103. </el-tooltip>
  104. </div>
  105. </div>
  106. </template>
  107. //产品名称
  108. <template slot="cnameForm" slot-scope="{type,disabled}">
  109. <span style="display:flex">
  110. <!-- <el-select v-model="goodsForm.itemId" placeholder="请选择" size="small" filterable
  111. @change="cnameChange(goodsForm)">
  112. <el-option v-for="item in goodsoptions" :key="item.itemId" :label="item.cname"
  113. :value="item.itemId">
  114. </el-option>
  115. </el-select> -->
  116. <dic-select v-model="goodsForm.cname" placeholder="产品名称" key="id" label="cname" res="records"
  117. :url="'/blade-mocha-item/pricebank/pageListAllV1?billType=CG&statusTime=' + statusTime"
  118. :filterable="true" :remote="true" dataName="cname"
  119. @selectChange="cnameChange('cname', $event)"></dic-select>
  120. <el-button icon="el-icon-search" size="small" @click="pickGoods"></el-button>
  121. </span>
  122. </template>
  123. //螺纹
  124. <template slot="remarksOneForm" slot-scope="{type,disabled}">
  125. <el-select v-model="goodsForm.remarksOne" placeholder="请选择" size="small" :disabled="disabled"
  126. @change="propsChange(goodsForm)">
  127. <el-option v-for="item in ThreadList" :key="item.id" :label="item.dictValue"
  128. :value="item.dictValue">
  129. </el-option>
  130. </el-select>
  131. </template>
  132. //介质
  133. <template slot="customTwoForm" slot-scope="{type,disabled}">
  134. <el-select v-model="goodsForm.customTwo" placeholder="请选择" size="small" :disabled="disabled"
  135. @change="propsChange(goodsForm)">
  136. <el-option v-for="item in mediumList" :key="item.id" :label="item.dictValue"
  137. :value="item.dictValue">
  138. </el-option>
  139. </el-select>
  140. </template>
  141. //颜色
  142. <template slot="customThreeForm" slot-scope="{type,disabled}">
  143. <el-select v-model="goodsForm.customThree" placeholder="请选择" size="small" :disabled="disabled"
  144. @change="propsChange(goodsForm)">
  145. <el-option v-for="item in colorList" :key="item.id" :label="item.dictValue" :value="item.dictValue">
  146. </el-option>
  147. </el-select>
  148. </template>
  149. //电压
  150. <template slot="customFourForm" slot-scope="{type,disabled}">
  151. <el-select v-model="goodsForm.customFour" placeholder="请选择" size="small" :disabled="disabled"
  152. @change="propsChange(goodsForm)">
  153. <el-option v-for="item in stencilList" :key="item.id" :label="item.dictValue"
  154. :value="item.dictValue">
  155. </el-option>
  156. </el-select>
  157. </template>
  158. //产品属性
  159. <template slot="itemPropForm" slot-scope="{type,disabled}">
  160. <el-input type="textarea" :rows="2" v-model="goodsForm.itemProp" size="small" placeholder=""
  161. @change="editChange(goodsForm)">
  162. </el-input>
  163. </template>
  164. //阀门配件
  165. <template slot="partsValveNameForm" slot-scope="{type,disabled}">
  166. <div style="display:flex;">
  167. <el-input v-model="goodsForm.partsValveName" size="small" placeholder="" :disabled="disabled">
  168. <template slot="append">{{ goodsForm.partsValveSalePrice ? goodsForm.partsValveSalePrice : 0
  169. }}</template>
  170. </el-input>
  171. <el-button icon="el-icon-edit" size="mini" @click="openpart(0, goodsForm.partsValveValue)"
  172. :disabled="disabled"></el-button>
  173. </div>
  174. </template>
  175. //瓶帽配件
  176. <template slot="partsCapNameForm" slot-scope="{type,disabled}">
  177. <div style="display:flex;">
  178. <el-input v-model="goodsForm.partsCapName" size="small" placeholder="" :disabled="disabled">
  179. <template slot="append">{{ goodsForm.partsCapSalePrice ? goodsForm.partsCapSalePrice : 0
  180. }}</template>
  181. </el-input>
  182. <el-button icon="el-icon-edit" size="mini" @click="openpart(1, goodsForm.partsCapValue)"
  183. :disabled="disabled"></el-button>
  184. </div>
  185. </template>
  186. //特殊处理
  187. <template slot="partsHandleNameForm" slot-scope="{type,disabled}">
  188. <div style="display:flex;">
  189. <el-input v-model="goodsForm.partsHandleName" size="small" placeholder="" :disabled="disabled">
  190. <template slot="append">{{ goodsForm.partsHandleSalePrice ? goodsForm.partsHandleSalePrice : 0
  191. }}</template>
  192. </el-input>
  193. <el-button icon="el-icon-edit" size="mini" @click="openpart(2, goodsForm.partsHandleValue)"
  194. :disabled="disabled"></el-button>
  195. </div>
  196. </template>
  197. //包装方式
  198. <template slot="partsColourNameForm" slot-scope="{type,disabled}">
  199. <div style="display:flex;">
  200. <el-input v-model="goodsForm.partsColourName" size="small" placeholder="" :disabled="disabled">
  201. <template slot="append">{{ goodsForm.partsColourSalePrice ? goodsForm.partsColourSalePrice : 0
  202. }}</template>
  203. </el-input>
  204. <el-button icon="el-icon-edit" size="mini" @click="openpart(3, goodsForm.partsColourValue)"
  205. :disabled="disabled"></el-button>
  206. </div>
  207. </template>
  208. //特殊颜色
  209. <template slot="partsModeNameForm" slot-scope="{type,disabled}">
  210. <div style="display:flex;">
  211. <el-input v-model="goodsForm.partsModeName" size="small" placeholder="" :disabled="disabled">
  212. <template slot="append">{{ goodsForm.partsModeSalePrice ? goodsForm.partsModeSalePrice : 0
  213. }}</template>
  214. </el-input>
  215. <el-button icon="el-icon-edit" size="mini" @click="openpart(4, goodsForm.partsModeValue)"
  216. :disabled="disabled"></el-button>
  217. </div>
  218. </template>
  219. //认证
  220. <template slot="partsAuthenticationNameForm" slot-scope="{type,disabled}">
  221. <div style="display:flex;">
  222. <el-input v-model="goodsForm.partsAuthenticationName" size="small" placeholder=""
  223. :disabled="disabled">
  224. <template slot="append">{{ goodsForm.partsAuthenticationSalePrice ?
  225. goodsForm.partsAuthenticationSalePrice : 0
  226. }}</template>
  227. </el-input>
  228. <el-button icon="el-icon-edit" size="mini" @click="openpart(5, goodsForm.partsAuthenticationValue)"
  229. :disabled="disabled">
  230. </el-button>
  231. </div>
  232. </template>
  233. //其他
  234. <template slot="partsOtherNameForm" slot-scope="{type,disabled}">
  235. <div style="display:flex;">
  236. <el-input v-model="goodsForm.partsOtherName" size="small" placeholder="" :disabled="disabled">
  237. <template slot="append">{{ goodsForm.partsOtherSalePrice ? goodsForm.partsOtherSalePrice : 0
  238. }}</template>
  239. </el-input>
  240. <el-button icon="el-icon-edit" size="mini" @click="openpart(6, goodsForm.partsOtherValue)"
  241. :disabled="disabled"></el-button>
  242. </div>
  243. </template>
  244. //配件信息
  245. <template slot="partsDescribeForm" slot-scope="{type,disabled}">
  246. <el-input type="textarea" :rows="2" v-model="goodsForm.partsDescribe" size="small" placeholder=""
  247. @change="editChange(goodsForm)">
  248. </el-input>
  249. </template>
  250. //英文名称
  251. <template slot="enameForm" slot-scope="{type,disabled}">
  252. <el-input type="textarea" :rows="2" v-model="goodsForm.ename" size="small" placeholder="请点击右边按钮"
  253. @change="editChange(goodsForm)"></el-input>
  254. </template>
  255. //产品描述
  256. <template slot="itemDescriptionForm" slot-scope="{type,disabled}">
  257. <el-input type="textarea" :rows="2" v-model="goodsForm.itemDescription" size="small" placeholder="请输入"
  258. @change="editChange(goodsForm)">
  259. </el-input>
  260. </template>
  261. //采购单价
  262. <template slot="purchaseAmountForm" slot-scope="{type,disabled}">
  263. <el-input v-model="goodsForm.purchaseAmount" size="small" placeholder="请输入"
  264. @change="purchaseAmountChange(goodsForm)" :disabled="disabled"></el-input>
  265. </template>
  266. //出厂费用
  267. <template slot="outFactoryPriceForm" slot-scope="{type,disabled}">
  268. <el-input v-model="goodsForm.outFactoryPrice" size="small"
  269. oninput="value=value.replace(/[^0-9.]/g,'').replace(/^(\-)*(\d+)\.(\d\d\d).*$/,'$1$2.$3')"
  270. @change="priceChange(goodsForm)"></el-input>
  271. </template>
  272. //分摊金额
  273. <template slot="shareAmountForm" slot-scope="{type,disabled}">
  274. <el-input-number v-model="goodsForm.shareAmount" size="small" style="width:100%"
  275. @change="priceChange(goodsForm)" :controls="false" :precision="10"></el-input-number>
  276. </template>
  277. //分摊金额
  278. <template slot="internationalAmountForm" slot-scope="{type,disabled}">
  279. <el-input-number v-model="goodsForm.internationalAmount" size="small" style="width:100%"
  280. @change="priceChange(goodsForm)" :controls="false" :precision="10"></el-input-number>
  281. </template>
  282. //单价
  283. <template slot="priceForm" slot-scope="{type,disabled}">
  284. <el-input v-model="goodsForm.price" size="small"
  285. oninput="value=value.replace(/[^0-9.]/g,'').replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')"
  286. @change="priceChange(goodsForm)"></el-input>
  287. </template>
  288. //数量
  289. <template slot="orderQuantityForm" slot-scope="{type,disabled}">
  290. <el-input v-model="goodsForm.orderQuantity" size="small"
  291. oninput='this.value=this.value.replace(/[^\d.]/g,"")' @change="priceChange(goodsForm)">
  292. </el-input>
  293. </template>
  294. //折扣
  295. <template slot="discountForm" slot-scope="{type,disabled}">
  296. <el-input v-model="goodsForm.discount" size="small"
  297. oninput="value=value.replace(/[^0-9.]/g,'').replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')"
  298. @change="discountChange(goodsForm)"></el-input>
  299. </template>
  300. //税率
  301. <template slot="taxRateForm" slot-scope="{type,disabled}">
  302. <el-input v-model="goodsForm.taxRate" size="small"
  303. oninput="value=value.replace(/[^0-9.]/g,'').replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')"
  304. @change="taxRateChange(goodsForm)"></el-input>
  305. </template>
  306. //产品型号
  307. <template slot="itemTypeForm" slot-scope="{type,disabled}">
  308. <el-input v-model="goodsForm.itemType" placeholder="请输入内容"></el-input>
  309. <!-- <el-select v-model="goodsForm.itemType" filterable allow-create default-first-option placeholder="请输入"-->
  310. <!-- size="small" @focus="itemTypeFocus(goodsForm)">-->
  311. <!-- <el-option v-for="(item, index) in itemtypeList" :key="index" :label="item.value"-->
  312. <!-- :value="item.value">-->
  313. <!-- </el-option>-->
  314. <!-- </el-select>-->
  315. </template>
  316. </avue-crud>
  317. <!-- <el-dialog title="导入商品" append-to-body class="el-dialogDeep" :visible.sync="dialogVisible" width="80%"
  318. :close-on-click-modal="false" :destroy-on-close="true" :close-on-press-escape="false" @close="closeGoods"
  319. top="5vh" v-dialog-drag>
  320. <span>
  321. <el-row>
  322. <el-col :span="4">
  323. <div>
  324. <el-scrollbar>
  325. <basic-container>
  326. <avue-tree :option="treeOption" @node-click="nodeClick" :style="treeStyle" />
  327. </basic-container>
  328. </el-scrollbar>
  329. </div>
  330. </el-col>
  331. <el-col :span="20">
  332. <avue-crud :option="goodsOption" :table-loading="loading" :data="goodsList" ref="goodsCrud"
  333. :search.sync="search" @search-change="searchChange" @refresh-change="refreshChange"
  334. @selection-change="selectionChange" @row-click="rowClick" :page.sync="page"
  335. @on-load="onLoad" @saveColumn="saveGoodsColumn" @resetColumn="resetGoodsColumn"
  336. :cell-style="cellStyle"></avue-crud>
  337. </el-col>
  338. </el-row>
  339. </span>
  340. <span slot="footer" class="dialog-footer">
  341. <el-button @click="dialogVisible = false">取 消</el-button>
  342. <el-button type="primary" @click="importGoods" :disabled="selectionList.length !=1">导入</el-button>
  343. </span>
  344. </el-dialog> -->
  345. <report-dialog :switchDialog="switchDialog" :reportId="form.id" reportName="报价单明细(E)" @onClose="onClose()">
  346. </report-dialog>
  347. <part-library ref="partLibrary" @importPart="importPart"></part-library>
  348. <price-library ref="library" @importLibray="importLibray" />
  349. </trade-card>
  350. </template>
  351. <script>
  352. import goodsOption from "../config/commodity.json";
  353. import tableOption from "../config/customerContact.json";
  354. import reportDialog from "@/components/report-dialog/main";
  355. import partLibrary from "@/components/part-library/main";
  356. import priceLibrary from "@/components/price-Library/main";
  357. import propertyDialog from "@/components/property-dialog/main";
  358. import dicSelect from "@/components/dicSelect/main";
  359. import { dateFormat } from "@/util/date";
  360. import {
  361. delItem,
  362. getDeptLazyTree,
  363. getGoods,
  364. savePurchase,
  365. saveShipping,
  366. getSpecification,
  367. getPricebank,
  368. calculationDomesticFees, getPricebankAll
  369. } from "@/api/basicData/customerInquiry";
  370. import {
  371. sum,
  372. multiply,
  373. partSum,
  374. productCal,
  375. sellingCal,
  376. amountCal,
  377. grossProfitCal,
  378. goodsGrossProfitCal,
  379. costCal,
  380. addPrice,
  381. divide,
  382. priceaAjustment
  383. } from "@/util/calculate";
  384. import { micrometerFormat2, decimalFormat2 } from "@/util/validate";
  385. import _ from "lodash";
  386. export default {
  387. name: "customerInformation",
  388. data() {
  389. return {
  390. statusTime: dateFormat(new Date(), "yyyy-MM-dd"),
  391. priceAD: 0,
  392. visible: false,
  393. calculateLoading: false,
  394. switchDialog: false,
  395. loading: false,
  396. itemtypeList: [],
  397. goodsForm: {},
  398. tableOption: {},
  399. goodsoptions: [],
  400. partList: [],
  401. ThreadList: [],
  402. mediumList: [],
  403. colorList: [],
  404. stencilList: [],
  405. selectionList: [],
  406. dialogVisible: false,
  407. treeDeptId: null,
  408. treeStyle: "height:" + (window.innerHeight - 315) + "px",
  409. goodsOption: {},
  410. goodsList: [],
  411. page: {
  412. pageSize: 10,
  413. currentPage: 1,
  414. total: 0
  415. },
  416. treeOption: {
  417. nodeKey: "id",
  418. lazy: true,
  419. treeLoad: function (node, resolve) {
  420. const parentId = node.level === 0 ? 0 : node.data.id;
  421. getDeptLazyTree(parentId).then(res => {
  422. resolve(
  423. res.data.data.map(item => {
  424. return {
  425. ...item,
  426. leaf: !item.hasChildren
  427. };
  428. })
  429. );
  430. });
  431. },
  432. addBtn: false,
  433. menu: false,
  434. size: "small",
  435. props: {
  436. label: "title",
  437. value: "value",
  438. children: "children"
  439. }
  440. },
  441. };
  442. },
  443. props: {
  444. data: {
  445. type: Array
  446. },
  447. detailData: {
  448. type: Object
  449. },
  450. form: {
  451. type: Object
  452. },
  453. orderFeesList: {
  454. type: Array
  455. }
  456. },
  457. components: {
  458. partLibrary,
  459. propertyDialog,
  460. priceLibrary,
  461. reportDialog,
  462. dicSelect
  463. },
  464. filters: {
  465. decimalFormat2(num) {
  466. return decimalFormat2(num);
  467. }
  468. },
  469. async created() {
  470. this.tableOption = await this.getColumnData(
  471. this.getColumnName(1),
  472. tableOption
  473. );
  474. this.goodsOption = await this.getColumnData(
  475. this.getColumnName(26),
  476. goodsOption
  477. );
  478. if (localStorage.getItem("roleName").indexOf('贸易') == -1 && localStorage.getItem("roleName").indexOf('运营') == -1) {
  479. this.findObject(this.tableOption.column, "purchaseCost").hide = false;
  480. this.findObject(this.tableOption.column, "purchaseCost").showColumn = true;
  481. this.findObject(this.tableOption.column, "partsPrice").hide = false;
  482. this.findObject(this.tableOption.column, "partsPrice").showColumn = true;
  483. this.findObject(this.tableOption.column, "partsCost").hide = false;
  484. this.findObject(this.tableOption.column, "partsCost").showColumn = true;
  485. this.findObject(this.tableOption.column, "purchaseAmount").hide = false;
  486. this.findObject(this.tableOption.column, "purchaseAmount").showColumn = true;
  487. this.findObject(this.tableOption.column, "corpName").hide = false;
  488. this.findObject(this.tableOption.column, "corpName").showColumn = true;
  489. this.findObject(this.tableOption.column, "productPrice").hide = false;
  490. this.findObject(this.tableOption.column, "productPrice").showColumn = true;
  491. this.findObject(this.tableOption.column, "productPrice").display = true;
  492. }
  493. this.getWorkDicts("Thread").then(res => {
  494. this.ThreadList = res.data.data;
  495. });
  496. this.getWorkDicts("medium").then(res => {
  497. this.mediumList = res.data.data;
  498. });
  499. this.getWorkDicts("property_color").then(res => {
  500. this.colorList = res.data.data;
  501. });
  502. this.getWorkDicts("stencil").then(res => {
  503. this.stencilList = res.data.data;
  504. });
  505. this.getWorkDicts("unit").then(res => {
  506. this.findObject(this.tableOption.column, "unit").dicData = res.data.data;
  507. });
  508. getPricebankAll({ billType: "CG", statusTime: dateFormat(new Date(), "yyyy-MM-dd") }).then(res => {
  509. this.goodsoptions = res.data.data
  510. })
  511. // getPricebank(1, 10, { billType: "CG", statusTime: dateFormat(new Date(), "yyyy-MM-dd") }).then(res => {
  512. // if (res.data.data.total > 0) {
  513. // this.goodsoptions = res.data.data.records;
  514. // if (Math.ceil(res.data.data.total / 10) > 1) {
  515. // for (let i = 2; i <= Math.ceil(res.data.data.total / 10); i++) {
  516. // getPricebank(i, 10, { billType: "CG", statusTime: dateFormat(new Date(), "yyyy-MM-dd") }).then(e => {
  517. // this.goodsoptions = this.goodsoptions.concat(e.data.data.records);
  518. // });
  519. // }
  520. // }
  521. // }
  522. // });
  523. },
  524. methods: {
  525. cellStyle() {
  526. return "padding:0;height:40px;";
  527. },
  528. pickGoods() {
  529. // this.dialogVisible = !this.dialogVisible;
  530. this.$refs.library.search = {}
  531. this.$refs.library.init(false);
  532. },
  533. nodeClick(data) {
  534. this.treeDeptId = data.id;
  535. this.page.currentPage = 1;
  536. this.onLoad(this.page);
  537. },
  538. //费用查询
  539. onLoad(page, params = {}) {
  540. let obj = this.deepClone(Object.assign(params, this.search));
  541. this.loading = true;
  542. getGoods(page.currentPage, page.pageSize, this.treeDeptId, obj)
  543. .then(res => {
  544. const data = res.data.data;
  545. this.page.total = data.total;
  546. this.goodsList = data.records;
  547. if (this.page.total) {
  548. this.goodsOption.height = window.innerHeight - 350;
  549. }
  550. })
  551. .finally(() => {
  552. this.loading = false;
  553. });
  554. },
  555. rowClick(row) {
  556. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  557. },
  558. // importGoods() {
  559. // this.upDataOption()
  560. // this.selectionList.forEach(e => {
  561. // this.goodsForm.itemId = e.id;
  562. // this.goodsForm.ename = e.ename;
  563. // this.goodsForm.code = e.code;
  564. // this.goodsForm.cname = e.cname;
  565. // this.goodsForm.corpId = e.corpId;
  566. // this.goodsForm.corpName = e.corpCode;
  567. // this.goodsForm.priceCategory = e.goodsTypeName;
  568. // this.goodsForm.itemUrl = e.url;
  569. // this.goodsForm.itemProp = null;
  570. // this.goodsForm.remarksOne = null;
  571. // this.goodsForm.customTwo = null;
  572. // this.goodsForm.customThree = null;
  573. // this.goodsForm.customFour = null;
  574. // this.goodsForm.customFive = null;
  575. // this.goodsForm.customSix = null;
  576. // this.goodsForm.customSeven = null;
  577. // this.goodsForm.customEight = null;
  578. // this.goodsForm.customNine = null;
  579. // this.goodsForm.customTen = null;
  580. // this.goodsForm.itemDescription = e.cnameDescription;
  581. // this.goodsForm.partsList = [];
  582. // this.goodsForm.partsPrice = 0;
  583. // this.goodsForm.itemType = null;
  584. // this.goodsForm.tradeTerms = null;
  585. // this.goodsForm.purchaseCost = 0;
  586. // this.goodsForm.purchaseAmount = 0;
  587. // this.goodsForm.price = 0;
  588. // this.goodsForm.orderQuantity = 0;
  589. // this.goodsForm.insurance = 0;
  590. // this.goodsForm.freight = 0;
  591. // this.goodsForm.discount = null;
  592. // this.goodsForm.amount = 0;
  593. // this.goodsForm.taxRate = 0;
  594. // this.goodsForm.unit = e.unit;
  595. // this.goodsForm.itemMargin = 0;
  596. // this.goodsForm.remarks = null;
  597. // this.goodsForm.exchangeRate = this.form.exchangeRate;
  598. // this.goodsForm.partsDescribe = null;
  599. // this.goodsForm.productRemark = e.ename;
  600. // this.goodsForm.attributeList = this.getAttribute(e.goodsSpecificationList);
  601. // })
  602. // this.dialogVisible = false
  603. // },
  604. closeGoods() {
  605. this.selectionList = [];
  606. this.treeDeptId = "";
  607. },
  608. selectionChange(list) {
  609. this.selectionList = list;
  610. },
  611. refreshTable() {
  612. this.$refs.crud.refreshTable();
  613. },
  614. openpart(val, list) {
  615. this.$refs.partLibrary.init(val, list)
  616. },
  617. addRow() {
  618. if (!this.form.corpId) {
  619. return this.$message.error("请选择客户名称");
  620. }
  621. this.$refs.crud.rowAdd()
  622. },
  623. cnameChange(name,row) {
  624. this.upDataOption()
  625. this.goodsForm.itemId = row.itemId;
  626. this.goodsForm.code = row.code;
  627. this.goodsForm.cname = row.cname;
  628. this.goodsForm.ename = row.ename;
  629. this.goodsForm.priceCategory = row.goodsTypeName;
  630. this.goodsForm.purchaseCost = costCal(row.price, row.taxRate);
  631. this.goodsForm.purchaseAmount = row.purchaseAmount;
  632. this.goodsForm.itemProp = null;
  633. this.goodsForm.remarksOne = null;
  634. this.goodsForm.customTwo = null;
  635. this.goodsForm.customThree = null;
  636. this.goodsForm.customFour = null;
  637. this.goodsForm.customFive = null;
  638. this.goodsForm.customSix = null;
  639. this.goodsForm.customSeven = null;
  640. this.goodsForm.customEight = null;
  641. this.goodsForm.customNine = null;
  642. this.goodsForm.customTen = null;
  643. this.goodsForm.partsValveName = null;
  644. this.goodsForm.partsValveValue = null;
  645. this.goodsForm.partsValveCostPrice = 0;
  646. this.goodsForm.partsValveSalePrice = 0;
  647. this.goodsForm.partsCapName = null;
  648. this.goodsForm.partsCapValue = null;
  649. this.goodsForm.partsCapCostPrice = 0;
  650. this.goodsForm.partsCapSalePrice = 0;
  651. this.goodsForm.partsHandleName = null;
  652. this.goodsForm.partsHandleValue = null;
  653. this.goodsForm.partsHandleCostPrice = 0;
  654. this.goodsForm.partsHandleSalePrice = 0;
  655. this.goodsForm.partsColourName = null;
  656. this.goodsForm.partsColourValue = null;
  657. this.goodsForm.partsColourCostPrice = 0;
  658. this.goodsForm.partsColourSalePrice = 0;
  659. this.goodsForm.partsModeName = null;
  660. this.goodsForm.partsModeValue = null;
  661. this.goodsForm.partsModeCostPrice = 0;
  662. this.goodsForm.partsModeSalePrice = 0;
  663. this.goodsForm.partsAuthenticationName = null;
  664. this.goodsForm.partsAuthenticationValue = null;
  665. this.goodsForm.partsAuthenticationCostPrice = 0;
  666. this.goodsForm.partsAuthenticationSalePrice = 0;
  667. this.goodsForm.partsOtherName = null;
  668. this.goodsForm.partsOtherValue = null;
  669. this.goodsForm.partsOtherCostPrice = 0;
  670. this.goodsForm.partsOtherSalePrice = 0;
  671. this.goodsForm.partsCost = 0;
  672. this.goodsForm.corpId = row.corpId;
  673. this.goodsForm.corpName = row.corpCode;
  674. this.goodsForm.itemDescription = row.cnameDescription;
  675. this.goodsForm.partsPrice = 0;
  676. this.goodsForm.itemType = row.specs;
  677. this.goodsForm.tradeTerms = null;
  678. this.goodsForm.productPrice = productCal(row.purchaseAmount, 0, this.form.coefficient);
  679. this.goodsForm.outFactoryPrice = sellingCal(productCal(row.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate, 3);
  680. this.goodsForm.shareAmount = 0;
  681. this.goodsForm.internationalAmount = 0;
  682. this.goodsForm.orderQuantity = 1;
  683. this.goodsForm.insurance = 0;
  684. this.goodsForm.freight = 0;
  685. this.goodsForm.discount = null;
  686. this.goodsForm.price = sellingCal(productCal(row.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate);
  687. this.goodsForm.amount = sellingCal(productCal(row.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate);
  688. this.goodsForm.taxRate = 0;
  689. this.goodsForm.unit = row.unit;
  690. this.goodsForm.itemMargin = grossProfitCal(row.purchaseAmount, 0, sellingCal(productCal(row.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate), this.form.exchangeRate);
  691. this.goodsForm.goodsGrossProfit = goodsGrossProfitCal(row.purchaseAmount, 0, sellingCal(productCal(row.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate), this.form.exchangeRate);
  692. this.goodsForm.partsDescribe = null;
  693. this.goodsForm.remarks = null;
  694. this.goodsForm.exchangeRate = this.form.exchangeRate;
  695. this.goodsForm.productRemark = row.ename;
  696. this.goodsForm.attributeList = this.getAttribute(row.goodsSpecificationList);
  697. this.goodsForm.referrerReason = row.referrerReason
  698. // for (let e of this.goodsoptions) {
  699. // if (e.itemId == row.itemId) {
  700. // row.itemId = e.itemId;
  701. // row.code = e.code;
  702. // row.cname = e.cname;
  703. // row.ename = e.ename;
  704. // row.priceCategory = e.goodsTypeName;
  705. // row.purchaseCost = costCal(e.price, e.taxRate);
  706. // row.purchaseAmount = e.purchaseAmount;
  707. // row.itemProp = null;
  708. // row.remarksOne = null;
  709. // row.customTwo = null;
  710. // row.customThree = null;
  711. // row.customFour = null;
  712. // row.customFive = null;
  713. // row.customSix = null;
  714. // row.customSeven = null;
  715. // row.customEight = null;
  716. // row.customNine = null;
  717. // row.customTen = null;
  718. // row.partsValveName = null;
  719. // row.partsValveValue = null;
  720. // row.partsValveCostPrice = 0;
  721. // row.partsValveSalePrice = 0;
  722. // row.partsCapName = null;
  723. // row.partsCapValue = null;
  724. // row.partsCapCostPrice = 0;
  725. // row.partsCapSalePrice = 0;
  726. // row.partsHandleName = null;
  727. // row.partsHandleValue = null;
  728. // row.partsHandleCostPrice = 0;
  729. // row.partsHandleSalePrice = 0;
  730. // row.partsColourName = null;
  731. // row.partsColourValue = null;
  732. // row.partsColourCostPrice = 0;
  733. // row.partsColourSalePrice = 0;
  734. // row.partsModeName = null;
  735. // row.partsModeValue = null;
  736. // row.partsModeCostPrice = 0;
  737. // row.partsModeSalePrice = 0;
  738. // row.partsAuthenticationName = null;
  739. // row.partsAuthenticationValue = null;
  740. // row.partsAuthenticationCostPrice = 0;
  741. // row.partsAuthenticationSalePrice = 0;
  742. // row.partsOtherName = null;
  743. // row.partsOtherValue = null;
  744. // row.partsOtherCostPrice = 0;
  745. // row.partsOtherSalePrice = 0;
  746. // row.partsCost = 0;
  747. // row.corpId = e.corpId;
  748. // row.corpName = e.corpCode;
  749. // row.itemDescription = e.cnameDescription;
  750. // row.partsPrice = 0;
  751. // row.itemType = e.specs;
  752. // row.tradeTerms = null;
  753. // row.productPrice = productCal(e.purchaseAmount, 0, this.form.coefficient);
  754. // row.outFactoryPrice = sellingCal(productCal(e.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate, 3);
  755. // row.shareAmount = 0;
  756. // row.internationalAmount = 0;
  757. // row.orderQuantity = 1;
  758. // row.insurance = 0;
  759. // row.freight = 0;
  760. // row.discount = null;
  761. // row.price = sellingCal(productCal(e.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate);
  762. // row.amount = sellingCal(productCal(e.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate);
  763. // row.taxRate = 0;
  764. // row.unit = e.unit;
  765. // row.itemMargin = grossProfitCal(e.purchaseAmount, 0, sellingCal(productCal(e.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate), this.form.exchangeRate);
  766. // row.goodsGrossProfit = goodsGrossProfitCal(e.purchaseAmount, 0, sellingCal(productCal(e.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate), this.form.exchangeRate);
  767. // row.partsDescribe = null;
  768. // row.remarks = null;
  769. // row.exchangeRate = this.form.exchangeRate;
  770. // row.productRemark = e.ename;
  771. // row.attributeList = this.getAttribute(e.goodsSpecificationList);
  772. // row.referrerReason = e.referrerReason
  773. // }
  774. // }
  775. },
  776. importLibray(rows) {
  777. this.upDataOption()
  778. rows.forEach(e => {
  779. this.goodsForm = {
  780. itemId: e.itemId,
  781. code: e.code,
  782. cname: e.cname,
  783. ename: e.ename,
  784. priceCategory: e.goodsTypeName,
  785. purchaseCost: costCal(e.price, e.taxRate),
  786. purchaseAmount: e.purchaseAmount,
  787. itemProp: null,
  788. remarksOne: null,
  789. customTwo: null,
  790. customThree: null,
  791. customFour: null,
  792. customFive: null,
  793. customSix: null,
  794. customSeven: null,
  795. customEight: null,
  796. customNine: null,
  797. customTen: null,
  798. partsValveName: null,
  799. partsValveValue: null,
  800. partsValveCostPrice: 0,
  801. partsValveSalePrice: 0,
  802. partsCapName: null,
  803. partsCapValue: null,
  804. partsCapCostPrice: 0,
  805. partsCapSalePrice: 0,
  806. partsHandleName: null,
  807. partsHandleValue: null,
  808. partsHandleCostPrice: 0,
  809. partsHandleSalePrice: 0,
  810. partsColourName: null,
  811. partsColourValue: null,
  812. partsColourCostPrice: 0,
  813. partsColourSalePrice: 0,
  814. partsModeName: null,
  815. partsModeValue: null,
  816. partsModeCostPrice: 0,
  817. partsModeSalePrice: 0,
  818. partsAuthenticationName: null,
  819. partsAuthenticationValue: null,
  820. partsAuthenticationCostPrice: 0,
  821. partsAuthenticationSalePrice: 0,
  822. partsOtherName: null,
  823. partsOtherValue: null,
  824. partsOtherCostPrice: 0,
  825. partsOtherSalePrice: 0,
  826. corpId: e.corpId,
  827. corpName: e.corpCode,
  828. itemDescription: e.cnameDescription,
  829. partsPrice: 0,
  830. partsCost: 0,
  831. itemType: e.specs,
  832. tradeTerms: null,
  833. productPrice: productCal(e.purchaseAmount, 0, this.form.coefficient),
  834. outFactoryPrice: sellingCal(
  835. productCal(e.purchaseAmount, 0, this.form.coefficient),
  836. this.form.exchangeRate, 3
  837. ),
  838. shareAmount: 0,
  839. internationalAmount: 0,
  840. orderQuantity: 1,
  841. insurance: 0,
  842. freight: 0,
  843. discount: null,
  844. price: sellingCal(
  845. productCal(e.purchaseAmount, 0, this.form.coefficient),
  846. this.form.exchangeRate
  847. ),
  848. amount: sellingCal(
  849. productCal(e.purchaseAmount, 0, this.form.coefficient),
  850. this.form.exchangeRate
  851. ),
  852. taxRate: 0,
  853. unit: 'PCS',
  854. itemMargin: grossProfitCal(
  855. e.purchaseAmount,
  856. 0,
  857. sellingCal(
  858. productCal(e.purchaseAmount, 0, this.form.coefficient),
  859. this.form.exchangeRate
  860. ),
  861. this.form.exchangeRate
  862. ),
  863. goodsGrossProfit: goodsGrossProfitCal(
  864. e.purchaseAmount,
  865. 0,
  866. sellingCal(
  867. productCal(e.purchaseAmount, 0, this.form.coefficient),
  868. this.form.exchangeRate
  869. ),
  870. this.form.exchangeRate
  871. ),
  872. partsDescribe: null,
  873. remarks: null,
  874. exchangeRate: this.form.exchangeRate,
  875. productRemark: e.ename,
  876. attributeList: this.getAttribute(e.goodsSpecificationList),
  877. referrerReason: e.referrerReason
  878. }
  879. });
  880. this.$refs.crud.rowAdd()
  881. },
  882. openProperty(row) {
  883. this.$refs.property.init(row);
  884. },
  885. addLibrary() {
  886. if (!this.form.corpId) {
  887. return this.$message.error("请选择客户名称");
  888. }
  889. if (!this.form.currency) {
  890. return this.$message.error("请选择币别");
  891. }
  892. this.$refs.library.init(false);
  893. },
  894. openReport() {
  895. this.switchDialog = !this.switchDialog;
  896. },
  897. onClose(val) {
  898. this.switchDialog = val;
  899. },
  900. savePurchase() {
  901. if (!this.form.id) {
  902. return this.$message.error("此单据没有提交记录,请先提交");
  903. }
  904. if (!this.form.buyerId) {
  905. return this.$message.error("采购员必填");
  906. }
  907. this.$confirm("是否生成采购询价单?", {
  908. confirmButtonText: "确定",
  909. cancelButtonText: "取消",
  910. type: "warning"
  911. }).then(() => {
  912. savePurchase(this.form.id).then(res => {
  913. if (res.data.code == 200) {
  914. this.$message.success("生成成功");
  915. }
  916. });
  917. });
  918. },
  919. saveShipping() {
  920. if (!this.form.id) {
  921. return this.$message.error("此单据没有提交记录,请先提交");
  922. }
  923. if (!this.form.documenterId) {
  924. return this.$message.error("船务员必填");
  925. }
  926. this.$confirm("是否生成船务询价单?", {
  927. confirmButtonText: "确定",
  928. cancelButtonText: "取消",
  929. type: "warning"
  930. }).then(() => {
  931. let obj = {}
  932. obj = {
  933. id: this.form.id,
  934. srcBillType: 'BJ'
  935. }
  936. saveShipping(obj).then(res => {
  937. if (res.data.code == 200) {
  938. this.$message.success("生成成功");
  939. this.$emit('retrieve')
  940. }
  941. });
  942. });
  943. },
  944. cnameData() {
  945. this.goodsoptions = []
  946. getPricebankAll({ billType: "CG", statusTime: dateFormat(new Date(), "yyyy-MM-dd") }).then(res => {
  947. this.goodsoptions = res.data.data
  948. })
  949. // getGoods(1, 10).then(res => {
  950. // if (res.data.data.total > 0) {
  951. // this.goodsoptions = res.data.data.records;
  952. // if (Math.ceil(res.data.data.total / 10) > 1) {
  953. // for (let i = 2; i <= Math.ceil(res.data.data.total / 10); i++) {
  954. // getGoods(i, 10).then(e => {
  955. // this.goodsoptions = this.goodsoptions.concat(e.data.data.records);
  956. // });
  957. // }
  958. // }
  959. // }
  960. // });
  961. },
  962. oceanUSD() {
  963. this.$confirm('是否将应付的海运费(USD)复制到应收?', '提示', {
  964. confirmButtonText: '确定',
  965. cancelButtonText: '取消',
  966. type: 'warning'
  967. }).then(() => {
  968. this.$emit('oceanUSD')
  969. })
  970. },
  971. calculate(val) {
  972. this.form.totalValue = 0
  973. this.data.forEach((e, index) => {
  974. e.sort = Number(index) + 1
  975. this.form.totalValue = sum(multiply(e.outFactoryPrice, e.orderQuantity), this.form.totalValue)
  976. })
  977. if (val == 1) {
  978. let numSum = 0
  979. this.orderFeesList.forEach(e => {
  980. if (e.feesType == 2 && e.currency == "CNY") {
  981. numSum = sum(numSum, e.amount)
  982. }
  983. })
  984. let num = 0;
  985. num = divide(divide(numSum, this.form.totalValue, 10), this.form.exchangeRate, 10)
  986. this.$confirm("总运费:" + divide(numSum, this.form.exchangeRate) + ",单价分摊运费:" + num + ",是否继续更新?", {
  987. confirmButtonText: "确定",
  988. cancelButtonText: "取消",
  989. type: "warning"
  990. }).then(() => {
  991. this.data.forEach(e => {
  992. e.shareAmount = multiply(num, e.outFactoryPrice, 10)
  993. e.price = addPrice(e.outFactoryPrice, multiply(num, e.outFactoryPrice, 10), e.internationalAmount)
  994. e.amount = amountCal(
  995. addPrice(e.outFactoryPrice, multiply(num, e.outFactoryPrice, 10), e.internationalAmount),
  996. e.orderQuantity,
  997. e.freight,
  998. e.insurance,
  999. e.discount
  1000. );
  1001. e.itemMargin = grossProfitCal(
  1002. e.purchaseAmount,
  1003. e.partsPrice,
  1004. e.outFactoryPrice,
  1005. this.form.exchangeRate
  1006. );
  1007. e.goodsGrossProfit = goodsGrossProfitCal(
  1008. e.purchaseAmount,
  1009. e.partsPrice,
  1010. e.outFactoryPrice,
  1011. this.form.exchangeRate
  1012. );
  1013. // 处理单品毛利率是 -00.00 的问题
  1014. if (Number(e.itemMargin) === 0) {
  1015. e.itemMargin = Number(e.itemMargin) + ''
  1016. }
  1017. if (Number(e.goodsGrossProfit) == 0) {
  1018. e.goodsGrossProfit = Number(e.goodsGrossProfit)
  1019. }
  1020. })
  1021. })
  1022. } else {
  1023. let numSum = 0
  1024. this.orderFeesList.forEach(e => {
  1025. if (e.feesType == 2 && e.currency == "USD") {
  1026. numSum = sum(numSum, e.amount)
  1027. }
  1028. })
  1029. let num = 0;
  1030. num = divide(numSum, this.form.totalValue, 10)
  1031. this.$confirm("总运费:" + numSum + ",单价分摊运费:" + num + ",是否继续更新?", {
  1032. confirmButtonText: "确定",
  1033. cancelButtonText: "取消",
  1034. type: "warning"
  1035. }).then(() => {
  1036. this.data.forEach(e => {
  1037. e.internationalAmount = multiply(num, e.outFactoryPrice, 10)
  1038. e.price = addPrice(e.outFactoryPrice, multiply(num, e.outFactoryPrice, 10), e.shareAmount)
  1039. e.amount = amountCal(
  1040. addPrice(e.outFactoryPrice, multiply(num, e.outFactoryPrice, 10), e.shareAmount),
  1041. e.orderQuantity,
  1042. e.freight,
  1043. e.insurance,
  1044. e.discount
  1045. );
  1046. e.itemMargin = grossProfitCal(
  1047. e.purchaseAmount,
  1048. e.partsPrice,
  1049. e.outFactoryPrice,
  1050. this.form.exchangeRate
  1051. );
  1052. e.goodsGrossProfit = goodsGrossProfitCal(
  1053. e.purchaseAmount,
  1054. e.partsPrice,
  1055. e.outFactoryPrice,
  1056. this.form.exchangeRate
  1057. );
  1058. // 处理单品毛利率是 -00.00 的问题
  1059. if (Number(e.itemMargin) === 0) {
  1060. e.itemMargin = Number(e.itemMargin) + ''
  1061. }
  1062. if (Number(e.goodsGrossProfit) == 0) {
  1063. e.goodsGrossProfit = Number(e.goodsGrossProfit)
  1064. }
  1065. })
  1066. })
  1067. }
  1068. },
  1069. khEdit(status) {
  1070. if (status == 'cname') {
  1071. this.$router.push({
  1072. path: '/basicData/commodityType/index'
  1073. })
  1074. }
  1075. },
  1076. rowCell(row, index) {
  1077. this.getAttribute(JSON.parse(row.attributeList))
  1078. this.$refs.crud.rowEdit(row, index)
  1079. },
  1080. rowDel(row) {
  1081. this.$confirm("确定删除数据?", {
  1082. confirmButtonText: "确定",
  1083. cancelButtonText: "取消",
  1084. type: "warning"
  1085. }).then(() => {
  1086. if (row.id) {
  1087. delItem(row.id).then(res => {
  1088. this.$message({
  1089. type: "success",
  1090. message: "删除成功!"
  1091. });
  1092. this.data.splice(row.$index, 1);
  1093. });
  1094. } else {
  1095. this.$message({
  1096. type: "success",
  1097. message: "删除成功!"
  1098. });
  1099. this.data.splice(row.$index, 1);
  1100. }
  1101. });
  1102. },
  1103. moveUp(row, index) {
  1104. this.data[index] = this.data.splice(index - 1, 1, row)[0]
  1105. },
  1106. moveDown(row, index) {
  1107. this.data[index] = this.data.splice(index + 1, 1, row)[0]
  1108. },
  1109. inPriceAD() {
  1110. this.$DialogForm.show({
  1111. title: '调整出厂价',
  1112. width: '30%',
  1113. menuPosition: 'right',
  1114. option: {
  1115. submitText: '确定',
  1116. emptyText: '取消',
  1117. span: 24,
  1118. column: [{
  1119. label: "出厂价(%)",
  1120. prop: "value",
  1121. min: 0,
  1122. value: 0,
  1123. type: 'number',
  1124. controls: false,
  1125. rules: [{
  1126. required: true,
  1127. message: "请输入出厂价",
  1128. trigger: "blur",
  1129. }],
  1130. }]
  1131. },
  1132. beforeClose: (done) => {
  1133. done()
  1134. },
  1135. callback: (res) => {
  1136. res.done()
  1137. this.data.forEach(e => {
  1138. e.outFactoryPrice = priceaAjustment(e.outFactoryPrice, res.data.value, 3)
  1139. e.totalValue = multiply(e.outFactoryPrice, e.orderQuantity)
  1140. e.price = addPrice(e.outFactoryPrice, e.shareAmount, e.internationalAmount)
  1141. e.amount = amountCal(
  1142. addPrice(e.outFactoryPrice, e.shareAmount, e.internationalAmount),
  1143. e.orderQuantity,
  1144. e.freight,
  1145. e.insurance,
  1146. e.discount
  1147. );
  1148. e.itemMargin = grossProfitCal(
  1149. e.purchaseAmount,
  1150. e.partsPrice,
  1151. e.outFactoryPrice,
  1152. this.form.exchangeRate
  1153. );
  1154. e.goodsGrossProfit = goodsGrossProfitCal(
  1155. e.purchaseAmount,
  1156. e.partsPrice,
  1157. e.outFactoryPrice,
  1158. this.form.exchangeRate
  1159. );
  1160. // 处理单品毛利率是 -00.00 的问题
  1161. if (Number(e.itemMargin) === 0) {
  1162. e.itemMargin = Number(e.itemMargin) + ''
  1163. }
  1164. if (Number(e.goodsGrossProfit) == 0) {
  1165. e.goodsGrossProfit = Number(e.goodsGrossProfit)
  1166. }
  1167. // 出厂价格为零,单品毛利润为零
  1168. if (e.outFactoryPrice == 0) {
  1169. e.itemMargin = 0
  1170. }
  1171. })
  1172. res.close()
  1173. }
  1174. })
  1175. },
  1176. submitPriceAD() {
  1177. this.visible = false;
  1178. this.data.forEach(e => {
  1179. e.outFactoryPrice = priceaAjustment(e.outFactoryPrice, this.priceAD, 3)
  1180. e.totalValue = multiply(e.outFactoryPrice, e.orderQuantity)
  1181. e.price = addPrice(e.outFactoryPrice, e.shareAmount, e.internationalAmount)
  1182. e.amount = amountCal(
  1183. addPrice(e.outFactoryPrice, e.shareAmount, e.internationalAmount),
  1184. e.orderQuantity,
  1185. e.freight,
  1186. e.insurance,
  1187. e.discount
  1188. );
  1189. e.itemMargin = grossProfitCal(
  1190. e.purchaseAmount,
  1191. e.partsPrice,
  1192. e.outFactoryPrice,
  1193. this.form.exchangeRate
  1194. );
  1195. e.goodsGrossProfit = goodsGrossProfitCal(
  1196. e.purchaseAmount,
  1197. e.partsPrice,
  1198. e.outFactoryPrice,
  1199. this.form.exchangeRate
  1200. );
  1201. // 处理单品毛利率是 -00.00 的问题
  1202. if (Number(e.itemMargin) === 0) {
  1203. e.itemMargin = Number(e.itemMargin) + ''
  1204. }
  1205. if (Number(e.goodsGrossProfit) == 0) {
  1206. e.goodsGrossProfit = Number(e.goodsGrossProfit)
  1207. }
  1208. // 出厂价格为零,单品毛利润为零
  1209. if (e.outFactoryPrice == 0) {
  1210. e.itemMargin = 0
  1211. }
  1212. })
  1213. this.priceAD = 0
  1214. },
  1215. purchaseAmountChange(row) {
  1216. row.productPrice = productCal(
  1217. row.purchaseAmount,
  1218. row.partsPrice,
  1219. this.form.coefficient
  1220. );
  1221. row.outFactoryPrice = sellingCal(row.productPrice, this.form.exchangeRate, 3);
  1222. row.price = addPrice(
  1223. row.outFactoryPrice,
  1224. row.shareAmount,
  1225. row.internationalAmount
  1226. );
  1227. row.amount = amountCal(
  1228. row.price,
  1229. row.orderQuantity,
  1230. row.freight,
  1231. row.insurance,
  1232. row.discount
  1233. );
  1234. row.itemMargin = grossProfitCal(
  1235. row.purchaseAmount,
  1236. row.partsPrice,
  1237. row.outFactoryPrice,
  1238. this.form.exchangeRate
  1239. );
  1240. row.goodsGrossProfit = goodsGrossProfitCal(
  1241. row.purchaseAmount,
  1242. row.partsPrice,
  1243. row.outFactoryPrice,
  1244. this.form.exchangeRate
  1245. );
  1246. if (Number(row.goodsGrossProfit) == 0) {
  1247. row.goodsGrossProfit = Number(row.goodsGrossProfit)
  1248. }
  1249. },
  1250. priceChange(row) {
  1251. row.price = addPrice(row.outFactoryPrice, row.shareAmount, row.internationalAmount)
  1252. row.amount = amountCal(
  1253. addPrice(row.outFactoryPrice, row.shareAmount, row.internationalAmount),
  1254. row.orderQuantity,
  1255. row.freight,
  1256. row.insurance,
  1257. row.discount
  1258. );
  1259. row.itemMargin = grossProfitCal(
  1260. row.purchaseAmount,
  1261. row.partsPrice,
  1262. row.outFactoryPrice,
  1263. this.form.exchangeRate
  1264. );
  1265. row.goodsGrossProfit = goodsGrossProfitCal(
  1266. row.purchaseAmount,
  1267. row.partsPrice,
  1268. row.outFactoryPrice,
  1269. this.form.exchangeRate
  1270. );
  1271. if (Number(row.goodsGrossProfit) == 0) {
  1272. row.goodsGrossProfit = Number(row.goodsGrossProfit)
  1273. }
  1274. },
  1275. itemTypeFocus(row) {
  1276. this.itemtypeList = [];
  1277. getSpecification({ goodId: row.itemId }).then(res => {
  1278. const data = res.data.data;
  1279. this.itemtypeList = data.map(item => ({ value: item }));
  1280. });
  1281. },
  1282. getAttribute(rows) {
  1283. let data = []
  1284. rows.forEach(e => {
  1285. if (e.attributeNo == 'Thread' && e.status == 0) {
  1286. this.findObject(this.tableOption.column, "remarksOne").disabled = false;
  1287. }
  1288. if (e.attributeNo == 'medium' && e.status == 0) {
  1289. this.findObject(this.tableOption.column, "customTwo").disabled = false;
  1290. }
  1291. if (e.attributeNo == 'property_color' && e.status == 0) {
  1292. this.findObject(this.tableOption.column, "customThree").disabled = false;
  1293. }
  1294. if (e.attributeNo == 'stencil' && e.status == 0) {
  1295. this.findObject(this.tableOption.column, "customFour").disabled = false;
  1296. }
  1297. if (e.attributeName == '阀门配件' && e.status == 0) {
  1298. this.findObject(this.tableOption.column, "partsValveName").disabled = false;
  1299. }
  1300. if (e.attributeName == '瓶帽配件' && e.status == 0) {
  1301. this.findObject(this.tableOption.column, "partsCapName").disabled = false;
  1302. }
  1303. if (e.attributeName == '特殊处理' && e.status == 0) {
  1304. this.findObject(this.tableOption.column, "partsHandleName").disabled = false;
  1305. }
  1306. if (e.attributeName == '包装方式' && e.status == 0) {
  1307. this.findObject(this.tableOption.column, "partsColourName").disabled = false;
  1308. }
  1309. if (e.attributeName == '特殊颜色' && e.status == 0) {
  1310. this.findObject(this.tableOption.column, "partsModeName").disabled = false;
  1311. }
  1312. if (e.attributeName == '认证' && e.status == 0) {
  1313. this.findObject(this.tableOption.column, "partsAuthenticationName").disabled = false;
  1314. }
  1315. if (e.attributeName == '其他' && e.status == 0) {
  1316. this.findObject(this.tableOption.column, "partsOtherName").disabled = false;
  1317. }
  1318. data.push({
  1319. type: e.type,
  1320. attributeName: e.attributeName,
  1321. attributeNo: e.attributeNo,
  1322. status: e.status,
  1323. })
  1324. })
  1325. return JSON.stringify(data);
  1326. },
  1327. // importProperty(row) {
  1328. // const arr = [];
  1329. // for (let key in row) {
  1330. // if (row[key]) {
  1331. // arr.push(row[key]);
  1332. // }
  1333. // }
  1334. // this.goodsForm.itemProp = arr.join(" ");
  1335. // this.goodsForm.remarksOne = row.remarksOne;
  1336. // this.goodsForm.customTwo = row.customTwo;
  1337. // this.goodsForm.customThree = row.customThree;
  1338. // this.goodsForm.customFour = row.customFour;
  1339. // this.goodsForm.customFive = row.customFive;
  1340. // this.goodsForm.customSix = row.customSix;
  1341. // this.goodsForm.customSeven = row.customSeven;
  1342. // this.goodsForm.customEight = row.customEight;
  1343. // this.goodsForm.customNine = row.customNine;
  1344. // this.goodsForm.customTen = row.customTen;
  1345. // this.goodsForm.productRemark = this.getproductRemark(this.goodsForm)
  1346. // },
  1347. importPart(rows, type) {
  1348. if (type == 0) {
  1349. this.goodsForm.partsValveCostPrice = 0
  1350. this.goodsForm.partsValveSalePrice = 0
  1351. let names = []
  1352. rows.forEach(e => {
  1353. names.push(e.goodName)
  1354. this.goodsForm.partsValveCostPrice = sum(this.goodsForm.partsValveCostPrice, multiply(e.partsCost, e.goodNumber));
  1355. this.goodsForm.partsValveSalePrice = sum(this.goodsForm.partsValveSalePrice, e.amout);
  1356. })
  1357. this.goodsForm.partsValveName = names.join(" ")
  1358. this.goodsForm.partsValveValue = JSON.stringify(rows)
  1359. }
  1360. if (type == 1) {
  1361. this.goodsForm.partsCapCostPrice = 0
  1362. this.goodsForm.partsCapSalePrice = 0
  1363. let names = []
  1364. rows.forEach(e => {
  1365. names.push(e.goodName)
  1366. this.goodsForm.partsCapCostPrice = sum(this.goodsForm.partsCapCostPrice, multiply(e.partsCost, e.goodNumber));
  1367. this.goodsForm.partsCapSalePrice = sum(this.goodsForm.partsCapSalePrice, e.amout);
  1368. })
  1369. this.goodsForm.partsCapName = names.join(" ")
  1370. this.goodsForm.partsCapValue = JSON.stringify(rows)
  1371. }
  1372. if (type == 2) {
  1373. this.goodsForm.partsHandleCostPrice = 0
  1374. this.goodsForm.partsHandleSalePrice = 0
  1375. let names = []
  1376. rows.forEach(e => {
  1377. names.push(e.goodName)
  1378. this.goodsForm.partsHandleCostPrice = sum(this.goodsForm.partsHandleCostPrice, multiply(e.partsCost, e.goodNumber));
  1379. this.goodsForm.partsHandleSalePrice = sum(this.goodsForm.partsHandleSalePrice, e.amout);
  1380. })
  1381. this.goodsForm.partsHandleName = names.join(" ")
  1382. this.goodsForm.partsHandleValue = JSON.stringify(rows)
  1383. }
  1384. if (type == 3) {
  1385. this.goodsForm.partsColourCostPrice = 0
  1386. this.goodsForm.partsColourSalePrice = 0
  1387. let names = []
  1388. rows.forEach(e => {
  1389. names.push(e.goodName)
  1390. this.goodsForm.partsColourCostPrice = sum(this.goodsForm.partsColourCostPrice, multiply(e.partsCost, e.goodNumber));
  1391. this.goodsForm.partsColourSalePrice = sum(this.goodsForm.partsColourSalePrice, e.amout);
  1392. })
  1393. this.goodsForm.partsColourName = names.join(" ")
  1394. this.goodsForm.partsColourValue = JSON.stringify(rows)
  1395. }
  1396. if (type == 4) {
  1397. this.goodsForm.partsModeCostPrice = 0
  1398. this.goodsForm.partsModeSalePrice = 0
  1399. let names = []
  1400. rows.forEach(e => {
  1401. names.push(e.goodName)
  1402. this.goodsForm.partsModeCostPrice = sum(this.goodsForm.partsModeCostPrice, multiply(e.partsCost, e.goodNumber));
  1403. this.goodsForm.partsModeSalePrice = sum(this.goodsForm.partsModeSalePrice, e.amout);
  1404. })
  1405. this.goodsForm.partsModeName = names.join(" ")
  1406. this.goodsForm.partsModeValue = JSON.stringify(rows)
  1407. }
  1408. if (type == 5) {
  1409. this.goodsForm.partsAuthenticationCostPrice = 0
  1410. this.goodsForm.partsAuthenticationSalePrice = 0
  1411. let names = []
  1412. rows.forEach(e => {
  1413. names.push(e.goodName)
  1414. this.goodsForm.partsAuthenticationCostPrice = sum(this.goodsForm.partsAuthenticationCostPrice, multiply(e.partsCost, e.goodNumber));
  1415. this.goodsForm.partsAuthenticationSalePrice = sum(this.goodsForm.partsAuthenticationSalePrice, e.amout);
  1416. })
  1417. this.goodsForm.partsAuthenticationName = names.join(" ")
  1418. this.goodsForm.partsAuthenticationValue = JSON.stringify(rows)
  1419. }
  1420. if (type == 6) {
  1421. this.goodsForm.partsOtherCostPrice = 0
  1422. this.goodsForm.partsOtherSalePrice = 0
  1423. let names = []
  1424. rows.forEach(e => {
  1425. names.push(e.goodName)
  1426. this.goodsForm.partsOtherCostPrice = sum(this.goodsForm.partsOtherCostPrice, multiply(e.partsCost, e.goodNumber));
  1427. this.goodsForm.partsOtherSalePrice = sum(this.goodsForm.partsOtherSalePrice, e.amout);
  1428. })
  1429. this.goodsForm.partsOtherName = names.join(" ")
  1430. this.goodsForm.partsOtherValue = JSON.stringify(rows)
  1431. }
  1432. this.goodsForm.partsCost = partSum(this.goodsForm.partsValveCostPrice, this.goodsForm.partsCapCostPrice, this.goodsForm.partsHandleCostPrice, this.goodsForm.partsColourCostPrice, this.goodsForm.partsModeCostPrice, this.goodsForm.partsAuthenticationCostPrice, this.goodsForm.partsOtherCostPrice)
  1433. this.goodsForm.partsPrice = partSum(this.goodsForm.partsValveSalePrice, this.goodsForm.partsCapSalePrice, this.goodsForm.partsHandleSalePrice, this.goodsForm.partsColourSalePrice, this.goodsForm.partsModeSalePrice, this.goodsForm.partsAuthenticationSalePrice, this.goodsForm.partsOtherSalePrice)
  1434. // 销售价=(配件采购价格+产品价格)/汇率 *(1+客户FOB系数/100)
  1435. this.goodsForm.productPrice = productCal(
  1436. this.goodsForm.purchaseAmount,
  1437. this.goodsForm.partsPrice,
  1438. this.form.coefficient
  1439. );
  1440. this.goodsForm.outFactoryPrice = sellingCal(
  1441. this.goodsForm.productPrice,
  1442. this.form.exchangeRate,
  1443. 3
  1444. );
  1445. this.goodsForm.price = addPrice(
  1446. this.goodsForm.outFactoryPrice,
  1447. this.goodsForm.shareAmount,
  1448. this.goodsForm.internationalAmount
  1449. );
  1450. this.goodsForm.amount = amountCal(
  1451. this.goodsForm.price,
  1452. this.goodsForm.orderQuantity,
  1453. this.goodsForm.freight,
  1454. this.goodsForm.insurance,
  1455. this.goodsForm.discount
  1456. );
  1457. this.goodsForm.itemMargin = grossProfitCal(
  1458. this.goodsForm.purchaseAmount,
  1459. this.goodsForm.partsPrice,
  1460. this.goodsForm.outFactoryPrice,
  1461. this.form.exchangeRate
  1462. );
  1463. this.goodsForm.goodsGrossProfit = goodsGrossProfitCal(
  1464. this.goodsForm.purchaseAmount,
  1465. this.goodsForm.partsPrice,
  1466. this.goodsForm.outFactoryPrice,
  1467. this.form.exchangeRate
  1468. );
  1469. if (Number(this.goodsForm.goodsGrossProfit) == 0) {
  1470. this.goodsForm.goodsGrossProfit = Number(this.goodsForm.goodsGrossProfit)
  1471. }
  1472. const names = [this.goodsForm.partsModeName, this.goodsForm.partsHandleName, this.goodsForm.partsCapName, this.goodsForm.partsValveName, this.goodsForm.partsColourName, this.goodsForm.partsAuthenticationName, this.goodsForm.partsOtherName];
  1473. const name = []
  1474. names.forEach(e => {
  1475. if (e) {
  1476. name.push(e)
  1477. }
  1478. })
  1479. this.goodsForm.partsDescribe = name.join("; ");
  1480. this.goodsForm.productRemark = this.getproductRemark(this.goodsForm)
  1481. },
  1482. propsChange(row) {
  1483. const data = {
  1484. remarksOne: row.remarksOne,
  1485. customTwo: row.customTwo,
  1486. customThree: row.customThree,
  1487. customFour: row.customFour,
  1488. customFive: row.customFive,
  1489. customSix: row.customSix,
  1490. customSeven: row.customSeven,
  1491. customEight: row.customEight,
  1492. customNine: row.customNine,
  1493. customTen: row.customTen,
  1494. };
  1495. const arr = []
  1496. for (let key in data) {
  1497. if (row[key]) {
  1498. arr.push(row[key]);
  1499. }
  1500. }
  1501. this.goodsForm.itemProp = arr.join(', ')
  1502. this.goodsForm.productRemark = this.getproductRemark(this.goodsForm)
  1503. },
  1504. editChange(row) {
  1505. row.productRemark = this.getproductRemark(row)
  1506. },
  1507. getproductRemark(row) {
  1508. const ename = row.ename ? row.ename : "";
  1509. const itemDescription = row.itemDescription
  1510. ? row.itemDescription
  1511. : "";
  1512. const itemProp = row.itemProp ? row.itemProp : ''
  1513. const partsDescribe = row.partsDescribe ? row.partsDescribe : ''
  1514. const productRemark =
  1515. ename + "\n" +
  1516. itemDescription + "\n" +
  1517. itemProp + "\n" +
  1518. partsDescribe
  1519. return productRemark
  1520. },
  1521. beforeClose(done) {
  1522. this.upDataOption()
  1523. done();
  1524. },
  1525. upDataOption() {
  1526. this.findObject(this.tableOption.column, "remarksOne").disabled = true;
  1527. this.findObject(this.tableOption.column, "customTwo").disabled = true;
  1528. this.findObject(this.tableOption.column, "customThree").disabled = true;
  1529. this.findObject(this.tableOption.column, "customFour").disabled = true;
  1530. this.findObject(this.tableOption.column, "partsValveName").disabled = true;
  1531. this.findObject(this.tableOption.column, "partsCapName").disabled = true;
  1532. this.findObject(this.tableOption.column, "partsHandleName").disabled = true;
  1533. this.findObject(this.tableOption.column, "partsColourName").disabled = true;
  1534. this.findObject(this.tableOption.column, "partsModeName").disabled = true;
  1535. this.findObject(this.tableOption.column, "partsAuthenticationName").disabled = true;
  1536. this.findObject(this.tableOption.column, "partsOtherName").disabled = true;
  1537. },
  1538. discountChange(row) {
  1539. if (row.discount >= 10) {
  1540. row.discount = null;
  1541. this.$message.error("请正确输入折扣");
  1542. }
  1543. this.priceChange(row);
  1544. },
  1545. taxRateChange(row) {
  1546. if (row.taxRate > 100) {
  1547. row.taxRate = 0;
  1548. this.$message.error("请正确输入税率");
  1549. }
  1550. },
  1551. handleRowSave(row, done, loading) {
  1552. this.data.push(row)
  1553. loading()
  1554. done()
  1555. },
  1556. handleRowUpdate(row, index, done, loading) {
  1557. // this.data[index] = row
  1558. this.$set(this.data, index, row)
  1559. // this.$refs.crud.rowUpdate(row)
  1560. loading()
  1561. done()
  1562. },
  1563. summaryMethod({ columns, data }) {
  1564. const sums = [];
  1565. if (columns.length > 0) {
  1566. columns.forEach((column, index) => {
  1567. let prop = column.property
  1568. if (['orderQuantity', 'amount', 'partsCost', 'partsPrice', 'productPrice'].includes(prop)) {
  1569. let values = this.data.map(item => Number(item[prop] || 0));
  1570. let all = values.length !== 0 ? sums[index] = values.reduce((a, b) => {
  1571. return a + b;
  1572. }) : 0
  1573. if (prop == 'orderQuantity') {
  1574. sums[index] = micrometerFormat2(all)
  1575. }
  1576. if (prop == 'amount') {
  1577. sums[index] = micrometerFormat2(all)
  1578. }
  1579. if (prop == 'partsCost') {
  1580. sums[index] = micrometerFormat2(all)
  1581. }
  1582. if (prop == 'partsPrice') {
  1583. sums[index] = micrometerFormat2(all)
  1584. }
  1585. if (prop == 'productPrice') {
  1586. sums[index] = micrometerFormat2(all)
  1587. }
  1588. }
  1589. });
  1590. }
  1591. return sums;
  1592. },
  1593. async saveColumn() {
  1594. const inSave = await this.saveColumnData(this.getColumnName(1), this.tableOption);
  1595. if (localStorage.getItem("roleName").indexOf('贸易') == -1 && localStorage.getItem("roleName").indexOf('运营') == -1) {
  1596. this.findObject(this.tableOption.column, "purchaseCost").hide = false;
  1597. this.findObject(this.tableOption.column, "purchaseCost").showColumn = true;
  1598. this.findObject(this.tableOption.column, "partsPrice").hide = false;
  1599. this.findObject(this.tableOption.column, "partsPrice").showColumn = true;
  1600. this.findObject(this.tableOption.column, "partsCost").hide = false;
  1601. this.findObject(this.tableOption.column, "partsCost").showColumn = true;
  1602. this.findObject(this.tableOption.column, "purchaseAmount").hide = false;
  1603. this.findObject(this.tableOption.column, "purchaseAmount").showColumn = true;
  1604. this.findObject(this.tableOption.column, "corpName").hide = false;
  1605. this.findObject(this.tableOption.column, "corpName").showColumn = true;
  1606. this.findObject(this.tableOption.column, "productPrice").hide = false;
  1607. this.findObject(this.tableOption.column, "productPrice").showColumn = true;
  1608. this.findObject(this.tableOption.column, "productPrice").display = true;
  1609. }
  1610. if (inSave) {
  1611. this.$nextTick(() => {
  1612. this.$refs.crud.doLayout();
  1613. });
  1614. this.getWorkDicts("cargo_type").then(res => {
  1615. this.findObject(this.tableOption.column, "cargoType").dicData = res.data.data;
  1616. });
  1617. this.$message.success("保存成功");
  1618. //关闭窗口
  1619. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  1620. }
  1621. },
  1622. async resetColumn() {
  1623. this.tableOption = tableOption;
  1624. const inSave = await this.delColumnData(
  1625. this.getColumnName(1),
  1626. tableOption
  1627. );
  1628. if (inSave) {
  1629. this.$nextTick(() => {
  1630. this.$refs.crud.doLayout();
  1631. });
  1632. this.$message.success("重置成功");
  1633. if (localStorage.getItem("roleName").indexOf('贸易') == -1 && localStorage.getItem("roleName").indexOf('运营') == -1) {
  1634. this.findObject(this.tableOption.column, "purchaseCost").hide = false;
  1635. this.findObject(this.tableOption.column, "purchaseCost").showColumn = true;
  1636. this.findObject(this.tableOption.column, "partsPrice").hide = false;
  1637. this.findObject(this.tableOption.column, "partsPrice").showColumn = true;
  1638. this.findObject(this.tableOption.column, "partsCost").hide = false;
  1639. this.findObject(this.tableOption.column, "partsCost").showColumn = true;
  1640. this.findObject(this.tableOption.column, "purchaseAmount").hide = false;
  1641. this.findObject(this.tableOption.column, "purchaseAmount").showColumn = true;
  1642. this.findObject(this.tableOption.column, "corpName").hide = false;
  1643. this.findObject(this.tableOption.column, "corpName").showColumn = true;
  1644. this.findObject(this.tableOption.column, "productPrice").hide = false;
  1645. this.findObject(this.tableOption.column, "productPrice").showColumn = true;
  1646. this.findObject(this.tableOption.column, "productPrice").display = true;
  1647. }
  1648. //关闭窗口
  1649. setTimeout(() => {
  1650. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  1651. }, 1000);
  1652. }
  1653. },
  1654. async saveGoodsColumn() {
  1655. const inSave = await this.saveColumnData(
  1656. this.getColumnName(26),
  1657. this.goodsOption
  1658. );
  1659. if (inSave) {
  1660. this.$nextTick(() => {
  1661. this.$refs.goodsCrud.doLayout();
  1662. });
  1663. this.$message.success("保存成功");
  1664. //关闭窗口
  1665. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  1666. }
  1667. },
  1668. async resetGoodsColumn() {
  1669. this.goodsOption = goodsOption;
  1670. const inSave = await this.delColumnData(
  1671. this.getColumnName(26),
  1672. goodsOption
  1673. );
  1674. if (inSave) {
  1675. this.$nextTick(() => {
  1676. this.$refs.goodsCrud.doLayout();
  1677. });
  1678. this.$message.success("重置成功");
  1679. //关闭窗口
  1680. setTimeout(() => {
  1681. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  1682. }, 1000);
  1683. }
  1684. }
  1685. },
  1686. watch: {
  1687. }
  1688. };
  1689. </script>
  1690. <style scoped>
  1691. ::v-deep .select-component {
  1692. display: flex;
  1693. }
  1694. .page-crad ::v-deep .basic-container__card {
  1695. height: 94.2vh;
  1696. }
  1697. .itemTable ::v-deep .el-table {
  1698. width: 738px;
  1699. }
  1700. ::v-deep .el-input-group__append,
  1701. .el-input-group__prepend {
  1702. padding: 0 5px;
  1703. }
  1704. </style>