detail.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <el-form label-width="100px" ref="manageForm" :model="form" :rules="rules">
  5. <headerTitle title="基本信息">
  6. <el-button @click="cancel">返回</el-button>
  7. <el-button type="primary" @click="submit" :loading="loading">保存
  8. </el-button>
  9. </headerTitle>
  10. <el-row :gutter="24">
  11. <el-col :span="8">
  12. <el-form-item label="分类" prop="categoryLevelName">
  13. <el-input v-model="form.categoryLevelName" @click.native="openCategory" />
  14. </el-form-item>
  15. </el-col>
  16. <el-col :span="8">
  17. <el-form-item label="编码" prop="code">
  18. <el-input v-if="ruleCode == '自定义'" v-model="form.code" readonly @click.native="openCode"
  19. :disabled="status == 0" />
  20. <el-input v-else v-model="form.code" :disabled="status == 0" />
  21. </el-form-item>
  22. </el-col>
  23. <el-col :span="8">
  24. <el-form-item label="名称" prop="name">
  25. <el-input v-model="form.name" />
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="8">
  29. <el-form-item label="存货类型:" prop="attributeType">
  30. <el-select v-model="form.attributeType" filterable class="ele-block">
  31. <el-option v-for="item in attributeList" :key="item.value" :value="item.value"
  32. :label="item.label"></el-option>
  33. </el-select>
  34. </el-form-item>
  35. </el-col>
  36. <el-col :span="8">
  37. <div>
  38. <el-form-item label="属性类型" prop="componentAttribute">
  39. <el-select style="width: 100%" v-model="form.componentAttribute" filterable multiple>
  40. <el-option v-for="item in lbjtList" :key="item.value" :value="item.value"
  41. :label="item.label"></el-option>
  42. </el-select>
  43. </el-form-item>
  44. </div>
  45. </el-col>
  46. <el-col :span="8">
  47. <div>
  48. <el-form-item label="生产类型" prop="produceType"
  49. :rules="{
  50. required: form.categoryLevelPathId==9 ? true : false,
  51. message: '请选择生产类型',
  52. trigger: 'change'
  53. }"
  54. >
  55. <el-select style="width: 100%" v-model="form.produceType" filterable @change="produceTypeChange">
  56. <el-option v-for="item in dictList" :key="item.value" :value="item.value"
  57. :label="item.label"></el-option>
  58. </el-select>
  59. </el-form-item>
  60. </div>
  61. </el-col>
  62. <el-col :span="8">
  63. <!-- v-if="
  64. [1, 23, 9, 28].includes(
  65. Number(categoryLevelPathId || $route.query.rootTreeId)
  66. )
  67. " -->
  68. <el-form-item label="加工类型" prop="isConsumable">
  69. <el-select v-model="form.isConsumable" style="width: 100%" @change="changeConsumable">
  70. <el-option :value="1" label="批量"></el-option>
  71. <el-option :value="0" label="单件"></el-option>
  72. </el-select>
  73. </el-form-item>
  74. </el-col>
  75. <el-col :span="8">
  76. <el-form-item label="牌号" prop="brandNum">
  77. <el-input v-model="form.brandNum" />
  78. </el-form-item>
  79. </el-col>
  80. <el-col :span="8">
  81. <el-form-item label="型号" prop="modelType">
  82. <el-input v-model="form.modelType" />
  83. </el-form-item>
  84. </el-col>
  85. <el-col :span="8">
  86. <el-form-item label="规格" prop="specification">
  87. <el-input v-model="form.specification" @input="inputSpe" />
  88. </el-form-item>
  89. </el-col>
  90. <el-col :span="8">
  91. <el-form-item label="计量类型" prop="measureType">
  92. <el-select v-model="form.measureType" style="width: 100%" @change="changeMeasureType">
  93. <el-option v-for="item in measureTypeList" :key="item.value" :value="item.value"
  94. :label="item.label"></el-option>
  95. </el-select>
  96. </el-form-item>
  97. </el-col>
  98. <el-col :span="8">
  99. <el-form-item label="计量单位" prop="measuringUnit">
  100. <DictSelection dictName="计量单位" clearable v-model="form.measuringUnit" @change="changeUnit">
  101. </DictSelection>
  102. </el-form-item>
  103. </el-col>
  104. <el-col :span="8">
  105. <el-form-item label="重量单位" prop="weightUnit">
  106. <DictSelection dictName="重量单位" clearable v-model="form.weightUnit" @change="changeWeightUnit">
  107. </DictSelection>
  108. </el-form-item>
  109. </el-col>
  110. <el-col :span="8">
  111. <el-form-item label="包装单位" prop="packingUnit">
  112. <DictSelection dictName="包装单位" clearable v-model="form.packingUnit" @change="changeUnit">
  113. </DictSelection>
  114. </el-form-item>
  115. </el-col>
  116. <el-col :span="8">
  117. <el-form-item label="图号/件号" prop="imgCode">
  118. <el-input v-model="form.imgCode" />
  119. </el-form-item>
  120. </el-col>
  121. <el-col :span="8">
  122. <el-form-item label="毛重">
  123. <div class="form-line">
  124. <el-input v-model="form.roughWeight" @input="handleInput2" />
  125. </div>
  126. </el-form-item>
  127. </el-col>
  128. <el-col :span="8">
  129. <el-form-item label="净重" prop="netWeight"
  130. :rules="{ required: form.measuringUnit == form.weightUnit, trigger: ['blur', 'change'], message: '请输入净重', }">
  131. <div class="form-line">
  132. <el-input v-model="form.netWeight" @input="handleInput3" />
  133. </div>
  134. </el-form-item>
  135. </el-col>
  136. <el-col :span="8">
  137. <el-form-item label="体积">
  138. <div class="form-line">
  139. <el-input v-model="form.volume" style="width: calc(100% - 100px)" />
  140. <!-- @input="handleInput1" -->
  141. <DictSelection dictName="体积单位" clearable v-model="form.volumeUnit" style="width: 100px">
  142. </DictSelection>
  143. </div>
  144. </el-form-item>
  145. </el-col>
  146. <el-col :span="8">
  147. <el-form-item label="级别">
  148. <template>
  149. <el-select style="width: 100%" v-model="form.level" placeholder="请选择">
  150. <el-option v-for="item in levelOptions" :label="item.label" :value="item.value" :key="item.value">
  151. </el-option>
  152. </el-select>
  153. </template>
  154. </el-form-item>
  155. </el-col>
  156. <el-col :span="8">
  157. <el-form-item label="状态">
  158. <template>
  159. <el-switch v-model="form.isEnabled" :active-text="form.isEnabled == 1 ? '启用' : '停用'" :active-value="1"
  160. :inactive-value="0">
  161. </el-switch>
  162. </template>
  163. </el-form-item>
  164. </el-col>
  165. <el-col :span="8" v-for="(f, idx) in fileList" :key="idx">
  166. <el-form-item :label="f.label">
  167. <template>
  168. <div class="form-line">
  169. <component :is="f.tagType" v-model="form.extField[f.prop]" :disabled="f.extAttribute?.disabled"
  170. clearable :isProhibit="f.modelType == 'dict' ? f.extAttribute?.disabled : false
  171. " :dictName="f.modelType == 'dict' ? f.label : ''"></component>
  172. </div>
  173. </template>
  174. </el-form-item>
  175. </el-col>
  176. </el-row>
  177. </el-form>
  178. </el-card>
  179. <el-card shadow="never">
  180. <headerTitle title="标签"></headerTitle>
  181. <!-- {{ form.extTagField }} -->
  182. <el-form label-width="100px">
  183. <el-form-item label="是否消耗品">
  184. <el-radio-group v-model="form.extTagField.isConsumables">
  185. <el-radio :label="1">是</el-radio>
  186. <el-radio :label="0">否</el-radio>
  187. </el-radio-group>
  188. </el-form-item>
  189. </el-form>
  190. </el-card>
  191. <!-- 自定义编码 -->
  192. <CodeDialog ref="codeRefs" v-if="codeShow" @close="codeShow = false" @chooseCode="chooseCode" />
  193. <!-- 分类选择弹窗 -->
  194. <CategoryDialog ref="categoryRefs" @chooseCategory="confirmCategory" />
  195. <!-- 仓储配置 -->
  196. <WarehouseInfo ref="warehouseRefs" v-if="isShow" :form="categoryWms" :measuringUnit="form.measuringUnit"
  197. :packingUnit="form.packingUnit" :packageDispositionVOList="packageDispositionVOList"
  198. @change="changePackagingSpecification" />
  199. <!-- 销售配置 -->
  200. <SalesInfos ref="salesRefs" :form="categorySales" />
  201. <!-- 采购信息 -->
  202. <PurchasingInfo ref="PurchasingInfoRefs" :form="categoryPurchase" />
  203. <!-- 生产信息 -->
  204. <ProductionInfo ref="productionRefs" :form="categoryMes" />
  205. <!-- 计划 -->
  206. <PlanInfo ref="planRefs" :form="categoryAps" />
  207. <!-- 质量配置 -->
  208. <QualityInfo ref="qualityRefs" :form="categoryQms" />
  209. <!-- 舟皿信息 -->
  210. <BoatInfo ref="qualityRefs" :form="categoryPallet" />
  211. <!-- 周转车信息 -->
  212. <TurnoverInfo ref="turnoverRefs" :form="categoryVehicle" />
  213. <!-- 模具信息 -->
  214. <MoldInfo ref="moldRefs" :form="categoryMold" />
  215. <!-- 备注信息 -->
  216. <RemarkInfo ref="remarkRefs" :form="remarkform" />
  217. <!-- 关联信息 -->
  218. <linkMsg ref="linkMsgRef" :id="$route.query.id" :categoryLevelId="form.categoryLevelId"
  219. :categoryLevelGroupId="form.categoryLevelGroupId" :code="form.code" />
  220. </div>
  221. </template>
  222. <script>
  223. import SalesInfos from './components/SalesInfos.vue';
  224. import PurchasingInfo from './components/PurchasingInfo.vue';
  225. import GroupDialog from './components/GroupDialog.vue';
  226. import CodeDialog from './components/codeDialog.vue';
  227. import CategoryDialog from './components/CategoryDialog.vue';
  228. import WarehouseInfo from './components/WarehouseInfo.vue';
  229. import ProcureInfo from './components/ProcureInfo.vue';
  230. import ProductionInfo from './components/ProductionInfo.vue';
  231. import PlanInfo from './components/PlanInfo.vue';
  232. import SalesInfo from './components/SalesInfo.vue';
  233. import QualityInfo from './components/QualityInfo.vue';
  234. import BoatInfo from './components/BoatInfo.vue';
  235. import TurnoverInfo from './components/TurnoverInfo.vue';
  236. import MoldInfo from './components/MoldInfo.vue';
  237. import RemarkInfo from './components/RemarkInfo.vue';
  238. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  239. import personSelect from '@/components/CommomSelect/person-select.vue';
  240. import linkMsg from './components/link-msg.vue';
  241. import { getDetails } from '@/api/classifyManage/itemInformation';
  242. import { getByCode } from '@/api/system/dictionary-data';
  243. import { getCode, rootCategoryCode, fieldModel, checkExist } from '@/api/codeManagement';
  244. // /main/category/checkExist
  245. import { addMaterial } from '@/api/material/list.js';
  246. import { deepClone } from '@/utils/index';
  247. import { finishPageTab, reloadPageTab } from '@/utils/page-tab-util';
  248. export default {
  249. name: 'product',
  250. components: {
  251. SalesInfos,
  252. PurchasingInfo,
  253. linkMsg,
  254. GroupDialog,
  255. deptSelect,
  256. personSelect,
  257. WarehouseInfo,
  258. ProcureInfo,
  259. ProductionInfo,
  260. PlanInfo,
  261. SalesInfo,
  262. QualityInfo,
  263. BoatInfo,
  264. TurnoverInfo,
  265. MoldInfo,
  266. RemarkInfo,
  267. CategoryDialog,
  268. CodeDialog
  269. },
  270. data() {
  271. return {
  272. isShow: true,
  273. packagingSpecificationList: [],
  274. loading: false,
  275. measureTypeList: [
  276. {
  277. label: '数量',
  278. value: 1
  279. },
  280. {
  281. label: '重量',
  282. value: 2
  283. },
  284. {
  285. label: '体积',
  286. value: 3
  287. }, {
  288. label: '容积',
  289. value: 4
  290. },
  291. {
  292. label: '面积',
  293. value: 5
  294. },
  295. ],
  296. levelOptions: [
  297. {
  298. label: '特级',
  299. value: '特级'
  300. },
  301. {
  302. label: '一级',
  303. value: '一级'
  304. },
  305. {
  306. label: '二级',
  307. value: '二级'
  308. },
  309. {
  310. label: '三级',
  311. value: '三级'
  312. }
  313. ],
  314. isUpdate: 0,
  315. form: {
  316. categoryLevelGroupName: '',
  317. componentAttribute: [],
  318. categoryLevelName: '',
  319. isConsumable: 0,
  320. isEnabled: 1,
  321. measuringUnit: '',
  322. netWeight: '',
  323. attributeType: 1,
  324. weightUnit: '',
  325. packingUnit: '',
  326. extField: {},
  327. // isConsumables:2,
  328. extTagField: {
  329. isConsumables: 0,
  330. },
  331. },
  332. lbjtList: [
  333. {
  334. label: '自制件',
  335. value: 1
  336. },
  337. {
  338. label: '采购件',
  339. value: 2
  340. },
  341. {
  342. label: '外协件',
  343. value: 3
  344. }, {
  345. label: '受托件',
  346. value: 4
  347. }
  348. ],
  349. attributeList: [
  350. {
  351. label: '总装',
  352. value: 1
  353. },
  354. {
  355. label: '部件',
  356. value: 2
  357. },
  358. {
  359. label: '零件',
  360. value: 3
  361. }, {
  362. label: '原材料',
  363. value: 4
  364. }
  365. ],
  366. remarkform: {
  367. remarkAttach: []
  368. },
  369. categorySales: {},
  370. categoryPurchase: { purchaseMultiplier: 1, measuringUnit: '' },
  371. categoryAps: {},
  372. categoryMes: { productionDays: '1' },
  373. categoryMold: {},
  374. categoryPallet: {},
  375. categoryQms: {
  376. isComeCheck: '1'
  377. },
  378. categoryVehicle: {},
  379. categoryWms: {
  380. isUnpack: 1,
  381. isWarn: 1,
  382. inventoryMode: '',
  383. secureInventory: '1',
  384. minInventory: '1',
  385. maxInventory: '1',
  386. },
  387. packageDispositionVOList: [],
  388. categoryLevelPathId: null,
  389. dictList: [
  390. {
  391. label: '加工',
  392. value: 1
  393. },
  394. {
  395. label: '装配',
  396. value: 3
  397. },
  398. ],
  399. fileList: [],
  400. // 表单验证规则
  401. rules: {
  402. measureType: [
  403. { required: true, message: '请选择计量类型', trigger: 'change' }
  404. ],
  405. categoryLevelGroupName: [
  406. { required: true, message: '请选择所属物料组', trigger: 'change' }
  407. ],
  408. code: [{ required: true, message: '请输入编码', trigger: 'blur' }],
  409. name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
  410. // produceType: [
  411. // { required: true, message: '请选择生产类型', trigger: 'change' }
  412. // ],
  413. componentAttribute: [
  414. { required: true, message: '请选择属性类型', trigger: 'change' }
  415. ],
  416. attributeType: [
  417. { required: true, message: '请选择属性类型', trigger: 'change' }
  418. ],
  419. categoryLevelName: [
  420. { required: true, message: '请选择所属分类', trigger: 'change' }
  421. ],
  422. measuringUnit: [
  423. { required: true, message: '请选择计量单位', trigger: 'change' }
  424. ],
  425. weightUnit: [
  426. { required: true, message: '请选择重量单位', trigger: 'change' }
  427. ],
  428. packingUnit: [
  429. { required: true, message: '请选择包装单位', trigger: 'change' }
  430. ],
  431. netWeight: [
  432. { required: true, message: '请输入净重', trigger: 'blur' }
  433. ]
  434. },
  435. PathInfo: {},
  436. id: null,
  437. ruleCode: null,
  438. codeShow: false,
  439. status: null
  440. };
  441. },
  442. watch: {
  443. '$route.query.id': {
  444. handler(id) {
  445. if (id) {
  446. this._getDetails();
  447. } else {
  448. let { lyType } = this.$route.query;
  449. let arrId = '';
  450. if (lyType == "wp") {
  451. arrId = 3
  452. }
  453. if (lyType == "cp") {
  454. arrId = 1
  455. }
  456. this.form = {
  457. categoryLevelGroupName: '',
  458. // categoryLevelName: '',
  459. componentAttribute: [],
  460. isConsumable: 0,
  461. attributeType: arrId,
  462. measuringUnit: '',
  463. netWeight: '',
  464. weightUnit: '',
  465. packingUnit: '',
  466. extField: {},
  467. extTagField: {
  468. isConsumables: 0,
  469. },
  470. measureType: 1,
  471. isEnabled: 1,
  472. };
  473. this.isUpdate = 0;
  474. this.categorySales = {};
  475. this.purchaseInfo = {};
  476. this.remarkform = {
  477. remarkAttach: []
  478. };
  479. this.categoryAps = {};
  480. this.categoryMes = { productionDays: '20', isCompleteSet: 0, isModify: 0, isRework: 0, isRematerial: 0, isByProduct: 0, isWaste: 0, isDefective: 0 };
  481. this.categoryMold = {};
  482. this.categoryPallet = {};
  483. this.categoryQms = {};
  484. this.categoryVehicle = {};
  485. this.categoryWms = {
  486. isUnpack: 1,
  487. isWarn: 1,
  488. inventoryMode: this.form.isConsumable,
  489. minPackageCell: '',
  490. secureInventory: '10',
  491. minInventory: '10',
  492. maxInventory: '10',
  493. };
  494. this.packageDispositionVOList = [];
  495. this.categoryLevelPathId = null;
  496. // this.dictList = [];
  497. this.fileList = [];
  498. }
  499. },
  500. deep: true,
  501. immediate: true
  502. }
  503. },
  504. async activated() {
  505. this.status = this.$route.query.status;
  506. this.form.categoryLevelId = this.$route.query.categoryLevelId;
  507. this.form.categoryLevelName = this.$route.query.categoryLevelName;
  508. this.form.categoryLevelPath = this.$route.query.categoryLevelPath;
  509. this.form.categoryLevelPathId = this.$route.query.categoryLevelPathId;
  510. this.ruleCode = this.$route.query.ruleCode;
  511. if (this.ruleCode && this.ruleCode != '自定义' && this.status != 0) {
  512. const code = await getCode(this.ruleCode);
  513. this.$set(this.form, 'code', code);
  514. }
  515. this.getFieldModel();
  516. // this.getDictList('zeroPartPros');
  517. },
  518. async created() {
  519. //新增
  520. console.log('88888888');
  521. this.$set(
  522. this.form,
  523. 'categoryLevelId',
  524. this.$route.query.categoryLevelId
  525. );
  526. this.$set(
  527. this.form,
  528. 'isUpdate',
  529. this.$route.query.isUpdate
  530. );
  531. this.isUpdate = this.$route.query.isUpdate;
  532. this.$set(
  533. this.form,
  534. 'categoryLevelName',
  535. this.$route.query.categoryLevelName
  536. );
  537. this.$set(
  538. this.form,
  539. 'categoryLevelPath',
  540. this.$route.query.categoryLevelPath
  541. );
  542. this.$set(
  543. this.form,
  544. 'categoryLevelPathId',
  545. this.$route.query.categoryLevelPathId
  546. );
  547. this.status = this.$route.query.status;
  548. this.ruleCode = this.$route.query.ruleCode;
  549. if (this.ruleCode && this.ruleCode != '自定义' && this.status != 0) {
  550. const code = await getCode(this.ruleCode);
  551. this.$set(this.form, 'code', code);
  552. }
  553. this.getFieldModel();
  554. this.getDictList('zeroPartPros');
  555. },
  556. methods: {
  557. inputSpe(val) {
  558. if (this.form.measuringUnit == '立方') {
  559. if (!val || typeof val !== 'string') {
  560. this.form.volume = 0;
  561. return;
  562. };
  563. let modelArr = val.split('*');
  564. let modelLong = modelArr[0]; // model规格长度
  565. let modeWide = modelArr[1]; // model规格宽度
  566. let modeHight = modelArr[2]?.substr(0, modelArr[2].indexOf('cm')); // model规格高度
  567. modeHight = Number(modeHight);
  568. let aa = (modelLong * modeWide * modeHight) / 1000000;
  569. console.log(aa, 'aa')
  570. this.form.volume = aa;
  571. } else {
  572. this.form.volume = '';
  573. }
  574. },
  575. changeMeasureType() {
  576. if (this.form.measureType == 1) {
  577. this.$set(this.categoryWms, 'isUnpack', 1);
  578. } else {
  579. this.$set(this.categoryWms, 'isUnpack', 0);
  580. }
  581. },
  582. handleInput(value) {
  583. // this.form.volume = this.$handleInputPublicHasPoint(value);
  584. },
  585. handleInput2(value) {
  586. this.form.roughWeight = this.$handleInputPublicHasPoint(value);
  587. },
  588. handleInput3(value) {
  589. // this.form.netWeight = this.$handleInputPublicHasPoint(value);
  590. if (this.form.weightUnit == this.form.measuringUnit) {
  591. this.$refs.warehouseRefs.changeNetWeight(this.form.netWeight);
  592. }
  593. },
  594. changeConsumable() {
  595. this.$set(this.categoryWms, 'inventoryMode', this.form.isConsumable);
  596. },
  597. changeWeightUnit() {
  598. if (this.form.measuringUnit && this.form.packingUnit && this.form.netWeight) {
  599. this.$refs.warehouseRefs.changeNetWeight(this.form.netWeight);
  600. }
  601. },
  602. changeUnit() {
  603. if (this.$route.query.id == '' || this.$route.query.id == null) {
  604. if (this.form.measuringUnit) {
  605. // 计量单位是‘立方’ 体积单位默认是‘立方’
  606. if (this.form.measuringUnit == '立方' && this.form.specification != '') {
  607. this.form.volumeUnit = '立方';
  608. this.inputSpe(this.form.specification)
  609. } else {
  610. this.form.volume = 0;
  611. }
  612. this.categoryPurchase.measuringUnit = this.form.measuringUnit;
  613. console.log(this.categoryPurchase.measuringUnit, '采购信息');
  614. // 如果有计量单位和包装单位 默认添加包装组
  615. if (this.form.packingUnit) {
  616. this.$refs.warehouseRefs.defaultBuild(this.form.packingUnit);
  617. }
  618. }
  619. } else {
  620. this.isShow = false;
  621. if (this.form.measuringUnit) {
  622. this.categoryPurchase.measuringUnit = this.form.measuringUnit;
  623. if (this.form.packingUnit) {
  624. console.log(this.form.measuringUnit, 'this.form.measuringUnit');
  625. console.log(this.form.packingUnit, 'this.form.packingUnit');
  626. if (this.packageDispositionVOList.length === 0) {
  627. console.log('如果没有包装组');
  628. this.$refs.warehouseRefs.defaultBuild(this.form.packingUnit);
  629. }
  630. }
  631. }
  632. this.isShow = true;
  633. }
  634. },
  635. changePackagingSpecification(val) {
  636. this.packagingSpecificationList = val;
  637. },
  638. async _getDetails() {
  639. const data = await getDetails(this.$route.query.id);
  640. const info = deepClone(data);
  641. info.category.produceType = info.category.produceType[0];
  642. this.form = {
  643. ...info.category
  644. };
  645. // if (this.form.measuringUnit && this.form.packingUnit) {
  646. // this.$refs.warehouseRefs.defaultBuild(this.form.packingUnit);
  647. // }
  648. this.categoryLevelPathId = info.category.categoryLevelPathIdParent;
  649. this.judgeSet(info);
  650. if (this.status == 1) {
  651. rootCategoryCode(this.categoryLevelPathId).then((res) => {
  652. this.$set(this.form, 'code', res);
  653. });
  654. this.form.createTime = null;
  655. }
  656. this.$forceUpdate();
  657. },
  658. // 判断字段类型并赋值
  659. judgeSet(info) {
  660. console.log('info-------', info);
  661. if (typeof info.categoryAps == 'string') {
  662. this.categoryAps = {};
  663. } else {
  664. this.categoryAps = info.categoryAps;
  665. }
  666. if (typeof info.categoryMes == 'string') {
  667. this.categoryMes = {};
  668. } else {
  669. this.categoryMes = info.categoryMes;
  670. }
  671. if (typeof info.categoryMold == 'string') {
  672. this.categoryMold = {};
  673. } else {
  674. this.categoryMold = info.categoryMold;
  675. }
  676. if (typeof info.categoryPallet == 'string') {
  677. this.categoryPallet = {};
  678. } else {
  679. this.categoryPallet = info.categoryPallet;
  680. }
  681. if (typeof info.categorySales == 'string') {
  682. this.categorySales = {};
  683. } else {
  684. this.categorySales = info.categorySales;
  685. }
  686. if (typeof info.categoryPurchase == 'string') {
  687. this.categoryPurchase = {};
  688. } else {
  689. this.categoryPurchase = info.categoryPurchase;
  690. }
  691. if (typeof info.categoryQms == 'string') {
  692. this.categoryQms = {};
  693. } else {
  694. this.categoryQms = info.categoryQms;
  695. }
  696. if (typeof info.categoryVehicle == 'string') {
  697. this.categoryVehicle = {};
  698. } else {
  699. this.categoryVehicle = info.categoryVehicle;
  700. }
  701. if (typeof info.categoryWms == 'string') {
  702. this.categoryWms = {};
  703. } else {
  704. this.categoryWms = info.categoryWms;
  705. }
  706. if (typeof info.packageDispositionVOList == 'string') {
  707. this.packageDispositionVOList = [];
  708. } else {
  709. this.packageDispositionVOList = info.packageDispositionVOList;
  710. console.log(
  711. 'this.packageDispositionVOList---!!!----',
  712. this.packageDispositionVOList
  713. );
  714. }
  715. },
  716. getFieldModel() {
  717. fieldModel({ relevance: 't_main_category' }).then((res) => {
  718. this.fileList = res;
  719. if (!this.form.extTagField) {
  720. this.form.extTagField = {
  721. isConsumables: 0
  722. }; // 初始化动态模型属性
  723. }
  724. // this.$set(this.form.extTagField, 'isConsumables', 0); // 初始化动态模型属性
  725. this.fileList.forEach((f) => {
  726. this.$set(this.form.extField, f.prop, ''); // 初始化动态模型属性
  727. // this.$set(this.form.extTagField, f.prop, ''); // 初始化动态模型属性
  728. });
  729. });
  730. },
  731. // 确定分类
  732. async confirmCategory(node, title, PathInfo, ruleCode) {
  733. if (this.status != 0) {
  734. this.$set(this.form, 'code', null);
  735. }
  736. this.categoryLevelPathId = PathInfo.categoryLevelPathId.split(',')[0];
  737. if (title == '选择产品分类') {
  738. this.$set(this.form, 'productCategoryLevelName', node.name);
  739. this.$set(this.form, 'productCategoryLevelId', node.id);
  740. } else {
  741. this.$set(this.form, 'categoryLevelName', node.name);
  742. this.$set(this.form, 'categoryLevelId', node.id);
  743. this.$set(this.form, 'categoryLevelPath', node.name);
  744. this.$set(this.form, 'categoryLevelPathId', node.id);
  745. this.PathInfo = PathInfo;
  746. this.ruleCode = ruleCode;
  747. if (ruleCode && ruleCode != '自定义' && this.status != 0) {
  748. const code = await getCode(ruleCode);
  749. this.$set(this.form, 'code', code);
  750. }
  751. console.log(this.form,'this.form')
  752. }
  753. this.$forceUpdate();
  754. },
  755. async getDictList(code) {
  756. let { data: res } = await getByCode(code);
  757. console.log('res----', res);
  758. // this.lbjtList = res.map((item) => {
  759. // let values = Object.keys(item);
  760. // return {
  761. // value: Number(values[0]),
  762. // label: item[values[0]]
  763. // };
  764. // });
  765. },
  766. openCategory() {
  767. this.$refs.categoryRefs.open();
  768. },
  769. openCode() {
  770. this.codeShow = true;
  771. },
  772. chooseCode(code) {
  773. this.$set(this.form, 'code', code);
  774. this.codeShow = false;
  775. this.$forceUpdate();
  776. },
  777. cancel() {
  778. // finishPageTab();
  779. // this.$router.go(-1);
  780. if (this.$route.query.rootTreeId == 9) {
  781. this.$router.push({
  782. path: '/product/oneProduct',
  783. query: {
  784. categoryLevelId: this.form.categoryLevelId
  785. }
  786. });
  787. } else {
  788. this.$router.push({
  789. path: '/material/product',
  790. query: {
  791. categoryLevelId: this.form.categoryLevelId
  792. }
  793. });
  794. }
  795. },
  796. verifyDuplicate(obj) {
  797. return new Promise((resolve, reject) => {
  798. checkExist(obj).then((res) => {
  799. if (res) {
  800. console.log(res, 'res----');
  801. this.$confirm('系统已有相同的数据', '提示', {
  802. confirmButtonText: '确定',
  803. cancelButtonText: '取消',
  804. type: 'warning'
  805. }).then(() => {
  806. resolve(true);
  807. }).catch(() => {
  808. resolve(false);
  809. });
  810. } else {
  811. resolve(true);
  812. }
  813. });
  814. })
  815. },
  816. // 保存
  817. submit() {
  818. this.$refs.manageForm.validate(async (valid) => {
  819. if (!valid) return;
  820. let req = {
  821. name: this.form.name,
  822. modelType: this.form.modelType,
  823. specification: this.form.specification,
  824. isUpdate: this.isUpdate * 1 || 0
  825. }
  826. if (! await this.verifyDuplicate(req)) return;
  827. let productionValid = await this.$refs.productionRefs.getFormValid();
  828. let warehouseValid = await this.$refs.warehouseRefs.getFormValid();
  829. if (!valid || !productionValid || !warehouseValid) {
  830. return false;
  831. }
  832. let packageDispositionVOList = [];
  833. if (this.packagingSpecificationList.length > 0) {
  834. packageDispositionVOList = this.packagingSpecificationList.map(
  835. (item) => {
  836. let obj = {
  837. code: item.code,
  838. name: item.name
  839. };
  840. return [
  841. {
  842. ...obj,
  843. id: item.id0,
  844. sort: 0,
  845. status: item.status,
  846. packageCell: 1,
  847. packageUnit: item.packageUnit,
  848. conversionUnit: item.packageUnit
  849. },
  850. {
  851. ...obj,
  852. id: item.id1,
  853. sort: 1,
  854. packageCell: item.minPackageCell,
  855. packageUnit: item.packageUnit,
  856. conversionUnit: item.minConversionUnit,
  857. status: item.status
  858. },
  859. {
  860. ...obj,
  861. id: item.id2,
  862. sort: 2,
  863. packageCell: item.inPackageCell,
  864. packageUnit: item.minConversionUnit,
  865. conversionUnit: item.inConversionUnit,
  866. status: item.status
  867. },
  868. {
  869. ...obj,
  870. id: item.id3,
  871. sort: 3,
  872. packageCell: item.outPackageCell,
  873. packageUnit: item.inConversionUnit,
  874. conversionUnit: item.outConversionUnit,
  875. status: item.status
  876. }
  877. ];
  878. }
  879. );
  880. let packagingSpecificationList =
  881. this.packagingSpecificationList.filter(
  882. (item) => item.status == 1
  883. );
  884. this.form.extField.packingSpecification = packagingSpecificationList
  885. .map((item) => {
  886. return [
  887. `${item.minPackageCell}${item.packageUnit}/${item.minConversionUnit}`,
  888. `${item.inPackageCell}${item.minConversionUnit}/${item.inConversionUnit}`,
  889. `${item.outPackageCell}${item.inConversionUnit}/${item.outConversionUnit}`
  890. ];
  891. })
  892. .flat()
  893. .join(',');
  894. } else {
  895. this.form.extField.packingSpecification = '';
  896. }
  897. this.loading = true;
  898. // const imgList = this.remarkform.imgList;
  899. // const arr = [];
  900. // if (imgList.length) {
  901. // imgList.map((item) => {
  902. // arr.push(item.storePath);
  903. // });
  904. // this.form.remarkAttach = arr.join(',');
  905. // }
  906. // this.form.remark = this.remarkform.remark
  907. // ? this.remarkform.remark
  908. // : '';
  909. const data = {
  910. categorySales: this.categorySales,
  911. categoryPurchase: this.categoryPurchase,
  912. categoryWms: this.categoryWms,
  913. categoryAps: this.categoryAps,
  914. categoryMes: this.categoryMes,
  915. categoryMold: this.categoryMold,
  916. categoryPallet: this.categoryPallet,
  917. categoryQms: this.categoryQms,
  918. categoryVehicle: this.categoryVehicle,
  919. category: {
  920. ...this.form,
  921. ...this.remarkform,
  922. ...this.PathInfo
  923. },
  924. packageDispositionVOList: packageDispositionVOList.flat()
  925. };
  926. if (this.$route.query.status == 1) {
  927. data.categorySales.id = null;
  928. data.categoryPurchase.id = null;
  929. data.category.id = null;
  930. data.categoryWms.id = null;
  931. data.categoryAps.id = null;
  932. data.categoryMes.id = null;
  933. data.categoryMold.id = null;
  934. data.categoryPallet.id = null;
  935. data.categoryQms.id = null;
  936. data.categoryVehicle.id = null;
  937. data.packageDispositionVOList = data.packageDispositionVOList.map(
  938. (item) => {
  939. return {
  940. ...item,
  941. id: null
  942. };
  943. }
  944. );
  945. }
  946. data.category.produceType = data.category.produceType?[data.category.produceType]:[];
  947. addMaterial(data)
  948. .then((msg) => {
  949. this.loading = false;
  950. this.$message.success(msg);
  951. // reloadPageTab({ fullPath: '/material/product' });
  952. // this.$router.go(-1);
  953. this.cancel();
  954. // if (this.$route.query.rootTreeId == 9) {
  955. // this.$router.push({
  956. // path: '/product/oneProduct',
  957. // query: {
  958. // categoryLevelId: this.form.categoryLevelId
  959. // }
  960. // });
  961. // } else {
  962. // this.$router.push({
  963. // path: '/material/product',
  964. // query: {
  965. // categoryLevelId: this.form.categoryLevelId
  966. // }
  967. // });
  968. // }
  969. })
  970. .catch((e) => {
  971. this.loading = false;
  972. });
  973. });
  974. },
  975. //生产类型切换
  976. produceTypeChange(value){
  977. if(value==1){
  978. this.attributeList=[
  979. {
  980. label: '成品',
  981. value: 1
  982. },
  983. {
  984. label: '半成品',
  985. value: 2
  986. }, {
  987. label: '原材料',
  988. value: 4
  989. }
  990. ]
  991. this.form.attributeType=1
  992. }else{
  993. this.attributeList=[
  994. {
  995. label: '总装(成品)',
  996. value: 1
  997. },
  998. {
  999. label: '部件(半成品)',
  1000. value: 2
  1001. },
  1002. {
  1003. label: '零件',
  1004. value: 3
  1005. }, {
  1006. label: '原材料',
  1007. value: 4
  1008. }
  1009. ]
  1010. this.form.attributeType=1
  1011. }
  1012. }
  1013. }
  1014. };
  1015. </script>
  1016. <style lang="scss" scoped>
  1017. .ele-page-header {
  1018. border: none;
  1019. }
  1020. .body-top {
  1021. display: flex;
  1022. align-items: center;
  1023. justify-content: space-between;
  1024. background: #fff;
  1025. .top-left {
  1026. display: flex;
  1027. align-items: center;
  1028. justify-content: flex-start;
  1029. margin-left: -25px;
  1030. .el-form-item {
  1031. margin-bottom: 0;
  1032. }
  1033. }
  1034. }
  1035. .divider {
  1036. margin: 20px 0;
  1037. .title {
  1038. display: flex;
  1039. align-items: center;
  1040. margin-bottom: 10px;
  1041. div {
  1042. width: 8px;
  1043. height: 20px;
  1044. margin-right: 10px;
  1045. }
  1046. span {
  1047. font-size: 20px;
  1048. }
  1049. }
  1050. .ele-width {
  1051. width: 100%;
  1052. height: 2px;
  1053. }
  1054. }
  1055. .form-line {
  1056. display: flex;
  1057. align-items: center;
  1058. justify-content: space-between;
  1059. .line-select {
  1060. margin-left: 15px;
  1061. }
  1062. }
  1063. </style>