baseForm.vue 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127
  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="85px"
  10. class="demo-ruleForm"
  11. >
  12. <el-row>
  13. <el-col
  14. :span="24"
  15. style="padding: 12px 16px 12px 16px; text-align: right"
  16. >
  17. <span
  18. >成本合计:<span>{{ back_total }}</span></span
  19. >
  20. <span
  21. class="fl"
  22. style="height: 28px; font-size: 16px; line-height: 28px"
  23. >{{ title }}</span
  24. >
  25. <el-button :size="'mini'" @click="$emit('cancel')">取 消 </el-button>
  26. <el-button :size="'mini'" type="primary" @click="submitForm"
  27. >保 存
  28. </el-button>
  29. </el-col>
  30. <el-col :span="16">
  31. <el-form-item label="供应商" prop="supplierNo">
  32. <search-supplier
  33. :value="ruleForm.supplierNo"
  34. :placeholder="'供应商'"
  35. :size="'mini'"
  36. :disabled="type === 'view'"
  37. :isDetail="type !== 'add'"
  38. @searchChange="supplierNosearchChange"
  39. />
  40. </el-form-item>
  41. </el-col>
  42. <el-col :span="8">
  43. <el-form-item label="品牌" prop="brandid" label-width="60px">
  44. <search-brand
  45. :value="ruleForm.brandid"
  46. :size="'mini'"
  47. :disabled="true"
  48. :isDetail="true"
  49. :names="brand_name"
  50. :placeholder="'品牌'"
  51. @searchChange="brandidsearchChange"
  52. />
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span="5">
  56. <el-form-item label="有效期" prop="expire_day">
  57. <digital-input
  58. :values="ruleForm.expire_day"
  59. :placeholder="'有效期'"
  60. :min="0"
  61. :max="100000000000"
  62. :position="'right'"
  63. :precision="0"
  64. :size="'mini'"
  65. :disabled="type === 'view'"
  66. :controls="false"
  67. :append="'天'"
  68. @reschange="number_change($event, 'expire_day')"
  69. />
  70. </el-form-item>
  71. </el-col>
  72. <el-col :span="5">
  73. <el-form-item label="物流时间" prop="delivery_day">
  74. <digital-input
  75. :values="ruleForm.delivery_day"
  76. :placeholder="'物流时间'"
  77. :min="0"
  78. :max="100000000000"
  79. :position="'right'"
  80. :precision="0"
  81. :size="'mini'"
  82. :disabled="type === 'view'"
  83. :controls="false"
  84. :append="'天'"
  85. @reschange="number_change($event, 'delivery_day')"
  86. />
  87. </el-form-item>
  88. </el-col>
  89. <el-col :span="5">
  90. <el-form-item label="生产工期" prop="work_day">
  91. <digital-input
  92. :values="ruleForm.work_day"
  93. :placeholder="'生产工期'"
  94. :min="0"
  95. :max="100000000000"
  96. :disabled="type === 'view'"
  97. :position="'right'"
  98. :precision="0"
  99. :size="'mini'"
  100. :controls="false"
  101. :append="'天'"
  102. @reschange="number_change($event, 'work_day')"
  103. />
  104. </el-form-item>
  105. </el-col>
  106. <el-col :span="5">
  107. <el-form-item label="税点" prop="tax" label-width="60px">
  108. <search-tax
  109. :value="ruleForm.tax"
  110. :size="'mini'"
  111. :disabled="type === 'view'"
  112. :isDetail="type !== 'add'"
  113. :placeholder="'税点'"
  114. @searchChange="taxsearchChange"
  115. />
  116. </el-form-item>
  117. </el-col>
  118. <el-col :span="4">
  119. <el-form-item label="单位" prop="unit_id" label-width="60px">
  120. <search-unit
  121. :value="ruleForm.unit_id"
  122. :size="'mini'"
  123. :isDetail="true"
  124. :names="unit_name"
  125. disabled
  126. :placeholder="'单位'"
  127. @searchChange="unitsearchChange"
  128. />
  129. </el-form-item>
  130. </el-col>
  131. <el-col :span="24">
  132. <el-row>
  133. <el-col :span="12">
  134. <el-form-item label="分类" prop="cat_id">
  135. <search-sort
  136. :value="ruleForm.cat_id"
  137. :placeholder="'分类'"
  138. :size="'mini'"
  139. :names="cat_id_name"
  140. :disabled="true"
  141. :isDetail="true"
  142. @searchChange="cat_id_change"
  143. />
  144. </el-form-item>
  145. <el-form-item label="商品名称" prop="pname">
  146. <el-input
  147. placeholder="商品名称"
  148. maxlength="100"
  149. :disabled="type === 'view'"
  150. v-model="ruleForm.pname"
  151. ></el-input>
  152. </el-form-item>
  153. <el-form-item label="产地" prop="origin_place">
  154. <select-area
  155. :placeholder="'产地'"
  156. :value="ruleForm.origin_place"
  157. :size="'mini'"
  158. :disabled="type === 'view'"
  159. :is-detail="id !== 'add'"
  160. @selectChange="selectAreaorigin_place"
  161. />
  162. </el-form-item>
  163. </el-col>
  164. <el-col :span="12" style="padding: 0 0 0 15px">
  165. <el-table
  166. :data="spec_tableData"
  167. :size="'mini'"
  168. border
  169. style="width: 100%"
  170. height="120px"
  171. >
  172. <el-table-column prop="spec_name" label="规格类型" />
  173. <el-table-column prop="spec_value_name" label="规格值" />
  174. <el-table-column
  175. fixed="right"
  176. width="88px"
  177. v-if="type !== 'view'"
  178. >
  179. <template slot="header" slot-scope="scope">
  180. <span>操作</span>
  181. <el-tooltip
  182. class="item"
  183. effect="dark"
  184. content="添加规格类型"
  185. placement="top"
  186. >
  187. <i
  188. class="el-icon-circle-plus-outline fr"
  189. style="font-size: 18px; margin-top: 2px"
  190. @click="openEdit('-1', {})"
  191. />
  192. </el-tooltip>
  193. </template>
  194. <template slot-scope="scope">
  195. <el-tooltip effect="dark" content="修改" placement="top">
  196. <i
  197. class="el-icon-edit tb-icon"
  198. @click="openEdit(scope.$index, scope.row)"
  199. ></i>
  200. </el-tooltip>
  201. <el-tooltip effect="dark" content="删除" placement="top">
  202. <i
  203. class="el-icon-delete tb-icon"
  204. @click="openDelete(scope.$index)"
  205. ></i>
  206. </el-tooltip>
  207. </template>
  208. </el-table-column>
  209. </el-table>
  210. <!-- 弹窗 新增/修改 -->
  211. <!-- <base-form-add-edit
  212. :index="modelIndex"
  213. :show-model="showOtherModel"
  214. :sitem="modelSitem"
  215. @refresh="refreshEdit"
  216. @cancel="showOtherModel = false"
  217. /> -->
  218. </el-col>
  219. </el-row>
  220. </el-col>
  221. <el-col :span="6">
  222. <el-form-item label="总重量" prop="weight">
  223. <digital-input
  224. :values="ruleForm.weight"
  225. :placeholder="'总重量'"
  226. :min="0"
  227. :max="100000000000"
  228. :position="'right'"
  229. :precision="3"
  230. :disabled="type === 'view'"
  231. :size="'mini'"
  232. :controls="false"
  233. :append="'g'"
  234. @reschange="number_change($event, 'weight')"
  235. />
  236. </el-form-item>
  237. </el-col>
  238. <el-col :span="6">
  239. <el-form-item label="供货区域" prop="supply_area">
  240. <el-select
  241. v-model="ruleForm.supply_area"
  242. filterable
  243. :disabled="type === 'view'"
  244. clearable
  245. style="width: 100%"
  246. placeholder="供货区域"
  247. >
  248. <el-option
  249. v-for="group in options6"
  250. :key="group.id"
  251. :label="group.name"
  252. :value="group.id"
  253. />
  254. </el-select>
  255. </el-form-item>
  256. </el-col>
  257. <el-col :span="6">
  258. <el-form-item label="付款方式" prop="pay_way" class="clear">
  259. <el-select
  260. v-model="ruleForm.pay_way"
  261. filterable
  262. :disabled="type === 'view'"
  263. clearable
  264. style="width: 100%"
  265. placeholder="付款方式"
  266. >
  267. <el-option
  268. v-for="group in options10"
  269. :key="group.id"
  270. :label="group.name"
  271. :value="group.id"
  272. />
  273. </el-select>
  274. </el-form-item>
  275. </el-col>
  276. <el-col :span="6">
  277. <el-form-item label="发货方式" prop="send_way" class="clear">
  278. <el-select
  279. v-model="ruleForm.send_way"
  280. filterable
  281. clearable
  282. :disabled="type === 'view'"
  283. style="width: 100%"
  284. placeholder="发货方式"
  285. >
  286. <el-option
  287. v-for="group in options11"
  288. :key="group.id"
  289. :label="group.name"
  290. :value="group.id"
  291. />
  292. </el-select>
  293. </el-form-item>
  294. </el-col>
  295. <el-col :span="6">
  296. <el-form-item label="证书费" prop="cert_fee">
  297. <digital-input
  298. :values="ruleForm.cert_fee"
  299. :placeholder="'证书费'"
  300. :min="0"
  301. :disabled="type === 'view'"
  302. :max="100000000000"
  303. :position="'right'"
  304. :precision="2"
  305. :size="'mini'"
  306. :controls="false"
  307. :append="'元'"
  308. @reschange="number_change($event, 'cert_fee')"
  309. />
  310. </el-form-item>
  311. </el-col>
  312. <el-col :span="6">
  313. <el-form-item label="包装费" prop="pakge_fee">
  314. <digital-input
  315. :values="ruleForm.pakge_fee"
  316. :placeholder="'包装费'"
  317. :min="0"
  318. :disabled="type === 'view'"
  319. :max="100000000000"
  320. :position="'right'"
  321. :precision="2"
  322. :size="'mini'"
  323. :controls="false"
  324. :append="'元'"
  325. @reschange="number_change($event, 'pakge_fee')"
  326. />
  327. </el-form-item>
  328. </el-col>
  329. <el-col :span="6">
  330. <el-form-item label="工艺费" prop="cost_fee">
  331. <digital-input
  332. :values="ruleForm.pcost_fee"
  333. :placeholder="'工艺费'"
  334. :min="0"
  335. :disabled="type === 'view'"
  336. :max="100000000000"
  337. :position="'right'"
  338. :precision="2"
  339. :size="'mini'"
  340. :controls="false"
  341. :append="'元'"
  342. @reschange="number_change($event, 'cost_fee')"
  343. />
  344. </el-form-item>
  345. </el-col>
  346. <el-col :span="6">
  347. <el-form-item label="加标费" prop="mark_fee">
  348. <digital-input
  349. :values="ruleForm.mark_fee"
  350. :placeholder="'加标费'"
  351. :min="0"
  352. :disabled="type === 'view'"
  353. :max="100000000000"
  354. :position="'right'"
  355. :precision="2"
  356. :size="'mini'"
  357. :controls="false"
  358. :append="'元'"
  359. @reschange="number_change($event, 'mark_fee')"
  360. />
  361. </el-form-item>
  362. </el-col>
  363. <el-col :span="6">
  364. <el-form-item label="打样费" prop="demo_fee">
  365. <digital-input
  366. :values="ruleForm.demo_fee"
  367. :placeholder="'打样费'"
  368. :min="0"
  369. :disabled="type === 'view'"
  370. :max="100000000000"
  371. :position="'right'"
  372. :precision="2"
  373. :size="'mini'"
  374. :controls="false"
  375. :append="'元'"
  376. @reschange="number_change($event, 'demo_fee')"
  377. />
  378. </el-form-item>
  379. </el-col>
  380. <el-col :span="6">
  381. <el-form-item label="开模费" prop="open_fee">
  382. <digital-input
  383. :values="ruleForm.open_fee"
  384. :placeholder="'开模费'"
  385. :min="0"
  386. :disabled="type === 'view'"
  387. :max="100000000000"
  388. :position="'right'"
  389. :precision="2"
  390. :size="'mini'"
  391. :controls="false"
  392. :append="'元'"
  393. @reschange="number_change($event, 'open_fee')"
  394. />
  395. </el-form-item>
  396. </el-col>
  397. <el-col :span="6">
  398. <el-form-item label="物流费" prop="delivery_fee">
  399. <digital-input
  400. :values="ruleForm.delivery_fee"
  401. :placeholder="'物流费'"
  402. :min="0"
  403. :disabled="type === 'view'"
  404. :max="100000000000"
  405. :position="'right'"
  406. :precision="2"
  407. :size="'mini'"
  408. :controls="false"
  409. :append="'元'"
  410. @reschange="number_change($event, 'delivery_fee')"
  411. />
  412. </el-form-item>
  413. </el-col>
  414. <el-col :span="6">
  415. <el-form-item label="裸价" prop="nake_fee" class="clear">
  416. <digital-input
  417. :values="ruleForm.nake_fee"
  418. :placeholder="'裸价'"
  419. :min="0"
  420. :disabled="type === 'view'"
  421. :max="100000000000"
  422. :position="'right'"
  423. :precision="2"
  424. :size="'mini'"
  425. :controls="false"
  426. :append="'元'"
  427. @reschange="number_change($event, 'nake_fee')"
  428. />
  429. </el-form-item>
  430. </el-col>
  431. <el-col :span="24" v-if="is_noble">
  432. <el-col :span="6">
  433. <el-form-item label="金属重量" prop="noble_weight">
  434. <digital-input
  435. :values="ruleForm.noble_weight"
  436. :placeholder="'金属重量'"
  437. :min="0"
  438. :disabled="type === 'view'"
  439. :max="100000000000"
  440. :position="'right'"
  441. :precision="3"
  442. :size="'mini'"
  443. :controls="false"
  444. :append="'g'"
  445. @reschange="number_change($event, 'noble_weight')"
  446. />
  447. </el-form-item>
  448. </el-col>
  449. <el-col :span="6">
  450. <el-form-item label="金属种类" prop="metal_id">
  451. <search-metal-kind
  452. :value="ruleForm.metal_id"
  453. :size="'mini'"
  454. :disabled="type === 'view'"
  455. :isDetail="type !== 'add'"
  456. :placeholder="'金属种类'"
  457. @searchChange="metal_idsearchChange"
  458. />
  459. </el-form-item>
  460. </el-col>
  461. <el-col :span="6">
  462. <el-form-item label="启用金价" prop="is_gold_price">
  463. <el-select
  464. v-model="ruleForm.is_gold_price"
  465. filterable
  466. clearable
  467. :disabled="type === 'view'"
  468. style="width: 100%"
  469. placeholder="启用金价"
  470. >
  471. <el-option
  472. v-for="group in options5"
  473. :key="group.id"
  474. :label="group.name"
  475. :value="group.id"
  476. />
  477. </el-select>
  478. </el-form-item>
  479. </el-col>
  480. <el-col :span="6">
  481. <el-form-item label="有无工差" prop="is_diff">
  482. <el-select
  483. v-model="ruleForm.is_diff"
  484. filterable
  485. clearable
  486. :disabled="type === 'view'"
  487. style="width: 100%"
  488. placeholder="有无工差"
  489. >
  490. <el-option
  491. v-for="group in options8"
  492. :key="group.id"
  493. :label="group.name"
  494. :value="group.id"
  495. />
  496. </el-select>
  497. </el-form-item>
  498. </el-col>
  499. <el-col :span="12">
  500. <el-form-item label="配置要求" prop="config">
  501. <el-select
  502. v-model="ruleForm.config"
  503. multiple
  504. :disabled="type === 'view'"
  505. style="width: 100%"
  506. placeholder="配置要求"
  507. >
  508. <el-option
  509. v-for="(item, index) in options9"
  510. :key="item + index"
  511. :label="item"
  512. :value="item"
  513. >
  514. </el-option>
  515. </el-select>
  516. </el-form-item>
  517. </el-col>
  518. <el-col :span="12">
  519. <el-form-item
  520. label="其他配置要求"
  521. prop="other_config"
  522. label-width="120px"
  523. >
  524. <el-input
  525. placeholder="其他要求"
  526. maxlength="100"
  527. :disabled="type === 'view'"
  528. v-model="ruleForm.other_config"
  529. >
  530. </el-input>
  531. </el-form-item>
  532. </el-col>
  533. </el-col>
  534. <el-col :span="18">
  535. <el-form-item label="采购备注" prop="remark">
  536. <el-input
  537. placeholder="采购备注"
  538. maxlength="500"
  539. :disabled="type === 'view'"
  540. v-model="ruleForm.remark"
  541. >
  542. </el-input>
  543. </el-form-item>
  544. <el-form-item label="工艺说明" prop="cost_desc">
  545. <el-input
  546. placeholder="工艺说明"
  547. maxlength="500"
  548. :disabled="type === 'view'"
  549. v-model="ruleForm.cost_desc"
  550. >
  551. </el-input>
  552. </el-form-item>
  553. </el-col>
  554. <el-col :span="6">
  555. <el-form-item
  556. label="商品图片(<1mb)"
  557. prop="good_img"
  558. class="activity-upload"
  559. >
  560. <div class="btnupload" style="position: relative">
  561. <img
  562. v-if="ruleForm.good_img"
  563. :src="ruleForm.good_img"
  564. class="avatar"
  565. />
  566. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  567. <file-upload
  568. class="Upload"
  569. :accept="'.jpg,.png,.jpeg'"
  570. :multiple="true"
  571. :disabled="type === 'view'"
  572. :uploadcondition="beforeAvatarUpload"
  573. @UploadErrorEvent="UploadErrorEventgood_img"
  574. @UploadSuccessEvent="UploadSuccessEventgood_img"
  575. ></file-upload>
  576. </div>
  577. </el-form-item>
  578. </el-col>
  579. </el-row>
  580. </el-form>
  581. </template>
  582. <script>
  583. import asyncRequest from "@/apis/service/purchaseIn/workbench";
  584. import resToken from "@/mixins/resToken";
  585. import { mapGetters } from "vuex";
  586. import baseFormAddEdit from "./baseFormAddEdit";
  587. import {
  588. options1,
  589. options2,
  590. options3,
  591. options4,
  592. options5,
  593. options6,
  594. options7,
  595. options8,
  596. options9,
  597. options10,
  598. options11,
  599. rules,
  600. } from "../columns";
  601. export default {
  602. name: "goodsCostAdd",
  603. mixins: [resToken],
  604. props: ["showModel", "id", "type", "sitem", "askItem", "newTime", "editId"],
  605. components: {
  606. baseFormAddEdit,
  607. },
  608. computed: {
  609. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  610. powers() {
  611. let tran =
  612. this.$store.getters.btnList.find(
  613. (item) => item.menu_route == "goodsCostAdd"
  614. ) || {};
  615. if (tran && tran.action && tran.action.length > 0) {
  616. return tran.action;
  617. } else {
  618. return [];
  619. }
  620. },
  621. },
  622. watch: {
  623. newTime: function (val) {
  624. if (val) {
  625. this.initForm();
  626. }
  627. },
  628. },
  629. data() {
  630. return {
  631. cat_id_name: "",
  632. brand_name: "",
  633. unit_name: "",
  634. title: "",
  635. modelIndex: "",
  636. modelSitem: {},
  637. showOtherModel: false,
  638. is_noble: false,
  639. status: "",
  640. rulesThis: this.rules,
  641. activeName: "1",
  642. loading: true,
  643. options1: options1,
  644. options2: options2,
  645. options3: options3,
  646. options4: options4,
  647. options5: options5,
  648. options6: options6,
  649. options7: options7,
  650. options8: options8,
  651. options9: options9,
  652. options10: options10,
  653. options11: options11,
  654. ruleForm: {},
  655. rules: rules,
  656. };
  657. },
  658. mounted() {
  659. this.initForm();
  660. },
  661. methods: {
  662. async initForm() {
  663. console.log(this.id);
  664. this.loading = true;
  665. if (this.type === "add") {
  666. this.title = "新建采返商品";
  667. } else if (this.type === "edit") {
  668. this.title = "编辑采返商品";
  669. } else {
  670. this.title = "采返商品详情";
  671. }
  672. this.resetFormData();
  673. this.rulesThis = this.rules;
  674. await this.resetForm();
  675. if (this.type === "edit" || this.type === "view") {
  676. await this.initData();
  677. }
  678. this.loading = false;
  679. },
  680. number_change(e, key) {
  681. this.ruleForm[key] = e + "" || "0";
  682. this.$refs.ruleForm.validateField(key);
  683. },
  684. async initData() {
  685. this.loading = true;
  686. const { code, message, data } = await asyncRequest.good_detail({
  687. bidNo: this.editId,
  688. });
  689. console.log(data);
  690. if (code === 0) {
  691. const {
  692. bidNo,
  693. good_name, //string 名称
  694. cat_id, //array 分类
  695. cat_name,
  696. brand_id, //string 品牌id
  697. unit, // string 单位
  698. unit_id, //单位ID
  699. tax, //string 税率
  700. supplierNo, // string 供应商
  701. cost_desc, // string 工艺说明
  702. remark, // string 采购备注
  703. weight, // string 重量
  704. supply_area, // string 供货区域 1 全国2 除偏远地区
  705. origin_place, // string 产地
  706. delivery_day, // string 物流天数
  707. expire_day, // string 信息有效期
  708. good_img, //
  709. // good_name,
  710. cert_fee, // string 证书费
  711. pakge_fee, // string 打包费
  712. cost_fee, // string 工艺费
  713. mark_fee, // string 加标费
  714. demo_fee, // string 打样费
  715. open_fee, // string 开模费
  716. metal_id, // string 金属类别
  717. noble_weight, // string 金属重量
  718. is_gold_price, // string 是否使用实时金价
  719. delivery_fee, // string 物流费
  720. status, // string 状态
  721. brand_name,
  722. color, //颜色
  723. model, //型号
  724. material, //材质
  725. work_day,
  726. pay_way,
  727. send_way,
  728. is_diff,
  729. config,
  730. nake_fee,
  731. other_config,
  732. } = JSON.parse(JSON.stringify(data));
  733. this.is_noble = this.askItem.is_metal;
  734. this.cat_id_name =
  735. this.type === "add" ? this.askItem.cat_name : cat_name || "";
  736. console.log(this.cat_id_name);
  737. console.log(this.askItem);
  738. this.brand_name =
  739. this.type === "add" ? this.askItem.brand : brand_name || "";
  740. this.unit_name =
  741. this.type === "add" ? this.askItem.unit_name : unit || "";
  742. this.ruleForm = {
  743. infoNo: this.id || "",
  744. bidNo: bidNo || "",
  745. infoNo: this.id || "",
  746. cat_id: this.type === "add" ? [this.askItem.cat_id] : [cat_id] || [],
  747. supplierNo: supplierNo ? [supplierNo] : [],
  748. pname: this.type === "add" ? this.askItem.good_name : good_name || "",
  749. expire_day: expire_day || "0", //有效期
  750. delivery_day: delivery_day || "0", //物流时间
  751. work_day: work_day || "0", //生产工期
  752. color: this.type === "add" ? this.askItem.color : color || "",
  753. model: this.type === "add" ? this.askItem.model : model || "",
  754. material:
  755. this.type === "add" ? this.askItem.material : material || "",
  756. brandid:
  757. this.type === "add" && this.askItem.brand_id
  758. ? [this.askItem.brand_id]
  759. : brand_id
  760. ? [brand_id]
  761. : [],
  762. unit_id:
  763. this.type === "add"
  764. ? [this.askItem.unit]
  765. : unit_id
  766. ? [unit_id]
  767. : [],
  768. weight:
  769. this.type === "add" ? this.askItem.total_weight : weight || "0.000",
  770. tax: tax ? tax + "%" : "",
  771. supply_area: supply_area || "",
  772. origin_place: origin_place ? origin_place.split(",") : [],
  773. cert_fee: cert_fee || "0.00",
  774. pakge_fee: pakge_fee || "0.00",
  775. cost_fee: cost_fee || "0.00",
  776. mark_fee: mark_fee || "0.00",
  777. demo_fee: demo_fee || "0.00",
  778. open_fee: open_fee || "0.00",
  779. delivery_fee: delivery_fee || "0.00",
  780. nake_fee: nake_fee || "0.00",
  781. pay_way: pay_way || "",
  782. send_way: send_way || "",
  783. noble_weight:
  784. this.type === "add"
  785. ? this.askItem.specs_weight
  786. : noble_weight || "0.000",
  787. metal_id:
  788. this.type === "add" ? this.askItem.metal_id : metal_id || "",
  789. is_gold_price:
  790. this.type === "add"
  791. ? this.askItem.is_gold_price
  792. : is_gold_price || "",
  793. is_diff: is_diff || "",
  794. config: config ? [config] : [],
  795. other_config: other_config || "",
  796. remark: remark || "",
  797. cost_desc: cost_desc || "",
  798. good_img:
  799. this.type === "add" ? this.askItem.good_img : good_img || "",
  800. };
  801. console.log(this.ruleForm);
  802. this.status = status;
  803. } else if (code >= 100 && code <= 104) {
  804. await this.logout();
  805. } else {
  806. this.$message.warning(message);
  807. }
  808. },
  809. async submitForm() {
  810. await this.$refs.ruleForm.validate(async (valid) => {
  811. if (valid) {
  812. this.loading = true;
  813. let model = JSON.parse(JSON.stringify(this.ruleForm));
  814. model.cat_id = model.cat_id[model.cat_id.length - 1];
  815. model.brandid = model.brandid.toString();
  816. model.supplierNo = model.supplierNo.toString();
  817. model.origin_place = model.origin_place.toString();
  818. model.unit_id = model.unit_id.toString();
  819. model.config = model.config.toString();
  820. model.tax = parseInt(model.tax + "") + "";
  821. console.log(model);
  822. let res = {};
  823. if (this.type === "add") {
  824. delete model["bidNo"];
  825. res = await asyncRequest.good_add(model);
  826. } else {
  827. res = await asyncRequest.good_update(model);
  828. }
  829. console.log(res);
  830. this.loading = false;
  831. if (res && res.code === 0) {
  832. const title = this.type === "add" ? "新建成功!" : "修改成功!";
  833. this.$notify.success({
  834. title: title,
  835. message: "",
  836. });
  837. this.showModelThis = false;
  838. // 刷新
  839. this.$emit("refresh");
  840. }
  841. } else {
  842. console.log("error submit!!");
  843. return false;
  844. }
  845. });
  846. },
  847. async resetForm() {
  848. // 重置
  849. await this.$nextTick(async () => {
  850. if (this.$refs.ruleForm) {
  851. this.$refs.ruleForm.resetFields();
  852. this.$refs.ruleForm.clearValidate();
  853. console.log(this.askItem);
  854. // const { can_id_arr } = this.askItem;
  855. this.is_noble = this.askItem.is_metal;
  856. this.cat_id_name = this.type === "add" ? this.askItem.cat_name : "";
  857. // console.log(this.cat_id_name);
  858. // console.log(this.askItem);
  859. this.brand_name = this.type === "add" ? this.askItem.brand : "";
  860. this.unit_name = this.type === "add" ? this.askItem.unit_name : "";
  861. this.ruleForm = {
  862. infoNo: this.id || "",
  863. cat_id: this.type === "add" ? [this.askItem.cat_id] : [],
  864. supplierNo: [],
  865. pname: this.type === "add" ? this.askItem.good_name : "",
  866. expire_day: "0", //有效期
  867. delivery_day: "0", //物流时间
  868. work_day: "0", //生产工期
  869. color: this.type === "add" ? this.askItem.color : "",
  870. model: this.type === "add" ? this.askItem.model : "",
  871. material: this.type === "add" ? this.askItem.material : "",
  872. brandid:
  873. this.type === "add" && this.askItem.brand_id
  874. ? [this.askItem.brand_id]
  875. : [],
  876. unit_id: this.type === "add" ? [this.askItem.unit] : [],
  877. weight: this.type === "add" ? this.askItem.total_weight : "0.000",
  878. tax: "",
  879. supply_area: "",
  880. origin_place: [],
  881. cert_fee: "0.00",
  882. pakge_fee: "0.00",
  883. cost_fee: "0.00",
  884. mark_fee: "0.00",
  885. demo_fee: "0.00",
  886. open_fee: "0.00",
  887. delivery_fee: "0.00",
  888. nake_fee: "0.00",
  889. pay_way: "",
  890. send_way: "",
  891. noble_weight:
  892. this.type === "add" ? this.askItem.specs_weight : "0.000",
  893. metal_id: this.type === "add" ? this.askItem.metal_id : "",
  894. is_gold_price:
  895. this.type === "add" ? this.askItem.is_gold_price : "",
  896. is_diff: "",
  897. config: [],
  898. other_config: "",
  899. remark: "",
  900. cost_desc: "",
  901. good_img: this.type === "add" ? this.askItem.good_img : "",
  902. };
  903. }
  904. });
  905. },
  906. openEdit(index, sitem) {
  907. this.modelIndex = index;
  908. this.modelSitem = sitem;
  909. this.showOtherModel = true;
  910. },
  911. openDelete(index) {
  912. this.spec_tableData.splice(index, 1);
  913. },
  914. //规格编辑修改结果
  915. refreshEdit(e) {
  916. let item = JSON.parse(JSON.stringify(e));
  917. const { index, specid, spec_name, spec_value_id, spec_value_name } = item;
  918. if (index + "" === "-1") {
  919. this.spec_tableData.push(item);
  920. } else {
  921. let findex = parseInt(index + "");
  922. this.spec_tableData[findex].specid = specid;
  923. this.spec_tableData[findex].spec_name = spec_name;
  924. this.spec_tableData[findex].spec_value_id = spec_value_id;
  925. this.spec_tableData[findex].spec_value_name = spec_value_name;
  926. }
  927. this.showOtherModel = false;
  928. },
  929. //分类选择
  930. async cat_id_change(e) {
  931. const { pid, id, label } = e;
  932. if (id) {
  933. this.ruleForm.cat_id = [id];
  934. this.is_noble = pid === "6";
  935. } else {
  936. this.ruleForm.cat_id = [];
  937. this.is_noble = false;
  938. }
  939. this.$refs.ruleForm.validateField("cat_id");
  940. },
  941. //品牌选择
  942. brandidsearchChange(e) {
  943. const { id, code, label } = e;
  944. if (id) {
  945. this.ruleForm.brandid = [id];
  946. } else {
  947. this.ruleForm.brandid = [];
  948. }
  949. this.$refs.ruleForm.validateField("brandid");
  950. },
  951. //供应商选择
  952. supplierNosearchChange(e) {
  953. console.log(e);
  954. const { id, code, label } = e;
  955. if (id) {
  956. this.ruleForm.supplierNo = [code];
  957. } else {
  958. this.ruleForm.supplierNo = [];
  959. }
  960. this.$refs.ruleForm.validateField("supplierNo");
  961. },
  962. //税点选择
  963. taxsearchChange(e) {
  964. this.ruleForm.tax = e;
  965. this.$refs.ruleForm.validateField("tax");
  966. },
  967. //单位选择
  968. unitsearchChange(e) {
  969. const { id, code, label } = e;
  970. if (id) {
  971. this.ruleForm.unit_id = [code];
  972. } else {
  973. this.ruleForm.unit_id = [];
  974. }
  975. this.$refs.ruleForm.validateField("unit_id");
  976. },
  977. //金属种类选择
  978. metal_idsearchChange(e) {
  979. console.log(e);
  980. const { id, code, label } = e;
  981. if (id) {
  982. this.ruleForm.metal_id = id;
  983. } else {
  984. this.ruleForm.metal_id = "";
  985. }
  986. this.$refs.ruleForm.validateField("metal_id");
  987. },
  988. //仓库省市区
  989. selectAreaorigin_place(e) {
  990. this.ruleForm.origin_place = e;
  991. this.$refs.ruleForm.validateField("origin_place");
  992. },
  993. //图片上传成功
  994. async UploadSuccessEventgood_img(data) {
  995. await this.UploadSuccessEvent(1, data);
  996. },
  997. //图片上传成功
  998. async UploadSuccessEvent(type, data) {
  999. const { url } = data;
  1000. if (url === "noToken") {
  1001. await this.logout();
  1002. } else {
  1003. if (type === 1) {
  1004. this.ruleForm.good_img = url;
  1005. this.$refs.ruleForm.validateField("good_img");
  1006. } else if (type === 2) {
  1007. this.ruleForm.good_img = url;
  1008. this.$refs.ruleForm.validateField("good_img");
  1009. }
  1010. this.$message.success("图片上传成功!");
  1011. }
  1012. },
  1013. //图片上传失败
  1014. UploadErrorEventgood_img(res) {
  1015. this.imgUploadError(1, res);
  1016. },
  1017. imgUploadError(type, res) {
  1018. if (res !== "break") {
  1019. this.$message.error("图片上传失败!");
  1020. this.$refs.ruleForm.validateField(
  1021. type === 1 ? "good_img" : type === 2 ? "good_img" : ""
  1022. );
  1023. }
  1024. },
  1025. //判断图片规格
  1026. beforeAvatarUpload(file) {
  1027. let isJPG = false;
  1028. if (
  1029. file.type === "image/jpg" ||
  1030. file.type === "image/png" ||
  1031. file.type === "image/jpeg"
  1032. ) {
  1033. isJPG = true;
  1034. }
  1035. const isLt2M = file.size / 1024 / 1024 < 1;
  1036. if (!isJPG) {
  1037. this.$message.error("图片格式不正确!");
  1038. }
  1039. if (!isLt2M) {
  1040. this.$message.error("图片大小不能超过 1MB!");
  1041. }
  1042. return isJPG && isLt2M;
  1043. },
  1044. resetFormData() {
  1045. this.status = "";
  1046. this.is_noble = false;
  1047. this.cat_id_name = "";
  1048. this.brand_name = "";
  1049. this.unit_name = "";
  1050. this.ruleForm = {
  1051. infoNo: "",
  1052. cat_id: [],
  1053. supplierNo: [],
  1054. pname: "",
  1055. expire_day: "0", //有效期
  1056. delivery_day: "0", //物流时间
  1057. work_day: "0", //生产工期
  1058. color: "",
  1059. model: "",
  1060. material: "",
  1061. brandid: [],
  1062. unit_id: [],
  1063. weight: "0.000",
  1064. tax: "",
  1065. supply_area: "",
  1066. origin_place: [],
  1067. cert_fee: "0.00",
  1068. pakge_fee: "0.00",
  1069. cost_fee: "0.00",
  1070. mark_fee: "0.00",
  1071. demo_fee: "0.00",
  1072. open_fee: "0.00",
  1073. delivery_fee: "0.00",
  1074. nake_fee: "0.00",
  1075. pay_way: "",
  1076. send_way: "",
  1077. noble_weight: "0.000",
  1078. metal_id: "",
  1079. is_gold_price: "",
  1080. is_diff: "",
  1081. config: [],
  1082. other_config: "",
  1083. remark: "",
  1084. cost_desc: "",
  1085. good_img: "",
  1086. };
  1087. },
  1088. },
  1089. };
  1090. </script>
  1091. <style lang="scss" scoped>
  1092. .goodsCostDetail {
  1093. .goodsCostAdd-title {
  1094. border-top: 1px solid #ebeef5;
  1095. span {
  1096. height: 50px;
  1097. line-height: 50px;
  1098. font-family: "微软雅黑", sans-serif;
  1099. font-weight: 400;
  1100. font-style: normal;
  1101. font-size: 16px;
  1102. text-align: left;
  1103. }
  1104. }
  1105. }
  1106. </style>