baseForm.vue 73 KB

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