baseForm.vue 86 KB

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