detail.vue 55 KB

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