baseFormNormal.vue 85 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537
  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="type === 'view' || type === 'editBase' || type === 'editCoin' || type === 'edit'"
  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="type === 'view' || type === 'editBase' || type === 'editCoin' || type === 'edit'"
  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'"
  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. <el-form-item label="商品分类" prop="cat_id">
  95. <company-sort
  96. :value="ruleForm.cat_id"
  97. :placeholder="'商品分类'"
  98. :disabled="type !== 'add' && !(type === 'edit' && String(sitem.status) === '7')"
  99. :size="'mini'"
  100. :names="cat_id_name"
  101. :isDetail="type !== 'add'"
  102. :company-no="ruleForm.company_id"
  103. @searchChange="goods_class_change"
  104. />
  105. </el-form-item>
  106. </el-col>
  107. <el-col :span="8">
  108. <el-form-item label="商品品牌" prop="brandid">
  109. <search-brand
  110. :value="ruleForm.brandid"
  111. :disabled="type === 'view' || type === 'editCoin'"
  112. :size="'mini'"
  113. :isDetail="type !== 'add'"
  114. :names="brand_name"
  115. :placeholder="'商品品牌'"
  116. @searchChange="brandidsearchChange"
  117. />
  118. </el-form-item>
  119. </el-col>
  120. <el-col :span="8">
  121. <el-form-item label="销售权限" prop="is_auth">
  122. <el-select
  123. v-model="ruleForm.is_auth"
  124. filterable
  125. clearable
  126. :disabled="type === 'view' || type === 'editCoin'"
  127. style="width: 100%"
  128. placeholder="销售权限"
  129. >
  130. <el-option
  131. v-for="group in options3"
  132. :key="group.id"
  133. :label="group.name"
  134. :value="group.id"
  135. />
  136. </el-select>
  137. </el-form-item>
  138. </el-col>
  139. </el-row>
  140. <el-row>
  141. <el-col :span="4">
  142. <el-form-item label="单位" prop="unit" label-width="60px">
  143. <search-unit
  144. :value="ruleForm.unit"
  145. :disabled="type === 'view' || type === 'editCoin'"
  146. :size="'mini'"
  147. :isDetail="type !== 'add'"
  148. :names="unit_name"
  149. :placeholder="'单位'"
  150. @searchChange="unitsearchChange"
  151. />
  152. </el-form-item>
  153. </el-col>
  154. <el-col :span="4">
  155. <el-form-item label="税点" prop="tax" label-width="60px">
  156. <search-tax
  157. :value="ruleForm.tax"
  158. :disabled="type === 'view' || type === 'editBase' || type === 'editCoin'"
  159. :size="'mini'"
  160. :isDetail="type !== 'add'"
  161. :placeholder="'税点'"
  162. @searchChange="taxsearchChange"
  163. />
  164. </el-form-item>
  165. </el-col>
  166. <el-col :span="8">
  167. <el-form-item label="专属类型" prop="is_exclusive">
  168. <search-exclusive
  169. :disabled="type === 'view' || type === 'editCoin'"
  170. style="width: 100%"
  171. :isDetail="type !== 'add'"
  172. :size="'mini'"
  173. placeholder="专属类型"
  174. :value="ruleForm.is_exclusive"
  175. @selectChange="exclusiveSearchChange"
  176. />
  177. </el-form-item>
  178. </el-col>
  179. <el-col :span="8">
  180. <el-form-item label="商品总重量" prop="weight" label-width="95px" style="height:32px">
  181. <digital-input
  182. :values="ruleForm.weight"
  183. :name="'ruleForm.weight'"
  184. :placeholder="'商品总重量'"
  185. :min="0"
  186. :disabled="type === 'view' || type === 'editCoin'"
  187. :max="100000000000"
  188. :position="'right'"
  189. :precision="3"
  190. :size="'mini'"
  191. :controls="false"
  192. :append="'g'"
  193. @reschange="number_change($event, 'weight')"
  194. />
  195. </el-form-item>
  196. </el-col>
  197. </el-row>
  198. <el-row :span="24" v-show="is_noble">
  199. <el-row>
  200. <el-col :span="8">
  201. <el-form-item label="贵金属重量" prop="noble_weight" label-width="95px">
  202. <digital-input
  203. :values="ruleForm.noble_weight"
  204. :placeholder="'贵金属重量'"
  205. :name="'ruleForm.noble_weight'"
  206. :min="0"
  207. :disabled="
  208. type === 'view' ||
  209. type === 'editBase' ||
  210. type === 'editCoin'
  211. "
  212. :max="100000000000"
  213. :position="'right'"
  214. :precision="3"
  215. :size="'mini'"
  216. :controls="false"
  217. :append="'g'"
  218. @reschange="number_change($event, 'noble_weight')"
  219. />
  220. </el-form-item>
  221. </el-col>
  222. <el-col :span="8">
  223. <el-form-item label="贵金属种类" prop="noble_metal" label-width="95px">
  224. <search-metal-kind
  225. :value="ruleForm.noble_metal"
  226. :disabled="
  227. type === 'view' || type === 'editBase' || type === 'editCoin'
  228. "
  229. :size="'mini'"
  230. :isDetail="type !== 'add'"
  231. :placeholder="'贵金属种类'"
  232. @searchChange="noble_metalsearchChange"
  233. />
  234. </el-form-item>
  235. </el-col>
  236. <el-col :span="8">
  237. <el-form-item label="启用实时金价" prop="is_gold_price" label-width="110px">
  238. <el-select
  239. v-model="ruleForm.is_gold_price"
  240. filterable
  241. clearable
  242. :disabled="
  243. type === 'view' || type === 'editBase' || type === 'editCoin'
  244. "
  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>
  919. <el-col :span="6">
  920. <el-form-item label="打样费" prop="demo_fee" label-width="75px">
  921. <digital-input
  922. :values="ruleForm.demo_fee"
  923. :placeholder="'打样费'"
  924. :min="0"
  925. :name="'ruleForm.demo_fee'"
  926. :disabled="type === 'view' || type === 'editBase'"
  927. :max="100000000000"
  928. :position="'right'"
  929. :precision="2"
  930. :size="'mini'"
  931. :controls="false"
  932. :append="'元'"
  933. @reschange="number_change($event, 'demo_fee')"
  934. />
  935. </el-form-item>
  936. </el-col>
  937. <el-col :span="6">
  938. <el-form-item label="开模费" prop="open_fee" label-width="75px">
  939. <digital-input
  940. :values="ruleForm.open_fee"
  941. :placeholder="'开模费'"
  942. :min="0"
  943. :name="'ruleForm.open_fee'"
  944. :disabled="type === 'view' || type === 'editBase'"
  945. :max="100000000000"
  946. :position="'right'"
  947. :precision="2"
  948. :size="'mini'"
  949. :controls="false"
  950. :append="'元/件'"
  951. @reschange="number_change($event, 'open_fee')"
  952. />
  953. </el-form-item>
  954. </el-col>
  955. <el-col :span="6">
  956. <el-form-item label="调样费" prop="sample_fee" label-width="75px">
  957. <digital-input
  958. :values="ruleForm.sample_fee"
  959. :placeholder="'调样费'"
  960. :min="0"
  961. :name="'ruleForm.sample_fee'"
  962. :disabled="type === 'view' || type === 'editBase'"
  963. :max="100000000000"
  964. :position="'right'"
  965. :precision="2"
  966. :size="'mini'"
  967. :controls="false"
  968. :append="'元'"
  969. @reschange="number_change($event, 'sample_fee')"
  970. />
  971. </el-form-item>
  972. </el-col>
  973. <el-col :span="6">
  974. <el-form-item label="市场价" prop="market_price" label-width="75px">
  975. <digital-input
  976. :values="ruleForm.market_price"
  977. :placeholder="'市场价'"
  978. :min="0"
  979. :name="'ruleForm.market_price'"
  980. :disabled="type === 'view' || type === 'editBase'"
  981. :max="100000000000"
  982. :position="'right'"
  983. :precision="2"
  984. :size="'mini'"
  985. :controls="false"
  986. :append="'元'"
  987. @reschange="number_change($event, 'market_price')"
  988. />
  989. </el-form-item>
  990. </el-col>
  991. <!-- <el-col :span="6">
  992. <el-form-item label="启用阶梯" prop="is_step">
  993. <el-select
  994. v-model="ruleForm.is_step"
  995. filterable
  996. :disabled="type === 'view' || type === 'editBase'"
  997. style="width: 100%"
  998. placeholder="启用阶梯"
  999. @change="is_step_change"
  1000. >
  1001. <el-option
  1002. v-for="group in options5"
  1003. :key="group.id"
  1004. :label="group.name"
  1005. :value="group.id"
  1006. />
  1007. </el-select>
  1008. </el-form-item>
  1009. </el-col>-->
  1010. <el-col :span="6" v-show="is_noble && ruleForm && ruleForm.is_gold_price === '1'">
  1011. <el-form-item label="供应商采购金价" prop="cgd_gold_price" label-width="130px">
  1012. <digital-input
  1013. :values="ruleForm.cgd_gold_price"
  1014. :placeholder="'供应商采购金价'"
  1015. :min="0"
  1016. :name="'ruleForm.cgd_gold_price'"
  1017. :disabled="type === 'view' || type === 'editBase'"
  1018. :max="100000000000"
  1019. :position="'right'"
  1020. :precision="2"
  1021. :size="'mini'"
  1022. :controls="false"
  1023. :append="'元/g'"
  1024. @reschange="number_change($event, 'cgd_gold_price')"
  1025. />
  1026. </el-form-item>
  1027. </el-col>
  1028. <el-col :span="6" v-show="is_noble && ruleForm && ruleForm.is_gold_price === '1'">
  1029. <el-form-item label="当前金价">
  1030. <el-input v-model="ruleForm.noble_price" disabled maxlength="15" placeholder="当前金价">
  1031. <template slot="append">元/g</template>
  1032. </el-input>
  1033. </el-form-item>
  1034. </el-col>
  1035. <el-col :span="24" style="padding-left: 18px">
  1036. <el-table
  1037. :data="ladder_tableData"
  1038. :size="'mini'"
  1039. border
  1040. stripe
  1041. style="width: 100%; margin: 0 0 20px 0"
  1042. >
  1043. <el-table-column prop="min_num" label="起订量(>=)" />
  1044. <el-table-column prop="nake_fee" label="成本单价" />
  1045. <el-table-column prop="cost_fee" label="工艺费" />
  1046. <el-table-column prop="delivery_fee" label="物流费" />
  1047. <el-table-column prop="cert_fee" label="证书费" />
  1048. <el-table-column prop="mark_fee" label="加标费" />
  1049. <el-table-column prop="package_fee" label="包装费" />
  1050. <el-table-column prop="other_fee" label="其他费用" />
  1051. <el-table-column prop="nake_total" label="成本合计" />
  1052. <el-table-column
  1053. fixed="right"
  1054. v-if="type === 'add' || type === 'editCoin' || type === 'edit'"
  1055. width="80px"
  1056. >
  1057. <template slot="header" slot-scope="scope">
  1058. <span>操作</span>
  1059. <el-tooltip effect="dark" content="添加阶梯" placement="top">
  1060. <i class="el-icon-circle-plus-outline tb-icon fr" @click="openCostEdit(-1, {})"></i>
  1061. </el-tooltip>
  1062. </template>
  1063. <template slot-scope="scope">
  1064. <el-tooltip effect="dark" content="修改" placement="top">
  1065. <i class="el-icon-edit tb-icon" @click="openCostEdit(scope.$index, scope.row)"></i>
  1066. </el-tooltip>
  1067. <el-tooltip effect="dark" content="删除" placement="top">
  1068. <i class="el-icon-delete tb-icon" @click="openCostEditDelete(scope.$index)"></i>
  1069. </el-tooltip>
  1070. </template>
  1071. </el-table-column>
  1072. </el-table>
  1073. </el-col>
  1074. </el-row>
  1075. <!-- 弹窗 新增/修改 -->
  1076. <cost-form-add-edit
  1077. :index="costmodelIndex"
  1078. :show-model="costshowModel"
  1079. :sitem="costsitem"
  1080. @refresh="costrefreshEdit"
  1081. @cancel="costshowModel = false"
  1082. />
  1083. <product-modal
  1084. :type="modalType"
  1085. :editIndex="editIndex"
  1086. :editItem="editItem"
  1087. :visible.sync="mVisible"
  1088. />
  1089. <product-list-modal :visible.sync="visible" @selected="handleProductSelected" />
  1090. </el-col>
  1091. <el-col
  1092. :span="24"
  1093. v-if="
  1094. type === 'editBase' || type === 'add' || type === 'editCoin' || type === 'edit'
  1095. "
  1096. style="text-align: right; padding: 15px 0 15px 0; border-top: 1px solid #dcdfe6"
  1097. >
  1098. <el-button :size="'mini'" type="primary" @click="submitForm">保 存</el-button>
  1099. </el-col>
  1100. </el-row>
  1101. </el-form>
  1102. </template>
  1103. <script>
  1104. import asyncRequest from "@/apis/service/goodStore/goodsCost";
  1105. import resToken from "@/mixins/resToken";
  1106. import { mapGetters } from "vuex";
  1107. import baseFormAddEdit from "./baseFormAddEdit";
  1108. import costFormAddEdit from "./costFormAddEdit";
  1109. import companyHelper from "@/mixins/companyHelper";
  1110. import { add_sum, accMul } from "@/utils/validate";
  1111. import CompanySort from "@/components/globalComponents/company-sort/index.vue";
  1112. import { replaceTextWrapAndSpace } from "@/utils";
  1113. import ProductModal from "./productModal.vue";
  1114. import ProductListModal from "./productListModal.vue";
  1115. import { isStockOptions } from "@/assets/js/statusList";
  1116. import {
  1117. options1,
  1118. options2,
  1119. options3,
  1120. options4,
  1121. options5,
  1122. options6,
  1123. options7,
  1124. options8,
  1125. options9,
  1126. rules
  1127. } from "../columns";
  1128. export default {
  1129. name: "goodsCostAdd",
  1130. mixins: [resToken, companyHelper],
  1131. props: ["showModel", "id", "type", "sitem", "business_companyNo"],
  1132. components: {
  1133. CompanySort,
  1134. baseFormAddEdit,
  1135. costFormAddEdit,
  1136. ProductModal,
  1137. ProductListModal
  1138. },
  1139. computed: {
  1140. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  1141. powers() {
  1142. const { btnList } = this.$store.getters;
  1143. const tran = btnList.find(i => i.menu_route == "goodsCostAdd") || {};
  1144. const { action } = tran ?? {};
  1145. return action ?? [];
  1146. }
  1147. },
  1148. watch: {
  1149. newTime: function(val) {
  1150. if (val) {
  1151. this.initForm();
  1152. }
  1153. }
  1154. },
  1155. data() {
  1156. return {
  1157. isStockOptions,
  1158. areaInfo: {
  1159. delivery_place: {
  1160. code: [],
  1161. label: []
  1162. },
  1163. origin_place: {
  1164. code: [],
  1165. label: []
  1166. }
  1167. },
  1168. mVisible: false,
  1169. modalType: "",
  1170. editItem: null,
  1171. editIndex: -1,
  1172. childTableData: [],
  1173. visible: false,
  1174. companyName: "",
  1175. spec_tableData: [],
  1176. is_support_stock: "",
  1177. cat_id_name: "",
  1178. brand_name: "",
  1179. unit_name: "",
  1180. costshowModel: false,
  1181. costmodelIndex: "",
  1182. costsitem: {},
  1183. showModel: false,
  1184. modelIndex: "",
  1185. is_noble: false,
  1186. size: "small",
  1187. status: "",
  1188. rulesThis: this.rules,
  1189. activeName: "1",
  1190. loading: true,
  1191. supplierName: "",
  1192. options1: options1,
  1193. options2: options2,
  1194. options3: options3,
  1195. options4: options4,
  1196. options5: options5,
  1197. options6: options6,
  1198. options7: options7,
  1199. options8: options8,
  1200. options9: options9,
  1201. sourceCombindList: [],
  1202. ruleForm: {
  1203. is_combind: "",
  1204. company_id: ""
  1205. },
  1206. spec_tableData: [],
  1207. old_spec_tableData: [],
  1208. ladder_tableData: [],
  1209. old_ladder_tableData: [],
  1210. rules: rules
  1211. };
  1212. },
  1213. mounted() {
  1214. this.initForm();
  1215. },
  1216. methods: {
  1217. num_change(evt, index) {
  1218. this.$set(this.childTableData, index, {
  1219. ...this.childTableData[index],
  1220. child_num: evt
  1221. });
  1222. },
  1223. onSaveLine(index) {
  1224. const { child_num } = this.childTableData[index];
  1225. if (Number(child_num) === 0) {
  1226. this.$message.warning("组合比例不能为零!");
  1227. return;
  1228. }
  1229. this.editIndex = -1;
  1230. },
  1231. onChildProdChange(index = null, type = "view") {
  1232. this.modalType = type;
  1233. if (type === "add") {
  1234. if (this.editIndex !== -1) {
  1235. this.$message.warning("当前有正在编辑的子商品,请先保存");
  1236. return;
  1237. }
  1238. if (this.childTableData.length === 10) {
  1239. this.$message.warning("子商品最多不能超过十条");
  1240. return;
  1241. }
  1242. }
  1243. if (type === "view" && index !== null) {
  1244. this.editItem = { ...this.childTableData[index] };
  1245. } else {
  1246. this.editItem = null;
  1247. }
  1248. if (type === "edit") {
  1249. if (this.editIndex !== -1) {
  1250. this.$message.warning("当前有正在编辑的子商品,请先保存");
  1251. return;
  1252. }
  1253. this.editIndex = index !== null ? index : -1;
  1254. return;
  1255. }
  1256. this[type === "view" ? "mVisible" : "visible"] = true;
  1257. },
  1258. handleProductSelected(selecteds = []) {
  1259. const childCodes = this.childTableData.map(({ childCode }) => childCode);
  1260. selecteds.forEach(item => {
  1261. const { childCode, child_name } = item;
  1262. const _t = { childCode, child_name, child_num: 1 };
  1263. if (!childCodes.includes(childCode)) {
  1264. this.childTableData.push(_t);
  1265. }
  1266. });
  1267. },
  1268. onCompanyChange() {
  1269. if (this.type === "add") {
  1270. this.ruleForm.company_id = this.currentCompany;
  1271. }
  1272. },
  1273. async initForm() {
  1274. this.loading = true;
  1275. this.resetFormData();
  1276. this.rulesThis = this.rules;
  1277. await this.resetForm();
  1278. this.sch_is_noble();
  1279. this.good_type_change();
  1280. await this.get_golpricelast();
  1281. this.stock_change();
  1282. this.loading = false;
  1283. },
  1284. async number_change(e, key) {
  1285. this.ruleForm[key] = e + "" || "0";
  1286. this.$refs.ruleForm && this.$refs.ruleForm.validateField(key);
  1287. await this.get_all_fee();
  1288. },
  1289. openEdit(index, sitem) {
  1290. this.modelIndex = index;
  1291. this.sitem = sitem;
  1292. this.showModel = true;
  1293. },
  1294. stock_change() {
  1295. if (this.ruleForm.is_stock === "0") {
  1296. this.ruleForm.is_combind = "0";
  1297. }
  1298. this.rulesThis.stock_moq[0].required = this.ruleForm.is_stock === "1";
  1299. },
  1300. onDeleteItem(index) {
  1301. if (this.editIndex !== -1) {
  1302. this.$message.warning("当前有正在编辑的子商品,请先保存");
  1303. return;
  1304. }
  1305. this.childTableData.splice(index, 1);
  1306. // if (index === this.editIndex) {
  1307. // this.editIndex = -1;
  1308. // }
  1309. },
  1310. openCostEdit(index, sitem) {
  1311. // const { is_step } = this.ruleForm;
  1312. // if (index === -1 && is_step === "0" && this.ladder_tableData.length > 0) {
  1313. // this.$message.warning("不启用阶梯成本,只能录入一条阶梯成本信息!");
  1314. // return;
  1315. // }
  1316. this.costmodelIndex = index;
  1317. this.costsitem = sitem;
  1318. this.costshowModel = true;
  1319. },
  1320. openDelete(index) {
  1321. this.spec_tableData.splice(index, 1);
  1322. },
  1323. openCostEditDelete(index) {
  1324. this.ladder_tableData.splice(index, 1);
  1325. },
  1326. // is_step_change() {
  1327. // const { is_step } = this.ruleForm;
  1328. // if (is_step === "0") {
  1329. // let res = [];
  1330. // let list =
  1331. // this.ladder_tableData.length === 0
  1332. // ? []
  1333. // : JSON.parse(JSON.stringify(this.ladder_tableData));
  1334. // if (list.length > 0) {
  1335. // res.push(list[0]);
  1336. // }
  1337. // this.ladder_tableData = res;
  1338. // }
  1339. // },
  1340. async submitForm() {
  1341. if (this.editIndex !== -1) {
  1342. this.$message.warning("当前有正在编辑的子商品,请先保存");
  1343. return;
  1344. }
  1345. const { is_combind, is_gold_price } = this.ruleForm;
  1346. if (is_combind === "1" && is_gold_price === "1" && this.is_noble) {
  1347. this.$message.warning("组合商品不能启用实时金价");
  1348. return;
  1349. }
  1350. this.sch_is_noble();
  1351. this.good_type_change();
  1352. this.ruleForm.good_remark = replaceTextWrapAndSpace(
  1353. this.ruleForm.good_remark
  1354. );
  1355. this.ruleForm.craft_desc = replaceTextWrapAndSpace(
  1356. this.ruleForm.craft_desc
  1357. );
  1358. this.ruleForm.after_sales = replaceTextWrapAndSpace(
  1359. this.ruleForm.after_sales
  1360. );
  1361. await this.$refs.ruleForm.validate(async valid => {
  1362. if (valid) {
  1363. if (!this.loading) {
  1364. this.loading = true;
  1365. const {
  1366. noble_weight,
  1367. weight,
  1368. is_gold_price,
  1369. stock_moq,
  1370. is_stock,
  1371. supplierNo,
  1372. company_id
  1373. } = this.ruleForm;
  1374. if (supplierNo.toString() === company_id) {
  1375. this.$message.warning("供应商不能与业务公司相同!");
  1376. loading = false;
  1377. return;
  1378. }
  1379. if (this.is_support_stock + "" === "0" && is_stock === "0") {
  1380. this.$message.warning(
  1381. "该商品为供应商退货业务创建的,不允许改为非库存品!"
  1382. );
  1383. loading = false;
  1384. return;
  1385. }
  1386. if (is_stock === "0") {
  1387. const { scode, sdata, smsg } = await this.getSupplerPower();
  1388. if (scode === 0) {
  1389. const { has_account } = sdata;
  1390. if (has_account + "" === "1") {
  1391. this.$message.warning(
  1392. "该供应商已开通账号,不允许创建非库存商品!"
  1393. );
  1394. this.loading = false;
  1395. return;
  1396. }
  1397. }
  1398. }
  1399. if (this.spec_tableData.length === 0) {
  1400. this.$message.warning("请录入商品规格信息!");
  1401. this.loading = false;
  1402. return;
  1403. }
  1404. let isMust = true;
  1405. this.spec_tableData.forEach(e => {
  1406. if (e.isMust && !e.spec_value_id) {
  1407. isMust = false;
  1408. }
  1409. });
  1410. if (!isMust) {
  1411. this.$message.warning("分类绑定的规格必须填写规格值!");
  1412. this.loading = false;
  1413. return;
  1414. }
  1415. if (this.ladder_tableData.length === 0) {
  1416. this.$message.warning("请录入阶梯成本!");
  1417. this.loading = false;
  1418. return;
  1419. }
  1420. // stock_moq
  1421. if (is_stock === "1") {
  1422. let min = parseInt(this.ladder_tableData[0].min_num),
  1423. smoq = parseInt(stock_moq);
  1424. this.ladder_tableData.forEach(si => {
  1425. let n = parseInt(si.min_num);
  1426. min = n < min ? n : min;
  1427. });
  1428. if (smoq < min) {
  1429. this.$message.warning("备库起订量不能低于成本最低起订量!");
  1430. this.loading = false;
  1431. return;
  1432. }
  1433. }
  1434. if (this.is_noble) {
  1435. if (noble_weight * 1000 > weight * 1000) {
  1436. this.$message.warning("贵金属总重量不能大于商品总重量!");
  1437. this.loading = false;
  1438. return;
  1439. }
  1440. }
  1441. if (is_gold_price === "1" && this.is_noble) {
  1442. let is_p = true;
  1443. this.ladder_tableData.forEach(v => {
  1444. if (v.nake_fee * 1 !== 0) {
  1445. is_p = false;
  1446. }
  1447. });
  1448. }
  1449. let model = JSON.parse(JSON.stringify(this.ruleForm));
  1450. model.cat_id = model.cat_id.toString();
  1451. model.brandid = model.brandid.toString();
  1452. model.supplierNo = model.supplierNo.toString();
  1453. model.delivery_place = model.delivery_place.toString();
  1454. model.origin_place = model.origin_place.toString();
  1455. model.good_info_img = model.good_info_img.toString();
  1456. model.good_img = model.good_img.toString();
  1457. model.unit = model.unit.toString();
  1458. model.speclist = JSON.parse(JSON.stringify(this.setResData(1)));
  1459. model.good_ladder = JSON.parse(JSON.stringify(this.setResData(2)));
  1460. model.config = model.config.toString();
  1461. model.is_exclusive =
  1462. model.is_exclusive.length > 0
  1463. ? model.is_exclusive[model.is_exclusive.length - 1]
  1464. : "";
  1465. let res = {};
  1466. delete model["id"];
  1467. if (model.is_combind === "1") {
  1468. if (this.childTableData.length === 0) {
  1469. this.message.warning("请添加子商品!");
  1470. return;
  1471. }
  1472. if (this.childTableData.length === 1) {
  1473. this.message.warning("子商品数量必须大于1!");
  1474. return;
  1475. }
  1476. if (this.type === "add") {
  1477. model.combind_list = this.childTableData.map(item => ({
  1478. ...item,
  1479. is_del: "0"
  1480. }));
  1481. } else {
  1482. const currentIds = this.childTableData.map(({ id }) => id);
  1483. // 删除项
  1484. const delCombinds = this.sourceCombindList
  1485. .filter(({ id }) => !currentIds.includes(String(id)))
  1486. .map(item => ({
  1487. ...item,
  1488. is_del: "1"
  1489. }));
  1490. //原项
  1491. const sourceCombinds = this.sourceCombindList
  1492. .filter(({ id }) => currentIds.includes(String(id)))
  1493. .map(item => ({
  1494. ...item,
  1495. is_del: "0"
  1496. }));
  1497. const addCombinds = this.childTableData
  1498. .filter(({ id }) => !id)
  1499. .map(({ childCode, child_num, child_name }) => ({
  1500. childCode,
  1501. child_num,
  1502. child_name,
  1503. is_del: "0"
  1504. }));
  1505. model.combind_list = [
  1506. ...delCombinds,
  1507. ...sourceCombinds,
  1508. ...addCombinds
  1509. ];
  1510. }
  1511. }
  1512. if (this.type === "add") {
  1513. delete model["spuCode"];
  1514. res = await asyncRequest.add(model);
  1515. } else if (this.type === "editBase") {
  1516. let item1 = this.setModel(model, "1");
  1517. res = await asyncRequest.update(item1);
  1518. } else if (this.type === "editCoin") {
  1519. let item2 = this.setModel(model, "2");
  1520. res = await asyncRequest.updateP(item2);
  1521. } else {
  1522. model.companyNo = model.company_id;
  1523. delete model["company_id"];
  1524. res = await asyncRequest.edit_update(model);
  1525. }
  1526. // console.log(res);
  1527. this.loading = false;
  1528. const { code, data, message } = res;
  1529. if (code === 0) {
  1530. const title =
  1531. this.type === "add"
  1532. ? "新建成功!"
  1533. : this.type === "editBase"
  1534. ? "基础信息修改成功!"
  1535. : this.type === "editCoin"
  1536. ? "成本信息修改成功!"
  1537. : "商品信息修改成功";
  1538. this.$notify.success({
  1539. title: title,
  1540. message: ""
  1541. });
  1542. this.showModelThis = false;
  1543. // 刷新
  1544. this.$emit("refresh");
  1545. } else if (code >= 100 && code <= 104) {
  1546. await this.logout();
  1547. } else {
  1548. this.$message.warning(message);
  1549. }
  1550. }
  1551. } else {
  1552. // console.log("error submit!!");
  1553. return false;
  1554. }
  1555. });
  1556. },
  1557. groupGoodChange(e) {
  1558. this.ruleForm.is_combind = e;
  1559. },
  1560. //获取规格值
  1561. setResData(type) {
  1562. let list = JSON.parse(
  1563. JSON.stringify(type === 1 ? this.spec_tableData : this.ladder_tableData)
  1564. );
  1565. let oldlist = JSON.parse(
  1566. JSON.stringify(
  1567. type === 1 ? this.old_spec_tableData : this.old_ladder_tableData
  1568. )
  1569. );
  1570. let hasIDlist = [];
  1571. list.forEach(a => {
  1572. if (a.id !== "") {
  1573. hasIDlist.push(a);
  1574. }
  1575. });
  1576. let newList = [];
  1577. let resList = [];
  1578. oldlist.forEach((a, ai) => {
  1579. let item = null;
  1580. let index = hasIDlist.findIndex(b => a.id === b.id);
  1581. if (index === -1) {
  1582. item = JSON.parse(JSON.stringify(a));
  1583. item.is_del = "1";
  1584. } else {
  1585. item = JSON.parse(JSON.stringify(hasIDlist[index]));
  1586. }
  1587. newList.push(item);
  1588. });
  1589. list.forEach(b => {
  1590. if (b.id === "") {
  1591. b.is_del = "0";
  1592. newList.push(b);
  1593. }
  1594. });
  1595. if (type === 1) {
  1596. newList.forEach(a => {
  1597. let m = {
  1598. id: a.id,
  1599. spec_id: a.spec_id,
  1600. spec_value_id: a.spec_value_id,
  1601. is_del: a.is_del || "0"
  1602. };
  1603. resList.push(m);
  1604. });
  1605. } else {
  1606. newList.forEach(a => {
  1607. let m = {
  1608. id: a.id,
  1609. min_num: a.min_num,
  1610. nake_fee: a.nake_fee,
  1611. cost_fee: a.cost_fee,
  1612. delivery_fee: a.delivery_fee,
  1613. cert_fee: a.cert_fee,
  1614. mark_fee: a.mark_fee,
  1615. package_fee: a.package_fee,
  1616. other_fee: a.other_fee,
  1617. is_del: a.is_del || "0"
  1618. };
  1619. resList.push(m);
  1620. });
  1621. }
  1622. return resList;
  1623. },
  1624. setladder() {
  1625. let list = JSON.parse(JSON.stringify(this.ladder_tableData));
  1626. let oldlist = JSON.parse(JSON.stringify(this.old_ladder_tableData));
  1627. let hasIDlist = [];
  1628. list.forEach(a => {
  1629. if (a.id !== "") {
  1630. hasIDlist.push(a);
  1631. }
  1632. });
  1633. let newList = [];
  1634. let resList = [];
  1635. oldlist.forEach((a, ai) => {
  1636. let item = null;
  1637. let index = hasIDlist.findIndex(b => a.id === b.id);
  1638. if (index === -1) {
  1639. item = JSON.parse(JSON.stringify(a));
  1640. item.is_del = "1";
  1641. } else {
  1642. item = JSON.parse(JSON.stringify(b));
  1643. }
  1644. newList.push(item);
  1645. });
  1646. list.forEach(b => {
  1647. if (b.id === "") {
  1648. b.is_del = "0";
  1649. newList.push(b);
  1650. }
  1651. });
  1652. newList.forEach(a => {
  1653. let m = {
  1654. id: a.id,
  1655. min_num: a.min_num,
  1656. spec_value_id: a.spec_value_id,
  1657. is_del: a.is_del || "0"
  1658. };
  1659. resList.push(m);
  1660. });
  1661. return resList;
  1662. },
  1663. //规格编辑修改
  1664. refreshEdit(e) {
  1665. let item = JSON.parse(JSON.stringify(e));
  1666. const {
  1667. index,
  1668. id,
  1669. spec_id,
  1670. isMust,
  1671. spec_value,
  1672. spec_value_id,
  1673. spec_value_value
  1674. } = item;
  1675. let ffindex = -1;
  1676. this.spec_tableData.forEach((i, findex) => {
  1677. if (i.spec_id === spec_id) {
  1678. ffindex = findex;
  1679. this.spec_tableData[findex].id = id;
  1680. this.spec_tableData[findex].spec_id = spec_id;
  1681. // this.spec_tableData[findex].isMust = isMust;
  1682. this.spec_tableData[findex].spec_value = spec_value;
  1683. this.spec_tableData[findex].spec_value_id = spec_value_id;
  1684. this.spec_tableData[findex].spec_value_value = spec_value_value;
  1685. }
  1686. });
  1687. if (ffindex === -1) {
  1688. this.spec_tableData.push(item);
  1689. }
  1690. this.showModel = false;
  1691. },
  1692. //阶梯成本修改
  1693. async costrefreshEdit(e) {
  1694. let item = JSON.parse(JSON.stringify(e));
  1695. const {
  1696. index,
  1697. id,
  1698. cost_fee,
  1699. delivery_fee,
  1700. min_num,
  1701. nake_fee,
  1702. cert_fee,
  1703. mark_fee,
  1704. package_fee,
  1705. other_fee
  1706. } = item;
  1707. let isok = true;
  1708. let ffindex = -1;
  1709. if (this.ladder_tableData && this.ladder_tableData.length === 0) {
  1710. this.ladder_tableData.push(item);
  1711. } else {
  1712. this.ladder_tableData.forEach((i, findex) => {
  1713. if (parseInt(min_num + "") === parseInt(i.min_num + "")) {
  1714. isok = false;
  1715. this.ladder_tableData[findex].id = id;
  1716. this.ladder_tableData[findex].min_num = min_num;
  1717. this.ladder_tableData[findex].cost_fee = cost_fee;
  1718. this.ladder_tableData[findex].delivery_fee = delivery_fee;
  1719. this.ladder_tableData[findex].nake_fee = nake_fee;
  1720. this.ladder_tableData[findex].cert_fee = cert_fee;
  1721. this.ladder_tableData[findex].mark_fee = mark_fee;
  1722. this.ladder_tableData[findex].package_fee = package_fee;
  1723. this.ladder_tableData[findex].other_fee = other_fee;
  1724. }
  1725. });
  1726. if (isok) {
  1727. this.ladder_tableData.forEach((i, findex) => {
  1728. if (findex === parseInt(index + "")) {
  1729. ffindex = findex;
  1730. this.ladder_tableData[findex].id = id;
  1731. this.ladder_tableData[findex].min_num = min_num;
  1732. this.ladder_tableData[findex].cost_fee = cost_fee;
  1733. this.ladder_tableData[findex].delivery_fee = delivery_fee;
  1734. this.ladder_tableData[findex].nake_fee = nake_fee;
  1735. this.ladder_tableData[findex].cert_fee = cert_fee;
  1736. this.ladder_tableData[findex].mark_fee = mark_fee;
  1737. this.ladder_tableData[findex].package_fee = package_fee;
  1738. this.ladder_tableData[findex].other_fee = other_fee;
  1739. }
  1740. });
  1741. if (ffindex === -1) {
  1742. this.ladder_tableData.push(item);
  1743. }
  1744. }
  1745. }
  1746. await this.get_all_fee();
  1747. this.showModel = false;
  1748. },
  1749. async get_golpricelast() {
  1750. const { noble_metal } = this.ruleForm;
  1751. if (noble_metal) {
  1752. let model = {
  1753. type: noble_metal
  1754. };
  1755. const { code, data, message } = await asyncRequest.golpricelast(model);
  1756. if (code === 0) {
  1757. data.forEach(e => {
  1758. if (e.type) {
  1759. this.ruleForm.noble_price = e.price;
  1760. }
  1761. });
  1762. } else if (code >= 100 && code <= 104) {
  1763. await this.logout();
  1764. } else {
  1765. this.$message.warning(message);
  1766. }
  1767. } else {
  1768. this.ruleForm.noble_price = "0";
  1769. }
  1770. },
  1771. async get_all_fee() {
  1772. await this.get_golpricelast();
  1773. this.ladder_tableData.forEach((si, sii) => {
  1774. this.ladder_tableData[sii].nake_total = this.count_fee(si);
  1775. this.$set(this.ladder_tableData, sii, this.ladder_tableData[sii]);
  1776. });
  1777. },
  1778. count_fee(e) {
  1779. const {
  1780. noble_price, //供应商采购金价
  1781. is_gold_price, //是否启用实时金价
  1782. noble_weight //贵金属重量
  1783. } = this.ruleForm;
  1784. const {
  1785. nake_fee, //成本单价
  1786. cost_fee, //工艺费
  1787. delivery_fee, //物流费
  1788. cert_fee, //证书费
  1789. mark_fee, //加标费
  1790. package_fee, //包装费
  1791. other_fee //其他费用
  1792. } = e;
  1793. let XA = add_sum(nake_fee, delivery_fee),
  1794. XB = add_sum(package_fee, cert_fee),
  1795. XC = add_sum(mark_fee, other_fee),
  1796. XD = 0;
  1797. let total = add_sum(add_sum(XA, XB), XC);
  1798. // console.log(total);
  1799. if (this.is_noble && is_gold_price === "1") {
  1800. XD = add_sum(
  1801. accMul(noble_price, noble_weight),
  1802. accMul(noble_weight, cost_fee)
  1803. );
  1804. total = add_sum(total, XD);
  1805. }
  1806. return total;
  1807. },
  1808. dataSort(key) {
  1809. return function(a, b) {
  1810. let value1 = a[key];
  1811. let value2 = b[key];
  1812. return value1 - value2;
  1813. };
  1814. },
  1815. async getSupplerPower() {
  1816. const { code, data, message } = await asyncRequest.supplerlist({
  1817. code: this.ruleForm.supplierNo[0],
  1818. is_platform: "",
  1819. name: "",
  1820. page: 1,
  1821. size: 1000
  1822. });
  1823. return { scode: code, sdata: data, smsg: message };
  1824. },
  1825. resetFormData() {
  1826. this.is_support_stock = "1";
  1827. this.spec_tableData = [];
  1828. this.old_spec_tableData = [];
  1829. this.ladder_tableData = [];
  1830. this.old_ladder_tableData = [];
  1831. this.cat_id_name = "";
  1832. this.is_noble = false;
  1833. this.status = "";
  1834. this.brand_name = "";
  1835. this.unit_name = "";
  1836. this.supplierName = "";
  1837. this.ruleForm = {
  1838. id: "",
  1839. spuCode: "",
  1840. cat_id: [],
  1841. brandid: [],
  1842. noble_weight: "0",
  1843. weight: "0",
  1844. good_type: "0",
  1845. is_stock: "0",
  1846. supplierNo: [],
  1847. company_id: "",
  1848. is_auth: "",
  1849. tax: "",
  1850. good_name: "",
  1851. unit: [],
  1852. is_exclusive: [],
  1853. noble_metal: "",
  1854. is_gold_price: "",
  1855. moq: "",
  1856. customized: "",
  1857. after_sales: "",
  1858. craft_desc: "",
  1859. good_remark: "",
  1860. //包装发货/图片
  1861. packing_list: "",
  1862. packing_way: "",
  1863. packing_spec: "",
  1864. packing_weight: "",
  1865. packing_size: "",
  1866. good_size: "",
  1867. good_bar: "",
  1868. supply_area: "",
  1869. delivery_place: [],
  1870. origin_place: [],
  1871. delivery_day: "0",
  1872. lead_time: "0",
  1873. sample_day: "0",
  1874. good_thumb_img: "",
  1875. good_img: [],
  1876. good_info_img: [],
  1877. //固定阶梯成本
  1878. demo_fee: "0",
  1879. open_fee: "0",
  1880. sample_fee: "0",
  1881. market_price: "0",
  1882. cgd_gold_price: "0",
  1883. noble_price: "0",
  1884. // is_step: "0",
  1885. is_diff: "",
  1886. config: [],
  1887. other_config: "",
  1888. stock_moq: "0",
  1889. is_combind: ""
  1890. };
  1891. },
  1892. async resetForm() {
  1893. // 重置
  1894. await this.$nextTick(async () => {
  1895. if (this.$refs.ruleForm) {
  1896. this.$refs.ruleForm.resetFields();
  1897. this.$refs.ruleForm.clearValidate();
  1898. this.spec_tableData = [];
  1899. this.old_spec_tableData = [];
  1900. this.ladder_tableData = [];
  1901. this.old_ladder_tableData = [];
  1902. const {
  1903. id,
  1904. companyName,
  1905. spuCode, //string 商品spuCode
  1906. // good_code, //string 无
  1907. good_name, //string 商品名称
  1908. // cat_id, //string 分类id
  1909. cat_info, //array 分类
  1910. brand_id, //string 品牌id
  1911. unit,
  1912. supplierName,
  1913. companyNo, // string 企业公司id
  1914. good_unit, // string 商品单位
  1915. good_type, //string 是否定制 1是0否
  1916. moq, //string 起订量
  1917. is_exclusive, // string 是否是专属
  1918. customized, // string 定制工期
  1919. tax, //string 税率
  1920. supplierNo, // string 供应商
  1921. is_auth, //string 是否有销售权限0 否1 是
  1922. auth_img, // string 无
  1923. exclusive,
  1924. is_stock, //
  1925. after_sales, // string 售后说明
  1926. craft_desc, // string 工艺说明
  1927. good_remark, // string 商品备注
  1928. weight, // string 重量
  1929. packing_way, // string 包装方式
  1930. packing_size, // string 包装尺寸
  1931. good_size, //商品尺寸
  1932. packing_spec, // string 包装规格
  1933. packing_list, // string 包装清单
  1934. packing_weight, // string 装箱重量
  1935. good_bar, // string 条形码
  1936. supply_area, // string 供货区域 1 全国2 除偏远地区
  1937. delivery_place, // string 发货地区
  1938. origin_place, // string 产地
  1939. delivery_day, // string 物流天数
  1940. lead_time, // string 供货周期
  1941. sample_day, //string 调样周期
  1942. sample_fee, // string 调样费有
  1943. good_img, // string 商品图片
  1944. good_thumb_img, // string 商品说略图
  1945. good_info_img, // string 商品详情图
  1946. demo_fee, // string 打样费
  1947. open_fee, // string 开模费
  1948. noble_metal, // string 金属类别
  1949. noble_weight, // string 金属重量
  1950. is_gold_price, // string 是否使用实时金价
  1951. market_price, // string 市场价
  1952. cgd_gold_price, // string 供应商采购金价
  1953. noble_price,
  1954. // is_step, // string 是否使用阶梯价
  1955. // is_online, // string 是否上线
  1956. status, // string 状态
  1957. nakelist, //阶梯成本
  1958. speclist, //商品规格
  1959. brand_name,
  1960. config,
  1961. is_diff,
  1962. other_config,
  1963. stock_moq,
  1964. is_support_stock,
  1965. is_combind,
  1966. combind_list,
  1967. } = this.sitem;
  1968. if (this.type !== "add") {
  1969. const { name, area_code } = await this.getArea("delivery_place");
  1970. if(name && area_code){
  1971. this.areaInfo.delivery_place.label = [name];
  1972. this.areaInfo.delivery_place.code = [area_code];
  1973. const { name: _name, area_code: _area_code } = await this.getArea(
  1974. "origin_place"
  1975. );
  1976. this.areaInfo.origin_place.label = [_name];
  1977. this.areaInfo.origin_place.code = [_area_code];
  1978. }
  1979. }
  1980. this.companyName = companyName;
  1981. if (this.type !== "add") {
  1982. this.childTableData = combind_list.map(
  1983. ({ childCode, child_name, child_num, id }) => ({
  1984. childCode,
  1985. child_name,
  1986. child_num,
  1987. id
  1988. })
  1989. );
  1990. this.sourceCombindList = this.childTableData.map(item => ({
  1991. ...item
  1992. }));
  1993. }
  1994. this.is_support_stock = is_support_stock || "1";
  1995. let cat_id_name = "";
  1996. let cat_id = [];
  1997. (cat_info || []).forEach((ai, i) => {
  1998. cat_id_name += i === 0 ? ai.name : `_${ai.name}`;
  1999. cat_id.push(ai.id);
  2000. });
  2001. this.cat_id_name = cat_id_name;
  2002. let isok = false;
  2003. if (cat_id.length > 0) {
  2004. cat_id.forEach(i => {
  2005. if (i === "6") {
  2006. isok = true;
  2007. }
  2008. });
  2009. }
  2010. let exclusiveList = [];
  2011. if (exclusive && exclusive.length > 0) {
  2012. exclusive.forEach((a, ai) => {
  2013. exclusiveList.push(a.id);
  2014. });
  2015. }
  2016. this.is_noble = isok;
  2017. let spec_list1 =
  2018. speclist && speclist.length > 0
  2019. ? JSON.parse(JSON.stringify(speclist))
  2020. : [];
  2021. spec_list1.forEach(a => {
  2022. let model = {
  2023. id: a.id,
  2024. is_del: a.is_del,
  2025. spec_id: a.spec_id,
  2026. spec_value: a.spec_name,
  2027. spec_value_value: a.spec_value,
  2028. spec_value_id: a.spec_value_id,
  2029. spuCode: a.spuCode
  2030. };
  2031. this.spec_tableData.push(model);
  2032. });
  2033. this.old_spec_tableData = JSON.parse(
  2034. JSON.stringify(this.spec_tableData)
  2035. );
  2036. let list2 =
  2037. nakelist && nakelist.length > 0
  2038. ? JSON.parse(JSON.stringify(nakelist))
  2039. : [];
  2040. this.ladder_tableData = list2;
  2041. this.old_ladder_tableData = JSON.parse(
  2042. JSON.stringify(this.ladder_tableData)
  2043. );
  2044. this.status = status;
  2045. this.brand_name = brand_name;
  2046. this.unit_name = unit;
  2047. this.supplierName = supplierName || "";
  2048. this.ruleForm = {
  2049. id: id || "",
  2050. spuCode: spuCode || "",
  2051. cat_id:
  2052. cat_id && cat_id.length > 0 ? [cat_id[cat_id.length - 1]] : [],
  2053. brandid: brand_id ? [brand_id] : [],
  2054. noble_weight: noble_weight || "",
  2055. weight: weight || "",
  2056. good_type: good_type || "0",
  2057. is_stock: is_stock || "0",
  2058. supplierNo: supplierNo ? [supplierNo] : [],
  2059. company_id: companyNo,
  2060. is_auth: is_auth || "",
  2061. tax: tax ? tax + "%" : "",
  2062. good_name: good_name || "",
  2063. unit: good_unit ? [good_unit] : [],
  2064. is_exclusive: exclusiveList || [],
  2065. noble_metal: noble_metal || "",
  2066. is_gold_price: is_gold_price || "0",
  2067. moq: moq || "0",
  2068. customized: customized || "0",
  2069. after_sales: after_sales || "",
  2070. craft_desc: craft_desc || "",
  2071. good_remark: good_remark || "",
  2072. //包装发货/图片
  2073. packing_list: packing_list || "",
  2074. packing_way: packing_way || "",
  2075. packing_spec: packing_spec || "",
  2076. packing_weight: packing_weight || "",
  2077. packing_size: packing_size || "",
  2078. good_size: good_size || "",
  2079. good_bar: good_bar || "",
  2080. supply_area: supply_area || "",
  2081. delivery_place: delivery_place
  2082. ? (delivery_place || "").split(",")
  2083. : [],
  2084. origin_place: origin_place ? (origin_place || "").split(",") : [],
  2085. delivery_day: delivery_day || "",
  2086. lead_time: lead_time || "",
  2087. sample_day: sample_day || "",
  2088. good_thumb_img: good_thumb_img || "",
  2089. good_img: good_img
  2090. ? Object.prototype.toString.call(good_img) === "[object Array]"
  2091. ? []
  2092. : (good_img || "").split(",")
  2093. : [],
  2094. good_info_img: good_info_img
  2095. ? (Object.prototype.toString.call(good_info_img) ===
  2096. "[object Array]"
  2097. ? []
  2098. : good_info_img || ""
  2099. ).split(",")
  2100. : [],
  2101. //固定阶梯成本
  2102. demo_fee: demo_fee || "",
  2103. open_fee: open_fee || "",
  2104. sample_fee: sample_fee || "",
  2105. market_price: market_price || "",
  2106. cgd_gold_price: cgd_gold_price || "",
  2107. noble_price: noble_price || "0",
  2108. // is_step: is_step || "0",
  2109. is_diff: is_diff || "",
  2110. config: config ? config.split(",") : [],
  2111. other_config: other_config || "",
  2112. stock_moq: stock_moq || "0",
  2113. is_combind: is_combind || ""
  2114. };
  2115. }
  2116. if (this.type === "add") this.ruleForm.company_id = this.currentCompany;
  2117. await this.set_must_spec();
  2118. });
  2119. },
  2120. sch_is_noble() {
  2121. let list = [
  2122. "noble_weight",
  2123. "noble_metal",
  2124. "is_gold_price",
  2125. "is_diff",
  2126. "config",
  2127. "other_config",
  2128. "cgd_gold_price"
  2129. ];
  2130. for (let i = 0; i < list.length; i++) {
  2131. if (list[i] === "cgd_gold_price") {
  2132. const { is_gold_price } = this.ruleForm;
  2133. this.rulesThis[list[i]][0].required =
  2134. this.is_noble && is_gold_price === "1";
  2135. // console.log(list[i] + "===" + this.rulesThis[list[i]][0].required);
  2136. } else {
  2137. this.rulesThis[list[i]][0].required = this.is_noble;
  2138. }
  2139. this.$refs.ruleForm && this.$refs.ruleForm.validateField(list[i]);
  2140. }
  2141. },
  2142. setModel(model, type) {
  2143. let item = null;
  2144. if (type === 1) {
  2145. item = JSON.parse(JSON.stringify(model));
  2146. delete item["demo_fee"];
  2147. delete item["open_fee"];
  2148. delete item["noble_metal"];
  2149. delete item["noble_weight"];
  2150. delete item["is_gold_price"];
  2151. delete item["market_price"];
  2152. delete item["cgd_gold_price"];
  2153. // delete item["is_step"];
  2154. delete item["good_ladder"];
  2155. } else {
  2156. const {
  2157. demo_fee,
  2158. open_fee,
  2159. noble_metal,
  2160. noble_weight,
  2161. is_gold_price,
  2162. market_price,
  2163. cgd_gold_price,
  2164. // is_step,
  2165. good_ladder,
  2166. spuCode
  2167. } = model;
  2168. item = {
  2169. demo_fee: demo_fee || "",
  2170. open_fee: open_fee || "",
  2171. noble_metal: noble_metal || "",
  2172. noble_weight: noble_weight || "",
  2173. is_gold_price: is_gold_price || "",
  2174. market_price: market_price || "",
  2175. cgd_gold_price: cgd_gold_price || "",
  2176. // is_step: is_step || "",
  2177. good_ladder: good_ladder || [],
  2178. spuCode: spuCode || ""
  2179. };
  2180. }
  2181. return model;
  2182. },
  2183. //商品分类选择
  2184. async goods_class_change(e) {
  2185. const { is_gold, pid, id, label, cat_desc } = e;
  2186. this.spec_tableData = [];
  2187. this.ruleForm.cat_id = id ? [id] : [];
  2188. this.$refs.ruleForm && this.$refs.ruleForm.validateField("cat_id");
  2189. this.ruleForm.after_sales = cat_desc || "";
  2190. this.$refs.ruleForm && this.$refs.ruleForm.validateField("after_sales");
  2191. this.is_noble = is_gold;
  2192. this.sch_is_noble();
  2193. await this.set_must_spec();
  2194. await this.get_all_fee();
  2195. },
  2196. async getArea(prop = "delivery_place") {
  2197. const chunks = this.sitem[prop].split(",");
  2198. if(chunks.length !== 3) return {nanme:"", area_code:""}
  2199. let { data: province } = await asyncRequest.province();
  2200. province = province.find(
  2201. ({ province_code }) => province_code === chunks[0]
  2202. );
  2203. let { data: city } = await asyncRequest.city({ code: chunks[0] });
  2204. city = city.find(({ city_code }) => city_code === chunks[1]);
  2205. let { data: area } = await asyncRequest.area({ code: chunks[1] });
  2206. return area.find(({ area_code }) => area_code === chunks[2]) || {};
  2207. },
  2208. async set_must_spec() {
  2209. const { cat_id } = this.ruleForm;
  2210. let id = cat_id.length == 1 ? cat_id[0] : "";
  2211. if (id) {
  2212. const { code, message, data } = await asyncRequest.catinfo({ id: id });
  2213. this.ruleForm.after_sales = data.cat_desc;
  2214. this.$refs.ruleForm && this.$refs.ruleForm.validateField("after_sales");
  2215. const unionSpec = spec => {
  2216. const newArr = [];
  2217. const map = new Map();
  2218. spec.forEach((item, index) => {
  2219. if (!map.has(item.id)) {
  2220. map.set(item.id, index);
  2221. newArr.push(item);
  2222. }
  2223. });
  2224. return newArr;
  2225. };
  2226. if (code === 0) {
  2227. const { spec: _spec = [] } = data;
  2228. const spec = unionSpec(_spec);
  2229. if (spec && spec.length > 0) {
  2230. if (this.spec_tableData && this.spec_tableData.length > 0) {
  2231. this.spec_tableData.forEach(c => {
  2232. c.isMust = false;
  2233. });
  2234. spec.forEach((a, ai) => {
  2235. let findex = this.spec_tableData.findIndex(
  2236. b => b.spec_id + "" === a.id + ""
  2237. );
  2238. if (findex !== -1) {
  2239. this.spec_tableData[findex].isMust = true;
  2240. } else {
  2241. this.spec_tableData.push({
  2242. id: "",
  2243. index: "1",
  2244. spec_id: a.id + "",
  2245. spec_value: a.spec_name,
  2246. isMust: true,
  2247. spec_value_value: "",
  2248. spec_value_id: ""
  2249. });
  2250. }
  2251. });
  2252. } else {
  2253. spec.forEach((a, ai) => {
  2254. let model = {
  2255. id: "",
  2256. index: "1",
  2257. spec_id: a.id + "",
  2258. spec_value: a.spec_name,
  2259. isMust: true,
  2260. spec_value_value: "",
  2261. spec_value_id: ""
  2262. };
  2263. this.spec_tableData.push(model);
  2264. });
  2265. }
  2266. }
  2267. this.spec_tableData.map((e, ei) => {
  2268. e.index = ei + "";
  2269. return e;
  2270. });
  2271. this.spec_tableData.forEach((si, sii) => {
  2272. this.$set(this.spec_tableData, sii, si);
  2273. });
  2274. this.ruleForm.after_sales = data.cat_desc || "";
  2275. this.$refs.ruleForm &&
  2276. this.$refs.ruleForm.validateField("after_sales");
  2277. } else if (code >= 100 && code <= 104) {
  2278. await this.logout();
  2279. } else {
  2280. this.$message.warning(message);
  2281. }
  2282. } else {
  2283. this.spec_tableData.forEach((si, sii) => {
  2284. si.isMust = false;
  2285. this.$set(this.spec_tableData, sii, si);
  2286. });
  2287. }
  2288. },
  2289. async is_goold_price_change(e) {
  2290. await this.get_all_fee();
  2291. },
  2292. //商品品牌选择
  2293. brandidsearchChange(e) {
  2294. const { id, code, label } = e;
  2295. this.ruleForm.brandid = id ? [id] : [];
  2296. this.$refs.ruleForm && this.$refs.ruleForm.validateField("brandid");
  2297. },
  2298. //供应商选择
  2299. supplierNosearchChange(e) {
  2300. const { id, code, label } = e;
  2301. this.ruleForm.supplierNo = code ? [code] : [];
  2302. this.$refs.ruleForm && this.$refs.ruleForm.validateField("supplierNo");
  2303. },
  2304. //业务企业选择
  2305. company_idsearchChange(e) {
  2306. const { code } = e;
  2307. this.ruleForm.company_id = code || "";
  2308. this.$refs.ruleForm && this.$refs.ruleForm.validateField("company_id");
  2309. },
  2310. //税点选择
  2311. taxsearchChange(e) {
  2312. this.ruleForm.tax = e;
  2313. this.$refs.ruleForm && this.$refs.ruleForm.validateField("tax");
  2314. },
  2315. //专属类型选择
  2316. exclusiveSearchChange(e) {
  2317. this.ruleForm.is_exclusive = e;
  2318. this.$refs.ruleForm && this.$refs.ruleForm.validateField("is_exclusive");
  2319. },
  2320. //单位选择
  2321. unitsearchChange(e) {
  2322. const { id, code, label } = e;
  2323. this.ruleForm.unit = code ? [code] : [];
  2324. this.$refs.ruleForm && this.$refs.ruleForm.validateField("unit");
  2325. },
  2326. //贵金属种类选择
  2327. async noble_metalsearchChange(e) {
  2328. const { id, code, label } = e;
  2329. this.ruleForm.noble_metal = id || "";
  2330. tthis.$refs.ruleForm && his.$refs.ruleForm.validateField("noble_metal");
  2331. await this.get_all_fee();
  2332. },
  2333. async areaChange(e, key) {
  2334. const { code, area_code, label } = e;
  2335. this.ruleForm[key] = code ? code.split(",") : [];
  2336. this.areaInfo[key].code = area_code ? [area_code] : [];
  2337. this.areaInfo[key].label = label ? [label] : [];
  2338. this.$refs.ruleForm && this.$refs.ruleForm.validateField(key);
  2339. },
  2340. //省市区
  2341. selectAreaChange(e, key) {
  2342. this.ruleForm[key] = e;
  2343. this.$refs.ruleForm && this.$refs.ruleForm.validateField(key);
  2344. },
  2345. closeImg(index, key) {
  2346. this.ruleForm[key].splice(index, 1);
  2347. this.$refs.ruleForm && this.$refs.ruleForm.validateField(key);
  2348. },
  2349. //图片上传成功
  2350. async UploadSuccessEvent(data, key) {
  2351. const { url } = data;
  2352. if (url === "noToken") {
  2353. await this.logout();
  2354. } else {
  2355. if (key === "good_thumb_img") {
  2356. this.ruleForm[key] = url;
  2357. } else {
  2358. if (this.ruleForm[key].length < 10) {
  2359. this.ruleForm[key].push(url);
  2360. }
  2361. }
  2362. this.$refs.ruleForm && this.$refs.ruleForm.validateField(key);
  2363. this.$message.success("图片上传成功!");
  2364. }
  2365. },
  2366. good_type_change() {
  2367. let list = ["moq", "customized"];
  2368. for (let i = 0; i < list.length; i++) {
  2369. this.rulesThis[list[i]][0].required = this.ruleForm.good_type === "1";
  2370. this.$refs.ruleForm && this.$refs.ruleForm.validateField(list[i]);
  2371. }
  2372. },
  2373. UploadErrorEvent(res, key) {
  2374. if (res !== "break") {
  2375. this.$message.error("图片上传失败!");
  2376. this.$refs.ruleForm && this.$refs.ruleForm.validateField(key);
  2377. }
  2378. },
  2379. //判断图片规格
  2380. beforeAvatarUpload(file) {
  2381. let isJPG = false;
  2382. if (
  2383. file.type === "image/jpg" ||
  2384. file.type === "image/png" ||
  2385. file.type === "image/jpeg"
  2386. ) {
  2387. isJPG = true;
  2388. }
  2389. const isLt2M = file.size / 1024 / 1024 < 1;
  2390. if (!isJPG) {
  2391. this.$message.error("图片格式不正确!");
  2392. }
  2393. if (!isLt2M) {
  2394. this.$message.error("图片大小不能超过 1MB!");
  2395. }
  2396. return isJPG && isLt2M;
  2397. }
  2398. }
  2399. };
  2400. </script>
  2401. <style lang="scss" scoped>
  2402. .goodsCostDetail {
  2403. // position: relative;
  2404. .good_info_img_div {
  2405. ul {
  2406. width: 100%;
  2407. li {
  2408. float: left;
  2409. width: 55px;
  2410. height: 55px;
  2411. padding: 0 5px 0 0;
  2412. .img-show-li-div {
  2413. width: 50px;
  2414. height: 50px;
  2415. border: 1px solid #dfe4ed;
  2416. background: #dfe4ed;
  2417. position: relative;
  2418. img.img-show {
  2419. width: 100%;
  2420. height: 100%;
  2421. position: relative;
  2422. display: inline-block;
  2423. }
  2424. i.el-icon-close {
  2425. position: absolute;
  2426. z-index: 2;
  2427. top: 0;
  2428. right: 0;
  2429. color: #dfe4ed;
  2430. }
  2431. &:hover {
  2432. i.el-icon-close {
  2433. cursor: pointer;
  2434. color: #6954f0;
  2435. }
  2436. }
  2437. }
  2438. }
  2439. }
  2440. }
  2441. .goodsCostAdd-title {
  2442. border-top: 1px solid #ebeef5;
  2443. span {
  2444. height: 50px;
  2445. line-height: 50px;
  2446. font-family: "微软雅黑", sans-serif;
  2447. font-weight: 400;
  2448. font-style: normal;
  2449. font-size: 16fpx;
  2450. text-align: left;
  2451. }
  2452. }
  2453. }
  2454. </style>