detail.vue 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055
  1. <template>
  2. <div class="ele-body">
  3. <el-tabs v-model="activeTab" type="card" class="product-detail-tabs">
  4. <el-tab-pane label="详情" name="detail">
  5. <el-card shadow="never">
  6. <el-form
  7. label-width="100px"
  8. ref="manageForm"
  9. :model="form"
  10. :rules="rules"
  11. >
  12. <headerTitle title="基本信息">
  13. <el-button @click="cancel">返回</el-button>
  14. <el-button
  15. v-if="!isReadOnly"
  16. type="primary"
  17. @click="submit"
  18. :loading="loading"
  19. >保存
  20. </el-button>
  21. </headerTitle>
  22. <el-row :gutter="24">
  23. <el-col :span="8">
  24. <el-form-item label="分类" prop="categoryLevelName">
  25. <el-input
  26. v-model="form.categoryLevelName"
  27. @click.native="openCategory"
  28. :disabled="isReadOnly"
  29. />
  30. </el-form-item>
  31. </el-col>
  32. <el-col :span="8">
  33. <el-form-item label="编码" prop="code">
  34. <!-- <el-input
  35. v-if="ruleCode == '自定义'"
  36. v-model="form.code"
  37. readonly
  38. @click.native="openCode"
  39. :disabled="status == 0"
  40. /> -->
  41. <el-input
  42. v-model="form.code"
  43. :disabled="status == 0 || isReadOnly"
  44. >
  45. <template slot="append" v-if="status != 0 && !isReadOnly">
  46. <el-link :underline="false" @click.native="getCodeOpen"
  47. >申请编码
  48. </el-link></template
  49. >
  50. </el-input>
  51. </el-form-item>
  52. </el-col>
  53. <el-col :span="8">
  54. <el-form-item label="名称" prop="name">
  55. <el-input v-model="form.name" :disabled="isReadOnly" />
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="8">
  59. <el-form-item label="存货类型:" prop="attributeType">
  60. <!-- <DictSelection
  61. dictName="存货类型"
  62. clearable
  63. v-model="form.attributeType"
  64. >
  65. </DictSelection> -->
  66. <el-select
  67. v-model="form.attributeType"
  68. filterable
  69. class="ele-block"
  70. :disabled="isReadOnly"
  71. >
  72. <el-option
  73. v-for="item in attributeList"
  74. :key="item.value"
  75. :value="item.value"
  76. :label="item.label"
  77. ></el-option>
  78. </el-select>
  79. </el-form-item>
  80. </el-col>
  81. <el-col :span="8">
  82. <div>
  83. <el-form-item label="属性类型" prop="componentAttribute">
  84. <el-select
  85. style="width: 100%"
  86. v-model="form.componentAttribute"
  87. filterable
  88. multiple
  89. :disabled="isReadOnly"
  90. >
  91. <el-option
  92. v-for="item in lbjtList"
  93. :key="item.value"
  94. :value="item.value"
  95. :label="item.label"
  96. ></el-option>
  97. </el-select>
  98. </el-form-item>
  99. </div>
  100. </el-col>
  101. <el-col :span="8">
  102. <div>
  103. <el-form-item
  104. label="生产类型"
  105. prop="produceType"
  106. :rules="{
  107. required:
  108. form.categoryLevelPathId.substring(0, 1) == 9 ||
  109. form.componentAttribute.includes(1) == 1
  110. ? true
  111. : false,
  112. message: '请选择生产类型',
  113. trigger: 'change'
  114. }"
  115. >
  116. <el-select
  117. style="width: 100%"
  118. v-model="form.produceType"
  119. filterable
  120. @change="produceTypeChange"
  121. :disabled="isReadOnly"
  122. >
  123. <el-option
  124. v-for="item in produceTypeList"
  125. :key="item.value"
  126. :value="item.value"
  127. :label="item.label"
  128. ></el-option>
  129. </el-select>
  130. </el-form-item>
  131. </div>
  132. </el-col>
  133. <el-col :span="8">
  134. <!-- v-if="
  135. [1, 23, 9, 28].includes(
  136. Number(categoryLevelPathId || $route.query.rootTreeId)
  137. )
  138. " -->
  139. <el-form-item
  140. label="加工类型"
  141. prop="isConsumable"
  142. :rules="{
  143. required: mandatoryFieldList.includes('isConsumable'),
  144. message: '请选择加工类型',
  145. trigger: 'change'
  146. }"
  147. >
  148. <el-select
  149. v-model="form.isConsumable"
  150. style="width: 100%"
  151. @change="changeConsumable"
  152. :disabled="isReadOnly"
  153. >
  154. <el-option :value="1" label="批量"></el-option>
  155. <el-option :value="0" label="单件"></el-option>
  156. </el-select>
  157. </el-form-item>
  158. </el-col>
  159. <el-col :span="8">
  160. <el-form-item
  161. label="牌号"
  162. prop="brandNum"
  163. :rules="{
  164. required: mandatoryFieldList.includes('brandNum'),
  165. message: '请输入牌号',
  166. trigger: 'change'
  167. }"
  168. >
  169. <el-input v-model="form.brandNum" :disabled="isReadOnly" />
  170. </el-form-item>
  171. </el-col>
  172. <el-col :span="8">
  173. <el-form-item
  174. label="型号"
  175. prop="modelType"
  176. :rules="{
  177. required: mandatoryFieldList.includes('modelType'),
  178. message: '请输入型号',
  179. trigger: 'change'
  180. }"
  181. >
  182. <el-input v-model="form.modelType" :disabled="isReadOnly" />
  183. </el-form-item>
  184. </el-col>
  185. <el-col :span="8">
  186. <el-form-item
  187. label="规格"
  188. prop="specification"
  189. :rules="{
  190. required: mandatoryFieldList.includes('specification'),
  191. message: '请输入规格',
  192. trigger: 'change'
  193. }"
  194. >
  195. <el-input
  196. v-model="form.specification"
  197. @input="inputSpe"
  198. :disabled="isReadOnly"
  199. />
  200. </el-form-item>
  201. </el-col>
  202. <el-col :span="8">
  203. <el-form-item
  204. label="计量类型"
  205. prop="measureType"
  206. :rules="{
  207. required: mandatoryFieldList.includes('measureType'),
  208. message: '请选择计量类型',
  209. trigger: 'change'
  210. }"
  211. >
  212. <el-select
  213. v-model="form.measureType"
  214. style="width: 100%"
  215. @change="changeMeasureType"
  216. :disabled="isReadOnly"
  217. >
  218. <el-option
  219. v-for="item in measureTypeList"
  220. :key="item.value"
  221. :value="item.value"
  222. :label="item.label"
  223. ></el-option>
  224. </el-select>
  225. </el-form-item>
  226. </el-col>
  227. <el-col :span="8">
  228. <el-form-item label="计量单位" prop="measuringUnit">
  229. <DictSelection
  230. dictName="计量单位"
  231. clearable
  232. v-model="form.measuringUnit"
  233. @change="changeUnit"
  234. :disabled="isReadOnly"
  235. >
  236. </DictSelection>
  237. </el-form-item>
  238. </el-col>
  239. <el-col :span="8">
  240. <el-form-item label="重量单位" prop="weightUnit">
  241. <DictSelection
  242. dictName="重量单位"
  243. clearable
  244. v-model="form.weightUnit"
  245. @change="changeWeightUnit"
  246. :disabled="isReadOnly"
  247. >
  248. </DictSelection>
  249. </el-form-item>
  250. </el-col>
  251. <el-col :span="8">
  252. <el-form-item label="包装单位" prop="packingUnit">
  253. <DictSelection
  254. dictName="包装单位"
  255. clearable
  256. v-model="form.packingUnit"
  257. @change="changeUnit"
  258. :disabled="isReadOnly"
  259. >
  260. </DictSelection>
  261. </el-form-item>
  262. </el-col>
  263. <el-col :span="8">
  264. <el-form-item label="面积" prop="area">
  265. <el-input
  266. v-model="form.area"
  267. @input="handleAreaInput"
  268. :disabled="isReadOnly"
  269. />
  270. </el-form-item>
  271. </el-col>
  272. <el-col :span="8">
  273. <el-form-item label="面积单位" prop="areaUnit">
  274. <DictSelection
  275. dictName="计量单位"
  276. clearable
  277. v-model="form.areaUnit"
  278. :disabled="isReadOnly"
  279. >
  280. </DictSelection>
  281. </el-form-item>
  282. </el-col>
  283. <el-col :span="8">
  284. <el-form-item
  285. label="图号/件号"
  286. prop="imgCode"
  287. :rules="{
  288. required: mandatoryFieldList.includes('imgCode'),
  289. message: '请输入图号/件号',
  290. trigger: 'change'
  291. }"
  292. >
  293. <el-input v-model="form.imgCode" :disabled="isReadOnly" />
  294. </el-form-item>
  295. </el-col>
  296. <el-col :span="8">
  297. <el-form-item
  298. label="毛重"
  299. prop="roughWeight"
  300. :rules="{
  301. required: mandatoryFieldList.includes('roughWeight'),
  302. message: '请输入毛重',
  303. trigger: 'change'
  304. }"
  305. >
  306. <div class="form-line">
  307. <el-input
  308. v-model="form.roughWeight"
  309. @input="handleInput2"
  310. :disabled="isReadOnly"
  311. />
  312. </div>
  313. </el-form-item>
  314. </el-col>
  315. <el-col :span="8">
  316. <!-- 计量类型为重量 净重必填 -->
  317. <el-form-item
  318. label="净重"
  319. prop="netWeight"
  320. :rules="{
  321. required: form.measureType == 2,
  322. trigger: ['blur', 'change'],
  323. message: '请输入净重'
  324. }"
  325. >
  326. <div class="form-line">
  327. <el-input
  328. v-model="form.netWeight"
  329. @input="handleInput3"
  330. :disabled="isReadOnly"
  331. />
  332. </div>
  333. </el-form-item>
  334. </el-col>
  335. <el-col :span="8">
  336. <el-form-item
  337. label="体积"
  338. prop="volume"
  339. :rules="{
  340. required: mandatoryFieldList.includes('volume'),
  341. message: '请输入体积',
  342. trigger: 'change'
  343. }"
  344. >
  345. <div class="form-line">
  346. <el-input
  347. v-model="form.volume"
  348. @input="handleInput"
  349. style="width: calc(100% - 100px)"
  350. :disabled="isReadOnly"
  351. />
  352. <DictSelection
  353. dictName="体积单位"
  354. clearable
  355. v-model="form.volumeUnit"
  356. style="width: 100px"
  357. :disabled="isReadOnly"
  358. >
  359. </DictSelection>
  360. </div>
  361. </el-form-item>
  362. </el-col>
  363. <el-col :span="8">
  364. <el-form-item
  365. label="级别"
  366. prop="level"
  367. :rules="{
  368. required: mandatoryFieldList.includes('level'),
  369. message: '请选择级别',
  370. trigger: 'change'
  371. }"
  372. >
  373. <template>
  374. <el-select
  375. style="width: 100%"
  376. v-model="form.level"
  377. placeholder="请选择"
  378. @change="levelChange"
  379. :disabled="isReadOnly"
  380. >
  381. <el-option
  382. v-for="item in levelOptions"
  383. :label="item.label"
  384. :value="item.value"
  385. :key="item.value"
  386. >
  387. </el-option>
  388. </el-select>
  389. </template>
  390. </el-form-item>
  391. </el-col>
  392. <el-col :span="8">
  393. <el-form-item
  394. label="机型"
  395. prop="modelKey"
  396. :rules="{
  397. required: mandatoryFieldList.includes('modelKey'),
  398. message: '请选择机型',
  399. trigger: 'change'
  400. }"
  401. >
  402. <DictSelection
  403. dictName="物品机型"
  404. clearable
  405. v-model="form.modelKey"
  406. multiple
  407. filterable
  408. allow-create
  409. default-first-option
  410. :disabled="isReadOnly"
  411. >
  412. </DictSelection>
  413. </el-form-item>
  414. </el-col>
  415. <el-col :span="8">
  416. <el-form-item
  417. label="颜色"
  418. prop="colorKey"
  419. :rules="{
  420. required: mandatoryFieldList.includes('colorKey'),
  421. message: '请选择颜色',
  422. trigger: 'change'
  423. }"
  424. >
  425. <DictSelection
  426. dictName="物品颜色"
  427. clearable
  428. v-model="form.colorKey"
  429. multiple
  430. filterable
  431. allow-create
  432. default-first-option
  433. :disabled="isReadOnly"
  434. >
  435. </DictSelection>
  436. </el-form-item>
  437. </el-col>
  438. <el-col :span="8">
  439. <el-form-item label="状态">
  440. <template>
  441. <el-switch
  442. v-model="form.isEnabled"
  443. :active-text="form.isEnabled == 1 ? '启用' : '停用'"
  444. :active-value="1"
  445. :inactive-value="0"
  446. :disabled="isReadOnly"
  447. >
  448. </el-switch>
  449. </template>
  450. </el-form-item>
  451. </el-col>
  452. <!-- :rules="{
  453. required:
  454. form.categoryLevelPathId.substring(0, 1) == 9 ||
  455. form.componentAttribute.includes(1) == 1
  456. ? true
  457. : false,
  458. message: '请选择生产类型',
  459. trigger: 'change'
  460. }" -->
  461. <el-col :span="8" v-for="(f, idx) in fileList" :key="idx">
  462. <el-form-item
  463. :label="f.label"
  464. :prop="'extField.' + f.prop"
  465. :rules="{
  466. required: mandatoryFieldList.includes(f.prop),
  467. message: '请输入',
  468. trigger: 'change'
  469. }"
  470. >
  471. <template>
  472. <div class="form-line">
  473. <component
  474. :is="f.tagType"
  475. v-model="form.extField[f.prop]"
  476. :disabled="f.extAttribute?.disabled || isReadOnly"
  477. clearable
  478. :isProhibit="
  479. f.modelType == 'dict'
  480. ? f.extAttribute?.disabled || isReadOnly
  481. : false
  482. "
  483. :dictName="f.modelType == 'dict' ? f.label : ''"
  484. ></component>
  485. </div>
  486. </template>
  487. </el-form-item>
  488. </el-col>
  489. <template v-if="industryAttribute == 1">
  490. <el-col :span="8">
  491. <el-form-item label="性味与归经">
  492. <el-input
  493. v-model="form.propertiesChannelTropism"
  494. :disabled="isReadOnly"
  495. />
  496. </el-form-item>
  497. </el-col>
  498. <el-col :span="8">
  499. <el-form-item label="功能与主治">
  500. <el-input
  501. v-model="form.actionsAndUses"
  502. :disabled="isReadOnly"
  503. />
  504. </el-form-item>
  505. </el-col>
  506. <el-col :span="8">
  507. <el-form-item label="用法与用量">
  508. <el-input
  509. v-model="form.usageAndDosage"
  510. :disabled="isReadOnly"
  511. />
  512. </el-form-item>
  513. </el-col>
  514. </template>
  515. <el-col :span="8" v-if="clientEnvironmentId == 5">
  516. <el-form-item label="需要序列号">
  517. <el-radio-group
  518. v-model="form.extTagField.needProductSequence"
  519. :disabled="isReadOnly"
  520. >
  521. <el-radio :label="1">是</el-radio>
  522. <el-radio :label="0">否</el-radio>
  523. </el-radio-group>
  524. </el-form-item>
  525. </el-col>
  526. <el-col :span="8">
  527. <el-form-item label="物联产品Key">
  528. <el-input v-model="form.iotProductKey" :disabled="isReadOnly" />
  529. </el-form-item>
  530. </el-col>
  531. <el-col :span="24">
  532. <el-form-item label="产品图片">
  533. <ImgUpload
  534. ref="imgUploadRef"
  535. v-model="form.imgUrl"
  536. :disabled="isReadOnly"
  537. />
  538. </el-form-item>
  539. </el-col>
  540. </el-row>
  541. </el-form>
  542. </el-card>
  543. <el-card shadow="never">
  544. <headerTitle title="标签"></headerTitle>
  545. <!-- {{ form.extTagField }} -->
  546. <el-form label-width="100px">
  547. <el-form-item label="是否消耗品">
  548. <el-radio-group
  549. v-model="form.extTagField.isConsumables"
  550. :disabled="isReadOnly"
  551. >
  552. <el-radio :label="1">是</el-radio>
  553. <el-radio :label="0">否</el-radio>
  554. </el-radio-group>
  555. </el-form-item>
  556. </el-form>
  557. </el-card>
  558. <!-- 自定义编码 -->
  559. <!-- <CodeDialog
  560. ref="codeRefs"
  561. v-if="codeShow"
  562. @close="codeShow = false"
  563. @chooseCode="chooseCode"
  564. /> -->
  565. <!-- 分类选择弹窗 -->
  566. <CategoryDialog ref="categoryRefs" @chooseCategory="confirmCategory" />
  567. <!-- 仓储配置 -->
  568. <WarehouseInfo
  569. ref="warehouseRefs"
  570. v-if="isShow"
  571. :form="categoryWms"
  572. :measuringUnit="form.measuringUnit"
  573. :packingUnit="form.packingUnit"
  574. :packageDispositionVOList="packageDispositionVOList"
  575. :industry-attribute="industryAttribute"
  576. @change="changePackagingSpecification"
  577. :disabled="isReadOnly"
  578. />
  579. <!-- 销售配置 -->
  580. <SalesInfos ref="salesRefs" :form="categorySales" :disabled="isReadOnly" />
  581. <!-- 采购信息 -->
  582. <PurchasingInfo
  583. ref="PurchasingInfoRefs"
  584. :form="categoryPurchase"
  585. :industry-attribute="industryAttribute"
  586. :disabled="isReadOnly"
  587. />
  588. <!-- 生产信息 -->
  589. <ProductionInfo
  590. ref="productionRefs"
  591. :form="categoryMes"
  592. :disabled="isReadOnly"
  593. />
  594. <!-- 计划 -->
  595. <PlanInfo ref="planRefs" :form="categoryAps" :disabled="isReadOnly" />
  596. <!-- 质量配置 -->
  597. <QualityInfo ref="qualityRefs" :form="categoryQms" :disabled="isReadOnly" />
  598. <!-- 舟皿信息 -->
  599. <BoatInfo :form="categoryPallet" :disabled="isReadOnly" />
  600. <!-- 周转车信息 -->
  601. <TurnoverInfo
  602. ref="turnoverRefs"
  603. :form="categoryVehicle"
  604. :disabled="isReadOnly"
  605. />
  606. <!-- 模具信息 -->
  607. <MoldInfo ref="moldRefs" :form="categoryMold" :disabled="isReadOnly" />
  608. <!-- 备注信息 -->
  609. <RemarkInfo ref="remarkRefs" :form="remarkform" :disabled="isReadOnly" />
  610. <!-- 关联信息 -->
  611. <linkMsg
  612. ref="linkMsgRef"
  613. :id="$route.query.id"
  614. :categoryLevelId="form.categoryLevelId"
  615. :categoryLevelGroupId="form.categoryLevelGroupId"
  616. :code="form.code"
  617. :disabled="isReadOnly"
  618. />
  619. <!-- 申请编码 -->
  620. <GetCodeDialog ref="GetCodeDialogRef" @setCode="setCode"></GetCodeDialog>
  621. </el-tab-pane>
  622. <el-tab-pane v-if="hasProcessInstanceId" label="流程详情" name="bpm">
  623. <bpmDetail :id="form.processInstanceId"></bpmDetail>
  624. </el-tab-pane>
  625. </el-tabs>
  626. </div>
  627. </template>
  628. <script>
  629. import SalesInfos from './components/SalesInfos.vue';
  630. import PurchasingInfo from './components/PurchasingInfo.vue';
  631. import GroupDialog from './components/GroupDialog.vue';
  632. // import CodeDialog from './components/codeDialog.vue';
  633. import CategoryDialog from './components/CategoryDialog.vue';
  634. import WarehouseInfo from './components/WarehouseInfo.vue';
  635. import ProcureInfo from './components/ProcureInfo.vue';
  636. import ProductionInfo from './components/ProductionInfo.vue';
  637. import PlanInfo from './components/PlanInfo.vue';
  638. import SalesInfo from './components/SalesInfo.vue';
  639. import QualityInfo from './components/QualityInfo.vue';
  640. import BoatInfo from './components/BoatInfo.vue';
  641. import TurnoverInfo from './components/TurnoverInfo.vue';
  642. import MoldInfo from './components/MoldInfo.vue';
  643. import RemarkInfo from './components/RemarkInfo.vue';
  644. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  645. import personSelect from '@/components/CommomSelect/person-select.vue';
  646. import linkMsg from './components/link-msg.vue';
  647. import { getDetails } from '@/api/classifyManage/itemInformation';
  648. import { getByCode } from '@/api/system/dictionary-data';
  649. import {
  650. getCode as getCodeApi,
  651. rootCategoryCode,
  652. fieldModel,
  653. checkExist
  654. } from '@/api/codeManagement';
  655. // /main/category/checkExist
  656. import { addMaterial } from '@/api/material/list.js';
  657. import { deepClone } from '@/utils/index';
  658. import { finishPageTab, reloadPageTab } from '@/utils/page-tab-util';
  659. import { produceTypeList } from '@/enum/dict.js';
  660. import { copyObj } from '@/utils/util';
  661. import { parameterGetByCode } from '@/api/system/dictionary/index.js';
  662. import GetCodeDialog from '@/components/addDoc/getCode.vue';
  663. import { getCode, listCode } from '@/components/addDoc/api/index.js';
  664. import ImgUpload from '@/components/upload/imgUploadNew.vue';
  665. import bpmDetail from '@/views/bpm/processInstance/businessDetail.vue';
  666. const defCategoryQms = [
  667. {
  668. categoryId: '',
  669. checkDepart: null,
  670. sampleProportion: null,
  671. sampleProportionUnit: '%',
  672. checkPerson: null,
  673. checkProportion: null,
  674. createTime: '',
  675. createUserId: '',
  676. inspectionStandards: null,
  677. isComeCheck: 0,
  678. // level: '',
  679. levelItem: null,
  680. netWeight: null,
  681. qualityTemplateIds: [],
  682. dataType: 1
  683. },
  684. {
  685. categoryId: '',
  686. checkDepart: null,
  687. sampleProportion: null,
  688. sampleProportionUnit: '%',
  689. checkPerson: null,
  690. checkProportion: null,
  691. createTime: '',
  692. createUserId: '',
  693. inspectionStandards: null,
  694. isComeCheck: 0,
  695. // level: '',
  696. levelItem: null,
  697. netWeight: null,
  698. qualityTemplateIds: [],
  699. dataType: 2
  700. },
  701. {
  702. categoryId: '',
  703. checkDepart: null,
  704. sampleProportion: null,
  705. sampleProportionUnit: '%',
  706. checkPerson: null,
  707. checkProportion: null,
  708. createTime: '',
  709. createUserId: '',
  710. inspectionStandards: null,
  711. isComeCheck: 0,
  712. // level: '',
  713. levelItem: null,
  714. netWeight: null,
  715. qualityTemplateIds: [],
  716. dataType: 3
  717. }
  718. ];
  719. export default {
  720. name: 'product',
  721. components: {
  722. SalesInfos,
  723. PurchasingInfo,
  724. linkMsg,
  725. GroupDialog,
  726. deptSelect,
  727. personSelect,
  728. WarehouseInfo,
  729. ProcureInfo,
  730. ProductionInfo,
  731. PlanInfo,
  732. SalesInfo,
  733. QualityInfo,
  734. BoatInfo,
  735. TurnoverInfo,
  736. MoldInfo,
  737. RemarkInfo,
  738. CategoryDialog,
  739. // CodeDialog,
  740. GetCodeDialog,
  741. ImgUpload,
  742. bpmDetail
  743. },
  744. data() {
  745. return {
  746. activeTab: 'detail',
  747. isReadOnly: false,
  748. isShow: true,
  749. industryAttribute: '',
  750. produceTypeList,
  751. packagingSpecificationList: [],
  752. loading: false,
  753. productImgs: [],
  754. measureTypeList: [
  755. {
  756. label: '数量',
  757. value: 1
  758. },
  759. {
  760. label: '重量',
  761. value: 2
  762. },
  763. {
  764. label: '体积',
  765. value: 3
  766. },
  767. {
  768. label: '容积',
  769. value: 4
  770. },
  771. {
  772. label: '面积',
  773. value: 5
  774. }
  775. ],
  776. levelOptions: [
  777. {
  778. label: '特级',
  779. value: '特级'
  780. },
  781. {
  782. label: '一级',
  783. value: '一级'
  784. },
  785. {
  786. label: '二级',
  787. value: '二级'
  788. },
  789. {
  790. label: '三级',
  791. value: '三级'
  792. }
  793. ],
  794. isUpdate: 0,
  795. form: {
  796. categoryLevelGroupName: '',
  797. iotProductKey: '',
  798. imgUrl: [],
  799. propertiesChannelTropism: '',
  800. usageAndDosage: '',
  801. actionsAndUses: '',
  802. componentAttribute: [],
  803. categoryLevelName: '',
  804. isConsumable: 0,
  805. isEnabled: 1,
  806. measuringUnit: '',
  807. netWeight: '',
  808. attributeType: 1,
  809. weightUnit: '',
  810. packingUnit: '',
  811. areaUnit: '',
  812. area: '',
  813. colorKey: [],
  814. modelKey: [],
  815. extField: {},
  816. // isConsumables:2,
  817. extTagField: {
  818. isConsumables: 0,
  819. needProductSequence: 0
  820. }
  821. },
  822. lbjtList: [
  823. {
  824. label: '自制件',
  825. value: 1
  826. },
  827. {
  828. label: '采购件',
  829. value: 2
  830. },
  831. {
  832. label: '外协件',
  833. value: 3
  834. },
  835. {
  836. label: '受托件',
  837. value: 4
  838. }
  839. ],
  840. attributeList: [],
  841. remarkform: {
  842. remarkAttach: [],
  843. remark: ''
  844. },
  845. categorySales: {},
  846. categoryPurchase: { purchaseMultiplier: 1, measuringUnit: '' },
  847. categoryAps: {},
  848. categoryMes: { productionDays: '1' },
  849. categoryMold: {},
  850. categoryPallet: {},
  851. categoryQms: [...copyObj(defCategoryQms)],
  852. categoryVehicle: {},
  853. categoryWms: {
  854. isUnpack: 1,
  855. isWarn: 1,
  856. inventoryMode: '',
  857. secureInventory: '1',
  858. minInventory: '1',
  859. maxInventory: '1'
  860. },
  861. packageDispositionVOList: [],
  862. categoryLevelPathId: null,
  863. dictList: [
  864. {
  865. label: '加工',
  866. value: 1
  867. },
  868. {
  869. label: '装配',
  870. value: 3
  871. }
  872. ],
  873. fileList: [],
  874. // 表单验证规则
  875. PathInfo: {},
  876. id: null,
  877. ruleCode: null,
  878. codeShow: false,
  879. autoCodeRouteKey: '',
  880. status: null,
  881. isNetWeight: 0,
  882. mandatoryFieldList: []
  883. };
  884. },
  885. watch: {
  886. hasProcessInstanceId(value) {
  887. if (!value && this.activeTab === 'bpm') {
  888. this.activeTab = 'detail';
  889. }
  890. },
  891. '$route.query.id': {
  892. handler(id) {
  893. console.log(id, 'id');
  894. if (id) {
  895. this._getDetails();
  896. } else {
  897. let { lyType } = this.$route.query;
  898. let arrId = '';
  899. if (lyType == 'wp') {
  900. arrId = 3;
  901. }
  902. if (lyType == 'cp') {
  903. arrId = 1;
  904. }
  905. this.form = {
  906. categoryLevelGroupName: '',
  907. // categoryLevelName: '',
  908. componentAttribute: [],
  909. isConsumable: 0,
  910. attributeType: arrId,
  911. measuringUnit: '',
  912. netWeight: '',
  913. weightUnit: '',
  914. packingUnit: '',
  915. areaUnit: '',
  916. area: '',
  917. colorKey: [],
  918. modelKey: [],
  919. extField: {},
  920. extTagField: {
  921. isConsumables: 0,
  922. needProductSequence: 0
  923. },
  924. measureType: 1,
  925. isEnabled: 1
  926. };
  927. this.isUpdate = 0;
  928. this.categorySales = {};
  929. this.purchaseInfo = {};
  930. this.remarkform = {
  931. remarkAttach: [],
  932. remark: ''
  933. };
  934. this.categoryAps = {};
  935. this.categoryMes = {
  936. productionDays: '20',
  937. isCompleteSet: 0,
  938. isModify: 0,
  939. isRework: 0,
  940. isRematerial: 0,
  941. isByProduct: 0,
  942. isWaste: 0,
  943. isDefective: 0
  944. };
  945. this.categoryMold = {};
  946. this.categoryPallet = {};
  947. this.categoryQms = [...copyObj(defCategoryQms)];
  948. this.categoryVehicle = {};
  949. this.categoryWms = {
  950. isUnpack: 1,
  951. isWarn: 1,
  952. inventoryMode: this.form.isConsumable,
  953. minPackageCell: '',
  954. secureInventory: '10',
  955. minInventory: '10',
  956. maxInventory: '10'
  957. };
  958. this.packageDispositionVOList = [];
  959. this.categoryLevelPathId = null;
  960. // this.dictList = [];
  961. this.fileList = [];
  962. }
  963. },
  964. deep: true,
  965. immediate: true
  966. }
  967. // 同步图片id到表单模型(用于保存)
  968. // productImgs: {
  969. // handler(val) {
  970. // this.form.imgurl = val
  971. // .map((img) => img.id)
  972. // .filter(Boolean)
  973. // .join(',');
  974. // },
  975. // immediate: true
  976. // },
  977. },
  978. computed: {
  979. clientEnvironmentId() {
  980. return this.$store.state.user.info.clientEnvironmentId;
  981. },
  982. hasProcessInstanceId() {
  983. return (
  984. this.form.processInstanceId !== null &&
  985. this.form.processInstanceId !== undefined &&
  986. this.form.processInstanceId !== ''
  987. );
  988. },
  989. rules() {
  990. return {
  991. measureType: [
  992. { required: true, message: '请选择计量类型', trigger: 'change' }
  993. ],
  994. categoryLevelGroupName: [
  995. { required: true, message: '请选择所属物料组', trigger: 'change' }
  996. ],
  997. code: [{ required: true, message: '请输入编码', trigger: 'blur' }],
  998. name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
  999. specification: [
  1000. {
  1001. required: this.clientEnvironmentId == 10 ? true : false,
  1002. message: '请输入规格',
  1003. trigger: 'blur'
  1004. }
  1005. ],
  1006. modelType: [
  1007. {
  1008. required: this.clientEnvironmentId == 10 ? true : false,
  1009. message: '请输入型号',
  1010. trigger: 'blur'
  1011. }
  1012. ],
  1013. 'extField.layBy': [
  1014. {
  1015. required: this.clientEnvironmentId == 10 ? true : false,
  1016. message: '请输入贮藏',
  1017. trigger: 'blur'
  1018. }
  1019. ],
  1020. componentAttribute: [
  1021. { required: true, message: '请选择属性类型', trigger: 'change' }
  1022. ],
  1023. attributeType: [
  1024. { required: true, message: '请选择属性类型', trigger: 'change' }
  1025. ],
  1026. categoryLevelName: [
  1027. { required: true, message: '请选择所属分类', trigger: 'change' }
  1028. ],
  1029. measuringUnit: [
  1030. { required: true, message: '请选择计量单位', trigger: 'change' }
  1031. ],
  1032. weightUnit: [
  1033. { required: true, message: '请选择重量单位', trigger: 'change' }
  1034. ],
  1035. packingUnit: [
  1036. { required: true, message: '请选择包装单位', trigger: 'change' }
  1037. ],
  1038. netWeight: [
  1039. { required: true, message: '请输入净重', trigger: 'blur' }
  1040. ]
  1041. };
  1042. }
  1043. },
  1044. async activated() {
  1045. this.status = this.$route.query.status;
  1046. this.isReadOnly =
  1047. this.$route.query.readOnly === 'true' ||
  1048. this.$route.query.readOnly === true;
  1049. console.log(
  1050. 'activated - isReadOnly 状态:',
  1051. this.isReadOnly,
  1052. 'readOnly参数:',
  1053. this.$route.query.readOnly
  1054. );
  1055. this.form.categoryLevelId = this.$route.query.categoryLevelId;
  1056. this.form.categoryLevelName = this.$route.query.categoryLevelName;
  1057. this.form.categoryLevelPath = this.$route.query.categoryLevelPath;
  1058. this.form.categoryLevelPathId = this.$route.query.categoryLevelPathId;
  1059. this.ruleCode = this.$route.query.ruleCode;
  1060. // if (this.ruleCode && this.ruleCode != '自定义' && this.status != 0) {
  1061. // const code = await getCode(this.ruleCode);
  1062. // this.$set(this.form, 'code', code);
  1063. // }
  1064. await this.generateCodeIfNeeded();
  1065. this.getFieldModel();
  1066. // this.getDictList('zeroPartPros');
  1067. },
  1068. async created() {
  1069. //主数据物品是否计算净重
  1070. parameterGetByCode({
  1071. code: 'main_isNetWeight'
  1072. }).then((res) => {
  1073. if (res.value) {
  1074. this.isNetWeight = res.value;
  1075. if (this.clientEnvironmentId != 5) {
  1076. if (this.isNetWeight == 1 && !this.$route.query.id) {
  1077. console.log('dadada');
  1078. this.setDefaultUnpackByConsumable();
  1079. }
  1080. }
  1081. }
  1082. });
  1083. this.isReadOnly =
  1084. this.$route.query.readOnly === 'true' ||
  1085. this.$route.query.readOnly === true;
  1086. console.log(
  1087. '详情页 isReadOnly 状态:',
  1088. this.isReadOnly,
  1089. 'readOnly参数:',
  1090. this.$route.query.readOnly
  1091. );
  1092. parameterGetByCode({
  1093. code: 'mandatory_field'
  1094. }).then((res) => {
  1095. // console.log(res.value, '77777');
  1096. if (res.value) {
  1097. this.mandatoryFieldList = res.value.split(',');
  1098. console.log(this.mandatoryFieldList, '7222222');
  1099. }
  1100. });
  1101. // 行业属性 0:通用行业;1:生物医药行业;2:电线电缆行业;
  1102. parameterGetByCode({
  1103. code: 'industry_attribute'
  1104. }).then((res) => {
  1105. console.log(res.value, '77777');
  1106. if (res.value) {
  1107. console.log(res, '33333333');
  1108. this.industryAttribute = res.value;
  1109. }
  1110. });
  1111. //新增
  1112. this.$set(
  1113. this.form,
  1114. 'categoryLevelId',
  1115. this.$route.query.categoryLevelId
  1116. );
  1117. this.$set(this.form, 'isUpdate', this.$route.query.isUpdate);
  1118. this.isUpdate = this.$route.query.isUpdate;
  1119. this.$set(
  1120. this.form,
  1121. 'categoryLevelName',
  1122. this.$route.query.categoryLevelName
  1123. );
  1124. this.$set(
  1125. this.form,
  1126. 'categoryLevelPath',
  1127. this.$route.query.categoryLevelPath
  1128. );
  1129. this.$set(
  1130. this.form,
  1131. 'categoryLevelPathId',
  1132. this.$route.query.categoryLevelPathId
  1133. );
  1134. this.status = this.$route.query.status;
  1135. this.ruleCode = this.$route.query.ruleCode;
  1136. // if (this.ruleCode && this.ruleCode != '自定义' && this.status != 0) {
  1137. // const code = await getCode(this.ruleCode);
  1138. // this.$set(this.form, 'code', code);
  1139. // }
  1140. await this.generateCodeIfNeeded();
  1141. this.getFieldModel();
  1142. this.getAttributeList('inventory_type');
  1143. this.getDictList('zeroPartPros');
  1144. },
  1145. mounted() {
  1146. if (this.clientEnvironmentId == 4) {
  1147. this.form.measureType = 3;
  1148. }
  1149. },
  1150. methods: {
  1151. getDefaultIsUnpackByConsumable(isConsumable) {
  1152. return Number(isConsumable) === 1 ? 0 : 1;
  1153. },
  1154. setDefaultUnpackByConsumable() {
  1155. this.$set(
  1156. this.categoryWms,
  1157. 'isUnpack',
  1158. this.getDefaultIsUnpackByConsumable(this.form.isConsumable)
  1159. );
  1160. },
  1161. inputSpe(val) {
  1162. if (this.form.measuringUnit == '立方') {
  1163. if (!val || typeof val !== 'string') {
  1164. this.form.volume = 0;
  1165. return;
  1166. }
  1167. let modelArr = val.split('*');
  1168. let modelLong = modelArr[0]; // model规格长度
  1169. let modeWide = modelArr[1]; // model规格宽度
  1170. let modeHight = modelArr[2]?.substr(0, modelArr[2].indexOf('cm')); // model规格高度
  1171. modeHight = Number(modeHight);
  1172. let aa = (modelLong * modeWide * modeHight) / 1000000;
  1173. console.log(aa, 'aa');
  1174. this.form.volume = aa;
  1175. } else {
  1176. this.form.volume = '';
  1177. }
  1178. this.setNetWeight();
  1179. },
  1180. //计算净重
  1181. setNetWeight() {
  1182. if (
  1183. this.form.specification &&
  1184. this.form.weightUnit == 'KG' &&
  1185. this.isNetWeight == 1
  1186. ) {
  1187. let modelArr = this.form.specification.split('*');
  1188. let modelLong = modelArr[0]; // model规格长度
  1189. let modeWide = modelArr[1]; // model规格宽度
  1190. let modeHight = modelArr[2]?.substr(0, modelArr[2].indexOf('mm')); // model规格高度
  1191. modeHight = Number(modeHight);
  1192. let volume = (modelLong * modeWide * modeHight) / 1000;
  1193. if (volume) {
  1194. this.$set(
  1195. this.form,
  1196. 'netWeight',
  1197. parseFloat((volume * 7.85) / 1000).toFixed(4)
  1198. );
  1199. } else {
  1200. this.$set(this.form, 'netWeight', 0);
  1201. }
  1202. this.$nextTick(() => {
  1203. // this.$refs.warehouseRefs &&
  1204. // this.$refs.warehouseRefs.changeNetWeight(this.form.netWeight);
  1205. this.handleInput3();
  1206. });
  1207. // this.form.netWeight = volume*7.85/1000;
  1208. }
  1209. },
  1210. changeMeasureType() {
  1211. this.setNetWeight();
  1212. },
  1213. sanitizePositiveDecimalInput(value) {
  1214. if (value === null || value === undefined) return '';
  1215. const filteredValue = String(value).replace(/[^0-9.]/g, '');
  1216. if (!filteredValue) return '';
  1217. const [integerPart, ...decimalParts] = filteredValue.split('.');
  1218. if (!decimalParts.length) {
  1219. return integerPart;
  1220. }
  1221. return `${integerPart || '0'}.${decimalParts.join('')}`;
  1222. },
  1223. normalizeDecimalFields() {
  1224. ['area', 'roughWeight', 'netWeight', 'volume'].forEach((field) => {
  1225. const value = this.sanitizePositiveDecimalInput(this.form[field]);
  1226. this.$set(
  1227. this.form,
  1228. field,
  1229. value.endsWith('.') ? value.slice(0, -1) : value
  1230. );
  1231. });
  1232. },
  1233. handleAreaInput(value) {
  1234. this.form.area = this.sanitizePositiveDecimalInput(value);
  1235. },
  1236. handleInput(value) {
  1237. this.form.volume = this.sanitizePositiveDecimalInput(value);
  1238. },
  1239. handleInput2(value) {
  1240. this.form.roughWeight = this.sanitizePositiveDecimalInput(value);
  1241. },
  1242. handleInput3(value) {
  1243. this.form.netWeight = this.sanitizePositiveDecimalInput(
  1244. value === undefined ? this.form.netWeight : value
  1245. );
  1246. if (this.form.weightUnit == this.form.measuringUnit) {
  1247. this.$refs.warehouseRefs.changeNetWeight(this.form.netWeight);
  1248. }
  1249. },
  1250. changeConsumable() {
  1251. this.$set(this.categoryWms, 'inventoryMode', this.form.isConsumable);
  1252. this.setDefaultUnpackByConsumable();
  1253. },
  1254. changeWeightUnit() {
  1255. if (
  1256. this.form.measuringUnit &&
  1257. this.form.packingUnit &&
  1258. this.form.netWeight
  1259. ) {
  1260. this.$refs.warehouseRefs.changeNetWeight(this.form.netWeight);
  1261. }
  1262. this.setNetWeight();
  1263. },
  1264. async changeUnit() {
  1265. if (this.$route.query.id == '' || this.$route.query.id == null) {
  1266. if (this.form.measuringUnit) {
  1267. // 计量单位是‘立方’ 体积单位默认是‘立方’
  1268. if (
  1269. this.form.measuringUnit == '立方' &&
  1270. this.form.specification != ''
  1271. ) {
  1272. this.form.volumeUnit = '立方';
  1273. this.inputSpe(this.form.specification);
  1274. } else {
  1275. this.form.volume = 0;
  1276. }
  1277. this.categoryPurchase.measuringUnit = this.form.measuringUnit;
  1278. console.log(this.categoryPurchase.measuringUnit, '采购信息');
  1279. // 如果有计量单位和包装单位 默认添加包装组
  1280. if (this.form.packingUnit) {
  1281. await this.$refs.warehouseRefs.defaultBuild(
  1282. this.form.packingUnit
  1283. );
  1284. }
  1285. }
  1286. } else {
  1287. this.isShow = false;
  1288. if (this.form.measuringUnit) {
  1289. this.categoryPurchase.measuringUnit = this.form.measuringUnit;
  1290. if (this.form.packingUnit) {
  1291. console.log(this.form.measuringUnit, 'this.form.measuringUnit');
  1292. console.log(this.form.packingUnit, 'this.form.packingUnit');
  1293. if (this.packageDispositionVOList.length === 0) {
  1294. console.log('如果没有包装组');
  1295. await this.$refs.warehouseRefs.defaultBuild(
  1296. this.form.packingUnit
  1297. );
  1298. }
  1299. }
  1300. }
  1301. this.isShow = true;
  1302. }
  1303. await this.setNetWeight();
  1304. },
  1305. // changeAttribute(val) {
  1306. // if (val.includes(1)) {
  1307. // // this.rules = {
  1308. // // produceType: [
  1309. // // { required: true, message: '请选择生产类型', trigger: 'change' }
  1310. // // ]
  1311. // // };
  1312. // this.rules.produceType = [
  1313. // { required: true, message: '请选择生产类型', trigger: 'change' }
  1314. // ];
  1315. // } else {
  1316. // if (this.rules.produceType) {
  1317. // delete this.rules.produceType;
  1318. // }
  1319. // }
  1320. // },
  1321. changePackagingSpecification(val) {
  1322. this.packagingSpecificationList = val;
  1323. },
  1324. async _getDetails() {
  1325. const data = await getDetails(this.$route.query.id);
  1326. this.isUpdate = this.$route.query.isUpdate;
  1327. this.$set(this.form, 'isUpdate', this.$route.query.isUpdate);
  1328. const info = deepClone(data);
  1329. info.category.produceType = info.category.produceType[0];
  1330. try {
  1331. if (info.category.colorKey) {
  1332. info.category.colorKey = info.category.colorKey.split(',');
  1333. }
  1334. if (info.category.modelKey) {
  1335. info.category.modelKey = info.category.modelKey.split(',');
  1336. }
  1337. if (info.category.imgUrl && info.category.imgUrl.length > 0) {
  1338. info.category.imgUrl = info.category.imgUrl.map((item) => ({
  1339. ...item,
  1340. status: 'done'
  1341. }));
  1342. }
  1343. } catch (error) {}
  1344. this.form = {
  1345. ...info.category
  1346. };
  1347. this.remarkform.remark = info.category.remark;
  1348. this.remarkform.remarkAttach = info.category.remarkAttach;
  1349. // if (this.form.measuringUnit && this.form.packingUnit) {
  1350. // this.$refs.warehouseRefs.defaultBuild(this.form.packingUnit);
  1351. // }
  1352. this.categoryLevelPathId = info.category.categoryLevelPathIdParent;
  1353. this.judgeSet(info);
  1354. if (this.status == 1) {
  1355. // rootCategoryCode(this.categoryLevelPathId).then((res) => {
  1356. // this.$set(this.form, 'code', res);
  1357. // });
  1358. this.form.createTime = null;
  1359. }
  1360. // 回显上传组件
  1361. this.$nextTick(() => {
  1362. this.$refs.imgUploadRef?.putValue(this.form.imgUrl);
  1363. });
  1364. this.$forceUpdate();
  1365. },
  1366. // 判断字段类型并赋值
  1367. judgeSet(info) {
  1368. console.log('info-------', info);
  1369. if (typeof info.categoryAps == 'string') {
  1370. this.categoryAps = {};
  1371. } else {
  1372. this.categoryAps = info.categoryAps;
  1373. }
  1374. if (typeof info.categoryMes == 'string') {
  1375. this.categoryMes = {};
  1376. } else {
  1377. this.categoryMes = info.categoryMes;
  1378. }
  1379. if (typeof info.categoryMold == 'string') {
  1380. this.categoryMold = {};
  1381. } else {
  1382. this.categoryMold = info.categoryMold;
  1383. }
  1384. if (typeof info.categoryPallet == 'string') {
  1385. this.categoryPallet = {};
  1386. } else {
  1387. this.categoryPallet = info.categoryPallet;
  1388. }
  1389. if (typeof info.categorySales == 'string') {
  1390. this.categorySales = {};
  1391. } else {
  1392. this.categorySales = info.categorySales;
  1393. }
  1394. if (typeof info.categoryPurchase == 'string') {
  1395. this.categoryPurchase = {};
  1396. } else {
  1397. this.categoryPurchase = info.categoryPurchase;
  1398. }
  1399. if (!info.categoryQms || !info.categoryQms?.length) {
  1400. this.categoryQms = [...copyObj(defCategoryQms)];
  1401. } else if (info.categoryQms.length < defCategoryQms.length) {
  1402. //历史数据处理
  1403. // let num= defCategoryQms.length-info.categoryQms.length
  1404. // info.categoryQms.push();
  1405. this.categoryQms = [
  1406. ...info.categoryQms,
  1407. ...copyObj(
  1408. defCategoryQms.slice(
  1409. info.categoryQms.length,
  1410. defCategoryQms.length
  1411. )
  1412. )
  1413. ];
  1414. } else {
  1415. this.categoryQms = info.categoryQms;
  1416. }
  1417. if (typeof info.categoryVehicle == 'string') {
  1418. this.categoryVehicle = {};
  1419. } else {
  1420. this.categoryVehicle = info.categoryVehicle;
  1421. }
  1422. if (typeof info.categoryWms == 'string') {
  1423. this.categoryWms = {};
  1424. } else {
  1425. this.categoryWms = info.categoryWms;
  1426. }
  1427. if (typeof info.packageDispositionVOList == 'string') {
  1428. this.packageDispositionVOList = [];
  1429. } else {
  1430. this.packageDispositionVOList = info.packageDispositionVOList;
  1431. console.log(
  1432. 'this.packageDispositionVOList---!!!----',
  1433. this.packageDispositionVOList
  1434. );
  1435. }
  1436. },
  1437. getFieldModel() {
  1438. fieldModel({ relevance: 't_main_category' }).then((res) => {
  1439. this.fileList = res;
  1440. if (!this.form.extTagField) {
  1441. this.form.extTagField = {
  1442. isConsumables: 0,
  1443. needProductSequence: 0
  1444. }; // 初始化动态模型属性
  1445. }
  1446. // this.$set(this.form.extTagField, 'isConsumables', 0); // 初始化动态模型属性
  1447. if (!this.form.extField) {
  1448. this.$set(this.form, 'extField', {});
  1449. }
  1450. this.fileList.forEach((f) => {
  1451. if (
  1452. Object.prototype.hasOwnProperty.call(this.form.extField, f.prop)
  1453. ) {
  1454. return;
  1455. }
  1456. this.$set(this.form.extField, f.prop, ''); // 初始化动态模型属性
  1457. // this.$set(this.form.extTagField, f.prop, ''); // 初始化动态模型属性
  1458. });
  1459. });
  1460. },
  1461. levelChange(val) {
  1462. // this.$refs.qualityRefs?.forEach((item) => {
  1463. // item.levelChange(val);
  1464. // // console.log(item)
  1465. // });
  1466. },
  1467. // 确定分类
  1468. async confirmCategory(node, title, PathInfo, ruleCode) {
  1469. this.categoryLevelPathId = PathInfo.categoryLevelPathId.split(',')[0];
  1470. if (title == '选择产品分类') {
  1471. this.$set(this.form, 'productCategoryLevelName', node.name);
  1472. this.$set(this.form, 'productCategoryLevelId', node.id);
  1473. } else {
  1474. this.$set(this.form, 'categoryLevelName', node.name);
  1475. this.$set(this.form, 'categoryLevelId', node.id);
  1476. this.$set(this.form, 'categoryLevelPath', node.name);
  1477. this.$set(this.form, 'categoryLevelPathId', node.id);
  1478. this.PathInfo = PathInfo;
  1479. this.ruleCode = ruleCode;
  1480. // if (ruleCode && ruleCode != '自定义' && this.status != 0) {
  1481. // const code = await getCode(ruleCode);
  1482. // this.$set(this.form, 'code', code);
  1483. // }
  1484. // console.log(this.form, 'this.form');
  1485. await this.generateCodeIfNeeded(true);
  1486. }
  1487. this.$forceUpdate();
  1488. },
  1489. getCodeOpen() {
  1490. if (this.isReadOnly) return;
  1491. let parentId = [];
  1492. if (this.form.categoryLevelPathId?.length) {
  1493. parentId = this.form.categoryLevelPathId?.split(',');
  1494. }
  1495. this.$refs.GetCodeDialogRef.open({
  1496. id: this.form.categoryLevelId,
  1497. parentId: parentId.length > 1 ? parentId[parentId.length - 2] : ''
  1498. });
  1499. },
  1500. setCode(val) {
  1501. this.$set(this.form, 'code', val);
  1502. },
  1503. shouldAutoGenerateCode() {
  1504. const status = Number(this.status);
  1505. return !this.isReadOnly && (status === 1 || status === 2);
  1506. },
  1507. getAutoCodeRouteKey() {
  1508. const { t, id, categoryLevelId, categoryLevelPathId } =
  1509. this.$route.query;
  1510. return [
  1511. t || '',
  1512. id || '',
  1513. this.status || '',
  1514. this.form.categoryLevelId || categoryLevelId || '',
  1515. this.form.categoryLevelPathId || categoryLevelPathId || ''
  1516. ].join('|');
  1517. },
  1518. async generateCodeIfNeeded(force = false) {
  1519. if (!this.shouldAutoGenerateCode()) {
  1520. return;
  1521. }
  1522. const routeKey = this.getAutoCodeRouteKey();
  1523. if (!force && this.autoCodeRouteKey === routeKey) {
  1524. return;
  1525. }
  1526. this.autoCodeRouteKey = routeKey;
  1527. await this.getCode();
  1528. },
  1529. async getCode() {
  1530. let parentId = [];
  1531. let categoryLevelPathId = this.PathInfo?.categoryLevelPathId
  1532. ? this.PathInfo.categoryLevelPathId
  1533. : this.form.categoryLevelPathId;
  1534. if (categoryLevelPathId?.length) {
  1535. parentId = categoryLevelPathId.split(',');
  1536. }
  1537. const options = await listCode({
  1538. id: this.form.categoryLevelId,
  1539. parentId: parentId.length > 1 ? parentId[parentId.length - 2] : ''
  1540. });
  1541. if (options.length > 0) {
  1542. getCode({
  1543. categoryId: options[0].id
  1544. }).then((res) => {
  1545. this.$set(this.form, 'code', res.codeStr);
  1546. });
  1547. } else {
  1548. if (this.ruleCode && this.ruleCode != '自定义') {
  1549. const code = await getCodeApi(this.ruleCode);
  1550. this.$set(this.form, 'code', code);
  1551. }
  1552. }
  1553. },
  1554. async getDictList(code) {
  1555. let { data: res } = await getByCode(code);
  1556. console.log('res----', res);
  1557. // this.lbjtList = res.map((item) => {
  1558. // let values = Object.keys(item);
  1559. // return {
  1560. // value: Number(values[0]),
  1561. // label: item[values[0]]
  1562. // };
  1563. // });
  1564. },
  1565. async getAttributeList(code) {
  1566. let res = await getByCode(code);
  1567. // this.attributeList = res.data.map((item) => {
  1568. // let values = Object.keys(item);
  1569. // return {
  1570. // value: values[0],
  1571. // label: item[values[0]]
  1572. // };
  1573. // });
  1574. let list = res.data.map((item) => {
  1575. let key = Object.keys(item)[0];
  1576. return { value: Number(key), label: item[key] };
  1577. });
  1578. this.attributeList = list;
  1579. console.log(this.attributeList, 'this.attributeList');
  1580. },
  1581. openCategory() {
  1582. if (this.isReadOnly) return;
  1583. this.$refs.categoryRefs.open();
  1584. },
  1585. openCode() {
  1586. this.codeShow = true;
  1587. },
  1588. chooseCode(code) {
  1589. this.$set(this.form, 'code', code);
  1590. this.codeShow = false;
  1591. this.$forceUpdate();
  1592. },
  1593. cancel() {
  1594. // finishPageTab();
  1595. // this.$router.go(-1);
  1596. if (this.$route.query.rootTreeId == 9) {
  1597. this.$router.push({
  1598. path: '/product/oneProduct',
  1599. query: {
  1600. categoryLevelId: this.form.categoryLevelId
  1601. }
  1602. });
  1603. } else {
  1604. this.$router.push({
  1605. path: '/material/product',
  1606. query: {
  1607. categoryLevelId: this.form.categoryLevelId
  1608. }
  1609. });
  1610. }
  1611. },
  1612. verifyDuplicate(obj) {
  1613. return new Promise((resolve, reject) => {
  1614. checkExist(obj).then((res) => {
  1615. if (res) {
  1616. console.log(res, 'res----');
  1617. this.$confirm('系统已有相同的数据', '提示', {
  1618. confirmButtonText: '确定',
  1619. cancelButtonText: '取消',
  1620. type: 'warning'
  1621. })
  1622. .then(() => {
  1623. resolve(true);
  1624. })
  1625. .catch(() => {
  1626. resolve(false);
  1627. });
  1628. } else {
  1629. resolve(true);
  1630. }
  1631. });
  1632. });
  1633. },
  1634. // 保存
  1635. submit() {
  1636. this.normalizeDecimalFields();
  1637. this.$refs.manageForm.validate(async (valid) => {
  1638. console.log(this.$refs.qualityRefs);
  1639. if (!valid) return;
  1640. let req = {
  1641. name: this.form.name,
  1642. modelType: this.form.modelType,
  1643. specification: this.form.specification,
  1644. isUpdate: this.$route.query.isUpdate
  1645. };
  1646. if (!(await this.verifyDuplicate(req))) return;
  1647. let productionValid = await this.$refs.productionRefs.getFormValid();
  1648. let warehouseValid = await this.$refs.warehouseRefs.getFormValid();
  1649. if (!valid || !productionValid || !warehouseValid) {
  1650. return false;
  1651. }
  1652. let packageDispositionVOList = [];
  1653. if (this.packagingSpecificationList.length > 0) {
  1654. packageDispositionVOList = this.packagingSpecificationList.map(
  1655. (item) => {
  1656. let obj = {
  1657. code: item.code,
  1658. name: item.name
  1659. };
  1660. return [
  1661. {
  1662. ...obj,
  1663. id: item.id0,
  1664. sort: 0,
  1665. status: item.status,
  1666. packageCell: 1,
  1667. packageUnit: item.packageUnit,
  1668. conversionUnit: item.packageUnit
  1669. },
  1670. {
  1671. ...obj,
  1672. id: item.id1,
  1673. sort: 1,
  1674. packageCell: item.minPackageCell,
  1675. packageUnit: item.packageUnit,
  1676. conversionUnit: item.minConversionUnit,
  1677. status: item.status
  1678. },
  1679. {
  1680. ...obj,
  1681. id: item.id2,
  1682. sort: 2,
  1683. packageCell: item.inPackageCell,
  1684. packageUnit: item.minConversionUnit,
  1685. conversionUnit: item.inConversionUnit,
  1686. status: item.status
  1687. },
  1688. {
  1689. ...obj,
  1690. id: item.id3,
  1691. sort: 3,
  1692. packageCell: item.outPackageCell,
  1693. packageUnit: item.inConversionUnit,
  1694. conversionUnit: item.outConversionUnit,
  1695. status: item.status
  1696. }
  1697. ];
  1698. }
  1699. );
  1700. let packagingSpecificationList =
  1701. this.packagingSpecificationList.filter(
  1702. (item) => item.status == 1
  1703. );
  1704. this.form.extField.packingSpecification = packagingSpecificationList
  1705. .map((item) => {
  1706. return [
  1707. `${item.minPackageCell}${item.packageUnit}/${item.minConversionUnit}`,
  1708. `${item.inPackageCell}${item.minConversionUnit}/${item.inConversionUnit}`,
  1709. `${item.outPackageCell}${item.inConversionUnit}/${item.outConversionUnit}`
  1710. ];
  1711. })
  1712. .flat()
  1713. .join(',');
  1714. } else {
  1715. this.form.extField.packingSpecification = '';
  1716. }
  1717. this.loading = true;
  1718. // const imgList = this.remarkform.imgList;
  1719. // const arr = [];
  1720. // if (imgList.length) {
  1721. // imgList.map((item) => {
  1722. // arr.push(item.storePath);
  1723. // });
  1724. // this.form.remarkAttach = arr.join(',');
  1725. // }
  1726. // this.form.remark = this.remarkform.remark
  1727. // ? this.remarkform.remark
  1728. // : '';
  1729. const data = {
  1730. categorySales: this.categorySales,
  1731. categoryPurchase: this.categoryPurchase,
  1732. categoryWms: this.categoryWms,
  1733. categoryAps: this.categoryAps,
  1734. categoryMes: this.categoryMes,
  1735. categoryMold: this.categoryMold,
  1736. categoryPallet: this.categoryPallet,
  1737. categoryQms: this.categoryQms,
  1738. categoryVehicle: this.categoryVehicle,
  1739. category: {
  1740. ...this.form,
  1741. ...this.remarkform,
  1742. ...this.PathInfo
  1743. },
  1744. packageDispositionVOList: packageDispositionVOList.flat()
  1745. };
  1746. if (this.$route.query.status == 1) {
  1747. data.categorySales.id = null;
  1748. data.categoryPurchase.id = null;
  1749. data.category.id = null;
  1750. data.categoryWms.id = null;
  1751. data.categoryAps.id = null;
  1752. data.categoryMes.id = null;
  1753. data.categoryMold.id = null;
  1754. data.categoryPallet.id = null;
  1755. // data.categoryQms.id = null;
  1756. data.categoryVehicle.id = null;
  1757. data.packageDispositionVOList = data.packageDispositionVOList.map(
  1758. (item) => {
  1759. return {
  1760. ...item,
  1761. id: null
  1762. };
  1763. }
  1764. );
  1765. }
  1766. if (data.category.colorKey) {
  1767. data.category.colorKey = data.category.colorKey.toString();
  1768. }
  1769. if (data.category.modelKey) {
  1770. data.category.modelKey = data.category.modelKey.toString();
  1771. }
  1772. data.category.produceType = data.category.produceType
  1773. ? [data.category.produceType]
  1774. : [];
  1775. addMaterial(data)
  1776. .then((msg) => {
  1777. this.loading = false;
  1778. this.$message.success(msg);
  1779. // reloadPageTab({ fullPath: '/material/product' });
  1780. // this.$router.go(-1);
  1781. this.cancel();
  1782. // if (this.$route.query.rootTreeId == 9) {
  1783. // this.$router.push({
  1784. // path: '/product/oneProduct',
  1785. // query: {
  1786. // categoryLevelId: this.form.categoryLevelId
  1787. // }
  1788. // });
  1789. // } else {
  1790. // this.$router.push({
  1791. // path: '/material/product',
  1792. // query: {
  1793. // categoryLevelId: this.form.categoryLevelId
  1794. // }
  1795. // });
  1796. // }
  1797. })
  1798. .catch((e) => {
  1799. this.loading = false;
  1800. });
  1801. });
  1802. },
  1803. //生产类型切换
  1804. produceTypeChange(value) {
  1805. // if (value == 1) {
  1806. // this.attributeList = [
  1807. // {
  1808. // label: '成品',
  1809. // value: 1
  1810. // },
  1811. // {
  1812. // label: '半成品',
  1813. // value: 2
  1814. // },
  1815. // {
  1816. // label: '零件',
  1817. // value: 3
  1818. // },
  1819. // {
  1820. // label: '原材料',
  1821. // value: 4
  1822. // }
  1823. // ];
  1824. // this.form.attributeType = 1;
  1825. // } else {
  1826. // this.attributeList = [
  1827. // {
  1828. // label: '总装(成品)',
  1829. // value: 1
  1830. // },
  1831. // {
  1832. // label: '部件(半成品)',
  1833. // value: 2
  1834. // },
  1835. // {
  1836. // label: '零件',
  1837. // value: 3
  1838. // },
  1839. // {
  1840. // label: '原材料',
  1841. // value: 4
  1842. // }
  1843. // ];
  1844. // this.form.attributeType = 1;
  1845. // }
  1846. }
  1847. }
  1848. };
  1849. </script>
  1850. <style lang="scss" scoped>
  1851. .ele-page-header {
  1852. border: none;
  1853. }
  1854. .product-detail-tabs {
  1855. ::v-deep .el-tabs__header {
  1856. margin: 0 0 12px;
  1857. border-bottom: 1px solid #d8e6f5;
  1858. }
  1859. ::v-deep .el-tabs__nav {
  1860. border: none;
  1861. }
  1862. ::v-deep .el-tabs__item {
  1863. height: 40px;
  1864. padding: 0 22px;
  1865. border: 1px solid #d8e6f5;
  1866. border-radius: 4px 4px 0 0;
  1867. background: #f5f7fa;
  1868. color: #606266;
  1869. font-weight: 600;
  1870. line-height: 40px;
  1871. transition: all 0.18s ease;
  1872. }
  1873. ::v-deep .el-tabs__item + .el-tabs__item {
  1874. margin-left: 6px;
  1875. }
  1876. ::v-deep .el-tabs__item:hover {
  1877. color: #1684df;
  1878. background: #eef7ff;
  1879. }
  1880. ::v-deep .el-tabs__item.is-active {
  1881. border-color: #1684df;
  1882. background: #1684df;
  1883. color: #fff;
  1884. box-shadow: 0 4px 10px rgba(22, 132, 223, 0.22);
  1885. }
  1886. ::v-deep .el-tabs__content {
  1887. overflow: visible;
  1888. }
  1889. }
  1890. .body-top {
  1891. display: flex;
  1892. align-items: center;
  1893. justify-content: space-between;
  1894. background: #fff;
  1895. .top-left {
  1896. display: flex;
  1897. align-items: center;
  1898. justify-content: flex-start;
  1899. margin-left: -25px;
  1900. .el-form-item {
  1901. margin-bottom: 0;
  1902. }
  1903. }
  1904. }
  1905. .divider {
  1906. margin: 20px 0;
  1907. .title {
  1908. display: flex;
  1909. align-items: center;
  1910. margin-bottom: 10px;
  1911. div {
  1912. width: 8px;
  1913. height: 20px;
  1914. margin-right: 10px;
  1915. }
  1916. span {
  1917. font-size: 20px;
  1918. }
  1919. }
  1920. .ele-width {
  1921. width: 100%;
  1922. height: 2px;
  1923. }
  1924. }
  1925. .form-line {
  1926. display: flex;
  1927. align-items: center;
  1928. justify-content: space-between;
  1929. .line-select {
  1930. margin-left: 15px;
  1931. }
  1932. }
  1933. </style>