baseForm.vue 75 KB

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