baseForm.vue 86 KB

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