detail.vue 52 KB

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