baseFormNormal.vue 87 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599
  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="90px"
  10. >
  11. <el-row class="ddiv">
  12. <el-col :span="1" class="dtitle">
  13. <ul style="padding: 140px 0 0 0">
  14. <li>基</li>
  15. <li>础</li>
  16. <li>信</li>
  17. <li>息</li>
  18. </ul>
  19. </el-col>
  20. <el-col :span="23" class="dmain">
  21. <el-row>
  22. <el-row>
  23. <el-col :span="12">
  24. <el-form-item label="业务公司" prop="company_id">
  25. <el-input
  26. :value="
  27. type === 'add'
  28. ? getCompanyWithCode(ruleForm.companyNo).name
  29. : companyName
  30. "
  31. disabled
  32. />
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="6">
  36. <el-form-item label="是否库存品" prop="is_stock" label-width="95px">
  37. <el-select
  38. v-model="ruleForm.is_stock"
  39. filterable
  40. clearable
  41. :disabled="
  42. type === 'view' ||
  43. type === 'editBase' ||
  44. type === 'editCoin' ||
  45. type === 'edit'
  46. "
  47. style="width: 100%"
  48. @change="stock_change"
  49. placeholder="是否库存品"
  50. >
  51. <el-option
  52. v-for="group in options4"
  53. :key="group.id"
  54. :label="group.name"
  55. :value="group.id"
  56. />
  57. </el-select>
  58. </el-form-item>
  59. </el-col>
  60. <el-col :span="6">
  61. <el-form-item prop="is_combind" label="组合类型" label-width="110px">
  62. <el-select
  63. style="width: 100%"
  64. :disabled="
  65. type === 'view' ||
  66. type === 'editBase' ||
  67. type === 'editCoin' ||
  68. type === 'edit'
  69. "
  70. v-model="ruleForm.is_combind"
  71. placeholder="是否组合商品"
  72. @change="groupGoodChange"
  73. >
  74. <el-option
  75. v-if="ruleForm.is_stock === '1'"
  76. value="1"
  77. label="组合商品"
  78. />
  79. <el-option value="0" label="非组合商品" />
  80. </el-select>
  81. </el-form-item>
  82. </el-col>
  83. </el-row>
  84. <el-row>
  85. <el-col :span="12">
  86. <el-form-item label="供应商" prop="supplierNo">
  87. <search-supplier
  88. :value="ruleForm.supplierNo"
  89. :placeholder="'供应商'"
  90. :disabled="type === 'view' || type === 'editCoin'"
  91. :size="'mini'"
  92. :names="supplierName"
  93. :isDetail="type !== 'add'"
  94. :isp="this.type !== 'view'"
  95. @searchChange="supplierNosearchChange"
  96. />
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="12">
  100. <el-form-item label="商品名称" prop="good_name">
  101. <el-input
  102. placeholder="商品名称"
  103. maxlength="100"
  104. :disabled="type === 'view' || type === 'editCoin'"
  105. v-model="ruleForm.good_name"
  106. ></el-input>
  107. </el-form-item>
  108. </el-col>
  109. </el-row>
  110. <el-row>
  111. <el-col :span="8">
  112. <el-form-item label="商品分类" prop="cat_id">
  113. <company-sort
  114. :value="ruleForm.cat_id"
  115. :placeholder="'商品分类'"
  116. :disabled="
  117. type !== 'add' && !(type === 'edit' && String(sitem.status) === '7')
  118. "
  119. :size="'mini'"
  120. :names="cat_id_name"
  121. :isDetail="type !== 'add'"
  122. :company-no="ruleForm.company_id"
  123. @searchChange="goods_class_change"
  124. />
  125. </el-form-item>
  126. </el-col>
  127. <el-col :span="8">
  128. <el-form-item label="商品品牌" prop="brandid">
  129. <search-brand
  130. :value="ruleForm.brandid"
  131. :disabled="type === 'view' || type === 'editCoin'"
  132. :size="'mini'"
  133. :isDetail="type !== 'add'"
  134. :names="brand_name"
  135. :placeholder="'商品品牌'"
  136. @searchChange="brandidsearchChange"
  137. />
  138. </el-form-item>
  139. </el-col>
  140. <el-col :span="8">
  141. <el-form-item label="销售权限" prop="is_auth">
  142. <el-select
  143. v-model="ruleForm.is_auth"
  144. filterable
  145. clearable
  146. :disabled="type === 'view' || type === 'editCoin'"
  147. style="width: 100%"
  148. placeholder="销售权限"
  149. >
  150. <el-option
  151. v-for="group in options3"
  152. :key="group.id"
  153. :label="group.name"
  154. :value="group.id"
  155. />
  156. </el-select>
  157. </el-form-item>
  158. </el-col>
  159. </el-row>
  160. <el-row>
  161. <el-col :span="4">
  162. <el-form-item label="单位" prop="unit" label-width="60px">
  163. <search-unit
  164. :value="ruleForm.unit"
  165. :disabled="type === 'view' || type === 'editCoin'"
  166. :size="'mini'"
  167. :isDetail="type !== 'add'"
  168. :names="unit_name"
  169. :placeholder="'单位'"
  170. @searchChange="unitsearchChange"
  171. />
  172. </el-form-item>
  173. </el-col>
  174. <el-col :span="4">
  175. <el-form-item label="税点" prop="tax" label-width="60px">
  176. <search-tax
  177. :value="ruleForm.tax"
  178. :disabled="
  179. type === 'view' || type === 'editBase' || type === 'editCoin'
  180. "
  181. :size="'mini'"
  182. :isDetail="type !== 'add'"
  183. :placeholder="'税点'"
  184. @searchChange="taxsearchChange"
  185. />
  186. </el-form-item>
  187. </el-col>
  188. <el-col :span="8">
  189. <el-form-item label="专属类型" prop="is_exclusive">
  190. <search-exclusive
  191. :disabled="type === 'view' || type === 'editCoin'"
  192. style="width: 100%"
  193. :isDetail="type !== 'add'"
  194. :size="'mini'"
  195. placeholder="专属类型"
  196. :value="ruleForm.is_exclusive"
  197. @selectChange="exclusiveSearchChange"
  198. />
  199. </el-form-item>
  200. </el-col>
  201. <el-col :span="8">
  202. <el-form-item
  203. label="商品总重量"
  204. prop="weight"
  205. label-width="95px"
  206. style="height: 32px"
  207. >
  208. <digital-input
  209. :values="ruleForm.weight"
  210. :name="'ruleForm.weight'"
  211. :placeholder="'商品总重量'"
  212. :min="0"
  213. :disabled="type === 'view' || type === 'editCoin'"
  214. :max="100000000000"
  215. :position="'right'"
  216. :precision="3"
  217. :size="'mini'"
  218. :controls="false"
  219. :append="'g'"
  220. @reschange="number_change($event, 'weight')"
  221. />
  222. </el-form-item>
  223. </el-col>
  224. </el-row>
  225. <el-row :span="24" v-show="is_noble">
  226. <el-row>
  227. <el-col :span="8">
  228. <el-form-item label="贵金属重量" prop="noble_weight" label-width="95px">
  229. <digital-input
  230. :values="ruleForm.noble_weight"
  231. :placeholder="'贵金属重量'"
  232. :name="'ruleForm.noble_weight'"
  233. :min="0"
  234. :disabled="
  235. type === 'view' || type === 'editBase' || type === 'editCoin'
  236. "
  237. :max="100000000000"
  238. :position="'right'"
  239. :precision="3"
  240. :size="'mini'"
  241. :controls="false"
  242. :append="'g'"
  243. @reschange="number_change($event, 'noble_weight')"
  244. />
  245. </el-form-item>
  246. </el-col>
  247. <el-col :span="8">
  248. <el-form-item label="贵金属种类" prop="noble_metal" label-width="95px">
  249. <search-metal-kind
  250. :value="ruleForm.noble_metal"
  251. :disabled="
  252. type === 'view' || type === 'editBase' || type === 'editCoin'
  253. "
  254. :size="'mini'"
  255. :isDetail="type !== 'add'"
  256. :placeholder="'贵金属种类'"
  257. @searchChange="noble_metalsearchChange"
  258. />
  259. </el-form-item>
  260. </el-col>
  261. <el-col :span="8">
  262. <el-form-item
  263. label="启用实时金价"
  264. prop="is_gold_price"
  265. label-width="110px"
  266. >
  267. <el-select
  268. v-model="ruleForm.is_gold_price"
  269. filterable
  270. clearable
  271. :disabled="
  272. type === 'view' || type === 'editBase' || type === 'editCoin'
  273. "
  274. style="width: 100%"
  275. placeholder="启用实时金价"
  276. @change="is_goold_price_change"
  277. >
  278. <el-option
  279. v-for="group in options5"
  280. :key="group.id"
  281. :label="group.name"
  282. :value="group.id"
  283. />
  284. </el-select>
  285. </el-form-item>
  286. </el-col>
  287. <el-col :span="6">
  288. <el-form-item label="有无工差" prop="is_diff">
  289. <el-select
  290. v-model="ruleForm.is_diff"
  291. filterable
  292. clearable
  293. :disabled="
  294. type === 'view' || type === 'editBase' || type === 'editCoin'
  295. "
  296. style="width: 100%"
  297. placeholder="有无工差"
  298. >
  299. <el-option
  300. v-for="group in options8"
  301. :key="group.id"
  302. :label="group.name"
  303. :value="group.id"
  304. />
  305. </el-select>
  306. </el-form-item>
  307. </el-col>
  308. <el-col :span="10">
  309. <el-form-item label="配置要求" prop="config" label-width="85px">
  310. <el-select
  311. v-model="ruleForm.config"
  312. multiple
  313. :disabled="type === 'view'"
  314. style="width: 100%"
  315. placeholder="配置要求"
  316. >
  317. <el-option
  318. v-for="(item, index) in options9"
  319. :key="item + index"
  320. :label="item"
  321. :value="item"
  322. ></el-option>
  323. </el-select>
  324. </el-form-item>
  325. </el-col>
  326. <el-col :span="8">
  327. <el-form-item
  328. label="其他配置要求"
  329. prop="other_config"
  330. label-width="110px"
  331. >
  332. <el-input
  333. placeholder="其他配置要求"
  334. maxlength="100"
  335. :disabled="type === 'view'"
  336. v-model="ruleForm.other_config"
  337. ></el-input>
  338. </el-form-item>
  339. </el-col>
  340. </el-row>
  341. </el-row>
  342. <el-row>
  343. <el-col :span="8">
  344. <el-form-item label="售后说明" prop="after_sales">
  345. <el-input
  346. type="textarea"
  347. :rows="4"
  348. :disabled="type === 'view' || type === 'editCoin'"
  349. placeholder="售后说明"
  350. v-model="ruleForm.after_sales"
  351. show-word-limit
  352. maxlength="1000"
  353. />
  354. </el-form-item>
  355. </el-col>
  356. <el-col :span="8">
  357. <el-form-item label="商品备注" prop="good_remark">
  358. <el-input
  359. type="textarea"
  360. :rows="4"
  361. :disabled="type === 'view' || type === 'editCoin'"
  362. placeholder="商品备注"
  363. show-word-limit
  364. maxlength="250"
  365. v-model="ruleForm.good_remark"
  366. ></el-input>
  367. </el-form-item>
  368. </el-col>
  369. <el-col :span="8">
  370. <el-form-item label="工艺说明" prop="craft_desc">
  371. <el-input
  372. type="textarea"
  373. :disabled="type === 'view' || type === 'editCoin'"
  374. :rows="4"
  375. placeholder="工艺说明"
  376. show-word-limit
  377. maxlength="250"
  378. v-model="ruleForm.craft_desc"
  379. ></el-input>
  380. </el-form-item>
  381. </el-col>
  382. </el-row>
  383. <el-col :span="8">
  384. <el-form-item label="是否定制" prop="good_type">
  385. <el-select
  386. v-model="ruleForm.good_type"
  387. filterable
  388. :disabled="type === 'view' || type === 'editCoin'"
  389. clearable
  390. style="width: 100%"
  391. placeholder="是否定制"
  392. @change="good_type_change"
  393. >
  394. <el-option
  395. v-for="group in options1"
  396. :key="group.id"
  397. :label="group.name"
  398. :value="group.id"
  399. />
  400. </el-select>
  401. </el-form-item>
  402. </el-col>
  403. <el-col :span="8" v-show="ruleForm.good_type === '1'">
  404. <el-form-item label="定制起订量" prop="moq" label-width="95px">
  405. <digital-input
  406. :values="ruleForm.moq"
  407. :placeholder="'定制起订量'"
  408. :name="'ruleForm.moq'"
  409. :min="0"
  410. :disabled="type === 'view' || type === 'editCoin'"
  411. :max="100000000000"
  412. :position="'right'"
  413. :precision="0"
  414. :size="'mini'"
  415. :controls="false"
  416. :append="''"
  417. @reschange="number_change($event, 'moq')"
  418. />
  419. </el-form-item>
  420. </el-col>
  421. <el-col :span="8" v-show="ruleForm.good_type === '1'">
  422. <el-form-item label="定制工期" prop="customized">
  423. <digital-input
  424. :values="ruleForm.customized"
  425. :placeholder="'定制工期'"
  426. :name="'ruleForm.customized'"
  427. :min="0"
  428. :disabled="type === 'view' || type === 'editCoin'"
  429. :max="100000000000"
  430. :position="'right'"
  431. :precision="0"
  432. :size="'mini'"
  433. :controls="false"
  434. :append="'天'"
  435. @reschange="number_change($event, 'customized')"
  436. />
  437. </el-form-item>
  438. </el-col>
  439. <el-col :span="8" v-show="ruleForm.is_stock === '1'">
  440. <el-form-item label="备库起订量" prop="stock_moq" label-width="95px">
  441. <digital-input
  442. :values="ruleForm.stock_moq"
  443. :placeholder="'备库起订量'"
  444. :min="0"
  445. :disabled="type === 'view' || type === 'editCoin'"
  446. :max="100000000000"
  447. :position="'right'"
  448. :precision="0"
  449. :size="'mini'"
  450. :controls="false"
  451. :append="''"
  452. @reschange="number_change($event, 'stock_moq')"
  453. />
  454. </el-form-item>
  455. </el-col>
  456. </el-row>
  457. </el-col>
  458. </el-row>
  459. <el-row class="ddiv" v-if="ruleForm.is_combind === '1'">
  460. <el-col
  461. :span="1"
  462. tag="div"
  463. style="
  464. border-right: 1px solid #dcdfe6;
  465. width: 40px;
  466. display: flex;
  467. align-items: center;
  468. height: 100%;
  469. "
  470. >
  471. <ul style="text-align: center; padding-top: 20px">
  472. <li>子</li>
  473. <li>商</li>
  474. <li>品</li>
  475. <li>设</li>
  476. <li>置</li>
  477. </ul>
  478. </el-col>
  479. <el-col :span="23" class="dmain" style="padding: 20px 0px; padding-left: 20px">
  480. <el-table :data="childTableData" size="mini" border max-height="350px">
  481. <el-table-column label="子商品成本编号" prop="childCode" min-width="160px" />
  482. <el-table-column
  483. label="子商品名称"
  484. prop="child_name"
  485. min-width="180px"
  486. show-overflow-tooltip
  487. />
  488. <el-table-column label="组合比例" prop="child_num" width="140px">
  489. <template slot-scope="scope">
  490. <span v-if="scope.$index !== editIndex">
  491. {{ childTableData[scope.$index].child_num }}
  492. </span>
  493. <digital-input
  494. v-else
  495. :values="childTableData[scope.$index].child_num"
  496. :placeholder="'组合比例'"
  497. :min="0"
  498. :max="100000000000"
  499. :position="'right'"
  500. :precision="0"
  501. :size="'mini'"
  502. :controls="false"
  503. @reschange="num_change($event, scope.$index)"
  504. />
  505. </template>
  506. </el-table-column>
  507. <el-table-column label="操作" width="120px">
  508. <template #header>
  509. <div>
  510. <span>操作</span>
  511. <el-tooltip
  512. class="item"
  513. effect="dark"
  514. content="添加"
  515. placement="top"
  516. v-if="type === 'add' || type === 'edit'"
  517. >
  518. <i
  519. class="el-icon-circle-plus-outline fr"
  520. style="font-size: 18px; cursor: pointer"
  521. @click="onChildProdChange(null, 'add')"
  522. />
  523. </el-tooltip>
  524. </div>
  525. </template>
  526. <template slot-scope="scope">
  527. <el-tooltip
  528. effect="dark"
  529. content="查看"
  530. placement="top"
  531. v-if="editIndex !== scope.$index"
  532. >
  533. <i
  534. class="el-icon-view tb-icon"
  535. @click="onChildProdChange(scope.$index, 'view')"
  536. ></i>
  537. </el-tooltip>
  538. <template v-if="type === 'add' || type === 'edit'">
  539. <el-tooltip
  540. effect="dark"
  541. content="修改"
  542. placement="top"
  543. v-if="editIndex !== scope.$index"
  544. >
  545. <i
  546. class="el-icon-edit tb-icon"
  547. @click="onChildProdChange(scope.$index, 'edit')"
  548. ></i>
  549. </el-tooltip>
  550. <el-tooltip effect="dark" content="保存" placement="top" v-else>
  551. <i
  552. class="el-icon-circle-check tb-icon"
  553. @click="onSaveLine(scope.$index)"
  554. ></i>
  555. </el-tooltip>
  556. <el-tooltip
  557. effect="dark"
  558. content="删除"
  559. placement="top"
  560. v-if="editIndex !== scope.$index"
  561. >
  562. <i
  563. class="el-icon-delete tb-icon"
  564. @click="onDeleteItem(scope.$index)"
  565. ></i>
  566. </el-tooltip>
  567. </template>
  568. </template>
  569. </el-table-column>
  570. </el-table>
  571. </el-col>
  572. </el-row>
  573. <el-row class="ddiv">
  574. <el-col :span="1" class="dtitle">
  575. <ul>
  576. <li>规</li>
  577. <li>格</li>
  578. <li>信</li>
  579. <li>息</li>
  580. </ul>
  581. </el-col>
  582. <el-col :span="23" class="dmain" style="padding: 20px 0 20px 18px">
  583. <el-table :data="spec_tableData" :size="'mini'" border style="width: 100%">
  584. <el-table-column prop="spec_value" label="规格类型" />
  585. <el-table-column prop="spec_value_value" label="规格值" />
  586. <el-table-column
  587. fixed="right"
  588. v-if="type === 'add' || type === 'editBase' || type === 'edit'"
  589. >
  590. <template slot="header" slot-scope="scope">
  591. <span>操作</span>
  592. <el-tooltip
  593. class="item"
  594. effect="dark"
  595. content="添加规格类型"
  596. placement="top"
  597. >
  598. <i
  599. class="el-icon-circle-plus-outline fr"
  600. style="font-size: 18px; margin-top: 2px"
  601. @click="openEdit('-1', {})"
  602. />
  603. </el-tooltip>
  604. </template>
  605. <template slot-scope="scope">
  606. <el-tooltip effect="dark" content="修改" placement="top">
  607. <i
  608. class="el-icon-edit tb-icon"
  609. @click="openEdit(scope.$index, scope.row)"
  610. ></i>
  611. </el-tooltip>
  612. <el-tooltip
  613. v-if="!scope.row.isMust"
  614. effect="dark"
  615. content="删除"
  616. placement="top"
  617. >
  618. <i class="el-icon-delete tb-icon" @click="openDelete(scope.$index)"></i>
  619. </el-tooltip>
  620. </template>
  621. </el-table-column>
  622. </el-table>
  623. <!-- 弹窗 新增/修改 -->
  624. <base-form-add-edit
  625. :index="modelIndex"
  626. :show-model="showModel"
  627. :sitem="sitem"
  628. @refresh="refreshEdit"
  629. @cancel="showModel = false"
  630. />
  631. </el-col>
  632. </el-row>
  633. <el-row class="ddiv">
  634. <el-col :span="1" class="dtitle">
  635. <ul>
  636. <li>包</li>
  637. <li>装</li>
  638. <li>信</li>
  639. <li>息</li>
  640. </ul>
  641. </el-col>
  642. <el-col :span="23" class="dmain">
  643. <el-row>
  644. <el-col :span="6">
  645. <el-form-item label="包装方式" prop="packing_way">
  646. <el-input
  647. placeholder="包装方式"
  648. :disabled="type === 'view' || type === 'editCoin'"
  649. v-model="ruleForm.packing_way"
  650. maxlength="250"
  651. />
  652. </el-form-item>
  653. </el-col>
  654. <el-col :span="6">
  655. <el-form-item label="装箱规格" prop="packing_spec">
  656. <el-input
  657. placeholder="装箱规格"
  658. :disabled="type === 'view' || type === 'editCoin'"
  659. v-model="ruleForm.packing_spec"
  660. maxlength="250"
  661. />
  662. </el-form-item>
  663. </el-col>
  664. <el-col :span="6">
  665. <el-form-item label="装箱重量" prop="packing_weight">
  666. <digital-input
  667. :values="ruleForm.packing_weight"
  668. :placeholder="'装箱重量'"
  669. :min="0"
  670. :name="'ruleForm.packing_weight'"
  671. :disabled="type === 'view' || type === 'editCoin'"
  672. :max="100000000000"
  673. :position="'right'"
  674. :precision="3"
  675. :size="'mini'"
  676. :controls="false"
  677. :append="'g'"
  678. @reschange="number_change($event, 'packing_weight')"
  679. />
  680. </el-form-item>
  681. </el-col>
  682. <el-col :span="6">
  683. <el-form-item label="装箱尺寸" prop="packing_size">
  684. <el-input
  685. placeholder="装箱尺寸"
  686. :disabled="type === 'view' || type === 'editCoin'"
  687. v-model="ruleForm.packing_size"
  688. maxlength="250"
  689. />
  690. </el-form-item>
  691. </el-col>
  692. <el-col :span="6">
  693. <el-form-item label="商品尺寸" prop="good_size">
  694. <el-input
  695. placeholder="商品尺寸"
  696. :disabled="type === 'view' || type === 'editCoin'"
  697. v-model="ruleForm.good_size"
  698. maxlength="250"
  699. />
  700. </el-form-item>
  701. </el-col>
  702. <el-col :span="6">
  703. <el-form-item label="商品条形码" prop="good_bar">
  704. <el-input
  705. placeholder="商品条形码"
  706. :disabled="type === 'view' || type === 'editCoin'"
  707. v-model="ruleForm.good_bar"
  708. type="number"
  709. :min="0"
  710. :max="9999999999999"
  711. :step="0"
  712. />
  713. </el-form-item>
  714. </el-col>
  715. <el-col :span="12">
  716. <el-form-item label="包装清单" prop="packing_list">
  717. <el-input
  718. placeholder="包装清单"
  719. :disabled="type === 'view' || type === 'editCoin'"
  720. v-model="ruleForm.packing_list"
  721. maxlength="250"
  722. />
  723. </el-form-item>
  724. </el-col>
  725. </el-row>
  726. </el-col>
  727. </el-row>
  728. <el-row class="ddiv">
  729. <el-col :span="1" class="dtitle">
  730. <ul>
  731. <li>发</li>
  732. <li>货</li>
  733. <li>信</li>
  734. <li>息</li>
  735. </ul>
  736. </el-col>
  737. <el-col :span="23" class="dmain">
  738. <el-row>
  739. <el-col :span="6">
  740. <el-form-item label="供货区域" prop="supply_area">
  741. <el-select
  742. v-model="ruleForm.supply_area"
  743. filterable
  744. clearable
  745. :disabled="type === 'view' || type === 'editCoin'"
  746. style="width: 100%"
  747. placeholder="供货区域"
  748. >
  749. <el-option
  750. v-for="group in options6"
  751. :key="group.id"
  752. :label="group.name"
  753. :value="group.id"
  754. />
  755. </el-select>
  756. </el-form-item>
  757. </el-col>
  758. <el-col :span="6" style="padding-bottom: 1px">
  759. <el-form-item label="物流时间" prop="delivery_day">
  760. <digital-input
  761. :values="ruleForm.delivery_day"
  762. :placeholder="'物流时间'"
  763. :min="0"
  764. :name="'ruleForm.delivery_day'"
  765. :disabled="type === 'view' || type === 'editCoin'"
  766. :max="100000000000"
  767. :position="'right'"
  768. :precision="0"
  769. :size="'mini'"
  770. :controls="false"
  771. :append="'天'"
  772. @reschange="number_change($event, 'delivery_day')"
  773. />
  774. </el-form-item>
  775. </el-col>
  776. <el-col :span="6" style="padding-bottom: 1px">
  777. <el-form-item label="供货周期" prop="lead_time">
  778. <digital-input
  779. :values="ruleForm.lead_time"
  780. :placeholder="'物流时间'"
  781. :min="0"
  782. :name="'ruleForm.lead_time'"
  783. :disabled="type === 'view' || type === 'editCoin'"
  784. :max="100000000000"
  785. :position="'right'"
  786. :precision="0"
  787. :size="'mini'"
  788. :controls="false"
  789. :append="'天'"
  790. @reschange="number_change($event, 'lead_time')"
  791. />
  792. </el-form-item>
  793. </el-col>
  794. <el-col :span="6" style="padding-bottom: 1px">
  795. <el-form-item label="调样周期" prop="sample_day">
  796. <digital-input
  797. :values="ruleForm.sample_day"
  798. :placeholder="'调样周期'"
  799. :min="0"
  800. :name="'ruleForm.sample_day'"
  801. :disabled="type === 'view' || type === 'editCoin'"
  802. :max="100000000000"
  803. :position="'right'"
  804. :precision="0"
  805. :size="'mini'"
  806. :controls="false"
  807. :append="'天'"
  808. @reschange="number_change($event, 'sample_day')"
  809. />
  810. </el-form-item>
  811. </el-col>
  812. <el-col :span="12">
  813. <el-form-item label="发货地" prop="delivery_place">
  814. <search-area
  815. :value="areaInfo.delivery_place.code"
  816. :is-detail="true"
  817. size="mini"
  818. :disabled="type === 'view' || type === 'editCoin'"
  819. :names="areaInfo.delivery_place.label"
  820. placeholder="发货地"
  821. :level="3"
  822. @searchChange="areaChange($event, 'delivery_place')"
  823. />
  824. </el-form-item>
  825. </el-col>
  826. <el-col :span="12">
  827. <el-form-item label="产地" prop="origin_place">
  828. <search-area
  829. :value="areaInfo.origin_place.code"
  830. :disabled="type === 'view' || type === 'editCoin'"
  831. :is-detail="true"
  832. size="mini"
  833. :names="areaInfo.origin_place.label"
  834. placeholder="产地"
  835. :level="3"
  836. @searchChange="areaChange($event, 'origin_place')"
  837. />
  838. </el-form-item>
  839. </el-col>
  840. </el-row>
  841. </el-col>
  842. </el-row>
  843. <el-row class="ddiv">
  844. <el-col :span="1" class="dtitle">
  845. <ul>
  846. <li>图</li>
  847. <li>片</li>
  848. <li>信</li>
  849. <li>息</li>
  850. </ul>
  851. </el-col>
  852. <el-col :span="23" class="dmain">
  853. <el-row style="padding: 0 0 20px 0">
  854. <el-col :span="6">
  855. <el-form-item
  856. label="商品缩略"
  857. prop="good_thumb_img"
  858. class="activity-upload my-label-top"
  859. >
  860. <div class="btnupload" style="position: relative">
  861. <img
  862. v-if="ruleForm.good_thumb_img"
  863. :src="ruleForm.good_thumb_img"
  864. class="avatar"
  865. />
  866. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  867. <file-upload
  868. class="Upload"
  869. :disabled="type === 'view' || type === 'editCoin'"
  870. :accept="'.jpg,.png,.jpeg'"
  871. :multiple="true"
  872. :uploadcondition="beforeAvatarUpload"
  873. @UploadErrorEvent="UploadErrorEvent($event, 'good_thumb_img')"
  874. @UploadSuccessEvent="UploadSuccessEvent($event, 'good_thumb_img')"
  875. ></file-upload>
  876. </div>
  877. <div class="txt-tips fl">
  878. <p>尺寸比例:</p>
  879. <p>1:1</p>
  880. </div>
  881. </el-form-item>
  882. </el-col>
  883. <el-col :span="9">
  884. <el-form-item label="商品主图" prop="good_img">
  885. <div class="good_info_img_div" style="display: flex">
  886. <ul v-if="ruleForm.good_img" class="clear">
  887. <li
  888. class="img-show-li"
  889. v-viewer
  890. v-for="(img, iindex) in ruleForm.good_img"
  891. :key="img + iindex"
  892. >
  893. <div class="img-show-li-div">
  894. <img :src="img" class="img-show" alt />
  895. <i
  896. v-if="type == 'add' || type === 'editBase' || type === 'edit'"
  897. class="el-icon-close"
  898. @click="closeImg(iindex, 'good_img')"
  899. ></i>
  900. </div>
  901. </li>
  902. <li
  903. class="img-show-li"
  904. v-if="
  905. ruleForm.good_img.length < 11 &&
  906. (type == 'add' || type === 'editBase' || type === 'edit')
  907. "
  908. >
  909. <div class="activity-upload">
  910. <div class="btnupload" style="position: relative">
  911. <i class="el-icon-plus avatar-uploader-icon"></i>
  912. <file-upload
  913. class="Upload"
  914. :disabled="type === 'view' || type === 'editCoin'"
  915. :accept="'.jpg,.png,.jpeg'"
  916. :multiple="true"
  917. :uploadcondition="beforeAvatarUpload"
  918. @UploadErrorEvent="UploadErrorEvent($event, 'good_img')"
  919. @UploadSuccessEvent="UploadSuccessEvent($event, 'good_img')"
  920. ></file-upload>
  921. </div>
  922. </div>
  923. </li>
  924. </ul>
  925. </div>
  926. </el-form-item>
  927. </el-col>
  928. <el-col :span="9">
  929. <el-form-item label="详情介绍" prop="good_info_img">
  930. <div class="good_info_img_div" style="display: flex">
  931. <ul v-if="ruleForm.good_info_img" class="clear">
  932. <li
  933. class="img-show-li"
  934. v-viewer
  935. v-for="(img, iindex) in ruleForm.good_info_img"
  936. :key="img + iindex"
  937. >
  938. <div class="img-show-li-div">
  939. <img :src="img" class="img-show" alt />
  940. <i
  941. v-if="type == 'add' || type === 'editBase' || type === 'edit'"
  942. class="el-icon-close"
  943. @click="closeImg(iindex, 'good_info_img')"
  944. ></i>
  945. </div>
  946. </li>
  947. <li
  948. class="img-show-li"
  949. v-if="
  950. ruleForm.good_info_img.length < 11 &&
  951. (type == 'add' || type === 'editBase' || type === 'edit')
  952. "
  953. >
  954. <div class="activity-upload">
  955. <div class="btnupload" style="position: relative">
  956. <i class="el-icon-plus avatar-uploader-icon"></i>
  957. <file-upload
  958. class="Upload"
  959. :disabled="type === 'view' || type === 'editCoin'"
  960. :accept="'.jpg,.png,.jpeg'"
  961. :multiple="true"
  962. :uploadcondition="beforeAvatarUpload"
  963. @UploadErrorEvent="UploadErrorEvent($event, 'good_info_img')"
  964. @UploadSuccessEvent="
  965. UploadSuccessEvent($event, 'good_info_img')
  966. "
  967. ></file-upload>
  968. </div>
  969. </div>
  970. </li>
  971. </ul>
  972. </div>
  973. </el-form-item>
  974. </el-col>
  975. <el-col :span="24">
  976. <div style="font-size: 12px; color: #606266">
  977. <span style="padding: 0 0 0 20px">图片大小:小于1M</span>
  978. <span style="padding: 0 0 0 20px">图片类型.jpg/png/jpeg</span>
  979. </div>
  980. </el-col>
  981. </el-row>
  982. </el-col>
  983. </el-row>
  984. <el-row class="ddiv">
  985. <el-col :span="1" class="dtitle">
  986. <ul style="padding: 0">
  987. <li>固</li>
  988. <li>定</li>
  989. <li>与</li>
  990. <li>阶</li>
  991. <li>梯</li>
  992. <li>成</li>
  993. <li>本</li>
  994. </ul>
  995. </el-col>
  996. <el-col :span="23" class="dmain">
  997. <el-row>
  998. <el-col :span="6">
  999. <el-form-item label="打样费" prop="demo_fee" label-width="75px">
  1000. <digital-input
  1001. :values="ruleForm.demo_fee"
  1002. :placeholder="'打样费'"
  1003. :min="0"
  1004. :name="'ruleForm.demo_fee'"
  1005. :disabled="type === 'view' || type === 'editBase'"
  1006. :max="100000000000"
  1007. :position="'right'"
  1008. :precision="2"
  1009. :size="'mini'"
  1010. :controls="false"
  1011. :append="'元'"
  1012. @reschange="number_change($event, 'demo_fee')"
  1013. />
  1014. </el-form-item>
  1015. </el-col>
  1016. <el-col :span="6">
  1017. <el-form-item label="开模费" prop="open_fee" label-width="75px">
  1018. <digital-input
  1019. :values="ruleForm.open_fee"
  1020. :placeholder="'开模费'"
  1021. :min="0"
  1022. :name="'ruleForm.open_fee'"
  1023. :disabled="type === 'view' || type === 'editBase'"
  1024. :max="100000000000"
  1025. :position="'right'"
  1026. :precision="2"
  1027. :size="'mini'"
  1028. :controls="false"
  1029. :append="'元/件'"
  1030. @reschange="number_change($event, 'open_fee')"
  1031. />
  1032. </el-form-item>
  1033. </el-col>
  1034. <el-col :span="6">
  1035. <el-form-item label="调样费" prop="sample_fee" label-width="75px">
  1036. <digital-input
  1037. :values="ruleForm.sample_fee"
  1038. :placeholder="'调样费'"
  1039. :min="0"
  1040. :name="'ruleForm.sample_fee'"
  1041. :disabled="type === 'view' || type === 'editBase'"
  1042. :max="100000000000"
  1043. :position="'right'"
  1044. :precision="2"
  1045. :size="'mini'"
  1046. :controls="false"
  1047. :append="'元'"
  1048. @reschange="number_change($event, 'sample_fee')"
  1049. />
  1050. </el-form-item>
  1051. </el-col>
  1052. <el-col :span="6">
  1053. <el-form-item label="市场价" prop="market_price" label-width="75px">
  1054. <digital-input
  1055. :values="ruleForm.market_price"
  1056. :placeholder="'市场价'"
  1057. :min="0"
  1058. :name="'ruleForm.market_price'"
  1059. :disabled="type === 'view' || type === 'editBase'"
  1060. :max="100000000000"
  1061. :position="'right'"
  1062. :precision="2"
  1063. :size="'mini'"
  1064. :controls="false"
  1065. :append="'元'"
  1066. @reschange="number_change($event, 'market_price')"
  1067. />
  1068. </el-form-item>
  1069. </el-col>
  1070. <!-- <el-col :span="6">
  1071. <el-form-item label="启用阶梯" prop="is_step">
  1072. <el-select
  1073. v-model="ruleForm.is_step"
  1074. filterable
  1075. :disabled="type === 'view' || type === 'editBase'"
  1076. style="width: 100%"
  1077. placeholder="启用阶梯"
  1078. @change="is_step_change"
  1079. >
  1080. <el-option
  1081. v-for="group in options5"
  1082. :key="group.id"
  1083. :label="group.name"
  1084. :value="group.id"
  1085. />
  1086. </el-select>
  1087. </el-form-item>
  1088. </el-col>-->
  1089. <el-col
  1090. :span="6"
  1091. v-show="is_noble && ruleForm && ruleForm.is_gold_price === '1'"
  1092. >
  1093. <el-form-item
  1094. label="供应商采购金价"
  1095. prop="cgd_gold_price"
  1096. label-width="130px"
  1097. >
  1098. <digital-input
  1099. :values="ruleForm.cgd_gold_price"
  1100. :placeholder="'供应商采购金价'"
  1101. :min="0"
  1102. :name="'ruleForm.cgd_gold_price'"
  1103. :disabled="type === 'view' || type === 'editBase'"
  1104. :max="100000000000"
  1105. :position="'right'"
  1106. :precision="2"
  1107. :size="'mini'"
  1108. :controls="false"
  1109. :append="'元/g'"
  1110. @reschange="number_change($event, 'cgd_gold_price')"
  1111. />
  1112. </el-form-item>
  1113. </el-col>
  1114. <el-col
  1115. :span="6"
  1116. v-show="is_noble && ruleForm && ruleForm.is_gold_price === '1'"
  1117. >
  1118. <el-form-item label="当前金价">
  1119. <el-input
  1120. v-model="ruleForm.noble_price"
  1121. disabled
  1122. maxlength="15"
  1123. placeholder="当前金价"
  1124. >
  1125. <template slot="append">元/g</template>
  1126. </el-input>
  1127. </el-form-item>
  1128. </el-col>
  1129. <el-col :span="24" style="padding-left: 18px">
  1130. <el-table
  1131. :data="ladder_tableData"
  1132. :size="'mini'"
  1133. border
  1134. stripe
  1135. style="width: 100%; margin: 0 0 20px 0"
  1136. >
  1137. <el-table-column prop="min_num" label="起订量(>=)" />
  1138. <el-table-column prop="nake_fee" label="成本单价" />
  1139. <el-table-column prop="cost_fee" label="工艺费" />
  1140. <el-table-column prop="delivery_fee" label="物流费" />
  1141. <el-table-column prop="cert_fee" label="证书费" />
  1142. <el-table-column prop="mark_fee" label="加标费" />
  1143. <el-table-column prop="package_fee" label="包装费" />
  1144. <el-table-column prop="other_fee" label="其他费用" />
  1145. <el-table-column prop="nake_total" label="成本合计" />
  1146. <el-table-column
  1147. fixed="right"
  1148. v-if="type === 'add' || type === 'editCoin' || type === 'edit'"
  1149. width="80px"
  1150. >
  1151. <template slot="header" slot-scope="scope">
  1152. <span>操作</span>
  1153. <el-tooltip effect="dark" content="添加阶梯" placement="top">
  1154. <i
  1155. class="el-icon-circle-plus-outline tb-icon fr"
  1156. @click="openCostEdit(-1, {})"
  1157. ></i>
  1158. </el-tooltip>
  1159. </template>
  1160. <template slot-scope="scope">
  1161. <el-tooltip effect="dark" content="修改" placement="top">
  1162. <i
  1163. class="el-icon-edit tb-icon"
  1164. @click="openCostEdit(scope.$index, scope.row)"
  1165. ></i>
  1166. </el-tooltip>
  1167. <el-tooltip effect="dark" content="删除" placement="top">
  1168. <i
  1169. class="el-icon-delete tb-icon"
  1170. @click="openCostEditDelete(scope.$index)"
  1171. ></i>
  1172. </el-tooltip>
  1173. </template>
  1174. </el-table-column>
  1175. </el-table>
  1176. </el-col>
  1177. </el-row>
  1178. <!-- 弹窗 新增/修改 -->
  1179. <cost-form-add-edit
  1180. :index="costmodelIndex"
  1181. :show-model="costshowModel"
  1182. :sitem="costsitem"
  1183. @refresh="costrefreshEdit"
  1184. @cancel="costshowModel = false"
  1185. />
  1186. <product-modal
  1187. :type="modalType"
  1188. :editIndex="editIndex"
  1189. :editItem="editItem"
  1190. :visible.sync="mVisible"
  1191. />
  1192. <product-list-modal :visible.sync="visible" @selected="handleProductSelected" />
  1193. </el-col>
  1194. <el-col
  1195. :span="24"
  1196. v-if="
  1197. type === 'editBase' || type === 'add' || type === 'editCoin' || type === 'edit'
  1198. "
  1199. style="text-align: right; padding: 15px 0 15px 0; border-top: 1px solid #dcdfe6"
  1200. >
  1201. <el-button :size="'mini'" type="primary" @click="submitForm">保 存</el-button>
  1202. </el-col>
  1203. </el-row>
  1204. </el-form>
  1205. </template>
  1206. <script>
  1207. import asyncRequest from "@/apis/service/goodStore/goodsCost";
  1208. import resToken from "@/mixins/resToken";
  1209. import { mapGetters } from "vuex";
  1210. import baseFormAddEdit from "./baseFormAddEdit";
  1211. import costFormAddEdit from "./costFormAddEdit";
  1212. import companyHelper from "@/mixins/companyHelper";
  1213. import { add_sum, accMul } from "@/utils/validate";
  1214. import CompanySort from "@/components/globalComponents/company-sort/index.vue";
  1215. import { replaceTextWrapAndSpace } from "@/utils";
  1216. import ProductModal from "./productModal.vue";
  1217. import ProductListModal from "./productListModal.vue";
  1218. import { isStockOptions } from "@/assets/js/statusList";
  1219. import { isArray } from "@/utils/validate";
  1220. import {
  1221. options1,
  1222. options2,
  1223. options3,
  1224. options4,
  1225. options5,
  1226. options6,
  1227. options7,
  1228. options8,
  1229. options9,
  1230. rules,
  1231. } from "../columns";
  1232. export default {
  1233. name: "goodsCostAdd",
  1234. mixins: [resToken, companyHelper],
  1235. props: ["showModel", "id", "type", "sitem", "business_companyNo"],
  1236. components: {
  1237. CompanySort,
  1238. baseFormAddEdit,
  1239. costFormAddEdit,
  1240. ProductModal,
  1241. ProductListModal,
  1242. },
  1243. computed: {
  1244. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  1245. powers() {
  1246. const { btnList } = this.$store.getters;
  1247. const tran = btnList.find((i) => i.menu_route == "goodsCostAdd") || {};
  1248. const { action } = tran ?? {};
  1249. return action ?? [];
  1250. },
  1251. },
  1252. watch: {
  1253. newTime: function (val) {
  1254. if (val) {
  1255. this.initForm();
  1256. }
  1257. },
  1258. },
  1259. data() {
  1260. return {
  1261. isStockOptions,
  1262. areaInfo: {
  1263. delivery_place: {
  1264. code: [],
  1265. label: [],
  1266. },
  1267. origin_place: {
  1268. code: [],
  1269. label: [],
  1270. },
  1271. },
  1272. mVisible: false,
  1273. modalType: "",
  1274. editItem: null,
  1275. editIndex: -1,
  1276. childTableData: [],
  1277. visible: false,
  1278. companyName: "",
  1279. spec_tableData: [],
  1280. is_support_stock: "",
  1281. cat_id_name: "",
  1282. brand_name: "",
  1283. unit_name: "",
  1284. costshowModel: false,
  1285. costmodelIndex: "",
  1286. costsitem: {},
  1287. showModel: false,
  1288. modelIndex: "",
  1289. is_noble: false,
  1290. size: "small",
  1291. status: "",
  1292. rulesThis: this.rules,
  1293. activeName: "1",
  1294. loading: true,
  1295. supplierName: "",
  1296. options1: options1,
  1297. options2: options2,
  1298. options3: options3,
  1299. options4: options4,
  1300. options5: options5,
  1301. options6: options6,
  1302. options7: options7,
  1303. options8: options8,
  1304. options9: options9,
  1305. sourceCombindList: [],
  1306. ruleForm: {
  1307. is_combind: "",
  1308. company_id: "",
  1309. },
  1310. spec_tableData: [],
  1311. old_spec_tableData: [],
  1312. ladder_tableData: [],
  1313. old_ladder_tableData: [],
  1314. rules: rules,
  1315. };
  1316. },
  1317. mounted() {
  1318. this.initForm();
  1319. },
  1320. methods: {
  1321. num_change(evt, index) {
  1322. this.$set(this.childTableData, index, {
  1323. ...this.childTableData[index],
  1324. child_num: evt,
  1325. });
  1326. },
  1327. onSaveLine(index) {
  1328. const { child_num } = this.childTableData[index];
  1329. if (Number(child_num) === 0) {
  1330. this.$message.warning("组合比例不能为零!");
  1331. return;
  1332. }
  1333. this.editIndex = -1;
  1334. },
  1335. onChildProdChange(index = null, type = "view") {
  1336. this.modalType = type;
  1337. if (type === "add") {
  1338. if (this.editIndex !== -1) {
  1339. this.$message.warning("当前有正在编辑的子商品,请先保存");
  1340. return;
  1341. }
  1342. if (this.childTableData.length === 10) {
  1343. this.$message.warning("子商品最多不能超过十条");
  1344. return;
  1345. }
  1346. }
  1347. if (type === "view" && index !== null) {
  1348. this.editItem = { ...this.childTableData[index] };
  1349. } else {
  1350. this.editItem = null;
  1351. }
  1352. if (type === "edit") {
  1353. if (this.editIndex !== -1) {
  1354. this.$message.warning("当前有正在编辑的子商品,请先保存");
  1355. return;
  1356. }
  1357. this.editIndex = index !== null ? index : -1;
  1358. return;
  1359. }
  1360. this[type === "view" ? "mVisible" : "visible"] = true;
  1361. },
  1362. handleProductSelected(selecteds = []) {
  1363. const childCodes = this.childTableData.map(({ childCode }) => childCode);
  1364. selecteds.forEach((item) => {
  1365. const { childCode, child_name } = item;
  1366. const _t = { childCode, child_name, child_num: 1 };
  1367. if (!childCodes.includes(childCode)) {
  1368. this.childTableData.push(_t);
  1369. }
  1370. });
  1371. },
  1372. onCompanyChange() {
  1373. if (this.type === "add") {
  1374. this.ruleForm.company_id = this.currentCompany;
  1375. }
  1376. },
  1377. async initForm() {
  1378. this.loading = true;
  1379. this.resetFormData();
  1380. this.rulesThis = this.rules;
  1381. await this.resetForm();
  1382. this.sch_is_noble();
  1383. this.good_type_change();
  1384. await this.get_golpricelast();
  1385. this.stock_change();
  1386. this.loading = false;
  1387. },
  1388. async number_change(e, key) {
  1389. this.ruleForm[key] = e + "" || "0";
  1390. this.$refs.ruleForm && this.$refs.ruleForm.validateField(key);
  1391. await this.get_all_fee();
  1392. },
  1393. openEdit(index, sitem) {
  1394. this.modelIndex = index;
  1395. this.sitem = sitem;
  1396. this.showModel = true;
  1397. },
  1398. stock_change() {
  1399. if (this.ruleForm.is_stock === "0") {
  1400. this.ruleForm.is_combind = "0";
  1401. }
  1402. this.rulesThis.stock_moq[0].required = this.ruleForm.is_stock === "1";
  1403. },
  1404. onDeleteItem(index) {
  1405. if (this.editIndex !== -1) {
  1406. this.$message.warning("当前有正在编辑的子商品,请先保存");
  1407. return;
  1408. }
  1409. this.childTableData.splice(index, 1);
  1410. // if (index === this.editIndex) {
  1411. // this.editIndex = -1;
  1412. // }
  1413. },
  1414. openCostEdit(index, sitem) {
  1415. // const { is_step } = this.ruleForm;
  1416. // if (index === -1 && is_step === "0" && this.ladder_tableData.length > 0) {
  1417. // this.$message.warning("不启用阶梯成本,只能录入一条阶梯成本信息!");
  1418. // return;
  1419. // }
  1420. this.costmodelIndex = index;
  1421. this.costsitem = sitem;
  1422. this.costshowModel = true;
  1423. },
  1424. openDelete(index) {
  1425. this.spec_tableData.splice(index, 1);
  1426. },
  1427. openCostEditDelete(index) {
  1428. this.ladder_tableData.splice(index, 1);
  1429. },
  1430. // is_step_change() {
  1431. // const { is_step } = this.ruleForm;
  1432. // if (is_step === "0") {
  1433. // let res = [];
  1434. // let list =
  1435. // this.ladder_tableData.length === 0
  1436. // ? []
  1437. // : JSON.parse(JSON.stringify(this.ladder_tableData));
  1438. // if (list.length > 0) {
  1439. // res.push(list[0]);
  1440. // }
  1441. // this.ladder_tableData = res;
  1442. // }
  1443. // },
  1444. async submitForm() {
  1445. if (this.editIndex !== -1) {
  1446. this.$message.warning("当前有正在编辑的子商品,请先保存");
  1447. return;
  1448. }
  1449. const { is_combind, is_gold_price } = this.ruleForm;
  1450. if (is_combind === "1" && is_gold_price === "1" && this.is_noble) {
  1451. this.$message.warning("组合商品不能启用实时金价");
  1452. return;
  1453. }
  1454. this.sch_is_noble();
  1455. this.good_type_change();
  1456. this.ruleForm.good_remark = replaceTextWrapAndSpace(this.ruleForm.good_remark);
  1457. this.ruleForm.craft_desc = replaceTextWrapAndSpace(this.ruleForm.craft_desc);
  1458. this.ruleForm.after_sales = replaceTextWrapAndSpace(this.ruleForm.after_sales);
  1459. await this.$refs.ruleForm.validate(async (valid) => {
  1460. if (valid) {
  1461. if (!this.loading) {
  1462. this.loading = true;
  1463. const {
  1464. noble_weight,
  1465. weight,
  1466. is_gold_price,
  1467. stock_moq,
  1468. is_stock,
  1469. supplierNo,
  1470. company_id,
  1471. } = this.ruleForm;
  1472. if (supplierNo.toString() === company_id) {
  1473. this.$message.warning("供应商不能与业务公司相同!");
  1474. loading = false;
  1475. return;
  1476. }
  1477. if (this.is_support_stock + "" === "0" && is_stock === "0") {
  1478. this.$message.warning("该商品为供应商退货业务创建的,不允许改为非库存品!");
  1479. loading = false;
  1480. return;
  1481. }
  1482. if (is_stock === "0") {
  1483. const { scode, sdata, smsg } = await this.getSupplerPower();
  1484. if (scode === 0) {
  1485. const { has_account } = sdata;
  1486. if (has_account + "" === "1") {
  1487. this.$message.warning("该供应商已开通账号,不允许创建非库存商品!");
  1488. this.loading = false;
  1489. return;
  1490. }
  1491. }
  1492. }
  1493. if (this.spec_tableData.length === 0) {
  1494. this.$message.warning("请录入商品规格信息!");
  1495. this.loading = false;
  1496. return;
  1497. }
  1498. let isMust = true;
  1499. this.spec_tableData.forEach((e) => {
  1500. if (e.isMust && !e.spec_value_id) {
  1501. isMust = false;
  1502. }
  1503. });
  1504. if (!isMust) {
  1505. this.$message.warning("分类绑定的规格必须填写规格值!");
  1506. this.loading = false;
  1507. return;
  1508. }
  1509. if (this.ladder_tableData.length === 0) {
  1510. this.$message.warning("请录入阶梯成本!");
  1511. this.loading = false;
  1512. return;
  1513. }
  1514. // stock_moq
  1515. if (is_stock === "1") {
  1516. let min = parseInt(this.ladder_tableData[0].min_num),
  1517. smoq = parseInt(stock_moq);
  1518. this.ladder_tableData.forEach((si) => {
  1519. let n = parseInt(si.min_num);
  1520. min = n < min ? n : min;
  1521. });
  1522. if (smoq < min) {
  1523. this.$message.warning("备库起订量不能低于成本最低起订量!");
  1524. this.loading = false;
  1525. return;
  1526. }
  1527. }
  1528. if (this.is_noble) {
  1529. if (noble_weight * 1000 > weight * 1000) {
  1530. this.$message.warning("贵金属总重量不能大于商品总重量!");
  1531. this.loading = false;
  1532. return;
  1533. }
  1534. }
  1535. if (is_gold_price === "1" && this.is_noble) {
  1536. let is_p = true;
  1537. this.ladder_tableData.forEach((v) => {
  1538. if (v.nake_fee * 1 !== 0) {
  1539. is_p = false;
  1540. }
  1541. });
  1542. }
  1543. let model = JSON.parse(JSON.stringify(this.ruleForm));
  1544. model.cat_id = model.cat_id.toString();
  1545. model.brandid = model.brandid.toString();
  1546. model.supplierNo = model.supplierNo.toString();
  1547. model.delivery_place = model.delivery_place.toString();
  1548. model.origin_place = model.origin_place.toString();
  1549. model.good_info_img = model.good_info_img.toString();
  1550. model.good_img = model.good_img.toString();
  1551. model.unit = model.unit.toString();
  1552. model.speclist = JSON.parse(JSON.stringify(this.setResData(1)));
  1553. model.good_ladder = JSON.parse(JSON.stringify(this.setResData(2)));
  1554. model.config = model.config.toString();
  1555. model.is_exclusive =
  1556. model.is_exclusive.length > 0
  1557. ? model.is_exclusive[model.is_exclusive.length - 1]
  1558. : "";
  1559. let res = {};
  1560. delete model["id"];
  1561. if (model.is_combind === "1") {
  1562. if (this.childTableData.length === 0) {
  1563. this.message.warning("请添加子商品!");
  1564. return;
  1565. }
  1566. if (this.childTableData.length === 1) {
  1567. this.message.warning("子商品数量必须大于1!");
  1568. return;
  1569. }
  1570. if (this.type === "add") {
  1571. model.combind_list = this.childTableData.map((item) => ({
  1572. ...item,
  1573. is_del: "0",
  1574. }));
  1575. } else {
  1576. const currentIds = this.childTableData.map(({ id }) => id);
  1577. // 删除项
  1578. const delCombinds = this.sourceCombindList
  1579. .filter(({ id }) => !currentIds.includes(String(id)))
  1580. .map((item) => ({
  1581. ...item,
  1582. is_del: "1",
  1583. }));
  1584. //原项
  1585. const sourceCombinds = this.sourceCombindList
  1586. .filter(({ id }) => currentIds.includes(String(id)))
  1587. .map((item) => ({
  1588. ...item,
  1589. is_del: "0",
  1590. }));
  1591. const addCombinds = this.childTableData
  1592. .filter(({ id }) => !id)
  1593. .map(({ childCode, child_num, child_name }) => ({
  1594. childCode,
  1595. child_num,
  1596. child_name,
  1597. is_del: "0",
  1598. }));
  1599. model.combind_list = [...delCombinds, ...sourceCombinds, ...addCombinds];
  1600. }
  1601. }
  1602. if (this.type === "add") {
  1603. delete model["spuCode"];
  1604. res = await asyncRequest.add(model);
  1605. } else if (this.type === "editBase") {
  1606. let item1 = this.setModel(model, "1");
  1607. res = await asyncRequest.update(item1);
  1608. } else if (this.type === "editCoin") {
  1609. let item2 = this.setModel(model, "2");
  1610. res = await asyncRequest.updateP(item2);
  1611. } else {
  1612. model.companyNo = model.company_id;
  1613. delete model["company_id"];
  1614. res = await asyncRequest.edit_update(model);
  1615. }
  1616. // console.log(res);
  1617. this.loading = false;
  1618. const { code, data, message } = res;
  1619. if (code === 0) {
  1620. const title =
  1621. this.type === "add"
  1622. ? "新建成功!"
  1623. : this.type === "editBase"
  1624. ? "基础信息修改成功!"
  1625. : this.type === "editCoin"
  1626. ? "成本信息修改成功!"
  1627. : "商品信息修改成功";
  1628. this.$notify.success({
  1629. title: title,
  1630. message: "",
  1631. });
  1632. this.showModelThis = false;
  1633. // 刷新
  1634. this.$emit("refresh");
  1635. } else if (code >= 100 && code <= 104) {
  1636. await this.logout();
  1637. } else {
  1638. this.$message.warning(message);
  1639. }
  1640. }
  1641. } else {
  1642. // console.log("error submit!!");
  1643. return false;
  1644. }
  1645. });
  1646. },
  1647. groupGoodChange(e) {
  1648. this.ruleForm.is_combind = e;
  1649. },
  1650. //获取规格值
  1651. setResData(type) {
  1652. let list = JSON.parse(
  1653. JSON.stringify(type === 1 ? this.spec_tableData : this.ladder_tableData)
  1654. );
  1655. let oldlist = JSON.parse(
  1656. JSON.stringify(type === 1 ? this.old_spec_tableData : this.old_ladder_tableData)
  1657. );
  1658. let hasIDlist = [];
  1659. list.forEach((a) => {
  1660. if (a.id !== "") {
  1661. hasIDlist.push(a);
  1662. }
  1663. });
  1664. let newList = [];
  1665. let resList = [];
  1666. oldlist.forEach((a, ai) => {
  1667. let item = null;
  1668. let index = hasIDlist.findIndex((b) => a.id === b.id);
  1669. if (index === -1) {
  1670. item = JSON.parse(JSON.stringify(a));
  1671. item.is_del = "1";
  1672. } else {
  1673. item = JSON.parse(JSON.stringify(hasIDlist[index]));
  1674. }
  1675. newList.push(item);
  1676. });
  1677. list.forEach((b) => {
  1678. if (b.id === "") {
  1679. b.is_del = "0";
  1680. newList.push(b);
  1681. }
  1682. });
  1683. if (type === 1) {
  1684. newList.forEach((a) => {
  1685. let m = {
  1686. id: a.id,
  1687. spec_id: a.spec_id,
  1688. spec_value_id: a.spec_value_id,
  1689. is_del: a.is_del || "0",
  1690. };
  1691. resList.push(m);
  1692. });
  1693. } else {
  1694. newList.forEach((a) => {
  1695. let m = {
  1696. id: a.id,
  1697. min_num: a.min_num,
  1698. nake_fee: a.nake_fee,
  1699. cost_fee: a.cost_fee,
  1700. delivery_fee: a.delivery_fee,
  1701. cert_fee: a.cert_fee,
  1702. mark_fee: a.mark_fee,
  1703. package_fee: a.package_fee,
  1704. other_fee: a.other_fee,
  1705. is_del: a.is_del || "0",
  1706. };
  1707. resList.push(m);
  1708. });
  1709. }
  1710. return resList;
  1711. },
  1712. setladder() {
  1713. let list = JSON.parse(JSON.stringify(this.ladder_tableData));
  1714. let oldlist = JSON.parse(JSON.stringify(this.old_ladder_tableData));
  1715. let hasIDlist = [];
  1716. list.forEach((a) => {
  1717. if (a.id !== "") {
  1718. hasIDlist.push(a);
  1719. }
  1720. });
  1721. let newList = [];
  1722. let resList = [];
  1723. oldlist.forEach((a, ai) => {
  1724. let item = null;
  1725. let index = hasIDlist.findIndex((b) => a.id === b.id);
  1726. if (index === -1) {
  1727. item = JSON.parse(JSON.stringify(a));
  1728. item.is_del = "1";
  1729. } else {
  1730. item = JSON.parse(JSON.stringify(b));
  1731. }
  1732. newList.push(item);
  1733. });
  1734. list.forEach((b) => {
  1735. if (b.id === "") {
  1736. b.is_del = "0";
  1737. newList.push(b);
  1738. }
  1739. });
  1740. newList.forEach((a) => {
  1741. let m = {
  1742. id: a.id,
  1743. min_num: a.min_num,
  1744. spec_value_id: a.spec_value_id,
  1745. is_del: a.is_del || "0",
  1746. };
  1747. resList.push(m);
  1748. });
  1749. return resList;
  1750. },
  1751. //规格编辑修改
  1752. refreshEdit(e) {
  1753. let item = JSON.parse(JSON.stringify(e));
  1754. const {
  1755. index,
  1756. id,
  1757. spec_id,
  1758. isMust,
  1759. spec_value,
  1760. spec_value_id,
  1761. spec_value_value,
  1762. } = item;
  1763. let ffindex = -1;
  1764. this.spec_tableData.forEach((i, findex) => {
  1765. if (i.spec_id === spec_id) {
  1766. ffindex = findex;
  1767. this.spec_tableData[findex].id = id;
  1768. this.spec_tableData[findex].spec_id = spec_id;
  1769. // this.spec_tableData[findex].isMust = isMust;
  1770. this.spec_tableData[findex].spec_value = spec_value;
  1771. this.spec_tableData[findex].spec_value_id = spec_value_id;
  1772. this.spec_tableData[findex].spec_value_value = spec_value_value;
  1773. }
  1774. });
  1775. if (ffindex === -1) {
  1776. this.spec_tableData.push(item);
  1777. }
  1778. this.showModel = false;
  1779. },
  1780. //阶梯成本修改
  1781. async costrefreshEdit(e) {
  1782. let item = JSON.parse(JSON.stringify(e));
  1783. const {
  1784. index,
  1785. id,
  1786. cost_fee,
  1787. delivery_fee,
  1788. min_num,
  1789. nake_fee,
  1790. cert_fee,
  1791. mark_fee,
  1792. package_fee,
  1793. other_fee,
  1794. } = item;
  1795. let isok = true;
  1796. let ffindex = -1;
  1797. if (this.ladder_tableData && this.ladder_tableData.length === 0) {
  1798. this.ladder_tableData.push(item);
  1799. } else {
  1800. this.ladder_tableData.forEach((i, findex) => {
  1801. if (parseInt(min_num + "") === parseInt(i.min_num + "")) {
  1802. isok = false;
  1803. this.ladder_tableData[findex].id = id;
  1804. this.ladder_tableData[findex].min_num = min_num;
  1805. this.ladder_tableData[findex].cost_fee = cost_fee;
  1806. this.ladder_tableData[findex].delivery_fee = delivery_fee;
  1807. this.ladder_tableData[findex].nake_fee = nake_fee;
  1808. this.ladder_tableData[findex].cert_fee = cert_fee;
  1809. this.ladder_tableData[findex].mark_fee = mark_fee;
  1810. this.ladder_tableData[findex].package_fee = package_fee;
  1811. this.ladder_tableData[findex].other_fee = other_fee;
  1812. }
  1813. });
  1814. if (isok) {
  1815. this.ladder_tableData.forEach((i, findex) => {
  1816. if (findex === parseInt(index + "")) {
  1817. ffindex = findex;
  1818. this.ladder_tableData[findex].id = id;
  1819. this.ladder_tableData[findex].min_num = min_num;
  1820. this.ladder_tableData[findex].cost_fee = cost_fee;
  1821. this.ladder_tableData[findex].delivery_fee = delivery_fee;
  1822. this.ladder_tableData[findex].nake_fee = nake_fee;
  1823. this.ladder_tableData[findex].cert_fee = cert_fee;
  1824. this.ladder_tableData[findex].mark_fee = mark_fee;
  1825. this.ladder_tableData[findex].package_fee = package_fee;
  1826. this.ladder_tableData[findex].other_fee = other_fee;
  1827. }
  1828. });
  1829. if (ffindex === -1) {
  1830. this.ladder_tableData.push(item);
  1831. }
  1832. }
  1833. }
  1834. await this.get_all_fee();
  1835. this.showModel = false;
  1836. },
  1837. async get_golpricelast() {
  1838. const { noble_metal } = this.ruleForm;
  1839. if (noble_metal) {
  1840. let model = {
  1841. type: noble_metal,
  1842. };
  1843. const { code, data, message } = await asyncRequest.golpricelast(model);
  1844. if (code === 0) {
  1845. data.forEach((e) => {
  1846. if (e.type) {
  1847. this.ruleForm.noble_price = e.price;
  1848. }
  1849. });
  1850. } else if (code >= 100 && code <= 104) {
  1851. await this.logout();
  1852. } else {
  1853. this.$message.warning(message);
  1854. }
  1855. } else {
  1856. this.ruleForm.noble_price = "0";
  1857. }
  1858. },
  1859. async get_all_fee() {
  1860. await this.get_golpricelast();
  1861. this.ladder_tableData.forEach((si, sii) => {
  1862. this.ladder_tableData[sii].nake_total = this.count_fee(si);
  1863. this.$set(this.ladder_tableData, sii, this.ladder_tableData[sii]);
  1864. });
  1865. },
  1866. count_fee(e) {
  1867. const {
  1868. noble_price, //供应商采购金价
  1869. is_gold_price, //是否启用实时金价
  1870. noble_weight, //贵金属重量
  1871. } = this.ruleForm;
  1872. const {
  1873. nake_fee, //成本单价
  1874. cost_fee, //工艺费
  1875. delivery_fee, //物流费
  1876. cert_fee, //证书费
  1877. mark_fee, //加标费
  1878. package_fee, //包装费
  1879. other_fee, //其他费用
  1880. } = e;
  1881. let XA = add_sum(nake_fee, delivery_fee),
  1882. XB = add_sum(package_fee, cert_fee),
  1883. XC = add_sum(mark_fee, other_fee),
  1884. XD = 0;
  1885. let total = add_sum(add_sum(XA, XB), XC);
  1886. // console.log(total);
  1887. if (this.is_noble && is_gold_price === "1") {
  1888. XD = add_sum(accMul(noble_price, noble_weight), accMul(noble_weight, cost_fee));
  1889. total = add_sum(total, XD);
  1890. }
  1891. return total;
  1892. },
  1893. dataSort(key) {
  1894. return function (a, b) {
  1895. let value1 = a[key];
  1896. let value2 = b[key];
  1897. return value1 - value2;
  1898. };
  1899. },
  1900. async getSupplerPower() {
  1901. const { code, data, message } = await asyncRequest.supplerlist({
  1902. code: this.ruleForm.supplierNo[0],
  1903. is_platform: "",
  1904. name: "",
  1905. page: 1,
  1906. size: 1000,
  1907. });
  1908. return { scode: code, sdata: data, smsg: message };
  1909. },
  1910. resetFormData() {
  1911. this.is_support_stock = "1";
  1912. this.spec_tableData = [];
  1913. this.old_spec_tableData = [];
  1914. this.ladder_tableData = [];
  1915. this.old_ladder_tableData = [];
  1916. this.cat_id_name = "";
  1917. this.is_noble = false;
  1918. this.status = "";
  1919. this.brand_name = "";
  1920. this.unit_name = "";
  1921. this.supplierName = "";
  1922. this.ruleForm = {
  1923. id: "",
  1924. spuCode: "",
  1925. cat_id: [],
  1926. brandid: [],
  1927. noble_weight: "0",
  1928. weight: "0",
  1929. good_type: "0",
  1930. is_stock: "0",
  1931. supplierNo: [],
  1932. company_id: "",
  1933. is_auth: "",
  1934. tax: "",
  1935. good_name: "",
  1936. unit: [],
  1937. is_exclusive: [],
  1938. noble_metal: "",
  1939. is_gold_price: "",
  1940. moq: "",
  1941. customized: "",
  1942. after_sales: "",
  1943. craft_desc: "",
  1944. good_remark: "",
  1945. //包装发货/图片
  1946. packing_list: "",
  1947. packing_way: "",
  1948. packing_spec: "",
  1949. packing_weight: "",
  1950. packing_size: "",
  1951. good_size: "",
  1952. good_bar: "",
  1953. supply_area: "",
  1954. delivery_place: [],
  1955. origin_place: [],
  1956. delivery_day: "0",
  1957. lead_time: "0",
  1958. sample_day: "0",
  1959. good_thumb_img: "",
  1960. good_img: [],
  1961. good_info_img: [],
  1962. //固定阶梯成本
  1963. demo_fee: "0",
  1964. open_fee: "0",
  1965. sample_fee: "0",
  1966. market_price: "0",
  1967. cgd_gold_price: "0",
  1968. noble_price: "0",
  1969. // is_step: "0",
  1970. is_diff: "",
  1971. config: [],
  1972. other_config: "",
  1973. stock_moq: "0",
  1974. is_combind: "",
  1975. };
  1976. },
  1977. async resetForm() {
  1978. // 重置
  1979. await this.$nextTick(async () => {
  1980. if (this.$refs.ruleForm) {
  1981. this.$refs.ruleForm.resetFields();
  1982. this.$refs.ruleForm.clearValidate();
  1983. this.spec_tableData = [];
  1984. this.old_spec_tableData = [];
  1985. this.ladder_tableData = [];
  1986. this.old_ladder_tableData = [];
  1987. const {
  1988. id,
  1989. companyName,
  1990. spuCode, //string 商品spuCode
  1991. // good_code, //string 无
  1992. good_name, //string 商品名称
  1993. // cat_id, //string 分类id
  1994. cat_info, //array 分类
  1995. brand_id, //string 品牌id
  1996. unit,
  1997. supplierName,
  1998. companyNo, // string 企业公司id
  1999. good_unit, // string 商品单位
  2000. good_type, //string 是否定制 1是0否
  2001. moq, //string 起订量
  2002. is_exclusive, // string 是否是专属
  2003. customized, // string 定制工期
  2004. tax, //string 税率
  2005. supplierNo, // string 供应商
  2006. is_auth, //string 是否有销售权限0 否1 是
  2007. auth_img, // string 无
  2008. exclusive,
  2009. is_stock, //
  2010. after_sales, // string 售后说明
  2011. craft_desc, // string 工艺说明
  2012. good_remark, // string 商品备注
  2013. weight, // string 重量
  2014. packing_way, // string 包装方式
  2015. packing_size, // string 包装尺寸
  2016. good_size, //商品尺寸
  2017. packing_spec, // string 包装规格
  2018. packing_list, // string 包装清单
  2019. packing_weight, // string 装箱重量
  2020. good_bar, // string 条形码
  2021. supply_area, // string 供货区域 1 全国2 除偏远地区
  2022. delivery_place, // string 发货地区
  2023. origin_place, // string 产地
  2024. delivery_day, // string 物流天数
  2025. lead_time, // string 供货周期
  2026. sample_day, //string 调样周期
  2027. sample_fee, // string 调样费有
  2028. good_img, // string 商品图片
  2029. good_thumb_img, // string 商品说略图
  2030. good_info_img, // string 商品详情图
  2031. demo_fee, // string 打样费
  2032. open_fee, // string 开模费
  2033. noble_metal, // string 金属类别
  2034. noble_weight, // string 金属重量
  2035. is_gold_price, // string 是否使用实时金价
  2036. market_price, // string 市场价
  2037. cgd_gold_price, // string 供应商采购金价
  2038. noble_price,
  2039. // is_step, // string 是否使用阶梯价
  2040. // is_online, // string 是否上线
  2041. status, // string 状态
  2042. nakelist, //阶梯成本
  2043. speclist, //商品规格
  2044. brand_name,
  2045. config,
  2046. is_diff,
  2047. other_config,
  2048. stock_moq,
  2049. is_support_stock,
  2050. is_combind,
  2051. combind_list,
  2052. } = this.sitem;
  2053. console.log(good_img);
  2054. if (this.type !== "add") {
  2055. const { name, area_code } = await this.getArea("delivery_place");
  2056. if (name && area_code) {
  2057. this.areaInfo.delivery_place.label = [name];
  2058. this.areaInfo.delivery_place.code = [area_code];
  2059. const { name: _name, area_code: _area_code } = await this.getArea(
  2060. "origin_place"
  2061. );
  2062. this.areaInfo.origin_place.label = [_name];
  2063. this.areaInfo.origin_place.code = [_area_code];
  2064. }
  2065. }
  2066. this.companyName = companyName;
  2067. if (this.type !== "add") {
  2068. this.childTableData = combind_list.map(
  2069. ({ childCode, child_name, child_num, id }) => ({
  2070. childCode,
  2071. child_name,
  2072. child_num,
  2073. id,
  2074. })
  2075. );
  2076. this.sourceCombindList = this.childTableData.map((item) => ({
  2077. ...item,
  2078. }));
  2079. }
  2080. this.is_support_stock = is_support_stock || "1";
  2081. let cat_id_name = "";
  2082. let cat_id = [];
  2083. (cat_info || []).forEach((ai, i) => {
  2084. cat_id_name += i === 0 ? ai.name : `_${ai.name}`;
  2085. cat_id.push(ai.id);
  2086. });
  2087. this.cat_id_name = cat_id_name;
  2088. let isok = false;
  2089. if (cat_id.length > 0) {
  2090. cat_id.forEach((i) => {
  2091. if (i === "6") {
  2092. isok = true;
  2093. }
  2094. });
  2095. }
  2096. let exclusiveList = [];
  2097. if (exclusive && exclusive.length > 0) {
  2098. exclusive.forEach((a, ai) => {
  2099. exclusiveList.push(a.id);
  2100. });
  2101. }
  2102. this.is_noble = isok;
  2103. let spec_list1 =
  2104. speclist && speclist.length > 0 ? JSON.parse(JSON.stringify(speclist)) : [];
  2105. spec_list1.forEach((a) => {
  2106. let model = {
  2107. id: a.id,
  2108. is_del: a.is_del,
  2109. spec_id: a.spec_id,
  2110. spec_value: a.spec_name,
  2111. spec_value_value: a.spec_value,
  2112. spec_value_id: a.spec_value_id,
  2113. spuCode: a.spuCode,
  2114. };
  2115. this.spec_tableData.push(model);
  2116. });
  2117. this.old_spec_tableData = JSON.parse(JSON.stringify(this.spec_tableData));
  2118. let list2 =
  2119. nakelist && nakelist.length > 0 ? JSON.parse(JSON.stringify(nakelist)) : [];
  2120. this.ladder_tableData = list2;
  2121. this.old_ladder_tableData = JSON.parse(JSON.stringify(this.ladder_tableData));
  2122. this.status = status;
  2123. this.brand_name = brand_name;
  2124. this.unit_name = unit;
  2125. this.supplierName = supplierName || "";
  2126. console.log(good_img);
  2127. console.log(good_info_img);
  2128. this.ruleForm = {
  2129. id: id || "",
  2130. spuCode: spuCode || "",
  2131. cat_id: cat_id && cat_id.length > 0 ? [cat_id[cat_id.length - 1]] : [],
  2132. brandid: brand_id ? [brand_id] : [],
  2133. noble_weight: noble_weight || "",
  2134. weight: weight || "",
  2135. good_type: good_type || "0",
  2136. is_stock: is_stock || "0",
  2137. supplierNo: supplierNo ? [supplierNo] : [],
  2138. company_id: companyNo,
  2139. is_auth: is_auth || "",
  2140. tax: tax ? tax + "%" : "",
  2141. good_name: good_name || "",
  2142. unit: good_unit ? [good_unit] : [],
  2143. is_exclusive: exclusiveList || [],
  2144. noble_metal: noble_metal || "",
  2145. is_gold_price: is_gold_price || "0",
  2146. moq: moq || "0",
  2147. customized: customized || "0",
  2148. after_sales: after_sales || "",
  2149. craft_desc: craft_desc || "",
  2150. good_remark: good_remark || "",
  2151. //包装发货/图片
  2152. packing_list: packing_list || "",
  2153. packing_way: packing_way || "",
  2154. packing_spec: packing_spec || "",
  2155. packing_weight: packing_weight || "",
  2156. packing_size: packing_size || "",
  2157. good_size: good_size || "",
  2158. good_bar: good_bar || "",
  2159. supply_area: supply_area || "",
  2160. delivery_place: delivery_place ? (delivery_place || "").split(",") : [],
  2161. origin_place: origin_place ? (origin_place || "").split(",") : [],
  2162. delivery_day: delivery_day || "",
  2163. lead_time: lead_time || "",
  2164. sample_day: sample_day || "",
  2165. good_thumb_img: good_thumb_img || "",
  2166. good_img: good_img?!isArray(good_img || "") ? good_img.split(",") : []:[],
  2167. good_info_img:good_info_img||[] ,
  2168. //固定阶梯成本
  2169. demo_fee: demo_fee || "",
  2170. open_fee: open_fee || "",
  2171. sample_fee: sample_fee || "",
  2172. market_price: market_price || "",
  2173. cgd_gold_price: cgd_gold_price || "",
  2174. noble_price: noble_price || "0",
  2175. // is_step: is_step || "0",
  2176. is_diff: is_diff || "",
  2177. config: config ? config.split(",") : [],
  2178. other_config: other_config || "",
  2179. stock_moq: stock_moq || "0",
  2180. is_combind: is_combind || "",
  2181. };
  2182. }
  2183. if (this.type === "add") this.ruleForm.company_id = this.currentCompany;
  2184. await this.set_must_spec();
  2185. console.log(this.ruleForm);
  2186. });
  2187. },
  2188. sch_is_noble() {
  2189. let list = [
  2190. "noble_weight",
  2191. "noble_metal",
  2192. "is_gold_price",
  2193. "is_diff",
  2194. "config",
  2195. "other_config",
  2196. "cgd_gold_price",
  2197. ];
  2198. for (let i = 0; i < list.length; i++) {
  2199. if (list[i] === "cgd_gold_price") {
  2200. const { is_gold_price } = this.ruleForm;
  2201. this.rulesThis[list[i]][0].required = this.is_noble && is_gold_price === "1";
  2202. // console.log(list[i] + "===" + this.rulesThis[list[i]][0].required);
  2203. } else {
  2204. this.rulesThis[list[i]][0].required = this.is_noble;
  2205. }
  2206. this.$refs.ruleForm && this.$refs.ruleForm.validateField(list[i]);
  2207. }
  2208. },
  2209. setModel(model, type) {
  2210. let item = null;
  2211. if (type === 1) {
  2212. item = JSON.parse(JSON.stringify(model));
  2213. delete item["demo_fee"];
  2214. delete item["open_fee"];
  2215. delete item["noble_metal"];
  2216. delete item["noble_weight"];
  2217. delete item["is_gold_price"];
  2218. delete item["market_price"];
  2219. delete item["cgd_gold_price"];
  2220. // delete item["is_step"];
  2221. delete item["good_ladder"];
  2222. } else {
  2223. const {
  2224. demo_fee,
  2225. open_fee,
  2226. noble_metal,
  2227. noble_weight,
  2228. is_gold_price,
  2229. market_price,
  2230. cgd_gold_price,
  2231. // is_step,
  2232. good_ladder,
  2233. spuCode,
  2234. } = model;
  2235. item = {
  2236. demo_fee: demo_fee || "",
  2237. open_fee: open_fee || "",
  2238. noble_metal: noble_metal || "",
  2239. noble_weight: noble_weight || "",
  2240. is_gold_price: is_gold_price || "",
  2241. market_price: market_price || "",
  2242. cgd_gold_price: cgd_gold_price || "",
  2243. // is_step: is_step || "",
  2244. good_ladder: good_ladder || [],
  2245. spuCode: spuCode || "",
  2246. };
  2247. }
  2248. return model;
  2249. },
  2250. //商品分类选择
  2251. async goods_class_change(e) {
  2252. const { is_gold, pid, id, label, cat_desc } = e;
  2253. this.spec_tableData = [];
  2254. this.ruleForm.cat_id = id ? [id] : [];
  2255. this.$refs.ruleForm && this.$refs.ruleForm.validateField("cat_id");
  2256. this.ruleForm.after_sales = cat_desc || "";
  2257. this.$refs.ruleForm && this.$refs.ruleForm.validateField("after_sales");
  2258. this.is_noble = is_gold;
  2259. this.sch_is_noble();
  2260. await this.set_must_spec();
  2261. await this.get_all_fee();
  2262. },
  2263. async getArea(prop = "delivery_place") {
  2264. const chunks = this.sitem[prop].split(",");
  2265. if (chunks.length !== 3) return { nanme: "", area_code: "" };
  2266. let { data: province } = await asyncRequest.province();
  2267. province = province.find(({ province_code }) => province_code === chunks[0]);
  2268. let { data: city } = await asyncRequest.city({ code: chunks[0] });
  2269. city = city.find(({ city_code }) => city_code === chunks[1]);
  2270. let { data: area } = await asyncRequest.area({ code: chunks[1] });
  2271. return area.find(({ area_code }) => area_code === chunks[2]) || {};
  2272. },
  2273. async set_must_spec() {
  2274. const { cat_id } = this.ruleForm;
  2275. let id = cat_id.length == 1 ? cat_id[0] : "";
  2276. if (id) {
  2277. const { code, message, data } = await asyncRequest.catinfo({ id: id });
  2278. this.ruleForm.after_sales = data.cat_desc;
  2279. this.$refs.ruleForm && this.$refs.ruleForm.validateField("after_sales");
  2280. const unionSpec = (spec) => {
  2281. const newArr = [];
  2282. const map = new Map();
  2283. spec.forEach((item, index) => {
  2284. if (!map.has(item.id)) {
  2285. map.set(item.id, index);
  2286. newArr.push(item);
  2287. }
  2288. });
  2289. return newArr;
  2290. };
  2291. if (code === 0) {
  2292. const { spec: _spec = [] } = data;
  2293. const spec = unionSpec(_spec);
  2294. if (spec && spec.length > 0) {
  2295. if (this.spec_tableData && this.spec_tableData.length > 0) {
  2296. this.spec_tableData.forEach((c) => {
  2297. c.isMust = false;
  2298. });
  2299. spec.forEach((a, ai) => {
  2300. let findex = this.spec_tableData.findIndex(
  2301. (b) => b.spec_id + "" === a.id + ""
  2302. );
  2303. if (findex !== -1) {
  2304. this.spec_tableData[findex].isMust = true;
  2305. } else {
  2306. this.spec_tableData.push({
  2307. id: "",
  2308. index: "1",
  2309. spec_id: a.id + "",
  2310. spec_value: a.spec_name,
  2311. isMust: true,
  2312. spec_value_value: "",
  2313. spec_value_id: "",
  2314. });
  2315. }
  2316. });
  2317. } else {
  2318. spec.forEach((a, ai) => {
  2319. let model = {
  2320. id: "",
  2321. index: "1",
  2322. spec_id: a.id + "",
  2323. spec_value: a.spec_name,
  2324. isMust: true,
  2325. spec_value_value: "",
  2326. spec_value_id: "",
  2327. };
  2328. this.spec_tableData.push(model);
  2329. });
  2330. }
  2331. }
  2332. this.spec_tableData.map((e, ei) => {
  2333. e.index = ei + "";
  2334. return e;
  2335. });
  2336. this.spec_tableData.forEach((si, sii) => {
  2337. this.$set(this.spec_tableData, sii, si);
  2338. });
  2339. this.ruleForm.after_sales = data.cat_desc || "";
  2340. this.$refs.ruleForm && this.$refs.ruleForm.validateField("after_sales");
  2341. } else if (code >= 100 && code <= 104) {
  2342. await this.logout();
  2343. } else {
  2344. this.$message.warning(message);
  2345. }
  2346. } else {
  2347. this.spec_tableData.forEach((si, sii) => {
  2348. si.isMust = false;
  2349. this.$set(this.spec_tableData, sii, si);
  2350. });
  2351. }
  2352. },
  2353. async is_goold_price_change(e) {
  2354. await this.get_all_fee();
  2355. },
  2356. //商品品牌选择
  2357. brandidsearchChange(e) {
  2358. const { id, code, label } = e;
  2359. this.ruleForm.brandid = id ? [id] : [];
  2360. this.$refs.ruleForm && this.$refs.ruleForm.validateField("brandid");
  2361. },
  2362. //供应商选择
  2363. supplierNosearchChange(e) {
  2364. const { id, code, label } = e;
  2365. this.ruleForm.supplierNo = code ? [code] : [];
  2366. this.$refs.ruleForm && this.$refs.ruleForm.validateField("supplierNo");
  2367. },
  2368. //业务企业选择
  2369. company_idsearchChange(e) {
  2370. const { code } = e;
  2371. this.ruleForm.company_id = code || "";
  2372. this.$refs.ruleForm && this.$refs.ruleForm.validateField("company_id");
  2373. },
  2374. //税点选择
  2375. taxsearchChange(e) {
  2376. this.ruleForm.tax = e;
  2377. this.$refs.ruleForm && this.$refs.ruleForm.validateField("tax");
  2378. },
  2379. //专属类型选择
  2380. exclusiveSearchChange(e) {
  2381. this.ruleForm.is_exclusive = e;
  2382. this.$refs.ruleForm && this.$refs.ruleForm.validateField("is_exclusive");
  2383. },
  2384. //单位选择
  2385. unitsearchChange(e) {
  2386. const { id, code, label } = e;
  2387. this.ruleForm.unit = code ? [code] : [];
  2388. this.$refs.ruleForm && this.$refs.ruleForm.validateField("unit");
  2389. },
  2390. //贵金属种类选择
  2391. async noble_metalsearchChange(e) {
  2392. const { id, code, label } = e;
  2393. this.ruleForm.noble_metal = id || "";
  2394. this.$refs.ruleForm && this.$refs.ruleForm.validateField("noble_metal");
  2395. await this.get_all_fee();
  2396. },
  2397. async areaChange(e, key) {
  2398. const { code, area_code, label } = e;
  2399. this.ruleForm[key] = code ? code.split(",") : [];
  2400. this.areaInfo[key].code = area_code ? [area_code] : [];
  2401. this.areaInfo[key].label = label ? [label] : [];
  2402. this.$refs.ruleForm && this.$refs.ruleForm.validateField(key);
  2403. },
  2404. //省市区
  2405. selectAreaChange(e, key) {
  2406. this.ruleForm[key] = e;
  2407. this.$refs.ruleForm && this.$refs.ruleForm.validateField(key);
  2408. },
  2409. closeImg(index, key) {
  2410. this.ruleForm[key].splice(index, 1);
  2411. this.$refs.ruleForm && this.$refs.ruleForm.validateField(key);
  2412. },
  2413. //图片上传成功
  2414. async UploadSuccessEvent(data, key) {
  2415. const { url } = data;
  2416. if (url === "noToken") {
  2417. await this.logout();
  2418. } else {
  2419. if (key === "good_thumb_img") {
  2420. this.ruleForm[key] = url;
  2421. } else {
  2422. if (this.ruleForm[key].length < 10) {
  2423. this.ruleForm[key].push(url);
  2424. }
  2425. }
  2426. this.$refs.ruleForm && this.$refs.ruleForm.validateField(key);
  2427. this.$message.success("图片上传成功!");
  2428. }
  2429. },
  2430. good_type_change() {
  2431. let list = ["moq", "customized"];
  2432. for (let i = 0; i < list.length; i++) {
  2433. this.rulesThis[list[i]][0].required = this.ruleForm.good_type === "1";
  2434. this.$refs.ruleForm && this.$refs.ruleForm.validateField(list[i]);
  2435. }
  2436. },
  2437. UploadErrorEvent(res, key) {
  2438. if (res !== "break") {
  2439. this.$message.error("图片上传失败!");
  2440. this.$refs.ruleForm && this.$refs.ruleForm.validateField(key);
  2441. }
  2442. },
  2443. //判断图片规格
  2444. beforeAvatarUpload(file) {
  2445. let isJPG = false;
  2446. if (
  2447. file.type === "image/jpg" ||
  2448. file.type === "image/png" ||
  2449. file.type === "image/jpeg"
  2450. ) {
  2451. isJPG = true;
  2452. }
  2453. const isLt2M = file.size / 1024 / 1024 < 1;
  2454. if (!isJPG) {
  2455. this.$message.error("图片格式不正确!");
  2456. }
  2457. if (!isLt2M) {
  2458. this.$message.error("图片大小不能超过 1MB!");
  2459. }
  2460. return isJPG && isLt2M;
  2461. },
  2462. },
  2463. };
  2464. </script>
  2465. <style lang="scss" scoped>
  2466. .goodsCostDetail {
  2467. // position: relative;
  2468. .good_info_img_div {
  2469. ul {
  2470. width: 100%;
  2471. li {
  2472. float: left;
  2473. width: 55px;
  2474. height: 55px;
  2475. padding: 0 5px 0 0;
  2476. .img-show-li-div {
  2477. width: 50px;
  2478. height: 50px;
  2479. border: 1px solid #dfe4ed;
  2480. background: #dfe4ed;
  2481. position: relative;
  2482. img.img-show {
  2483. width: 100%;
  2484. height: 100%;
  2485. position: relative;
  2486. display: inline-block;
  2487. }
  2488. i.el-icon-close {
  2489. position: absolute;
  2490. z-index: 2;
  2491. top: 0;
  2492. right: 0;
  2493. color: #dfe4ed;
  2494. }
  2495. &:hover {
  2496. i.el-icon-close {
  2497. cursor: pointer;
  2498. color: #6954f0;
  2499. }
  2500. }
  2501. }
  2502. }
  2503. }
  2504. }
  2505. .goodsCostAdd-title {
  2506. border-top: 1px solid #ebeef5;
  2507. span {
  2508. height: 50px;
  2509. line-height: 50px;
  2510. font-family: "微软雅黑", sans-serif;
  2511. font-weight: 400;
  2512. font-style: normal;
  2513. font-size: 16fpx;
  2514. text-align: left;
  2515. }
  2516. }
  2517. }
  2518. </style>