goodsInfo.vue 56 KB

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