baseForm.vue 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307
  1. <template>
  2. <el-form
  3. :model="ruleForm"
  4. status-icon
  5. :rules="rulesThis"
  6. ref="ruleForm"
  7. :size="'mini'"
  8. v-loading="loading"
  9. label-width="85px"
  10. class="demo-ruleForm"
  11. >
  12. <el-row>
  13. <el-col
  14. :span="24"
  15. style="padding: 12px 16px 12px 16px; text-align: right"
  16. >
  17. <!-- 贵金属重量*供应商采购金价 + 工艺费*贵金属重量+加标费+包装费+证书费+成本裸价+运费+其他费用=成本合计 -->
  18. <!-- 贵金属重量*供应商采购金价 + 工艺费*贵金属重量+加标费+包装费+证书费+成本裸价+运费=成本合计 -->
  19. <!-- ps:没有其他费用-->
  20. <!-- (ruleForm.noble_weight*askItem.gold_price)+ (ruleForm.cost_fee*ruleForm.noble_weight)
  21. + ruleForm.mark_fee + ruleForm.pakge_fee + ruleForm.cert_fee + ruleForm.nake_fee + ruleForm.delivery_fee-->
  22. <!-- 乘法精度函数调用在mounted(初始调用),number_change函数(改变调用),如果放在dom层初始值时undifind会报错 r1,r2-->
  23. <span
  24. >成本合计:<span>
  25. {{
  26. accAdd(
  27. r1,
  28. r2,
  29. ruleForm.mark_fee,
  30. ruleForm.pakge_fee,
  31. ruleForm.cert_fee,
  32. ruleForm.nake_fee,
  33. ruleForm.delivery_fee,
  34. )
  35. }}
  36. <!-- {{ruleForm.delivery_fee}} -->
  37. </span></span
  38. >
  39. <span
  40. class="fl"
  41. style="height: 28px; font-size: 16px; line-height: 28px"
  42. >{{ title }}</span
  43. >
  44. <el-button :size="'mini'" @click="$emit('cancel')">取 消 </el-button>
  45. <el-button
  46. :size="'mini'"
  47. type="primary"
  48. v-if="type !== 'view'"
  49. @click="submitForm"
  50. >保 存
  51. </el-button>
  52. </el-col>
  53. <el-col :span="16">
  54. <el-form-item label="供应商" prop="supplierNo">
  55. <search-supplier
  56. :value="ruleForm.supplierNo"
  57. :placeholder="'供应商'"
  58. :size="'mini'"
  59. :names="supplierNo_name"
  60. :disabled="type === 'view'"
  61. :isDetail="type !== 'add'"
  62. @searchChange="supplierNosearchChange"
  63. />
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="8">
  67. <el-form-item label="品牌" prop="brandid" label-width="60px">
  68. <search-brand
  69. :value="ruleForm.brandid"
  70. :size="'mini'"
  71. :disabled="false"
  72. :isDetail="true"
  73. :names="brand_name"
  74. :placeholder="'品牌'"
  75. @searchChange="brandidsearchChange"
  76. />
  77. </el-form-item>
  78. </el-col>
  79. <el-col :span="5">
  80. <el-form-item label="有效期" prop="expire_day">
  81. <digital-input
  82. :values="ruleForm.expire_day"
  83. :placeholder="'有效期'"
  84. :min="0"
  85. :max="100000000000"
  86. :position="'right'"
  87. :precision="0"
  88. :size="'mini'"
  89. :disabled="type === 'view'"
  90. :controls="false"
  91. :append="'天'"
  92. @reschange="number_change($event, 'expire_day')"
  93. />
  94. </el-form-item>
  95. </el-col>
  96. <el-col :span="5">
  97. <el-form-item label="物流时间" prop="delivery_day">
  98. <digital-input
  99. :values="ruleForm.delivery_day"
  100. :placeholder="'物流时间'"
  101. :min="0"
  102. :max="100000000000"
  103. :position="'right'"
  104. :precision="0"
  105. :size="'mini'"
  106. :disabled="type === 'view'"
  107. :controls="false"
  108. :append="'天'"
  109. @reschange="number_change($event, 'delivery_day')"
  110. />
  111. </el-form-item>
  112. </el-col>
  113. <el-col :span="5">
  114. <el-form-item label="生产工期" prop="work_day">
  115. <digital-input
  116. :values="ruleForm.work_day"
  117. :placeholder="'生产工期'"
  118. :min="0"
  119. :max="100000000000"
  120. :disabled="type === 'view'"
  121. :position="'right'"
  122. :precision="0"
  123. :size="'mini'"
  124. :controls="false"
  125. :append="'天'"
  126. @reschange="number_change($event, 'work_day')"
  127. />
  128. </el-form-item>
  129. </el-col>
  130. <el-col :span="5">
  131. <el-form-item label="税点" prop="tax" label-width="60px">
  132. <search-tax
  133. :value="ruleForm.tax"
  134. :size="'mini'"
  135. :disabled="type === 'view'"
  136. :isDetail="type !== 'add'"
  137. :placeholder="'税点'"
  138. @searchChange="taxsearchChange"
  139. />
  140. </el-form-item>
  141. </el-col>
  142. <el-col :span="4">
  143. <el-form-item label="单位" prop="unit_id" label-width="60px">
  144. <search-unit
  145. :value="ruleForm.unit_id"
  146. :size="'mini'"
  147. :isDetail="true"
  148. :names="unit_name"
  149. :disabled="false"
  150. :placeholder="'单位'"
  151. @searchChange="unitsearchChange"
  152. />
  153. </el-form-item>
  154. </el-col>
  155. <el-col :span="24">
  156. <el-row>
  157. <el-col :span="12">
  158. <el-form-item label="分类" prop="cat_id">
  159. <search-sort
  160. :value="ruleForm.cat_id"
  161. :placeholder="'分类'"
  162. :size="'mini'"
  163. :names="cat_id_name"
  164. :disabled="false"
  165. :isDetail="true"
  166. @searchChange="cat_id_change"
  167. />
  168. </el-form-item>
  169. <el-form-item label="商品名称" prop="pname">
  170. <el-input
  171. placeholder="商品名称"
  172. maxlength="100"
  173. :disabled="type === 'view'"
  174. v-model="ruleForm.pname"
  175. ></el-input>
  176. </el-form-item>
  177. <el-form-item label="产地" prop="origin_place">
  178. <select-area
  179. :placeholder="'产地'"
  180. :value="ruleForm.origin_place"
  181. :size="'mini'"
  182. :disabled="type === 'view'"
  183. :is-detail="id !== 'add'"
  184. @selectChange="selectAreaorigin_place"
  185. />
  186. </el-form-item>
  187. </el-col>
  188. <el-col :span="12" style="padding: 0 0 0 15px">
  189. <el-table
  190. :data="spec_tableData"
  191. :size="'mini'"
  192. border
  193. style="width: 100%"
  194. max-height="120px"
  195. >
  196. <el-table-column prop="spec_name" label="规格类型" />
  197. <el-table-column prop="spec_value_name" label="规格值" />
  198. <el-table-column
  199. fixed="right"
  200. width="88px"
  201. v-if="type !== 'view'"
  202. >
  203. <template slot="header" slot-scope="scope">
  204. <span>操作</span>
  205. <el-tooltip
  206. class="item"
  207. effect="dark"
  208. content="添加规格类型"
  209. placement="top"
  210. >
  211. <i
  212. class="el-icon-circle-plus-outline fr"
  213. style="font-size: 18px; margin-top: 2px"
  214. @click="openEdit('-1', {})"
  215. />
  216. </el-tooltip>
  217. </template>
  218. <template slot-scope="scope">
  219. <el-tooltip effect="dark" content="修改" placement="top">
  220. <i
  221. class="el-icon-edit tb-icon"
  222. @click="openEdit(scope.$index, scope.row)"
  223. ></i>
  224. </el-tooltip>
  225. <el-tooltip effect="dark" content="删除" placement="top">
  226. <i
  227. class="el-icon-delete tb-icon"
  228. @click="openDelete(scope.$index)"
  229. ></i>
  230. </el-tooltip>
  231. </template>
  232. </el-table-column>
  233. </el-table>
  234. <!-- 弹窗 新增/修改 -->
  235. <base-form-add-edit
  236. :index="modelIndex"
  237. :show-model="showOtherModel"
  238. :sitem="modelSitem"
  239. @refresh="refreshEdit"
  240. @cancel="showOtherModel = false"
  241. />
  242. </el-col>
  243. </el-row>
  244. </el-col>
  245. <el-col :span="6">
  246. <el-form-item label="总重量" prop="weight">
  247. <digital-input
  248. :values="ruleForm.weight"
  249. :placeholder="'总重量'"
  250. :min="0"
  251. :max="100000000000"
  252. :position="'right'"
  253. :precision="3"
  254. :disabled="type === 'view'"
  255. :size="'mini'"
  256. :controls="false"
  257. :append="'g'"
  258. @reschange="number_change($event, 'weight')"
  259. />
  260. </el-form-item>
  261. </el-col>
  262. <el-col :span="6">
  263. <el-form-item label="供货区域" prop="supply_area">
  264. <el-select
  265. v-model="ruleForm.supply_area"
  266. filterable
  267. :disabled="type === 'view'"
  268. clearable
  269. style="width: 100%"
  270. placeholder="供货区域"
  271. >
  272. <el-option
  273. v-for="group in options6"
  274. :key="group.id"
  275. :label="group.name"
  276. :value="group.id"
  277. />
  278. </el-select>
  279. </el-form-item>
  280. </el-col>
  281. <el-col :span="6">
  282. <el-form-item label="付款方式" prop="pay_way" class="clear">
  283. <el-select
  284. v-model="ruleForm.pay_way"
  285. filterable
  286. :disabled="type === 'view'"
  287. clearable
  288. style="width: 100%"
  289. placeholder="付款方式"
  290. >
  291. <el-option
  292. v-for="group in options10"
  293. :key="group.id"
  294. :label="group.name"
  295. :value="group.id"
  296. />
  297. </el-select>
  298. </el-form-item>
  299. </el-col>
  300. <el-col :span="6">
  301. <el-form-item label="发货方式" prop="send_way" class="clear">
  302. <el-select
  303. v-model="ruleForm.send_way"
  304. filterable
  305. clearable
  306. :disabled="type === 'view'"
  307. style="width: 100%"
  308. placeholder="发货方式"
  309. >
  310. <el-option
  311. v-for="group in options11"
  312. :key="group.id"
  313. :label="group.name"
  314. :value="group.id"
  315. />
  316. </el-select>
  317. </el-form-item>
  318. </el-col>
  319. <el-col :span="6">
  320. <el-form-item label="证书费" prop="cert_fee">
  321. <digital-input
  322. :values="ruleForm.cert_fee"
  323. :placeholder="'证书费'"
  324. :min="0"
  325. :disabled="type === 'view'"
  326. :max="100000000000"
  327. :position="'right'"
  328. :precision="2"
  329. :size="'mini'"
  330. :controls="false"
  331. :append="'元'"
  332. @reschange="number_change($event, 'cert_fee')"
  333. />
  334. </el-form-item>
  335. </el-col>
  336. <el-col :span="6">
  337. <el-form-item label="包装费" prop="pakge_fee">
  338. <digital-input
  339. :values="ruleForm.pakge_fee"
  340. :placeholder="'包装费'"
  341. :min="0"
  342. :disabled="type === 'view'"
  343. :max="100000000000"
  344. :position="'right'"
  345. :precision="2"
  346. :size="'mini'"
  347. :controls="false"
  348. :append="'元'"
  349. @reschange="number_change($event, 'pakge_fee')"
  350. />
  351. </el-form-item>
  352. </el-col>
  353. <el-col :span="6">
  354. <el-form-item label="工艺费" prop="cost_fee">
  355. <digital-input
  356. :values="ruleForm.pcost_fee"
  357. :placeholder="'工艺费'"
  358. :min="0"
  359. :disabled="type === 'view'"
  360. :max="100000000000"
  361. :position="'right'"
  362. :precision="2"
  363. :size="'mini'"
  364. :controls="false"
  365. :append="'元'"
  366. @reschange="number_change($event, 'cost_fee')"
  367. />
  368. </el-form-item>
  369. </el-col>
  370. <el-col :span="6">
  371. <el-form-item label="加标费" prop="mark_fee">
  372. <digital-input
  373. :values="ruleForm.mark_fee"
  374. :placeholder="'加标费'"
  375. :min="0"
  376. :disabled="type === 'view'"
  377. :max="100000000000"
  378. :position="'right'"
  379. :precision="2"
  380. :size="'mini'"
  381. :controls="false"
  382. :append="'元'"
  383. @reschange="number_change($event, 'mark_fee')"
  384. />
  385. </el-form-item>
  386. </el-col>
  387. <el-col :span="6">
  388. <el-form-item label="打样费" prop="demo_fee">
  389. <digital-input
  390. :values="ruleForm.demo_fee"
  391. :placeholder="'打样费'"
  392. :min="0"
  393. :disabled="type === 'view'"
  394. :max="100000000000"
  395. :position="'right'"
  396. :precision="2"
  397. :size="'mini'"
  398. :controls="false"
  399. :append="'元'"
  400. @reschange="number_change($event, 'demo_fee')"
  401. />
  402. </el-form-item>
  403. </el-col>
  404. <el-col :span="6">
  405. <el-form-item label="开模费" prop="open_fee">
  406. <digital-input
  407. :values="ruleForm.open_fee"
  408. :placeholder="'开模费'"
  409. :min="0"
  410. :disabled="type === 'view'"
  411. :max="100000000000"
  412. :position="'right'"
  413. :precision="2"
  414. :size="'mini'"
  415. :controls="false"
  416. :append="'元'"
  417. @reschange="number_change($event, 'open_fee')"
  418. />
  419. </el-form-item>
  420. </el-col>
  421. <el-col :span="6">
  422. <el-form-item label="物流费" prop="delivery_fee">
  423. <digital-input
  424. :values="ruleForm.delivery_fee"
  425. :placeholder="'物流费'"
  426. :min="0"
  427. :disabled="type === 'view'"
  428. :max="100000000000"
  429. :position="'right'"
  430. :precision="2"
  431. :size="'mini'"
  432. :controls="false"
  433. :append="'元'"
  434. @reschange="number_change($event, 'delivery_fee')"
  435. />
  436. </el-form-item>
  437. </el-col>
  438. <el-col :span="6">
  439. <el-form-item label="裸价" prop="nake_fee" class="clear">
  440. <digital-input
  441. :values="ruleForm.nake_fee"
  442. :placeholder="'裸价'"
  443. :min="0"
  444. :disabled="type === 'view' || is_noble"
  445. :max="100000000000"
  446. :position="'right'"
  447. :precision="2"
  448. :size="'mini'"
  449. :controls="false"
  450. :append="'元'"
  451. @reschange="number_change($event, 'nake_fee')"
  452. />
  453. </el-form-item>
  454. </el-col>
  455. <el-col :span="24" v-show="is_noble">
  456. <el-col :span="6">
  457. <el-form-item label="金属重量" prop="noble_weight">
  458. <digital-input
  459. :values="ruleForm.noble_weight"
  460. :placeholder="'金属重量'"
  461. :min="0"
  462. :disabled="type === 'view'"
  463. :max="100000000000"
  464. :position="'right'"
  465. :precision="3"
  466. :size="'mini'"
  467. :controls="false"
  468. :append="'g'"
  469. @reschange="number_change($event, 'noble_weight')"
  470. />
  471. </el-form-item>
  472. </el-col>
  473. <el-col :span="6">
  474. <el-form-item label="金属种类" prop="metal_id">
  475. <search-metal-kind
  476. :value="ruleForm.metal_id"
  477. :size="'mini'"
  478. :disabled="false"
  479. :isDetail="true"
  480. :placeholder="'金属种类'"
  481. @searchChange="metal_idsearchChange"
  482. />
  483. </el-form-item>
  484. </el-col>
  485. <el-col :span="6">
  486. <el-form-item label="启用金价" prop="is_gold_price">
  487. <el-select
  488. v-model="ruleForm.is_gold_price"
  489. filterable
  490. clearable
  491. :disabled="type === 'view'"
  492. style="width: 100%"
  493. placeholder="启用金价"
  494. >
  495. <el-option
  496. v-for="group in options5"
  497. :key="group.id"
  498. :label="group.name"
  499. :value="group.id"
  500. />
  501. </el-select>
  502. </el-form-item>
  503. </el-col>
  504. <el-col :span="6">
  505. <el-form-item label="有无工差" prop="is_diff">
  506. <el-select
  507. v-model="ruleForm.is_diff"
  508. filterable
  509. clearable
  510. :disabled="type === 'view'"
  511. style="width: 100%"
  512. placeholder="有无工差"
  513. >
  514. <el-option
  515. v-for="group in options8"
  516. :key="group.id"
  517. :label="group.name"
  518. :value="group.id"
  519. />
  520. </el-select>
  521. </el-form-item>
  522. </el-col>
  523. <el-col :span="12">
  524. <el-form-item label="配置要求" prop="config">
  525. <el-select
  526. v-model="ruleForm.config"
  527. multiple
  528. :disabled="type === 'view'"
  529. style="width: 100%"
  530. placeholder="配置要求"
  531. >
  532. <el-option
  533. v-for="(item, index) in options9"
  534. :key="item + index"
  535. :label="item"
  536. :value="item"
  537. >
  538. </el-option>
  539. </el-select>
  540. </el-form-item>
  541. </el-col>
  542. <el-col :span="12">
  543. <el-form-item
  544. label="其他配置要求"
  545. prop="other_config"
  546. label-width="120px"
  547. >
  548. <el-input
  549. placeholder="其他要求"
  550. maxlength="100"
  551. :disabled="type === 'view'"
  552. v-model="ruleForm.other_config"
  553. >
  554. </el-input>
  555. </el-form-item>
  556. </el-col>
  557. </el-col>
  558. <el-col :span="18">
  559. <el-form-item label="采购备注" prop="remark">
  560. <el-input
  561. placeholder="采购备注"
  562. maxlength="500"
  563. :disabled="type === 'view'"
  564. v-model="ruleForm.remark"
  565. >
  566. </el-input>
  567. </el-form-item>
  568. <el-form-item label="工艺说明" prop="cost_desc">
  569. <el-input
  570. placeholder="工艺说明"
  571. maxlength="500"
  572. :disabled="type === 'view'"
  573. v-model="ruleForm.cost_desc"
  574. >
  575. </el-input>
  576. </el-form-item>
  577. </el-col>
  578. <el-col :span="6">
  579. <el-form-item
  580. label="商品图片(<1mb)"
  581. prop="good_img"
  582. class="activity-upload"
  583. >
  584. <div class="btnupload" style="position: relative">
  585. <img
  586. v-if="ruleForm.good_img"
  587. :src="ruleForm.good_img"
  588. class="avatar"
  589. />
  590. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  591. <file-upload
  592. class="Upload"
  593. :accept="'.jpg,.png,.jpeg'"
  594. :multiple="true"
  595. :disabled="type === 'view'"
  596. :uploadcondition="beforeAvatarUpload"
  597. @UploadErrorEvent="UploadErrorEventgood_img"
  598. @UploadSuccessEvent="UploadSuccessEventgood_img"
  599. ></file-upload>
  600. </div>
  601. </el-form-item>
  602. </el-col>
  603. </el-row>
  604. </el-form>
  605. </template>
  606. <script>
  607. import asyncRequest from "@/apis/service/purchaseIn/workbench";
  608. import resToken from "@/mixins/resToken";
  609. import { mapGetters } from "vuex";
  610. import baseFormAddEdit from "./baseFormAddEdit";
  611. import {
  612. options1,
  613. options2,
  614. options3,
  615. options4,
  616. options5,
  617. options6,
  618. options7,
  619. options8,
  620. options9,
  621. options10,
  622. options11,
  623. rules,
  624. } from "../columns";
  625. export default {
  626. name: "goodsCostAdd",
  627. mixins: [resToken],
  628. props: ["showModel", "id", "type", "sitem", "askItem", "newTime", "editId",],
  629. components: {
  630. baseFormAddEdit,
  631. },
  632. computed: {
  633. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  634. powers() {
  635. let tran =
  636. this.$store.getters.btnList.find(
  637. (item) => item.menu_route == "goodsCostAdd"
  638. ) || {};
  639. if (tran && tran.action && tran.action.length > 0) {
  640. return tran.action;
  641. } else {
  642. return [];
  643. }
  644. },
  645. },
  646. watch: {
  647. newTime: function (val) {
  648. if (val) {
  649. this.initForm();
  650. }
  651. },
  652. },
  653. data() {
  654. return {
  655. cat_id_name: "",
  656. supplierNo: "",
  657. brand_name: "",
  658. unit_name: "",
  659. title: "",
  660. modelIndex: "",
  661. modelSitem: {},
  662. showOtherModel: false,
  663. is_noble: false,
  664. status: "",
  665. rulesThis: this.rules,
  666. activeName: "1",
  667. loading: true,
  668. options1: options1,
  669. options2: options2,
  670. options3: options3,
  671. options4: options4,
  672. options5: options5,
  673. options6: options6,
  674. options7: options7,
  675. options8: options8,
  676. options9: options9,
  677. options10: options10,
  678. options11: options11,
  679. ruleForm: {},
  680. rules: JSON.parse(JSON.stringify(rules)),
  681. r1:"",
  682. r2:"",
  683. };
  684. },
  685. mounted() {
  686. this.initForm();
  687. this.$nextTick(()=>{
  688. this.r1 = this.accMul(this.ruleForm.noble_weight,this.askItem.gold_price)
  689. this.r2 = this.accMul(this.ruleForm.cost_fee,this.ruleForm.noble_weight)
  690. console.log(this.r1,this.r2)
  691. })
  692. },
  693. methods: {
  694. //加法精度问题
  695. // accAdd(arg1,arg2){
  696. // var r1,r2,m;
  697. // try{
  698. // r1=arg1.toString().split(".")[1].length;
  699. // }catch(e){
  700. // r1=0;
  701. // }
  702. // try{
  703. // r2=arg2.toString().split(".")[1].length;
  704. // }catch(e){
  705. // r2=0;
  706. // }
  707. // m=Math.pow(10,Math.max(r1,r2)) ;
  708. // return (arg1*m+arg2*m)/m ;
  709. // },
  710. accAdd(arg1,arg2,arg3,arg4,arg5,arg6,arg7){
  711. var r1,r2,r3,r4,r5,r6,r7,m;
  712. console.log(arg1,arg2,arg3,arg4,arg5,arg6,arg7)
  713. try{
  714. r1=arg1.toString().split(".")[1].length;
  715. }catch(e){
  716. r1=0;
  717. }
  718. try{
  719. r2=arg2.toString().split(".")[1].length;
  720. }catch(e){
  721. r2=0;
  722. }
  723. try{
  724. r3=arg3.toString().split(".")[1].length;
  725. }catch(e){
  726. r3=0;
  727. }
  728. try{
  729. r4=arg4.toString().split(".")[1].length;
  730. }catch(e){
  731. r4=0;
  732. }
  733. try{
  734. r5=arg5.toString().split(".")[1].length;
  735. }catch(e){
  736. r5=0;
  737. }
  738. try{
  739. r6=arg6.toString().split(".")[1].length;
  740. }catch(e){
  741. r6=0;
  742. }
  743. try{
  744. r7=arg7.toString().split(".")[1].length;
  745. }catch(e){
  746. r7=0;
  747. }
  748. m=Math.pow(10,Math.max(r1,r2,r3,r4,r5,r6,r7)) ;
  749. return (arg1*m+arg2*m+arg3*m+arg4*m+arg5*m+arg6*m+arg7*m)/m ;
  750. },
  751. //乘法精度问题
  752. accMul(arg1, arg2) {
  753. var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
  754. try {
  755. m += s1.split(".")[1].length;
  756. }
  757. catch (e) {
  758. }
  759. try {
  760. m += s2.split(".")[1].length;
  761. }
  762. catch (e) {
  763. }
  764. let numStr = Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
  765. return numStr.toString()
  766. },
  767. async initForm() {
  768. this.supplierNo = [];
  769. console.log(this.id);
  770. this.loading = true;
  771. if (this.type === "add") {
  772. this.title = "新建采返商品";
  773. } else if (this.type === "edit") {
  774. this.title = "编辑采返商品";
  775. } else {
  776. this.title = "采返商品详情";
  777. }
  778. console.log(this.type);
  779. this.resetFormData();
  780. this.rulesThis = this.rules;
  781. await this.resetForm();
  782. if (this.type === "edit" || this.type === "view") {
  783. await this.initData();
  784. }
  785. this.setrules();
  786. this.loading = false;
  787. },
  788. number_change(e, key) {
  789. this.ruleForm[key] = e + "" || "0";
  790. this.$refs.ruleForm.validateField(key);
  791. this.$nextTick(()=>{
  792. this.r1 = this.accMul(this.ruleForm.noble_weight,this.askItem.gold_price)
  793. this.r2 = this.accMul(this.ruleForm.cost_fee,this.ruleForm.noble_weight)
  794. })
  795. },
  796. async initData() {
  797. this.loading = true;
  798. const { code, message, data } = await asyncRequest.good_detail({
  799. bidNo: this.editId,
  800. });
  801. console.log(data);
  802. if (code === 0) {
  803. const {
  804. bidNo,
  805. good_name, //string 名称
  806. cat_id, //array 分类
  807. cat_info,
  808. brand_id, //string 品牌id
  809. unit, // string 单位
  810. unit_id, //单位ID
  811. tax, //string 税率
  812. supplierNo, // string 供应商
  813. cost_desc, // string 工艺说明
  814. remark, // string 采购备注
  815. weight, // string 重量
  816. supply_area, // string 供货区域 1 全国2 除偏远地区
  817. origin_place, // string 产地
  818. delivery_day, // string 物流天数
  819. expire_day, // string 信息有效期
  820. good_img, //
  821. // good_name,
  822. cert_fee, // string 证书费
  823. pakge_fee, // string 打包费
  824. cost_fee, // string 工艺费
  825. mark_fee, // string 加标费
  826. demo_fee, // string 打样费
  827. open_fee, // string 开模费
  828. metal_id, // string 金属类别
  829. noble_weight, // string 金属重量
  830. is_gold_price, // string 是否使用实时金价
  831. delivery_fee, // string 物流费
  832. status, // string 状态
  833. brand_name,
  834. work_day,
  835. pay_way,
  836. send_way,
  837. is_diff,
  838. config,
  839. nake_fee,
  840. other_config,
  841. supplierName,
  842. specinfo,
  843. } = JSON.parse(JSON.stringify(data));
  844. if (specinfo && specinfo.length > 0) {
  845. this.spec_tableData = JSON.parse(JSON.stringify(specinfo));
  846. }
  847. this.cat_id_name = "";
  848. if (cat_info && cat_info.length) {
  849. cat_info.forEach((e, ei) => {
  850. this.cat_id_name += `${ei !== 0 ? "_" : ""}${e.name}`;
  851. });
  852. }
  853. this.supplierNo_name = supplierName || "";
  854. console.log(this.supplierNo_name);
  855. this.is_noble = this.askItem.is_metal;
  856. this.brand_name = brand_name || "";
  857. this.unit_name = unit || "";
  858. this.ruleForm = {
  859. infoNo: this.id || "",
  860. bidNo: bidNo || "",
  861. infoNo: this.id || "",
  862. cat_id: cat_id ? [cat_id] : [],
  863. supplierNo: supplierNo ? [supplierNo] : [],
  864. pname: good_name || "",
  865. expire_day: expire_day || "0", //有效期
  866. delivery_day: delivery_day || "0", //物流时间
  867. work_day: work_day || "0", //生产工期
  868. brandid: brand_id ? [brand_id] : [],
  869. unit_id: unit_id ? [unit_id] : [],
  870. weight: weight || "0.000",
  871. tax: tax ? tax + "%" : "",
  872. supply_area: supply_area || "",
  873. origin_place: origin_place ? origin_place.split(",") : [],
  874. cert_fee: cert_fee || "0.00",
  875. pakge_fee: pakge_fee || "0.00",
  876. cost_fee: cost_fee || "0.00",
  877. mark_fee: mark_fee || "0.00",
  878. demo_fee: demo_fee || "0.00",
  879. open_fee: open_fee || "0.00",
  880. delivery_fee: delivery_fee || "0.00",
  881. nake_fee: nake_fee || "0.00",
  882. pay_way: pay_way || "",
  883. send_way: send_way || "",
  884. noble_weight: noble_weight || "0.000",
  885. metal_id: metal_id || "",
  886. is_gold_price: is_gold_price || "",
  887. is_diff: is_diff || "",
  888. config: config ? config.split(",") : [],
  889. other_config: other_config || "",
  890. remark: remark || "",
  891. cost_desc: cost_desc || "",
  892. good_img: good_img || "",
  893. };
  894. this.status = status;
  895. if (this.is_noble) {
  896. this.ruleForm.nake_fee = "0";
  897. }
  898. // console.log(this.ruleForm.origin_place);
  899. } else if (code >= 100 && code <= 104) {
  900. await this.logout();
  901. } else {
  902. this.$message.warning(message);
  903. }
  904. },
  905. async submitForm() {
  906. await this.$refs.ruleForm.validate(async (valid) => {
  907. if (valid) {
  908. this.loading = true;
  909. if (this.spec_tableData.length === 0) {
  910. this.$message.warning("请填写规格!");
  911. this.loading = false;
  912. return;
  913. }
  914. let model = JSON.parse(JSON.stringify(this.ruleForm));
  915. model.cat_id = model.cat_id[model.cat_id.length - 1];
  916. model.brandid = model.brandid.toString();
  917. model.supplierNo = model.supplierNo.toString();
  918. model.origin_place = model.origin_place.toString();
  919. model.unit_id = model.unit_id.toString();
  920. model.config = model.config.toString();
  921. model.tax = parseInt(model.tax + "") + "";
  922. model.specinfo = [];
  923. let list = JSON.parse(JSON.stringify(this.spec_tableData));
  924. list.forEach((a) => {
  925. let am = {
  926. specid: a.specid,
  927. spec_value_id: a.spec_value_id,
  928. };
  929. model.specinfo.push(am);
  930. });
  931. console.log(model);
  932. let res = {};
  933. if (this.type === "add") {
  934. delete model["bidNo"];
  935. res = await asyncRequest.good_add(model);
  936. } else {
  937. res = await asyncRequest.good_update(model);
  938. }
  939. console.log(res);
  940. this.loading = false;
  941. if (res && res.code === 0) {
  942. const title = this.type === "add" ? "新建成功!" : "修改成功!";
  943. this.$notify.success({
  944. title: title,
  945. message: "",
  946. });
  947. this.showModelThis = false;
  948. // 刷新
  949. this.$emit("refresh");
  950. } else if (res && res.code >= 100 && res.code <= 104) {
  951. await this.logout();
  952. } else {
  953. this.$message.warning(res.message);
  954. }
  955. } else {
  956. console.log("error submit!!");
  957. return false;
  958. }
  959. });
  960. },
  961. async resetForm() {
  962. // 重置
  963. await this.$nextTick(async () => {
  964. if (this.$refs.ruleForm) {
  965. this.$refs.ruleForm.resetFields();
  966. this.$refs.ruleForm.clearValidate();
  967. this.spec_tableData = [];
  968. console.log(this.askItem);
  969. // const { can_id_arr } = this.askItem;
  970. this.is_noble = this.askItem.is_metal;
  971. this.cat_id_name = this.type === "add" ? this.askItem.can_name : "";
  972. this.brand_name =""
  973. // this.type === "add" ? this.askItem.brand : "";
  974. this.unit_name = ""
  975. //this.type === "add" ? this.askItem.unit_name : "";
  976. this.ruleForm = {
  977. infoNo: this.id || "",
  978. cat_id: this.type === "add" ? [this.askItem.cat_id] : [],
  979. supplierNo: [],
  980. pname: this.type === "add" ? this.askItem.good_name : "",
  981. expire_day: "0", //有效期
  982. delivery_day: "0", //物流时间
  983. work_day: "0", //生产工期
  984. brandid:[],
  985. // this.type === "add" && this.askItem.brand_id
  986. // ? [this.askItem.brand_id]
  987. // : [],
  988. unit_id: [],
  989. //this.type === "add" ? [this.askItem.unit] : [],
  990. weight: this.type === "add" ? this.askItem.total_weight : "0.000",
  991. tax: "",
  992. supply_area: "",
  993. origin_place: [],
  994. cert_fee: "0.00",
  995. pakge_fee: "0.00",
  996. cost_fee: "0.00",
  997. mark_fee: "0.00",
  998. demo_fee: "0.00",
  999. open_fee: "0.00",
  1000. delivery_fee: "0.00",
  1001. nake_fee: "0.00",
  1002. pay_way: "",
  1003. send_way: "",
  1004. noble_weight:
  1005. this.type === "add" ? this.askItem.specs_weight : "0.000",
  1006. metal_id: this.type === "add" ? this.askItem.metal_id : "",
  1007. is_gold_price:
  1008. this.type === "add" ? this.askItem.is_gold_price : "",
  1009. is_diff: "",
  1010. config:
  1011. this.type === "add"
  1012. ? this.askItem.config
  1013. ? this.askItem.config.split(",")
  1014. : []
  1015. : [],
  1016. other_config: this.type === "add" ? this.askItem.other_config : "",
  1017. remark: "",
  1018. cost_desc: this.type === "add" ? this.askItem.cost_desc : "",
  1019. good_img: this.type === "add" ? this.askItem.good_img : "",
  1020. };
  1021. if (this.type === "add") {
  1022. this.spec_tableData = JSON.parse(
  1023. JSON.stringify(this.askItem.specinfo)
  1024. );
  1025. }
  1026. }
  1027. });
  1028. },
  1029. openEdit(index, sitem) {
  1030. this.modelIndex = index;
  1031. this.modelSitem = sitem;
  1032. this.showOtherModel = true;
  1033. },
  1034. openDelete(index) {
  1035. this.spec_tableData.splice(index, 1);
  1036. },
  1037. //规格编辑修改结果
  1038. refreshEdit(e) {
  1039. let item = JSON.parse(JSON.stringify(e));
  1040. const { index, specid, spec_name, spec_value_id, spec_value_name } = item;
  1041. if (index + "" === "-1") {
  1042. this.spec_tableData.push(item);
  1043. } else {
  1044. let findex = parseInt(index + "");
  1045. this.spec_tableData[findex].specid = specid;
  1046. this.spec_tableData[findex].spec_name = spec_name;
  1047. this.spec_tableData[findex].spec_value_id = spec_value_id;
  1048. this.spec_tableData[findex].spec_value_name = spec_value_name;
  1049. }
  1050. this.showOtherModel = false;
  1051. },
  1052. //分类选择
  1053. async cat_id_change(e) {
  1054. const { pid, id, label } = e;
  1055. this.ruleForm.cat_id = id ? [id] : [];
  1056. this.is_noble = pid === "6";
  1057. this.$refs.ruleForm.validateField("cat_id");
  1058. this.setrules();
  1059. this.ruleForm.nake_fee = "0";
  1060. },
  1061. setrules() {
  1062. let list = [
  1063. "noble_weight",
  1064. "metal_id",
  1065. "is_gold_price",
  1066. "is_diff",
  1067. "config",
  1068. "other_config",
  1069. ];
  1070. for (let i = 0; i < list.length; i++) {
  1071. this.rules[list[i]][0].required = this.is_noble;
  1072. }
  1073. },
  1074. //品牌选择
  1075. brandidsearchChange(e) {
  1076. const { id, code, label } = e;
  1077. if (id) {
  1078. this.ruleForm.brandid = [id];
  1079. } else {
  1080. this.ruleForm.brandid = [];
  1081. }
  1082. this.$refs.ruleForm.validateField("brandid");
  1083. },
  1084. //供应商选择
  1085. supplierNosearchChange(e) {
  1086. console.log(e);
  1087. const { id, code, label } = e;
  1088. if (id) {
  1089. this.ruleForm.supplierNo = [code];
  1090. } else {
  1091. this.ruleForm.supplierNo = [];
  1092. }
  1093. this.$refs.ruleForm.validateField("supplierNo");
  1094. },
  1095. //税点选择
  1096. taxsearchChange(e) {
  1097. this.ruleForm.tax = e;
  1098. this.$refs.ruleForm.validateField("tax");
  1099. },
  1100. //单位选择
  1101. unitsearchChange(e) {
  1102. const { id, code, label } = e;
  1103. if (id) {
  1104. this.ruleForm.unit_id = [code];
  1105. } else {
  1106. this.ruleForm.unit_id = [];
  1107. }
  1108. this.$refs.ruleForm.validateField("unit_id");
  1109. },
  1110. //金属种类选择
  1111. metal_idsearchChange(e) {
  1112. console.log(e);
  1113. const { id, code, label } = e;
  1114. if (id) {
  1115. this.ruleForm.metal_id = id;
  1116. } else {
  1117. this.ruleForm.metal_id = "";
  1118. }
  1119. this.$refs.ruleForm.validateField("metal_id");
  1120. },
  1121. //仓库省市区
  1122. selectAreaorigin_place(e) {
  1123. this.ruleForm.origin_place = e;
  1124. this.$refs.ruleForm.validateField("origin_place");
  1125. },
  1126. //图片上传成功
  1127. async UploadSuccessEventgood_img(data) {
  1128. await this.UploadSuccessEvent(1, data);
  1129. },
  1130. //图片上传成功
  1131. async UploadSuccessEvent(type, data) {
  1132. const { url } = data;
  1133. if (url === "noToken") {
  1134. await this.logout();
  1135. } else {
  1136. if (type === 1) {
  1137. this.ruleForm.good_img = url;
  1138. this.$refs.ruleForm.validateField("good_img");
  1139. } else if (type === 2) {
  1140. this.ruleForm.good_img = url;
  1141. this.$refs.ruleForm.validateField("good_img");
  1142. }
  1143. this.$message.success("图片上传成功!");
  1144. }
  1145. },
  1146. //图片上传失败
  1147. UploadErrorEventgood_img(res) {
  1148. this.imgUploadError(1, res);
  1149. },
  1150. imgUploadError(type, res) {
  1151. if (res !== "break") {
  1152. this.$message.error("图片上传失败!");
  1153. this.$refs.ruleForm.validateField(
  1154. type === 1 ? "good_img" : type === 2 ? "good_img" : ""
  1155. );
  1156. }
  1157. },
  1158. //判断图片规格
  1159. beforeAvatarUpload(file) {
  1160. let isJPG = false;
  1161. if (
  1162. file.type === "image/jpg" ||
  1163. file.type === "image/png" ||
  1164. file.type === "image/jpeg"
  1165. ) {
  1166. isJPG = true;
  1167. }
  1168. const isLt2M = file.size / 1024 / 1024 < 1;
  1169. if (!isJPG) {
  1170. this.$message.error("图片格式不正确!");
  1171. }
  1172. if (!isLt2M) {
  1173. this.$message.error("图片大小不能超过 1MB!");
  1174. }
  1175. return isJPG && isLt2M;
  1176. },
  1177. resetFormData() {
  1178. this.status = "";
  1179. this.is_noble = false;
  1180. this.cat_id_name = "";
  1181. this.brand_name = "";
  1182. this.unit_name = "";
  1183. this.ruleForm = {
  1184. infoNo: "",
  1185. cat_id: [],
  1186. supplierNo: [],
  1187. pname: "",
  1188. expire_day: "0", //有效期
  1189. delivery_day: "0", //物流时间
  1190. work_day: "0", //生产工期
  1191. color: "",
  1192. model: "",
  1193. material: "",
  1194. brandid: [],
  1195. unit_id: [],
  1196. weight: "0.000",
  1197. tax: "",
  1198. supply_area: "",
  1199. origin_place: [],
  1200. cert_fee: "0.00",
  1201. pakge_fee: "0.00",
  1202. cost_fee: "0.00",
  1203. mark_fee: "0.00",
  1204. demo_fee: "0.00",
  1205. open_fee: "0.00",
  1206. delivery_fee: "0.00",
  1207. nake_fee: "0.00",
  1208. pay_way: "",
  1209. send_way: "",
  1210. noble_weight: "0.000",
  1211. metal_id: "",
  1212. is_gold_price: "",
  1213. is_diff: "",
  1214. config: [],
  1215. other_config: "",
  1216. remark: "",
  1217. cost_desc: "",
  1218. good_img: "",
  1219. };
  1220. },
  1221. addFormData() {
  1222. this.status = "";
  1223. this.is_noble = false;
  1224. this.cat_id_name = "";
  1225. this.brand_name = "";
  1226. this.unit_name = "";
  1227. this.ruleForm = {
  1228. infoNo: "",
  1229. cat_id: [],
  1230. supplierNo: [],
  1231. pname: "",
  1232. expire_day: "0", //有效期
  1233. delivery_day: "0", //物流时间
  1234. work_day: "0", //生产工期
  1235. color: "",
  1236. model: "",
  1237. material: "",
  1238. brandid: [],
  1239. unit_id: [],
  1240. weight: "0.000",
  1241. tax: "",
  1242. supply_area: "",
  1243. origin_place: [],
  1244. cert_fee: "0.00",
  1245. pakge_fee: "0.00",
  1246. cost_fee: "0.00",
  1247. mark_fee: "0.00",
  1248. demo_fee: "0.00",
  1249. open_fee: "0.00",
  1250. delivery_fee: "0.00",
  1251. nake_fee: "0.00",
  1252. pay_way: "",
  1253. send_way: "",
  1254. noble_weight: "0.000",
  1255. metal_id: "",
  1256. is_gold_price: "",
  1257. is_diff: "",
  1258. config: [],
  1259. other_config: "",
  1260. remark: "",
  1261. cost_desc: "",
  1262. good_img: "",
  1263. };
  1264. },
  1265. },
  1266. };
  1267. </script>
  1268. <style lang="scss" scoped>
  1269. .goodsCostDetail {
  1270. .goodsCostAdd-title {
  1271. border-top: 1px solid #ebeef5;
  1272. span {
  1273. height: 50px;
  1274. line-height: 50px;
  1275. font-family: "微软雅黑", sans-serif;
  1276. font-weight: 400;
  1277. font-style: normal;
  1278. font-size: 16px;
  1279. text-align: left;
  1280. }
  1281. }
  1282. }
  1283. </style>