goodsInfo.vue 57 KB

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