goodsInfo.vue 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433
  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") == "贸易") {
  420. this.findObject(this.tableOption.column, "purchaseCost").hide = true;
  421. this.findObject(this.tableOption.column, "purchaseCost").showColumn = false;
  422. this.findObject(this.tableOption.column, "partsCost").hide = true;
  423. this.findObject(this.tableOption.column, "partsCost").showColumn = false;
  424. this.findObject(this.tableOption.column, "purchaseAmount").hide = true;
  425. this.findObject(this.tableOption.column, "purchaseAmount").showColumn = false;
  426. this.findObject(this.tableOption.column, "corpName").hide = true;
  427. this.findObject(this.tableOption.column, "corpName").showColumn = false;
  428. }
  429. this.getWorkDicts("Thread").then(res => {
  430. this.ThreadList = res.data.data;
  431. });
  432. this.getWorkDicts("medium").then(res => {
  433. this.mediumList = res.data.data;
  434. });
  435. this.getWorkDicts("property_color").then(res => {
  436. this.colorList = res.data.data;
  437. });
  438. this.getWorkDicts("stencil").then(res => {
  439. this.stencilList = res.data.data;
  440. });
  441. this.getWorkDicts("unit").then(res => {
  442. this.findObject(this.tableOption.column, "unit").dicData = res.data.data;
  443. });
  444. getPricebankAll({ billType: "CG", statusTime: dateFormat(new Date(), "yyyy-MM-dd") }).then(res=>{
  445. this.goodsoptions = res.data.data
  446. })
  447. // getPricebank(1, 10, {
  448. // billType: "CG",
  449. // statusTime: dateFormat(new Date(), "yyyy-MM-dd")
  450. // }).then(res => {
  451. // if (res.data.data.total > 0) {
  452. // this.goodsoptions = res.data.data.records;
  453. // if (Math.ceil(res.data.data.total / 10) > 1) {
  454. // for (let i = 2; i <= Math.ceil(res.data.data.total / 10); i++) {
  455. // getPricebank(i, 10, {
  456. // billType: "CG",
  457. // statusTime: dateFormat(new Date(), "yyyy-MM-dd")
  458. // }).then(e => {
  459. // this.goodsoptions = this.goodsoptions.concat(e.data.data.records);
  460. // });
  461. // }
  462. // }
  463. // }
  464. // });
  465. },
  466. methods: {
  467. cellStyle() {
  468. return "padding:0;height:40px;";
  469. },
  470. goodsSelectionChange(list) {
  471. this.orderItemIds = [];
  472. list.map(e => {
  473. this.orderItemIds.push(e.id);
  474. });
  475. },
  476. pickGoods() {
  477. // this.dialogVisible = !this.dialogVisible;
  478. this.$refs.library.init(false);
  479. },
  480. nodeClick(data) {
  481. this.treeDeptId = data.id;
  482. this.page.currentPage = 1;
  483. this.onLoad(this.page);
  484. },
  485. //费用查询
  486. onLoad(page, params = {}) {
  487. let obj = this.deepClone(Object.assign(params, this.search));
  488. this.loading = true;
  489. getGoods(page.currentPage, page.pageSize, this.treeDeptId, obj)
  490. .then(res => {
  491. const data = res.data.data;
  492. this.page.total = data.total;
  493. this.goodsList = data.records;
  494. if (this.page.total) {
  495. this.goodsOption.height = window.innerHeight - 350;
  496. }
  497. })
  498. .finally(() => {
  499. this.loading = false;
  500. });
  501. },
  502. rowClick(row) {
  503. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  504. },
  505. // importGoods() {
  506. // this.upDataOption()
  507. // this.selectionList.forEach(e => {
  508. // this.goodsForm.itemId = e.id;
  509. // this.goodsForm.ename = e.ename;
  510. // this.goodsForm.code = e.code;
  511. // this.goodsForm.cname = e.cname;
  512. // this.goodsForm.corpId = e.corpId;
  513. // this.goodsForm.corpName = e.corpCode;
  514. // this.goodsForm.priceCategory = e.goodsTypeName;
  515. // this.goodsForm.itemUrl = e.url;
  516. // this.goodsForm.itemProp = null;
  517. // this.goodsForm.remarksOne = null;
  518. // this.goodsForm.customTwo = null;
  519. // this.goodsForm.customThree = null;
  520. // this.goodsForm.customFour = null;
  521. // this.goodsForm.customFive = null;
  522. // this.goodsForm.customSix = null;
  523. // this.goodsForm.customSeven = null;
  524. // this.goodsForm.customEight = null;
  525. // this.goodsForm.customNine = null;
  526. // this.goodsForm.customTen = null;
  527. // this.goodsForm.itemDescription = e.cnameDescription;
  528. // this.goodsForm.partsList = [];
  529. // this.goodsForm.partsPrice = 0;
  530. // this.goodsForm.itemType = null;
  531. // this.goodsForm.tradeTerms = null;
  532. // this.goodsForm.purchaseCost = 0;
  533. // this.goodsForm.purchaseAmount = 0;
  534. // this.goodsForm.price = 0;
  535. // this.goodsForm.orderQuantity = 0;
  536. // this.goodsForm.insurance = 0;
  537. // this.goodsForm.freight = 0;
  538. // this.goodsForm.discount = null;
  539. // this.goodsForm.amount = 0;
  540. // this.goodsForm.taxRate = 0;
  541. // this.goodsForm.unit = e.unit;
  542. // this.goodsForm.itemMargin = 0;
  543. // this.goodsForm.remarks = null;
  544. // this.goodsForm.exchangeRate = this.form.exchangeRate;
  545. // this.goodsForm.partsDescribe = null;
  546. // this.goodsForm.productRemark = e.ename;
  547. // this.goodsForm.attributeList = this.getAttribute(e.goodsSpecificationList);
  548. // })
  549. // this.dialogVisible = false
  550. // },
  551. closeGoods() {
  552. this.selectionList = [];
  553. this.treeDeptId = "";
  554. },
  555. selectionChange(list) {
  556. this.selectionList = list;
  557. },
  558. refreshTable() {
  559. this.$refs.crud.refreshTable();
  560. },
  561. openpart(val, list) {
  562. this.$refs.partLibrary.init(val, list)
  563. },
  564. addRow() {
  565. if (!this.form.corpId) {
  566. return this.$message.error("请选择客户名称");
  567. }
  568. this.$refs.crud.rowAdd()
  569. },
  570. cnameChange(row) {
  571. this.upDataOption()
  572. this.goodsoptions.forEach(e => {
  573. if (e.itemId == row.itemId) {
  574. row.itemId = e.itemId;
  575. row.code = e.code;
  576. row.cname = e.cname;
  577. row.ename = e.ename;
  578. row.priceCategory = e.goodsTypeName;
  579. row.purchaseCost = costCal(e.price, e.taxRate);
  580. row.purchaseAmount = e.purchaseAmount;
  581. row.itemProp = null;
  582. row.remarksOne = null;
  583. row.customTwo = null;
  584. row.customThree = null;
  585. row.customFour = null;
  586. row.customFive = null;
  587. row.customSix = null;
  588. row.customSeven = null;
  589. row.customEight = null;
  590. row.customNine = null;
  591. row.customTen = null;
  592. row.partsValveName = null;
  593. row.partsValveValue = null;
  594. row.partsValveCostPrice = 0;
  595. row.partsValveSalePrice = 0;
  596. row.partsCapName = null;
  597. row.partsCapValue = null;
  598. row.partsCapCostPrice = 0;
  599. row.partsCapSalePrice = 0;
  600. row.partsHandleName = null;
  601. row.partsHandleValue = null;
  602. row.partsHandleCostPrice = 0;
  603. row.partsHandleSalePrice = 0;
  604. row.partsColourName = null;
  605. row.partsColourValue = null;
  606. row.partsColourCostPrice = 0;
  607. row.partsColourSalePrice = 0;
  608. row.partsModeName = null;
  609. row.partsModeValue = null;
  610. row.partsModeCostPrice = 0;
  611. row.partsModeSalePrice = 0;
  612. row.partsAuthenticationName = null;
  613. row.partsAuthenticationValue = null;
  614. row.partsAuthenticationCostPrice = 0;
  615. row.partsAuthenticationSalePrice = 0;
  616. row.partsOtherName = null;
  617. row.partsOtherValue = null;
  618. row.partsOtherCostPrice = 0;
  619. row.partsOtherSalePrice = 0;
  620. row.partsCost = 0;
  621. row.corpId = e.corpId;
  622. row.corpName = e.corpCode;
  623. row.itemDescription = e.cnameDescription;
  624. row.partsPrice = 0;
  625. row.itemType = e.specs;
  626. row.tradeTerms = null;
  627. row.productPrice = productCal(e.purchaseAmount, 0, this.form.coefficient);
  628. row.outFactoryPrice = sellingCal(productCal(e.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate);
  629. row.shareAmount = 0;
  630. row.internationalAmount = 0;
  631. row.totalValue = sellingCal(productCal(e.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate);
  632. row.orderQuantity = 1;
  633. row.insurance = 0;
  634. row.freight = 0;
  635. row.discount = null;
  636. row.price = sellingCal(productCal(e.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate);
  637. row.amount = sellingCal(productCal(e.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate);
  638. row.taxRate = 0;
  639. row.unit = e.unit;
  640. row.itemMargin = grossProfitCal(e.purchaseAmount, 0, sellingCal(productCal(e.purchaseAmount, 0, this
  641. .form.coefficient), this.form.exchangeRate), this.form.exchangeRate);
  642. // 处理单品毛利率是 -00.00 的问题
  643. if (Number(row.itemMargin) === 0) {
  644. row.itemMargin = Number(row.itemMargin) + ''
  645. }
  646. row.partsDescribe = null;
  647. row.remarks = null;
  648. row.exchangeRate = this.form.exchangeRate;
  649. row.productRemark = e.ename;
  650. row.attributeList = this.getAttribute(e.goodsSpecificationList),
  651. row.referrerReason = e.referrerReason
  652. }
  653. })
  654. },
  655. importLibray(rows) {
  656. this.upDataOption()
  657. rows.forEach(e => {
  658. this.goodsForm = {
  659. itemId: e.itemId,
  660. code: e.code,
  661. cname: e.cname,
  662. ename: e.ename,
  663. priceCategory: e.goodsTypeName,
  664. purchaseCost: costCal(e.price, e.taxRate),
  665. purchaseAmount: e.purchaseAmount,
  666. itemProp: null,
  667. remarksOne: null,
  668. customTwo: null,
  669. customThree: null,
  670. customFour: null,
  671. customFive: null,
  672. customSix: null,
  673. customSeven: null,
  674. customEight: null,
  675. customNine: null,
  676. customTen: null,
  677. partsValveName: null,
  678. partsValveValue: null,
  679. partsValveCostPrice: 0,
  680. partsValveSalePrice: 0,
  681. partsCapName: null,
  682. partsCapValue: null,
  683. partsCapCostPrice: 0,
  684. partsCapSalePrice: 0,
  685. partsHandleName: null,
  686. partsHandleValue: null,
  687. partsHandleCostPrice: 0,
  688. partsHandleSalePrice: 0,
  689. partsColourName: null,
  690. partsColourValue: null,
  691. partsColourCostPrice: 0,
  692. partsColourSalePrice: 0,
  693. partsModeName: null,
  694. partsModeValue: null,
  695. partsModeCostPrice: 0,
  696. partsModeSalePrice: 0,
  697. partsAuthenticationName: null,
  698. partsAuthenticationValue: null,
  699. partsAuthenticationCostPrice: 0,
  700. partsAuthenticationSalePrice: 0,
  701. partsOtherName: null,
  702. partsOtherValue: null,
  703. partsOtherCostPrice: 0,
  704. partsOtherSalePrice: 0,
  705. corpId: e.corpId,
  706. corpName: e.corpCode,
  707. itemDescription: e.cnameDescription,
  708. partsPrice: 0,
  709. partsCost: 0,
  710. itemType: e.specs,
  711. tradeTerms: null,
  712. productPrice: productCal(e.purchaseAmount, 0, this.form.coefficient),
  713. outFactoryPrice: sellingCal(
  714. productCal(e.purchaseAmount, 0, this.form.coefficient),
  715. this.form.exchangeRate
  716. ),
  717. shareAmount: 0,
  718. internationalAmount: 0,
  719. totalValue: sellingCal(
  720. productCal(e.purchaseAmount, 0, this.form.coefficient),
  721. this.form.exchangeRate
  722. ),
  723. orderQuantity: 1,
  724. insurance: 0,
  725. freight: 0,
  726. discount: null,
  727. price: sellingCal(
  728. productCal(e.purchaseAmount, 0, this.form.coefficient),
  729. this.form.exchangeRate
  730. ),
  731. amount: sellingCal(
  732. productCal(e.purchaseAmount, 0, this.form.coefficient),
  733. this.form.exchangeRate
  734. ),
  735. taxRate: 0,
  736. unit: 'PCS',
  737. itemMargin: grossProfitCal(
  738. e.purchaseAmount,
  739. 0,
  740. sellingCal(
  741. productCal(e.purchaseAmount, 0, this.form.coefficient),
  742. this.form.exchangeRate
  743. ),
  744. this.form.exchangeRate
  745. ),
  746. partsDescribe: null,
  747. remarks: null,
  748. exchangeRate: this.form.exchangeRate,
  749. productRemark: e.ename,
  750. attributeList: this.getAttribute(e.goodsSpecificationList),
  751. referrerReason:e.referrerReason
  752. }
  753. });
  754. this.$refs.crud.rowAdd()
  755. },
  756. openProperty(row) {
  757. this.$refs.property.init(row);
  758. },
  759. addLibrary() {
  760. if (!this.form.corpId) {
  761. return this.$message.error("请选择客户名称");
  762. }
  763. if (!this.form.currency) {
  764. return this.$message.error("请选择币别");
  765. }
  766. this.$refs.library.init(false);
  767. },
  768. openReport() {
  769. this.switchDialog = !this.switchDialog;
  770. },
  771. onClose(val) {
  772. this.switchDialog = val;
  773. },
  774. inInvoice() {
  775. if (!this.pickerValue)return this.$message.error("请选择日期")
  776. const data = {
  777. id: this.form.id,
  778. documentaryDate:this.pickerValue
  779. };
  780. const loading = this.$loading({
  781. lock: true,
  782. text: '加载中',
  783. spinner: 'el-icon-loading',
  784. background: 'rgba(255,255,255,0.7)'
  785. });
  786. deliverGoods(data).then(res => {
  787. if (res.data.code == 200) {
  788. this.$message.success("生成成功");
  789. this.dialog = false
  790. this.pickerValue = ''
  791. loading.close()
  792. this.$emit("backToList",this.form.id)
  793. }
  794. }).catch(()=>{
  795. loading.close()
  796. this.pickerValue = ''
  797. this.dialog = false
  798. })
  799. },
  800. saveSell() {
  801. if (!this.pickerValue) return this.$message.error("请选择日期")
  802. if (!this.form.id) {
  803. return this.$message.error("此单据没有提交记录,请先提交");
  804. }
  805. if (!this.form.buyerId){
  806. return this.$message.error("采购员必填");
  807. }
  808. const loading = this.$loading({
  809. lock: true,
  810. text: '加载中',
  811. spinner: 'el-icon-loading',
  812. background: 'rgba(255,255,255,0.7)'
  813. });
  814. generatePurchaseNews(this.form.id,this.pickerValue).then(res => {
  815. if (res.data.code == 200) {
  816. this.$message.success("生成成功");
  817. this.dialog = false
  818. this.pickerValue = ''
  819. loading.close()
  820. this.$emit("backToList",this.form.id)
  821. }
  822. }).catch(()=>{
  823. this.pickerValue = ''
  824. this.dialog = false
  825. loading.close()
  826. })
  827. },
  828. getInvoice() {
  829. if (this.$store.getters.outStatus) {
  830. this.$alert("出口跟单存在,请保存发货单再进行操作", "温馨提示", {
  831. confirmButtonText: "确定",
  832. type: "warning",
  833. callback: action => {
  834. console.log(action);
  835. }
  836. });
  837. } else {
  838. this.inInvoice();
  839. }
  840. },
  841. cnameData() {
  842. this.goodsoptions = []
  843. getGoods(1, 10).then(res => {
  844. if (res.data.data.total > 0) {
  845. this.goodsoptions = res.data.data.records;
  846. if (Math.ceil(res.data.data.total / 10) > 1) {
  847. for (let i = 2; i <= Math.ceil(res.data.data.total / 10); i++) {
  848. getGoods(i, 10).then(e => {
  849. this.goodsoptions = this.goodsoptions.concat(e.data.data.records);
  850. });
  851. }
  852. }
  853. }
  854. });
  855. },
  856. pleaseCheck(){
  857. this.$parent.pleaseCheck()
  858. },
  859. calculate(val) {
  860. this.form.totalValue = 0
  861. this.data.forEach((e, index) => {
  862. e.sort = Number(index) + 1
  863. this.form.totalValue = sum(multiply(e.outFactoryPrice, e.orderQuantity), this.form.totalValue)
  864. })
  865. if (val == 1) {
  866. let numSum = 0
  867. this.orderFeesList.forEach(e => {
  868. if (e.feesType == 2 && e.currency == "CNY") {
  869. console.log(sum, e.amount)
  870. numSum = sum(numSum, e.amount)
  871. }
  872. })
  873. let num = 0;
  874. num = divide(divide(numSum, this.form.totalValue, 10), this.form.exchangeRate, 10)
  875. this.$confirm("总运费:" + divide(numSum, this.form.exchangeRate) + ",单价分摊运费:" + num + ",是否继续更新?", {
  876. confirmButtonText: "确定",
  877. cancelButtonText: "取消",
  878. type: "warning"
  879. }).then(() => {
  880. this.data.forEach(e => {
  881. e.shareAmount = multiply(num, e.outFactoryPrice, 10)
  882. e.price = addPrice(e.outFactoryPrice, multiply(num, e.outFactoryPrice, 10), e.internationalAmount)
  883. e.amount = amountCal(
  884. addPrice(e.outFactoryPrice, multiply(num, e.outFactoryPrice, 10), e.internationalAmount),
  885. e.orderQuantity,
  886. e.freight,
  887. e.insurance,
  888. e.discount
  889. );
  890. e.itemMargin = grossProfitCal(
  891. e.purchaseAmount,
  892. e.partsPrice,
  893. e.outFactoryPrice,
  894. this.form.exchangeRate
  895. );
  896. })
  897. })
  898. } else {
  899. let numSum = 0
  900. this.orderFeesList.forEach(e => {
  901. if (e.feesType == 2 && e.currency == "USD") {
  902. console.log(sum, e.amount)
  903. numSum = sum(numSum, e.amount)
  904. }
  905. })
  906. let num = 0;
  907. num = divide(numSum, this.form.totalValue, 10)
  908. this.$confirm("总运费:" + numSum + ",单价分摊运费:" + num + ",是否继续更新?", {
  909. confirmButtonText: "确定",
  910. cancelButtonText: "取消",
  911. type: "warning"
  912. }).then(() => {
  913. this.data.forEach(e => {
  914. e.internationalAmount = multiply(num, e.outFactoryPrice, 10)
  915. e.price = addPrice(e.outFactoryPrice, multiply(num, e.outFactoryPrice, 10), e.shareAmount)
  916. e.amount = amountCal(
  917. addPrice(e.outFactoryPrice, multiply(num, e.outFactoryPrice, 10), e.shareAmount),
  918. e.orderQuantity,
  919. e.freight,
  920. e.insurance,
  921. e.discount
  922. );
  923. e.itemMargin = grossProfitCal(
  924. e.purchaseAmount,
  925. e.partsPrice,
  926. e.outFactoryPrice,
  927. this.form.exchangeRate
  928. );
  929. })
  930. })
  931. }
  932. },
  933. khEdit(status) {
  934. if (status == 'cname') {
  935. this.$router.push({
  936. path: '/basicData/commodityType/index'
  937. })
  938. }
  939. },
  940. rowCell(row, index) {
  941. this.getAttribute(JSON.parse(row.attributeList) || [])
  942. this.$refs.crud.rowEdit(row, index)
  943. },
  944. rowDel(row) {
  945. this.$confirm("确定删除数据?", {
  946. confirmButtonText: "确定",
  947. cancelButtonText: "取消",
  948. type: "warning"
  949. }).then(() => {
  950. if (row.id) {
  951. delItem(row.id).then(res => {
  952. this.$message({
  953. type: "success",
  954. message: "删除成功!"
  955. });
  956. this.data.splice(row.$index, 1);
  957. });
  958. } else {
  959. this.$message({
  960. type: "success",
  961. message: "删除成功!"
  962. });
  963. this.data.splice(row.$index, 1);
  964. }
  965. });
  966. },
  967. moveUp(row, index) {
  968. this.data[index] = this.data.splice(index - 1, 1, row)[0]
  969. },
  970. moveDown(row, index) {
  971. this.data[index] = this.data.splice(index + 1, 1, row)[0]
  972. },
  973. purchaseAmountChange(row) {
  974. row.productPrice = productCal(
  975. row.purchaseAmount,
  976. row.partsPrice,
  977. this.form.coefficient
  978. );
  979. row.outFactoryPrice = sellingCal(row.productPrice, this.form.exchangeRate);
  980. row.totalValue = multiply(row.outFactoryPrice, row.orderQuantity)
  981. row.price = addPrice(
  982. row.outFactoryPrice,
  983. row.shareAmount,
  984. row.internationalAmount
  985. );
  986. row.amount = amountCal(
  987. row.price,
  988. row.orderQuantity,
  989. row.freight,
  990. row.insurance,
  991. row.discount
  992. );
  993. row.itemMargin = grossProfitCal(
  994. row.purchaseAmount,
  995. row.partsPrice,
  996. row.outFactoryPrice,
  997. this.form.exchangeRate
  998. );
  999. },
  1000. outFactoryPriceInput(row){
  1001. console.log(row,1005)
  1002. this.$set(row,'outFactoryChange',true)
  1003. },
  1004. priceChange(row) {
  1005. row.totalValue = multiply(row.outFactoryPrice, row.orderQuantity)
  1006. row.price = addPrice(row.outFactoryPrice, row.shareAmount, row.internationalAmount)
  1007. row.amount = amountCal(
  1008. addPrice(row.outFactoryPrice, row.shareAmount, row.internationalAmount),
  1009. row.orderQuantity,
  1010. row.freight,
  1011. row.insurance,
  1012. row.discount
  1013. );
  1014. console.log(row.purchaseAmount,'purchaseAmount')
  1015. console.log(row.partsPrice,'partsPrice')
  1016. console.log(row.outFactoryPrice,'outFactoryPrice')
  1017. console.log(this.form.exchangeRate,'exchangeRate')
  1018. // this.$set(row,'outFactoryChange',true)
  1019. row.itemMargin = grossProfitCal(
  1020. row.purchaseAmount,
  1021. row.partsPrice,
  1022. row.outFactoryPrice,
  1023. this.form.exchangeRate
  1024. );
  1025. // 处理单品毛利率是 -00.00 的问题
  1026. if (Number(row.itemMargin) === 0) {
  1027. row.itemMargin = Number(row.itemMargin) + ''
  1028. }
  1029. // 出厂价格为零,单品毛利润为零
  1030. if(row.outFactoryPrice == 0) {
  1031. row.itemMargin = 0
  1032. }
  1033. },
  1034. itemTypeFocus(row) {
  1035. this.itemtypeList = [];
  1036. getSpecification({
  1037. goodId: row.itemId
  1038. }).then(res => {
  1039. const data = res.data.data;
  1040. this.itemtypeList = data.map(item => ({
  1041. value: item
  1042. }));
  1043. });
  1044. },
  1045. getAttribute(rows) {
  1046. let data = []
  1047. rows.forEach(e => {
  1048. if (e.attributeNo == 'Thread' && e.status == 0) {
  1049. this.findObject(this.tableOption.column, "remarksOne").disabled = false;
  1050. }
  1051. if (e.attributeNo == 'medium' && e.status == 0) {
  1052. this.findObject(this.tableOption.column, "customTwo").disabled = false;
  1053. }
  1054. if (e.attributeNo == 'property_color' && e.status == 0) {
  1055. this.findObject(this.tableOption.column, "customThree").disabled = false;
  1056. }
  1057. if (e.attributeNo == 'stencil' && e.status == 0) {
  1058. this.findObject(this.tableOption.column, "customFour").disabled = false;
  1059. }
  1060. if (e.attributeName == '阀门配件' && e.status == 0) {
  1061. this.findObject(this.tableOption.column, "partsValveName").disabled = false;
  1062. }
  1063. if (e.attributeName == '瓶帽配件' && e.status == 0) {
  1064. this.findObject(this.tableOption.column, "partsCapName").disabled = false;
  1065. }
  1066. if (e.attributeName == '特殊处理' && e.status == 0) {
  1067. this.findObject(this.tableOption.column, "partsHandleName").disabled = false;
  1068. }
  1069. if (e.attributeName == '包装方式' && e.status == 0) {
  1070. this.findObject(this.tableOption.column, "partsColourName").disabled = false;
  1071. }
  1072. if (e.attributeName == '特殊颜色' && e.status == 0) {
  1073. this.findObject(this.tableOption.column, "partsModeName").disabled = false;
  1074. }
  1075. if (e.attributeName == '认证' && e.status == 0) {
  1076. this.findObject(this.tableOption.column, "partsAuthenticationName").disabled = false;
  1077. }
  1078. if (e.attributeName == '其他' && e.status == 0) {
  1079. this.findObject(this.tableOption.column, "partsOtherName").disabled = false;
  1080. }
  1081. data.push({
  1082. type: e.type,
  1083. attributeName: e.attributeName,
  1084. attributeNo: e.attributeNo,
  1085. status: e.status,
  1086. })
  1087. })
  1088. return JSON.stringify(data);
  1089. },
  1090. // importProperty(row) {
  1091. // const arr = [];
  1092. // for (let key in row) {
  1093. // if (row[key]) {
  1094. // arr.push(row[key]);
  1095. // }
  1096. // }
  1097. // this.goodsForm.itemProp = arr.join(" ");
  1098. // this.goodsForm.remarksOne = row.remarksOne;
  1099. // this.goodsForm.customTwo = row.customTwo;
  1100. // this.goodsForm.customThree = row.customThree;
  1101. // this.goodsForm.customFour = row.customFour;
  1102. // this.goodsForm.customFive = row.customFive;
  1103. // this.goodsForm.customSix = row.customSix;
  1104. // this.goodsForm.customSeven = row.customSeven;
  1105. // this.goodsForm.customEight = row.customEight;
  1106. // this.goodsForm.customNine = row.customNine;
  1107. // this.goodsForm.customTen = row.customTen;
  1108. // this.goodsForm.productRemark = this.getproductRemark(this.goodsForm)
  1109. // },
  1110. importPart(rows, type) {
  1111. if (type == 0) {
  1112. this.goodsForm.partsValveCostPrice = 0
  1113. this.goodsForm.partsValveSalePrice = 0
  1114. let names = []
  1115. rows.forEach(e => {
  1116. names.push(e.goodName)
  1117. this.goodsForm.partsValveCostPrice = sum(this.goodsForm.partsValveCostPrice, multiply(e.partsCost, e.goodNumber));
  1118. this.goodsForm.partsValveSalePrice = sum(this.goodsForm.partsValveSalePrice, e.amout);
  1119. })
  1120. this.goodsForm.partsValveName = names.join(" ")
  1121. this.goodsForm.partsValveValue = JSON.stringify(rows)
  1122. }
  1123. if (type == 1) {
  1124. this.goodsForm.partsCapCostPrice = 0
  1125. this.goodsForm.partsCapSalePrice = 0
  1126. let names = []
  1127. rows.forEach(e => {
  1128. names.push(e.goodName)
  1129. this.goodsForm.partsCapCostPrice = sum(this.goodsForm.partsCapCostPrice, multiply(e.partsCost, e.goodNumber));
  1130. this.goodsForm.partsCapSalePrice = sum(this.goodsForm.partsCapSalePrice, e.amout);
  1131. })
  1132. this.goodsForm.partsCapName = names.join(" ")
  1133. this.goodsForm.partsCapValue = JSON.stringify(rows)
  1134. }
  1135. if (type == 2) {
  1136. this.goodsForm.partsHandleCostPrice = 0
  1137. this.goodsForm.partsHandleSalePrice = 0
  1138. let names = []
  1139. rows.forEach(e => {
  1140. names.push(e.goodName)
  1141. this.goodsForm.partsHandleCostPrice = sum(this.goodsForm.partsHandleCostPrice, multiply(e.partsCost, e.goodNumber));
  1142. this.goodsForm.partsHandleSalePrice = sum(this.goodsForm.partsHandleSalePrice, e.amout);
  1143. })
  1144. this.goodsForm.partsHandleName = names.join(" ")
  1145. this.goodsForm.partsHandleValue = JSON.stringify(rows)
  1146. }
  1147. if (type == 3) {
  1148. this.goodsForm.partsColourCostPrice = 0
  1149. this.goodsForm.partsColourSalePrice = 0
  1150. let names = []
  1151. rows.forEach(e => {
  1152. names.push(e.goodName)
  1153. this.goodsForm.partsColourCostPrice = sum(this.goodsForm.partsColourCostPrice, multiply(e.partsCost, e.goodNumber));
  1154. this.goodsForm.partsColourSalePrice = sum(this.goodsForm.partsColourSalePrice, e.amout);
  1155. })
  1156. this.goodsForm.partsColourName = names.join(" ")
  1157. this.goodsForm.partsColourValue = JSON.stringify(rows)
  1158. }
  1159. if (type == 4) {
  1160. this.goodsForm.partsModeCostPrice = 0
  1161. this.goodsForm.partsModeSalePrice = 0
  1162. let names = []
  1163. rows.forEach(e => {
  1164. names.push(e.goodName)
  1165. this.goodsForm.partsModeCostPrice = sum(this.goodsForm.partsModeCostPrice, multiply(e.partsCost, e.goodNumber));
  1166. this.goodsForm.partsModeSalePrice = sum(this.goodsForm.partsModeSalePrice, e.amout);
  1167. })
  1168. this.goodsForm.partsModeName = names.join(" ")
  1169. this.goodsForm.partsModeValue = JSON.stringify(rows)
  1170. }
  1171. if (type == 5) {
  1172. this.goodsForm.partsAuthenticationCostPrice = 0
  1173. this.goodsForm.partsAuthenticationSalePrice = 0
  1174. let names = []
  1175. rows.forEach(e => {
  1176. names.push(e.goodName)
  1177. this.goodsForm.partsAuthenticationCostPrice = sum(this.goodsForm.partsAuthenticationCostPrice, multiply(e.partsCost, e.goodNumber));
  1178. this.goodsForm.partsAuthenticationSalePrice = sum(this.goodsForm.partsAuthenticationSalePrice, e.amout);
  1179. })
  1180. this.goodsForm.partsAuthenticationName = names.join(" ")
  1181. this.goodsForm.partsAuthenticationValue = JSON.stringify(rows)
  1182. }
  1183. if (type == 6) {
  1184. this.goodsForm.partsOtherCostPrice = 0
  1185. this.goodsForm.partsOtherSalePrice = 0
  1186. let names = []
  1187. rows.forEach(e => {
  1188. names.push(e.goodName)
  1189. this.goodsForm.partsOtherCostPrice = sum(this.goodsForm.partsOtherCostPrice, multiply(e.partsCost, e.goodNumber));
  1190. this.goodsForm.partsOtherSalePrice = sum(this.goodsForm.partsOtherSalePrice, e.amout);
  1191. })
  1192. this.goodsForm.partsOtherName = names.join(" ")
  1193. this.goodsForm.partsOtherValue = JSON.stringify(rows)
  1194. }
  1195. 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)
  1196. 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)
  1197. // 销售价=(配件采购价格+产品价格)/汇率 *(1+客户FOB系数/100)
  1198. this.goodsForm.productPrice = productCal(
  1199. this.goodsForm.purchaseAmount,
  1200. this.goodsForm.partsPrice,
  1201. this.form.coefficient
  1202. );
  1203. this.goodsForm.outFactoryPrice = sellingCal(
  1204. this.goodsForm.productPrice,
  1205. this.form.exchangeRate
  1206. );
  1207. this.goodsForm.price = addPrice(
  1208. this.goodsForm.outFactoryPrice,
  1209. this.goodsForm.shareAmount,
  1210. this.goodsForm.internationalAmount
  1211. );
  1212. this.goodsForm.amount = amountCal(
  1213. this.goodsForm.price,
  1214. this.goodsForm.orderQuantity,
  1215. this.goodsForm.freight,
  1216. this.goodsForm.insurance,
  1217. this.goodsForm.discount
  1218. );
  1219. this.goodsForm.itemMargin = grossProfitCal(
  1220. this.goodsForm.purchaseAmount,
  1221. this.goodsForm.partsPrice,
  1222. this.goodsForm.outFactoryPrice,
  1223. this.form.exchangeRate
  1224. );
  1225. const names = [this.goodsForm.partsModeName, this.goodsForm.partsHandleName, this.goodsForm.partsCapName, this.goodsForm.partsValveName, this.goodsForm.partsColourName, this.goodsForm.partsAuthenticationName, this.goodsForm.partsOtherName];
  1226. const name = []
  1227. names.forEach(e => {
  1228. if (e) {
  1229. name.push(e)
  1230. }
  1231. })
  1232. this.goodsForm.partsDescribe = name.join("; ");
  1233. this.goodsForm.productRemark = this.getproductRemark(this.goodsForm)
  1234. },
  1235. propsChange(row) {
  1236. const data = {
  1237. remarksOne: row.remarksOne,
  1238. customTwo: row.customTwo,
  1239. customThree: row.customThree,
  1240. customFour: row.customFour,
  1241. customFive: row.customFive,
  1242. customSix: row.customSix,
  1243. customSeven: row.customSeven,
  1244. customEight: row.customEight,
  1245. customNine: row.customNine,
  1246. customTen: row.customTen,
  1247. };
  1248. const arr = []
  1249. for (let key in data) {
  1250. if (row[key]) {
  1251. arr.push(row[key]);
  1252. }
  1253. }
  1254. this.goodsForm.itemProp = arr.join(', ')
  1255. this.goodsForm.productRemark = this.getproductRemark(this.goodsForm)
  1256. },
  1257. editChange(row) {
  1258. row.productRemark = this.getproductRemark(row)
  1259. },
  1260. getproductRemark(row) {
  1261. const ename = row.ename ? row.ename : "";
  1262. const itemDescription = row.itemDescription
  1263. ? row.itemDescription
  1264. : "";
  1265. const itemProp = row.itemProp ? row.itemProp : ''
  1266. const partsDescribe = row.partsDescribe ? row.partsDescribe : ''
  1267. const productRemark =
  1268. ename + " " + itemDescription + "\n" +
  1269. itemProp + "\n" +
  1270. partsDescribe
  1271. return productRemark
  1272. },
  1273. beforeClose(done) {
  1274. this.upDataOption()
  1275. done();
  1276. },
  1277. upDataOption() {
  1278. this.findObject(this.tableOption.column, "remarksOne").disabled = true;
  1279. this.findObject(this.tableOption.column, "customTwo").disabled = true;
  1280. this.findObject(this.tableOption.column, "customThree").disabled = true;
  1281. this.findObject(this.tableOption.column, "customFour").disabled = true;
  1282. this.findObject(this.tableOption.column, "partsValveName").disabled = true;
  1283. this.findObject(this.tableOption.column, "partsCapName").disabled = true;
  1284. this.findObject(this.tableOption.column, "partsHandleName").disabled = true;
  1285. this.findObject(this.tableOption.column, "partsColourName").disabled = true;
  1286. this.findObject(this.tableOption.column, "partsModeName").disabled = true;
  1287. this.findObject(this.tableOption.column, "partsAuthenticationName").disabled = true;
  1288. this.findObject(this.tableOption.column, "partsOtherName").disabled = true;
  1289. },
  1290. discountChange(row) {
  1291. if (row.discount >= 10) {
  1292. row.discount = null;
  1293. this.$message.error("请正确输入折扣");
  1294. }
  1295. this.priceChange(row);
  1296. },
  1297. taxRateChange(row) {
  1298. if (row.taxRate > 100) {
  1299. row.taxRate = 0;
  1300. this.$message.error("请正确输入税率");
  1301. }
  1302. },
  1303. handleRowSave(row, done, loading) {
  1304. this.data.push(row)
  1305. loading()
  1306. done()
  1307. },
  1308. handleRowUpdate(row, index, done, loading) {
  1309. this.$set(this.data,index,row)
  1310. loading()
  1311. done()
  1312. },
  1313. async saveColumn() {
  1314. const inSave = await this.saveColumnData(
  1315. this.getColumnName(5),
  1316. this.tableOption
  1317. );
  1318. if (localStorage.getItem("roleName") == "贸易") {
  1319. this.findObject(this.tableOption.column, "purchaseCost").hide = true;
  1320. this.findObject(this.tableOption.column, "purchaseCost").showColumn = false;
  1321. this.findObject(this.tableOption.column, "partsCost").hide = true;
  1322. this.findObject(this.tableOption.column, "partsCost").showColumn = false;
  1323. this.findObject(this.tableOption.column, "purchaseAmount").hide = true;
  1324. this.findObject(this.tableOption.column, "purchaseAmount").showColumn = false;
  1325. this.findObject(this.tableOption.column, "corpName").hide = true;
  1326. this.findObject(this.tableOption.column, "corpName").showColumn = false;
  1327. }
  1328. if (inSave) {
  1329. this.$nextTick(() => {
  1330. this.$refs.crud.doLayout();
  1331. });
  1332. this.getWorkDicts("cargo_type").then(res => {
  1333. this.findObject(this.tableOption.column, "cargoType").dicData =
  1334. res.data.data;
  1335. });
  1336. this.$message.success("保存成功");
  1337. //关闭窗口
  1338. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  1339. }
  1340. },
  1341. async resetColumn() {
  1342. this.tableOption = tableOption;
  1343. const inSave = await this.delColumnData(
  1344. this.getColumnName(5),
  1345. tableOption
  1346. );
  1347. if (inSave) {
  1348. this.$nextTick(() => {
  1349. this.$refs.crud.doLayout();
  1350. });
  1351. if (localStorage.getItem("roleName") == "贸易") {
  1352. this.findObject(this.tableOption.column, "purchaseCost").hide = true;
  1353. this.findObject(this.tableOption.column, "purchaseCost").showColumn = false;
  1354. this.findObject(this.tableOption.column, "partsCost").hide = true;
  1355. this.findObject(this.tableOption.column, "partsCost").showColumn = false;
  1356. this.findObject(this.tableOption.column, "purchaseAmount").hide = true;
  1357. this.findObject(this.tableOption.column, "purchaseAmount").showColumn = false;
  1358. this.findObject(this.tableOption.column, "corpName").hide = true;
  1359. this.findObject(this.tableOption.column, "corpName").showColumn = false;
  1360. }
  1361. this.$message.success("重置成功");
  1362. //关闭窗口
  1363. setTimeout(() => {
  1364. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  1365. }, 1000);
  1366. }
  1367. },
  1368. async saveGoodsColumn() {
  1369. const inSave = await this.saveColumnData(
  1370. this.getColumnName(28),
  1371. this.goodsOption
  1372. );
  1373. if (inSave) {
  1374. this.$nextTick(() => {
  1375. this.$refs.goodsCrud.doLayout();
  1376. });
  1377. this.$message.success("保存成功");
  1378. //关闭窗口
  1379. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  1380. }
  1381. },
  1382. async resetGoodsColumn() {
  1383. this.goodsOption = goodsOption;
  1384. const inSave = await this.delColumnData(
  1385. this.getColumnName(28),
  1386. goodsOption
  1387. );
  1388. if (inSave) {
  1389. this.$nextTick(() => {
  1390. this.$refs.goodsCrud.doLayout();
  1391. });
  1392. this.$message.success("重置成功");
  1393. //关闭窗口
  1394. setTimeout(() => {
  1395. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  1396. }, 1000);
  1397. }
  1398. }
  1399. },
  1400. watch: {
  1401. dialog(newVla, oldVal) {
  1402. if (newVla){
  1403. this.pickerValue = dateFormat(new Date(), "yyyy-MM-dd") + " 00:00:00"
  1404. }
  1405. }
  1406. }
  1407. };
  1408. </script>
  1409. <style scoped>
  1410. ::v-deep .select-component {
  1411. display: flex;
  1412. }
  1413. .page-crad ::v-deep .basic-container__card {
  1414. height: 94.2vh;
  1415. }
  1416. .itemTable ::v-deep .el-table {
  1417. width: 738px;
  1418. }
  1419. /* ::v-deep .el-input-group__append,
  1420. .el-input-group__prepend {
  1421. padding: 0 5px;
  1422. } */
  1423. </style>